:root {
  --ink: #0a0907;
  --panel: #17140f;
  --panel-2: #1f1b14;
  --line: rgba(214, 180, 112, .16);
  --line-strong: rgba(214, 180, 112, .38);
  --gold: #cfa962;
  --gold-hi: #f0d9a0;
  --gold-lo: #8d6a2f;
  --text: #f3ede1;
  --muted: #a8a092;
  --good: #6fbf8a;
  --warn: #e6a756;
  --bad: #e07a6a;
  --f-display: "Frank Ruhl Libre", "David", serif;
  --f-body: "Assistant", "Segoe UI", Arial, sans-serif;
  --f-latin: "Montserrat", "Segoe UI", Arial, sans-serif;
  --r: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--ink); color: var(--text); font-family: var(--f-body); font-size: 15px; line-height: 1.5; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
.num { font-family: var(--f-latin); direction: ltr; unicode-bidi: isolate; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.app { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { border-inline-start: 1px solid var(--line); background: var(--panel); padding: 22px 16px; display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh; }
.brand { font-family: var(--f-latin); font-weight: 500; letter-spacing: .18em; font-size: 13px; color: var(--gold); margin: 0 10px 22px; direction: ltr; text-align: right; }
.brand b { display: block; font-family: var(--f-display); letter-spacing: 0; font-size: 22px; color: var(--text); }
.nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: var(--muted); font-weight: 600; }
.nav a:hover { background: var(--panel-2); color: var(--text); }
.nav a.on { background: rgba(207,169,98,.12); color: var(--gold-hi); }
.nav svg { width: 20px; height: 20px; flex: none; }
.who { margin-top: auto; padding: 12px; border: 1px solid var(--line); border-radius: 12px; font-size: 13px; color: var(--muted); display: grid; gap: 6px; }
.who b { color: var(--text); font-size: 14px; }
.who a { color: var(--gold); }

main { padding: 28px clamp(16px, 3vw, 40px) 100px; max-width: 1200px; width: 100%; min-width: 0; }
.loading { color: var(--muted); }
.head { display: flex; align-items: end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
h1 { font-family: var(--f-display); font-weight: 900; font-size: clamp(26px, 3vw, 34px); margin: 0; line-height: 1.15; }
h2 { font-size: 17px; margin: 0 0 14px; }
.sub { color: var(--muted); margin: 4px 0 0; }
.muted { color: var(--muted); }

.btn { border: 1px solid var(--line-strong); background: transparent; border-radius: 10px; padding: 9px 16px; cursor: pointer; font-weight: 600; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { border-color: var(--gold); color: var(--gold-hi); }
.btn:disabled { opacity: .5; cursor: progress; }
.btn-gold { background: linear-gradient(100deg, #8d6a2f, #cfa962 55%, #e9cf8f); border: 0; color: #1a1408; }
.btn-gold:hover { color: #000; filter: brightness(1.08); }
.btn-danger { color: var(--bad); border-color: rgba(224,122,106,.45); }
.btn-danger:hover { color: #ffb3a7; border-color: var(--bad); }
.btn-sm { padding: 5px 11px; font-size: 13px; border-radius: 8px; }
.linkbtn { background: none; border: 0; color: var(--gold); cursor: pointer; padding: 0; font-size: 13px; }
.linkbtn:hover { color: var(--gold-hi); text-decoration: underline; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; }
.grid { display: grid; gap: 16px; }
.grid > * { min-width: 0; }
.kpis { grid-template-columns: repeat(4, 1fr); margin-bottom: 16px; }
.kpi .label { color: var(--muted); font-size: 13px; }
.kpi .val { font-family: var(--f-latin); font-size: clamp(22px, 2.4vw, 30px); font-weight: 500; margin-top: 6px; direction: ltr; text-align: right; }
.kpi .val.text { font-family: var(--f-body); font-size: 22px; direction: rtl; }
.kpi .hint { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.kpi.alert .val { color: var(--warn); }
.two { grid-template-columns: 1.3fr 1fr; }
.mt { margin-top: 16px; }

.list { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row .t { font-weight: 600; }
.row .s { color: var(--muted); font-size: 13px; }
.row-end { text-align: left; display: grid; justify-items: end; gap: 4px; }
.empty { color: var(--muted); padding: 10px 0; }

.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; border: 1px solid var(--line-strong); color: var(--muted); white-space: nowrap; }
.tag.good { color: var(--good); border-color: rgba(111,191,138,.4); }
.tag.warn { color: var(--warn); border-color: rgba(230,167,86,.45); }
.tag.bad { color: var(--bad); border-color: rgba(224,122,106,.45); }
.tag.gold { color: var(--gold-hi); }
.tags { display: flex; gap: 4px; flex-wrap: wrap; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.input { background: var(--panel); border: 1px solid var(--line-strong); border-radius: 10px; padding: 9px 12px; min-width: 0; width: 100%; }
.toolbar .input { width: auto; }
.toolbar .input[type=search] { flex: 1 1 220px; }
textarea.input { resize: vertical; min-height: 80px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: right; font-size: 12.5px; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line-strong); }
td { padding: 13px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
td.num { white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--panel-2); }
.tbl { padding: 6px 8px; overflow-x: auto; }
.tbl.flush { padding: 0; }
.cell-sub { color: var(--muted); font-size: 13px; }

.back { color: var(--muted); font-size: 14px; display: inline-block; margin-bottom: 10px; }
.back:hover { color: var(--gold-hi); }
dl.info { display: grid; grid-template-columns: auto 1fr; gap: 10px 18px; margin: 0; }
dl.info dt { color: var(--muted); font-size: 13.5px; }
dl.info dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
dl.info dd.plain { font-weight: 400; white-space: pre-wrap; }
.secret { display: inline-flex; gap: 8px; align-items: center; }

.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: var(--f-latin); }
.chart .grid-line { stroke: var(--line); }
.chart .bar { fill: var(--gold); }
.chart .hit { fill: transparent; }
.chart g:hover .bar { fill: var(--gold-hi); }
.hbar { display: grid; grid-template-columns: 150px 1fr 90px; gap: 10px; align-items: center; padding: 7px 0; }
.hbar .track { height: 12px; }
.hbar .fill { height: 100%; background: var(--gold); border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar .v { text-align: left; color: var(--muted); font-size: 13px; }
.tip { position: fixed; pointer-events: none; background: #000; border: 1px solid var(--line-strong); border-radius: 8px; padding: 6px 10px; font-size: 13px; z-index: 50; display: none; white-space: nowrap; }

.toast { position: fixed; inset-inline: 0; bottom: 24px; margin: 0 auto; width: max-content; max-width: calc(100vw - 32px); background: #000; border: 1px solid var(--line-strong); border-radius: 10px; padding: 10px 16px; z-index: 60; display: none; }
.toast.err { border-color: var(--bad); color: #ffc9bf; }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line-strong); border-radius: 16px; padding: 24px; width: min(540px, calc(100vw - 32px)); max-height: calc(100vh - 32px); }
dialog::backdrop { background: rgba(0,0,0,.6); }
.form { display: grid; gap: 12px; }
.form h2 { font-size: 20px; }
.form label { display: grid; gap: 5px; font-size: 13.5px; color: var(--muted); }
.form .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form .check { display: flex; align-items: center; gap: 8px; color: var(--text); }
.form .check input { width: 18px; height: 18px; accent-color: var(--gold); }
.form fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px 14px; display: grid; gap: 12px; margin: 0; }
.form legend { color: var(--gold); font-size: 13px; padding: 0 6px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-start; margin-top: 8px; flex-wrap: wrap; }
.form-actions .spacer { flex: 1; }
.price-hint { font-size: 12.5px; color: var(--muted); }
.form-err { color: var(--bad); font-size: 14px; min-height: 0; }

.notice { max-width: 460px; margin: 12vh auto; text-align: center; }
.notice h1 { margin-bottom: 10px; }

.bottom-nav, .show-sm { display: none; }

@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .two { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .side { display: none; }
  main { padding-top: 20px; }
  .bottom-nav { display: flex; position: fixed; inset: auto 0 0 0; background: var(--panel); border-top: 1px solid var(--line-strong); z-index: 20; padding-bottom: env(safe-area-inset-bottom); }
  .bottom-nav a { flex: 1; display: grid; justify-items: center; gap: 2px; padding: 9px 0; font-size: 12px; color: var(--muted); }
  .bottom-nav a.on { color: var(--gold-hi); }
  .bottom-nav svg { width: 22px; height: 22px; }
  .hide-sm { display: none; }
  .show-sm { display: block; }
  .hbar { grid-template-columns: 104px 1fr 76px; }
  .form .pair { grid-template-columns: 1fr; }
  .toast { bottom: 84px; }
}
