/* AfricanSpring Ice — SaaS dashboard.
   Dark navy rail, light blue-gradient canvas, cobalt accent, cyan mark.
   Desktop: fixed sidebar + top bar. Mobile: dark header + bottom tabs. */

:root {
  /* rail (dark chrome) */
  --ink: #0c1a25;
  --ink-2: #152a37;
  --ink-text: rgba(255, 255, 255, 0.92);
  --ink-muted: rgba(255, 255, 255, 0.5);
  --ink-line: rgba(255, 255, 255, 0.08);
  --ice: #34c6e6;

  /* content (light) */
  --bg: #f5f8fc;
  --surface: #ffffff;
  --text: #10161d;
  --muted: #5c6672;
  --faint: #93a0ad;
  --border: #e7ebf0;
  --border-strong: #d3dae2;

  --accent: #1e6fe6;
  --accent-strong: #165fd0;
  --accent-ink: #ffffff;
  --accent-soft: #e8f1fd;
  --accent-softer: #f2f7fe;

  --danger: #c33b3f;
  --danger-soft: #fbeeee;
  --ok: #1f7a4d;
  --ok-soft: #e9f4ee;
  --warn: #8a6420;
  --warn-soft: #f7f1e2;

  --radius: 16px;
  --radius-sm: 11px;
  --tap: 48px;

  --sidebar-w: 240px;
  --content-w: 1120px;
  --form-w: 560px;

  --shadow: 0 1px 2px rgba(16, 30, 45, 0.05);
  --shadow-lg: 0 6px 24px rgba(16, 40, 70, 0.06);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  font-optical-sizing: auto;
}

a { color: var(--accent); text-decoration: none; }
.num { font-variant-numeric: tabular-nums; }

.icon {
  width: 20px; height: 20px;
  stroke: currentColor; fill: none;
  stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
  flex: none;
}

.only-desktop { display: none; }
.only-mobile { display: block; }
@media (min-width: 900px) {
  .only-desktop { display: block; }
  .only-mobile { display: none; }
}

/* Brand mark ---------------------------------------------------------- */
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--ice);
  display: flex; align-items: center; justify-content: center; flex: none;
}
.brand-mark .icon { width: 19px; height: 19px; stroke: var(--ink); stroke-width: 2.2; }

/* Sidebar ------------------------------------------------------------- */
.sidebar {
  display: none;
  position: fixed; inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--ink);
  flex-direction: column;
  padding: 18px 14px 16px;
  z-index: 30;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 11px;
  color: var(--ink-text);
  padding: 6px 8px;
  margin-bottom: 18px;
}
.sidebar .brand .b-name { font-weight: 800; font-size: 15px; letter-spacing: -0.01em; line-height: 1.1; }
.sidebar .brand .b-tag { display: block; font-weight: 500; font-size: 11.5px; color: var(--ink-muted); }
.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-label {
  font-size: 10.5px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ink-muted); padding: 16px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--ink-muted);
  font-size: 14px; font-weight: 600;
}
.nav-item .icon { width: 18px; height: 18px; }
.nav-item:hover { color: var(--ink-text); background: var(--ink-line); }
.nav-item.on { color: #fff; background: var(--accent); }

.sidebar-foot {
  border-top: 1px solid var(--ink-line);
  padding: 14px 10px 0;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.sidebar-foot .who { font-size: 13px; font-weight: 700; color: var(--ink-text); }
.sidebar-foot .who small { display: block; color: var(--ink-muted); font-weight: 500; font-size: 11.5px; }
.sidebar-foot .link { color: var(--ice); }
.link {
  background: none; border: none; padding: 0;
  color: var(--accent); font-size: 13.5px; font-weight: 700; cursor: pointer;
  font-family: inherit;
}

/* Mobile header ------------------------------------------------------- */
.app-header {
  position: sticky; top: 0; z-index: 20;
  background: var(--ink);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; height: 56px;
}
.app-header .brand { display: flex; align-items: center; gap: 10px; }
.app-header .brand .b-name { color: var(--ink-text); font-weight: 800; font-size: 15px; }
.app-header .brand .brand-mark { width: 28px; height: 28px; border-radius: 8px; }
.app-header .brand .brand-mark .icon { width: 16px; height: 16px; }
.app-header .who { color: var(--ink-muted); font-size: 13px; font-weight: 600; }

/* Top bar (desktop) --------------------------------------------------- */
.topbar { display: none; }

/* Tab bar (mobile) ---------------------------------------------------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; padding: 8px 0 7px;
  color: var(--faint); font-size: 10.5px; font-weight: 700;
}
.tab .icon { width: 22px; height: 22px; }
.tab.on { color: var(--accent); }

/* Shell --------------------------------------------------------------- */
.content { min-height: 100vh; }
.container {
  max-width: var(--form-w);
  margin: 0 auto;
  padding: 20px 16px 104px;
}
.container.wide { max-width: var(--content-w); }

@media (min-width: 900px) {
  body.authed { background: #eaf0f7; }
  .shell.authed .sidebar { display: flex; }
  .shell.authed .app-header, .shell.authed .tabbar { display: none; }
  .shell.authed .content {
    margin-left: var(--sidebar-w);
    background: linear-gradient(178deg, #e7f0fb 0%, #f4f8fc 300px, #f4f8fc 100%);
    background-color: #f4f8fc;
    min-height: 100vh;
  }
  .shell.authed .topbar {
    display: flex; align-items: center; gap: 14px;
    height: 60px; padding: 0 32px;
    border-bottom: 1px solid rgba(16,40,70,0.05);
  }
  .topbar .tb-icon { color: var(--faint); }
  .topbar .tb-sep { color: var(--border-strong); }
  .topbar .tb-crumb { font-size: 13.5px; font-weight: 700; color: var(--muted); }
  .container { padding: 30px 32px 60px; }
}

/* Type ---------------------------------------------------------------- */
.page-title { font-size: 27px; font-weight: 800; letter-spacing: -0.03em; margin: 2px 0 2px; }
.page-sub { color: var(--muted); margin: 0 0 22px; font-size: 14.5px; }
.section-label {
  font-size: 11px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.09em; color: var(--faint);
  margin: 28px 0 10px;
}
.muted { color: var(--muted); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.page-head .page-title { margin: 0; }
.view-all { font-size: 13px; font-weight: 700; color: var(--accent); }

.back {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--muted); font-size: 13.5px; font-weight: 600; margin-bottom: 14px;
}
.back .icon { width: 15px; height: 15px; }
.back:hover { color: var(--text); }

/* Cards / lists ------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.list-row {
  display: flex; align-items: center; gap: 13px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.list-row:last-child { border-bottom: none; }
a.list-row:hover { background: var(--accent-softer); }
.list-row .row-main { min-width: 0; flex: 1; }
.list-row .primary { font-weight: 700; font-size: 14.5px; }
.list-row .secondary { color: var(--muted); font-size: 13px; }
.list-row .amount { font-variant-numeric: tabular-nums; font-weight: 800; white-space: nowrap; font-size: 14.5px; }
.list-row .row-right { display: flex; align-items: center; gap: 10px; flex: none; }
.list-row .chev { color: var(--border-strong); width: 16px; height: 16px; }

.avatar {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent);
  font-weight: 800; font-size: 13px;
}
.avatar.ghost { background: #eef1f5; color: var(--muted); }
.avatar .icon { width: 18px; height: 18px; }

.empty {
  text-align: center; color: var(--muted);
  padding: 36px 16px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  font-size: 14px;
}

/* KPI cards ------------------------------------------------------------ */
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (min-width: 900px) { .kpi-grid { grid-template-columns: repeat(4, 1fr); gap: 16px; } }
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.kpi-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.kpi-label { font-size: 10.5px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.kpi-chip {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center; flex: none;
}
.kpi-chip .icon { width: 18px; height: 18px; }
.kpi-value { font-size: 29px; font-weight: 800; letter-spacing: -0.03em; margin-top: 14px; font-variant-numeric: tabular-nums; }
.kpi-value.neg { color: var(--danger); }
.kpi-sub { color: var(--faint); font-size: 12.5px; margin-top: 3px; font-weight: 500; }

/* Data table ----------------------------------------------------------- */
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--faint); font-weight: 800; padding: 13px 18px; border-bottom: 1px solid var(--border);
}
table.data th.right, table.data td.right { text-align: right; }
table.data td { padding: 15px 18px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover td { background: var(--accent-softer); cursor: pointer; }
table.data .t-primary { font-weight: 700; }
table.data .t-note { color: var(--muted); font-size: 12.5px; }
table.data .t-strong { font-weight: 800; font-variant-numeric: tabular-nums; }

/* Inventory cards ------------------------------------------------------ */
.inv-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 700px) { .inv-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .inv-grid { grid-template-columns: repeat(3, 1fr); } }
.inv-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.inv-head { display: flex; align-items: center; gap: 10px; }
.inv-head .avatar { width: 34px; height: 34px; border-radius: 9px; }
.inv-head .n { font-weight: 800; font-size: 15px; flex: 1; }
.inv-value { font-size: 34px; font-weight: 800; letter-spacing: -0.03em; margin: 12px 0 1px; font-variant-numeric: tabular-nums; }
.inv-meta { color: var(--muted); font-size: 13px; }
.inv-actions { display: flex; gap: 8px; margin-top: 14px; align-items: center; }
.inv-actions input { width: 64px; min-height: 40px; text-align: center; padding: 0 8px;
  border: 1.5px solid var(--border-strong); border-radius: 10px; font-size: 15px; font-family: inherit; font-weight: 600; }
.inv-updated { color: var(--faint); font-size: 12px; margin-top: 12px; }

/* Tiles / stats -------------------------------------------------------- */
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (min-width: 900px) {
  .action-grid { grid-template-columns: repeat(3, 1fr); }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .stat-grid.two { grid-template-columns: repeat(2, 1fr); }
}
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; min-height: 116px;
  display: flex; flex-direction: column; gap: 14px; color: var(--text);
  transition: border-color .12s ease, transform .06s ease;
}
.tile:hover { border-color: var(--border-strong); }
.tile:active { border-color: var(--accent); transform: scale(0.99); }
.tile-icon {
  width: 38px; height: 38px; border-radius: 11px;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.tile .t-title { display: block; font-weight: 800; font-size: 15px; letter-spacing: -0.01em; }
.tile .t-sub { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; font-weight: 500; }

.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 15px 16px; }
.stat .value { font-size: 24px; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.stat .label { color: var(--muted); font-size: 12.5px; margin-top: 2px; font-weight: 600; }
.stat .value.neg { color: var(--danger); }
.stat .value.pos { color: var(--ok); }

/* Pipeline list -------------------------------------------------------- */
.pipe-row { display: flex; align-items: center; justify-content: space-between; padding: 11px 0; border-bottom: 1px solid var(--border); }
.pipe-row:last-child { border-bottom: none; }
.pipe-row .p-name { font-weight: 600; font-size: 14px; }
.pipe-count { min-width: 26px; height: 24px; padding: 0 8px; border-radius: 8px; background: var(--accent-soft); color: var(--accent);
  font-weight: 800; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; }

/* Balance hero (store detail) ------------------------------------------ */
.balance {
  background: var(--ink); border-radius: var(--radius); padding: 20px;
  color: var(--ink-text); display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
}
.balance .b-label { font-size: 11px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-muted); }
.balance .b-value { font-size: 24px; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; margin-top: 3px; }
.balance .b-value.owe { color: #ffb0aa; }
.balance .b-value.ok { color: var(--ice); }

/* CTA ------------------------------------------------------------------ */
.cta { display: flex; align-items: center; gap: 14px; background: var(--accent); color: #fff; border-radius: var(--radius); padding: 18px; }
.cta:hover { background: var(--accent-strong); }
.cta .cta-icon { width: 42px; height: 42px; border-radius: 12px; background: rgba(255,255,255,0.18); display: flex; align-items: center; justify-content: center; flex: none; }
.cta .cta-icon .icon { stroke: #fff; width: 21px; height: 21px; stroke-width: 2.1; }
.cta .cta-title { display: block; color: #fff; font-weight: 800; font-size: 16px; letter-spacing: -0.01em; }
.cta .cta-sub { display: block; color: rgba(255,255,255,0.82); font-size: 12.5px; font-weight: 500; }
.cta .cta-go { margin-left: auto; }
.cta .cta-go .icon { stroke: rgba(255,255,255,0.8); }

/* Badges --------------------------------------------------------------- */
.badge { display: inline-block; font-size: 11.5px; font-weight: 800; padding: 2.5px 9px; border-radius: 999px; background: #eef1f5; color: #49545f; }
.badge.supplying { background: var(--ok-soft); color: var(--ok); }
.badge.intalks   { background: var(--warn-soft); color: var(--warn); }
.badge.prospect  { background: var(--accent-soft); color: var(--accent); }
.badge.declined  { background: #eef1f5; color: #6b7681; }
.badge.owner     { background: var(--accent-soft); color: var(--accent); }
.badge.installed { background: var(--ok-soft); color: var(--ok); }
.badge.faulty    { background: var(--danger-soft); color: var(--danger); }

/* Forms ---------------------------------------------------------------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.field input, .field select, .field textarea, .qty-row input {
  width: 100%; min-height: var(--tap);
  border: 1.5px solid var(--border-strong); border-radius: 11px;
  background: var(--surface); padding: 0 13px;
  font-size: 16px; color: var(--text); font-family: inherit; font-weight: 500;
}
.field textarea { padding: 11px 13px; min-height: 84px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .qty-row input:focus, .inv-actions input:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.field .hint { color: var(--muted); font-size: 12.5px; margin-top: 6px; }
.field-error { color: var(--danger); font-size: 13.5px; font-weight: 600; margin: 8px 0 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
form.narrow { max-width: var(--form-w); }

/* Buttons -------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: var(--tap); padding: 0 20px; border-radius: 11px;
  border: 1.5px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-size: 14.5px; font-weight: 700; cursor: pointer; font-family: inherit;
}
.btn:hover { border-color: var(--faint); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-block { width: 100%; }
.btn-sm { min-height: 40px; padding: 0 14px; font-size: 13.5px; border-radius: 10px; }
.btn .icon { width: 16px; height: 16px; }

.action-bar { margin-top: 22px; }
@media (max-width: 899px) {
  .action-bar {
    position: sticky; bottom: calc(58px + env(safe-area-inset-bottom));
    background: linear-gradient(to top, var(--bg) 75%, rgba(245,248,252,0));
    padding: 14px 0 10px;
  }
  body.no-tabbar .action-bar { bottom: 0; }
}

/* Segmented ------------------------------------------------------------ */
.seg { display: grid; grid-auto-flow: column; gap: 5px; background: #eaeef3; border-radius: 12px; padding: 4px; }
.seg label { display: flex; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { flex: 1; text-align: center; padding: 10px 8px; border-radius: 9px; font-size: 13.5px; font-weight: 700; color: var(--muted); cursor: pointer; }
.seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* Toggle --------------------------------------------------------------- */
.toggle { display: flex; align-items: center; gap: 12px; padding: 6px 0 4px; font-weight: 700; font-size: 14px; cursor: pointer; }
.toggle input { appearance: none; -webkit-appearance: none; width: 46px; height: 28px; border-radius: 999px; background: var(--border-strong); position: relative; flex: none; cursor: pointer; transition: background .15s ease; margin: 0; }
.toggle input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: var(--shadow); transition: transform .15s ease; }
.toggle input:checked { background: var(--accent); }
.toggle input:checked::after { transform: translateX(18px); }

/* Delivery lines / totals ---------------------------------------------- */
.qty-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.qty-row:last-child { border-bottom: none; }
.qty-row .q-name { font-weight: 700; font-size: 14.5px; }
.qty-row .q-price { color: var(--muted); font-size: 12.5px; }
.qty-row input { width: 92px; text-align: center; flex: none; }
.total-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 2px; font-size: 16.5px; font-weight: 800; }
.total-row .amount { font-variant-numeric: tabular-nums; }

/* Definition rows ------------------------------------------------------ */
.dl { margin: 0; }
.dl .row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.dl .row:last-child { border-bottom: none; }
.dl dt { color: var(--muted); font-size: 13.5px; font-weight: 500; }
.dl dd { margin: 0; font-weight: 700; text-align: right; font-size: 13.5px; }
.pill-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* Login ---------------------------------------------------------------- */
body.unauth { background: var(--ink); }
.login-wrap { max-width: 400px; margin: 9vh auto 40px; padding: 0 18px; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 30px; }
.login-brand .brand-mark { width: 40px; height: 40px; border-radius: 11px; }
.login-brand .brand-mark .icon { width: 21px; height: 21px; }
.login-brand span { color: var(--ink-text); font-weight: 800; font-size: 17px; letter-spacing: -0.01em; }
.login-card { background: var(--surface); border-radius: 18px; padding: 26px 22px 22px; box-shadow: var(--shadow-lg); }
.login-title { font-size: 21px; font-weight: 800; letter-spacing: -0.02em; margin: 0 0 4px; }
.login-sub { color: var(--muted); margin: 0 0 22px; font-size: 14px; }

/* Columns / feed ------------------------------------------------------- */
.cols { display: grid; gap: 12px; }
@media (min-width: 900px) { .cols { grid-template-columns: 1.4fr 1fr; gap: 20px; align-items: start; } }
.feed-day { font-size: 11px; font-weight: 800; letter-spacing: 0.09em; text-transform: uppercase; color: var(--faint); margin: 20px 0 8px; }
.feed-day:first-of-type { margin-top: 4px; }
