:root {
  --orange: #FF6B2C;
  --navy: #1A1A2E;
  --green: #00A651;
  --blue: #00AED6;
  --shopee: #EE4D2D;
  --bg: #F4F5F7;
  --card: #FFFFFF;
  --border: #E5E7EB;
  --text: #1A1A2E;
  --text-muted: #6B7280;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.hidden { display: none !important; }

/* ── Gate ─────────────────────────────────────────────────────── */
.gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--navy), #2d2d4f);
}
.gate-card {
  background: var(--card);
  padding: 36px 32px;
  border-radius: var(--radius);
  width: 320px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);
}
.gate-card h1 { margin: 0 0 4px; font-size: 20px; }
.muted { color: var(--text-muted); font-size: 13px; margin: 0 0 20px; }
.gate-card input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  margin-bottom: 12px;
}

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  padding: 10px 16px;
  border-radius: var(--radius);
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
}
.btn:hover { opacity: 0.88; }
.btn-primary { background: var(--orange); color: white; }
.btn-outline { background: white; color: var(--orange); border: 1px solid var(--orange); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-block { width: 100%; }
.btn-danger { background: #DC2626; color: white; }
.btn-sm { padding: 6px 10px; font-size: 12px; }

.error { color: #DC2626; font-size: 13px; min-height: 18px; margin-top: 8px; }

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

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 24px;
  background: var(--navy);
  color: white;
  flex-wrap: wrap;
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.logo { font-weight: 700; font-size: 16px; white-space: nowrap; }
#outletSelect {
  padding: 8px 12px;
  border-radius: var(--radius);
  border: none;
  font-size: 14px;
  font-weight: 600;
}
.tabs { display: flex; gap: 4px; margin-left: auto; }
.tab-btn {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.65);
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.tab-btn.active { background: rgba(255,255,255,0.12); color: white; }
#logoutBtn { color: rgba(255,255,255,0.6); }

.content { padding: 20px 24px 60px; max-width: 1100px; margin: 0 auto; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Toolbar ──────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: end;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.field-group { display: flex; flex-direction: column; gap: 4px; }
.field-group label { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.field-group input, .search-input {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
}
.search-input { min-width: 220px; }
.loading { font-size: 13px; color: var(--text-muted); }

/* ── Cards / metrics ──────────────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.metric-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.metric-card.highlight { border-color: var(--orange); background: #FFF7F2; }
.metric-label { font-size: 12px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; }
.metric-value { font-size: 22px; font-weight: 700; }

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.panel h3 { margin: 0 0 12px; font-size: 14px; }
.hint { font-size: 12px; color: var(--text-muted); margin: 10px 0 0; }

.empty { text-align: center; color: var(--text-muted); padding: 60px 0; }

/* ── Charts (SVG, hand-rolled — lihat referensi dataviz skill) ───────── */
.chart-wrap { margin-bottom: 14px; position: relative; }
.chart-wrap svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-bar-label { font-size: 11px; fill: var(--text-muted); font-family: inherit; }
.chart-value-label { font-size: 11px; font-weight: 600; fill: var(--text); font-family: inherit; }
.chart-axis-label { font-size: 10px; fill: var(--text-muted); font-family: inherit; }
.chart-gridline { stroke: #E1E0D9; stroke-width: 1; }
.chart-empty { color: var(--text-muted); font-size: 13px; padding: 20px 0; text-align: center; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 10px 16px; margin: 4px 0 12px; font-size: 12px; color: var(--text-muted); }
.chart-legend-item { display: flex; align-items: center; gap: 6px; }
.chart-legend-swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; flex: none; }
.chart-tooltip {
  position: absolute;
  background: var(--navy);
  color: white;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 6px;
  pointer-events: none;
  white-space: nowrap;
  transform: translate(-50%, -110%);
  z-index: 50;
  box-shadow: 0 6px 18px rgba(0,0,0,0.2);
}

/* ── Tables ───────────────────────────────────────────────────── */
.table-scroll { overflow-x: auto; }
.chart-split { display: flex; gap: 20px; flex-wrap: wrap; }
.chart-split .chart-wrap { flex: 1 1 280px; min-width: 0; }

.cmp-outlet-picker { display: flex; flex-direction: column; gap: 10px; }
.cmp-brand-group { display: flex; flex-direction: column; gap: 4px; }
.cmp-brand-group .brand-label { font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px; }
.cmp-brand-group .outlet-checks { display: flex; flex-wrap: wrap; gap: 10px 16px; }
.cmp-brand-group label { display: flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
.simple-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.simple-table th {
  text-align: left;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.simple-table td { padding: 9px 10px; border-bottom: 1px solid #F0F1F3; }
.simple-table tbody tr:last-child td { border-bottom: none; }
.simple-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.simple-table.editable input[type=text],
.simple-table.editable input[type=number] {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 13px;
  background: transparent;
}
.simple-table.editable input:hover,
.simple-table.editable input:focus {
  border-color: var(--border);
  background: #FAFAFB;
}
.simple-table.editable input:disabled { color: #C4C7CD; }

.row-inactive { opacity: 0.45; }

/* ── Modal ────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal {
  background: white;
  border-radius: var(--radius);
  padding: 24px;
  width: 340px;
}
.modal h3 { margin: 0 0 16px; }
.modal label { display: block; font-size: 12px; color: var(--text-muted); font-weight: 600; margin: 10px 0 4px; }
.modal input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
}
.modal-actions { display: flex; gap: 8px; margin-top: 18px; justify-content: flex-end; }

/* ── Toast ────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%);
  background: var(--navy);
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  z-index: 200;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}
.toast.error { background: #DC2626; }

/* ── Status badge (Forecast & Stok) — status palette, bukan kategorikal */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.02em; white-space: nowrap;
}
.badge-aman   { background: #EAF7EE; color: #0ca30c; }
.badge-low    { background: #FFF7E8; color: #B5790F; }
.badge-kritis { background: #FDECEA; color: #d03b3b; }
.badge-empty  { background: #F3F4F6; color: var(--text-muted); }

@media (max-width: 640px) {
  .topbar { flex-direction: column; align-items: stretch; gap: 10px; }
  .tabs { margin-left: 0; }
  .content { padding: 14px; }
}
