:root {
  --bg: #0a0e0a; --panel: #0e130e; --fg: #c8d0c8; --amber: #f5a623;
  --up: #4caf50; --down: #ef5350; --muted: #6a746a; --line: #1e261e;
}
* { box-sizing: border-box; margin: 0; }
body {
  background: var(--bg); color: var(--fg);
  font: 13px/1.45 "SF Mono", Menlo, Consolas, monospace;
  height: 100vh; display: flex; flex-direction: column;
}
header {
  display: flex; gap: 16px; align-items: baseline;
  padding: 8px 14px; border-bottom: 1px solid var(--line);
}
.brand { color: var(--amber); letter-spacing: 3px; font-weight: 700; }
.muted { color: var(--muted); font-size: 11px; }
.banner { color: #0a0e0a; background: var(--amber); padding: 1px 8px; }
.hidden { display: none !important; }

.grid {
  flex: 1; min-height: 0; display: grid; gap: 8px; padding: 8px;
  grid-template-columns: 4fr 3fr 3fr;
}
.col-left { display: grid; grid-template-rows: 3fr 2fr; gap: 8px; min-height: 0; }
.panel {
  background: var(--panel); border: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
.panel-title {
  color: var(--amber); font-size: 11px; letter-spacing: 2px;
  padding: 6px 10px; border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: baseline;
}
.panel-body { flex: 1; overflow-y: auto; padding: 4px 10px; }
.panel-foot { padding: 4px 10px; border-top: 1px solid var(--line); font-size: 10px; }
.panel-foot.stale { color: var(--amber); }

table { width: 100%; border-collapse: collapse; }
th { color: var(--muted); font-size: 10px; text-transform: uppercase; text-align: right;
     font-weight: 400; padding: 3px 4px; }
th:first-child, td:first-child { text-align: left; }
td { padding: 3px 4px; text-align: right; white-space: nowrap; }
td.sym { color: var(--amber); }
.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--muted); }

tr.clickable, td.clickable { cursor: pointer; }
tr.clickable:hover, td.clickable:hover { background: var(--line); }
tr.release td.actual { font-weight: 700; }
tr.macro-divider td { color: var(--amber); letter-spacing: 2px; font-size: 10px;
                      text-align: center; padding: 6px 0 4px; }

.news-item { padding: 4px 0; border-bottom: 1px dotted var(--line); }
.news-item a { color: var(--amber); text-decoration: none; }
.news-item a:hover { color: #ffc95c; text-decoration: underline; }
.news-meta { color: var(--muted); font-size: 10px; }

.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.75);
  display: flex; align-items: center; justify-content: center;
}
.overlay-box {
  background: var(--panel); border: 1px solid var(--amber);
  padding: 12px; width: min(860px, 92vw);
}
.overlay-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;
                color: var(--amber); letter-spacing: 1px; }
.overlay-head button {
  background: none; border: none; color: var(--fg); cursor: pointer;
  font-size: 16px; line-height: 1; padding: 6px 10px; margin: -6px -10px;
}
.overlay-head button:hover { color: var(--amber); }

/* Bloomberg PORT-style workspace tabs: beveled buttons on a dark strip,
   active tab raised (light top/left, dark bottom/right) and merged into
   the content below by overlapping the strip's bottom border. */
.tab-row {
  display: flex; gap: 3px; align-items: flex-end;
  padding: 4px 8px 0; background: #131813; border-bottom: 1px solid #3c443c;
}
.tab-row a {
  color: #aab2aa; text-decoration: none; font-size: 11px; letter-spacing: 2px;
  padding: 2px 18px; background: linear-gradient(#2c332c, #191f19);
  border: 1px solid #060906;
  border-top-color: #4c544c; border-left-color: #444c44; border-bottom: none;
}
.tab-row a.active {
  color: var(--amber); font-weight: 700;
  background: linear-gradient(#4e564e, #272d27);
  border-top-color: #788278; border-left-color: #6a746a;
  padding-bottom: 3px; margin-bottom: -1px;
}
.grid-defi { grid-template-columns: 5fr 4fr; }
.grid-cycle { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); align-content: start; }
.grid-cycle .panel { min-height: 0; }
.col-right { display: grid; grid-template-rows: 3fr 2fr; gap: 8px; min-height: 0; }
.tier-head td { color: var(--amber); letter-spacing: 2px; font-size: 10px; padding-top: 8px; }
.tier-stats { color: var(--muted); letter-spacing: 1px; float: right; }
.defi-link { color: inherit; text-decoration: none; }
.defi-link:hover { color: var(--amber); text-decoration: underline; }
#midnight-curve { margin-top: 8px; }
.empty-state { color: var(--muted); padding: 8px 0; }

.view-toggle a { color: var(--muted); cursor: pointer; letter-spacing: 1px; padding: 0 6px; }
.view-toggle a.active { color: var(--bg); background: var(--amber); }

/* AI comment band: first child of the MKT grid, spanning every column. The
   grid only gets the auto+1fr row template while the band is shown, so an
   install without a comment keeps today's single-row layout exactly. */
.panel.comment { grid-column: 1 / -1; max-height: 32vh; }
.grid.has-comment { grid-template-rows: auto minmax(0, 1fr); }
.comment-body {
  flex: 0 1 auto; min-height: 0; overflow-y: auto;
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px 24px; padding: 6px 10px 8px;
}
.comment-headline { color: var(--amber); font-size: 18px; font-weight: 700; line-height: 1.3; margin-bottom: 4px; }
.comment-read { line-height: 1.5; }
.comment-label { color: var(--muted); font-size: 10px; letter-spacing: 2px; margin-bottom: 4px; }
.comment-drivers { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.comment-driver { border-left: 2px solid var(--amber); padding-left: 6px; overflow-wrap: anywhere; }
.comment-rotation { margin-top: 6px; font-size: 12px; }
.comment-meta { letter-spacing: 1px; }
.comment-meta.stale { color: var(--amber); }
.comment-outdated { display: flex; gap: 14px; align-items: center; padding: 8px 10px; color: var(--muted); }
.comment-refresh {
  background: none; border: 1px solid var(--amber); color: var(--amber);
  font: inherit; font-size: 11px; letter-spacing: 2px; padding: 2px 10px; cursor: pointer;
}
.comment-refresh:hover:not(:disabled) { background: var(--amber); color: var(--bg); }
.comment-refresh:disabled { opacity: .5; cursor: default; }

/* Alerts: a header control with an unread count, a dropdown of recent alerts,
   and toasts for new ones. Native notifications are the browser's own. */
.alerts-toggle {
  margin-left: auto; background: none; border: 1px solid var(--line); color: var(--muted);
  font: inherit; font-size: 11px; letter-spacing: 2px; padding: 1px 8px; cursor: pointer;
}
.alerts-toggle:hover, .alerts-toggle.open { color: var(--amber); border-color: var(--amber); }
.alerts-count { color: var(--bg); background: var(--amber); padding: 0 5px; margin-left: 6px; font-weight: 700; }
.alerts-list {
  position: absolute; right: 8px; top: 34px; z-index: 20; width: min(520px, 94vw); max-height: 60vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--amber); padding: 6px 10px;
}
.alert-item { padding: 6px 0; border-bottom: 1px dotted var(--line); }
.alert-item .alert-title { color: var(--amber); }
.alert-item .alert-meta { color: var(--muted); font-size: 10px; letter-spacing: 1px; }
.toasts { position: fixed; right: 12px; top: 40px; z-index: 30; display: flex; flex-direction: column; gap: 8px; width: min(420px, 92vw); }
.toast { background: var(--panel); border: 1px solid var(--amber); padding: 8px 10px; cursor: pointer; }
.toast .alert-title { color: var(--amber); font-weight: 700; }

/* /voisins: the hidden usage page. Same panels, a token prompt, stacked tables. */
.voisins { flex: 1; overflow-y: auto; padding: 8px; display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); align-content: start; }
.voisins .panel { min-height: 0; }
.voisins .panel-body { overflow-x: auto; }
.voisins .wide { grid-column: 1 / -1; }
.token-form { display: flex; gap: 8px; align-items: center; padding: 10px; }
.token-form input { background: var(--bg); border: 1px solid var(--line); color: var(--fg); font: inherit; padding: 3px 8px; width: min(360px, 70vw); }
.token-form button { background: none; border: 1px solid var(--amber); color: var(--amber); font: inherit; font-size: 11px; letter-spacing: 2px; padding: 2px 10px; cursor: pointer; }
.totals { display: flex; gap: 24px; flex-wrap: wrap; padding: 8px 10px; }
.totals .n { color: var(--amber); font-size: 20px; font-weight: 700; }
.totals .l { color: var(--muted); font-size: 10px; letter-spacing: 2px; }

@media (max-width: 1000px) {
  .grid { grid-template-columns: 1fr; grid-auto-rows: minmax(240px, auto); overflow-y: auto; }
  body { height: auto; }
  .grid.has-comment { grid-template-rows: auto; }
  .comment-body { grid-template-columns: 1fr; }
  /* the tab strip and every table scroll sideways instead of clipping */
  .tab-row { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .tab-row a { flex: 0 0 auto; }
  .panel-body { overflow-x: auto; }
  .panel, .col-left, .col-right { min-width: 0; }  /* a wide table scrolls inside its panel, never widens the grid */
}

/* Phones. Content height per panel (no 240px floor), a tighter tab strip,
   the least important columns hidden (c-opt), one-column band with the
   model line under the title, full-width alerts and toasts. */
@media (max-width: 480px) {
  body { font-size: 12px; }
  header { gap: 10px; padding: 6px 10px; }
  .grid { grid-auto-rows: auto; gap: 6px; padding: 6px; }
  .panel-body { padding: 4px 6px; }
  .panel-foot { padding: 3px 6px; }
  .tab-row { padding-left: 4px; gap: 2px; }
  .tab-row a { padding: 2px 7px; letter-spacing: 0; font-size: 10px; }
  .col-left, .col-right { grid-template-rows: auto; }  /* content height, not the desktop 3:2 split */
  td, th { padding: 3px 3px; }
  .c-opt { display: none; }
  .panel.comment { max-height: none; }
  .panel.comment .panel-title { flex-wrap: wrap; gap: 2px 10px; }
  .comment-headline { font-size: 15px; }
  .comment-outdated { flex-wrap: wrap; gap: 8px; }
  .alerts-list { left: 6px; right: 6px; width: auto; }
  .toasts { left: 6px; right: 6px; width: auto; top: 36px; }
  .news-item a { overflow-wrap: anywhere; }
  #panel-defi td.sym { white-space: normal; overflow-wrap: anywhere; max-width: 150px; }  /* vault names wrap instead of pushing APY off screen */
}
