:root {
  --paper: #E9ECEF;
  --surface: #FFFFFF;
  --ink: #17202A;
  --muted: #5C6672;
  --line: #D3D8DE;
  --brass: #8E6A1C;
  --brass-soft: #F3E9D2;
  --up: #1B7350;
  --down: #B0372C;
  --warn: #9A5B12;
  --radius-lg: 14px;
  --radius-sm: 6px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #10151B;
    --surface: #18202A;
    --ink: #E6E9ED;
    --muted: #98A2AD;
    --line: #2A3440;
    --brass: #D4AA4C;
    --brass-soft: #2E2716;
    --up: #4FC28C;
    --down: #F0786B;
    --warn: #E3A24F;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  line-height: 1.6;
}
h1, h2 { margin: 0; font-weight: 600; }
h1 { font-size: 1.25rem; }
h2 { font-size: 1.05rem; margin-bottom: .75rem; }
p { margin: .25rem 0; }
a { color: var(--brass); }
code { font-size: .9rem; overflow-wrap: anywhere; }
.muted { color: var(--muted); font-size: .9rem; }
.num { direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; }
.up { color: var(--up); }
.down { color: var(--down); }
.empty { color: var(--muted); padding: 1rem 0; }
.error { color: var(--down); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }

/* The vault: one strong strip that always tells you the state */
.vault {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1.5rem;
  padding: 1.25rem clamp(1rem, 4vw, 2.5rem);
  background: var(--surface);
  border-top: 4px solid var(--brass);
  border-bottom: 1px solid var(--line);
}
.vault.is-killed { border-top-color: var(--down); }
.vault-id { display: flex; align-items: center; gap: .85rem; }
.mark {
  display: grid; place-items: center;
  width: 3rem; height: 3rem;
  border: 1.5px solid var(--brass);
  border-radius: var(--radius-sm);
  color: var(--brass);
  font: 600 1.15rem/1 Georgia, "Times New Roman", serif;
  background: var(--brass-soft);
}
.vault-state { display: flex; flex-wrap: wrap; gap: .5rem 2rem; margin: 0; justify-content: center; }
.vault-state dt { font-size: .8rem; color: var(--muted); }
.vault-state dd { margin: 0; font-weight: 600; font-size: 1.05rem; display: flex; align-items: center; gap: .4rem; }
.dot { width: .55rem; height: .55rem; border-radius: 50%; background: currentColor; }
.kill-btn {
  font: inherit; font-weight: 600;
  padding: .8rem 1.4rem;
  border-radius: 999px;
  border: 2px solid var(--down);
  background: transparent;
  color: var(--down);
  cursor: pointer;
}
.kill-btn:hover { background: var(--down); color: var(--surface); }
.is-killed .kill-btn { border-color: var(--up); color: var(--up); }
.is-killed .kill-btn:hover { background: var(--up); color: var(--surface); }

.tabs {
  display: flex; gap: .25rem; align-items: center;
  padding: 0 clamp(1rem, 4vw, 2.5rem);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.tabs a {
  padding: .8rem .9rem;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
}
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--brass); font-weight: 600; }
.count { background: var(--brass); color: var(--surface); border-radius: 999px; padding: 0 .45rem; font-size: .8rem; }
.logout { margin-inline-start: auto; }
.link { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; padding: .8rem .5rem; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 1.5rem clamp(1rem, 4vw, 2.5rem) 3rem; display: grid; gap: 1.25rem; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 1.25rem; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 1.25rem; }

/* Figures: the first one leads, the rest support */
.figures { display: grid; grid-template-columns: 1.6fr repeat(4, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; }
.fig { background: var(--surface); padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: .15rem; }
.fig span { font-size: .85rem; color: var(--muted); }
.fig strong { font-size: 1.5rem; font-weight: 600; }
.fig small { color: var(--muted); }
.fig-lead strong { font-size: 2.1rem; color: var(--brass); }

.curve-wrap { position: relative; }
.curve { width: 100%; height: 220px; display: block; }
.curve .line { fill: none; stroke: var(--brass); stroke-width: 2; }
.curve .area { fill: var(--brass-soft); }
.curve-scale { position: absolute; inset: 0 auto 0 0; display: flex; flex-direction: column; justify-content: space-between; font-size: .8rem; color: var(--muted); padding: .2rem; pointer-events: none; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { text-align: start; font-weight: 500; color: var(--muted); border-bottom: 1px solid var(--line); padding: .5rem .6rem; white-space: nowrap; }
td { padding: .55rem .6rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }

.stance { display: inline-block; padding: .05rem .55rem; border-radius: var(--radius-sm); font-size: .85rem; font-weight: 600; }
.s-buy { background: color-mix(in srgb, var(--up) 14%, transparent); color: var(--up); }
.s-sell, .s-veto { background: color-mix(in srgb, var(--down) 14%, transparent); color: var(--down); }
.s-hold, .s-close { background: color-mix(in srgb, var(--muted) 16%, transparent); color: var(--muted); }
.tag { font-size: .8rem; padding: .05rem .5rem; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.t-pending { border-color: var(--brass); color: var(--brass); }
.t-approved, .t-executed { border-color: var(--up); color: var(--up); }
.t-rejected { border-color: var(--down); color: var(--down); }

/* Committee: the seats around the table */
.session { border-top: 1px solid var(--line); padding: 1rem 0; }
.panel > .session:first-of-type, .alert-approval .session { border-top: 0; padding-top: 0; }
.session-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem; align-items: center; margin-bottom: .75rem; }
.session-verdict .stance { font-size: 1rem; padding: .2rem .8rem; }
.session-meta { display: flex; flex-wrap: wrap; gap: .4rem .9rem; color: var(--muted); font-size: .88rem; align-items: center; }
.council { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .6rem; }
.seat { border: 1px solid var(--line); border-inline-start: 3px solid var(--muted); border-radius: 0; padding: .6rem .75rem; }
.seat-buy { border-inline-start-color: var(--up); }
.seat-sell, .seat-veto { border-inline-start-color: var(--down); }
.seat-top { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.seat p { font-size: .88rem; color: var(--muted); margin-top: .35rem; }
.reasons { margin-top: .85rem; }
.reasons ul { margin: .3rem 0; padding-inline-start: 1.2rem; }
.approve-row { display: flex; gap: .6rem; margin-top: 1rem; }
.alert-approval { background: var(--brass-soft); border: 1px solid var(--brass); border-radius: var(--radius-lg); padding: 1.25rem; }

.btn { font: inherit; padding: .6rem 1.1rem; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
.btn.primary { background: var(--brass); border-color: var(--brass); color: var(--surface); font-weight: 600; }

.events { list-style: none; margin: 0; padding: 0; }
.events li { padding: .5rem .75rem; border-inline-start: 3px solid var(--line); margin-bottom: .35rem; font-size: .92rem; }
.events .num { color: var(--muted); margin-inline-end: .5rem; }
.ev-warn { border-inline-start-color: var(--warn) !important; }
.ev-block { border-inline-start-color: var(--down) !important; }
.src { font-size: .78rem; color: var(--muted); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0 .35rem; margin-inline-end: .4rem; }
.rules { margin: 0; padding-inline-start: 1.2rem; }
.rules li { margin-bottom: .3rem; }

.phase-now { font-size: 1.3rem; font-weight: 600; color: var(--brass); }
.bar { height: .5rem; background: var(--line); border-radius: 999px; overflow: hidden; margin: .5rem 0; }
.bar span { display: block; height: 100%; background: var(--brass); }

/* Roadmap: a real sequence, so it gets numbers */
.roadmap { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }
.phase { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 1.1rem 1.25rem; }
.phase > header { display: flex; align-items: center; gap: 1rem; margin-bottom: .75rem; }
.phase > header > div { flex: 1; }
.phase h2 { margin: 0; }
.phase-no { width: 2.2rem; height: 2.2rem; display: grid; place-items: center; border: 1.5px solid var(--brass); color: var(--brass); border-radius: 50%; font-weight: 600; }
.phase.is-done .phase-no { background: var(--brass); color: var(--surface); }
.tasks { list-style: none; margin: 0; padding: 0; }
.task { display: flex; justify-content: space-between; gap: 1rem; align-items: start; padding: .75rem 0; border-top: 1px solid var(--line); }
.task p { font-size: .9rem; }
.task.st-done strong { text-decoration: line-through; color: var(--muted); }
.task.is-now { background: linear-gradient(var(--brass-soft), var(--brass-soft)) no-repeat; background-size: 4px 100%; background-position: right; padding-inline-start: .9rem; }
select, input[type="number"], input[type="password"] { font: inherit; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); }

.modes { display: grid; gap: .6rem; }
.mode { display: grid; grid-template-columns: auto 1fr; gap: .1rem .6rem; padding: .8rem; border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; }
.mode input { grid-row: span 2; margin-top: .35rem; accent-color: var(--brass); }
.mode span { color: var(--muted); font-size: .9rem; }
.mode.is-on { border-color: var(--brass); }
.modes .btn, .settings-form .btn { justify-self: start; }
.settings-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; align-items: end; }
.settings-form label { display: grid; gap: .3rem; font-size: .92rem; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--brass); border-radius: var(--radius-lg); padding: 2rem; display: grid; gap: .6rem; }
.login-card .btn { margin-top: .5rem; }

@media (max-width: 900px) {
  .vault { grid-template-columns: 1fr; text-align: start; }
  .vault-state { justify-content: flex-start; }
  .figures { grid-template-columns: 1fr 1fr; }
  .fig-lead { grid-column: 1 / -1; }
  .grid-2 { grid-template-columns: 1fr; }
}

/* Installer */
.install-card { width: min(520px, 100%); }
.install-form { display: grid; gap: 1rem; }
.install-form fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .9rem; display: grid; gap: .6rem; margin: 0; }
.install-form legend { padding: 0 .4rem; font-weight: 600; }
.install-form label { display: grid; gap: .25rem; font-size: .92rem; }
.install-form input { font: inherit; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); }
.key { display: block; padding: .7rem; background: var(--brass-soft); border: 1px solid var(--brass); border-radius: var(--radius-sm); user-select: all; }
.install-card .btn { text-align: center; text-decoration: none; }

/* Connect */
.flash { margin: 0; padding: .75rem 1rem; border-radius: var(--radius-sm); border: 1px solid var(--brass); background: var(--brass-soft); }
.flash.ok { border-color: var(--up); background: color-mix(in srgb, var(--up) 10%, var(--surface)); }
.flash.bad { border-color: var(--down); background: color-mix(in srgb, var(--down) 10%, var(--surface)); }
.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: .45rem; }
.checklist li { display: flex; align-items: center; gap: .6rem; color: var(--muted); }
.checklist li.is-ok { color: var(--ink); }
.tick { width: 1.4rem; height: 1.4rem; border-radius: 50%; border: 1.5px solid var(--line); display: grid; place-items: center; font-size: .85rem; flex: none; }
.is-ok .tick { background: var(--up); border-color: var(--up); color: var(--surface); }
.live-acct { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; margin-top: 1rem; }
.live-acct > div { background: var(--surface); padding: .6rem .8rem; display: grid; }
.live-acct span { font-size: .8rem; color: var(--muted); }
.step h2 { display: flex; align-items: center; gap: .6rem; }
.step-no { width: 1.8rem; height: 1.8rem; display: grid; place-items: center; border-radius: 50%; border: 1.5px solid var(--brass); color: var(--brass); font-size: .95rem; flex: none; }
.howto { margin: 0; padding-inline-start: 1.3rem; display: grid; gap: .5rem; }
.howto .key { margin-top: .35rem; }
.step .btn { display: inline-block; text-decoration: none; }

/* Strategy builder */
a.plain { color: inherit; text-decoration: none; }
.strat-list { list-style: none; margin: 0 0 1rem; padding: 0; }
.strat-list li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .75rem 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.strat-list li:first-child { border-top: 0; }
.strat-list li.is-active strong { color: var(--brass); }
.row-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row-actions .btn { text-decoration: none; display: inline-block; }
.strat-form { display: grid; gap: 1rem; }
.strat-form fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 1rem; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.strat-form legend { padding: 0 .4rem; font-weight: 600; }
.strat-form .fld { display: grid; gap: .25rem; align-content: start; }
.strat-form .fld[hidden] { display: none; }
.strat-form label { display: grid; gap: .3rem; font-size: .92rem; }
.strat-form label.check { display: flex; align-items: center; gap: .5rem; }
.strat-form .check input { accent-color: var(--brass); width: 1.05rem; height: 1.05rem; }
.strat-form input[type="time"], .strat-form input:not([type]) { font: inherit; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); }
.strat-form .wide { max-width: 420px; }
.strat-form small { font-size: .8rem; }
