/* ============================================================
   Stocker — Inventory Management
   Design system: warm, utilitarian, data-dense enterprise
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  /* Surfaces — cool slate/gray */
  --bg:          #f1f5f9;
  --surface:     #ffffff;
  --surface-2:   #f8fafc;
  --surface-3:   #e2e8f0;

  /* Ink */
  --ink:         #0f172a;
  --ink-2:       #334155;
  --muted:       #64748b;
  --faint:       #94a3b8;

  /* Lines */
  --line:        #e2e8f0;
  --line-2:      #cbd5e1;
  --line-3:      #94a3b8;

  /* Brand accent — premium Indigo */
  --accent:      #4f46e5;
  --accent-hi:   #4338ca;
  --accent-ink:  #3730a3;
  --accent-soft: #eef2ff;
  --accent-line: #c7d2fe;

  /* Status */
  --ok:          #0d9488;
  --ok-soft:     #ccfbf1;
  --warn:        #d97706;
  --warn-soft:   #fef3c7;
  --bad:         #e11d48;
  --bad-soft:    #ffe4e6;
  --info:        #2563eb;
  --info-soft:   #dbeafe;
  --neutral:     #475569;
  --neutral-soft:#f1f5f9;

  /* Radii */
  --r-sm: 4px;
  --r:    6px;
  --r-lg: 9px;
  --r-xl: 14px;

  /* Shadow */
  --sh-1: 0 1px 2px rgba(40,30,15,.05), 0 1px 1px rgba(40,30,15,.04);
  --sh-2: 0 4px 12px rgba(40,30,15,.08), 0 1px 3px rgba(40,30,15,.06);
  --sh-3: 0 16px 44px rgba(40,30,15,.16), 0 4px 12px rgba(40,30,15,.10);

  --sidebar-w: 244px;
  --topbar-h: 60px;

  --font: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
.mono { font-family: var(--mono); }
.num { font-family: var(--mono); font-feature-settings: "tnum" 1; }

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

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--surface-2);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 0 18px;
  height: var(--topbar-h);
  border-bottom: 1px solid var(--line);
  flex: 0 0 var(--topbar-h);
}
.brand-mark {
  width: 28px; height: 28px; border-radius: 7px;
  background: var(--accent);
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 15px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.16);
}
.brand-name { font-weight: 600; font-size: 16px; letter-spacing: -.01em; }
.brand-name b { color: var(--accent); font-weight: 700; }

.nav {
  flex: 1 1 auto; overflow-y: auto;
  padding: 12px 10px 24px;
}
.nav-group { margin-top: 14px; }
.nav-group:first-child { margin-top: 2px; }
.nav-label {
  font-size: 10.5px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--faint);
  padding: 6px 10px 5px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; margin: 1px 0;
  border-radius: var(--r);
  color: var(--ink-2); font-weight: 500; font-size: 13.5px;
  cursor: pointer; position: relative;
  white-space: nowrap;
}
.nav-item:hover { background: var(--surface-3); color: var(--ink); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.nav-item.active .nav-ico { color: var(--accent); }
.nav-ico { width: 17px; height: 17px; flex: 0 0 17px; color: var(--muted); }
.nav-item.active .nav-ico, .nav-item:hover .nav-ico { color: currentColor; }
.nav-badge {
  margin-left: auto; font-family: var(--mono); font-size: 11px; font-weight: 600;
  background: var(--bad-soft); color: var(--bad);
  padding: 1px 6px; border-radius: 20px; min-width: 20px; text-align: center;
}
.nav-item.disabled { opacity: .38; pointer-events: none; }

.sidebar-foot {
  border-top: 1px solid var(--line); padding: 10px;
}

/* ---------- Main ---------- */
.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h); flex: 0 0 var(--topbar-h);
  background: rgba(250,248,244,.86);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 30;
}
.topbar h1 { font-size: 16px; font-weight: 600; margin: 0; letter-spacing: -.01em; }
.crumb { color: var(--faint); font-size: 13px; }
.crumb b { color: var(--ink-2); font-weight: 500; }
.topbar-search {
  margin-left: auto; position: relative; width: 280px;
}
.topbar-search input {
  width: 100%; height: 36px; padding: 0 12px 0 34px;
  border: 1px solid var(--line-2); border-radius: var(--r);
  background: var(--surface); font-size: 13px; color: var(--ink);
}
.topbar-search svg { position: absolute; left: 10px; top: 9px; color: var(--muted); }
.topbar-search input:focus { outline: none; border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }

.content { padding: 24px 28px 64px; flex: 1 1 auto; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 20px; }
.page-head .ph-text { min-width: 0; }
.page-title { font-size: 22px; font-weight: 600; letter-spacing: -.02em; margin: 0; }
.page-sub { color: var(--muted); font-size: 13.5px; margin: 3px 0 0; }
.page-head .ph-actions { margin-left: auto; display: flex; gap: 9px; align-items: center; }

/* ---------- Role switcher / user ---------- */
.role-pill {
  display: inline-flex; align-items: center; gap: 7px;
  height: 32px; padding: 0 10px; border-radius: 20px;
  border: 1px solid var(--line-2); background: var(--surface);
  font-size: 12.5px; font-weight: 500; color: var(--ink-2); cursor: pointer;
}
.role-pill:hover { border-color: var(--line-3); }
.role-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.user-chip {
  display: flex; align-items: center; gap: 9px; cursor: pointer;
  padding: 4px 6px 4px 4px; border-radius: 20px;
}
.user-chip:hover { background: var(--surface-3); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-ink);
  display: grid; place-items: center; font-weight: 600; font-size: 12px;
  border: 1px solid var(--accent-line);
}
.avatar.lg { width: 44px; height: 44px; font-size: 16px; }
.user-meta { line-height: 1.2; }
.user-meta .un { font-weight: 600; font-size: 13px; }
.user-meta .ur { font-size: 11.5px; color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: var(--r);
  font-size: 13.5px; font-weight: 600; cursor: pointer;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  transition: background .12s, border-color .12s, box-shadow .12s;
  white-space: nowrap; user-select: none;
}
.btn:hover { background: var(--surface-2); border-color: var(--line-3); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: var(--sh-1); }
.btn.primary:hover { background: var(--accent-hi); border-color: var(--accent-hi); }
.btn.danger { color: var(--bad); border-color: var(--line-2); }
.btn.danger:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn.icon { width: 34px; padding: 0; }
.btn.sm.icon { width: 30px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-row { display: flex; gap: 9px; align-items: center; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--sh-1);
}
.card-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.card-head h3 { margin: 0; font-size: 14.5px; font-weight: 600; }
.card-head .sub { color: var(--muted); font-size: 12.5px; }
.card-head .ch-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-body { padding: 18px; }
.card-body.flush { padding: 0; }

/* ---------- Stat tiles ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 16px 18px; box-shadow: var(--sh-1);
  position: relative; overflow: hidden;
}
.stat .label { font-size: 12px; color: var(--muted); font-weight: 500; display: flex; align-items: center; gap: 7px; }
.stat .label svg { width: 15px; height: 15px; color: var(--faint); }
.stat .value { font-family: var(--mono); font-size: 27px; font-weight: 600; letter-spacing: -.02em; margin-top: 8px; color: var(--ink); }
.stat .delta { font-size: 12px; font-weight: 500; margin-top: 5px; display: inline-flex; align-items: center; gap: 4px; }
.stat .delta.up { color: var(--ok); }
.stat .delta.down { color: var(--bad); }
.stat .delta.flat { color: var(--muted); }

/* ---------- Table ---------- */
.table-wrap { width: 100%; overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl thead th {
  text-align: left; font-weight: 600; font-size: 11.5px; letter-spacing: .03em;
  text-transform: uppercase; color: var(--muted);
  padding: 10px 14px; background: var(--surface-2);
  border-bottom: 1px solid var(--line-2); white-space: nowrap; position: sticky; top: 0;
}
table.tbl thead th.sortable { cursor: pointer; user-select: none; }
table.tbl thead th.sortable:hover { color: var(--ink-2); }
table.tbl thead th .sort-i { opacity: .4; margin-left: 3px; }
table.tbl thead th.num, table.tbl td.num { text-align: right; }
table.tbl tbody td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.tbl tbody tr:hover { background: var(--surface-2); }
table.tbl tbody tr.clickable { cursor: pointer; }
table.tbl tbody tr:last-child td { border-bottom: none; }
td .cell-strong { font-weight: 600; color: var(--ink); }
td .cell-sub { color: var(--muted); font-size: 12px; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; opacity: .35; transition: opacity .12s; }
tr:hover .row-actions { opacity: 1; }
.iconbtn {
  width: 28px; height: 28px; display: grid; place-items: center;
  border-radius: var(--r-sm); border: 1px solid transparent; background: transparent;
  color: var(--muted); cursor: pointer;
}
.iconbtn:hover { background: var(--surface-3); color: var(--ink); border-color: var(--line); }
.iconbtn.danger:hover { color: var(--bad); background: var(--bad-soft); }
.iconbtn svg { width: 15px; height: 15px; }

/* product thumb */
.thumb {
  width: 34px; height: 34px; border-radius: var(--r); flex: 0 0 34px;
  background:
    repeating-linear-gradient(45deg, var(--surface-3) 0 6px, var(--surface-2) 6px 12px);
  border: 1px solid var(--line); display: grid; place-items: center;
  color: var(--faint); font-size: 9px;
}
.cell-prod { display: flex; align-items: center; gap: 11px; }

/* ---------- Badges / pills ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 9px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600; line-height: 1;
  border: 1px solid transparent; white-space: nowrap;
}
.badge .bd { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok      { background: var(--ok-soft); color: var(--ok); }
.badge.warn    { background: var(--warn-soft); color: var(--warn); }
.badge.bad     { background: var(--bad-soft); color: var(--bad); }
.badge.info    { background: var(--info-soft); color: var(--info); }
.badge.neutral { background: var(--neutral-soft); color: var(--neutral); }
.badge.accent  { background: var(--accent-soft); color: var(--accent-ink); }
.tag {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px;
  border-radius: var(--r-sm); background: var(--surface-3); color: var(--ink-2);
  font-size: 12px; font-weight: 500; border: 1px solid var(--line);
}

/* ---------- Filter bar ---------- */
.toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; flex-wrap: wrap;
}
.search-inp { position: relative; }
.search-inp input {
  height: 34px; width: 240px; padding: 0 12px 0 32px;
  border: 1px solid var(--line-2); border-radius: var(--r);
  background: var(--surface); font-size: 13px;
}
.search-inp svg { position: absolute; left: 9px; top: 9px; color: var(--muted); width: 16px; height: 16px; }
.search-inp input:focus { outline: none; border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
select.sel, input.inp, textarea.inp {
  height: 34px; padding: 0 10px; border: 1px solid var(--line-2);
  border-radius: var(--r); background: var(--surface); font-size: 13px;
  color: var(--ink); font-family: inherit;
}
select.sel { padding-right: 26px; cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238c847b' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
}
select.sel:focus, input.inp:focus, textarea.inp:focus { outline: none; border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.toolbar .spacer { margin-left: auto; }
.result-count { font-size: 12.5px; color: var(--muted); }

/* segmented */
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--r); overflow: hidden; }
.seg button {
  height: 34px; padding: 0 12px; border: none; background: var(--surface);
  font-size: 12.5px; font-weight: 500; color: var(--ink-2); cursor: pointer;
  border-left: 1px solid var(--line);
}
.seg button:first-child { border-left: none; }
.seg button.on { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }

/* ---------- Modal ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(33,29,24,.42);
  backdrop-filter: blur(2px); z-index: 100;
  display: grid; place-items: start center; padding: 56px 20px;
  opacity: 0; pointer-events: none; transition: opacity .16s;
  overflow-y: auto;
}
.overlay.show { opacity: 1; pointer-events: auto; }
.modal {
  width: 100%; max-width: 560px; background: var(--surface);
  border-radius: var(--r-xl); box-shadow: var(--sh-3);
  transform: translateY(8px) scale(.99); transition: transform .18s;
  border: 1px solid var(--line);
}
.overlay.show .modal { transform: none; }
.modal.wide { max-width: 760px; }
.modal-head {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 22px; border-bottom: 1px solid var(--line);
}
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 600; }
.modal-head .sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.modal-body { padding: 20px 22px; max-height: 62vh; overflow-y: auto; }
.modal-foot {
  display: flex; gap: 10px; justify-content: flex-end; align-items: center;
  padding: 16px 22px; border-top: 1px solid var(--line); background: var(--surface-2);
  border-radius: 0 0 var(--r-xl) var(--r-xl);
}
.modal-foot .spacer { margin-right: auto; }
.x-close { margin-left: auto; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.field label .req { color: var(--bad); }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.field input.inp, .field select.sel, .field textarea.inp { width: 100%; height: 38px; }
.field textarea.inp { height: auto; min-height: 72px; padding: 9px 10px; resize: vertical; line-height: 1.5; }
.field.err input.inp, .field.err select.sel, .field.err textarea.inp { border-color: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.field .err-msg { color: var(--bad); font-size: 12px; margin-top: 5px; display: none; }
.field.err .err-msg { display: block; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }
.input-affix { position: relative; }
.input-affix .affix { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); font-family: var(--mono); font-size: 13px; }
.input-affix input { padding-left: 24px !important; }

.switch { position: relative; width: 38px; height: 22px; flex: 0 0 38px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; background: var(--line-3); border-radius: 20px; transition: background .15s; cursor: pointer; }
.switch .track::after { content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%; background: #fff; top: 2px; left: 2px; transition: transform .15s; box-shadow: var(--sh-1); }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); }

/* checkbox */
.cbx { width: 17px; height: 17px; border: 1.5px solid var(--line-3); border-radius: 4px; background: var(--surface); cursor: pointer; appearance: none; display: inline-grid; place-items: center; flex: 0 0 17px; }
.cbx:checked { background: var(--accent); border-color: var(--accent); }
.cbx:checked::after { content: ''; width: 9px; height: 9px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6L9 17l-5-5'/%3E%3C/svg%3E") center/contain no-repeat; }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  display: flex; align-items: center; gap: 11px;
  background: var(--ink); color: #faf8f4; padding: 12px 16px; border-radius: var(--r-lg);
  box-shadow: var(--sh-3); font-size: 13.5px; font-weight: 500; min-width: 240px;
  transform: translateX(120%); transition: transform .26s cubic-bezier(.2,.9,.3,1);
}
.toast.show { transform: none; }
.toast .ti { width: 18px; height: 18px; flex: 0 0 18px; }
.toast.ok .ti { color: #7dd49a; }
.toast.bad .ti { color: #f3a08c; }

/* ---------- Empty / misc ---------- */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty svg { width: 34px; height: 34px; color: var(--faint); margin-bottom: 10px; }
.empty h4 { margin: 0 0 4px; color: var(--ink-2); font-size: 15px; }
.divider { height: 1px; background: var(--line); margin: 18px 0; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 9px 16px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }

/* dropdown menu */
.menu {
  position: absolute; z-index: 120; background: var(--surface);
  border: 1px solid var(--line-2); border-radius: var(--r-lg); box-shadow: var(--sh-3);
  padding: 6px; min-width: 190px;
}
.menu-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r); font-size: 13px; cursor: pointer; color: var(--ink-2); }
.menu-item:hover { background: var(--surface-3); color: var(--ink); }
.menu-item svg { width: 16px; height: 16px; color: var(--muted); }
.menu-item.danger { color: var(--bad); }
.menu-item.danger svg { color: var(--bad); }
.menu-sep { height: 1px; background: var(--line); margin: 5px 0; }
.menu-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--faint); padding: 7px 10px 4px; font-weight: 600; }

/* progress / meter */
.meter { height: 7px; border-radius: 20px; background: var(--surface-3); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 20px; background: var(--accent); }
.meter.ok > span { background: var(--ok); }
.meter.warn > span { background: var(--warn); }
.meter.bad > span { background: var(--bad); }

/* layout helpers */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; }
.split { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; align-items: start; }
.row { display: flex; align-items: center; gap: 10px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.muted { color: var(--muted); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt0{margin-top:0}.mt8{margin-top:8px}.mt16{margin-top:16px}.mt24{margin-top:24px}
.mb0{margin-bottom:0}

@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2,1fr); }
  .split { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}
