/* Design system. Edit these tokens and the whole app follows —
   change --accent once rather than hunting hex codes through the markup. */
:root {
  --bg: #121218;
  --fg: #f8f6f2;
  --mute: #a6a5b1;
  --card: #1c1c26;
  --border: #343340;
  --accent: #facc15;
  --purple: #312e81;
  --pink: #f472b6;
  --danger: #f87171;
  --ok: #84d6a2;
  --on-accent: #17151a; /* text and icons drawn on --accent */
  --radius: 14px;
  /* Real height of the tab bar, used to pad the scroll area so the last row
     is never trapped underneath it. */
  --tabbar: calc(58px + env(safe-area-inset-bottom));
}

/* A light look: set <html data-theme="light"> (or "dark" back) and change these
   alongside :root. Every colour below is a token, so nothing else needs touching. */
[data-theme=light] {
  --bg: #f6f6f9;
  --fg: #14141b;
  --mute: #5b6070;
  --card: #ffffff;
  --border: #dcdce4;
  --accent: #6d4aff;
  --danger: #c62828;
  --ok: #15803d;
  --on-accent: #ffffff;
  color-scheme: light;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  min-height: 100vh;
  min-height: 100dvh; /* dvh survives the mobile URL bar collapsing */
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  /* No pull-to-refresh bounce past the ends: the giveaway that a PWA is a
     web page wearing a costume. */
  overscroll-behavior-y: none;
}

/* ── Right-to-left ───────────────────────────────────────────────────
   Set <html lang="ar" dir="rtl"> and this file flips by itself: spacing and
   alignment use logical properties (margin-inline, padding-inline, inset-inline,
   text-align: start). The exception is the safe-area padding on the bars below:
   a notch or home indicator is on a physical side, so those stay left/right. */

/* ── App bar ─────────────────────────────────────────────────────── */
.appbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: .75rem;
  padding: calc(env(safe-area-inset-top) + .875rem) calc(1.25rem + env(safe-area-inset-right)) .875rem calc(1.25rem + env(safe-area-inset-left));
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.appbar h1 { font-size: 1.125rem; font-weight: 650; letter-spacing: -.02em; word-break: break-word; }
.status { display: inline-flex; align-items: center; gap: .375rem; margin-inline-start: auto; flex: none; padding: .25rem .625rem; background: var(--card); border: 1px solid var(--border); border-radius: 999px; font-size: .6875rem; color: var(--mute); }
.status .dot { width: 6px; height: 6px; background: #22c55e; border-radius: 50%; box-shadow: 0 0 8px #22c55e; }

/* ── Screens ─────────────────────────────────────────────────────── */
main { padding: 1rem calc(1.25rem + env(safe-area-inset-right)) calc(var(--tabbar) + 1.5rem) calc(1.25rem + env(safe-area-inset-left)); }
.screen { display: none; }
.screen.active { display: block; animation: rise .18s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card { padding: 1.25rem; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); margin-block-end: .875rem; }
.card h2 { font-size: 1rem; font-weight: 600; letter-spacing: -.01em; margin-block-end: .375rem; }
.card p { font-size: .875rem; color: var(--mute); line-height: 1.55; }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; margin-block-start: .875rem; padding-inline: 1.25rem; background: var(--accent); color: var(--on-accent); border: 0; border-radius: 10px; font-size: .9375rem; font-weight: 600; font-family: inherit; cursor: pointer; }
.btn:active { transform: scale(.98); }

.list { list-style: none; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .875rem 1.25rem; font-size: .875rem; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.list .meta { color: var(--mute); font-size: .75rem; flex: none; }

footer { margin-block-start: 1.5rem; text-align: center; font-size: .75rem; color: var(--mute); }
footer a { color: var(--mute); }

/* ── Bottom tab bar ──────────────────────────────────────────────── */
.tabbar {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 20;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--border);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 58px; padding: 0; border: 0; background: none; cursor: pointer;
  color: var(--mute); font-family: inherit; font-size: .625rem; font-weight: 500;
  -webkit-tap-highlight-color: transparent;
}
.tab svg { width: 22px; height: 22px; }
.tab.active { color: var(--accent); }

/* ── Forms and states ────────────────────────────────────────────────
   Unused until the app needs them: no markup here uses them, they carry no copy,
   and every colour is a token. 16px text stops iOS zooming the page when a field
   is focused; 44px is a comfortable tap. */
label { display: block; font-size: .875rem; font-weight: 500; margin-block-end: .375rem; }
.form-group { display: flex; flex-direction: column; margin-block-end: 1rem; }
input, select, textarea { width: 100%; min-height: 44px; padding: .625rem .875rem; background: var(--card); color: var(--fg); border: 1px solid var(--border); border-radius: 10px; font: inherit; font-size: 1rem; text-align: start; }
textarea { min-height: 96px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; }
input::placeholder, textarea::placeholder { color: var(--mute); }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--danger); }
[hidden] { display: none !important; }
.btn:disabled, .btn[aria-busy="true"] { opacity: .55; cursor: not-allowed; }
.loading { display: flex; align-items: center; gap: .625rem; color: var(--mute); font-size: .875rem; }
.loading::before { content: ""; width: 1rem; height: 1rem; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error { padding: .75rem 1rem; background: rgba(248, 113, 113, .1); background: color-mix(in srgb, var(--danger) 12%, var(--bg)); border: 1px solid var(--danger); border-radius: 10px; color: var(--fg); font-size: .875rem; }
.empty { padding: 2rem 1rem; text-align: center; border: 1px dashed var(--border); border-radius: var(--radius); color: var(--mute); font-size: .9375rem; }

/* ── Components ──────────────────────────────────────────────────────
   Small, on the tokens, RTL-safe. Use them as they are; change the tokens, not
   these. Behaviour lives in app.js: api(), toast(), sheet(). */

/* row: one line of a list. Put rows in a .list (or any card). */
.row { display: flex; align-items: center; gap: .75rem; min-height: 56px; padding: .625rem 1.25rem; border-block-end: 1px solid var(--border); }
.row:last-child { border-block-end: 0; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-size: .9375rem; overflow-wrap: anywhere; }
.row-sub { font-size: .75rem; color: var(--mute); }
.row .btn { margin: 0; min-height: 44px; }
.list-actions { display: flex; gap: .75rem; margin-block-start: .875rem; }
.list-actions .btn { flex: 1; margin: 0; }
.btn.secondary { background: var(--card); color: var(--fg); border: 1px solid var(--border); }
.btn.danger { background: var(--danger); color: var(--on-accent); }
.btn.block { display: flex; width: 100%; }

/* field: a label, a control and a hint under it; .invalid turns the hint red. */
.field { display: flex; flex-direction: column; gap: .375rem; margin-block-end: 1rem; }
.field label { margin: 0; }
.field .hint { font-size: .75rem; color: var(--mute); }
.field.invalid .hint { color: var(--danger); }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--danger); }

/* sheet: a panel that slides up over the page (sheet() in app.js builds it). */
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .5); animation: fade .15s ease-out; }
.sheet { position: fixed; inset-inline: 0; bottom: 0; z-index: 41; max-height: 85vh; max-height: 85dvh; overflow-y: auto; overscroll-behavior: contain; padding: 1.25rem calc(1.25rem + env(safe-area-inset-right)) calc(1.25rem + env(safe-area-inset-bottom)) calc(1.25rem + env(safe-area-inset-left)); background: var(--card); color: var(--fg); border-block-start: 1px solid var(--border); border-radius: calc(var(--radius) + 6px) calc(var(--radius) + 6px) 0 0; animation: slide .2s ease-out; }
.sheet h2 { font-size: 1.0625rem; font-weight: 600; margin-block-end: .5rem; }
.sheet p { color: var(--mute); font-size: .9375rem; }
.sheet-actions { display: flex; gap: .75rem; margin-block-start: 1.25rem; }
.sheet-actions .btn { flex: 1; margin: 0; }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateY(100%); } }

/* segmented: pick one of a few options (tablist semantics, aria-selected). */
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; padding: 3px; margin-block-end: 1rem; background: var(--bg); border: 1px solid var(--border); border-radius: 12px; }
.segmented button { min-height: 40px; padding-inline: .75rem; border: 0; border-radius: 9px; background: none; color: var(--mute); font: inherit; font-size: .875rem; font-weight: 500; cursor: pointer; }
.segmented button[aria-selected="true"] { background: var(--card); color: var(--fg); box-shadow: 0 0 0 1px var(--border); }

/* toast: a short message over the tab bar (toast() in app.js). */
.toast { position: fixed; inset-inline: 0; inset-block-end: calc(var(--tabbar) + .75rem); z-index: 50; width: fit-content; max-width: calc(100% - 2.5rem); margin-inline: auto; padding: .625rem 1rem; background: var(--fg); color: var(--bg); border-radius: 999px; font-size: .875rem; text-align: center; animation: rise .18s ease-out; }
.toast.error { background: var(--danger); color: var(--on-accent); }

/* empty state: .empty already exists; these add a heading, an icon slot and an action. */
.empty strong { display: block; margin-block-end: .25rem; color: var(--fg); font-weight: 600; }
.empty .btn { margin-block-start: 1rem; }

/* badge: a small status pill. */
.badge { display: inline-flex; align-items: center; padding: .125rem .5rem; border: 1px solid var(--border); border-radius: 999px; background: var(--bg); color: var(--mute); font-size: .6875rem; font-weight: 600; line-height: 1.4; white-space: nowrap; }
.badge.ok { color: var(--ok); border-color: var(--ok); }
.badge.accent { color: var(--accent); border-color: var(--accent); }
.badge.danger { color: var(--danger); border-color: var(--danger); }

/* avatar: a round picture or initials. */
.avatar { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 40px; height: 40px; overflow: hidden; border-radius: 50%; background: var(--accent); color: var(--on-accent); font-size: .9375rem; font-weight: 600; text-transform: uppercase; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.large { width: 72px; height: 72px; font-size: 1.5rem; }

.link { color: var(--accent); }

/* Showroom */
.appbar {padding-block: calc(env(safe-area-inset-top) + .9rem) .9rem; gap:.7rem; background:#121218ee}.brandmark {width:38px;height:38px;display:grid;place-items:center;border-radius:12px;background:var(--purple);color:var(--accent)}.brandmark svg {width:20px}.eyebrow {font-size:.62rem;letter-spacing:.16em;font-weight:800;color:var(--accent)}.appbar h1{font-size:.95rem;letter-spacing:.06em;font-weight:900}.brand-dot{color:var(--pink)}.header-button{margin-inline-start:auto;background:#26252f;border:1px solid var(--border);color:var(--fg);border-radius:50%;width:44px;height:44px;display:grid;place-items:center}.header-button svg{width:20px}
main{max-width:960px;margin:auto;padding-block-start:1.35rem}.tabbar{display:flex;overflow-x:auto;justify-content:flex-start;scrollbar-width:none}.tabbar::-webkit-scrollbar{display:none}.tab{flex:1 0 60px;min-width:60px}.tab svg{width:19px;height:19px}.page-heading{margin-bottom:1.2rem}.page-heading h2{font-size:1.8rem;line-height:1.12;letter-spacing:-.055em;margin:.35rem 0}.page-heading p,.subtle{color:var(--mute);font-size:.85rem}.hero{position:relative;overflow:hidden;padding:1.35rem;border-radius:20px;background:linear-gradient(130deg,#312e81,#242238 58%,#202d28);border:1px solid #565080;margin-bottom:1.3rem}.hero:after{content:'';position:absolute;width:180px;height:180px;border:1px solid #ffffff12;border-radius:50%;inset-inline-end:-55px;top:-70px;box-shadow:0 0 0 28px #ffffff08,0 0 0 56px #ffffff05;pointer-events:none}.hero .eyebrow{color:#ded8ff}.hero-value{font-size:2.2rem;line-height:1.1;font-weight:800;letter-spacing:-.05em;margin:.5rem 0;color:#fff}.hero-bottom{display:flex;justify-content:space-between;align-items:center;gap:.5rem;color:#dedbe8;font-size:.76rem}.hero-bottom button{color:var(--accent);border:0;background:none;font-weight:700;min-height:44px}.section-title{display:flex;align-items:center;justify-content:space-between;gap:1rem;margin:1.4rem 0 .7rem}.section-title h3{font-size:1.05rem}.section-title span{color:var(--mute);font-size:.72rem}.chips{display:flex;gap:.5rem;overflow:auto;padding-bottom:.4rem;scrollbar-width:none}.chip{border:1px solid var(--border);background:#20202a;color:#c2c0cb;white-space:nowrap;border-radius:999px;padding:.55rem .85rem;font:inherit;font-size:.74rem;min-height:40px}.chip.active{background:var(--accent);border-color:var(--accent);color:#17151a;font-weight:800}.toolbar{display:grid;grid-template-columns:1fr 1fr;gap:.5rem;margin:.7rem 0}.toolbar input{grid-column:1/-1}.toolbar select{font-size:.8rem;min-width:0}.agent-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.7rem}.agent-card{position:relative;min-width:0;border:1px solid #343340;border-radius:16px;background:linear-gradient(160deg,#292638,#1d1d26 65%);padding:1rem;cursor:pointer;overflow:hidden}.agent-card:before{content:'';position:absolute;width:140px;height:140px;border-radius:50%;background:#facc150d;filter:blur(24px);top:-35px;inset-inline-start:-35px}.agent-card .portrait{position:relative;margin-bottom:1rem}.portrait{width:54px;height:54px;border-radius:16px;display:grid;place-items:center;background:#373249;color:#facc15;font-size:1.3rem;font-weight:800;overflow:hidden}.portrait img{width:100%;height:100%;object-fit:cover}.star{position:absolute;inset-inline-end:.6rem;top:.5rem;border:0;background:transparent;color:#77727e;min-width:44px;min-height:44px;z-index:1}.star.on{color:var(--accent)}.star svg{width:19px}.agent-card h3{font-size:.97rem;overflow-wrap:anywhere}.agent-card .specialty{font-size:.73rem;color:var(--mute);min-height:2.5em}.agent-value{font-weight:800;font-size:1.25rem;color:var(--ok);letter-spacing:-.04em;margin:.7rem 0 .3rem}.agent-meta{font-size:.67rem;color:#c5c1cd;min-height:2.5em}.badge{white-space:normal}.agent-card .badge{margin-top:.45rem;color:var(--accent);border-color:#675b29;background:#332d20}.card{border-radius:16px}.card h3{font-size:.95rem;margin-bottom:.6rem}.card p+p{margin-top:.5rem}.metric{display:flex;justify-content:space-between;gap:1rem;padding:.7rem 0;border-bottom:1px solid var(--border);font-size:.85rem}.metric:last-child{border:0}.metric strong{color:var(--ok);text-align:end}.stack{display:grid;gap:.65rem}.stack .card{margin:0}.actions{display:flex;flex-wrap:wrap;gap:.5rem}.actions .btn{margin-top:.5rem}.back{background:none;color:var(--mute);border:0;font:inherit;min-height:44px;padding:0;margin-bottom:.6rem}.back svg{width:16px;vertical-align:middle}.detail-title{display:flex;gap:1rem;align-items:center;margin-bottom:1rem}.detail-title .portrait{width:76px;height:76px}.detail-title h2{font-size:1.55rem;letter-spacing:-.04em}.detail-title p{font-size:.83rem;color:var(--mute)}.detail-price{font-size:2rem;color:var(--ok);font-weight:800;letter-spacing:-.05em}.section-label{font-size:.65rem;letter-spacing:.12em;color:var(--pink);font-weight:800;margin-bottom:.6rem}.chart{width:100%;height:120px}.chart polyline{fill:none;stroke:var(--ok);stroke-width:3;stroke-linejoin:round}.chart circle{fill:var(--accent)}.alert{border-color:#6f6334;background:#302b1d}.form-group small{color:var(--mute);margin-top:.35rem}.listline{padding:.7rem 0;border-bottom:1px solid var(--border);overflow-wrap:anywhere;font-size:.85rem}.listline:last-child{border:0}.listline small{color:var(--mute)}.code{display:block;overflow-wrap:anywhere;padding:.8rem;background:#111119;border-radius:10px;color:var(--accent);font-size:.8rem}.compare-grid{display:grid;grid-template-columns:1fr 1fr;gap:.6rem}.compare-grid .card{min-width:0;padding:.8rem;overflow-wrap:anywhere}.compare-grid select{font-size:.8rem}.locked{padding:2rem 1rem;text-align:center}.locked svg{color:var(--accent);width:32px;height:32px;margin-bottom:1rem}.locked h2{font-size:1.25rem;margin-bottom:.4rem}.locked p{color:var(--mute);font-size:.85rem}.btn,.chip,button{cursor:pointer}.icon-inline{width:16px;height:16px;vertical-align:middle;margin-inline-end:.3rem}@media(min-width:700px){.agent-grid{grid-template-columns:repeat(3,minmax(0,1fr))}.tabbar{justify-content:center}.tab{max-width:110px}}
.passport-qr { width:min(270px,100%); padding:.5rem; margin:1rem auto; background:#fff; border-radius:12px; }
.passport-qr svg {display:block; width:100%; height:auto;}
@media (prefers-reduced-motion: reduce) {
  .screen.active, .toast, .sheet, .sheet-backdrop { animation: none; }
  .loading::before { animation-duration: 2.4s; }
}
