/* HedgX Core - desk UI. Neutral graphite, one accent, colour reserved for meaning (PnL, severity). */
:root {
  --bg: #0e1013; --s1: #14171b; --s2: #1a1e23; --s3: #22272d; --line: #262b31; --line2: #30363d;
  --text: #d8dce1; --strong: #f1f3f5; --muted: #858c96; --faint: #5d646d;
  --accent: #4a8ef0; --accent-d: #2f6fcc; --pos: #3fae76; --neg: #e1584f; --warn: #d0a03a; --info: #6e9fd8;
  --r: 6px; --side: 212px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f4f5f7; --s1: #ffffff; --s2: #f8f9fa; --s3: #eef0f2; --line: #e3e6ea; --line2: #d5d9de;
    --text: #23272d; --strong: #0f1215; --muted: #6a717b; --faint: #9aa1aa;
    --accent: #2563c9; --accent-d: #1d4fa3; --pos: #1f8a55; --neg: #c53b33; --warn: #a77b12; --info: #3c6db0;
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.num, td.n, th.n { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.pos { color: var(--pos); } .neg { color: var(--neg); } .warn { color: var(--warn); } .muted { color: var(--muted); } .faint { color: var(--faint); }
.small { font-size: 12.5px; } .strong { color: var(--strong); font-weight: 600; } .mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.side { background: var(--s1); border-right: 1px solid var(--line); position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; }
.brand { padding: 16px 16px 14px; font-weight: 700; letter-spacing: .12em; font-size: 12px; color: var(--strong); border-bottom: 1px solid var(--line); }
.brand small { display: block; font-weight: 500; letter-spacing: 0; color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.nav { padding: 8px 8px 16px; flex: 1; }
.nav h6 { margin: 14px 8px 4px; font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase; color: var(--faint); font-weight: 600; }
.nav a { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px; border-radius: 5px; color: var(--text); font-size: 13.5px; }
.nav a:hover { background: var(--s2); text-decoration: none; }
.nav a.on { background: var(--s3); color: var(--strong); box-shadow: inset 2px 0 0 var(--accent); }
.nav .cnt { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.me { border-top: 1px solid var(--line); padding: 10px 14px 12px; font-size: 12.5px; color: var(--muted); }
.me .who { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me button { margin-top: 6px; }
.mainc { min-width: 0; }
.topbar { display: none; }
.page { padding: 18px 24px 40px; max-width: 1600px; }
.ph { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px;
  padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.ph h1 { margin: 0; font-size: 19px; font-weight: 600; color: var(--strong); letter-spacing: -.01em; }
.ph .sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.ph .meta { color: var(--muted); font-size: 12px; text-align: right; }

/* ---------- blocks ---------- */
.panel { background: var(--s1); border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 14px; }
.panel > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.panel > header h2 { margin: 0; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.panel > .body { padding: 12px; }
.cols { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
.cols > .panel { margin-bottom: 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); border: 1px solid var(--line); border-radius: var(--r);
  background: var(--s1); margin-bottom: 14px; }
.kpi { padding: 10px 14px; border-right: 1px solid var(--line); }
.kpi:last-child { border-right: 0; }
.kpi .l { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.kpi .v { font-size: 20px; font-weight: 600; color: var(--strong); font-variant-numeric: tabular-nums; margin-top: 2px; }
.kpi .v.pos { color: var(--pos); } .kpi .v.neg { color: var(--neg); }
.kpi .s { font-size: 11.5px; color: var(--muted); }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 5px 14px; margin: 0; font-size: 13px; }
dl.facts dt { color: var(--muted); } dl.facts dd { margin: 0; color: var(--text); }
.prose { font-size: 13.5px; color: var(--text); margin: 0 0 8px; }

/* ---------- tables ---------- */
.tw { overflow: auto; max-height: calc(100vh - 210px); }
.tw.free { max-height: none; }
table.t { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.t th { position: sticky; top: 0; background: var(--s2); color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase;
  letter-spacing: .04em; text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line2); white-space: nowrap; z-index: 1; }
table.t th.sort { cursor: pointer; user-select: none; } table.t th.sort:hover { color: var(--text); }
table.t th.asc::after { content: " \25B2"; font-size: 9px; } table.t th.desc::after { content: " \25BC"; font-size: 9px; }
table.t td { padding: 6px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t tbody tr:hover td { background: var(--s2); }
table.t tr.click { cursor: pointer; }
table.t td.wrap { white-space: normal; min-width: 220px; }
.empty { padding: 18px 12px; color: var(--muted); }

/* ---------- controls ---------- */
.bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.bar .grow { flex: 1 1 220px; }
label.f { display: flex; flex-direction: column; gap: 3px; font-size: 11.5px; color: var(--muted); }
input, select, textarea { background: var(--bg); color: var(--text); border: 1px solid var(--line2); border-radius: 5px; padding: 6px 9px;
  font: inherit; font-size: 13.5px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent); }
input[type=checkbox] { width: 15px; height: 15px; accent-color: var(--accent); }
.chk { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; color: var(--text); }
button, .btn { background: var(--accent-d); color: #fff; border: 1px solid var(--accent-d); border-radius: 5px; padding: 6px 12px; font: inherit;
  font-size: 13px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
button:hover, .btn:hover { background: var(--accent); border-color: var(--accent); text-decoration: none; }
button.sec { background: transparent; color: var(--text); border-color: var(--line2); font-weight: 500; }
button.sec:hover { background: var(--s3); }
button.del { background: transparent; color: var(--neg); border-color: color-mix(in srgb, var(--neg) 45%, transparent); font-weight: 500; padding: 3px 9px; }
button.del:hover { background: color-mix(in srgb, var(--neg) 12%, transparent); }
.seg { display: inline-flex; border: 1px solid var(--line2); border-radius: 5px; overflow: hidden; }
.seg a { padding: 5px 11px; color: var(--muted); font-size: 13px; border-right: 1px solid var(--line2); }
.seg a:last-child { border-right: 0; }
.seg a.on { background: var(--s3); color: var(--strong); }
.seg a:hover { text-decoration: none; color: var(--text); }
.msg { display: none; margin: 8px 12px; padding: 7px 10px; border-radius: 5px; font-size: 13px; }
.msg.ok { display: block; color: var(--pos); background: color-mix(in srgb, var(--pos) 10%, transparent); }
.msg.err { display: block; color: var(--neg); background: color-mix(in srgb, var(--neg) 10%, transparent); }

/* ---------- tags ---------- */
.tag { display: inline-block; font-size: 11px; line-height: 17px; padding: 0 6px; border-radius: 3px; border: 1px solid var(--line2); color: var(--muted);
  white-space: nowrap; margin: 0 3px 2px 0; }
.tag.dnt { color: var(--neg); border-color: color-mix(in srgb, var(--neg) 40%, transparent); }
.tag.mkt { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.tag.hi { color: var(--neg); } .tag.med { color: var(--warn); } .tag.acc { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; background: var(--faint); }
.dot.ok { background: var(--pos); } .dot.bad { background: var(--neg); } .dot.warn { background: var(--warn); }

/* ---------- alert feed ---------- */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { padding: 8px 12px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 92px 1fr; gap: 10px; font-size: 13px; }
.feed li:last-child { border-bottom: 0; }
.feed .t { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.feed .k { color: var(--strong); font-weight: 600; }
.feed .x { color: var(--muted); font-size: 12.5px; white-space: pre-line; max-height: 4.4em; overflow: hidden; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1fr; place-items: center; padding: 16px; }
.login .box { width: 100%; max-width: 360px; }
.login .mark { font-weight: 700; letter-spacing: .14em; font-size: 13px; color: var(--strong); }
.login .mark span { color: var(--muted); font-weight: 500; letter-spacing: 0; }
.login p { color: var(--muted); font-size: 13px; }
.gbtn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; background: var(--s1); color: var(--strong);
  border: 1px solid var(--line2); padding: 9px 14px; border-radius: 5px; font-weight: 600; margin: 18px 0 10px; }
.gbtn:hover { background: var(--s3); text-decoration: none; }

/* ---------- small screens ---------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 20; inset: 0 auto 0 0; width: 250px; transform: translateX(-100%); transition: transform .18s ease; }
  body.menu .side { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.45); }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 9px 14px; background: var(--s1); border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 10; }
  .topbar .t { font-weight: 700; letter-spacing: .12em; font-size: 12px; color: var(--strong); }
  .page { padding: 12px 12px 32px; }
  .cols { grid-template-columns: 1fr; }
  .tw { max-height: none; }
  .ph .meta { text-align: left; }
  .feed li { grid-template-columns: 1fr; gap: 2px; }
  .hide-s { display: none; }
}
