/* =========================================================
   Guardios theme: design tokens + Bootstrap 5.3 overrides + g-* components.
   Ported from the design mockup (design/guardios_app/assets/css/guardios.css, lines 1-232 and
   the generic utilities) for plan 04-p2-design-system.md §4. Shared with the future website:
   nothing app-specific here (the shell is in app.css). Changes from the mockup:
   - --g-dim-text (Q1): text uses of the dim colour; --g-dim stays for decoration (§4.3);
   - score ring and meter are SVG, coloured by tone classes, no style="" (P2-5);
   - .g-risk.unknown: a banner for a missing or unknown risk level.
   ========================================================= */

:root,
[data-bs-theme="dark"] {
  --g-bg: #05090b;
  --g-bg-2: #081014;
  --g-surface: #0c1519;
  --g-surface-2: #111e23;
  --g-surface-3: #17272d;
  --g-line: rgba(196, 232, 222, 0.09);
  --g-line-2: rgba(196, 232, 222, 0.16);
  --g-text: #e7f1ee;
  --g-muted: #8ea39f;
  --g-dim: #5d716d; /* decorative only (chevrons, dividers): 3.8:1 on --g-bg */
  --g-dim-text: #6f837e; /* text in the dim colour: about 5.0:1 on --g-bg (WCAG AA) */

  --g-mint: #2ee59d;
  --g-mint-2: #1fbf80;
  --g-mint-soft: rgba(46, 229, 157, 0.12);
  --g-amber: #f6b93b;
  --g-amber-soft: rgba(246, 185, 59, 0.14);
  --g-red: #ff4d5e;
  --g-red-soft: rgba(255, 77, 94, 0.14);
  --g-blue: #5aa9ff;
  --g-blue-soft: rgba(90, 169, 255, 0.13);

  --g-silver: linear-gradient(135deg, #ffffff 0%, #c9d1d3 38%, #8d989b 62%, #e9eef0 100%);
  --g-radius: 18px;
  --g-radius-sm: 12px;
  --g-shadow: 0 18px 50px -20px rgba(0, 0, 0, 0.8);

  --g-font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --g-display: "Sora", "IBM Plex Sans", system-ui, sans-serif;
  --g-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --g-appbar-h: 60px;
  --g-tabbar-h: 68px;
  --g-sidebar-w: 280px;

  /* Bootstrap overrides */
  --bs-body-bg: var(--g-bg);
  --bs-body-color: var(--g-text);
  --bs-body-font-family: var(--g-font);
  --bs-secondary-color: var(--g-muted);
  --bs-border-color: var(--g-line);
  --bs-primary: var(--g-mint);
  --bs-primary-rgb: 46, 229, 157;
  --bs-success-rgb: 46, 229, 157;
  --bs-danger-rgb: 255, 77, 94;
  --bs-warning-rgb: 246, 185, 59;
  --bs-link-color: var(--g-mint);
  --bs-link-color-rgb: 46, 229, 157;
  --bs-link-hover-color: #7ff1c2;
  --bs-emphasis-color: #fff;
  --bs-tertiary-bg: var(--g-surface-2);
  --bs-secondary-bg: var(--g-surface);
  --bs-focus-ring-color: rgba(46, 229, 157, 0.35);
}

html { -webkit-tap-highlight-color: transparent; }
body {
  background: var(--g-bg);
  color: var(--g-text);
  font-family: var(--g-font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
h1, h2, h3, h4, h5, .g-display { font-family: var(--g-display); letter-spacing: -0.02em; font-weight: 600; color: #fff; }
.mono, code { font-family: var(--g-mono); font-size: 0.86em; }
code { color: var(--g-mint); }
a { text-decoration: none; }
.text-muted, .text-secondary { color: var(--g-muted) !important; }
.text-dim { color: var(--g-dim-text) !important; }
.text-mint { color: var(--g-mint) !important; }
.text-amber { color: var(--g-amber) !important; }
.text-red { color: var(--g-red) !important; }
.small-caps { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.12em; font-weight: 600; color: var(--g-muted); }
.eyebrow { font-family: var(--g-mono); font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.16em; color: var(--g-mint); }
.silver { background: var(--g-silver); -webkit-background-clip: text; background-clip: text; color: transparent; }
::selection { background: rgba(46, 229, 157, 0.3); }

/* ---------- Brand ---------- */
.g-brand { display: inline-flex; align-items: center; gap: 0.55rem; color: #fff; font-family: var(--g-display); font-weight: 600; font-size: 1.08rem; letter-spacing: -0.01em; }
.g-brand img { width: 28px; height: auto; }
.g-brand span b { font-weight: 600; color: var(--g-muted); }

/* ---------- Buttons ---------- */
.btn { border-radius: 999px; font-weight: 600; padding: 0.62rem 1.2rem; letter-spacing: -0.005em; }
.btn-lg { padding: 0.85rem 1.5rem; font-size: 1rem; }
.btn-sm { padding: 0.38rem 0.85rem; font-size: 0.82rem; }
.btn-primary { --bs-btn-bg: var(--g-mint); --bs-btn-border-color: var(--g-mint); --bs-btn-color: #04130d; --bs-btn-hover-bg: #5cf0b5; --bs-btn-hover-border-color: #5cf0b5; --bs-btn-hover-color: #04130d; --bs-btn-active-bg: var(--g-mint-2); --bs-btn-active-color: #04130d; --bs-btn-disabled-bg: var(--g-mint); --bs-btn-disabled-color: #04130d; box-shadow: 0 8px 28px -10px rgba(46, 229, 157, 0.6); }
.btn-ghost { --bs-btn-color: var(--g-text); --bs-btn-bg: var(--g-surface-2); --bs-btn-border-color: var(--g-line-2); --bs-btn-hover-bg: var(--g-surface-3); --bs-btn-hover-color: #fff; --bs-btn-hover-border-color: var(--g-line-2); --bs-btn-active-bg: var(--g-surface-3); --bs-btn-active-color: #fff; }
.btn-danger { --bs-btn-bg: var(--g-red); --bs-btn-border-color: var(--g-red); --bs-btn-hover-bg: #ff6a78; --bs-btn-hover-border-color: #ff6a78; }
.btn-icon { width: 42px; height: 42px; padding: 0; display: inline-grid; place-items: center; border-radius: 50%; font-size: 1.15rem; }

/* ---------- Forms ---------- */
.form-label { font-size: 0.84rem; font-weight: 500; color: var(--g-muted); margin-bottom: 0.35rem; }
.form-control, .form-select { background-color: var(--g-surface-2); border: 1px solid var(--g-line-2); color: var(--g-text); border-radius: var(--g-radius-sm); padding: 0.78rem 0.95rem; font-size: 1rem; }
.form-control::placeholder { color: var(--g-dim-text); }
.form-control:focus, .form-select:focus { background-color: var(--g-surface-2); color: #fff; border-color: var(--g-mint); box-shadow: 0 0 0 0.22rem rgba(46, 229, 157, 0.18); }
.form-text { color: var(--g-dim-text); font-size: 0.8rem; }
.form-check-input { background-color: var(--g-surface-3); border-color: var(--g-line-2); }
.form-check-input:checked { background-color: var(--g-mint); border-color: var(--g-mint); }
.form-switch .form-check-input { width: 2.6em; height: 1.45em; margin-top: 0; cursor: pointer; }
.form-switch .form-check-input:checked { --bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%2304130d'/%3e%3c/svg%3e"); }
.form-range::-webkit-slider-thumb { background: var(--g-mint); }
.form-range::-webkit-slider-runnable-track { background: var(--g-surface-3); }

/* ---------- Cards / surfaces ---------- */
.g-card { background: var(--g-surface); border: 1px solid var(--g-line); border-radius: var(--g-radius); padding: 1.1rem; }
.g-card-flush { background: var(--g-surface); border: 1px solid var(--g-line); border-radius: var(--g-radius); overflow: hidden; }
.g-card-2 { background: var(--g-surface-2); border: 1px solid var(--g-line); border-radius: var(--g-radius-sm); padding: 0.9rem; }
.g-card-glow { background: radial-gradient(120% 120% at 0% 0%, rgba(46, 229, 157, 0.12), transparent 55%), var(--g-surface); }
.g-section-title { display: flex; align-items: center; justify-content: space-between; margin: 1.5rem 0 0.7rem; }
.g-section-title h2, .g-section-title h3 { font-size: 1rem; margin: 0; }
.g-section-title a { font-size: 0.85rem; font-weight: 600; }
.g-divider { height: 1px; background: var(--g-line); margin: 1rem 0; }

/* list rows */
.g-list { list-style: none; margin: 0; padding: 0; }
.g-list > li, .g-row { display: flex; align-items: center; gap: 0.85rem; padding: 0.85rem 1rem; border-bottom: 1px solid var(--g-line); color: var(--g-text); }
.g-list > li:last-child, .g-row:last-child { border-bottom: 0; }
a.g-row:hover, .g-list > li.is-link:hover { background: var(--g-surface-2); color: #fff; }
.g-row .g-row-main { flex: 1; min-width: 0; }
.g-row .g-row-title { font-weight: 600; font-size: 0.95rem; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-row .g-row-sub { font-size: 0.8rem; color: var(--g-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-row .bi-chevron-right { color: var(--g-dim); }

/* icon tiles */
.g-ico { width: 40px; height: 40px; flex: 0 0 40px; border-radius: 12px; display: grid; place-items: center; font-size: 1.15rem; background: var(--g-surface-3); color: var(--g-text); }
.g-ico.lg { width: 52px; height: 52px; flex-basis: 52px; border-radius: 16px; font-size: 1.45rem; }
.g-ico.mint { background: var(--g-mint-soft); color: var(--g-mint); }
.g-ico.amber { background: var(--g-amber-soft); color: var(--g-amber); }
.g-ico.red { background: var(--g-red-soft); color: var(--g-red); }
.g-ico.blue { background: var(--g-blue-soft); color: var(--g-blue); }
.g-ico.wa { background: rgba(37, 211, 102, 0.14); color: #25d366; }

/* pills / risk */
.g-pill { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.22rem 0.62rem; border-radius: 999px; font-size: 0.74rem; font-weight: 600; background: var(--g-surface-3); color: var(--g-text); border: 1px solid var(--g-line); white-space: nowrap; }
.g-pill.mint { background: var(--g-mint-soft); color: var(--g-mint); border-color: transparent; }
.g-pill.amber { background: var(--g-amber-soft); color: var(--g-amber); border-color: transparent; }
.g-pill.red { background: var(--g-red-soft); color: var(--g-red); border-color: transparent; }
.g-pill.blue { background: var(--g-blue-soft); color: var(--g-blue); border-color: transparent; }
.g-pill.outline { background: transparent; border-color: var(--g-line-2); }
.g-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }
.g-live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--g-red); box-shadow: 0 0 0 0 rgba(255, 77, 94, 0.7); animation: g-pulse 1.6s infinite; display: inline-block; }
.g-live-dot.mint { background: var(--g-mint); animation-name: g-pulse-mint; }
@keyframes g-pulse { 0% { box-shadow: 0 0 0 0 rgba(255, 77, 94, 0.6); } 70% { box-shadow: 0 0 0 9px rgba(255, 77, 94, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 77, 94, 0); } }
@keyframes g-pulse-mint { 0% { box-shadow: 0 0 0 0 rgba(46, 229, 157, 0.6); } 70% { box-shadow: 0 0 0 9px rgba(46, 229, 157, 0); } 100% { box-shadow: 0 0 0 0 rgba(46, 229, 157, 0); } }

.g-risk { border-radius: var(--g-radius); padding: 1rem 1.1rem; color: #fff; position: relative; overflow: hidden; }
.g-risk.high { background: linear-gradient(135deg, #e23446, #b11f33); }
.g-risk.medium { background: linear-gradient(135deg, #d99a1c, #a86e0a); }
.g-risk.low { background: linear-gradient(135deg, #12a26b, #0b7a50); }
.g-risk .g-risk-label { font-family: var(--g-display); font-weight: 700; font-size: 1.15rem; letter-spacing: -0.01em; }
.g-risk .g-risk-meta { font-size: 0.8rem; opacity: 0.88; }
.g-risk .g-risk-score { font-family: var(--g-display); font-size: 2.2rem; font-weight: 700; line-height: 1; }

/* score ring (SVG, ui/components/ring.html) */
.g-ring { --c: var(--g-text); width: 120px; height: 120px; position: relative; display: grid; place-items: center; flex: 0 0 auto; }
.g-ring.sm { width: 84px; height: 84px; }
.g-ring.md { width: 96px; height: 96px; }
.g-ring.lg { width: 132px; height: 132px; }
.g-ring.mint { --c: var(--g-mint); }
.g-ring.amber { --c: var(--g-amber); }
.g-ring.red { --c: var(--g-red); }
.g-ring.blue { --c: var(--g-blue); }
.g-ring > svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.g-ring circle { fill: none; stroke-width: 10; }
.g-ring .g-ring-track { stroke: var(--g-surface-3); }
.g-ring .g-ring-value { stroke: var(--c); }
.g-ring > div { position: relative; text-align: center; }
.g-ring .v { font-family: var(--g-display); font-size: 1.9rem; font-weight: 700; color: #fff; line-height: 1; }
.g-ring.sm .v, .g-ring.md .v { font-size: 1.45rem; }
.g-ring .l { font-size: 0.68rem; color: var(--g-muted); text-transform: uppercase; letter-spacing: 0.1em; }

/* meter bar (SVG, ui/components/meter.html) */
.g-meter { display: block; height: 6px; }
.g-meter .g-meter-track { fill: var(--g-surface-3); }
.g-meter .g-meter-bar { fill: var(--g-mint); }
.g-meter.amber .g-meter-bar { fill: var(--g-amber); }
.g-meter.red .g-meter-bar { fill: var(--g-red); }
.g-meter.blue .g-meter-bar { fill: var(--g-blue); }

/* stat */
.g-stat .v { font-family: var(--g-display); font-size: 1.5rem; font-weight: 700; color: #fff; line-height: 1.1; }
.g-stat .l { font-size: 0.75rem; color: var(--g-muted); }

/* segmented / chips filter */
.g-seg { display: flex; gap: 0.4rem; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.g-seg::-webkit-scrollbar { display: none; }
.g-seg .btn-check + label, .g-seg a { flex: 0 0 auto; border-radius: 999px; padding: 0.4rem 0.9rem; font-size: 0.84rem; font-weight: 600; background: var(--g-surface-2); border: 1px solid var(--g-line); color: var(--g-muted); cursor: pointer; }
.g-seg .btn-check:checked + label, .g-seg a.active { background: var(--g-mint-soft); color: var(--g-mint); border-color: rgba(46, 229, 157, 0.35); }

/* selectable option cards */
.g-option { display: block; cursor: pointer; }
.g-option input { position: absolute; opacity: 0; pointer-events: none; }
.g-option .g-option-body { display: flex; gap: 0.85rem; align-items: flex-start; padding: 1rem; border-radius: var(--g-radius); border: 1.5px solid var(--g-line-2); background: var(--g-surface); transition: border-color 0.15s, background 0.15s; }
.g-option input:checked + .g-option-body { border-color: var(--g-mint); background: linear-gradient(0deg, var(--g-mint-soft), var(--g-mint-soft)), var(--g-surface); }
.g-option .g-check { margin-left: auto; width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--g-line-2); flex: 0 0 22px; display: grid; place-items: center; color: transparent; font-size: 0.8rem; }
.g-option input:checked + .g-option-body .g-check { background: var(--g-mint); border-color: var(--g-mint); color: #04130d; }

/* transcript */
.g-transcript { display: flex; flex-direction: column; gap: 0.6rem; }
.g-bubble { max-width: 86%; padding: 0.65rem 0.85rem; border-radius: 16px; font-size: 0.92rem; line-height: 1.45; }
.g-bubble .who { display: block; font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 0.2rem; opacity: 0.75; }
.g-bubble.them { background: var(--g-surface-2); border: 1px solid var(--g-line); border-top-left-radius: 4px; align-self: flex-start; }
.g-bubble.me { background: rgba(90, 169, 255, 0.12); border: 1px solid rgba(90, 169, 255, 0.18); border-top-right-radius: 4px; align-self: flex-end; }
.g-bubble mark { background: rgba(255, 77, 94, 0.2); color: #ffd6da; border-bottom: 1.5px solid var(--g-red); padding: 0 2px; border-radius: 3px; }
.g-bubble mark.amber { background: rgba(246, 185, 59, 0.18); color: #ffe7b5; border-color: var(--g-amber); }
.g-flag { font-size: 0.72rem; color: var(--g-red); font-weight: 600; margin-top: 0.3rem; display: flex; gap: 0.3rem; align-items: center; }

/* steps */
.g-steps { display: flex; gap: 6px; }
.g-steps span { flex: 1; height: 4px; border-radius: 4px; background: var(--g-surface-3); }
.g-steps span.on { background: var(--g-mint); }

/* empty / banners */
.g-banner { display: flex; gap: 0.8rem; align-items: center; padding: 0.85rem 1rem; border-radius: var(--g-radius-sm); background: var(--g-blue-soft); border: 1px solid rgba(90, 169, 255, 0.22); font-size: 0.9rem; }
.g-banner.mint { background: var(--g-mint-soft); border-color: rgba(46, 229, 157, 0.25); }
.g-banner.amber { background: var(--g-amber-soft); border-color: rgba(246, 185, 59, 0.25); }

/* avatar */
.g-avatar { width: 40px; height: 40px; flex: 0 0 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 0.85rem; background: var(--g-surface-3); color: #fff; }
.g-avatar.sm { width: 32px; height: 32px; flex-basis: 32px; font-size: 0.75rem; }

/* tables (desktop biz) */
.table { --bs-table-bg: transparent; --bs-table-color: var(--g-text); --bs-table-border-color: var(--g-line); --bs-table-hover-bg: var(--g-surface-2); font-size: 0.9rem; margin: 0; }
.table thead th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--g-muted); font-weight: 600; background: var(--g-surface-2); }
.table td, .table th { padding: 0.8rem 1rem; vertical-align: middle; }

/* accordion */
.accordion { --bs-accordion-bg: transparent; --bs-accordion-border-color: var(--g-line); --bs-accordion-btn-color: #fff; --bs-accordion-active-bg: transparent; --bs-accordion-active-color: var(--g-mint); --bs-accordion-btn-focus-box-shadow: none; --bs-accordion-btn-padding-x: 0; --bs-accordion-body-padding-x: 0; --bs-accordion-btn-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%238ea39f'%3e%3cpath d='M8 1a.75.75 0 0 1 .75.75v5.5h5.5a.75.75 0 0 1 0 1.5h-5.5v5.5a.75.75 0 0 1-1.5 0v-5.5h-5.5a.75.75 0 0 1 0-1.5h5.5v-5.5A.75.75 0 0 1 8 1z'/%3e%3c/svg%3e"); --bs-accordion-btn-active-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%232ee59d'%3e%3cpath d='M1.75 7.25h12.5a.75.75 0 0 1 0 1.5H1.75a.75.75 0 0 1 0-1.5z'/%3e%3c/svg%3e"); }
.accordion-button { font-family: var(--g-display); font-weight: 600; font-size: 1rem; }
.accordion-item { border-left: 0; border-right: 0; }
.accordion-body { color: var(--g-muted); padding-top: 0; }

/* modal / offcanvas */
.modal-content, .offcanvas { background: var(--g-bg-2); border-color: var(--g-line); color: var(--g-text); }
.offcanvas-bottom { border-radius: 22px 22px 0 0; height: auto; max-height: 88vh; }
.g-grabber { width: 40px; height: 5px; border-radius: 9px; background: var(--g-line-2); margin: 8px auto 0; }

/* risk banner without a level (no window scored yet, or an unknown value) */
.g-risk.unknown { background: var(--g-surface-3); border: 1px solid var(--g-line-2); }

/* ---------- utilities (mockup) ---------- */
.gap-2-5 { gap: 0.75rem; }
.hscroll { display: flex; gap: 0.75rem; overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding-inline: 1rem; scrollbar-width: none; margin: 0 -1rem; padding: 0 1rem 4px; }
.hscroll::-webkit-scrollbar { display: none; }
.hscroll > * { scroll-snap-align: start; flex: 0 0 auto; }
.fade-in { animation: g-fade 0.35s ease both; }
@keyframes g-fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.min-w-0 { min-width: 0; }
.d-grid > * { min-width: 0; }
.g-stat .v { white-space: nowrap; font-size: clamp(1.15rem, 5vw, 1.5rem); }
