/* ==========================================================================
   StockSmartPro — restaurant back-of-house design system
   Dark forest chrome, warm paper workspace, serif headings.
   ========================================================================== */

:root {
  --forest-950: #0a1b13;
  --forest-900: #0f241a;
  --forest-800: #143024;
  --forest-700: #1b3f2f;
  --forest-600: #265740;
  --forest-500: #357355;
  --moss: #7d9975;
  --amber: #c1863a;
  --amber-soft: #f1dcc0;
  --amber-ink: #6b4513;
  --paper: #f5efe3;
  --paper-2: #fbf7ee;
  --paper-3: #fffdf8;
  --ink: #1b241f;
  --ink-soft: #3f4b44;
  --muted: #6c756e;
  --line: #e0d5c1;
  --line-strong: #cdbfa6;
  --danger: #a13c35;
  --danger-soft: #f4dfda;
  --ok: #2c6449;
  --ok-soft: #dcebdf;
  --info: #335f74;
  --info-soft: #dde9ee;
  --warn: #8a6322;
  --warn-soft: #f4e8cf;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(27, 36, 31, .05), 0 10px 28px -18px rgba(27, 36, 31, .4);
  --shadow-lift: 0 2px 4px rgba(27, 36, 31, .06), 0 18px 40px -22px rgba(27, 36, 31, .45);
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, "Times New Roman", serif;
  --sidebar-w: 264px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 100% -10%, rgba(193, 134, 58, .08), transparent 60%),
    var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: -.01em;
  color: var(--ink);
  margin: 0;
}

h1 { font-size: clamp(1.55rem, 1.2rem + 1vw, 2.15rem); line-height: 1.15; }
h2 { font-size: 1.18rem; }
h3 { font-size: 1rem; }

p { margin: 0 0 .6rem; }
a { color: var(--forest-600); text-decoration: none; }
a:hover { color: var(--forest-500); text-decoration: underline; text-underline-offset: 2px; }
code { background: rgba(20, 48, 36, .08); padding: .08em .35em; border-radius: 4px; font-size: .88em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

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

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.1rem .9rem 1.2rem;
  background:
    linear-gradient(175deg, rgba(255, 255, 255, .045), transparent 38%),
    radial-gradient(420px 300px at 10% 0%, rgba(193, 134, 58, .16), transparent 65%),
    var(--forest-950);
  color: #e8e4d7;
  overflow-y: auto;
  z-index: 40;
  border-right: 1px solid rgba(0, 0, 0, .35);
}

.brand {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .35rem .4rem .9rem;
  border-bottom: 1px solid rgba(255, 255, 255, .1);
  color: #f6f1e6;
}
.brand:hover { text-decoration: none; color: #fff; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  border-radius: 11px;
  background: linear-gradient(145deg, var(--amber-soft), #d9b483);
  color: var(--forest-900);
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .35), 0 6px 16px -8px rgba(0, 0, 0, .8);
}
.brand-mark.big { width: 52px; height: 52px; font-size: 1.8rem; border-radius: 15px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-family: var(--serif); font-size: 1.12rem; letter-spacing: .01em; }
.brand-text small { font-size: .68rem; text-transform: uppercase; letter-spacing: .18em; color: rgba(232, 228, 215, .55); }

.nav { display: flex; flex-direction: column; gap: .15rem; flex: 1; }
.nav-group {
  margin: 1rem 0 .35rem;
  padding: 0 .65rem;
  font-size: .64rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: rgba(232, 228, 215, .42);
  font-weight: 600;
}
.nav-group:first-child { margin-top: .2rem; }
.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .55rem .65rem;
  border-radius: 9px;
  color: rgba(240, 237, 226, .78);
  font-size: .875rem;
  line-height: 1.2;
  transition: background .15s ease, color .15s ease;
}
.nav-link:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.nav-link.active {
  background: linear-gradient(90deg, rgba(193, 134, 58, .26), rgba(193, 134, 58, .06));
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(193, 134, 58, .28);
}
.nav-link.active::before {
  content: "";
  position: absolute; left: -0.9rem; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0;
  background: var(--amber);
}
.nav-link .ico { width: 17px; height: 17px; opacity: .85; flex: none; }
.nav-badge {
  margin-left: auto;
  background: var(--amber);
  color: #23180a;
  font-size: .68rem;
  font-weight: 700;
  border-radius: 999px;
  padding: .05rem .42rem;
}
.sidebar-foot {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  padding: .9rem .65rem 0;
  border-top: 1px solid rgba(255, 255, 255, .1);
  font-size: .72rem;
  color: rgba(232, 228, 215, .55);
}
.demo-flag {
  align-self: flex-start;
  font-size: .64rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  background: rgba(193, 134, 58, .18);
  border: 1px solid rgba(193, 134, 58, .35);
  color: #f0d9b7;
  border-radius: 999px;
  padding: .1rem .5rem;
}

.workspace {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------------------------------------------------------------- topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .65rem 1.6rem;
  background: rgba(251, 247, 238, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-context { display: flex; align-items: center; gap: .55rem; }
.context-label {
  font-size: .64rem;
  text-transform: uppercase;
  letter-spacing: .18em;
  color: var(--muted);
}
.branch-menu { position: relative; }
.branch-menu summary {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  cursor: pointer;
  list-style: none;
  padding: .35rem .7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper-3);
  font-size: .82rem;
}
.branch-menu summary::-webkit-details-marker { display: none; }
.branch-menu[open] summary { border-color: var(--line-strong); box-shadow: var(--shadow); }
.menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 260px;
  background: var(--paper-3);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-lift);
  padding: .35rem;
  z-index: 50;
}
.menu-item {
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: .5rem .6rem;
  border: 0;
  background: none;
  border-radius: 8px;
  font: inherit;
  font-size: .85rem;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}
.menu-item:hover { background: rgba(38, 87, 64, .08); }
.menu-item.is-current { background: rgba(193, 134, 58, .12); }
.menu-item small { color: var(--muted); text-transform: capitalize; }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.icon-button {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 38px; height: 38px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
}
.icon-button:hover { background: rgba(38, 87, 64, .08); color: var(--ink); text-decoration: none; }
.icon-button .ico { width: 19px; height: 19px; }
.dot-badge {
  position: absolute; top: 3px; right: 2px;
  min-width: 17px; height: 17px;
  display: grid; place-items: center;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: .64rem;
  font-weight: 700;
}
.who { display: flex; align-items: center; gap: .55rem; }
.who-text { display: flex; flex-direction: column; line-height: 1.15; }
.who-text strong { font-size: .82rem; }
.who-text small { font-size: .7rem; color: var(--muted); }
.avatar {
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--forest-700);
  color: #f4efe1;
  font-family: var(--serif);
  font-size: 1rem;
  flex: none;
}
.avatar.lg { width: 46px; height: 46px; font-size: 1.25rem; }
.logout { margin: 0; }
.nav-toggle { display: none; }

/* ---------------------------------------------------------------- content */
.content {
  width: 100%;
  max-width: 1480px;
  margin: 0 auto;
  padding: 1.6rem 1.8rem 2.5rem;
  flex: 1;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.35rem;
}
.page-head-text { max-width: 78ch; }
.eyebrow {
  margin: 0 0 .3rem;
  font-size: .66rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--amber-ink);
  font-weight: 700;
}
.lede { color: var(--ink-soft); margin: .4rem 0 0; max-width: 74ch; }
.page-actions { display: flex; gap: .55rem; flex-wrap: wrap; align-items: center; }

.app-foot {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: .9rem 1.8rem 1.4rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .72rem;
}

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .42rem;
  padding: .52rem .95rem;
  border-radius: 9px;
  border: 1px solid transparent;
  font-family: var(--sans);
  font-size: .85rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .05s ease, box-shadow .15s ease;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn .ico { width: 16px; height: 16px; }
.btn-primary {
  background: linear-gradient(180deg, var(--forest-600), var(--forest-700));
  color: #f6f2e7;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .12) inset, 0 8px 18px -12px rgba(20, 48, 36, .9);
}
.btn-primary:hover { background: linear-gradient(180deg, var(--forest-500), var(--forest-600)); color: #fff; }
.btn-ghost { background: var(--paper-3); border-color: var(--line-strong); color: var(--forest-700); }
.btn-ghost:hover { background: #fff; border-color: var(--forest-500); color: var(--forest-600); }
.btn-quiet { background: transparent; color: var(--ink-soft); border-color: transparent; }
.btn-quiet:hover { background: rgba(38, 87, 64, .08); color: var(--ink); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #8d2f29; color: #fff; }
.btn-amber { background: var(--amber); color: #241806; }
.btn-amber:hover { background: #b3792f; color: #1c1204; }
.btn-sm { padding: .34rem .65rem; font-size: .78rem; border-radius: 7px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.inline-actions { display: inline-flex; gap: .35rem; flex-wrap: wrap; align-items: center; }
.inline-actions form { margin: 0; }

/* ---------------------------------------------------------------- cards */
.card {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.05rem 1.15rem 1.15rem;
  min-width: 0;
}
.card + .card { margin-top: 0; }
.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .8rem;
  margin-bottom: .85rem;
}
.card-head h2 { font-size: 1.08rem; }
.card-head .link { font-size: .8rem; }
.card-sub { margin-top: 1rem; padding-top: .9rem; border-top: 1px dashed var(--line); }
.card-sub h3 { font-size: .82rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin-bottom: .5rem; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; margin-bottom: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.stack { display: flex; flex-direction: column; gap: .85rem; }
.split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin: 1.5rem 0 .8rem; }
.section-title h2 { font-size: 1.2rem; }

/* ---------------------------------------------------------------- stats */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .85rem;
  margin-bottom: 1.1rem;
}
.stat {
  position: relative;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: .85rem .95rem;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.stat::after {
  content: "";
  position: absolute; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, var(--forest-600), rgba(38, 87, 64, .1));
}
.stat.warning::after { background: linear-gradient(90deg, var(--amber), rgba(193, 134, 58, .1)); }
.stat.danger::after { background: linear-gradient(90deg, var(--danger), rgba(161, 60, 53, .1)); }
.stat-label { display: block; font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.stat-value { display: block; font-family: var(--serif); font-size: 1.5rem; line-height: 1.2; margin-top: .2rem; }
.stat.danger .stat-value { color: var(--danger); }
.stat.warning .stat-value { color: var(--warn); }
.stat-sub { display: block; font-size: .72rem; color: var(--muted); margin-top: .15rem; }

/* ---------------------------------------------------------------- bars and trend */
.trend { display: flex; flex-direction: column; gap: .22rem; }
.trend-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) 92px; align-items: center; gap: .6rem; min-width: 0; }
.trend-date { font-size: .7rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.trend-bars { display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow: hidden; }
.bar { display: block; height: 5px; border-radius: 3px; min-width: 1px; max-width: 100%; }
.bar-sales { background: var(--forest-600); }
.bar-purchases { background: var(--amber); opacity: .85; }
.bar-waste { background: var(--danger); opacity: .7; }
.trend-value { text-align: right; font-size: .74rem; font-variant-numeric: tabular-nums; color: var(--ink-soft); }
.legend { display: flex; gap: 1rem; margin-top: .8rem; font-size: .72rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: .35rem; }
.sw { width: 10px; height: 4px; border-radius: 2px; display: inline-block; }
.sw-sales { background: var(--forest-600); }
.sw-purchases { background: var(--amber); }
.sw-waste { background: var(--danger); }

.hbar-row { display: grid; grid-template-columns: minmax(90px, 1.2fr) minmax(0, 2fr) 96px; align-items: center; gap: .6rem; margin-bottom: .5rem; }
.hbar-label { font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { background: rgba(20, 48, 36, .07); border-radius: 999px; height: 9px; overflow: hidden; }
.hbar { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--forest-600), var(--moss)); }
.hbar-value { text-align: right; font-size: .78rem; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; margin: 0 -.2rem; padding: 0 .2rem; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .84rem;
}
.table th {
  text-align: left;
  font-size: .66rem;
  letter-spacing: .11em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  padding: .45rem .5rem;
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}
.table td {
  padding: .5rem .5rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.table tbody tr:hover { background: rgba(255, 253, 248, .7); }
.table tbody tr:last-child td { border-bottom: 0; }
.table.compact th, .table.compact td { padding: .38rem .45rem; }
.table .right, .right { text-align: right; }
.table .num, .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .neg { color: var(--danger); }
.table .block, .block { display: block; }
.table tfoot td { font-weight: 700; border-top: 1px solid var(--line-strong); border-bottom: 0; background: rgba(20, 48, 36, .03); }
.table-total { text-align: right; margin-top: .7rem; font-size: .9rem; }
.table-total strong { font-family: var(--serif); font-size: 1.05rem; }

/* ---------------------------------------------------------------- pills, chips, tags */
.pill {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .1rem .5rem;
  border-radius: 999px;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
  border: 1px solid transparent;
  white-space: nowrap;
  background: rgba(20, 48, 36, .07);
  color: var(--ink-soft);
}
.st-draft, .st-open, .st-queued { background: #eee7d8; color: #6a5c41; }
.st-submitted, .st-imported, .st-issued, .st-counting { background: var(--info-soft); color: var(--info); }
.st-pending-approval, .st-pending, .st-review { background: var(--warn-soft); color: var(--warn); }
.st-approved, .st-posted, .st-received, .st-shipped, .st-invoiced, .st-published, .st-paid, .st-resolved { background: var(--ok-soft); color: var(--ok); }
.st-locked, .st-closed, .st-in-progress, .st-processing { background: rgba(20, 48, 36, .1); color: var(--forest-700); }
.st-reversed, .st-rejected, .st-cancelled, .st-failed, .st-void { background: var(--danger-soft); color: var(--danger); }
.st-archived { background: #e8e2d5; color: #6d6557; }
.st-sent-demo { background: #e4ebdf; color: #44603a; }
.st-partially-received, .st-converted { background: #ecdfc9; color: #7a551d; }

.chip {
  display: inline-flex;
  align-items: center;
  padding: .08rem .5rem;
  border-radius: 6px;
  background: rgba(20, 48, 36, .06);
  border: 1px solid var(--line);
  font-size: .72rem;
  color: var(--ink-soft);
  white-space: nowrap;
}
.tag {
  display: inline-block;
  padding: .05rem .4rem;
  border-radius: 5px;
  background: rgba(20, 48, 36, .06);
  font-size: .7rem;
  color: var(--ink-soft);
  text-transform: capitalize;
}

/* ---------------------------------------------------------------- forms */
form { margin: 0; }
.field { display: flex; flex-direction: column; gap: .28rem; min-width: 0; }
.field-label {
  display: flex;
  align-items: baseline;
  gap: .4rem;
  font-size: .72rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
.field-label em { font-style: normal; font-size: .62rem; color: var(--amber-ink); letter-spacing: .04em; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="search"], input[type="time"], select, textarea {
  width: 100%;
  padding: .5rem .6rem;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--paper-3);
  color: var(--ink);
  font: inherit;
  font-size: .86rem;
  min-height: 38px;
}
textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--forest-500);
  box-shadow: 0 0 0 3px rgba(38, 87, 64, .14);
}
input::placeholder, textarea::placeholder { color: #a59c8d; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 55%, calc(100% - 10px) 55%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 1.8rem; }
.field-hint { font-size: .72rem; color: var(--muted); }
.field-hint a { text-decoration: underline; }
.input-prefix { position: relative; display: block; }
.input-prefix i {
  position: absolute; left: .65rem; top: 50%; transform: translateY(-50%);
  font-style: normal; color: var(--muted); font-size: .82rem;
}
.input-prefix input { padding-left: 1.6rem; }
.check { display: flex; align-items: flex-start; gap: .5rem; font-size: .84rem; color: var(--ink-soft); }
.check input { width: 16px; height: 16px; margin-top: .16rem; accent-color: var(--forest-600); }
.check small { display: block; color: var(--muted); font-size: .72rem; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .9rem; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-3 { grid-column: span 3; }
.form-actions { display: flex; gap: .6rem; align-items: center; margin-top: 1.1rem; flex-wrap: wrap; }
.form-section { margin-bottom: 1.2rem; }

.filters {
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
  align-items: flex-end;
  padding: .8rem .9rem;
  background: rgba(255, 253, 248, .65);
  border: 1px solid var(--line);
  border-radius: 11px;
  margin-bottom: 1rem;
}
.filters .field { min-width: 140px; }
.filters .field.grow { flex: 1; min-width: 200px; }
.filters .field-label { font-size: .64rem; }

.line-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.line-table th { font-size: .62rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); text-align: left; padding: .3rem .35rem; border-bottom: 1px solid var(--line-strong); }
.line-table td { padding: .3rem .35rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.line-table input, .line-table select { min-height: 34px; padding: .35rem .45rem; font-size: .82rem; }
.line-table .col-item { width: 34%; min-width: 210px; }
.line-table .col-qty { width: 92px; }
.line-table .col-money { width: 110px; }
.line-table .col-small { width: 84px; }
.line-table .col-note { min-width: 120px; }
.line-table .row-total { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-soft); }
.line-table tfoot td { border-bottom: 0; border-top: 1px solid var(--line-strong); font-weight: 700; }
.line-add { margin-top: .5rem; }

/* ---------------------------------------------------------------- misc content */
.flashes { display: flex; flex-direction: column; gap: .45rem; margin-bottom: 1rem; }
.flash {
  padding: .6rem .8rem;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: var(--paper-3);
  font-size: .84rem;
}
.flash-error { border-color: #dfb2ab; background: var(--danger-soft); color: #6f2722; }
.flash-success { border-color: #b5d1bc; background: var(--ok-soft); color: #1f4c37; }
.flash-info { border-color: #b9cfd9; background: var(--info-soft); color: #234a5c; }

.empty {
  padding: 1.4rem 1rem;
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  color: var(--muted);
  background: rgba(255, 253, 248, .5);
  font-size: .84rem;
}
.empty strong { display: block; color: var(--ink-soft); font-family: var(--serif); font-size: 1rem; margin-bottom: .2rem; }

.muted { color: var(--muted); }
.small { font-size: .78rem; }
.fine { font-size: .72rem; color: var(--muted); }
.neg { color: var(--danger); }
.pos { color: var(--ok); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .82em; }
.nowrap { white-space: nowrap; }

.kv { display: grid; grid-template-columns: minmax(120px, auto) minmax(0, 1fr); gap: .35rem 1rem; font-size: .85rem; }
.kv dt { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; padding-top: .1rem; }
.kv dd { margin: 0; }
.kv.two { grid-template-columns: auto 1fr auto 1fr; }

.queue { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.queue li { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.queue li:last-child { border-bottom: 0; }
.queue a { display: flex; flex-direction: column; line-height: 1.25; }
.queue a span { font-size: .76rem; color: var(--muted); }
.queue em { font-style: normal; font-variant-numeric: tabular-nums; font-size: .82rem; }

.mini-row { display: flex; justify-content: space-between; gap: 1rem; padding: .3rem 0; font-size: .82rem; border-bottom: 1px dotted var(--line); }
.mini-row:last-child { border-bottom: 0; }

.note-box, .warn-box, .danger-box, .ok-box {
  border-radius: 10px;
  padding: .7rem .85rem;
  font-size: .82rem;
  border: 1px solid var(--line);
  background: var(--paper-3);
  color: var(--ink-soft);
}
.note-box { border-left: 3px solid var(--moss); }
.warn-box { border-left: 3px solid var(--amber); background: var(--warn-soft); color: #5d4417; }
.danger-box { border-left: 3px solid var(--danger); background: var(--danger-soft); color: #6f2722; }
.ok-box { border-left: 3px solid var(--ok); background: var(--ok-soft); color: #1f4c37; }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; flex-wrap: wrap; }
.tab {
  padding: .45rem .8rem;
  border-radius: 8px 8px 0 0;
  font-size: .82rem;
  color: var(--muted);
  border: 1px solid transparent;
  border-bottom: 0;
}
.tab:hover { background: rgba(20, 48, 36, .05); text-decoration: none; }
.tab.active { background: var(--paper-2); border-color: var(--line); color: var(--ink); font-weight: 600; margin-bottom: -1px; }

.pagination { display: flex; align-items: center; gap: .5rem; margin-top: 1rem; font-size: .8rem; }
.pagination .spacer { flex: 1; }

/* ---------------------------------------------------------------- auth */
.auth-body { background: var(--forest-950); }
.auth-body .sidebar, .auth-body .topbar, .auth-body .app-foot { display: none; }
.auth-body .workspace { margin-left: 0; }
.auth-body .content { padding: 0; max-width: none; }
.auth-body .flashes { max-width: 900px; margin: 1rem auto 0; }
.auth-wrap { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); min-height: 100vh; }
.auth-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2rem;
  padding: clamp(1.5rem, 5vw, 4.5rem);
  background:
    radial-gradient(800px 500px at 0% 100%, rgba(193, 134, 58, .12), transparent 60%),
    var(--paper);
}
.auth-brand { display: flex; gap: 1rem; align-items: flex-start; }
.auth-brand h1 { font-size: 2rem; }
.auth-card {
  max-width: 430px;
  background: var(--paper-3);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: var(--shadow-lift);
}
.auth-card h2 { font-size: 1.3rem; margin-bottom: .3rem; }
.auth-alt { margin-top: 1.3rem; }
.rule { display: flex; align-items: center; gap: .7rem; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .14em; margin-bottom: .9rem; }
.rule::before, .rule::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.rule i { font-style: normal; }
.auth-aside {
  padding: clamp(1.5rem, 4vw, 3.5rem);
  background:
    radial-gradient(600px 400px at 100% 0%, rgba(193, 134, 58, .2), transparent 60%),
    linear-gradient(160deg, var(--forest-800), var(--forest-950));
  color: #eae5d7;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.auth-aside h2 { color: #f7f2e6; font-size: 1.4rem; margin-bottom: 1rem; }
.ticks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .7rem; }
.ticks li { position: relative; padding-left: 1.4rem; font-size: .88rem; color: rgba(234, 229, 215, .85); }
.ticks li::before { content: ""; position: absolute; left: 0; top: .45rem; width: 8px; height: 8px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 3px rgba(193, 134, 58, .18); }
.aside-note { margin-top: 1.4rem; font-size: .76rem; color: rgba(234, 229, 215, .55); }

.demo-body { background: var(--paper); }
.demo-body .content { padding: 0; max-width: none; }
.demo-wrap { max-width: 1180px; margin: 0 auto; padding: clamp(1.5rem, 4vw, 3rem); }
.demo-head { max-width: 68ch; margin-bottom: 1.8rem; }
.demo-head h1 { margin-bottom: .4rem; }
.person-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: .8rem; }
.person-card {
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: .85rem .95rem;
  background: var(--paper-3);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}
.person-main { display: flex; flex-direction: column; line-height: 1.3; flex: 1; min-width: 150px; }
.person-main .muted { font-size: .8rem; }
.person-main small { color: var(--muted); font-size: .72rem; }
.person-card .btn { margin-left: auto; }
.demo-foot { margin-top: 1.8rem; display: flex; flex-direction: column; gap: .7rem; align-items: flex-start; }

/* ---------------------------------------------------------------- state pages */
.state-page {
  max-width: 620px;
  margin: 6vh auto;
  text-align: center;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 2.2rem 1.6rem;
  box-shadow: var(--shadow);
}
.state-code {
  font-family: var(--serif);
  font-size: 3rem;
  line-height: 1;
  color: var(--amber);
  margin: 0 0 .5rem;
}

/* ---------------------------------------------------------------- print */
.sheet {
  background: #fff;
  color: #111;
  max-width: 900px;
  margin: 0 auto;
  padding: 1.6rem;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.sheet-head { display: flex; justify-content: space-between; gap: 1.5rem; border-bottom: 2px solid #222; padding-bottom: .8rem; margin-bottom: 1rem; flex-wrap: wrap; }
.sheet-head h1 { font-size: 1.5rem; }
.sheet-meta { text-align: right; font-size: .8rem; }
.sheet-meta div { margin-bottom: .15rem; }
.sheet h2 { font-size: 1rem; margin: 1.2rem 0 .4rem; text-transform: uppercase; letter-spacing: .1em; }
.sheet .table th { border-bottom-color: #333; color: #333; }
.sheet .table td { border-bottom-color: #ddd; }
.sheet-total { margin-left: auto; width: 280px; font-size: .85rem; }
.sheet-total div { display: flex; justify-content: space-between; padding: .2rem 0; }
.sheet-total .grand { border-top: 2px solid #222; margin-top: .3rem; padding-top: .4rem; font-weight: 700; }
.sheet-foot { margin-top: 1.6rem; border-top: 1px solid #ccc; padding-top: .6rem; font-size: .7rem; color: #555; display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

@media print {
  body { background: #fff; }
  .sidebar, .topbar, .app-foot, .page-head, .page-actions, .flashes, .no-print, .scrim, .filters { display: none !important; }
  .workspace { margin: 0; }
  .content { padding: 0; max-width: none; }
  .card, .sheet { border: 0; box-shadow: none; padding: 0; }
  .sheet { max-width: none; }
  a { color: #111; text-decoration: none; }
}

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1200px) {
  .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
}

@media (max-width: 980px) {
  :root { --sidebar-w: 268px; }
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; box-shadow: 20px 0 50px -30px rgba(0, 0, 0, .6); }
  body.nav-open .sidebar { transform: translateX(0); }
  .scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(10, 27, 19, .45); }
  .scrim[hidden] { display: none; }
  .workspace { margin-left: 0; }
  .nav-toggle { display: inline-grid; }
  .topbar { padding: .55rem .9rem; }
  .content { padding: 1.1rem .95rem 2rem; }
  .grid-2, .split { grid-template-columns: minmax(0, 1fr); }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid, .form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid .span-3 { grid-column: span 2; }
  .auth-panel { min-height: 100vh; }
}

@media (max-width: 640px) {
  body { font-size: 14px; }
  .who-text, .context-label { display: none; }
  .page-head { align-items: flex-start; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
  .stat-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .6rem; }
  .stat-value { font-size: 1.22rem; }
  .form-grid, .form-grid.two { grid-template-columns: 1fr; }
  .form-grid .span-2, .form-grid .span-3 { grid-column: span 1; }
  .filters .field { min-width: 100%; }
  .trend-row { grid-template-columns: 34px minmax(0, 1fr) 72px; }
  .hbar-row { grid-template-columns: 84px minmax(0, 1fr) 76px; }
  .app-foot { padding: .8rem .95rem 1.2rem; }
  .sheet { padding: .9rem; }
  .line-table .col-note { display: none; }
  .person-grid { grid-template-columns: 1fr; }
  .auth-panel { padding: 1.2rem; }
  .auth-card { padding: 1.1rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
/* Shared page primitives and intrinsic SVG sizing. */
.ico { width:18px; height:18px; flex:none; fill:none; stroke:currentColor; }
.panel { background:var(--paper-3); border:1px solid var(--line); border-radius:var(--radius); padding:1.25rem; margin-bottom:1.15rem; box-shadow:var(--shadow); min-width:0; }
.panel h2 { margin-bottom:.9rem; }
.grid { display:grid; gap:1rem; }
.grid-3 { grid-template-columns:repeat(3,minmax(0,1fr)); }
.card { min-width:0; }
.table-wrap { overflow-x:auto; max-width:100%; }
.topbar-context,.branch-menu { min-width:0; }
.branch-menu summary { max-width:100%; }
.branch-menu summary strong { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; min-width:0; }
@media(max-width:640px){
 .grid-3 { grid-template-columns:minmax(0,1fr); }
 .topbar { gap:.35rem; }
 .topbar-context { flex:1; }
 .topbar-actions { gap:.35rem; }
 .branch-menu summary { padding:.4rem; font-size:.73rem; }
 .panel { padding:1rem; }
 .who { display:none; }
 .logout .btn { padding:.4rem; font-size:.73rem; }
}
@media print{.panel{box-shadow:none;break-inside:avoid}.table-wrap{overflow:visible}}
