/* ============================================================
   GMI Inventory — Loyverse-inspired UI
   Clean, modern, POS-friendly. Legacy class names preserved.
   ============================================================ */

:root {
  /* Black & Gold brand palette */
  --primary: #c9a227;          /* signature gold */
  --primary-600: #b08a1c;       /* deeper gold (hover) */
  --primary-700: #8c6d12;       /* darkest gold (active) */
  --primary-50: #fbf5e1;        /* faint gold tint */
  --accent: #e6c659;             /* light gold accent */
  --ink: #15171a;                /* near-black text */
  --ink-2: #2a2d33;
  --muted: #6b7280;
  --line: #e7e5df;
  --line-2: #f1efe8;
  --bg: #f5f4ef;                 /* warm off-white */
  --surface: #ffffff;
  --surface-2: #fbfaf5;
  --danger: #c0392b;
  --warning: #d4a017;
  --info: #4a5568;
  --success: #2f855a;
  --shadow-sm: 0 1px 2px rgba(20, 18, 10, 0.05);
  --shadow: 0 1px 3px rgba(20, 18, 10, 0.07), 0 1px 2px rgba(20, 18, 10, 0.04);
  --shadow-md: 0 4px 12px rgba(20, 18, 10, 0.10);
  --shadow-lg: 0 10px 30px rgba(20, 18, 10, 0.14);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --sidebar-bg: #0d0d0f;         /* deep black */
  --sidebar-text: #cfc9b8;       /* warm muted gold-grey */
  --sidebar-active: #c9a227;     /* gold accent */
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p { margin: 0; }
h1 { font-size: 1.25rem; font-weight: 600; }
h2 { font-size: 1.4rem; font-weight: 600; letter-spacing: -0.01em; }
h3 { font-size: 1.05rem; font-weight: 600; }
a { color: var(--primary-600); }

/* ── Topbar ───────────────────────────────────────────── */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 10px 24px;
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand { display: flex; gap: 12px; align-items: center; min-width: 0; }
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.brand h1 { font-size: 1.05rem; color: var(--ink); white-space: nowrap; }
.brand p {
  font-size: .78rem; color: var(--muted); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.logo {
  width: 38px; height: 38px;
  object-fit: cover; border-radius: 8px;
  border: 1px solid var(--line);
  flex-shrink: 0;
}
.logo-large { width: 96px; height: 96px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); }

.topbar-right {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: nowrap;
}
.topbar-divider {
  width: 1px; height: 26px;
  background: var(--line);
  margin: 0 2px;
}
.user-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: .82rem; color: var(--ink-2);
  white-space: nowrap;
}
.user-chip .avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0d0d0f, var(--primary));
  color: #fff; font-weight: 700; font-size: .72rem;
  display: inline-flex; align-items: center; justify-content: center;
  text-transform: uppercase;
}
.user-chip .role-badge {
  font-size: .65rem; font-weight: 700;
  background: var(--primary-50); color: var(--primary-700);
  padding: 2px 8px; border-radius: 999px;
  letter-spacing: .04em; text-transform: uppercase;
}
.role-badge {
  font-size: .72rem; font-weight: 600;
  background: var(--primary-50); color: var(--primary-700);
  padding: 4px 10px; border-radius: 999px;
  letter-spacing: .02em; text-transform: uppercase;
}
.theme-toggle { font-size: .8rem; }

/* ── Topbar switchers ─────────────────────────────────── */
.currency-switcher,
.language-switcher { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.currency-switcher label,
.language-switcher label { font-size: .72rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.currency-switcher select,
.language-switcher select { width: auto; padding: 5px 26px 5px 10px; border-radius: 8px; font-size: .82rem; }
.language-switcher .btn { padding: 5px 10px; }

/* ── Layout / Sidebar ─────────────────────────────────── */
.layout { display: flex; flex-direction: row; min-height: calc(100vh - 60px); }
.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  padding: 14px 0 24px;
  position: sticky;
  top: 60px;
  align-self: flex-start;
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.18) transparent;
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 8px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.28); }
.sidebar a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: .88rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: background .15s, color .15s, border-color .15s;
}
.sidebar a:hover { background: rgba(255,255,255,0.05); color: #fff; }
.sidebar a.active {
  background: rgba(201, 162, 39, 0.18);
  border-left-color: var(--sidebar-active);
  color: #fff;
}
.sidebar .nav-section {
  display: block;
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: #8a9ba8;
  padding: 16px 22px 6px;
  font-weight: 700;
}

.content {
  flex: 1;
  padding: 22px 26px;
  overflow-x: auto;
  background: var(--bg);
}

/* ── Page header ──────────────────────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}
.page-header h2 { margin-bottom: 2px; }
.muted { color: var(--muted); font-size: .85rem; }
.quick-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── KPI cards ────────────────────────────────────────── */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.kpis article {
  background: var(--surface);
  color: var(--ink);
  padding: 16px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: transform .15s, box-shadow .15s;
}
.kpis article::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--primary);
}
.kpis article:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.kpis article p {
  font-size: .72rem !important;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted) !important;
  opacity: 1 !important;
  font-weight: 600;
  margin-bottom: 6px;
}
.kpis article h3 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.kpis article:nth-child(4n+2)::before { background: var(--info); }
.kpis article:nth-child(4n+3)::before { background: var(--warning); }
.kpis article:nth-child(4n+4)::before { background: var(--success); }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin: 14px 0;
}
.kpi-card, .card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.kpi-label { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.kpi-value { font-size: 1.5rem; font-weight: 700; margin-top: 6px; color: var(--ink); }
.kpi-card.kpi-accent {
  background: linear-gradient(135deg, #0d0d0f, #2a2418 60%, var(--primary));
  color: #fff; border-color: transparent;
}
.kpi-card.kpi-accent .kpi-label, .kpi-card.kpi-accent .kpi-value { color: #fff; }
.kpi-card.kpi-accent .kpi-label { opacity: .85; }

/* ── Grid / Panels ────────────────────────────────────── */
.grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}
.panel h3 { margin-bottom: 12px; font-size: 1rem; }

.report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.report-grid .card h3 { margin: 0 0 .6rem 0; font-size: 1rem; }
.report-grid table.data { width: 100%; border-collapse: collapse; font-size: .86rem; }
.report-grid table.data th, .report-grid table.data td { padding: .5rem .35rem; border-bottom: 1px solid var(--line-2); text-align: left; }
.report-grid table.data .muted { text-align: center; padding: .85rem 0; }

.notice-board-grid { grid-template-columns: minmax(280px, 380px) 1fr; align-items: start; }

/* ── Tables ───────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  background: var(--surface);
}
th, td {
  text-align: left;
  border-bottom: 1px solid var(--line-2);
  padding: 11px 12px;
  font-size: .88rem;
}
thead th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: .74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--line);
}
tbody tr:hover td { background: var(--surface-2); }
.panel table, .card table { margin-top: 6px; }

ul { margin: 8px 0 0 18px; }
li { margin-bottom: 6px; }

/* ── Forms ────────────────────────────────────────────── */
input, textarea, select, button { font: inherit; }
input, textarea, select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid #d1d9e0;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.20);
}
input[type="checkbox"], input[type="radio"] { width: auto; }

.form-panel { max-width: 820px; margin-left: auto; margin-right: auto; }
.form-panel.panel { padding: 26px 28px; }
.form-panel h2, .form-panel h3 { text-align: center; }
.form-grid { display: grid; gap: 12px; margin-top: 12px; }
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 10px;
}
.form-label {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 5px;
}
.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.form-panel .form-actions { justify-content: center; }
.compact-row { display: flex; align-items: center; }
.checkline { display: inline-flex; align-items: center; gap: 8px; font-size: .9rem; }
.checkline input { width: auto; }
.toggle-row {
  display: flex;
  align-items: end;
  gap: 14px;
  flex-wrap: wrap;
  padding-bottom: 8px;
}
.user-access-panel {
  grid-column: 1 / -1;
  overflow-x: auto;
}
.permission-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin-top: 6px;
}
.permission-grid-compact {
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  min-width: 420px;
}
.permission-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  font-size: .82rem;
  line-height: 1.2;
}
.permission-option input { width: auto; flex-shrink: 0; }
.permission-badges {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  min-width: 180px;
}
.user-edit-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 6px;
  min-width: 560px;
  margin-bottom: 8px;
}
.user-edit-grid input,
.user-edit-grid select { width: 100%; padding: 6px 8px; }
.user-edit-flags {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}

/* ── Buttons ──────────────────────────────────────────── */
button {
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 600;
  transition: background .15s, transform .05s, box-shadow .15s;
}
button:hover { background: var(--primary-600); border-color: var(--primary-600); }
button:active { transform: translateY(1px); }
.btn {
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: .88rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s;
}
.btn:hover { box-shadow: var(--shadow); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 600; }
.btn-primary:hover { background: var(--primary-600); border-color: var(--primary-600); color: #fff; }
.btn-secondary { background: #fff; color: var(--ink-2); border-color: #d1d9e0; }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--primary); color: var(--primary-700); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #c0392b; border-color: #c0392b; }
.btn-sm { padding: 6px 10px; font-size: .8rem; }

/* ── Messages ─────────────────────────────────────────── */
.messages { margin-bottom: 14px; display: grid; gap: 8px; }
.msg {
  background: var(--primary-50);
  border: 1px solid #ead9a3;
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  padding: 10px 14px;
  color: #5a4510;
  font-size: .88rem;
}
.msg-error {
  background: #fdecea;
  border-color: #f5b7b1;
  border-left-color: var(--danger);
  color: #7d1a13;
}

/* ── Badges ───────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .02em;
}
.badge-green, .badge-success { background: #d4f0e4; color: #145c3f; }
.badge-yellow { background: #fef3c7; color: #7c5e00; }
.badge-red    { background: #fde4e4; color: #8b1717; }
.badge-grey   { background: #e8eceb; color: #4a5c58; }

/* ── POS ──────────────────────────────────────────────── */
.pos-form { max-width: 1280px; margin: 0 auto; }
.pos-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 14px;
  align-items: start;
}
.pos-main { display: grid; gap: 14px; min-width: 0; }
.pos-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.pos-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.pos-card-head h3 { margin: 0; }
.pos-detail-row { margin-bottom: 0; }
.pos-lines { display: grid; gap: 10px; }
.pos-line {
  display: grid;
  grid-template-columns: 34px minmax(240px, 1fr) 72px 78px 112px 128px 40px;
  gap: 10px;
  align-items: end;
  padding: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.pos-line-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-50);
  color: var(--primary-700);
  font-weight: 700;
  align-self: center;
}
.pos-product-field,
.pos-number-field { min-width: 0; }
.pos-number-field input { min-width: 0; }
.pos-stock-cell,
.pos-line-total {
  min-height: 42px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  padding: 6px 8px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line-2);
}
.pos-stock-cell span,
.pos-line-total span {
  font-size: .68rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 700;
}
.pos-stock-cell strong,
.pos-line-total strong { font-size: .88rem; color: var(--ink); }
.pos-remove-line {
  width: 34px;
  height: 34px;
  justify-content: center;
  padding: 0;
}
.pos-checkout { position: sticky; top: 78px; }
.pos-checkout-card { display: grid; gap: 12px; }
.pos-money-fields { display: grid; gap: 10px; }
.pos-backorder {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}
.pos-summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}
.pos-summary div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line-2);
  font-size: .9rem;
}
.pos-summary div:last-child { border-bottom: 0; }
.pos-summary .summary-total {
  background: #0d0d0f;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
}
.pos-summary .summary-total strong { color: #fff; }
.pos-actions { display: grid; gap: 8px; }
.pos-actions .btn { justify-content: center; }

/* ── Lines table inside forms ────────────────────────── */
.lines-table { border-collapse: collapse; width: 100%; margin-top: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.lines-table th { background: var(--surface-2); }
.lines-table th, .lines-table td { padding: 8px 10px; border-bottom: 1px solid var(--line-2); }
.lines-table input, .lines-table select { padding: 6px 8px; border-radius: 6px; }
.lines-table + #add-line { margin-top: 10px; }

/* ── Inline forms ─────────────────────────────────────── */
.inline-form { display: inline-flex; gap: 6px; align-items: center; }
.inline-form select, .inline-form input { width: auto; padding: 5px 8px; }

/* ── Document list (related docs preserved across conversions) ── */
.doc-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.doc-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  flex-wrap: wrap;
}
.doc-list-info { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.doc-list-info strong { font-weight: 600; color: var(--ink); letter-spacing: .01em; }
.doc-list-actions { display: inline-flex; gap: 6px; flex-shrink: 0; }

/* ── Document templates ───────────────────────────────── */
.document {
  background: #eef2ee;
  padding: 24px 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #122220;
}
.doc-page {
  max-width: 820px;
  margin: 0 auto 20px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 36px 44px;
  box-shadow: var(--shadow-md);
  position: relative;
}
.doc-page::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 6px;
  background: linear-gradient(90deg, var(--primary-700), var(--accent));
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.doc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; border-bottom: 2px solid var(--primary-700); padding-bottom: 16px; margin-bottom: 22px; }
.doc-head .brand-block { display: flex; gap: 14px; align-items: flex-start; }
.doc-head .brand-block img { width: 78px; height: 78px; object-fit: contain; border-radius: 10px; border: 1px solid var(--line); }
.doc-head .biz-name { font-size: 1.45rem; color: var(--primary-700); font-weight: 700; letter-spacing: .02em; margin-bottom: 4px; }
.doc-head .biz-meta { font-size: .82rem; color: #3a4a47; line-height: 1.45; }
.doc-head .biz-meta a { color: var(--primary-600); text-decoration: none; }
.doc-title-block { text-align: right; }
.doc-title-block .doc-title { font-size: 2rem; color: var(--primary-700); letter-spacing: .12em; font-weight: 700; text-transform: uppercase; }
.doc-title-block .doc-code { font-size: .9rem; color: #3a4a47; margin-top: 4px; }
.doc-meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 20px; }
.doc-meta-grid .meta-card { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.doc-meta-grid .meta-card h4 { margin: 0 0 6px; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.doc-meta-grid .meta-card p { margin: 2px 0; font-size: .9rem; line-height: 1.45; }
.doc-meta-grid .meta-card strong { color: #122220; }
table.doc-table { width: 100%; border-collapse: collapse; margin: 8px 0 14px; font-size: .9rem; }
table.doc-table thead th { background: var(--primary-700); color: #fff; text-align: left; padding: 10px 12px; font-weight: 600; font-size: .82rem; letter-spacing: .04em; text-transform: uppercase; }
table.doc-table thead th:last-child, table.doc-table tbody td:last-child { text-align: right; }
table.doc-table tbody td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); }
table.doc-table tbody tr:nth-child(even) td { background: var(--surface-2); }
.doc-totals { display: grid; grid-template-columns: 1fr 280px; gap: 20px; margin-top: 8px; }
.doc-totals .notes-box { background: #fffbe6; border: 1px dashed #d6c46a; border-radius: 10px; padding: 12px 14px; font-size: .85rem; color: #5a4a00; line-height: 1.5; }
.doc-totals .totals-box { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.doc-totals .totals-box .row { display: flex; justify-content: space-between; padding: 8px 14px; font-size: .9rem; border-bottom: 1px solid var(--line-2); }
.doc-totals .totals-box .row:last-child { border-bottom: 0; }
.doc-totals .totals-box .row.grand { background: var(--primary-700); color: #fff; font-weight: 700; font-size: 1rem; }
.doc-footer { margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--line); font-size: .8rem; color: var(--muted); display: flex; justify-content: space-between; gap: 16px; }
.doc-footer .stamp { border: 2px solid var(--primary-700); color: var(--primary-700); padding: 10px 18px; border-radius: 50px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; font-size: .85rem; align-self: center; }
.doc-actions { max-width: 820px; margin: 0 auto 16px; display: flex; gap: 8px; justify-content: flex-end; }
.doc-watermark { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; font-size: 7rem; font-weight: 800; color: rgba(13, 102, 85, 0.05); letter-spacing: .2em; transform: rotate(-22deg); }

@media print {
  body { background: #fff; }
  .doc-actions, .topbar, .sidebar, .layout > .content > .messages { display: none !important; }
  .document { padding: 0; background: #fff; }
  .doc-page { box-shadow: none; border: 0; margin: 0; padding: 24px 32px; border-radius: 0; }
  .doc-page::before { display: none; }
}

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pos-workspace { grid-template-columns: 1fr; }
  .pos-checkout { position: static; }
}
@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; }
  .notice-board-grid { grid-template-columns: 1fr; }
  .report-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: stretch; }
  .user-edit-grid { grid-template-columns: 1fr 1fr; min-width: 0; }
  .permission-grid-compact { min-width: 0; }
  .pos-line {
    grid-template-columns: 32px minmax(220px, 1fr) 76px 92px 40px;
  }
  .pos-stock-cell { grid-column: 2 / 3; }
  .pos-line-total { grid-column: 3 / 5; }
}
@media (max-width: 720px) {
  /* Keep the sidebar on the left, just narrower with icon-style items */
  .layout { flex-direction: row; }
  .sidebar { width: 64px; padding: 10px 0 18px; }
  .sidebar .nav-section { display: none; }
  .sidebar a {
    justify-content: center;
    padding: 12px 6px;
    font-size: 0;            /* hide label, keep icon/first letter */
    border-left-width: 3px;
  }
  .sidebar a::first-letter { font-size: 14px; }
  .topbar { padding: 8px 14px; }
  .brand h1 { font-size: .95rem; }
  .content { padding: 14px; }
  .pos-card { padding: 12px; }
  .pos-card-head { align-items: flex-start; flex-direction: column; }
  .pos-line {
    grid-template-columns: 28px minmax(0, 1fr) 38px;
    align-items: stretch;
  }
  .pos-product-field,
  .pos-stock-cell,
  .pos-line-total { grid-column: 1 / -1; }
  .pos-number-field { grid-column: span 1; }
  .pos-remove-line { grid-column: 3; grid-row: 1; justify-self: end; }
}

/* ── Dark theme ───────────────────────────────────────── */
body.theme-dark {
  --bg: #0f1720;
  --surface: #1a232e;
  --surface-2: #131b24;
  --ink: #e8eef3;
  --ink-2: #c9d3dc;
  --muted: #8a98a6;
  --line: #283440;
  --line-2: #1f2933;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.15);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.2), 0 1px 2px rgba(0, 0, 0, 0.14);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.3);
  --sidebar-bg: #131b24;
  --primary-50: rgba(201, 162, 39, 0.1);
  background: var(--bg);
  color: var(--ink);
}
body.theme-dark .topbar { background: var(--surface); border-bottom-color: var(--line); }
body.theme-dark .sidebar { background: var(--sidebar-bg); }
body.theme-dark .content { background: var(--bg); }
body.theme-dark input, body.theme-dark textarea, body.theme-dark select {
  background: #0f1720; color: var(--ink); border-color: var(--line);
}
body.theme-dark input:focus, body.theme-dark textarea:focus, body.theme-dark select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.25);
}
body.theme-dark .kpis article, body.theme-dark .kpi-card, body.theme-dark .card, body.theme-dark .panel {
  background: var(--surface);
  border-color: var(--line);
}
body.theme-dark .kpis article h3, body.theme-dark .kpi-value { color: var(--ink); }
body.theme-dark table { background: var(--surface); }
body.theme-dark thead th { background: var(--surface-2); border-bottom-color: var(--line); color: var(--muted); }
body.theme-dark th, body.theme-dark td { border-bottom-color: var(--line-2); }
body.theme-dark tbody tr:hover td { background: var(--surface-2); }
body.theme-dark .btn-secondary {
  background: var(--surface-2);
  color: var(--ink-2);
  border-color: var(--line);
}
body.theme-dark .btn-secondary:hover {
  background: var(--surface);
  border-color: var(--primary);
  color: var(--primary);
}
body.theme-dark .user-chip { background: var(--surface-2); border-color: var(--line); color: var(--ink-2); }
body.theme-dark .doc-list li { background: var(--surface-2); border-color: var(--line); }
body.theme-dark .pos-card,
body.theme-dark .pos-summary,
body.theme-dark .pos-stock-cell,
body.theme-dark .pos-line-total { background: var(--surface); border-color: var(--line); }
body.theme-dark .pos-line,
body.theme-dark .pos-backorder { background: var(--surface-2); border-color: var(--line); }
body.theme-dark .pos-summary div { border-bottom-color: var(--line-2); }
body.theme-dark .pos-line-number { background: rgba(201, 162, 39, 0.12); color: var(--primary); }
body.theme-dark .lines-table { background: var(--surface); border-color: var(--line); }
body.theme-dark .lines-table th { background: var(--surface-2); }
body.theme-dark .lines-table th, body.theme-dark .lines-table td { border-bottom-color: var(--line-2); }
body.theme-dark .pos-summary { background: var(--surface); border-color: var(--line); }
body.theme-dark .pos-summary div { border-bottom-color: var(--line-2); }
body.theme-dark .badge-green { background: #1a3c31; color: #6ee7b7; }
body.theme-dark .badge-yellow { background: #4a3a13; color: #fcd34d; }
body.theme-dark .badge-red { background: #4d1c1c; color: #fca5a5; }
body.theme-dark .badge-grey { background: #283440; color: #a8b5c1; }
body.theme-dark .msg { background: rgba(201, 162, 39, 0.1); border-color: rgba(201, 162, 39, 0.3); color: #fce28d; }
body.theme-dark .msg-error { background: rgba(192, 57, 43, 0.1); border-color: rgba(192, 57, 43, 0.3); color: #f6a9a1; }

body.theme-dark .badge-green,
body.theme-dark .badge-success { background: #173a2b; color: #fff; border: 1px solid rgba(123, 224, 168, 0.45); }
body.theme-dark .badge-yellow { background: #3a2f0c; color: #f5d167; }
body.theme-dark .badge-red    { background: #3a1818; color: #f0a3a3; }
body.theme-dark .badge-grey   { background: #232c36; color: #b0bcc7; }
body.theme-dark .msg { background: #173a32; color: #a4e6d6; border-color: #1f5247; }
body.theme-dark .msg-error { background: #3a1818; color: #f0a3a3; border-color: #5a2a2a; }

/* ── Login page ───────────────────────────────────────── */
.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr auto;
  background: var(--bg);
}
.auth-hero {
  background: linear-gradient(140deg, #0d0d0f 0%, #17130a 48%, #5d4610 100%);
  color: #fff;
  padding: 64px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.auth-hero::before, .auth-hero::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
}
.auth-hero::before { width: 320px; height: 320px; top: -80px; right: -80px; }
.auth-hero::after  { width: 220px; height: 220px; bottom: -60px; left: -40px; }
.auth-mark {
  width: 66px;
  height: 66px;
  border: 1px solid rgba(230,198,89,0.58);
  border-radius: 16px;
  display: grid;
  place-items: center;
  margin-bottom: 28px;
  background: rgba(201,162,39,0.14);
  color: var(--accent);
  font-weight: 800;
  letter-spacing: 0;
  position: relative;
}
.auth-kicker { margin: 0 0 12px; color: var(--accent); font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0; position: relative; }
.auth-kicker-dark { color: var(--primary-700); }
.auth-hero h1 { font-size: 3rem; line-height: 1.03; margin: 0 0 18px; position: relative; max-width: 540px; }
.auth-hero p  { font-size: 1rem; opacity: .92; max-width: 460px; position: relative; line-height: 1.7; }
.auth-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; max-width: 560px; margin-top: 34px; position: relative; }
.auth-metrics span { border: 1px solid rgba(255,255,255,0.14); background: rgba(255,255,255,0.08); border-radius: 10px; padding: 14px; color: rgba(255,255,255,0.82); font-size: .78rem; line-height: 1.35; }
.auth-metrics strong { display: block; color: #fff; font-size: 1.15rem; margin-bottom: 2px; }
.auth-form-wrap { display: flex; align-items: center; justify-content: center; padding: 56px 34px; }
.auth-form {
  width: 100%; max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 40px 38px;
  box-shadow: var(--shadow-lg);
  position: relative;
}
.auth-form::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: linear-gradient(90deg, #0d0d0f, var(--primary), var(--accent));
  border-radius: 12px 12px 0 0;
}
.auth-form h2 { margin-bottom: 8px; color: var(--ink); }
.auth-form .auth-sub { color: var(--muted); margin-bottom: 22px; font-size: .9rem; }
.auth-form label { display: block; font-size: .78rem; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .03em; }
.auth-form input { width: 100%; margin-bottom: 14px; padding: 11px 12px; }
.auth-form .btn-primary { width: 100%; padding: 12px; font-size: .95rem; justify-content: center; }
.auth-language { justify-content: flex-end; margin-bottom: 18px; }
.auth-footer {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 28px;
  border-top: 1px solid var(--line);
  background: #0d0d0f;
  color: rgba(255,255,255,0.74);
  font-size: .78rem;
  line-height: 1.55;
}
.auth-footer div { display: flex; flex-wrap: wrap; gap: 5px 10px; align-items: center; }
.auth-footer strong { color: var(--accent); }
.auth-footer a { color: #fff; text-decoration: none; }
@media (max-width: 820px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .auth-form-wrap { min-height: calc(100vh - 160px); padding: 32px 18px; }
  .auth-footer { flex-direction: column; padding: 16px 18px; }
  .auth-footer div { align-items: flex-start; }
}
