:root {
  --green: #0f8f68;
  --green-dark: #087451;
  --green-soft: #e7f8ef;
  --blue: #1769aa;
  --blue-soft: #e8f3fb;
  --gold: #c79a2b;
  --ink: #102033;
  --muted: #64748b;
  --line: #dbe7ee;
  --bg: #f5faf8;
  --card: #ffffff;
  --danger: #b42318;
  --warning: #986600;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, Segoe UI, Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(15,143,104,.08), transparent 32rem),
    linear-gradient(180deg, #f8fcfb 0%, var(--bg) 44%, #eef6f5 100%);
  letter-spacing: 0;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
input, select, button, textarea { font: inherit; }

.ui-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  display: inline-block;
  vertical-align: -4px;
}

.auth-body { min-height: 100vh; background: #eef8f4 url("../backgrounds/medical-pattern.svg") center/520px repeat; }

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(320px, 520px);
  gap: 32px;
  align-items: center;
  padding: 32px;
  max-width: 1200px;
  margin: 0 auto;
}

.auth-visual {
  padding: 28px;
  color: #073b2d;
  border-radius: 8px;
}
.auth-visual img {
  width: min(520px, 100%);
  margin-bottom: 20px;
  filter: drop-shadow(0 24px 34px rgba(8, 116, 81, .13));
}
.auth-visual h1 { font-size: clamp(34px, 5vw, 64px); line-height: 1; margin: 0 0 16px; }
.auth-visual p { font-size: 18px; max-width: 620px; color: #315267; }
.auth-visual small { color: var(--green-dark); font-weight: 700; }

.auth-card, .panel, .stat-card, .license-panel {
  background: rgba(255,255,255,.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(13, 55, 69, .08);
  backdrop-filter: blur(8px);
}
.auth-card { padding: 30px; display: grid; gap: 16px; }
.auth-card.wide { max-height: 92vh; overflow: auto; }
.auth-card h2, .panel h2, .license-panel h2 { margin: 0 0 18px; }

label { display: grid; gap: 7px; color: #26384b; font-size: 14px; font-weight: 700; }
.field-label { display: block; margin-bottom: 7px; color: #26384b; font-size: 14px; font-weight: 700; }
input, select, textarea {
  width: 100%;
  border: 1px solid #cbd9e2;
  border-radius: 8px;
  min-height: 44px;
  padding: 10px 12px;
  background: linear-gradient(180deg, #fff, #fbfdfd);
  color: var(--ink);
  transition: border-color .14s ease, box-shadow .14s ease, background .14s ease;
}
textarea { min-height: 92px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 4px rgba(15,143,104,.14); background: #fff; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.product-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.product-builder { align-items: start; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: 18px; min-height: 18px; }
.form-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #fbfefd);
  padding: 16px;
  display: grid;
  gap: 14px;
  grid-column: span 2;
}
.form-section h3 { margin: 0; font-size: 17px; }
.form-submit-bar {
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}
.medicine-import-row {
  display: grid;
  grid-template-columns: minmax(240px, 1.2fr) minmax(240px, .8fr);
  gap: 14px;
}

.btn {
  border: 0;
  border-radius: 8px;
  min-height: 42px;
  padding: 10px 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 800;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease, background .12s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn.primary { background: linear-gradient(135deg, var(--green), var(--blue)); color: #fff; box-shadow: 0 10px 22px rgba(15, 143, 104, .2); }
.btn.ghost { border: 1px solid var(--line); color: var(--green-dark); background: #fff; }
.btn.danger { color: var(--danger); }
.btn.compact { min-height: 38px; padding: 8px 12px; }
.text-link { display: inline-block; margin-top: 14px; color: var(--blue); font-weight: 700; }

.app-body { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar {
  background:
    linear-gradient(180deg, rgba(255,255,255,.06), transparent 18rem),
    #06261f;
  color: #e9fff7;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 42px;
  aspect-ratio: 1;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--green), var(--gold));
  color: #fff;
  font-weight: 900;
}
.brand small, .user-chip span, table small { display: block; color: var(--muted); font-size: 12px; font-weight: 600; }
.sidebar .brand small { color: #aee7d1; }
.sidebar nav { display: grid; gap: 7px; }
.sidebar nav a, .logout {
  padding: 11px 12px;
  border-radius: 8px;
  color: #dff7ef;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar nav a .ui-icon, .logout .ui-icon { color: #86e2c0; }
.sidebar nav a:hover, .logout:hover,
.sidebar nav a.active {
  background: rgba(255,255,255,.11);
  color: #fff;
  box-shadow: inset 3px 0 0 #78e4bd;
}
.logout { margin-top: auto; }

.main { padding: 24px; min-width: 0; }
.topbar { display: flex; justify-content: space-between; gap: 18px; align-items: center; margin-bottom: 22px; }
.topbar h1 { margin: 4px 0 0; font-size: 28px; }
.eyebrow { margin: 0 0 6px; color: var(--green-dark); font-size: 12px; text-transform: uppercase; font-weight: 900; }
.user-chip { text-align: right; font-weight: 800; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }

.alert { padding: 12px 14px; border-radius: 8px; margin-bottom: 16px; border: 1px solid; }
.alert.success { background: #e9f9f1; color: var(--green-dark); border-color: #b8ead3; }
.alert.error { background: #fff1f0; color: var(--danger); border-color: #ffd2cc; }
.alert.warning { background: #fff8e1; color: var(--warning); border-color: #ffe39a; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.stat-card { padding: 18px; min-height: 124px; position: relative; overflow: hidden; }
.stat-card:before {
  content: "";
  position: absolute;
  inset: auto -30px -42px auto;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: rgba(15,143,104,.08);
}
.stat-card > .ui-icon {
  width: 40px;
  height: 40px;
  padding: 9px;
  border-radius: 8px;
  color: var(--green-dark);
  background: #e7f8ef;
  margin-bottom: 12px;
}
.stat-card span { color: var(--muted); font-weight: 800; }
.stat-card strong { display: block; margin-top: 12px; font-size: 26px; }
.stat-card.profit > .ui-icon { color: #8a6500; background: #fff2c2; }
.stat-card.stock > .ui-icon { color: var(--blue); background: #e8f3fb; }
.stat-card.expiry > .ui-icon { color: var(--danger); background: #fff1f0; }

.panel { padding: 20px; margin-bottom: 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.panel-head h2 { margin: 0; display: flex; align-items: center; gap: 9px; }
.panel-head h2 .ui-icon { color: var(--green-dark); }
.actions, .row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.mode-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fcfb;
  width: fit-content;
}
.row-actions form { margin: 0; }
.muted { color: var(--muted); }
.filters {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) repeat(4, minmax(150px, 1fr)) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 16px;
}
.pagination { color: var(--muted); font-weight: 800; margin-top: 14px; }
.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.summary-grid span {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfefd;
  color: var(--muted);
  font-weight: 800;
}
.summary-grid strong { display: block; margin-top: 8px; color: var(--ink); font-size: 22px; }
.catalog-row {
  display: grid;
  grid-template-columns: minmax(260px, .9fr) minmax(360px, 1.4fr);
  gap: 18px;
}
.catalog-row h2 small { display: block; color: var(--muted); font-size: 14px; margin-top: 5px; }
.catalog-note {
  border-left: 3px solid var(--gold);
  padding-left: 10px;
  color: #4d5f72;
}
.medicine-preview {
  border: 1px solid #cfe2dc;
  border-radius: 8px;
  background: #f7fcfa;
  padding: 12px;
  display: grid;
  gap: 4px;
  align-self: end;
}
.medicine-preview[hidden] { display: none; }
.medicine-preview span {
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}
.medicine-preview strong { font-size: 16px; }
.medicine-preview small, .medicine-preview em {
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
  font-weight: 700;
}
.medicine-picker-field {
  position: relative;
  min-width: 0;
}
.medicine-picker {
  position: relative;
  z-index: 20;
}
.medicine-picker-control {
  width: 100%;
  min-height: 52px;
  border: 1px solid #cbd9e2;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 9px 42px 9px 12px;
  display: grid;
  gap: 3px;
  text-align: left;
  position: relative;
}
.medicine-picker-control:after {
  content: "";
  position: absolute;
  right: 14px;
  top: 50%;
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: translateY(-65%) rotate(45deg);
}
.medicine-picker-control:hover,
.medicine-picker-control[aria-expanded="true"] {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(15,143,104,.12);
}
.medicine-picker-control span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 900;
}
.medicine-picker-control small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-weight: 700;
}
.medicine-picker-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: min(620px, 92vw);
  max-width: 100%;
  background: #fff;
  border: 1px solid #cbd9e2;
  border-radius: 8px;
  box-shadow: 0 20px 54px rgba(16, 32, 51, .18);
  padding: 10px;
  z-index: 1000;
}
.medicine-picker-search {
  margin-bottom: 8px;
  min-height: 40px;
}
.medicine-picker-results {
  display: grid;
  gap: 7px;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 2px;
}
.medicine-option {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  display: grid;
  gap: 5px;
  text-align: left;
}
.medicine-option:hover,
.medicine-option:focus {
  border-color: #b9ded3;
  background: #f3fbf8;
  outline: none;
}
.medicine-option-title {
  color: var(--ink);
  font-weight: 900;
  line-height: 1.25;
}
.medicine-option-generic {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.medicine-option-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.medicine-badge {
  border: 1px solid #d9e8ef;
  border-radius: 999px;
  background: #f8fbfd;
  color: #3f586f;
  padding: 3px 7px;
  font-size: 12px;
  font-weight: 900;
}
.medicine-option-empty {
  padding: 14px;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}
.selected-medicine-card {
  border: 1px solid #cfe2dc;
  border-radius: 8px;
  background: linear-gradient(135deg, #f7fcfa, #ffffff);
  padding: 12px;
  display: grid;
  gap: 5px;
  align-self: end;
}
.selected-medicine-card[hidden] { display: none; }
.selected-medicine-card span {
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}
.selected-medicine-card strong { font-size: 16px; line-height: 1.25; }
.selected-medicine-card small,
.selected-medicine-card em {
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
  font-weight: 700;
  line-height: 1.35;
}
.text-button {
  border: 0;
  background: transparent;
  color: var(--blue);
  padding: 0;
  justify-self: start;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}
.mini-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.mini-badges em {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #3f586f;
  background: #f8fbfd;
  padding: 4px 8px;
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}
.import-mini { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.panel-art {
  width: 124px;
  min-width: 96px;
  opacity: .95;
}
.hero-band, .report-head {
  margin-bottom: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, #ffffff, #eefaf6);
  border-radius: 8px;
  display: flex;
  gap: 16px;
  align-items: center;
}
.hero-band img, .report-head img { width: 72px; height: 72px; object-fit: contain; border-radius: 8px; background: #fff; border: 1px solid var(--line); }

.meter { height: 12px; border-radius: 999px; background: #e4edf2; overflow: hidden; }
.meter span { display: block; height: 100%; background: linear-gradient(90deg, var(--green), var(--gold)); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
table { background: #fff; }
th, td { padding: 13px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:hover { background: #f7fbfa; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .02em; background: #f8fbfd; }
.badge { display: inline-flex; padding: 5px 9px; border-radius: 999px; font-size: 12px; font-weight: 900; background: #edf3f6; }
.badge.active, .badge.trial { color: var(--green-dark); background: #e7f8ef; }
.badge.expired, .badge.suspended, .badge.invalid { color: var(--danger); background: #fff1f0; }

.empty { text-align: center; padding: 32px; }
.empty img { width: 160px; margin: 0 auto 12px; }
.empty p { color: var(--muted); }
.empty .btn { margin-top: 8px; }

.pos-layout { display: grid; grid-template-columns: minmax(420px, 0.9fr) minmax(520px, 1.7fr); gap: 18px; align-items: start; }
.pos-checkout-shell {
  display: grid;
  grid-template-columns: minmax(520px, 1fr) minmax(320px, 380px);
  gap: 18px;
  align-items: start;
}
.pos-cart,
.pos-workspace { align-self: start; display: grid; gap: 14px; overflow: hidden; }
.pos-summary {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 14px;
  background:
    linear-gradient(135deg, rgba(15,143,104,.09), transparent 46%),
    rgba(255,255,255,.98);
}
.summary-lines {
  display: grid;
  gap: 8px;
}
.summary-lines span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #f8fcfb;
}
.summary-lines small {
  color: var(--muted);
  font-weight: 800;
}
.summary-lines strong { color: var(--ink); }
.checkout-actions {
  display: grid;
  gap: 9px;
}
.checkout-actions .btn { width: 100%; }
.pos-products-panel { margin-top: 18px; }
.pos-search {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #f8fcfb, #fff);
  padding: 14px;
}
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.product-tile {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background:
    linear-gradient(135deg, rgba(15,143,104,.08), transparent 42%),
    #fbfefd;
  display: grid;
  gap: 5px;
  min-height: 128px;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease, background .12s ease;
}
.product-tile:hover,
.product-tile:focus {
  border-color: var(--green);
  box-shadow: 0 12px 28px rgba(15, 143, 104, .14);
  outline: none;
  transform: translateY(-1px);
}
.product-tile.just-added {
  border-color: var(--gold);
  background: #fffaf0;
  transform: scale(.99);
}
.product-tile:disabled {
  cursor: not-allowed;
  opacity: .58;
}
.product-tile span, .product-tile small { color: var(--muted); }
.product-tile b { color: var(--green-dark); }
.product-tile em {
  justify-self: start;
  border-radius: 999px;
  background: #e7f8ef;
  color: var(--green-dark);
  padding: 5px 9px;
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
}

.report-list { display: flex; flex-wrap: wrap; gap: 10px; }
.report-list span {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfefd;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.report-list .ui-icon { color: var(--green-dark); }
footer { margin-top: 20px; color: var(--muted); font-size: 12px; }
.danger-text { color: var(--danger); font-weight: 900; }
.compact-form {
  display: grid;
  grid-template-columns: 90px minmax(120px, 1fr) auto;
  gap: 8px;
  align-items: center;
}
.inline-maintenance {
  position: relative;
}
.inline-maintenance[open] {
  min-width: min(720px, 80vw);
}
.inline-maintenance > summary {
  list-style: none;
}
.inline-maintenance > summary::-webkit-details-marker { display: none; }
.cart-lines, .pos-results, .purchase-builder { display: grid; gap: 8px; }
.pos-results {
  max-height: 340px;
  overflow: auto;
  padding-right: 2px;
}
.cart-line, .purchase-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfefd;
}
.purchase-row { grid-template-columns: minmax(180px, 1.4fr) repeat(5, minmax(100px, 1fr)) auto; }
.cart-line small { display: block; color: var(--muted); }
.cart-line input, .purchase-row input, .purchase-row select { min-height: 36px; }
.cart-line-controls {
  display: grid;
  grid-template-columns: minmax(76px, .7fr) minmax(92px, .8fr) minmax(120px, 1fr) auto;
  gap: 8px;
  align-items: center;
}
.cart-line-controls input {
  min-width: 0;
}
.cart-line-controls b {
  color: var(--green-dark);
  white-space: nowrap;
}
.cart-total {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  font-size: 18px;
  font-weight: 900;
}
.cart-total strong {
  color: var(--green-dark);
  font-size: 24px;
}
.receipt {
  max-width: 760px;
  margin: 0 auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
}
.receipt-head { text-align: center; display: grid; justify-items: center; gap: 4px; margin-bottom: 18px; }
.receipt-head img { width: 72px; height: 72px; object-fit: contain; }
.receipt dl { margin-left: auto; max-width: 260px; }
.no-print { margin-top: 16px; }
@media print {
  .sidebar, .topbar, .alert, .no-print { display: none !important; }
  .app-body { display: block; }
  .main { padding: 0; }
  .receipt, .panel { border: 0; box-shadow: none; }
}

.license-panel { display: grid; grid-template-columns: 220px 1fr; gap: 28px; padding: 28px; align-items: center; }
dl { display: grid; grid-template-columns: 110px 1fr; gap: 9px; }
dt { color: var(--muted); font-weight: 800; }
dd { margin: 0; font-weight: 900; }

@media (max-width: 980px) {
  .auth-shell, .app-body, .pos-layout, .pos-checkout-shell, .license-panel { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .stat-grid, .product-form, .form-grid, .filters, .catalog-row, .import-mini { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pos-summary { position: static; }
  .span-4 { grid-column: span 2; }
}

@media (max-width: 640px) {
  .auth-shell, .main { padding: 16px; }
  .stat-grid, .product-form, .form-grid, .filters, .catalog-row, .import-mini, .summary-grid { grid-template-columns: 1fr; }
  .span-2, .span-3, .span-4, .form-section { grid-column: span 1; }
  .medicine-import-row { grid-template-columns: 1fr; }
  .medicine-picker-dropdown { width: 100%; }
  .cart-line, .purchase-row, .compact-form, .cart-line-controls { grid-template-columns: 1fr; }
  .topbar, .panel-head, .hero-band, .report-head { align-items: flex-start; flex-direction: column; }
  .topbar-actions { width: 100%; justify-content: space-between; }
  .user-chip { text-align: left; }
}

/* Patch 2026-06: staff/users and sale-control polish */
.status-pill.info { background: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; }
.status-pill.success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.status-pill.danger { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.status-pill.muted { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
.muted-row { opacity: .72; background: #f8fafc; }
.muted-text { color: #64748b; font-size: .9rem; }
.inline-form { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-top: .75rem; }
.inline-form input, .inline-form select { min-height: 42px; }
.checkbox-line { display: flex !important; flex-direction: row !important; gap: .55rem; align-items: center; min-height: 42px; }
.checkbox-line input { width: auto; }
.btn.danger, .btn.ghost.danger { color: #991b1b; border-color: #fecaca; background: #fff5f5; }
.btn.ghost.danger:hover { background: #fee2e2; }
@media (max-width: 640px) {
  .inline-form { display: grid; grid-template-columns: 1fr; }
  .inline-maintenance[open] { min-width: min(100%, 92vw); }
}

/* Cashier / POS staff role patch */
.field-hint {
  display: block;
  margin-top: 0.35rem;
  color: var(--muted, #6b7280);
  font-size: 0.82rem;
  line-height: 1.35;
}

/* Customer management + POS customer picker */
.customer-picker {
  position: relative;
  display: grid;
  gap: 0.55rem;
}

.customer-results {
  display: grid;
  gap: 0.35rem;
  max-height: 220px;
  overflow: auto;
}

.customer-result {
  width: 100%;
  border: 1px solid var(--border, #e5e7eb);
  background: #fff;
  border-radius: 14px;
  padding: 0.65rem 0.75rem;
  text-align: left;
  cursor: pointer;
  transition: 0.15s ease;
}

.customer-result:hover {
  border-color: var(--primary, #0f8f5f);
  background: #f0fdf4;
}

.customer-result strong,
.selected-customer-card strong {
  display: block;
  color: #0f172a;
}

.customer-result small,
.selected-customer-card small {
  display: block;
  margin-top: 0.15rem;
  color: var(--muted, #6b7280);
}

.customer-result.empty {
  cursor: default;
  background: #f8fafc;
  color: var(--muted, #6b7280);
}

.selected-customer-card {
  border: 1px solid #bbf7d0;
  background: #f0fdf4;
  border-radius: 16px;
  padding: 0.75rem;
}

.compact-hero {
  padding: 1.25rem;
}

/* Purchase & supplier balance patch */
.action-row { display:flex; gap:8px; flex-wrap:wrap; align-items:center; }
.detail-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:12px; margin-top:14px; }
.detail-grid > div { border:1px solid var(--line); border-radius:8px; background:#f8fbfd; padding:12px; }
.detail-grid p { margin:6px 0 0; color:var(--muted); }
.compact-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.compact-stats .stat-card { min-height:90px; }
.purchase-row { display:grid; grid-template-columns: minmax(180px,1.8fr) repeat(5,minmax(100px,1fr)) auto; gap:8px; align-items:end; margin-bottom:8px; padding:10px; border:1px solid var(--line); border-radius:8px; background:#fbfefd; }
.danger-zone { border-color:#ffd2cc; background:#fffafa; }
@media (max-width: 900px){ .detail-grid,.compact-stats { grid-template-columns:1fr 1fr; } .purchase-row { grid-template-columns:1fr; } }
@media (max-width: 520px){ .detail-grid,.compact-stats { grid-template-columns:1fr; } .action-row .btn { width:100%; } }

/* Purchase details UI hotfix: separate app view from invoice/print view */
.purchase-detail-hero {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  padding: 24px;
}
.purchase-detail-title h2 { margin: 6px 0 10px; }
.purchase-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  color: var(--muted);
}
.purchase-detail-meta strong { color: #0f172a; }
.purchase-detail-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.purchase-overview-grid {
  display: grid;
  grid-template-columns: minmax(260px, 1.4fr) repeat(4, minmax(140px, .8fr));
  gap: 14px;
  margin-bottom: 18px;
}
.purchase-info-card { min-height: 132px; }
.purchase-detail-list { display: grid; gap: 9px; margin-top: 10px; }
.detail-row { display: flex; gap: 7px; align-items: baseline; flex-wrap: wrap; }
.detail-label { color: var(--muted); font-weight: 900; }
.detail-value { color: #0f172a; }
.purchase-notes {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
  color: var(--muted);
}
.purchase-summary-card {
  min-height: 132px;
  display: grid;
  align-content: center;
  gap: 8px;
}
.purchase-summary-card span:first-child { color: var(--muted); font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: .03em; }
.purchase-summary-card strong { font-size: clamp(22px, 2.4vw, 31px); color: #0f172a; }
.purchase-summary-card small { color: var(--muted); font-weight: 700; }
.purchase-section-card { padding: 24px; }
.purchase-items-table td small { display: block; margin-top: 2px; color: var(--muted); }
.purchase-danger-compact {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  border-color: #fecaca;
  background: #fffafa;
}
.purchase-danger-compact h2 { margin: 3px 0; }
.purchase-cancelled-alert { margin-bottom: 18px; }
.purchase-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 3000;
  padding: 22px;
  align-items: center;
  justify-content: center;
}
.purchase-modal.is-open { display: flex; }
.purchase-modal__backdrop { position: absolute; inset: 0; background: rgba(15,23,42,.48); backdrop-filter: blur(3px); }
.purchase-modal__panel {
  position: relative;
  width: min(720px, 100%);
  max-height: min(90dvh, 760px);
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 24px 70px rgba(16,32,51,.24);
}
.purchase-modal__close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #0f172a;
  font-size: 24px;
  font-weight: 900;
  cursor: pointer;
}
.purchase-modal__actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
body.modal-open { overflow: hidden; }
.purchase-logo { max-width: 120px; max-height: 80px; object-fit: contain; }
.purchase-web-logo { width: 56px; height: 56px; object-fit: contain; }
@media (max-width: 1180px) {
  .purchase-overview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .purchase-info-card { grid-column: 1 / -1; }
}
@media (max-width: 700px) {
  .purchase-detail-hero, .purchase-danger-compact { flex-direction: column; align-items: stretch; }
  .purchase-detail-actions .btn, .purchase-danger-compact .btn { width: 100%; }
  .purchase-overview-grid { grid-template-columns: minmax(0, 1fr); }
  .purchase-section-card, .purchase-detail-hero { padding: 16px; }
  .purchase-modal { padding: 0; align-items: stretch; }
  .purchase-modal__panel { width: 100%; max-height: 100dvh; border-radius: 0; padding: 20px; }
  .purchase-modal__actions .btn { width: 100%; }
}
@media print {
  .app-sidebar, .app-topbar, .license-footer-strip, .topbar, .sidebar, .no-print, .purchase-modal, .menu-toggle, .sidebar-overlay, .sidebar-close { display: none !important; }
  .print-only { display: block !important; }
}

/* Barcode / label printing and scanner POS patch */
.scanner-hint {
  margin-top: 8px;
  padding: 9px 11px;
  border: 1px dashed rgba(15,143,104,.45);
  border-radius: 8px;
  background: #f0fbf6;
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 800;
}
.label-builder {
  display: grid;
  grid-template-columns: minmax(240px, 1.3fr) minmax(220px, 1fr) 120px repeat(3, minmax(120px, auto)) auto;
  gap: 12px;
  align-items: end;
}
.label-check {
  min-height: 44px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfefd;
}
.label-sheet-panel { overflow: visible; }
.label-print-header {
  display: none;
  margin-bottom: 12px;
  color: #111827;
  font-size: 12px;
}
.label-print-header span { display: block; color: #4b5563; font-weight: 600; }
.label-sheet {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  align-items: start;
}
.product-label {
  min-height: 168px;
  border: 1px dashed #9ca3af;
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  display: grid;
  gap: 4px;
  color: #111827;
  break-inside: avoid;
  page-break-inside: avoid;
}
.label-pharmacy {
  color: var(--green-dark);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.label-title { font-size: 15px; line-height: 1.1; }
.label-generic {
  color: #4b5563;
  font-size: 11px;
  line-height: 1.2;
  max-height: 28px;
  overflow: hidden;
}
.label-barcode {
  display: grid;
  place-items: center;
  min-height: 70px;
  margin-top: 2px;
}
.barcode-svg { width: 100%; height: auto; max-height: 78px; }
.label-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: #111827;
  font-size: 11px;
  font-weight: 800;
}
.label-batch-meta { color: #4b5563; }
@media (max-width: 980px) {
  .label-builder { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .label-builder { grid-template-columns: 1fr; }
  .label-check, .label-builder .btn { width: 100%; }
}
@media print {
  .label-sheet-panel { border: 0 !important; box-shadow: none !important; padding: 0 !important; }
  .label-print-header { display: block !important; }
  .label-sheet {
    grid-template-columns: repeat(2, 90mm);
    gap: 4mm;
  }
  .product-label {
    width: 90mm;
    min-height: 54mm;
    border: 1px dashed #777;
    box-shadow: none;
  }
  .barcode-svg { max-height: 24mm; }
}

/* Phone Camera Barcode Scanner POS Patch */
.pos-mobile-scan-actions {
  display: none;
  margin-top: 10px;
}
.phone-camera-scan-btn {
  width: 100%;
  min-height: 46px;
  justify-content: center;
  border-style: dashed;
  background: #f6fffb;
}
.phone-scanner-modal[hidden] { display: none !important; }
.phone-scanner-modal {
  position: fixed;
  z-index: 1400;
  inset: 0;
  display: grid;
  place-items: end center;
  padding: 18px;
}
.phone-scanner-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .64);
  backdrop-filter: blur(6px);
}
.phone-scanner-panel {
  position: relative;
  z-index: 1;
  width: min(560px, 100%);
  max-height: min(92dvh, 760px);
  overflow: auto;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 28px 90px rgba(15,23,42,.35);
  padding: 18px;
  display: grid;
  gap: 14px;
}
.phone-scanner-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.phone-scanner-head h2 { margin: 0; }
.phone-scanner-close { min-height: 40px; }
.phone-scanner-frame {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  background: #071a13;
  min-height: 320px;
  display: grid;
  place-items: center;
}
.phone-scanner-frame video {
  width: 100%;
  height: 100%;
  min-height: 320px;
  object-fit: cover;
  background: #071a13;
}
.phone-scanner-reticle {
  position: absolute;
  inset: 18%;
  border: 2px solid rgba(255,255,255,.92);
  border-radius: 18px;
  box-shadow: 0 0 0 999px rgba(0,0,0,.18), inset 0 0 0 1px rgba(15,143,104,.75);
  pointer-events: none;
}
.phone-scanner-reticle::before {
  content: "";
  position: absolute;
  left: 10%;
  right: 10%;
  top: 50%;
  border-top: 2px solid rgba(16,185,129,.95);
  box-shadow: 0 0 18px rgba(16,185,129,.85);
}
.phone-scanner-status {
  margin: 0;
  padding: 11px 13px;
  border-radius: 12px;
  background: #eefbf5;
  color: var(--green-dark);
  font-weight: 800;
}
.phone-scanner-status[data-mode="success"] { background: #e8fff5; color: #047857; }
.phone-scanner-status[data-mode="error"] { background: #fff1f2; color: #be123c; }
.phone-scanner-manual {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}
body.scanner-open { overflow: hidden; }
@media (max-width: 767px) {
  .pos-mobile-scan-actions { display: block; }
  .phone-scanner-modal {
    padding: 0;
    place-items: stretch;
  }
  .phone-scanner-panel {
    width: 100%;
    max-height: 100dvh;
    border-radius: 22px 22px 0 0;
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  }
  .phone-scanner-frame,
  .phone-scanner-frame video { min-height: min(54dvh, 420px); }
  .phone-scanner-manual { grid-template-columns: 1fr; }
  .phone-scanner-manual .btn { width: 100%; }
}
@media (min-width: 768px) {
  .phone-camera-scan-btn { display: none !important; }
}

/* Phone Camera Scanner Fallback Hotfix */
.phone-camera-reader {
  width: 100%;
  min-height: 320px;
  display: grid;
  place-items: center;
  background: #071a13;
  color: #ffffff;
}
.phone-camera-reader[hidden],
.phone-scanner-native[hidden] {
  display: none !important;
}
.phone-camera-reader video,
.phone-camera-reader canvas {
  max-width: 100% !important;
  border-radius: 16px;
}
.phone-camera-reader__scan_region,
#phone-camera-reader__scan_region {
  display: grid;
  place-items: center;
}
#phone-camera-reader__dashboard_section,
#phone-camera-reader__header_message,
#phone-camera-reader__dashboard_section_csr,
#phone-camera-reader__dashboard_section_swaplink {
  font-family: inherit !important;
}
@media (max-width: 767px) {
  .phone-camera-reader { min-height: min(54dvh, 420px); }
}

/* Phone Camera Scanner Detection Hotfix */
.phone-scanner-frame {
  min-height: 360px;
}
.phone-scanner-reticle {
  inset: auto 6% auto 6%;
  top: 50%;
  height: 150px;
  transform: translateY(-50%);
  border-radius: 14px;
}
.phone-scanner-reticle::after {
  content: "Keep barcode horizontal here";
  position: absolute;
  left: 50%;
  bottom: -30px;
  transform: translateX(-50%);
  white-space: nowrap;
  color: #ffffff;
  background: rgba(0, 0, 0, .52);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 800;
}
.phone-camera-reader,
.phone-camera-reader video {
  width: 100% !important;
  min-height: 360px;
}
.phone-camera-reader video {
  object-fit: cover;
}
#phone-camera-reader__scan_region img {
  display: none !important;
}
@media (max-width: 767px) {
  .phone-scanner-frame,
  .phone-camera-reader,
  .phone-camera-reader video { min-height: min(58dvh, 460px); }
  .phone-scanner-reticle { left: 5%; right: 5%; height: 142px; }
}

/* Larger barcode labels for phone-camera readability */
.product-label { min-height: 184px; }
.label-barcode { min-height: 88px; }
.barcode-svg { max-height: 96px; }
@media print {
  .product-label { min-height: 58mm; }
  .barcode-svg { max-height: 28mm; }
}

/* Phone camera reliability hotfix: QR-first scanning */
.label-scan-zone {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  margin-top: 4px;
}
.label-qr {
  display: grid;
  place-items: center;
  padding: 4px;
  background: #fff;
  border: 1px solid #111827;
  border-radius: 6px;
}
.qr-code-svg {
  width: 100%;
  height: auto;
  display: block;
}
.label-scan-text {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.label-scan-caption {
  color: #047857;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .08em;
}
.label-scan-text strong {
  font-size: 12px;
  line-height: 1.15;
  word-break: break-word;
}
.label-barcode-secondary {
  min-height: 42px;
  opacity: .9;
}
.label-barcode-secondary .barcode-svg { max-height: 46px; }
.phone-scanner-reticle {
  width: min(72vw, 290px);
  height: min(72vw, 290px);
  left: 50%;
  right: auto;
  top: 50%;
  transform: translate(-50%, -50%);
  border-radius: 18px;
}
.phone-scanner-reticle::before {
  left: 12%;
  right: 12%;
  top: 50%;
}
.phone-scanner-reticle::after {
  content: "Put QR code inside this box";
}
@media print {
  .product-label { min-height: 62mm; }
  .label-scan-zone { grid-template-columns: 29mm 1fr; gap: 2.5mm; }
  .label-qr { padding: 1mm; border-radius: 1.5mm; }
  .label-barcode-secondary .barcode-svg { max-height: 13mm; }
}

/* Factory barcode + internal SKU label metadata */
.label-meta {
  flex-wrap: wrap;
}
.label-scan-caption {
  letter-spacing: .05em;
}
