:root { --bg:#fff; --fg:#1b1b1b; --muted:#666; --line:rgba(128,128,128,.35); --box:rgba(128,128,128,.06);
        --red:#d64545; --amber:#e0a100; --green:#2e9e5b; --grey:#9a9a9a; --accent:#4a8cff; }
@media (prefers-color-scheme: dark) { :root { --bg:#141414; --fg:#eaeaea; --muted:#aaa; } }
* { box-sizing:border-box; }
body { margin:0; background:var(--bg); color:var(--fg); font:14px/1.45 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }
main { max-width:1200px; margin:0 auto; padding:16px; }
.top { display:flex; justify-content:space-between; padding:10px 16px; border-bottom:1px solid var(--line); }
.top .stamp { margin-left:auto; align-self:center; }   /* stamp and user sit together on the right */
.userbox { display:flex; align-items:center; gap:8px; margin-left:12px; }
.userbox .who { color:var(--muted); font-size:12px; }
.userbox button { font:inherit; font-size:12px; padding:2px 8px; border:1px solid var(--line); border-radius:6px;
                  background:var(--box); color:inherit; cursor:pointer; }
.brand { font-weight:700; color:inherit; text-decoration:none; }
.stamp { color:var(--muted); font-size:12px; }
.disclaimer { max-width:1200px; margin:24px auto; padding:0 16px 24px; color:var(--muted); font-size:12px; }
.hdr { display:flex; justify-content:space-between; align-items:center; border-left:6px solid var(--grey); padding:8px 12px; margin-bottom:12px; }
.strip-red { border-left-color:var(--red); } .strip-amber { border-left-color:var(--amber); }
.strip-green { border-left-color:var(--green); } .strip-grey { border-left-color:var(--grey); }
h1 { margin:0; font-size:20px; } .sym { color:var(--muted); font-weight:400; font-size:15px; }
.name-ar { font-weight:600; font-size:18px; } .name-sep { color:var(--muted); font-weight:400; }
.badge { font-size:10px; padding:1px 6px; border:1px solid var(--line); border-radius:8px; vertical-align:middle; }
.meta { color:var(--muted); font-size:12px; }
.headline { margin-top:4px; font-size:14px; font-weight:600; }
.rankline { margin-top:4px; } .rankline b { font-size:15px; } .sep { opacity:.4; margin:0 6px; } .insufficient { color:var(--amber); }
.ring-wrap { text-align:center; }
.ring { width:52px; height:52px; border-radius:50%; background:var(--grey); color:#fff; display:flex; align-items:center; justify-content:center; font-weight:700; font-size:18px; }
.ring-green { background:var(--green); } .ring-amber { background:var(--amber); } .ring-grey { background:var(--grey); }
.ringlab { font-size:10px; color:var(--muted); }
.two { display:flex; gap:12px; } .col { flex:1; min-width:0; }
@media (max-width: 800px) { .two { flex-direction:column; } }
.box { border:1px solid var(--line); border-radius:10px; padding:10px 12px; margin-bottom:10px; background:var(--box); }
.box h4 { margin:0 0 6px; font-size:11px; text-transform:uppercase; letter-spacing:.04em; color:var(--muted); }
.box ul { margin:4px 0 0 18px; padding:0; } .box li { margin:2px 0; }
.opinion { border:1px dashed var(--accent); } .caveat { color:var(--amber); } .fine { color:var(--muted); font-size:12px; }
.prow { display:flex; align-items:center; gap:8px; margin:5px 0; font-size:12px; }
.prow .lab { width:120px; } .prow .val { width:150px; }
.bar { flex:1; height:8px; border-radius:4px; background:rgba(128,128,128,.22); position:relative; }
.bar span { position:absolute; left:0; top:0; bottom:0; border-radius:4px; }
.al { display:flex; gap:8px; align-items:flex-start; padding:4px 0; border-bottom:1px solid var(--line); }
.dot { width:10px; height:10px; border-radius:50%; margin-top:5px; flex:0 0 auto; }
.dot.red { background:var(--red); } .dot.amber { background:var(--amber); } .dot.grey { background:var(--grey); } .dot.green { background:var(--green); }
table { width:100%; border-collapse:collapse; font-size:12px; }
th, td { text-align:left; padding:3px 4px; border-bottom:1px solid var(--line); } th { color:var(--muted); font-weight:600; }
td.n, th.n { text-align:right; font-variant-numeric:tabular-nums; }
.pct { display:inline-block; width:34px; height:6px; background:rgba(128,128,128,.22); border-radius:3px; position:relative; vertical-align:middle; }
.pct span { position:absolute; left:0; top:0; bottom:0; border-radius:3px; }
/* A percentile bar is filled by its band; an unknown percentile draws no fill at all. */
.bar span.band-red, .pct span.band-red { background:var(--red); }
.bar span.band-amber, .pct span.band-amber { background:var(--amber); }
.bar span.band-green, .pct span.band-green { background:var(--green); }
.arrow { font-size:10px; } .arrow-up { color:var(--green); } .arrow-down { color:var(--red); }
details summary { cursor:pointer; font-weight:600; margin:6px 0; }
.err h4 { font-size:22px; color:var(--fg); text-transform:none; letter-spacing:0; }

/* Price-context tiles. Every figure is drawn from a number the view computed; no script runs here. */
.tiles { display:flex; gap:8px; flex-wrap:wrap; margin:6px 0; }
.tile { flex:1 1 90px; min-width:90px; border:1px solid var(--line); border-radius:8px; padding:6px 8px; }
.tlab { font-size:10px; text-transform:uppercase; letter-spacing:.04em; color:var(--muted); }
.tval { font-size:13px; font-weight:600; font-variant-numeric:tabular-nums; margin:2px 0 4px; }
.tnote { font-size:10px; color:var(--muted); font-variant-numeric:tabular-nums; }
.tone-up .tval { color:var(--green); } .tone-down .tval { color:var(--red); }
.tone-flat .tval, .tone-none .tval { color:var(--muted); }
.tbar { display:flex; flex-direction:column; gap:2px; height:8px; }
.seg { height:3px; border-radius:2px; background:var(--grey); }
.tone-up .seg-co { background:var(--green); } .tone-down .seg-co { background:var(--red); }
.tone-flat .seg-co, .tone-none .seg-co { background:var(--grey); }
.seg-mkt { background:rgba(128,128,128,.55); }
.track { height:6px; border-radius:3px; background:rgba(128,128,128,.22); position:relative; margin-top:2px; }
.marker { position:absolute; top:-2px; width:3px; height:10px; border-radius:2px; background:var(--accent); }
.dd { position:absolute; left:0; top:0; bottom:0; border-radius:3px; background:var(--red); }
/* The price tiles' own chip, scoped to the tile so the home page's smaller chip rule -
   which lands later in this file - cannot shrink it. */
.tile .chip { display:inline-block; margin-top:2px; padding:1px 6px; border-radius:8px; font-size:12px;
        font-variant-numeric:tabular-nums; border:1px solid var(--line); }
.chip.tone-up { color:#fff; background:var(--green); border-color:var(--green); }
.chip.tone-down { color:#fff; background:var(--red); border-color:var(--red); }
.chip.tone-flat { color:var(--muted); }
.chip.na { color:var(--muted); }

/* Home page */
.strip { display:flex; gap:18px; flex-wrap:wrap; align-items:center; padding:8px 12px; border:1px solid var(--line); border-radius:10px; background:var(--box); margin-bottom:10px; font-size:13px; }
.strip .dot { display:inline-block; margin:0 2px 0 6px; vertical-align:middle; }
.muted { color:var(--muted); }
.controls { display:flex; gap:12px; flex-wrap:wrap; align-items:center; margin-bottom:12px; font-size:13px; }
.sorts a { margin-left:6px; color:inherit; text-decoration:none; padding:2px 8px; border:1px solid var(--line); border-radius:12px; }
.sorts a.current { background:var(--accent); color:#fff; border-color:var(--accent); }
.controls select, .controls button { font:inherit; padding:2px 6px; }
.grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(230px, 1fr)); gap:10px; }
.card { display:block; color:inherit; text-decoration:none; border:1px solid var(--line); border-left:6px solid var(--grey); border-radius:10px; padding:10px 12px; background:var(--box); }
/* The strip is the card's left border, so it has to beat `.card`'s own `border-left`
   shorthand above: same specificity, so these come later and set the colour alone. A card
   with no alert carries no colour at all - green here would read as a recommendation. */
.card.strip-red { border-left-color:var(--red); } .card.strip-amber { border-left-color:var(--amber); }
.card.strip-grey { border-left-color:var(--grey); } .card.strip-none { border-left-color:transparent; }
/* Hover repaints the three sides the strip does not own; a shorthand would erase it. */
.card:hover { border-top-color:var(--accent); border-right-color:var(--accent); border-bottom-color:var(--accent); }
.card-top { display:flex; justify-content:space-between; gap:8px; align-items:flex-start; }
.card-name { min-width:0; } .card-name b { font-size:15px; } .card-name .name-ar { font-size:14px; }
.ring-sm { width:44px; height:44px; font-size:16px; flex:0 0 auto; }
.card-pillars { margin:8px 0 6px; } .card-pillars .prow { margin:3px 0; font-size:11px; }
.card-pillars .lab { width:110px; } .card-pillars .val { width:24px; text-align:right; }
.card-headline { font-size:13px; font-weight:600; min-height:2.6em; }
.card-price { font-size:12px; margin-top:4px; } .card-price .tone-up { color:var(--green); } .card-price .tone-down { color:var(--red); }
.card-chips { display:flex; gap:4px; flex-wrap:wrap; margin-top:6px; }
.chip { font-size:10px; padding:1px 7px; border-radius:10px; border:1px solid var(--line); }
.chip-red { border-color:var(--red); color:var(--red); } .chip-amber { border-color:var(--amber); color:var(--amber); }
.chip-grey { border-color:var(--grey); color:var(--muted); } .chip-green { border-color:var(--green); color:var(--green); }
.chip-stance { border-style:dashed; }
.divider { margin:18px 0 8px; font-size:13px; text-transform:uppercase; letter-spacing:.04em; color:var(--muted); }
@media (max-width: 360px) { .grid { grid-template-columns:1fr; } }

/* Login and disclaimer: one narrow box, the only forms without a page behind them. */
.signin { max-width:360px; margin:40px auto; }
.signin p { margin:6px 0; }
.signin-form { display:flex; flex-direction:column; gap:8px; margin-top:8px; }
.signin-form label { display:flex; flex-direction:column; gap:2px; font-size:12px; color:var(--muted); }
.signin-form input { font:inherit; color:inherit; background:var(--bg); padding:6px 8px;
                     border:1px solid var(--line); border-radius:6px; }
.signin button { font:inherit; margin-top:10px; padding:6px 12px; border:1px solid var(--line); border-radius:6px;
                 background:var(--box); color:inherit; cursor:pointer; }
.formerr { color:var(--red); font-size:13px; margin:4px 0 0; }

/* Nav: three links in the header, only for a logged-in reader. */
.nav { display:flex; gap:10px; align-items:center; margin-left:16px; font-size:13px; }
.nav a { color:var(--muted); text-decoration:none; padding:2px 8px; border-radius:12px; }
.nav a.current { color:var(--fg); background:var(--box); }

/* Alerts page. The severity dot sits inline beside a heading, as it does in the strip. */
.divider .dot { display:inline-block; margin-right:6px; vertical-align:middle; }
.alerts td { vertical-align:top; padding:5px 6px; }
.alerts .num { text-align:right; font-variant-numeric:tabular-nums; white-space:nowrap; }
.alerts th.num { text-align:right; }
.alerts .say { width:45%; }
.alerts a { color:inherit; font-weight:600; }
.alerts .name-ar { font-size:13px; font-weight:400; }
.tag { font-size:10px; padding:0 6px; border-radius:8px; border:1px solid var(--line); vertical-align:middle; }
.tag-red { border-color:var(--red); color:var(--red); } .tag-amber { border-color:var(--amber); color:var(--amber); }
.tag-grey { border-color:var(--grey); color:var(--muted); }
.empty { margin:4px 0 12px; font-size:13px; }
.cleared { margin:4px 0 12px; padding-left:18px; font-size:13px; }
.cleared a { color:inherit; font-weight:600; }
.health { max-width:760px; } .health th { width:120px; color:var(--fg); }
.health .hstatus { width:110px; font-weight:600; }

/* Settings: three stacked forms, no script. Every control is a plain input, so the page
   works with the keyboard alone and a slider's number is printed beside it rather than
   being read out by a listener. */
.saved { border:1px solid var(--green); border-radius:8px; padding:8px 12px; margin:0 0 12px; background:var(--box); }
.setform { border-bottom:1px solid var(--line); padding-bottom:16px; margin-bottom:8px; }
.setform:last-child { border-bottom:0; }
.setform .divider { margin-top:8px; }
.sublab { margin:8px 0 4px; font-size:11px; text-transform:uppercase; letter-spacing:.04em; color:var(--muted); }
.setform button { font:inherit; margin-top:10px; padding:6px 12px; border:1px solid var(--line); border-radius:6px;
                  background:var(--box); color:inherit; cursor:pointer; }
.setform button:hover { border-color:var(--accent); }
.setform input[type=text], .setform input[type=number], .setform select, .setform textarea {
    font:inherit; color:inherit; background:var(--bg); padding:4px 6px; border:1px solid var(--line); border-radius:6px; }
.setform textarea { width:100%; font-family:ui-monospace, SFMono-Regular, Menlo, monospace; font-size:12px; }
.wrow, .trow, .drow, .noterow { display:flex; align-items:center; gap:8px; margin:5px 0; font-size:12px; }
.wrow .lab, .trow .lab, .drow .lab, .noterow .lab { width:150px; flex:0 0 auto; color:var(--muted); }
.wrow input[type=range] { flex:1; min-width:120px; }
.wrow .val { width:40px; text-align:right; font-variant-numeric:tabular-nums; font-weight:600; }
.trow input[type=number] { width:110px; text-align:right; font-variant-numeric:tabular-nums; }
.noterow input { flex:1; }
.drow.block { flex-direction:column; align-items:stretch; gap:4px; }
.drow .ro { color:var(--muted); }
.thresholds { display:grid; grid-template-columns:repeat(auto-fill, minmax(330px, 1fr)); gap:0 16px; }
.switches { border:1px solid var(--line); border-radius:8px; padding:4px 10px 8px; margin:0 0 8px; }
.switches legend { font-size:11px; text-transform:uppercase; letter-spacing:.04em; color:var(--muted); padding:0 4px; }
.switch { display:block; font-size:12px; margin:2px 0; }
.switch input { margin-right:6px; }
.env { max-width:320px; } .env th { width:110px; }
