/* =====================================================================
   Design tokens
   Subject: a multi-shop inventory ledger. The signature idea is the
   page reading like a physical stock ledger -- hairline rules, a
   tabular monospace face for SKUs/quantities/money, and a single warm
   amber used exclusively for "needs attention" (low stock, expiring,
   alerts) so it carries real meaning instead of decorating everything.
   ===================================================================== */
:root {
  --ink: #1c2321;
  --ink-soft: #4b5563;
  --paper: #f7f5f0;
  --panel: #ffffff;
  --teal: #0f4c45;
  --teal-dark: #0a3530;
  --teal-tint: #e7efed;
  --amber: #d98e04;
  --amber-tint: #fbf0d9;
  --danger: #b3261e;
  --danger-tint: #fbe9e7;
  --line: #e1ddd1;
  --line-strong: #c9c3b3;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(28, 35, 33, 0.06), 0 1px 1px rgba(28, 35, 33, 0.04);
  --font-display: "Sora", "Inter", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; margin: 0 0 .4em; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
table { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); font-size: 0.92em; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

/* ---------------------------------------------------------- app shell */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--teal-dark);
  color: #d9efe9;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
}
.sidebar .brand {
  font-family: var(--font-display);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  padding: 0 8px 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar .brand .mark {
  width: 22px; height: 22px; border-radius: 5px;
  background: var(--amber);
  display: inline-block;
}
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar a.nav-link {
  color: #b9d9d1;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 0.88rem;
  font-weight: 500;
}
.sidebar a.nav-link:hover { background: rgba(255,255,255,0.06); text-decoration: none; color: #fff; }
.sidebar a.nav-link.active { background: var(--teal); color: #fff; }
.sidebar .section-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6f988f;
  padding: 14px 10px 4px;
}
.sidebar .user-box {
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 12px;
  margin-top: 8px;
  font-size: 0.8rem;
}
.sidebar .user-box .role-pill {
  display: inline-block;
  background: var(--amber);
  color: #2a1c00;
  font-weight: 700;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 99px;
  margin-top: 4px;
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.content { padding: 24px; flex: 1; }

/* ------------------------------------------------------------- cards */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.card + .card { margin-top: 16px; }
.card-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.kpi .label { font-size: 0.74rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.05em; }
.kpi .value { font-family: var(--font-mono); font-size: 1.6rem; font-weight: 600; margin-top: 6px; }
.kpi.alert { border-color: var(--amber); background: var(--amber-tint); }
.kpi.alert .value { color: #8a5d00; }

@media (max-width: 980px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .sidebar { display: none; }
}

/* ------------------------------------------------------------ tables */
table.data { width: 100%; border-collapse: collapse; }
table.data th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line-strong);
  padding: 8px 10px;
}
table.data td { padding: 9px 10px; border-bottom: 1px solid var(--line); font-size: 0.88rem; }
table.data tr:hover td { background: var(--teal-tint); }
table.data td.num, table.data th.num { text-align: right; font-family: var(--font-mono); }

/* ------------------------------------------------------------- forms */
label { display: block; font-size: 0.78rem; font-weight: 600; margin-bottom: 4px; color: var(--ink-soft); }
input, select, textarea {
  width: 100%;
  font-family: var(--font-body);
  font-size: 0.9rem;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus { border-color: var(--teal); }
.field { margin-bottom: 14px; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
}
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-dark); text-decoration: none; }
.btn-amber { background: var(--amber); color: #2a1c00; }
.btn-outline { background: transparent; border-color: var(--line-strong); color: var(--ink); }
.btn-outline:hover { background: var(--teal-tint); text-decoration: none; }
.btn-danger { background: var(--danger-tint); color: var(--danger); border-color: #f0c9c5; }
.btn-sm { padding: 5px 10px; font-size: 0.78rem; }

/* ------------------------------------------------------------ badges */
.badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 2px 8px;
  border-radius: 99px;
}
.badge-active { background: var(--teal-tint); color: var(--teal-dark); }
.badge-warn { background: var(--amber-tint); color: #8a5d00; }
.badge-danger { background: var(--danger-tint); color: var(--danger); }
.badge-muted { background: #ece9e1; color: var(--ink-soft); }

/* ------------------------------------------------------------- alerts */
.alert { padding: 10px 14px; border-radius: 6px; font-size: 0.85rem; margin-bottom: 16px; }
.alert-success { background: var(--teal-tint); color: var(--teal-dark); border: 1px solid #bcdcd4; }
.alert-error { background: var(--danger-tint); color: var(--danger); border: 1px solid #f0c9c5; }

/* -------------------------------------------------------------- misc */
.muted { color: var(--ink-soft); }
.flex { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; }
.mt-16 { margin-top: 16px; }
.pagination { display: flex; gap: 6px; margin-top: 14px; }
.pagination a, .pagination span { padding: 5px 10px; border: 1px solid var(--line); border-radius: 6px; font-size: 0.8rem; }

/* ── Print styles ────────────────────────────────────────────────────────── */
.print-only { display: none; }

@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .print-only { display: block !important; }
  .main { margin-left: 0 !important; }
  .content { padding: 16px !important; }
  body { background: white !important; font-size: 12px; }
  .card { border: 1px solid #ccc !important; box-shadow: none !important; break-inside: avoid; }
  .card + .card { margin-top: 12px !important; }
  table.data th { background: #f0f0f0 !important; color: #000 !important; }
  .badge { border: 1px solid #ccc; background: #f5f5f5 !important; color: #000 !important; }
  .btn, button { display: none !important; }
  a { color: #000 !important; text-decoration: none !important; }
  h1 { font-size: 1.4rem !important; }
  h2 { font-size: 1.1rem !important; }
  .alert { border: 1px solid #ccc !important; background: #f9f9f9 !important; color: #000 !important; }
}

/* ── Mobile responsive ──────────────────────────────────────────────── */
.hamburger {
  background: none; border: none; color: var(--ink); font-size: 1.4rem;
  cursor: pointer; padding: 4px 8px; border-radius: 4px; line-height: 1;
}
.hamburger:hover { background: var(--paper); }

@media (max-width: 980px) {
  .hamburger { display: block !important; }

  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; z-index: 200;
    transform: translateX(-100%); transition: transform 0.22s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,0.25);
  }
  .sidebar.sidebar-open {
    transform: translateX(0);
  }

  .main { margin-left: 0 !important; }

  .topbar {
    position: sticky; top: 0; z-index: 100;
    background: var(--surface); border-bottom: 1px solid var(--line);
    padding: 8px 16px; display: flex; align-items: center;
  }

  .content { padding: 16px; }

  .kpi-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .field-row { flex-direction: column !important; }
  .field-row > .field { max-width: 100% !important; }

  table.data { font-size: 0.78rem; }
  table.data th, table.data td { padding: 6px 8px; }
  .btn-sm { font-size: 0.72rem; padding: 3px 8px; }
}

@media (max-width: 520px) {
  .kpi-grid { grid-template-columns: 1fr 1fr !important; }
  h1 { font-size: 1.3rem; }
  .card { border-radius: 6px; }
}
