/* ================================================================
   SIMS v6 — app.css  Complete Clean Build
   Slate Blue Theme — Professional, sober, elegant
   ================================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0 }

/* ── Variables ─────────────────────────────────────────────────*/
:root {
  --bg:        #f1f5f9;
  --surface:   #ffffff;
  --surface2:  #f8fafc;
  --surface3:  #f1f5f9;
  --border:    #e2e8f0;
  --border2:   #cbd5e1;

  --blue:      #3b82f6; --blue-d:   #2563eb; --blue-lt:  #eff6ff; --blue-bd:  #bfdbfe;
  --accent:    #3b82f6; --accent-d: #2563eb; --accent-lt:#eff6ff; --accent-bd:#bfdbfe;
  --green:     #16a34a; --green-lt: #f0fdf4; --green-bd: #bbf7d0;
  --red:       #dc2626; --red-lt:   #fef2f2; --red-bd:   #fecaca;
  --amber:     #d97706; --amber-lt: #fffbeb; --amber-bd: #fde68a;
  --purple:    #7c3aed; --purple-lt:#f5f3ff; --purple-bd:#ddd6fe;
  --teal:      #0f766e; --teal-lt:  #f0fdfa; --teal-bd:  #99f6e4;
  --slate:     #64748b;

  --sb:        #1e293b; --sb2: #0f172a;
  --sb-text:   rgba(255,255,255,.5);
  --sb-hover:  rgba(255,255,255,.07);
  --sb-active: rgba(59,130,246,.3);
  --sb-border: rgba(255,255,255,.07);

  --text:  #0f172a; --text2: #1e293b; --text3: #475569;
  --muted: #94a3b8; --muted2:#cbd5e1;

  --font:   'Inter', system-ui, -apple-system, sans-serif;
  --font-m: 'JetBrains Mono', 'Courier New', monospace;
  --font-h: 'Inter', system-ui, -apple-system, sans-serif;

  --r:  8px; --rl: 12px; --rx: 16px;

  --shadow-xs: 0 1px 2px rgba(15,23,42,.04);
  --shadow-sm: 0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
  --shadow:    0 4px 6px -1px rgba(15,23,42,.07), 0 2px 4px -2px rgba(15,23,42,.04);
  --shadow-md: 0 10px 15px -3px rgba(15,23,42,.08), 0 4px 6px -4px rgba(15,23,42,.04);
  --shadow-lg: 0 20px 25px -5px rgba(15,23,42,.1), 0 8px 10px -6px rgba(15,23,42,.05);

  --sidebar-w: 252px;
  --header-h:  56px;
  --t: .15s ease;
}

/* ── Base ──────────────────────────────────────────────────────*/
html { font-size: 14px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth }
body { background: var(--bg); color: var(--text); font-family: var(--font); line-height: 1.6; -webkit-font-smoothing: antialiased }
a    { color: inherit; text-decoration: none }
img  { max-width: 100%; display: block }
button, input, select, textarea { font-family: var(--font) }

::-webkit-scrollbar       { width: 4px; height: 4px }
::-webkit-scrollbar-track { background: transparent }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 99px }

/* ── Layout ────────────────────────────────────────────────────*/
.layout  { display: flex; min-height: 100vh }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column }

/* ── Sidebar ───────────────────────────────────────────────────*/
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: var(--sb);
  display: flex; flex-direction: column;
  height: 100vh; position: sticky; top: 0;
  z-index: 100; overflow: hidden; transition: transform var(--t);
}
.sidebar.sa-sidebar { background: var(--sb2) }

.sidebar-logo {
  padding: 18px 16px 14px; border-bottom: 1px solid var(--sb-border);
  display: flex; align-items: center; justify-content: space-between;
}
.sidebar-logo-inner { display: flex; align-items: center; gap: 10px }
.logo-mark { width: 30px; height: 30px; background: var(--blue); border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0 }
.logo-mark svg { width: 15px; height: 15px; stroke: #fff; fill: none; stroke-width: 2 }
.logo-text     { font-size: 15px; font-weight: 600; color: #fff; letter-spacing: -.01em }
.logo-sa-badge { font-size: 9px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; background: rgba(255,255,255,.1); color: rgba(255,255,255,.6); padding: 2px 7px; border-radius: 99px }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 10px; scrollbar-width: none }
.sidebar-nav::-webkit-scrollbar { display: none }

.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 10px; border-radius: var(--r);
  font-size: 13px; font-weight: 450; color: var(--sb-text);
  transition: all var(--t); cursor: pointer; white-space: nowrap; margin-bottom: 1px;
  border: none; background: none; width: 100%; text-align: left; text-decoration: none;
}
.nav-item svg { width: 15px; height: 15px; flex-shrink: 0; opacity: .7; transition: opacity var(--t); stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round }
.nav-item:hover     { color: #fff; background: var(--sb-hover) }
.nav-item:hover svg { opacity: 1 }
.nav-item.active    { color: #fff; background: var(--sb-active); font-weight: 500 }
.nav-item.active svg { opacity: 1 }
.nav-item.sa-active { color: #fff; background: rgba(124,58,237,.3); font-weight: 500 }

.sidebar-footer { padding: 8px 10px 12px; border-top: 1px solid var(--sb-border) }
.user-info { padding: 10px 10px 8px }
.user-name { font-size: 13px; font-weight: 500; color: #fff }
.user-shop { font-size: 11px; color: rgba(255,255,255,.35); margin-top: 1px }
.user-role { display: inline-block; font-size: 10px; font-weight: 500; color: rgba(255,255,255,.4); margin-top: 5px; background: rgba(255,255,255,.08); padding: 2px 8px; border-radius: 99px }

.trial-notice { margin: 0 10px 8px; padding: 8px 10px; background: rgba(217,119,6,.12); border: 1px solid rgba(217,119,6,.2); border-radius: var(--r); font-size: 11px; color: #fbbf24; line-height: 1.5 }

/* ── Mobile header & overlay ───────────────────────────────────*/
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 99 }
.mobile-header   { display: none; background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 16px; height: var(--header-h); align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 50; box-shadow: var(--shadow-xs) }
.hamburger       { background: none; border: 1px solid var(--border); cursor: pointer; padding: 7px 8px; border-radius: var(--r); color: var(--text3); display: flex; align-items: center; justify-content: center; transition: all var(--t) }
.hamburger:hover { background: var(--surface2) }
.hamburger svg   { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2 }
.mobile-logo     { font-size: 15px; font-weight: 600; color: var(--text); letter-spacing: -.01em }

/* ── Banners ───────────────────────────────────────────────────*/
.impersonate-bar { background: var(--amber-lt); border-bottom: 1px solid var(--amber-bd); padding: 7px 20px; display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: #92400e; flex-wrap: wrap; gap: 8px }
.license-banner  { padding: 7px 20px; display: flex; align-items: center; justify-content: space-between; font-size: 12px; font-weight: 500; border-bottom: 1px solid; flex-wrap: wrap; gap: 6px }
.license-banner.warning { background: var(--amber-lt); border-color: var(--amber-bd); color: #92400e }
.license-banner.danger  { background: var(--red-lt);   border-color: var(--red-bd);   color: #991b1b }

/* ── Page ──────────────────────────────────────────────────────*/
.page       { padding: 26px; flex: 1 }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px }
.page-title { font-size: 20px; font-weight: 600; color: var(--text); letter-spacing: -.02em; line-height: 1.2 }
.page-sub   { font-size: 13px; color: var(--muted); margin-top: 3px }

/* ── Stat cards ────────────────────────────────────────────────*/
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 22px }
.stat-card  { background: var(--surface); border: 1px solid var(--border); border-radius: var(--rl); padding: 16px; box-shadow: var(--shadow-xs); transition: box-shadow var(--t), transform var(--t); min-width: 0 }
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-1px) }
.stat-icon  { width: 34px; height: 34px; border-radius: 9px; background: var(--blue-lt); display: flex; align-items: center; justify-content: center; margin-bottom: 12px }
.stat-icon svg { width: 16px; height: 16px; stroke: var(--blue); fill: none; stroke-width: 1.75; stroke-linecap: round }
.stat-card.green  .stat-icon { background: var(--green-lt) } .stat-card.green  .stat-icon svg { stroke: var(--green) }
.stat-card.red    .stat-icon { background: var(--red-lt)   } .stat-card.red    .stat-icon svg { stroke: var(--red)   }
.stat-card.amber  .stat-icon { background: var(--amber-lt) } .stat-card.amber  .stat-icon svg { stroke: var(--amber) }
.stat-card.blue   .stat-icon { background: var(--blue-lt)  } .stat-card.blue   .stat-icon svg { stroke: var(--blue)  }
.stat-card.purple .stat-icon { background: var(--purple-lt)} .stat-card.purple .stat-icon svg { stroke: var(--purple)}
.stat-card.slate  .stat-icon { background: var(--surface3) } .stat-card.slate  .stat-icon svg { stroke: var(--slate) }
.stat-label { font-size: 11px; font-weight: 500; color: var(--muted); letter-spacing: .01em; margin-bottom: 5px }
.stat-value { font-size: 22px; font-weight: 600; color: var(--text); letter-spacing: -.02em; line-height: 1 }
.stat-sub   { font-size: 11px; color: var(--muted); margin-top: 5px }
.stat-up    { color: var(--green) }
.stat-down  { color: var(--red) }

/* ── Cards ─────────────────────────────────────────────────────*/
.card        { background: var(--surface); border: 1px solid var(--border); border-radius: var(--rl); box-shadow: var(--shadow-xs) }
.card-body   { padding: 20px }
.card-header { padding: 12px 18px; border-bottom: 1px solid var(--border); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--text3); display: flex; align-items: center; justify-content: space-between; background: var(--surface2); border-radius: var(--rl) var(--rl) 0 0 }
.mb-3 { margin-bottom: 20px } .mb-2 { margin-bottom: 12px }
.mt-3 { margin-top: 20px }    .mt-2 { margin-top: 12px }

/* ── Buttons ───────────────────────────────────────────────────*/
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 16px; border-radius: var(--r); font-size: 13px; font-weight: 500; border: none; cursor: pointer; transition: all var(--t); font-family: var(--font); white-space: nowrap; letter-spacing: -.01em; line-height: 1; text-decoration: none }
.btn svg    { width: 14px; height: 14px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 2 }
.btn:active { transform: scale(.98) }

.btn-primary   { background: var(--blue);   color: #fff }
.btn-primary:hover   { background: var(--blue-d); box-shadow: 0 2px 8px rgba(59,130,246,.3) }
.btn-secondary { background: var(--surface); color: var(--text2); border: 1px solid var(--border) }
.btn-secondary:hover { background: var(--surface2); border-color: var(--border2) }
.btn-danger    { background: var(--red);    color: #fff }
.btn-danger:hover    { background: #b91c1c }
.btn-green     { background: var(--green);  color: #fff }
.btn-green:hover     { background: #15803d }
.btn-amber     { background: var(--amber);  color: #fff }
.btn-amber:hover     { background: #b45309 }
.btn-slate     { background: #334155;       color: #fff }
.btn-slate:hover     { background: var(--sb) }
.btn-purple    { background: var(--purple); color: #fff }
.btn-purple:hover    { background: #6d28d9; box-shadow: 0 2px 8px rgba(124,58,237,.3) }
.btn-blue      { background: var(--blue);   color: #fff }
.btn-blue:hover      { background: var(--blue-d) }
.btn-teal      { background: var(--teal);   color: #fff }
.btn-teal:hover      { background: #0d5e56 }
.btn-outline   { background: transparent; border: 1px solid var(--blue); color: var(--blue) }
.btn-outline:hover   { background: var(--blue-lt) }

.btn-sm   { padding: 5px 12px; font-size: 12px; border-radius: 7px }
.btn-xs   { padding: 3px 8px;  font-size: 11px; border-radius: 6px }
.btn-icon { padding: 7px }
.w-100    { width: 100% }

/* ── Forms ─────────────────────────────────────────────────────*/
.form-group       { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px }
.form-group label { font-size: 12px; color: var(--text2); font-weight: 500 }
.form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 14px }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px }

input:not([type]), input[type=text], input[type=number], input[type=email],
input[type=password], input[type=date], input[type=time],
input[type=search], input[type=tel], input[type=url],
select, textarea {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  padding: 8px 11px; border-radius: var(--r); font-family: var(--font); font-size: 13px;
  line-height: 1.5; outline: none; width: 100%;
  transition: border-color var(--t), box-shadow var(--t);
  -webkit-appearance: none; appearance: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--blue); box-shadow: 0 0 0 3px rgba(59,130,246,.12); background: #fff;
}
input::placeholder, textarea::placeholder { color: var(--muted) }
input:disabled, select:disabled { background: var(--surface3); color: var(--muted); cursor: not-allowed }
textarea { resize: vertical; min-height: 80px }
select   { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; padding-right: 30px }

input[type=file] { padding: 6px 10px; cursor: pointer; background: var(--surface); border: 1px dashed var(--border2); border-radius: var(--r); font-size: 12px; color: var(--text3); width: 100% }
input[type=file]:hover { border-color: var(--blue); color: var(--blue) }

input[type=checkbox], input[type=radio] {
  width: 16px; height: 16px; border: 1.5px solid var(--border2); background: var(--surface);
  cursor: pointer; flex-shrink: 0; -webkit-appearance: none; appearance: none;
  display: inline-flex; align-items: center; justify-content: center; border-radius: 4px;
  transition: all var(--t); padding: 0;
}
input[type=radio] { border-radius: 50% }
input[type=checkbox]:checked, input[type=radio]:checked { background: var(--blue); border-color: var(--blue) }
input[type=checkbox]:checked::after { content: ''; width: 9px; height: 5px; border-left: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(-45deg) translate(1px,-1px) }
input[type=radio]:checked::after    { content: ''; width: 6px; height: 6px; border-radius: 50%; background: #fff }
input[type=checkbox]:focus, input[type=radio]:focus { box-shadow: 0 0 0 3px rgba(59,130,246,.15) }
.check-row { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; color: var(--text2) }

.search-wrap         { position: relative }
.search-wrap input   { padding-left: 36px }
.search-icon         { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--muted); display: flex; align-items: center }
.search-icon svg     { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round }

/* ── Tables ────────────────────────────────────────────────────*/
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch }
table       { border-collapse: collapse; width: 100%; min-width: 500px }
th  { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text3); text-align: left; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface2); white-space: nowrap }
td  { font-size: 13px; padding: 10px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text2) }
tr:last-child td { border-bottom: none }
tbody tr { transition: background var(--t) }
tbody tr:hover td { background: #f8f9ff }
.mono   { font-family: var(--font-m); font-size: 12px }
.fw-600 { font-weight: 600 }
.fw-bold{ font-weight: 700 }

/* ── Badges ────────────────────────────────────────────────────*/
.badge        { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: 99px; white-space: nowrap }
.badge-green  { background: var(--green-lt);  border: 1px solid var(--green-bd);  color: #15803d }
.badge-red    { background: var(--red-lt);    border: 1px solid var(--red-bd);    color: #991b1b }
.badge-yellow { background: var(--amber-lt);  border: 1px solid var(--amber-bd);  color: #92400e }
.badge-blue   { background: var(--blue-lt);   border: 1px solid var(--blue-bd);   color: #1d4ed8 }
.badge-purple { background: var(--purple-lt); border: 1px solid var(--purple-bd); color: #6d28d9 }
.badge-teal   { background: var(--teal-lt);   border: 1px solid var(--teal-bd);   color: var(--teal) }
.badge-slate  { background: var(--surface3);  border: 1px solid var(--border2);   color: var(--text3) }
.badge-gray   { background: var(--surface3);  border: 1px solid var(--border2);   color: var(--text3) }

/* ── Alerts ────────────────────────────────────────────────────*/
.alert         { padding: 10px 14px; border-radius: var(--r); font-size: 13px; margin-bottom: 14px; display: flex; align-items: flex-start; gap: 8px; border: 1px solid }
.alert-success { background: var(--green-lt); border-color: var(--green-bd); color: #15803d }
.alert-error   { background: var(--red-lt);   border-color: var(--red-bd);   color: #991b1b }
.alert-warning { background: var(--amber-lt); border-color: var(--amber-bd); color: #92400e }
.alert-info    { background: var(--blue-lt);  border-color: var(--blue-bd);  color: #1d4ed8 }
.flash-msg     { margin: 14px 26px 0 }

/* ── Modals ────────────────────────────────────────────────────*/
.modal-backdrop      { display: none; position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 1000; align-items: center; justify-content: center; padding: 16px; backdrop-filter: blur(2px) }
.modal-backdrop.open { display: flex }
.modal        { background: var(--surface); border: 1px solid var(--border); border-radius: var(--rx); width: 100%; max-width: 560px; max-height: 92vh; overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: modalIn .18s ease }
.modal-lg     { max-width: 760px }
/* Forms inside modals need to become flex containers too so child modal-body can scroll properly */
.modal > form { display: flex; flex-direction: column; min-height: 0; flex: 1; overflow: hidden }
.modal-header { padding: 15px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; background: var(--surface2); border-radius: var(--rx) var(--rx) 0 0 }
.modal-title  { font-size: 15px; font-weight: 600; color: var(--text); letter-spacing: -.01em }
.modal-body   { padding: 20px; overflow-y: auto; flex: 1 1 auto; min-height: 0 }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; flex-shrink: 0; background: var(--surface2); border-radius: 0 0 var(--rx) var(--rx) }
@keyframes modalIn { from { transform: translateY(10px) scale(.97); opacity: 0 } to { transform: none; opacity: 1 } }

/* ── Chips & filter ────────────────────────────────────────────*/
.chip        { display: inline-flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 99px; padding: 5px 13px; font-size: 12px; cursor: pointer; transition: all var(--t); color: var(--text3); font-weight: 500; white-space: nowrap; text-decoration: none }
.chip:hover  { border-color: var(--blue); color: var(--blue) }
.chip.active { border-color: var(--blue); color: var(--blue); background: var(--blue-lt); font-weight: 600 }
.filter-row  { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px }
.tag         { display: inline-flex; align-items: center; font-size: 11px; background: var(--surface3); border: 1px solid var(--border); border-radius: 5px; padding: 2px 7px; color: var(--text3); font-weight: 500 }

/* ── Progress & charts ─────────────────────────────────────────*/
.progress      { height: 5px; background: var(--surface3); border-radius: 99px; overflow: hidden }
.progress-fill { height: 100%; border-radius: 99px; transition: width .5s ease }
.chart-bar-wrap { display: flex; align-items: flex-end; gap: 5px; height: 100px }
.chart-bar-col  { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 0 }
.chart-bar      { width: 100%; border-radius: 4px 4px 0 0; background: var(--blue); min-height: 3px; opacity: .8; transition: height .4s ease }
.chart-bar:hover{ opacity: 1 }
.chart-label    { font-size: 9px; color: var(--muted); font-weight: 500 }

/* ── Misc helpers ──────────────────────────────────────────────*/
.divider        { border: none; border-top: 1px solid var(--border); margin: 16px 0 }
.totals-table   { width: 100%; border-collapse: collapse }
.totals-table td { border: none; padding: 4px 0; font-size: 13px; color: var(--text2) }
.totals-table td:last-child { text-align: right; font-family: var(--font-m); font-weight: 600 }
.text-muted   { color: var(--muted) }
.text-green   { color: var(--green) }
.text-red     { color: var(--red) }
.text-blue    { color: var(--blue) }
.text-accent  { color: var(--blue) }
.text-amber   { color: var(--amber) }
.text-purple  { color: var(--purple) }
.empty-state  { text-align: center; padding: 40px 20px; color: var(--muted) }
.empty-state svg { width: 36px; height: 36px; stroke: var(--muted2); fill: none; stroke-width: 1.5; margin: 0 auto 12px; display: block }
.w-100 { width: 100% }

/* ── Product images ────────────────────────────────────────────*/
.product-img             { width: 42px; height: 42px; border-radius: 8px; object-fit: cover; border: 1px solid var(--border); background: var(--surface3); flex-shrink: 0 }
.product-img-placeholder { width: 42px; height: 42px; border-radius: 8px; background: var(--surface3); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; flex-shrink: 0 }
.product-img-placeholder svg { width: 18px; height: 18px; stroke: var(--muted2); fill: none; stroke-width: 1.5 }

/* ── Report tabs ───────────────────────────────────────────────*/
.report-tabs { display: flex; gap: 2px; background: var(--surface3); border-radius: var(--rl); padding: 3px; margin-bottom: 20px; flex-wrap: wrap; border: 1px solid var(--border) }
.report-tab  { flex: 1; min-width: 80px; text-align: center; padding: 7px 10px; border-radius: 9px; font-size: 12px; font-weight: 500; color: var(--text3); transition: all var(--t); cursor: pointer; white-space: nowrap; text-decoration: none; display: block }
.report-tab:hover  { color: var(--text) }
.report-tab.active { background: var(--surface); color: var(--blue); font-weight: 600; box-shadow: var(--shadow-xs) }

/* ── POS layout ────────────────────────────────────────────────*/
.pos-layout   { display: grid; grid-template-columns: 1fr 360px; height: calc(100vh - var(--header-h, 0px)); overflow: hidden }
.pos-products { overflow-y: auto; padding: 16px; background: var(--bg) }

.pos-cart {
  display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--border);
  height: 100%; min-height: 0; overflow: hidden;
}
.pos-cart-top {
  padding: 11px 14px 9px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.pos-cart-title { font-size: 13px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 6px }
.pos-cart-title svg { stroke: var(--text3); fill: none; stroke-width: 2; stroke-linecap: round }
.pos-cart-items { flex: 1; overflow-y: auto; min-height: 0 }
.pos-cart-foot {
  /* Never shrinks — always occupies its natural height */
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -ms-flex-direction: column;
  flex-direction: column;
  background: var(--surface);
}
/* Totals + payment methods + inputs scroll if screen is short */
.pos-cart-form-scroll {
  overflow-y: auto;
  padding: 12px 14px 6px;
  max-height: 48vh;
  -webkit-overflow-scrolling: touch;
}
/* Complete Sale button — completely outside scroll, always visible */
.pos-cart-action {
  -webkit-box-flex: 0;
  -ms-flex-negative: 0;
  flex-shrink: 0;
  padding: 10px 14px 16px;
  background: var(--surface);
  border-top: 2px solid var(--border);
}

/* Product grid */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px,1fr)); gap: 8px }
.product-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--rl); padding: 10px; cursor: pointer; transition: border-color var(--t), box-shadow var(--t), transform var(--t); box-shadow: var(--shadow-xs); display: flex; align-items: center; gap: 10px; min-height: 60px }
.product-card:hover  { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-lt), var(--shadow-sm); transform: translateY(-1px) }
.product-card:active { transform: scale(.98) }
.product-card-oos    { opacity: .5; cursor: not-allowed; pointer-events: none; filter: grayscale(.4) }
.product-card-oos:hover { transform: none; border-color: var(--border); box-shadow: var(--shadow-xs) }
.prod-img-wrap { flex: 0 0 42px; width: 42px; height: 42px; border-radius: 6px; overflow: hidden; background: var(--surface3); display: flex; align-items: center; justify-content: center }
.prod-img-wrap img { width: 100%; height: 100%; object-fit: cover }
.prod-img-wrap svg { width: 20px; height: 20px; stroke: var(--muted2); fill: none; stroke-width: 1.5; stroke-linecap: round }
.prod-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px }
.prod-name  { font-size: 13px; font-weight: 500; color: var(--text); line-height: 1.25; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical }
.prod-price { font-family: var(--font-m); font-size: 14px; font-weight: 700; color: var(--blue) }
.prod-meta  { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted) }
.prod-stock { font-size: 11px; color: var(--muted) }
.prod-low   { font-size: 11px; color: var(--amber); font-weight: 600 }
.prod-stock { font-size: 10px; color: var(--muted); margin-top: 2px }
.prod-low   { font-size: 10px; color: var(--amber); margin-top: 2px; font-weight: 500 }

/* Cart items */
.cart-item         { display: flex; align-items: center; gap: 8px; padding: 9px 14px; border-bottom: 1px solid var(--border); transition: background var(--t) }
.cart-item:hover   { background: var(--surface2) }
.cart-item-info    { flex: 1; min-width: 0 }
.cart-item-name    { font-size: 12px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.cart-item-price   { font-size: 11px; color: var(--muted); margin-top: 1px }
.qty-wrap          { display: flex; align-items: center; gap: 3px; flex-shrink: 0 }
.qty-btn           { width: 24px; height: 24px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text3); font-size: 15px; font-weight: 600; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all var(--t); flex-shrink: 0; line-height: 1 }
.qty-btn:hover     { border-color: var(--blue); color: var(--blue); background: var(--blue-lt) }
.qty-display       { width: 26px; text-align: center; font-size: 12px; font-weight: 600; color: var(--text); font-family: var(--font-m) }
.cart-item-total   { font-family: var(--font-m); font-size: 12px; font-weight: 600; color: var(--text); min-width: 52px; text-align: right; flex-shrink: 0 }
.cart-remove       { width: 20px; height: 20px; border: none; background: none; cursor: pointer; color: var(--muted2); display: flex; align-items: center; justify-content: center; border-radius: 4px; transition: all var(--t); flex-shrink: 0; padding: 0 }
.cart-remove:hover { color: var(--red); background: var(--red-lt) }
.cart-remove svg   { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round }
.cart-empty        { padding: 30px 16px; text-align: center; color: var(--muted) }
.cart-empty svg    { width: 32px; height: 32px; stroke: var(--muted2); fill: none; stroke-width: 1.5; margin: 0 auto 10px; display: block }
.cart-empty-text   { font-size: 13px; color: var(--muted) }

/* POS totals */
.pos-totals    { margin-bottom: 10px }
.pos-total-row { display: flex; justify-content: space-between; align-items: center; padding: 3px 0; font-size: 12px; color: var(--text3) }
.pos-total-row.grand { padding-top: 8px; border-top: 1px solid var(--border); margin-top: 4px }
.pos-total-row.grand > span:first-child { font-size: 13px; font-weight: 600; color: var(--text) }
.pos-total-row.grand > #cart-grand { font-size: 17px; font-weight: 700; color: var(--blue); font-family: var(--font-m) }
.pos-total-val { font-family: var(--font-m); font-size: 12px; color: var(--text2) }

.pay-methods { display: flex; gap: 5px; margin-bottom: 10px }
.pay-pill    { flex: 1; padding: 6px 4px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); font-size: 11px; font-weight: 500; color: var(--text3); text-align: center; cursor: pointer; transition: all var(--t) }
.pay-pill:hover  { border-color: var(--blue-bd); color: var(--blue) }
.pay-pill.active { border-color: var(--blue); background: var(--blue-lt); color: var(--blue); font-weight: 600 }

.change-row   { display: flex; justify-content: space-between; align-items: center; background: var(--green-lt); border: 1px solid var(--green-bd); border-radius: 7px; padding: 7px 11px; margin-bottom: 9px }
.change-label { font-size: 12px; font-weight: 500; color: var(--green) }
.change-value { font-family: var(--font-m); font-size: 14px; font-weight: 700; color: var(--green) }

.borrow-toggle      { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--r); border: 1px solid var(--border); background: var(--surface); margin-bottom: 10px; cursor: pointer; transition: all var(--t) }
.borrow-toggle:hover { border-color: var(--blue-bd) }
.borrow-toggle.on   { border-color: var(--teal-bd); background: var(--teal-lt) }
.borrow-toggle svg  { width: 14px; height: 14px; stroke: var(--muted); fill: none; stroke-width: 2; flex-shrink: 0; stroke-linecap: round }
.borrow-toggle.on svg { stroke: var(--teal) }
.borrow-label       { font-size: 12px; font-weight: 500; color: var(--text3) }
.borrow-toggle.on .borrow-label { color: var(--teal) }
.borrow-fields      { background: var(--teal-lt); border: 1px solid var(--teal-bd); border-radius: var(--r); padding: 12px; margin-bottom: 10px }

/* Mobile POS tabs */
.pos-mobile-tabs { display: none; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: var(--header-h,0); z-index: 40 }
.pos-mobile-tab  { flex: 1; padding: 11px; text-align: center; font-size: 12px; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all var(--t); cursor: pointer }
.pos-mobile-tab.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 600 }

/* ── Login ─────────────────────────────────────────────────────*/
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 20px }
.login-box  { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--rx); padding: 38px; box-shadow: var(--shadow-md) }
.login-logo-mark { width: 40px; height: 40px; background: var(--blue); border-radius: 10px; display: flex; align-items: center; justify-content: center; margin-bottom: 18px }
.login-logo-mark svg { width: 20px; height: 20px; stroke: #fff; fill: none; stroke-width: 2 }
.login-logo { font-size: 21px; font-weight: 600; color: var(--text); margin-bottom: 4px; letter-spacing: -.02em }
.login-sub  { font-size: 13px; color: var(--muted); margin-bottom: 24px }

.sa-login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--sb); padding: 20px }
.sa-login-box  { width: 100%; max-width: 380px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1); border-radius: var(--rx); padding: 38px }
.sa-login-box input[type=text], .sa-login-box input[type=email], .sa-login-box input[type=password] { background: rgba(255,255,255,.07); border-color: rgba(255,255,255,.15); color: #fff }
.sa-login-box input::placeholder { color: rgba(255,255,255,.3) }
.sa-login-box input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(59,130,246,.2) }
.sa-login-box label { color: rgba(255,255,255,.65) }
.sa-login-mark { width: 38px; height: 38px; background: var(--blue); border-radius: 9px; display: flex; align-items: center; justify-content: center; margin-bottom: 18px }
.sa-login-mark svg { width: 18px; height: 18px; stroke: #fff; fill: none; stroke-width: 2 }
.sa-login-logo { font-size: 20px; font-weight: 600; color: #fff; margin-bottom: 4px; letter-spacing: -.02em }
.sa-login-sub  { font-size: 13px; color: rgba(255,255,255,.4); margin-bottom: 24px }

/* ── Plan cards ────────────────────────────────────────────────*/
.plan-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--rl); padding: 22px; box-shadow: var(--shadow-xs); transition: box-shadow var(--t) }
.plan-card.featured { border-color: var(--purple); box-shadow: 0 0 0 2px var(--purple-lt), var(--shadow) }
.plan-card:hover { box-shadow: var(--shadow-md) }
.plan-price  { font-size: 28px; font-weight: 700; color: var(--text); letter-spacing: -.02em; line-height: 1; margin: 10px 0 2px }
.plan-period { font-size: 14px; font-weight: 400; color: var(--muted) }
.feature-list { list-style: none; margin: 10px 0 0; padding: 0 }
.feature-list li { font-size: 12px; color: var(--text3); padding: 4px 0; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 7px }
.feature-list li:last-child { border: none }
.feature-list li::before { content: '✓'; color: var(--green); font-weight: 700; font-size: 11px; flex-shrink: 0 }

/* ── Thermal print ─────────────────────────────────────────────*/
@media print {
  .sidebar, .mobile-header, .no-print,
  .impersonate-bar, .license-banner,
  .pos-products, .pos-mobile-tabs { display: none !important }
  @page { margin: 4mm; size: 80mm auto }
  body { background: #fff; color: #000; font-family: 'Courier New', monospace; font-size: 11px }
  .thermal-receipt { width: 72mm; max-width: 72mm; margin: 0 auto; font-family: 'Courier New', monospace }
  .thermal-receipt * { font-family: 'Courier New', monospace !important }
  .shop-name    { font-size: 14px; font-weight: 700; text-align: center; margin-bottom: 2px }
  .shop-info    { font-size: 9px; text-align: center; margin-bottom: 5px }
  .divider-line { border-top: 1px dashed #000; margin: 4px 0 }
  .inv-no       { font-size: 10px; text-align: center; margin: 3px 0 }
  .total-row td { font-weight: 700; border-top: 1px dashed #000; padding-top: 3px }
  .footer-msg   { text-align: center; font-size: 10px; margin-top: 8px }
  .print-only   { display: block !important }
  .thermal-receipt table { width: 100%; border-collapse: collapse }
  .thermal-receipt th { font-size: 9px; padding: 1px 0; border-bottom: 1px solid #000; text-align: left }
  .thermal-receipt td { font-size: 10px; padding: 1px 0 }
}

/* ── Responsive ────────────────────────────────────────────────*/
@media (max-width: 1280px) {
  .stats-grid .stat-value { font-size: 18px }
  .stats-grid .stat-card  { padding: 14px }
  .pos-layout { grid-template-columns: 1fr 330px }
}
@media (max-width: 1024px) {
  :root { --sidebar-w: 220px }
  .stats-grid .stat-value { font-size: 16px }
  .stats-grid .stat-label { font-size: 11px }
  .stats-grid .stat-sub   { font-size: 10px }
  .stats-grid .stat-card  { padding: 12px }
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(128px,1fr)) }
}
@media (max-width: 768px) {
  :root { --sidebar-w: 270px }
  .mobile-header   { display: flex }
  .sidebar         { position: fixed; top: 0; left: 0; height: 100%; transform: translateX(-100%); z-index: 200 }
  .sidebar.open    { transform: translateX(0); box-shadow: var(--shadow-lg) }
  .sidebar-overlay.open { display: block }
  .layout          { display: block }
  .content         { min-height: 100vh }
  .page            { padding: 14px 12px 36px }
  .page-header     { flex-direction: column; align-items: stretch }
  .page-header .btn { width: 100%; justify-content: center }
  .stats-grid      { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; margin-bottom: 16px }
  .stat-value      { font-size: 19px }
  .stat-card       { padding: 14px }
  .form-row, .form-row-3 { grid-template-columns: 1fr; gap: 0 }
  .modal           { max-width: 100%; border-radius: var(--rl) var(--rl) 0 0; max-height: 90vh; margin-top: auto }
  .modal-backdrop  { align-items: flex-end; padding: 0 }
  .pos-mobile-tabs { display: flex }
  .pos-layout      { display: block; height: auto; overflow: visible }
  .pos-products    { max-height: calc(100vh - var(--header-h,56px) - 44px); overflow-y: auto }
  .pos-cart        { height: auto; max-height: none; border-left: none; border-top: 1px solid var(--border) }
  .pos-cart-foot   { max-height: none }
  .pos-cart-form-scroll { max-height: 45vh }
  .pos-products.hidden, .pos-cart.hidden { display: none }
  .product-grid    { grid-template-columns: repeat(auto-fill, minmax(150px,1fr)); gap: 8px }
  .report-tabs     { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px }
  .report-tab      { min-width: auto }
  th, td           { padding: 9px 11px }
  .flash-msg       { margin: 12px 12px 0 }
  .login-box, .sa-login-box { padding: 26px 18px }
}
@media (max-width: 480px) {
  .stats-grid  { gap: 8px }
  .stat-value  { font-size: 17px }
  .stat-icon   { width: 30px; height: 30px; margin-bottom: 8px }
  .stat-icon svg { width: 14px; height: 14px }
  .product-grid { grid-template-columns: repeat(2, 1fr); gap: 7px }
  .product-card { padding: 8px; gap: 8px; min-height: 56px }
  .prod-img-wrap { flex: 0 0 36px; width: 36px; height: 36px }
  .prod-name    { font-size: 12px }
  .prod-price   { font-size: 13px }
  .page        { padding: 10px 10px 28px }
  .page-title  { font-size: 17px }
}
@media (max-width: 360px) {
  .product-grid { grid-template-columns: 1fr }
  .stats-grid   { grid-template-columns: 1fr }
}
