/* Brand tokens (PROMPT §14) */
@font-face { font-family: "Almarai"; src: url("../fonts/almarai/Almarai-Light.8a509ba4e13f.woff2") format("woff2"), url("../fonts/almarai/Almarai-Light.b71af73441cd.ttf") format("truetype"); font-weight: 300; font-display: swap; }
@font-face { font-family: "Almarai"; src: url("../fonts/almarai/Almarai-Regular.3dc4261039dc.woff2") format("woff2"), url("../fonts/almarai/Almarai-Regular.43597c8a6eb4.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Almarai"; src: url("../fonts/almarai/Almarai-Bold.141ffec65c5e.woff2") format("woff2"), url("../fonts/almarai/Almarai-Bold.dd32140b4616.ttf") format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Almarai"; src: url("../fonts/almarai/Almarai-ExtraBold.a4068db302c1.woff2") format("woff2"), url("../fonts/almarai/Almarai-ExtraBold.26765177ab88.ttf") format("truetype"); font-weight: 800; font-display: swap; }

:root {
  --steel: #1E3A5F;
  --brick: #C2410C;
  --helmet: #F5B700;
  --cement: #6B7280;
  --sand: #F7F5F2;
  --up: #15803D;
  --down: #B91C1C;

  --app-bg: var(--sand);
  --app-surface: #FFFFFF;
  --app-text: #1F2937;
  --app-muted: var(--cement);
  --app-border: #E5E1DA;
  --radius-card: 12px;
  --tap: 48px;
  --chart-1: #2B6CB0;  /* validated: L/chroma band + contrast on white */
  --bottom-nav-h: 64px;

  --bs-font-sans-serif: "Almarai", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  --bs-body-font-family: var(--bs-font-sans-serif);
  --bs-primary: var(--steel);
  --bs-primary-rgb: 30, 58, 95;
  --bs-body-bg: var(--app-bg);
  --bs-body-color: var(--app-text);
  --bs-border-radius: 10px;
}

[data-bs-theme="dark"] {
  --app-bg: #0F1720;
  --app-surface: #18222E;
  --app-text: #E5E7EB;
  --app-muted: #9CA3AF;
  --app-border: #2A3644;
  --chart-1: #5B9BF0;  /* validated against the dark surface */
  --bs-body-bg: var(--app-bg);
  --bs-body-color: var(--app-text);
  --bs-primary-rgb: 96, 140, 196;
}

html, body { background: var(--app-bg); color: var(--app-text); }
body {
  font-family: var(--bs-body-font-family);
  font-variant-numeric: lining-nums tabular-nums;
  min-width: 360px;
  padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px) + 12px);
}
.num, input[type="number"], .ltr { direction: ltr; unicode-bidi: isolate; }

/* Top bar */
.app-topbar { background: var(--steel); color: #fff; min-height: 56px; }
.app-topbar a, .app-topbar .btn-link { color: #fff; text-decoration: none; }
.app-topbar .brand-mark { width: 10px; height: 28px; background: var(--helmet); border-radius: 3px; }

/* Cards */
.card, .app-card {
  border-radius: var(--radius-card);
  background: var(--app-surface);
  border: 1px solid var(--app-border);
}
.stat-card .stat-label { color: var(--app-muted); font-size: .85rem; }
.stat-card .stat-value { font-size: 1.5rem; font-weight: 800; }
.text-up { color: var(--up) !important; }
.text-down { color: var(--down) !important; }
.bg-helmet { background: var(--helmet) !important; color: #1F2937 !important; }
.btn-brick { background: var(--brick); border-color: var(--brick); color: #fff; }
.btn-brick:hover, .btn-brick:focus { background: #A3360A; border-color: #A3360A; color: #fff; }
.btn-brick:disabled, .btn-brick.disabled { background: var(--brick); border-color: var(--brick); color: #fff; opacity: .5; }

/* Touch targets >= 48px */
.btn, .form-control, .form-select { min-height: var(--tap); }
.btn-sm { min-height: 40px; }

/* Bottom navigation */
.bottom-nav {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 1030;
  height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--app-surface); border-top: 1px solid var(--app-border);
  display: flex;
}
.bottom-nav a {
  flex: 1 1 0; min-width: var(--tap); min-height: var(--tap);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--app-muted); text-decoration: none; font-size: .75rem;
}
.bottom-nav a i { font-size: 1.35rem; line-height: 1; }
.bottom-nav a.active { color: var(--brick); font-weight: 700; }
.bottom-nav a.nav-sell i {
  background: var(--brick); color: #fff; border-radius: 50%;
  width: 44px; height: 44px; display: grid; place-items: center; margin-top: -18px;
  box-shadow: 0 4px 10px rgba(194, 65, 12, .35);
}

/* Auth screen */
.auth-wrap { max-width: 420px; margin-inline: auto; padding-top: 8vh; }
.auth-wrap .brand-title { color: var(--steel); font-weight: 800; }
[data-bs-theme="dark"] .auth-wrap .brand-title { color: #fff; }

@media (min-width: 992px) {
  .bottom-nav { max-width: 640px; margin-inline: auto; border-radius: 16px 16px 0 0; border: 1px solid var(--app-border); }
}

/* Charts */
.chart-svg { width: 100%; height: auto; display: block; overflow: visible; direction: ltr; }
.chart-svg .grid { stroke: var(--app-border); stroke-width: 1; }
.chart-svg .axis-label { fill: var(--app-muted); font-size: 10px; font-family: var(--bs-body-font-family); }
.chart-svg .bar { fill: var(--chart-1); }
.chart-svg .bar.dim { opacity: .35; }
.chart-tip { position: absolute; pointer-events: none; background: var(--app-surface); border: 1px solid var(--app-border);
  border-radius: 8px; padding: 4px 8px; font-size: .8rem; box-shadow: 0 4px 12px rgba(0,0,0,.12); white-space: nowrap; transform: translate(-50%, -115%); }
