:root {
  --bg: #0b1020;
  --bg-soft: #121a30;
  --card: #151e36;
  --card-2: #1a2440;
  --line: #26314e;
  --text: #e8ecf7;
  --muted: #94a1c0;
  --accent: #6ee7b7;
  --accent-2: #60a5fa;
  --warn: #fbbf24;
  --bad: #f87171;
  --good: #34d399;
  --shadow: 0 12px 30px rgba(3, 7, 18, 0.45);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 10% -10%, #16224a 0%, var(--bg) 55%) fixed;
  color: var(--text);
  font: 14px/1.45 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
}

code { background: #0d1428; padding: 1px 5px; border-radius: 4px; font-size: 12px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 22px;
  background: rgba(11, 16, 32, 0.86);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  letter-spacing: 0.3px;
}
.brand-logo {
  height: 56px;
  width: auto;
  max-width: 120px;
  border-radius: 0;
  background: transparent;
  padding: 0;
  object-fit: contain;
  filter: drop-shadow(0 3px 8px rgba(3, 7, 18, 0.55));
  flex: none;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.05; gap: 1px; }
.brand-name { font-size: 17px; font-weight: 800; letter-spacing: 0.2px; }
.brand-name .biz { color: #ef4444; }
.brand-name .sol { color: #2dd4bf; }
.brand-slogan {
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.45px;
  color: #a9b6d3;
  margin-top: 1px;
}
.brand-tagline {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  color: #ffffff;
  margin-top: 1px;
}



.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.field { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
select, input, button {
  font: inherit;
  color: var(--text);
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
}
select:focus, input:focus, button:focus { outline: 2px solid var(--accent-2); outline-offset: 1px; }
button { cursor: pointer; transition: 120ms ease; }
button:hover { border-color: var(--accent-2); transform: translateY(-1px); }
button.ghost { background: transparent; }
button.primary { background: linear-gradient(135deg, #2563eb, #0ea5e9); border-color: transparent; font-weight: 600; }
button.tiny { padding: 4px 8px; font-size: 12px; }

.badge {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: #0e1730;
}

main { padding: 20px 22px 60px; max-width: 1500px; margin: 0 auto; display: grid; gap: 16px; }

.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); }

.kpi {
  background: linear-gradient(160deg, var(--card), var(--bg-soft));
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}
.kpi .label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.7px; }
.kpi .value { font-size: 21px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 11px; color: var(--muted); margin-top: 3px; }
.kpi.pos .value { color: var(--good); }
.kpi.neg .value { color: var(--bad); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.card h2 { font-size: 14px; margin: 0; letter-spacing: 0.3px; }
.card-head { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }

.grid-2 { display: grid; gap: 16px; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); }
.grid-3 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
@media (max-width: 980px) { .grid-2 { grid-template-columns: 1fr; } }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }

.chart { width: 100%; height: 250px; }
.chart svg { width: 100%; height: 100%; overflow: visible; }
.legend { display: flex; gap: 16px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.swatch.sales { background: #3b82f6; }
.swatch.spend { background: #f59e0b; }
.swatch.profit { background: var(--good); }

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.table th, table.table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.table th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; font-weight: 600; }
table.table tbody tr:hover { background: #172142; }
table.table td.num, table.table th.num { text-align: right; }
table.tight td, table.tight th { padding: 6px 8px; }
table.table tr.total td { font-weight: 700; border-top: 1px solid var(--line); }
.row-neg { color: var(--bad); }
.row-pos { color: var(--good); }

.pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
}
.pill.INCREASE { background: rgba(52, 211, 153, 0.14); color: var(--good); border-color: rgba(52, 211, 153, 0.35); }
.pill.REDUCE { background: rgba(251, 191, 36, 0.12); color: var(--warn); border-color: rgba(251, 191, 36, 0.35); }
.pill.PAUSE { background: rgba(248, 113, 113, 0.14); color: var(--bad); border-color: rgba(248, 113, 113, 0.35); }
.pill.HOLD { background: rgba(96, 165, 250, 0.12); color: var(--accent-2); border-color: rgba(96, 165, 250, 0.3); }
.pill.RESTOCK_FIRST { background: rgba(167, 139, 250, 0.14); color: #c4b5fd; border-color: rgba(167, 139, 250, 0.35); }
.pill.status { background: #0e1730; color: var(--muted); border-color: var(--line); }
.pill.DELIVERED { background: rgba(52, 211, 153, 0.12); color: var(--good); }
.pill.RETURNED { background: rgba(248, 113, 113, 0.12); color: var(--bad); }
.pill.IN_TRANSIT, .pill.PICKED, .pill.BOOKED { background: rgba(96, 165, 250, 0.12); color: var(--accent-2); }

.reasons { color: var(--muted); font-size: 12px; line-height: 1.5; white-space: normal; min-width: 260px; }
.reasons li { margin-left: 14px; }

.platform {
  background: linear-gradient(160deg, var(--card-2), var(--card));
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}
.platform h3 { margin: 0 0 8px; font-size: 13px; letter-spacing: 0.5px; display: flex; justify-content: space-between; }
.platform .big { font-size: 20px; font-weight: 700; }
.platform dl { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; margin: 10px 0 0; font-size: 12px; }
.platform dt { color: var(--muted); }
.platform dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

.inline-form { display: flex; gap: 8px; }
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translate(-50%, 20px);
  background: var(--card-2);
  border: 1px solid var(--line);
  padding: 10px 16px;
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  transition: 200ms ease;
  box-shadow: var(--shadow);
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: rgba(248, 113, 113, 0.5); color: var(--bad); }

/* -------------------------------------------------------- help assistant */
.assistant-toggle {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 40;
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 600;
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  border: 1px solid transparent;
  box-shadow: var(--shadow);
}
.assistant-panel {
  position: fixed;
  right: 20px;
  bottom: 78px;
  z-index: 41;
  width: min(420px, calc(100vw - 32px));
  max-height: min(620px, calc(100vh - 110px));
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.assistant-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--card-2);
}
.assistant-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.assistant-msg { max-width: 100%; font-size: 13px; line-height: 1.5; }
.assistant-msg.user {
  align-self: flex-end;
  background: #1d4ed8;
  color: #fff;
  padding: 8px 11px;
  border-radius: 12px 12px 2px 12px;
  max-width: 85%;
}
.assistant-msg.bot {
  align-self: flex-start;
  background: var(--card-2);
  border: 1px solid var(--line);
  padding: 10px 12px;
  border-radius: 12px 12px 12px 2px;
}
.assistant-msg.bot.warn { border-color: rgba(251, 191, 36, 0.45); }
.assistant-msg ul { margin: 6px 0 0; padding-left: 16px; }
.assistant-msg li { margin: 4px 0; }
.assistant-msg code { font-size: 11px; }
.assistant-screens { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.assistant-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 14px 0;
}
.assistant-suggestions button {
  font-size: 11px;
  padding: 4px 9px;
  border-radius: 999px;
  background: #0e1730;
  color: var(--muted);
}
.assistant-suggestions button:hover { color: var(--text); }
.assistant-form {
  display: flex;
  gap: 8px;
  padding: 10px 14px 14px;
}
.assistant-form input { flex: 1; }

/* ---------------------------------------------------------------- navigation */
.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  align-items: center;
}
.nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.nav a:hover { color: var(--text); background: #16203c; }
.nav a.active {
  color: var(--text);
  background: #1b2748;
  border-color: var(--line);
  font-weight: 600;
}

/* -------------------------------------------------------------------- forms */
.form-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  align-items: end;
  margin-bottom: 10px;
}
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
}
.form-grid input,
.form-grid select { width: 100%; }
.row-actions { display: flex; gap: 10px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.editor { margin-top: 12px; }
.editor summary { cursor: pointer; color: var(--accent-2); font-size: 13px; margin-bottom: 8px; }
.settings-group {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
}
.settings-group legend {
  padding: 0 6px;
  color: var(--text);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
}
.form-grid label .muted { font-size: 10px; opacity: 0.7; }
.notice {
  border: 1px solid rgba(251, 191, 36, 0.4);
  background: rgba(251, 191, 36, 0.08);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 12px;
  color: var(--warn);
  font-size: 13px;
}
.notice p { margin: 4px 0; }

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.inline-check input { width: auto; }

.cost-cell { display: flex; align-items: center; gap: 6px; }
.cost-cell input { width: 90px; }
.unit-tag {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 6px;
  background: #0e1730;
}

.view { display: grid; gap: 16px; }

