/* ==========================================================
   LedgerLine — design tokens
   Palette: ink navy + paper + ledger green + rust flag
   Type: Fraunces (display/serif) + Inter (body) + IBM Plex Mono (numbers)
   Signature: the perforated "ledger stub" edge on cards & the receipt tape
   ========================================================== */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  --ink: #1B2430;
  --ink-soft: #3A4657;
  --paper: #F6F3EC;
  --paper-raised: #FFFFFF;
  --line: #DCD5C4;
  --green: #2F6F4E;
  --green-deep: #1F4E37;
  --rust: #B4552F;
  --amber: #C08A28;
  --radius: 3px;
  --shadow: 0 1px 2px rgba(27, 36, 48, 0.06), 0 4px 12px rgba(27, 36, 48, 0.05);
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Inter', -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', 'Courier New', monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: inherit; }

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

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--ink);
  color: #E8E4DA;
  display: flex;
  flex-direction: column;
  padding: 24px 0;
}

.brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  color: #fff;
  padding: 0 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  margin-bottom: 12px;
  letter-spacing: 0.2px;
}
.brand span { color: var(--rust); }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 24px;
  text-decoration: none;
  color: #C7C2B6;
  font-size: 14px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: background 0.15s, color 0.15s;
}
.nav-link:hover { background: rgba(255,255,255,0.04); color: #fff; }
.nav-link.active {
  color: #fff;
  border-left-color: var(--rust);
  background: rgba(255,255,255,0.06);
}
.nav-icon { font-size: 16px; width: 18px; text-align: center; }

.sidebar-footer {
  margin-top: auto;
  padding: 12px 24px 0;
  font-size: 11px;
  color: #6E7686;
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 14px;
}

.main {
  flex: 1;
  padding: 32px 40px 60px;
  max-width: 1200px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-head h1 {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  margin: 0;
}
.page-head .sub { color: var(--ink-soft); font-size: 13.5px; margin-top: 4px; }

/* ---------- Cards ---------- */
.card {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.stub-card {
  position: relative;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.stub-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; height: 4px;
  background: repeating-linear-gradient(90deg, var(--line) 0 6px, transparent 6px 12px);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}
.stat-label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  font-weight: 600;
}
.stat-value {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 600;
  margin-top: 6px;
  color: var(--ink);
}
.stat-value.green { color: var(--green-deep); }
.stat-value.rust { color: var(--rust); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13.5px;
  padding: 9px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: filter 0.15s, transform 0.05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--green-deep); color: #fff; }
.btn-primary:hover { filter: brightness(1.12); }
.btn-secondary { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { background: rgba(27,36,48,0.04); }
.btn-danger { background: transparent; color: var(--rust); border-color: rgba(180,85,47,0.35); }
.btn-danger:hover { background: rgba(180,85,47,0.08); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Forms ---------- */
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); margin-bottom: 5px; }
input, select, textarea {
  width: 100%;
  font-family: var(--font-body);
  font-size: 14px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--green);
  outline-offset: 1px;
  border-color: var(--green);
}
.field { margin-bottom: 14px; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.field-mono input { font-family: var(--font-mono); }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  font-weight: 600;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
.num { font-family: var(--font-mono); text-align: right; }
.mono { font-family: var(--font-mono); }

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
  background: rgba(47,111,78,0.12);
  color: var(--green-deep);
}
.badge.warn { background: rgba(192,138,40,0.15); color: #8a6318; }
.badge.rust { background: rgba(180,85,47,0.12); color: var(--rust); }

.empty {
  text-align: center;
  padding: 50px 20px;
  color: var(--ink-soft);
  font-size: 14px;
}
.empty .big { font-family: var(--font-display); font-size: 20px; color: var(--ink); margin-bottom: 6px; }

/* ---------- Modal ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(27,36,48,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 50; padding: 20px;
}
.modal {
  background: #fff; border-radius: var(--radius); padding: 26px;
  width: 100%; max-width: 480px; box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  max-height: 90vh; overflow-y: auto;
}
.modal h2 { font-family: var(--font-display); font-size: 20px; margin: 0 0 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--ink); color: #fff;
  padding: 12px 18px; border-radius: var(--radius); font-size: 13.5px;
  box-shadow: var(--shadow); z-index: 100; opacity: 0; transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--rust); }

/* ---------- Search / toolbar ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar input[type=text] { max-width: 320px; }
.spacer { flex: 1; }

/* ---------- Barcode chip ---------- */
.barcode-wrap { background: #fff; padding: 6px; border-radius: 2px; display: inline-block; }

/* ---------- Scrollable list row hover ---------- */
tr.row-hover:hover { background: rgba(47,111,78,0.04); cursor: pointer; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 5px; }

@media (max-width: 820px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; overflow-x: auto; padding: 10px 0; }
  .brand { display: none; }
  .nav-link { border-left: none; border-bottom: 3px solid transparent; white-space: nowrap; }
  .nav-link.active { border-left: none; border-bottom-color: var(--rust); }
  .sidebar-footer { display: none; }
  .main { padding: 20px; }
}

:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
