/* Hermes PA — warm paper interface.
   Layout: a fixed left sidebar (brand, navigation, status) beside one centred reading column; serif
   page titles over sans-serif UI; white cards with hairline borders; a right-hand panel for details.
   On phones the sidebar becomes a drawer behind a slim top bar. Green = up, red = down. */
:root {
  --bg: #FAF9F5; --side: #F5F4ED; --card: #FFFFFF; --ink: #141413; --ink2: #3D3D3A; --muted: #73726C; --faint: #A6A49B;
  --line: #E8E6DC; --line2: #F0EEE6; --hover: #F0EEE6; --press: #E8E6DC;
  --accent: #D97757; --accent2: #C6613F; --accentbg: #F8ECE5;
  --green: #2E8B57; --red: #C4473A; --greenbg: #E7F3EC; --redbg: #F9E9E6; --amber: #A86B12; --amberbg: #F7EEDB;
  --shadow: 0 1px 2px rgba(20, 20, 19, .04), 0 4px 16px rgba(20, 20, 19, .04);
  --scrim: rgba(20, 20, 19, .28);
  --serif: ui-serif, "Iowan Old Style", "Charter", "Source Serif 4", Georgia, "Songti SC", "STSong", "Noto Serif SC", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --top: env(safe-area-inset-top, 0px); --bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #262624; --side: #1F1E1D; --card: #30302E; --ink: #FAF9F5; --ink2: #E3E1D8; --muted: #A4A298; --faint: #75736B;
    --line: #3E3D39; --line2: #353532; --hover: #353532; --press: #3E3D39;
    --accent: #D97757; --accent2: #E08A6D; --accentbg: #3D2B24;
    --green: #5CB885; --red: #E0735F; --greenbg: #243A2E; --redbg: #43281F; --amber: #E0A84A; --amberbg: #3A2F1A;
    --shadow: 0 1px 2px rgba(0, 0, 0, .2), 0 4px 16px rgba(0, 0, 0, .18);
    --scrim: rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.6 var(--sans); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; }
input { font: inherit; color: inherit; }
a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.pos { color: var(--green); } .neg { color: var(--red); } .mute { color: var(--muted); }

/* ───────── sidebar ───────── */
.side { position: fixed; inset: 0 auto 0 0; width: 264px; background: var(--side); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: calc(var(--top) + 16px) 12px calc(var(--bottom) + 14px); z-index: 30; }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 18px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.mark { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: #fff; display: grid; place-items: center; flex: 0 0 30px; }
.brand b { font-family: var(--serif); font-size: 19px; font-weight: 600; letter-spacing: -.2px; }
.brand small { display: block; font-size: 11px; color: var(--muted); margin-top: -2px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px; color: var(--ink2); font-size: 14px; font-weight: 500; }
.nav button:hover { background: var(--hover); }
.nav button[aria-current="page"] { background: var(--press); color: var(--ink); }
.nav svg { width: 18px; height: 18px; flex: 0 0 18px; color: var(--muted); }
.nav button[aria-current="page"] svg { color: var(--accent); }
.side .label { font-size: 12px; color: var(--muted); padding: 18px 12px 6px; }
.side .foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }
.status { display: flex; align-items: center; gap: 8px; padding: 9px 12px; font-size: 13px; color: var(--muted); }
.status i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.status.live i { background: var(--green); }
.status.bad i { background: var(--amber); }

/* phones: top bar + drawer */
.topbar { display: none; }
.scrim { display: none; }

/* ───────── main column ───────── */
main { margin-left: 264px; min-height: 100vh; padding: calc(var(--top) + 44px) 40px calc(var(--bottom) + 64px); }
.col { max-width: 1040px; margin: 0 auto; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 28px; }
h1 { font-family: var(--serif); font-weight: 500; font-size: 34px; line-height: 1.2; letter-spacing: -.5px; margin: 0; text-wrap: balance; }
.sub { color: var(--muted); margin: 6px 0 0; font-size: 15px; }
h2 { font-family: var(--serif); font-weight: 500; font-size: 21px; letter-spacing: -.2px; margin: 0; }
h3 { font-size: 14px; font-weight: 600; margin: 0; }
section.block { margin-top: 36px; }
.bh { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.bh p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.pad { padding: 18px 20px; }
.grid { display: grid; gap: 12px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat { padding: 16px 18px; min-width: 0; }
.stat .l { font-size: 13px; color: var(--muted); }
.stat .v { font-family: var(--serif); font-size: 28px; font-weight: 500; line-height: 1.25; margin-top: 4px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .s { font-size: 12px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--line2); border: 1px solid var(--line); border-radius: 10px; }
.seg button { padding: 5px 12px; border-radius: 7px; font-size: 13px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.seg button[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(20, 20, 19, .08); }
.search { border: 1px solid var(--line); background: var(--card); padding: 8px 14px; border-radius: 12px; font-size: 14px; width: 240px; outline: none; }
.search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accentbg); }
.tools { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.tag { display: inline-block; font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: 999px; background: var(--line2); color: var(--muted); white-space: nowrap; vertical-align: 1px; border: 1px solid var(--line); }
.tag.ok { background: var(--greenbg); color: var(--green); border-color: transparent; }
.tag.no { background: var(--redbg); color: var(--red); border-color: transparent; }
.tag.warn { background: var(--amberbg); color: var(--amber); border-color: transparent; }
.tag.acc { background: var(--accentbg); color: var(--accent2); border-color: transparent; }
.chg { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.logo { width: 26px; height: 26px; border-radius: 50%; flex: 0 0 26px; object-fit: cover; background: var(--line2); }
.logo-fb { display: inline-grid; place-items: center; font-size: 11px; font-weight: 600; color: var(--muted); }

/* ───────── tables (fold into two-line rows on phones) ───────── */
.tbl { overflow-x: auto; }
.tr { display: grid; align-items: center; gap: 14px; padding: 12px 20px; border-top: 1px solid var(--line2); width: 100%; text-align: left; min-width: 0; }
.tr:first-child { border-top: 0; }
.tr.th { font-size: 12px; color: var(--muted); padding-block: 10px; border-bottom: 1px solid var(--line); }
.tr.th + .tr { border-top: 0; }
button.tr:hover { background: var(--hover); }
.tr > * { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r { text-align: right; }
.sym { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.sym > span { min-width: 0; }
.sym .sub2 { display: block; font-size: 12px; color: var(--muted); font-weight: 400; overflow: hidden; text-overflow: ellipsis; }
.t-mkt .tr { grid-template-columns: minmax(170px, 2fr) 1.2fr .9fr 1.8fr 1.1fr 1fr; }
.t-major .tr { grid-template-columns: minmax(140px, 1.6fr) 1.2fr .8fr; }
.t-ev .tr { grid-template-columns: minmax(170px, 2fr) 50px repeat(3, .9fr) 24px repeat(3, .9fr); }
.t-setup .tr { grid-template-columns: minmax(120px, 1.6fr) repeat(4, 1fr); }
.t-crit .tr { grid-template-columns: 28px minmax(0, 2.2fr) minmax(0, 1.6fr) minmax(0, 1.2fr); white-space: normal; }
.t-crit .tr > * { white-space: normal; }
.more { display: block; width: 100%; padding: 12px; text-align: center; color: var(--accent2); font-size: 13px; font-weight: 500; border-top: 1px solid var(--line2); }
.more:hover { background: var(--hover); }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); font-size: 14px; }

.check { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.check.ok { background: var(--greenbg); color: var(--green); }
.check.no { background: var(--redbg); color: var(--red); }
.check.na { background: var(--line2); color: var(--faint); }

/* notice (like a Claude callout) */
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 12px; background: var(--accentbg); color: var(--ink2); font-size: 14px; }
.notice svg { flex: 0 0 18px; color: var(--accent); margin-top: 2px; }

/* prose (research log) */
.prose { font-family: var(--serif); font-size: 16px; line-height: 1.75; color: var(--ink2); max-width: 72ch; }
.prose h1, .prose h2 { font-family: var(--serif); margin: 28px 0 10px; }
.prose h1 { font-size: 26px; } .prose h2 { font-size: 21px; }
.prose p, .prose ul { margin: 0 0 14px; }
.prose li { margin: 4px 0; }
.prose strong { color: var(--ink); }
.prose table { border-collapse: collapse; font-family: var(--sans); font-size: 13px; margin: 8px 0 18px; display: block; overflow-x: auto; }
.prose th, .prose td { border-bottom: 1px solid var(--line); padding: 7px 12px; text-align: left; white-space: nowrap; }
.prose code { font-family: var(--mono); font-size: 13px; background: var(--line2); padding: 1px 5px; border-radius: 5px; }

/* charts */
.chart { height: 260px; position: relative; }
.chart.tall { height: 320px; }
.tip { position: absolute; top: -22px; left: 0; right: 0; font-size: 12px; color: var(--muted); pointer-events: none; z-index: 3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chart-wrap { padding: 34px 12px 8px 16px; }

/* ───────── right panel ───────── */
dialog.panel { position: fixed; inset: 0 0 0 auto; margin: 0; height: 100%; max-height: none; width: min(600px, 100%);
  border: 0; border-left: 1px solid var(--line); padding: 0; background: var(--bg); color: var(--ink); box-shadow: -12px 0 40px rgba(20, 20, 19, .10); }
dialog.panel[open] { display: flex; flex-direction: column; animation: slide .25s cubic-bezier(.2, .8, .2, 1); }
dialog.panel::backdrop { background: var(--scrim); }
@keyframes slide { from { transform: translateX(32px); opacity: 0; } }
.ph { display: flex; align-items: center; gap: 10px; padding: calc(var(--top) + 16px) 22px 14px; border-bottom: 1px solid var(--line); }
.ph h2 { display: flex; align-items: center; gap: 10px; min-width: 0; }
.x { margin-left: auto; width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: var(--muted); font-size: 20px; }
.x:hover { background: var(--hover); }
.pbody { flex: 1; overflow-y: auto; padding: 20px 22px calc(var(--bottom) + 28px); }
.big { font-family: var(--serif); font-size: 36px; font-weight: 500; font-variant-numeric: tabular-nums; line-height: 1.15; }
.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 16px; }
.kv div { padding: 12px 14px; }
.kv span { font-size: 12px; color: var(--muted); }
.kv strong { display: block; font-size: 16px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }

/* ───────── lock ───────── */
.lock { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.lock .box { width: 100%; max-width: 380px; text-align: center; }
.lock .mark { width: 44px; height: 44px; border-radius: 13px; margin: 0 auto 18px; }
.lock h1 { font-size: 30px; }
.lock p { color: var(--muted); margin: 8px 0 26px; }
.lock form { display: flex; flex-direction: column; gap: 10px; }
.lock input { height: 48px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); padding: 0 16px; font-size: 16px; outline: none; box-shadow: var(--shadow); }
.lock input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accentbg); }
.lock .btn { height: 46px; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 600; text-align: center; }
.lock .btn:hover { background: var(--accent2); }
.lock .btn:disabled { opacity: .55; }
.lock .err { color: var(--red); font-size: 13px; min-height: 18px; margin: 0; }
.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }

/* ───────── responsive ───────── */
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } main { padding-inline: 28px; } }
@media (max-width: 860px) {
  .side { transform: translateX(-100%); transition: transform .25s cubic-bezier(.2, .8, .2, 1); box-shadow: none; }
  body.drawer .side { transform: none; box-shadow: 12px 0 40px rgba(20, 20, 19, .16); }
  body.drawer .scrim { display: block; position: fixed; inset: 0; background: var(--scrim); z-index: 25; }
  .topbar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 20; padding: calc(var(--top) + 10px) 14px 10px;
    background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
  .topbar .menu { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; }
  .topbar .menu:hover { background: var(--hover); }
  .topbar b { font-family: var(--serif); font-size: 17px; font-weight: 500; }
  .topbar .status { margin-left: auto; padding: 0; }
  main { margin-left: 0; padding: 22px 16px calc(var(--bottom) + 48px); }
  h1 { font-size: 28px; }
  .head { flex-direction: column; align-items: flex-start; gap: 12px; margin-bottom: 20px; }
  .g3, .g2 { grid-template-columns: 1fr; }
  .stat .v { font-size: 24px; }
  .search { width: 100%; }
  .tools { width: 100%; }
  .tr { padding: 12px 16px; gap: 2px 12px; }
  .tr.th { display: none; }
  .t-mkt .tr, .t-major .tr, .t-setup .tr { grid-template-columns: minmax(0, 1fr) auto; }
  .tr > .hide-m { display: none; }
  .tr > .sym { grid-row: 1 / 3; }
  .tr > .m1 { grid-column: 2; grid-row: 1; text-align: right; }
  .tr > .m2 { grid-column: 2; grid-row: 2; text-align: right; font-size: 13px; }
  .t-ev .tr { grid-template-columns: minmax(0, 1fr) auto auto; }
  .t-crit .tr { grid-template-columns: 26px minmax(0, 1fr); }
  .t-crit .tr > :nth-child(3), .t-crit .tr > :nth-child(4) { grid-column: 2; }
  dialog.panel { width: 100%; border-left: 0; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
