/* ==========================================================================
   STOCKROOM. — retail inventory & stock control.
   Design category: LIGHT BUSINESS SOFTWARE. Near-white ground, indigo accent,
   Inter for UI and IBM Plex Mono for SKUs and quantities. Dense data table as
   the centrepiece — a different structure again from the other four apps.
   ========================================================================= */

:root {
  --bg: #f5f6f9;
  --surface: #ffffff;
  --surface-2: #fbfbfd;
  --ink: #14161a;
  --body: #4a5262;
  --muted: #8b93a3;
  --line: #e4e7ee;
  --line-soft: #eef0f5;

  --indigo: #3d4ef5;
  --indigo-deep: #2c3bd6;
  --indigo-soft: #edeffe;

  --green: #0f9d6e;
  --green-soft: #e3f6ef;
  --amber: #c98509;
  --amber-soft: #fdf2dc;
  --red: #d93b40;
  --red-soft: #fdeaeb;

  --ui: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;

  --side-w: 232px;
  --sh-1: 0 1px 2px rgba(20, 22, 26, 0.05);
  --sh-2: 0 12px 30px -12px rgba(20, 22, 26, 0.18);
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--indigo-soft); }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ------------------------------------------------------------------ SHELL */
.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }

/* ---------------------------------------------------------------- SIDEBAR */
.side {
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}

.side__brand {
  display: flex; align-items: center; gap: 9px;
  padding: 18px 18px 16px;
  font-weight: 700; font-size: 15px; letter-spacing: -0.02em;
}

.side__mark {
  width: 26px; height: 26px; border-radius: 8px;
  background: var(--indigo); color: #fff;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700;
}

.side__nav { padding: 4px 10px; display: grid; gap: 2px; }

.navitem {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  font-size: 13.5px; font-weight: 500; color: var(--body);
  cursor: pointer; border: 0; background: none; width: 100%; text-align: left;
  transition: background-color 120ms ease, color 120ms ease;
}

.navitem:hover { background: var(--surface-2); color: var(--ink); }
.navitem[aria-current="page"] { background: var(--indigo-soft); color: var(--indigo-deep); font-weight: 600; }
.navitem svg { flex: none; opacity: 0.75; }
.navitem[aria-current="page"] svg { opacity: 1; }

.navitem__badge {
  margin-left: auto;
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  background: var(--red-soft); color: var(--red);
  padding: 1px 6px; border-radius: 99px;
}

.side__store {
  margin-top: auto;
  padding: 14px 18px 18px;
  border-top: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: 10px;
}

.side__store b { display: block; font-size: 13px; font-weight: 600; }
.side__store span { display: block; font-size: 11.5px; color: var(--muted); }

.dot-live { width: 7px; height: 7px; border-radius: 50%; background: var(--green); flex: none; }

/* ------------------------------------------------------------------ MAIN */
.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: saturate(150%) blur(10px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 16px;
  padding: 12px 26px;
}

.search {
  flex: 1; max-width: 400px;
  display: flex; align-items: center; gap: 9px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 7px 11px;
}

.search input {
  border: 0; background: none; outline: none;
  font: inherit; color: var(--ink); width: 100%;
}
.search input::placeholder { color: var(--muted); }

.topbar__right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.iconbtn {
  width: 34px; height: 34px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface);
  display: grid; place-items: center; cursor: pointer; color: var(--body);
}
.iconbtn:hover { background: var(--surface-2); color: var(--ink); }

.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--indigo-soft); color: var(--indigo-deep);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
}

.page { padding: 24px 26px 60px; display: grid; gap: 20px; }

.page__head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.page__head h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; margin: 0; }
.page__head p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }

/* ----------------------------------------------------------------- BUTTON */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-family: var(--ui); font-weight: 600; font-size: 13px;
  padding: 8px 14px; border-radius: var(--r-sm);
  border: 1px solid transparent; cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}
.btn--primary { background: var(--indigo); color: #fff; }
.btn--primary:hover { background: var(--indigo-deep); }
.btn--ghost { background: var(--surface); border-color: var(--line); color: var(--body); }
.btn--ghost:hover { border-color: #cdd3e0; color: var(--ink); }
.btn--sm { padding: 5px 10px; font-size: 12px; }
.btn[disabled] { opacity: 0.45; pointer-events: none; }

/* ----------------------------------------------------------------- BANNER */
.banner {
  position: relative;
  border-radius: var(--r-md);
  overflow: hidden;
  min-height: 132px;
  display: flex;
  align-items: flex-end;
  isolation: isolate;
  border: 1px solid var(--line);
}

.banner img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -2; }

.banner::after {
  content: "";
  position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(92deg, rgba(12, 14, 18, 0.88) 0%, rgba(12, 14, 18, 0.55) 52%, rgba(12, 14, 18, 0.12) 100%);
}

.banner__body { padding: 18px 22px; max-width: 60ch; }
.banner__eyebrow {
  margin: 0 0 5px;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.13em; text-transform: uppercase;
  color: #a9b4ff;
}
.banner__text { margin: 0; color: #f2f4f8; font-size: 14.5px; line-height: 1.5; }

/* ------------------------------------------------------------------- KPIs */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }

.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 16px 18px;
  box-shadow: var(--sh-1);
  display: flex; flex-direction: column; gap: 6px;
}

.kpi__top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.kpi__label { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: 0.01em; }

.kpi__icon {
  width: 28px; height: 28px; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--indigo-soft); color: var(--indigo-deep);
}
.kpi__icon--amber { background: var(--amber-soft); color: var(--amber); }
.kpi__icon--red { background: var(--red-soft); color: var(--red); }
.kpi__icon--green { background: var(--green-soft); color: var(--green); }

.kpi__value { font-family: var(--mono); font-size: 26px; font-weight: 500; letter-spacing: -0.02em; line-height: 1.1; }
.kpi__foot { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi__up { color: var(--green); font-weight: 600; }
.kpi__down { color: var(--red); font-weight: 600; }

/* ------------------------------------------------------------------ PANEL */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--sh-1);
  overflow: hidden;
}

.panel__head {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.panel__head h2 { font-size: 14.5px; font-weight: 700; letter-spacing: -0.01em; margin: 0; }
.panel__head .spacer { margin-left: auto; }

.cols { display: grid; grid-template-columns: minmax(0, 1fr) 344px; gap: 20px; align-items: start; }

/* ---------------------------------------------------------------- FILTERS */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }

.chip {
  font-size: 12px; font-weight: 600;
  padding: 5px 11px; border-radius: 99px;
  border: 1px solid var(--line); background: var(--surface); color: var(--body);
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}
.chip:hover { border-color: #cdd3e0; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip__n { font-family: var(--mono); opacity: 0.62; margin-left: 5px; }

/* ------------------------------------------------------------------ TABLE */
.tablewrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

thead th {
  text-align: left;
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted);
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  background: var(--surface-2);
}

thead th.num, tbody td.num { text-align: right; }
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--ink); }
thead th[aria-sort] { color: var(--indigo); }

tbody tr { border-bottom: 1px solid var(--line-soft); cursor: pointer; transition: background-color 120ms ease; }
tbody tr:last-child { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }

tbody td { padding: 11px 14px; vertical-align: middle; }

.sku { font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: nowrap; }

.product { display: flex; align-items: center; gap: 11px; }
.product img { width: 34px; height: 34px; border-radius: var(--r-sm); object-fit: cover; background: var(--bg); flex: none; }
.product b { display: block; font-weight: 600; font-size: 13.5px; }
.product span { display: block; font-size: 11.5px; color: var(--muted); }

.qty { font-family: var(--mono); font-size: 13.5px; }
.qty small { color: var(--muted); }

/* stock level meter */
.meter { display: flex; align-items: center; gap: 9px; }
.meter__bar { width: 66px; height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; flex: none; }
.meter__bar span { display: block; height: 100%; width: 0; border-radius: 3px; background: var(--green); transition: width 700ms cubic-bezier(0.2, 0.9, 0.3, 1); }
.meter__bar--low span { background: var(--amber); }
.meter__bar--out span { background: var(--red); }

/* status pills */
.status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 600;
  padding: 3px 9px; border-radius: 99px;
  white-space: nowrap;
}
.status i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; display: block; }
.status--ok { background: var(--green-soft); color: var(--green); }
.status--low { background: var(--amber-soft); color: var(--amber); }
.status--out { background: var(--red-soft); color: var(--red); }

/* --------------------------------------------------------------- SIDE COL */
.stack { display: grid; gap: 20px; }

.reorder {
  display: grid; grid-template-columns: 30px minmax(0, 1fr) auto;
  gap: 12px; align-items: center;
  padding: 11px 18px;
  border-bottom: 1px solid var(--line-soft);
}
.reorder:last-child { border-bottom: 0; }
.reorder img { width: 30px; height: 30px; border-radius: var(--r-sm); object-fit: cover; }
.reorder b { display: block; font-size: 13px; font-weight: 600; }
.reorder span { display: block; font-size: 11.5px; color: var(--muted); font-family: var(--mono); }

.category {
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px; align-items: center;
  padding: 10px 18px;
}
.category b { font-size: 13px; font-weight: 500; }
.category span { font-family: var(--mono); font-size: 12px; color: var(--muted); }

/* ------------------------------------------------------------------ CHART */
.chart { display: flex; align-items: flex-end; gap: 10px; height: 130px; padding: 18px; }
.chart__col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 7px; height: 100%; justify-content: flex-end; }
.chart__stack { width: 100%; display: flex; flex-direction: column; justify-content: flex-end; gap: 3px; height: 100%; }
.chart__bar { border-radius: 3px 3px 0 0; height: 0; transition: height 800ms cubic-bezier(0.2, 0.9, 0.3, 1); }
.chart__bar--in { background: var(--indigo); }
.chart__bar--out { background: #cdd3e0; border-radius: 0 0 3px 3px; }
.chart__col small { font-family: var(--mono); font-size: 10.5px; color: var(--muted); }

.legend { display: flex; gap: 16px; padding: 0 18px 16px; font-size: 12px; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 9px; height: 9px; border-radius: 3px; display: block; }

/* ----------------------------------------------------------------- DRAWER */
.drawer { position: fixed; inset: 0; z-index: 60; display: none; }
.drawer[data-open="true"] { display: block; }

.drawer__scrim { position: absolute; inset: 0; background: rgba(20, 22, 26, 0.32); animation: fade 160ms ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.drawer__panel {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: min(420px, 100vw);
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: -20px 0 50px -24px rgba(20, 22, 26, 0.3);
  overflow-y: auto;
  animation: slidein 240ms cubic-bezier(0.2, 0.9, 0.3, 1);
}
@keyframes slidein { from { transform: translateX(24px); opacity: 0.4; } to { transform: none; opacity: 1; } }

.drawer__head { display: flex; align-items: flex-start; gap: 14px; padding: 20px; border-bottom: 1px solid var(--line-soft); }
.drawer__head img { width: 54px; height: 54px; border-radius: var(--r-md); object-fit: cover; }
.drawer__head h3 { font-size: 16px; font-weight: 700; margin: 0 0 3px; }
.drawer__head p { margin: 0; font-size: 12.5px; color: var(--muted); font-family: var(--mono); }

.drawer__close { margin-left: auto; }

.rows { display: grid; padding: 6px 20px 0; }
.row { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.row span { color: var(--muted); }
.row b { font-weight: 600; }
.row b.mono { font-family: var(--mono); font-weight: 500; }

.drawer__foot { display: flex; gap: 9px; padding: 18px 20px 24px; }
.drawer__foot .btn { flex: 1; }

/* ------------------------------------------------------------------- TOAST */
.toast {
  position: fixed; left: 50%; bottom: 26px;
  transform: translate(-50%, 14px);
  z-index: 90;
  background: var(--ink); color: #fff;
  font-size: 13px; font-weight: 500;
  padding: 11px 18px; border-radius: var(--r-sm);
  box-shadow: var(--sh-2);
  opacity: 0; pointer-events: none;
  transition: opacity 180ms ease, transform 200ms cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.toast[data-show="true"] { opacity: 1; transform: translate(-50%, 0); }

/* -------------------------------------------------------------- RESPONSIVE */
@media (max-width: 1120px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; align-items: center; border-right: 0; border-bottom: 1px solid var(--line); }
  .side__nav { display: flex; overflow-x: auto; padding: 8px; }
  .navitem { width: auto; white-space: nowrap; }
  .navitem__badge { margin-left: 6px; }
  .side__store { margin: 0; border-top: 0; padding: 12px 16px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .topbar { padding: 10px 16px; }
  .search { max-width: none; }
  .page { padding: 18px 16px 50px; }
  .side__store { display: none; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 13px 14px; }
  .kpi__value { font-size: 21px; }
  .kpi__label { font-size: 11px; }
  table { min-width: 720px; }
}
