/* Global Macro Expert terminal UI.
   Dense, full-width, dark "market terminal" layout in the Siller Advisory palette
   (ink #181826, violets #5F6097 / #7A7BAC / #BEBFD6), Inter with tabular figures.
   Spacing on a 4px grid; every grid collapses cleanly from ultra-wide monitors to phones. */
:root {
  --bg: #0d0d17; --bar: #08080f; --panel: #141425; --panel-2: #1b1b30; --panel-3: #22223b;
  --line: #262641; --line-2: #34345a;
  --text: #e8e8f2; --muted: #a3a3bd; --dim: #72738f;
  --violet: #5F6097; --violet-2: #7A7BAC; --lilac: #BEBFD6;
  --pos: #6cc59a; --neg: #e3836b; --amber: #d9b45a; --teal: #5fb8a6;
  --H: Inter, "Segoe UI", Arial, sans-serif;
  --mono: "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace;
  --bar-h: 32px; --pad: 12px; --r: 4px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font: 13px/1.45 var(--H); font-feature-settings: "tnum" 1, "cv11" 1; }
a { color: var(--lilac); }
button, select, input { font: inherit; color: inherit; }
::selection { background: var(--violet); color: #fff; }
:focus-visible { outline: 1px solid var(--lilac); outline-offset: 1px; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- thin top bar ---------- */
.gx-bar { position: sticky; top: 0; z-index: 100; height: var(--bar-h); display: flex; align-items: center; gap: 16px; padding: 0 var(--pad); background: var(--bar); border-bottom: 1px solid var(--line); font: 600 11px/1 var(--H); letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }
.gx-home { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; letter-spacing: .12em; }
.gx-home img { width: 18px; height: 18px; border-radius: 3px; display: block; }
.gx-nav { display: flex; align-items: stretch; height: 100%; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.gx-nav::-webkit-scrollbar { display: none; }
.gx-nav a, .gx-nav span { display: flex; align-items: center; padding: 0 10px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; }
.gx-nav a:hover { color: var(--text); }
.gx-nav a.a { color: #fff; border-bottom-color: var(--violet-2); }
.gx-nav .off { color: var(--dim); cursor: default; }
.gx-right { margin-left: auto; display: flex; align-items: center; gap: 14px; color: var(--dim); }
.gx-right a { color: var(--muted); text-decoration: none; }
.gx-right a:hover { color: var(--text); }
.gx-chip { padding: 3px 6px; border: 1px solid var(--line-2); border-radius: 3px; color: var(--amber); letter-spacing: .1em; }
.gx-clock { font-family: var(--mono); letter-spacing: 0; color: var(--muted); }
.live { display: none; align-items: center; gap: 5px; }
.live.dev { display: flex; }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--dim); }
.live-dot.on { background: var(--pos); }
@media (max-width: 900px) { .gx-clock, .gx-right a, .gx-home span { display: none; } .gx-bar { gap: 8px; } }
@media (max-width: 600px) { .gx-chip { display: none; } }

/* ---------- page frame ---------- */
.shell { width: 100%; padding: var(--pad); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap; padding: 10px var(--pad); margin: calc(-1 * var(--pad)) calc(-1 * var(--pad)) 0; background: var(--panel); border-bottom: 1px solid var(--line); }
.eyebrow { margin: 0 0 4px; color: var(--violet-2); font: 600 10px var(--H); letter-spacing: .16em; text-transform: uppercase; }
h1 { margin: 0; font: 700 20px/1.15 var(--H); letter-spacing: -.01em; }
h1 span { color: var(--lilac); font-weight: 600; }
.subtitle { margin: 4px 0 0; color: var(--muted); font-size: 11.5px; }
.controls { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; }
.control { display: grid; gap: 3px; }
.field-label { color: var(--dim); font: 600 9.5px var(--H); letter-spacing: .12em; text-transform: uppercase; }
select { height: 28px; min-width: 0; padding: 0 26px 0 8px; border: 1px solid var(--line-2); border-radius: 3px; background: var(--panel-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%23a3a3bd'/%3E%3C/svg%3E") no-repeat right 9px center; color: var(--text); font: 600 11.5px var(--H); appearance: none; -webkit-appearance: none; cursor: pointer; }
select:hover { border-color: var(--violet-2); }
select option { background: var(--panel-2); color: var(--text); }
.tabs { display: flex; gap: 0; margin: 0 calc(-1 * var(--pad)) var(--pad); padding: 0 var(--pad); background: var(--panel); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { position: relative; height: 32px; padding: 0 14px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font: 600 11px var(--H); letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; cursor: pointer; }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: #fff; border-bottom-color: var(--violet-2); background: var(--panel-2); }
.tab kbd { margin-right: 6px; padding: 1px 4px; border: 1px solid var(--line-2); border-radius: 2px; color: var(--dim); font: 600 9px var(--mono); }
.view { display: none; }
.view.active { display: block; }
.error { display: none; margin: 0 0 var(--pad); padding: 8px 10px; border: 1px solid rgba(227,131,107,.45); border-radius: var(--r); background: rgba(227,131,107,.1); color: var(--neg); font-size: 12px; }

/* ---------- KPI strip ---------- */
/* Cell grids draw their own right/bottom rules (pulled 1px out and clipped by the frame), so
   incomplete last rows never show empty filler cells. */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.metric { min-width: 0; padding: 9px 12px 10px; margin: 0 -1px -1px 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.metric-label { color: var(--dim); font: 600 9.5px var(--H); letter-spacing: .12em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric-value { margin-top: 5px; font: 700 22px/1 var(--H); letter-spacing: -.02em; white-space: nowrap; }
.metric-unit { margin-left: 4px; color: var(--muted); font: 600 11px var(--H); letter-spacing: 0; }
.metric-note { margin-top: 5px; color: var(--dim); font-size: 10.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- grids ---------- */
.grid-2, .grid-even, .grid-3 { display: grid; gap: var(--pad); margin-top: var(--pad); }
.grid-2 { grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); }
.grid-even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (min-width: 2000px) { .grid-2 { grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr); } }
@media (max-width: 1200px) { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 1000px) { .grid-2, .grid-even, .grid-3 { grid-template-columns: minmax(0, 1fr); } }

/* ---------- panels ---------- */
.panel { min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.panel-head { min-height: 36px; padding: 7px 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; border-bottom: 1px solid var(--line); background: var(--panel-2); }
.panel-head h2 { margin: 0; font: 700 11px/1.2 var(--H); letter-spacing: .1em; text-transform: uppercase; color: var(--text); }
.panel-kicker { margin-top: 2px; color: var(--dim); font-size: 10.5px; }
.panel-body { padding: 10px; }
.chart-tools { display: flex; align-items: center; gap: 6px 8px; flex-wrap: wrap; }
.chart-tools select { min-width: 140px; max-width: 100%; }
.chart-wrap { position: relative; }
canvas { display: block; width: 100%; height: clamp(240px, 32vh, 420px); }
canvas.small { height: clamp(200px, 24vh, 300px); }
.chart-foot { display: flex; justify-content: space-between; gap: 6px 14px; flex-wrap: wrap; margin-top: 6px; color: var(--dim); font-size: 10.5px; }
.chart-tooltip { position: absolute; display: none; z-index: 5; padding: 5px 8px; border: 1px solid var(--line-2); border-radius: 3px; background: var(--bar); color: var(--text); font: 11px var(--H); white-space: nowrap; pointer-events: none; box-shadow: 0 8px 20px -8px rgba(0,0,0,.8); }
.legend { display: flex; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 10.5px; }
.legend i { display: inline-block; width: 10px; height: 3px; margin-right: 5px; vertical-align: middle; border-radius: 1px; }

/* map */
.map-wrap svg { display: block; width: 100%; height: auto; max-height: min(78vh, 900px); background: #101021; border-radius: 3px; }
.map-node { cursor: pointer; }
.map-node text { font: 700 9px var(--H); fill: var(--lilac); pointer-events: none; }
.map-edge { cursor: pointer; }
.map-edge:hover line { stroke-opacity: 1; }

/* notices */
.notice-list { display: grid; }
.notice { padding: 8px 0; border-bottom: 1px solid var(--line); }
.notice:last-child { border-bottom: 0; }
.notice-title { display: flex; align-items: center; gap: 8px; font-size: 11.5px; font-weight: 600; }
.notice-title .val { margin-left: auto; color: var(--text); white-space: nowrap; }
.status-dot { width: 6px; height: 6px; flex: 0 0 6px; border-radius: 50%; background: var(--amber); }
.status-dot.good { background: var(--pos); }
.status-dot.bad { background: var(--neg); }
.notice p { margin: 4px 0 0 14px; color: var(--muted); font-size: 11px; line-height: 1.45; }

/* tables */
.table-wrap { width: 100%; overflow: auto; }
.table-wrap.tall { max-height: min(62vh, 640px); }
table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
th { position: sticky; top: 0; z-index: 1; padding: 6px 8px; background: var(--panel-2); color: var(--dim); text-align: left; font: 600 9.5px var(--H); letter-spacing: .1em; text-transform: uppercase; white-space: nowrap; border-bottom: 1px solid var(--line); }
th.sortable { cursor: pointer; }
th.sortable:hover { color: var(--text); }
td { padding: 5px 8px; border-top: 1px solid var(--line); white-space: nowrap; }
td.num, th.num { text-align: right; }
tbody tr:hover td { background: rgba(122,123,172,.07); }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: rgba(122,123,172,.14); }
tr.current td { background: rgba(217,180,90,.08); }
.positive { color: var(--pos); }
.negative { color: var(--neg); }
.pill { display: inline-block; padding: 2px 6px; border-radius: 3px; font: 700 9px var(--H); letter-spacing: .08em; text-transform: uppercase; background: var(--panel-3); color: var(--muted); }
.pill.good { background: rgba(108,197,154,.14); color: var(--pos); }
.pill.warn { background: rgba(217,180,90,.14); color: var(--amber); }
.pill.bad { background: rgba(227,131,107,.14); color: var(--neg); }
.empty { padding: 18px 10px; color: var(--dim); text-align: center; }

/* paging */
.hour-controls { display: flex; align-items: center; gap: 6px; }
.icon-button { width: 28px; height: 28px; border: 1px solid var(--line-2); border-radius: 3px; background: var(--panel-3); color: var(--text); cursor: pointer; font-size: 14px; line-height: 1; }
.icon-button:hover:not(:disabled) { border-color: var(--violet-2); }
.icon-button:disabled { opacity: .35; cursor: default; }
.page-count { min-width: 96px; color: var(--muted); text-align: center; font-size: 11px; }

/* bars */
.bar-list { display: grid; gap: 6px; }
.bar-row { display: grid; grid-template-columns: minmax(80px, 170px) minmax(60px, 1fr) 64px; align-items: center; gap: 8px; font-size: 11px; }
.bar-row.centered { grid-template-columns: 64px minmax(60px, 1fr) 64px; }
.bar-row > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.bar-row.clickable:hover > span:first-child { color: var(--text); }
.bar-track { position: relative; height: 10px; background: var(--panel-3); border-radius: 2px; overflow: hidden; }
.bar-center { position: absolute; top: 0; left: 50%; width: 1px; height: 100%; background: var(--dim); }
.bar-fill { position: absolute; top: 1px; height: 8px; border-radius: 1px; background: var(--pos); }
.bar-fill.import { background: var(--neg); }
.bar-fill.left { left: 0; background: var(--violet-2); }
.bar-value { text-align: right; }

/* stats */
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 16px; }
.stat { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 11.5px; color: var(--muted); }
.stat strong { color: var(--text); font-weight: 600; }
@media (max-width: 560px) { .stat-grid { grid-template-columns: 1fr; } }

.footer { display: flex; justify-content: space-between; gap: 6px 14px; flex-wrap: wrap; margin-top: var(--pad); padding-top: 8px; border-top: 1px solid var(--line); color: var(--dim); font-size: 10.5px; }
.footer strong { color: var(--muted); }

/* ---------- phones ---------- */
@media (max-width: 600px) {
  :root { --pad: 8px; }
  h1 { font-size: 17px; }
  .controls { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .controls select { width: 100%; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-value { font-size: 19px; }
  .panel-head { align-items: flex-start; flex-direction: column; }
  .chart-tools { width: 100%; display: grid; grid-template-columns: auto 1fr; }
  .chart-tools select { width: 100%; min-width: 0; }
  .bar-row { grid-template-columns: minmax(70px, 110px) minmax(40px, 1fr) 54px; }
  .tab { padding: 0 10px; }
  .tab kbd { display: none; }
}

/* ---------- free-access gate (first-time visitors) ----------
   The gated block stays in the DOM (indexable); first-time visitors see it dimmed and blurred
   with a card asking them to visit Siller Advisory. <html class="unlocked"> removes the gate. */
:is(html:not(.unlocked) .gated, html:not(.member) .gated[data-always]):not(.dismissed) { position: relative; max-height: var(--gate-max, 1100px); overflow: hidden; -webkit-mask-image: linear-gradient(180deg, #000 60%, transparent); mask-image: linear-gradient(180deg, #000 60%, transparent); }
:is(html:not(.unlocked) .gated, html:not(.member) .gated[data-always]):not(.dismissed) .gate-blur, :is(html:not(.unlocked) .gated, html:not(.member) .gated[data-always]):not(.dismissed)[data-gate="views"] .view > :not(.metrics) { filter: blur(5px) saturate(.6); opacity: .38; pointer-events: none; user-select: none; }
.gate-card { display: none; }
:is(html:not(.unlocked) .gated, html:not(.member) .gated[data-always]):not(.dismissed) .gate-card { display: block; position: absolute; z-index: 20; top: var(--gate-top, 48px); left: 50%; transform: translateX(-50%); width: min(560px, calc(100% - 24px)); padding: 22px 24px 20px; border: 1px solid var(--line-2); border-radius: 6px; background: rgba(13,13,23,.94); box-shadow: 0 30px 70px -20px rgba(0,0,0,.9), 0 0 0 1px rgba(122,123,172,.12); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.gate-card:before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; border-radius: 6px 6px 0 0; background: linear-gradient(90deg, var(--violet), var(--lilac)); }
.gate-card .eyebrow { margin-bottom: 8px; }
.gate-card h2 { margin: 0 0 8px; font: 700 19px/1.25 var(--H); letter-spacing: -.01em; }
.gate-card p { margin: 0 0 16px; color: var(--muted); font-size: 12.5px; line-height: 1.55; }
.gate-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.gate-btn { display: inline-flex; align-items: center; height: 32px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: 3px; background: var(--panel-3); color: var(--text); font: 600 11px var(--H); letter-spacing: .08em; text-transform: uppercase; text-decoration: none; white-space: nowrap; }
.gate-btn:hover { border-color: var(--violet-2); }
.gate-btn.primary { background: var(--violet); border-color: var(--violet); color: #fff; }
.gate-btn.primary:hover { background: var(--violet-2); border-color: var(--violet-2); }
.gx-auth { color: var(--lilac) !important; }
@media (max-width: 600px) { :is(html:not(.unlocked) .gated, html:not(.member) .gated[data-always]):not(.dismissed) .gate-card { padding: 16px; } .gate-card h2 { font-size: 16px; } .gate-btn { flex: 1 1 auto; justify-content: center; } }
.gate-sub { margin: 12px 0 0 !important; color: var(--dim) !important; font-size: 11.5px !important; }
.gate-paid { margin-top: 16px !important; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted) !important; }
.gate-paid + .gate-sub { margin-top: 6px !important; }
