/* =====================================================================
   StockLedger — design tokens
   Concept: a warehouse ledger book. Deep ink-navy chrome, paper-white
   workspace, amber for inward movement, clay-rose for outward movement,
   teal for confirmed/healthy stock. Mono type for SKUs/quantities gives
   the numeric data a "counted, not guessed" feel.
   ===================================================================== */
:root {
  --ink: #12172B;
  --ink-2: #1B2242;
  --ink-3: #262E52;
  --paper: #F6F5F1;
  --paper-card: #FFFFFF;
  --line: #E4E1D8;
  --text: #1A1D2B;
  --text-muted: #6B7080;
  --amber: #C8842B;
  --amber-bg: #FBF1E1;
  --clay: #B85C4A;
  --clay-bg: #FBECE8;
  --teal: #2F7D6E;
  --teal-bg: #E7F3EF;
  --danger: #B23B3B;

  --radius: 6px;
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  background: var(--paper);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: inherit; }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; }

.mono { font-family: var(--font-mono); }

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

.sidebar {
  width: 230px;
  flex-shrink: 0;
  background: var(--ink);
  color: #E9EAF4;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: baseline; gap: 8px; padding: 6px 10px 22px; }
.brand-mark { font-family: var(--font-mono); font-weight: 700; color: var(--amber); font-size: 18px; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }

.nav-section-label {
  font-size: 11px;
  color: #7E84A3;
  padding: 14px 10px 6px;
  text-transform: none;
}
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius);
  color: #C6CAE0;
  text-decoration: none;
  font-size: 14px;
  margin-bottom: 2px;
  cursor: pointer;
  border: none; background: transparent; width: 100%; text-align: left;
}
.nav-link:hover { background: var(--ink-2); color: #fff; }
.nav-link.active { background: var(--ink-3); color: #fff; font-weight: 600; }
.nav-sub { padding-left: 26px; font-size: 13.5px; }

.sidebar-footer { margin-top: auto; padding: 10px; border-top: 1px solid #2A3157; }
.user-chip { display: flex; gap: 10px; align-items: center; padding: 8px 2px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--amber); color: var(--ink); font-weight: 700;
  display: flex; align-items: center; justify-content: center; font-size: 13px;
  flex-shrink: 0;
}
.user-meta { line-height: 1.25; overflow: hidden; }
.user-meta .name { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.user-meta .role { font-size: 11.5px; color: #8D92B2; }
.logout-btn {
  margin-top: 8px; width: 100%; padding: 7px; border-radius: var(--radius);
  border: 1px solid #333B66; background: transparent; color: #C6CAE0; font-size: 13px; cursor: pointer;
}
.logout-btn:hover { background: var(--ink-2); }

.main { flex: 1; min-width: 0; }
.topbar {
  height: 60px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 26px; border-bottom: 1px solid var(--line); background: var(--paper-card);
  position: sticky; top: 0; z-index: 5;
}
.page-title { font-size: 18px; }
.content { padding: 26px; max-width: 1320px; }

/* ---------- Cards / summary ---------- */
.card {
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.summary-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; margin-bottom: 22px; }
@media (max-width: 1100px) { .summary-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px) { .summary-grid { grid-template-columns: repeat(2, 1fr); } }
.summary-card { background: var(--paper-card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.summary-card .label { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.summary-card .value { font-family: var(--font-mono); font-size: 24px; font-weight: 700; }
.summary-card.warn .value { color: var(--clay); }
.summary-card.good .value { color: var(--teal); }
.summary-card.in .value { color: var(--amber); }

/* ---------- Tables ---------- */
.table-wrap { background: var(--paper-card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left; padding: 10px 14px; background: #FAFAF7;
  border-bottom: 1px solid var(--line); color: var(--text-muted); font-weight: 600; font-size: 12px;
}
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #FBFBF9; }
.sku { font-family: var(--font-mono); font-size: 12.5px; color: var(--text-muted); }

.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; }
.badge.in-stock { background: var(--teal-bg); color: var(--teal); }
.badge.low-stock { background: var(--amber-bg); color: var(--amber); }
.badge.out-of-stock { background: var(--clay-bg); color: var(--clay); }
.badge.active { background: var(--teal-bg); color: var(--teal); }
.badge.inactive { background: #EFEFEF; color: #888; }
.badge.type-in { background: var(--amber-bg); color: var(--amber); }
.badge.type-out { background: var(--clay-bg); color: var(--clay); }
.badge.type-adjustment { background: #EDE9F7; color: #6B4FA0; }
.badge.type-opening { background: #E9EEF7; color: #3E6BAE; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 5px; color: var(--text-muted); }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--radius);
  font-size: 13.5px; background: #fff; color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--ink-3); outline-offset: -1px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.hint { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }
.error-text { font-size: 12px; color: var(--danger); margin-top: 4px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 9px 16px; border-radius: var(--radius); font-size: 13.5px; font-weight: 600;
  border: 1px solid transparent; cursor: pointer; transition: filter .12s ease;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.15); }
.btn-outline { background: transparent; border-color: var(--line); color: var(--text); }
.btn-outline:hover:not(:disabled) { background: #F1F1EC; }
.btn-danger { background: var(--clay); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(1.08); }
.btn-in { background: var(--amber); color: #241705; }
.btn-out { background: var(--clay); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.icon-btn { background: transparent; border: none; cursor: pointer; padding: 4px 6px; border-radius: 4px; color: var(--text-muted); }
.icon-btn:hover { background: #EFEFEA; color: var(--text); }

/* ---------- Toolbar / filters ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .grow { flex: 1; min-width: 180px; }
.search-input { position: relative; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(18,23,43,0.45);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal { background: #fff; border-radius: 8px; width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; padding: 24px; }
.modal-wide { max-width: 760px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ---------- Toast ---------- */
.toast-stack { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { padding: 12px 16px; border-radius: var(--radius); font-size: 13.5px; color: #fff; min-width: 240px; box-shadow: 0 6px 20px rgba(0,0,0,0.18); }
.toast.success { background: var(--teal); }
.toast.error { background: var(--clay); }
.toast.info { background: var(--ink-2); }

/* ---------- Login ---------- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--ink); }
.login-card { background: var(--paper-card); border-radius: 10px; padding: 38px 36px; width: 100%; max-width: 380px; }
.login-brand { text-align: center; margin-bottom: 26px; }
.login-brand .brand-mark { font-size: 26px; }
.login-brand .brand-name { display: block; font-size: 15px; margin-top: 4px; color: var(--text-muted); font-weight: 500; }
.login-error { background: var(--clay-bg); color: var(--clay); padding: 10px 12px; border-radius: var(--radius); font-size: 13px; margin-bottom: 14px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; margin-bottom: 18px; font-size: 13px; color: var(--text-muted); }
.checkbox-row input { width: auto; }
.login-demo { margin-top: 18px; font-size: 11.5px; color: var(--text-muted); text-align: center; line-height: 1.6; }

/* ---------- Misc ---------- */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); font-size: 13.5px; }
.pagination { display: flex; justify-content: flex-end; gap: 8px; align-items: center; padding: 12px 14px; font-size: 13px; color: var(--text-muted); }
.section-title { margin-bottom: 14px; font-size: 16px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tab { padding: 9px 14px; font-size: 13.5px; cursor: pointer; border-bottom: 2px solid transparent; color: var(--text-muted); }
.tab.active { color: var(--text); border-bottom-color: var(--ink); font-weight: 600; }
.stock-diff-pos { color: var(--teal); font-family: var(--font-mono); }
.stock-diff-neg { color: var(--clay); font-family: var(--font-mono); }
.perm-table td, .perm-table th { text-align: center; }
.perm-table td:first-child, .perm-table th:first-child { text-align: left; }
