/* ============================================================
   cartwell shared stylesheet
   A light, airy retail operations app. Cool neutrals, teal accent,
   one coral highlight per page. Dark mode via prefers-color-scheme.
   ============================================================ */

:root {
  --teal: #0E9488;
  --teal-600: #0B7D73;
  --ink: #0E1417;
  --muted: #5A636B;
  --hairline: rgba(14, 20, 23, .10);
  --hairline-strong: rgba(14, 20, 23, .16);
  --ground: #F4F7F7;
  --surface: #FFFFFF;
  --surface-2: #FCFDFD;
  --coral: #FF6B4A;
  --green: #129E6A;
  --amber: #E0952A;
  --red: #E0503A;

  --tint-teal: rgba(14, 148, 136, .10);
  --tint-coral: rgba(255, 107, 74, .12);
  --tint-green: rgba(18, 158, 106, .12);
  --tint-amber: rgba(224, 149, 42, .14);
  --tint-red: rgba(224, 80, 58, .12);

  --sidebar-bg: #EAF1F0;
  --sidebar-active: rgba(14, 148, 136, .12);

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-1: 0 1px 2px rgba(14, 20, 23, .04), 0 1px 1px rgba(14, 20, 23, .03);
  --shadow-2: 0 6px 20px rgba(14, 20, 23, .07), 0 1px 2px rgba(14, 20, 23, .04);

  --font-display: "Bricolage Grotesque", "Trebuchet MS", system-ui, sans-serif;
  --font-body: "Instrument Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --sidebar-w: 248px;
  --content-max: 1160px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --teal: #23B3A5;
    --teal-600: #4CC7BB;
    --ink: #EAF2F1;
    --muted: #9AA6AC;
    --hairline: rgba(234, 242, 241, .12);
    --hairline-strong: rgba(234, 242, 241, .20);
    --ground: #0C1416;
    --surface: #121D20;
    --surface-2: #162427;
    --coral: #FF8365;
    --green: #35B983;
    --amber: #E8AA4A;
    --red: #EC6B57;

    --tint-teal: rgba(35, 179, 165, .16);
    --tint-coral: rgba(255, 131, 101, .16);
    --tint-green: rgba(53, 185, 131, .16);
    --tint-amber: rgba(232, 170, 74, .18);
    --tint-red: rgba(236, 107, 87, .16);

    --sidebar-bg: #101B1E;
    --sidebar-active: rgba(35, 179, 165, .18);

    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-2: 0 8px 26px rgba(0, 0, 0, .5);
  }
}

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

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

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--ground);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 700; letter-spacing: -.01em; margin: 0; }

a { color: inherit; text-decoration: none; }

.tnum { font-variant-numeric: tabular-nums; }

/* ---------- App shell ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--hairline);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 8px 0;
}
.brand__mark {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -.02em;
  color: var(--ink);
}
.brand__dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--coral);
  display: inline-block;
  margin-left: 1px;
  transform: translateY(2px);
}

.storecard {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
}
.storecard__badge {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: var(--tint-teal);
  color: var(--teal);
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  flex: none;
}
.storecard__name { font-weight: 600; font-size: 14px; line-height: 1.2; }
.storecard__plan {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: .02em;
  color: var(--teal);
  text-transform: uppercase;
  margin-top: 3px;
}

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav__eyebrow {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 10px 6px;
}
.nav__item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-weight: 500;
  font-size: 14px;
  transition: background .15s ease, color .15s ease;
}
.nav__item svg { width: 18px; height: 18px; flex: none; color: var(--muted); transition: color .15s ease; }
.nav__item:hover { background: var(--sidebar-active); }
.nav__item:hover svg { color: var(--teal); }
.nav__item.is-active {
  background: var(--sidebar-active);
  color: var(--teal-600);
  font-weight: 600;
}
.nav__item.is-active svg { color: var(--teal); }
.nav__item.is-muted { color: var(--muted); }
.nav__item.is-muted svg { color: var(--muted); opacity: .8; }
.nav__soon {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: .04em;
  color: var(--muted);
  border: 1px solid var(--hairline);
  border-radius: 5px;
  padding: 1px 5px;
}

.sidebar__foot {
  margin-top: auto;
  font-size: 12px;
  color: var(--muted);
  padding: 0 10px;
  line-height: 1.45;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 24px;
  background: color-mix(in srgb, var(--ground) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--hairline);
}
.topbar__title { font-size: 19px; font-weight: 700; }
.topbar__spacer { flex: 1; }

.iconbtn {
  width: 38px; height: 38px;
  border: 1px solid var(--hairline);
  background: var(--surface);
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  color: var(--muted);
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease;
}
.iconbtn:hover { color: var(--teal); border-color: var(--hairline-strong); }
.iconbtn svg { width: 18px; height: 18px; }

.menutoggle { display: none; }

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  width: 260px;
  color: var(--muted);
}
.search svg { width: 16px; height: 16px; flex: none; }
.search input {
  border: 0;
  background: transparent;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--ink);
  width: 100%;
}
.search input::placeholder { color: var(--muted); }
.search input:focus { outline: none; }
.search:focus-within { border-color: var(--teal); }

.segment {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}
.segment button {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .02em;
  color: var(--muted);
  background: transparent;
  border: 0;
  padding: 5px 11px;
  border-radius: 6px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.segment button:hover { color: var(--ink); }
.segment button.is-on { background: var(--tint-teal); color: var(--teal-600); }

.avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--teal), var(--teal-600));
  color: #fff;
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  flex: none;
}

/* ---------- Content ---------- */
.content {
  padding: 26px 24px 40px;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  flex: 1;
}

.pagehead { margin-bottom: 22px; }
.pagehead h1 { font-size: 26px; }
.pagehead p { color: var(--muted); margin: 6px 0 0; font-size: 14.5px; max-width: 60ch; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}

.section { margin-top: 28px; }
.section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.section__head h2 { font-size: 17px; }
.section__link {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--teal-600);
  font-weight: 500;
}
.section__link:hover { text-decoration: underline; }

/* ---------- KPI tiles ---------- */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 16px 17px;
  box-shadow: var(--shadow-1);
}
.kpi__top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi__label { font-size: 13px; color: var(--muted); font-weight: 500; }
.kpi__unit {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .06em;
  color: var(--muted);
  border: 1px solid var(--hairline);
  border-radius: 5px;
  padding: 1px 5px;
}
.kpi__value {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 27px;
  letter-spacing: -.02em;
  margin: 12px 0 8px;
}
.kpi__foot { display: flex; align-items: center; gap: 8px; }
.kpi__note { font-size: 12px; color: var(--muted); }
.delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 5px;
}
.delta svg { width: 11px; height: 11px; }
.delta--up { color: var(--green); background: var(--tint-green); }
.delta--down { color: var(--red); background: var(--tint-red); }

/* ---------- Cards / panels ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}
.card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 18px 0;
}
.card__title { font-size: 16px; font-weight: 700; font-family: var(--font-display); }
.card__sub { font-size: 12.5px; color: var(--muted); }
.card__body { padding: 16px 18px; }

.grid-2 {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 16px;
  align-items: stretch;
}

/* ---------- Charts ---------- */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart__axis { font-family: var(--font-mono); font-size: 10px; fill: var(--muted); }
.chart__grid { stroke: var(--hairline); stroke-width: 1; }
.chart__area { fill: url(#cartwellArea); }
.chart__line { fill: none; stroke: var(--teal); stroke-width: 2.25; stroke-linecap: round; stroke-linejoin: round; }
.chart__dot { fill: var(--surface); stroke: var(--teal); stroke-width: 2; }
.chart__peak { fill: var(--coral); }
.chart__barlabel { font-family: var(--font-mono); font-size: 11px; fill: var(--muted); }
.chart__barvalue { font-family: var(--font-mono); font-size: 11px; fill: var(--ink); font-weight: 500; }

.barlist { display: flex; flex-direction: column; gap: 15px; }
.barrow { display: grid; grid-template-columns: 108px 1fr 44px; align-items: center; gap: 12px; }
.barrow__label { font-size: 13px; color: var(--muted); }
.barrow__track { height: 9px; border-radius: 6px; background: var(--ground); overflow: hidden; }
.barrow__fill { height: 100%; border-radius: 6px; transform-origin: left; }
.barrow__value { font-family: var(--font-mono); font-size: 13px; font-weight: 500; text-align: right; }

/* ---------- Tables ---------- */
.tablewrap {
  overflow-x: auto;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}
table.data { width: 100%; border-collapse: collapse; min-width: 640px; }
table.data thead th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 13px 16px;
  border-bottom: 1px solid var(--hairline);
  white-space: nowrap;
  background: var(--surface-2);
}
table.data tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--hairline);
  font-size: 14px;
  white-space: nowrap;
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr { transition: background .12s ease; }
table.data tbody tr:hover { background: var(--surface-2); }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.td-right { text-align: right; }
.cell-strong { font-weight: 600; }
.cell-id { font-family: var(--font-mono); font-size: 13px; color: var(--teal-600); font-weight: 500; }
.cell-muted { color: var(--muted); }

tr.is-low td { background: var(--tint-red); }
tr.is-low:hover td { background: color-mix(in srgb, var(--tint-red) 70%, var(--surface)); }

/* ---------- Pills / chips ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: .01em;
  padding: 3px 9px 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.pill--green { color: var(--green); background: var(--tint-green); }
.pill--green .dot { background: var(--green); }
.pill--amber { color: var(--amber); background: var(--tint-amber); }
.pill--amber .dot { background: var(--amber); }
.pill--red { color: var(--red); background: var(--tint-red); }
.pill--red .dot { background: var(--red); }
.pill--teal { color: var(--teal-600); background: var(--tint-teal); }
.pill--teal .dot { background: var(--teal); }
.pill--muted { color: var(--muted); background: var(--ground); }
.pill--muted .dot { background: var(--muted); }

.tag {
  display: inline-flex;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .02em;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid var(--hairline);
  color: var(--muted);
}
.tag--vip { color: var(--coral); border-color: color-mix(in srgb, var(--coral) 40%, transparent); background: var(--tint-coral); }
.tag--loyal { color: var(--teal-600); border-color: color-mix(in srgb, var(--teal) 35%, transparent); background: var(--tint-teal); }
.tag--wholesale { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 40%, transparent); background: var(--tint-amber); }

/* ---------- Filter chips (static UI) ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip {
  font-size: 13px;
  font-weight: 500;
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.chip:hover { color: var(--ink); border-color: var(--hairline-strong); }
.chip.is-on { background: var(--tint-teal); color: var(--teal-600); border-color: color-mix(in srgb, var(--teal) 35%, transparent); }

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.field {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 7px 11px;
  color: var(--muted);
  font-size: 13px;
}
.field svg { width: 15px; height: 15px; }
.field select {
  border: 0; background: transparent; font-family: var(--font-body);
  font-size: 13px; color: var(--ink); cursor: pointer;
}
.field select:focus { outline: none; }

/* ---------- Low-stock list ---------- */
.stocklist { display: flex; flex-direction: column; }
.stockrow {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--hairline);
}
.stockrow:last-child { border-bottom: 0; }
.stockrow__icon {
  width: 32px; height: 32px; border-radius: 8px; flex: none;
  background: var(--tint-red); color: var(--red);
  display: grid; place-items: center;
}
.stockrow__icon svg { width: 16px; height: 16px; }
.stockrow__name { font-weight: 600; font-size: 14px; }
.stockrow__sku { font-family: var(--font-mono); font-size: 11px; color: var(--muted); margin-top: 2px; }
.stockrow__meta { margin-left: auto; text-align: right; }
.stockrow__count { font-family: var(--font-mono); font-weight: 600; font-size: 15px; }
.stockrow__count b { color: var(--red); }
.stockrow__hint { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* ---------- Footer note ---------- */
.demonote {
  margin-top: 34px;
  padding-top: 16px;
  border-top: 1px solid var(--hairline);
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12.5px;
  color: var(--muted);
}
.demonote svg { width: 15px; height: 15px; flex: none; color: var(--teal); }

/* ---------- Focus ---------- */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- Scrim for mobile sidebar ---------- */
.scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(14, 20, 23, .4);
  z-index: 30;
}

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: no-preference) {
  .reveal { animation: rise .5s cubic-bezier(.2, .7, .2, 1) both; }
  .reveal[data-d="1"] { animation-delay: .05s; }
  .reveal[data-d="2"] { animation-delay: .1s; }
  .reveal[data-d="3"] { animation-delay: .15s; }
  .reveal[data-d="4"] { animation-delay: .2s; }
  @keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
  .barrow__fill { animation: grow .7s cubic-bezier(.2, .7, .2, 1) both; }
  @keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
  .chart__line { stroke-dasharray: 1200; stroke-dashoffset: 0; animation: draw 1s ease both; }
  @keyframes draw { from { stroke-dashoffset: 1200; } to { stroke-dashoffset: 0; } }
}

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0; left: 0;
    width: 264px;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform .22s ease;
  }
  .app.nav-open .sidebar { transform: none; }
  .app.nav-open .scrim { display: block; }
  .menutoggle { display: grid; }
  .search { display: none; }
  .content { padding: 22px 16px 36px; }
  .topbar { padding: 12px 16px; }
}

@media (max-width: 560px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi__value { font-size: 23px; }
  .segment { display: none; }
  .topbar__title { font-size: 17px; }
  .pagehead h1 { font-size: 22px; }
}

@media (max-width: 400px) {
  .kpis { grid-template-columns: 1fr; }
}
