/* ============================================================
   MedStock Pro — Professional Styles
   Designed for ease of use — even for a 10-year-old
   ============================================================ */

:root {
  --ink: #14242D;
  --ink-2: #203640;
  --paper: #EEF2F4;
  --panel: #FFFFFF;
  --panel-soft: #F8FAFB;
  --amber: #B5651D;
  --amber-deep: #7A4419;
  --amber-light: #FDF8F4;
  --blue: #246B8F;
  --line: #D9E0E4;
  --alert: #B72E25;
  --alert-bg: #FBEAE8;
  --ok: #2E6B4F;
  --ok-bg: #E7F1EC;
  --warn: #8A5A0C;
  --warn-bg: #FBF0DD;
  --muted: #5C6B75;
  --shadow: 0 1px 2px rgba(20,36,45,0.06), 0 8px 24px rgba(20,36,45,0.07);
  --radius: 14px;
  --radius-sm: 9px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.5;
}

.mono { font-family: 'Consolas', 'Courier New', monospace; }
.muted { color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); margin-top: 10px; line-height: 1.5; }

/* ===================== AUTH SCREEN ===================== */
.auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #14242D 0%, #1a3a4a 50%, #0E1B22 100%);
  padding: 20px;
}

.auth-container {
  width: 100%;
  max-width: 480px;
}

.auth-brand {
  text-align: center;
  margin-bottom: 30px;
}

.auth-logo {
  width: 64px;
  height: 64px;
  background: var(--amber);
  border-radius: 16px;
  margin: 0 auto 16px;
  position: relative;
  box-shadow: 0 10px 30px rgba(181,101,29,0.3);
}

.auth-logo::before, .auth-logo::after {
  content: '';
  position: absolute;
  background: var(--ink);
  border-radius: 3px;
}

.auth-logo::before {
  width: 32px; height: 8px;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
}

.auth-logo::after {
  width: 8px; height: 32px;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
}

.auth-brand h1 {
  color: #fff;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.auth-brand p {
  color: rgba(255,255,255,0.6);
  font-size: 13px;
  margin-top: 4px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.auth-card {
  background: #fff;
  border-radius: 20px;
  padding: 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.auth-card h2 {
  font-size: 22px;
  margin-bottom: 6px;
  color: var(--ink);
}

.auth-card .auth-sub {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 24px;
}

.auth-field {
  margin-bottom: 16px;
}

.auth-field label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.auth-field input, .auth-field textarea, .auth-field select {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: #fff;
  color: var(--ink);
}

.auth-field input:focus, .auth-field textarea:focus, .auth-field select:focus {
  outline: none;
  border-color: var(--amber);
  box-shadow: 0 0 0 4px rgba(181,101,29,0.1);
}

.auth-field textarea {
  resize: vertical;
  min-height: 60px;
}

.auth-divider {
  border: none;
  border-top: 1px dashed var(--line);
  margin: 20px 0;
}

.auth-divider-label {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 16px 0;
}

.auth-error {
  background: var(--alert-bg);
  color: var(--alert);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 16px;
  display: none;
}

.auth-success {
  background: var(--ok-bg);
  color: var(--ok);
  padding: 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  display: none;
}

.cred-box {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin: 10px 0;
}

.cred-box p {
  margin: 4px 0;
  font-size: 13px;
}

.cred-box code {
  background: #F4F5F6;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 700;
}

.cred-note {
  font-size: 12px;
  color: var(--warn);
  font-weight: 700;
  margin-top: 8px;
}

.auth-toggle {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--muted);
}

.auth-toggle a {
  color: var(--amber);
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}

.auth-toggle a:hover { text-decoration: underline; }

.optional-badge {
  display: inline-block;
  background: #EEF2F4;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  vertical-align: middle;
}

/* ===================== ADMIN PANEL ===================== */
.admin-screen {
  display: none;
  padding: 30px;
  max-width: 900px;
  margin: 0 auto;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
}

.admin-header h2 {
  font-size: 26px;
}

.admin-user-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
  gap: 12px;
  flex-wrap: wrap;
}

.admin-user-card.restricted {
  border-left: 4px solid var(--alert);
  opacity: 0.75;
  background: #FFF8F8;
}

.admin-user-name {
  font-size: 17px;
  font-weight: 800;
  margin-bottom: 4px;
}

.admin-user-detail {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.admin-user-creds code {
  background: #F4F5F6;
  padding: 3px 10px;
  border-radius: 5px;
  font-size: 12px;
  margin-right: 8px;
}

.admin-user-date {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

.empty-admin {
  text-align: center;
  padding: 40px;
  color: var(--muted);
  font-size: 14px;
}

/* ===================== APP SHELL ===================== */
.app-shell {
  display: none;
  grid-template-columns: 250px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, var(--ink) 0%, #0E1B22 100%);
  color: #EAEFF1;
  padding: 22px 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  padding: 0 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  margin-bottom: 8px;
}

.brand .mark {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand .cross {
  width: 32px;
  height: 32px;
  background: var(--amber);
  border-radius: 8px;
  position: relative;
  flex-shrink: 0;
  box-shadow: 0 6px 16px rgba(181,101,29,0.3);
}

.brand .cross::before, .brand .cross::after {
  content: '';
  position: absolute;
  background: var(--ink);
  border-radius: 2px;
}

.brand .cross::before { width: 16px; height: 4px; top: 50%; left: 50%; transform: translate(-50%,-50%); }
.brand .cross::after { width: 4px; height: 16px; top: 50%; left: 50%; transform: translate(-50%,-50%); }

.brand h1 {
  font-size: 19px;
  color: #fff;
  font-weight: 800;
}

.brand p {
  font-size: 10px;
  color: #9FB0B8;
  margin-top: 3px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.nav {
  list-style: none;
  padding: 8px 12px;
  flex: 1;
}

.nav li { margin-bottom: 2px; }

.nav button {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: #C6D2D7;
  font-family: inherit;
  font-size: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.15s;
}

.nav button:hover { background: rgba(255,255,255,0.08); color: #fff; }

.nav button.active {
  background: var(--amber);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(181,101,29,0.25);
}

.nav button .nav-icon { font-size: 16px; width: 22px; text-align: center; }

.sidebar-foot {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,0.12);
  font-size: 12px;
  color: #8FA0A8;
}

.sidebar-foot .operator-name {
  font-weight: 700;
  color: #C6D2D7;
  font-size: 13px;
}

.sidebar-foot .pharmacy-name {
  margin-top: 2px;
  color: #9FB0B8;
}

.sidebar-logout {
  margin-top: 8px;
  padding: 8px 14px;
  background: rgba(255,255,255,0.08);
  border: none;
  border-radius: 8px;
  color: #C6D2D7;
  font-size: 12px;
  cursor: pointer;
  width: 100%;
  text-align: center;
  font-family: inherit;
  transition: background 0.15s;
}

.sidebar-logout:hover { background: rgba(183,46,37,0.3); color: #fff; }

/* ===================== SYNC STATUS ===================== */
.sync-status-container {
  padding: 12px 16px;
  margin: 8px 12px;
  background: rgba(255,255,255,0.05);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,0.1);
}

.sync-status-header {
  margin-bottom: 8px;
}

.connection-status {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}

.connection-status.online {
  background: rgba(46, 107, 79, 0.2);
  color: #4FBE84;
}

.connection-status.offline {
  background: rgba(183, 46, 37, 0.2);
  color: #FF6B5E;
}

.sync-status-info {
  font-size: 11px;
  color: #8FA0A8;
  margin-bottom: 8px;
}

.sync-pending {
  margin-bottom: 2px;
}

.sync-last {
  font-size: 10px;
  color: #6E838C;
}

.sync-actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.sync-actions .btn {
  font-size: 10px;
  padding: 5px 8px;
  background: rgba(255,255,255,0.08);
  color: #C6D2D7;
  border: 1px solid rgba(255,255,255,0.15);
}

.sync-actions .btn:hover {
  background: rgba(255,255,255,0.15);
  color: #fff;
}

.sync-actions .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.main-content {
  padding: 26px 34px 60px;
  max-width: 1260px;
  width: 100%;
  overflow-x: auto;
}

/* ===================== COMMON ===================== */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 22px;
  gap: 18px;
}

.topbar h2 {
  font-size: 26px;
  font-weight: 800;
  color: var(--ink);
}

.topbar .sub {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.section { display: none; }
.section.active { display: block; }

.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.kpi .label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 700;
  margin-bottom: 8px;
}

.kpi .value {
  font-size: 28px;
  font-weight: 800;
}

.kpi.alert .value { color: var(--alert); }
.kpi.ok .value { color: var(--ok); }
.kpi.warn .value { color: var(--warn); }

.kpi .delta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  overflow: hidden;
}

.card-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: #fff;
}

.card-head h3 {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
}

.card-body { padding: 0; }
.card-pad { padding: 16px 18px; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  text-align: left;
  background: #F7F8F9;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
  white-space: nowrap;
}

td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #FAFBFB; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  white-space: nowrap;
}

.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.alert { background: var(--alert-bg); color: var(--alert); }
.badge.blue { background: #E8F1F6; color: var(--blue); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.btn {
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--amber); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-blue { background: var(--blue); color: #fff; }
.btn-ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: #F2F4F5; }
.btn-danger { background: var(--alert); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-full { width: 100%; }

.search-row {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.search-row input, .search-row select {
  font-size: 14px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--line);
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s;
}

.search-row input { flex: 1; }

.search-row input:focus, .search-row select:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(181,101,29,0.08);
}

.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.field input, .field select, .field textarea {
  font-size: 14px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--line);
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
}

.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(181,101,29,0.08);
}

.pill-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.soft-pill {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.empty-state {
  text-align: center;
  padding: 36px 16px;
  color: var(--muted);
  font-size: 13px;
}

.expiry-strip {
  height: 6px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
  width: 60px;
}

.expiry-strip .fill { height: 100%; border-radius: 3px; }

/* ===================== QUICK ACTIONS ===================== */
.quick-actions-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 18px;
}

.quick-action-btn {
  padding: 20px 16px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  color: var(--ink);
}

.quick-action-btn:hover {
  border-color: var(--amber);
  background: var(--amber-light);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(181,101,29,0.1);
}

/* ===================== BILLING / POS ===================== */
.pos-grid {
  display: grid;
  grid-template-columns: 1fr 1.25fr;
  gap: 18px;
  align-items: start;
  min-width: 0;
}

.billing-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
}

.tool-box { display: flex; gap: 8px; align-items: center; }
.tool-box input {
  width: 100%;
  font-size: 14px;
  padding: 10px 12px;
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  outline: none;
}
.tool-box input:focus { border-color: var(--amber); }

.quick-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 10px 18px 14px;
  background: var(--panel-soft);
}

.quick-tag {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.quick-tag:hover { border-color: var(--amber); color: var(--ink); }

.item-picker { max-height: 500px; overflow-y: auto; }

.item-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.1s;
}

.item-row:hover { background: #FAFBFB; }
.item-row .name { font-weight: 700; font-size: 14px; }
.item-row .generic { font-size: 12px; color: var(--muted); margin-top: 2px; }
.item-row .meta { font-size: 11px; color: var(--muted); margin-top: 4px; display: flex; gap: 8px; flex-wrap: wrap; }
.item-row .price { font-weight: 800; font-size: 15px; }
.item-row .stock-line { font-size: 11px; color: var(--muted); margin-top: 4px; text-align: right; }

.add-chip {
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
}

.add-chip:hover { background: var(--amber); }

.bill-shell { position: sticky; top: 20px; min-width: 0; }

.bill-controls {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  overflow: hidden;
}

.control-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: #F8FAFB;
}

.control-title h3 { font-size: 14px; font-weight: 700; margin: 0; }

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 16px;
}

.field.span-2 { grid-column: span 2; }

@media (max-width: 900px) {
  .field-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  .field-grid { grid-template-columns: 1fr; }
  .field.span-2 { grid-column: 1; }
}

/* ===================== RECEIPT ===================== */
.receipt-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.receipt {
  padding: 28px;
  background: #fff;
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  color: #111;
  font-size: 15px;
  line-height: 1.5;
}

.invoice-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  border-bottom: 3px solid var(--ink);
  padding-bottom: 16px;
  margin-bottom: 16px;
}

.invoice-brand { display: flex; gap: 14px; align-items: flex-start; }
.invoice-logo { display: none; }

.rname {
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 0.3px;
  color: var(--ink);
  line-height: 1.1;
}

.rmeta {
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
  margin-top: 4px;
}

.invoice-chip { text-align: right; }
.invoice-chip .label { font-size: 11px; color: var(--muted); font-weight: 700; letter-spacing: 1px; text-transform: uppercase; }
.invoice-chip .number { font-family: 'Consolas', monospace; font-size: 22px; font-weight: 700; color: var(--ink); margin-top: 4px; }

.invoice-meta {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px 20px;
  border-bottom: 1px dashed #BFCBD2;
  padding: 12px 0 14px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.invoice-meta b { color: var(--ink); font-weight: 700; }

.rx-warning {
  display: none;
  background: var(--warn-bg);
  border: 1px solid #EED4AA;
  color: var(--warn);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 11.5px;
  font-weight: 700;
  margin-bottom: 10px;
}

.rx-warning.show { display: block; }

.receipt-empty {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 35px 10px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: #FAFBFC;
  font-family: 'Segoe UI', sans-serif;
}

.receipt-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  margin-top: 6px;
}

.receipt-table th {
  font-size: 11px;
  padding: 10px 8px;
  background: #F3F5F6;
  color: var(--muted);
  border-bottom: 2px solid var(--line);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
}

.receipt-table td {
  padding: 10px 8px;
  border-bottom: 1px solid #EEF1F2;
  vertical-align: top;
}

.receipt-table tr:hover td { background: transparent; }

.receipt-table .medicine {
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
  line-height: 1.3;
}

.receipt-table .batch {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
  line-height: 1.4;
}

.num-cell {
  text-align: right;
  font-family: 'Consolas', monospace;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 600;
}

.center { text-align: center; }

.totals {
  margin-top: 16px;
  border-top: 2px dashed #BFCBD2;
  padding-top: 14px;
}

.total-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  font-size: 14px;
  padding: 5px 0;
  color: var(--muted);
}

.total-row strong {
  color: var(--ink);
  font-family: 'Consolas', monospace;
  font-size: 14px;
}

.grand-total {
  background: var(--ink);
  color: #fff;
  border-radius: 12px;
  margin-top: 14px;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 800;
  font-size: 18px;
}

.grand-total span:last-child {
  font-family: 'Consolas', monospace;
  font-size: 24px;
  font-weight: 900;
}

.payment-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.pay-box {
  border: 2px solid var(--line);
  background: #FAFBFC;
  border-radius: 12px;
  padding: 12px 14px;
  text-align: center;
}

.pay-box .l {
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.pay-box .v {
  font-family: 'Consolas', monospace;
  font-weight: 700;
  font-size: 16px;
  margin-top: 4px;
  color: var(--ink);
}

.receipt-foot {
  text-align: center;
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
  margin-top: 20px;
  border-top: 2px dashed #BFCBD2;
  padding-top: 14px;
}

.barcode {
  font-family: 'Consolas', monospace;
  letter-spacing: 2px;
  font-size: 18px;
  color: #222;
  margin-top: 10px;
}

.qty-adj {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.qty-adj button {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.qty-adj button:hover {
  background: var(--amber-light);
  border-color: var(--amber);
  color: var(--amber);
}

.qty-adj button:active {
  background: var(--amber);
  color: #fff;
}

.qty-input {
  width: 50px;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  font-family: 'Consolas', monospace;
  padding: 4px 6px;
  border: 2px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  -moz-appearance: textfield;
}

.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.qty-input:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(181, 101, 29, 0.15);
}

.remove-x {
  color: var(--alert);
  cursor: pointer;
  font-size: 10px;
  margin-left: 3px;
  font-weight: 700;
}

.pay-methods {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 12px 14px 0;
}

.pay-method {
  text-align: center;
  padding: 10px 6px;
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  color: var(--muted);
  background: #fff;
  transition: all 0.15s;
}

.pay-method.selected {
  border-color: var(--amber);
  background: var(--amber-light);
  color: var(--amber-deep);
}

.receipt-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 14px 14px 16px;
}

.receipt-actions .wide { grid-column: 1 / -1; }

/* ===================== VENDORS ===================== */
.vendor-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}

.vendor-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.vendor-card .top {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.vendor-avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #E8F1F6;
  color: var(--blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  flex-shrink: 0;
}

.vendor-card h4 { font-size: 14px; margin: 0; }
.vendor-card .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.vendor-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px dashed var(--line);
  padding-top: 8px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

/* ===================== VENDOR MODAL ===================== */
.vendor-modal {
  position: fixed;
  inset: 0;
  background: rgba(20, 36, 45, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
  padding: 20px;
}

.vendor-modal-content {
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  width: 100%;
  max-width: 750px;
  max-height: 90vh;
  overflow-y: auto;
}

.vendor-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: #F8FAFB;
  border-radius: 20px 20px 0 0;
}

.vendor-modal-header h3 { margin: 0; font-size: 18px; font-weight: 800; }

.vendor-modal-body {
  padding: 20px 22px;
}

.vendor-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 22px;
  border-top: 1px solid var(--line);
  background: #F8FAFB;
  border-radius: 0 0 20px 20px;
}

/* ===================== AUDIT ===================== */
.audit-row {
  display: flex;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  align-items: flex-start;
}

.audit-row:last-child { border-bottom: none; }

.audit-time {
  font-family: 'Consolas', monospace;
  font-size: 11px;
  color: var(--muted);
  width: 80px;
  flex-shrink: 0;
  padding-top: 2px;
}

.audit-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}

.audit-icon.sale { background: var(--ok-bg); color: var(--ok); }
.audit-icon.edit { background: var(--warn-bg); color: var(--warn); }
.audit-icon.void { background: var(--alert-bg); color: var(--alert); }
.audit-icon.login { background: #E9EEF1; color: var(--muted); }

.audit-text .title { font-size: 14px; font-weight: 700; }
.audit-text .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ===================== BATCH UPLOAD ===================== */
.upload-steps {
  display: flex;
  gap: 14px;
  margin-bottom: 20px;
}

.upload-steps .step {
  flex: 1;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
}

.upload-steps .step .step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--amber);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  margin-bottom: 10px;
}

.upload-steps .step h4 { font-size: 14px; margin: 0 0 4px; }
.upload-steps .step p { font-size: 12px; color: var(--muted); margin: 0; line-height: 1.4; }

.upload-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 2px solid var(--line);
  margin-bottom: 18px;
}

.upload-tab {
  padding: 12px 22px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  color: var(--muted);
  border: none;
  background: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
  font-family: inherit;
}

.upload-tab.active {
  color: var(--amber-deep);
  border-bottom-color: var(--amber);
}

.upload-tab:hover { color: var(--ink); }

.upload-panel { display: none; }
.upload-panel.active { display: block; }

.drop-zone {
  border: 3px dashed #BFCBD2;
  border-radius: 20px;
  padding: 50px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: #FAFBFC;
  position: relative;
}

.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--amber);
  background: var(--amber-light);
}

.drop-zone .icon { font-size: 48px; margin-bottom: 12px; display: block; }
.drop-zone h3 { font-size: 18px; margin: 0 0 8px; }
.drop-zone p { font-size: 13px; color: var(--muted); margin: 0; }
.drop-zone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* OCR Progress */
.ocr-progress-bar {
  height: 8px;
  background: var(--line);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
}

.ocr-progress-fill {
  height: 100%;
  background: var(--amber);
  border-radius: 4px;
  transition: width 0.3s;
}

.ocr-progress-text {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

/* Batch Grid — stacked: image on top, form full-width below */
.batch-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

.image-preview-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.image-preview-card .preview-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: #F8FAFB;
}

.image-preview-card .preview-head h4 { margin: 0; font-size: 14px; }
.image-preview-card img { width: 100%; max-height: 280px; object-fit: contain; display: block; background: #F4F5F6; }

/* OCR Result Rows */
.ocr-row {
  padding: 14px 16px;
  border-bottom: 1px solid #EEF1F2;
  background: #fff;
}

.ocr-row:nth-child(even) { background: #FAFBFC; }
.ocr-row:last-child { border-bottom: none; }

.ocr-row-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.ocr-row-num {
  font-size: 13px;
  font-weight: 800;
  color: var(--amber);
  background: var(--amber-light);
  padding: 3px 12px;
  border-radius: 10px;
}

.ocr-fields {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  align-items: end;
}

.mini-field { display: flex; flex-direction: column; gap: 4px; }
.mini-field label { font-size: 10.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px; white-space: nowrap; }
.mini-field input, .mini-field select {
  font-size: 14px;
  padding: 9px 11px;
  border: 2px solid var(--line);
  border-radius: 8px;
  font-family: inherit;
  width: 100%;
  min-width: 0;
  outline: none;
  transition: border-color 0.15s;
}

.mini-field input:focus, .mini-field select:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(181,101,29,0.08);
}

.batch-actions {
  display: flex;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  background: #FAFBFC;
  flex-wrap: wrap;
  align-items: center;
}

/* Pending items */
.pending-batch-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid #EEF1F2;
  font-size: 13px;
}

.pending-batch-item:last-child { border-bottom: none; }
.pending-batch-item .med-name { font-weight: 700; margin-right: 8px; }
.pending-batch-item .med-detail { font-size: 11px; color: var(--muted); }

/* ===================== TOAST ===================== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--ink);
  color: #fff;
  padding: 14px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s;
  pointer-events: none;
  z-index: 100;
  max-width: 400px;
}

.toast.show { opacity: 1; transform: translateY(0); }

/* ===================== INSTALL BUTTON ===================== */
.install-btn {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: linear-gradient(135deg, #b5651d 0%, #8B4513 100%);
  color: #fff;
  border: none;
  border-radius: 50px;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(181, 101, 29, 0.35);
  transition: all 0.2s;
  animation: installPulse 2s ease-in-out infinite;
}

.install-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(181, 101, 29, 0.45);
  filter: brightness(1.1);
}

.install-btn:active {
  transform: scale(0.97);
}

.install-icon {
  font-size: 16px;
}

@keyframes installPulse {
  0%, 100% { box-shadow: 0 4px 16px rgba(181, 101, 29, 0.35); }
  50% { box-shadow: 0 4px 24px rgba(181, 101, 29, 0.55); }
}

@media (max-width: 640px) {
  .install-btn {
    top: auto;
    bottom: 20px;
    right: 20px;
    padding: 12px 20px;
    font-size: 15px;
  }
}

/* ===================== RESPONSIVE ===================== */
@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 12px; }
  .brand { padding: 0 10px 0 0; border-bottom: none; margin-bottom: 0; }
  .nav { display: flex; flex-wrap: wrap; padding: 0; gap: 4px; }
  .nav li { margin: 0; }
  .nav button { padding: 8px 12px; font-size: 12px; }
  .sidebar-foot { display: none; }
  .main-content { padding: 18px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .vendor-grid { grid-template-columns: repeat(2, 1fr); }
  .ocr-fields { grid-template-columns: repeat(3, 1fr); }
  .quick-actions-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .kpis { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; }
  .billing-tools { grid-template-columns: 1fr; }
  .pay-methods { grid-template-columns: repeat(2, 1fr); }
  .receipt-actions { grid-template-columns: 1fr; }
  .receipt-actions .wide { grid-column: auto; }
  .vendor-grid { grid-template-columns: 1fr; }
  .field-grid { grid-template-columns: 1fr; }
  .ocr-fields { grid-template-columns: 1fr 1fr; }
  .upload-steps { flex-direction: column; }
  .quick-actions-grid { grid-template-columns: 1fr; }
  .search-row { flex-direction: column; }
}

/* ===================== PRINT ===================== */
@media print {
  @page { size: 80mm auto; margin: 0; }
  html, body {
    width: 80mm;
    background: #fff !important;
    margin: 0 !important;
    padding: 0 !important;
    font-size: 10px !important;
  }
  .sidebar, .topbar, .kpis, .card:not(.print-target), .bill-controls,
  .pay-methods, .receipt-actions, .no-print, .toast,
  .pill-row, .search-row, .upload-tabs, .upload-panel,
  .batch-grid, .vendor-modal, .quick-tags, .billing-tools {
    display: none !important;
  }
  .app-shell { display: block !important; width: 80mm !important; }
  .main-content {
    padding: 0 !important;
    margin: 0 !important;
    max-width: 80mm !important;
    width: 80mm !important;
  }
  .pos-grid {
    display: block !important;
    width: 80mm !important;
    grid-template-columns: 1fr !important;
  }
  .bill-shell {
    position: static !important;
    width: 80mm !important;
  }
  .receipt-wrap {
    box-shadow: none !important;
    border: none !important;
    border-radius: 0 !important;
    margin: 0 !important;
    width: 80mm !important;
    max-width: 80mm !important;
  }
  .receipt {
    padding: 4mm 3mm !important;
    width: 80mm !important;
    font-size: 9px !important;
  }
  .invoice-top {
    flex-direction: column !important;
    text-align: center !important;
    border-bottom: 1px dashed #000 !important;
    padding-bottom: 3mm !important;
    gap: 2mm !important;
  }
  .invoice-chip { text-align: center !important; }
  .rname { font-size: 14px !important; }
  .rmeta { font-size: 8px !important; }
  .invoice-chip .label { font-size: 7px !important; }
  .invoice-chip .number { font-size: 12px !important; }
  .invoice-meta { font-size: 8px !important; gap: 1px 4px !important; }
  .receipt-table { font-size: 8px !important; }
  .receipt-table th { font-size: 7px !important; padding: 2px 0 !important; }
  .receipt-table td { padding: 2px 0 !important; }
  .receipt-table .medicine { font-size: 8.5px !important; }
  .receipt-table .batch { font-size: 7px !important; }
  .grand-total { font-size: 12px !important; padding: 3mm !important; }
  .grand-total span:last-child { font-size: 14px !important; }
  .payment-summary { grid-template-columns: repeat(3, 1fr) !important; gap: 2px !important; }
  .pay-box { padding: 2mm !important; }
  .pay-box .l { font-size: 7px !important; }
  .pay-box .v { font-size: 9px !important; }
  .receipt-foot { font-size: 8px !important; margin-top: 3mm !important; }
  .barcode { font-size: 12px !important; }
  .remove-x { display: none !important; }
  .qty-adj button { display: none !important; }
}
