/* FF IQ admin console: layout, navigation, tiles, panels, charts. Colours come from app.css tokens. */

.admin-body {
  --series-1: #2a78d6;      /* model cost   (dataviz reference palette, slot 1, light) */
  --series-2: #eb6834;      /* BigQuery cost (slot 2, light) */
  --nav-w: 216px;
  min-height: 100dvh;
}
@media (prefers-color-scheme: dark) {
  .admin-body { --series-1: #3987e5; --series-2: #d95926; }
}

/* Top bar */
.admin-top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px;
  height: 57px; box-sizing: border-box; padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.admin-top .spacer { flex: 1; }
.currency-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.currency-switch button { border: 0; border-radius: 0; background: transparent; color: var(--muted); padding: .3rem .6rem; }
.currency-switch button.on { background: var(--surface-2); color: var(--text); font-weight: 600; }
.admin-denied { margin: 24px; }

/* Shell: menu + content */
.admin-shell { display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr); min-height: calc(100dvh - 57px); }
.admin-nav {
  display: flex; flex-direction: column; gap: 2px; padding: 16px 10px; border-right: 1px solid var(--border);
  background: var(--surface); position: sticky; top: 57px; align-self: start; height: calc(100dvh - 57px);
}
.admin-nav a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 12px; border-radius: 8px; color: var(--text); text-decoration: none; font-size: 14px;
}
.admin-nav a:hover { background: var(--surface-2); }
.admin-nav a.on { background: var(--surface-2); font-weight: 650; box-shadow: inset 3px 0 0 var(--brand); }
.admin-main { padding: 22px 28px 48px; max-width: 1180px; width: 100%; }

/* View heading */
.view-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.view-head h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.01em; }
.view-head p { margin: 0; max-width: 72ch; }
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; margin: 0 0 16px;
}
.panel.flush { padding: 0; overflow: hidden; }
.panel.flush .table-wrap { border: 0; border-radius: 0; margin: 0; max-height: none; }
.panel h2 { font-size: 15px; margin: 0 0 10px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.panel-head h2 { margin: 0; }
.split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.split .panel { margin: 0; }
.callout {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: 10px; padding: 10px 14px; margin: 0 0 16px;
}
.row-buttons { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.row-buttons .spacer { flex: 1; }

/* Date range bar */
.range-bar { display: flex; align-items: end; gap: 10px; flex-wrap: wrap; margin: 0 0 16px; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.range-bar label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.presets { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.presets button, .tabs button { background: transparent; border-color: var(--border); color: var(--muted); }
.presets button.on, .tabs button.on { background: var(--surface-2); color: var(--text); border-color: var(--border); font-weight: 600; }
.admin-main .tabs { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 14px; }

/* Figure tiles */
.tiles { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin: 0 0 16px; }
.tiles.compact { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1180px) { .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; min-width: 0; }
.tile .label { font-size: 13px; color: var(--muted); }
.tile .value { font-size: 26px; font-weight: 650; letter-spacing: -.01em; margin: 4px 0 2px; overflow-wrap: anywhere; }
.tile .sub { font-size: 12px; color: var(--muted); }
.tile .delta { font-size: 12px; color: var(--muted); margin-top: 6px; }
.tile .delta b { color: var(--text); font-weight: 600; }
.tile.hero .value { font-size: 30px; }
.tiles.compact .tile { padding: 10px 14px; }
.tiles.compact .tile .value { font-size: 20px; }

/* Legend, chart, tooltip */
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; }
.legend i.s1, .chart-tip i.s1 { background: var(--series-1); }
.legend i.s2, .chart-tip i.s2 { background: var(--series-2); }
.chart { position: relative; width: 100%; min-height: 220px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; outline: none; }
.chart svg:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 4px; border-radius: 6px; }
.chart .grid line { stroke: var(--border); stroke-width: 1; }
.chart .axis text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .s1 { fill: var(--series-1); }
.chart .s2 { fill: var(--series-2); }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .hover-band { fill: var(--surface-2); }
.chart-empty { display: grid; place-items: center; min-height: 200px; color: var(--muted); font-size: 14px; }
.chart-tip {
  position: fixed; z-index: 40; pointer-events: none; min-width: 170px; max-width: 260px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow); padding: 8px 10px; font-size: 13px;
}
.chart-tip .t { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.chart-tip .row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.chart-tip .row span { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.chart-tip .row b { font-variant-numeric: tabular-nums; }
.chart-tip i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; }
.chart-tip .total { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 6px; }

/* Ranked lists and tables */
.rank { list-style: none; margin: 0; padding: 0; }
.rank li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 7px 0; border-top: 1px solid var(--border); }
.rank li:first-child { border-top: 0; }
.rank .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank .amt { font-variant-numeric: tabular-nums; font-weight: 600; }
.rank .bar { grid-column: 1 / -1; height: 4px; background: var(--surface-2); border-radius: 2px; overflow: hidden; }
.rank .bar i { display: block; height: 100%; background: var(--series-1); border-radius: 2px; }
.rank .meta { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }
.share { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.share .bar { width: 64px; height: 4px; background: var(--surface-2); border-radius: 2px; overflow: hidden; }
.share .bar i { display: block; height: 100%; background: var(--series-1); }
.admin-main td.num, .admin-main th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.admin-main tfoot td { font-weight: 650; border-top: 2px solid var(--border); background: var(--surface-2); }
.admin-main .filters { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; margin: 0 0 14px; }
.admin-main .filters label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }

/* Phones and tablets: the menu becomes a scrollable tab bar */
@media (max-width: 820px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-nav {
    flex-direction: row; overflow-x: auto; position: sticky; top: 57px; z-index: 9; height: auto;
    padding: 6px 8px; border-right: 0; border-bottom: 1px solid var(--border); scrollbar-width: none;
  }
  .admin-nav a { white-space: nowrap; padding: 7px 10px; }
  .admin-nav a.on { box-shadow: inset 0 -2px 0 var(--brand); }
  .admin-main { padding: 16px 14px 40px; }
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .admin-top { padding: 8px 10px; gap: 8px; }
  .admin-top .brand-tag, .admin-top .ghost-link { display: none; }
  .tiles, .tiles.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .tile .value { font-size: 20px; }
  .tile.hero { grid-column: 1 / -1; }
  .tiles:not(.compact) .tile:last-child:nth-child(even) { grid-column: 1 / -1; }
  .tile.hero .value { font-size: 28px; }
  .range-bar label { flex: 1 1 130px; }
  .range-bar input { width: 100%; }
}

.prompt-group { font-size: 15px; margin: 6px 0 12px; padding-top: 4px; }
.prompt-group:not(:first-child) { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 8px; }

/* Business definitions */
.def-card { padding: 0; margin-bottom: 8px; }
.def-card > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 10px 14px; flex-wrap: wrap; }
.def-card > summary::-webkit-details-marker { display: none; }
.def-card > summary::before { content: "▸"; color: var(--muted); }
.def-card[open] > summary::before { content: "▾"; }
.def-snippet { max-width: 46ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.def-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; padding: 0 14px 14px; }
.def-grid label { display: grid; gap: 4px; }
.def-grid label.wide, .def-grid .def-actions { grid-column: 1 / -1; }
.def-grid textarea { resize: vertical; font: inherit; }
.def-actions { display: flex; justify-content: flex-end; }
.sticky-save { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0; z-index: 2; align-items: center; }
@media (max-width: 760px) { .def-grid { grid-template-columns: 1fr; } .def-snippet { display: none; } }
.def-grid .wide { grid-column: 1 / -1; }
.def-grid textarea[aria-label="SQL"] { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.def-actions { gap: 6px; }

/* Admin -> Users: working groups a user may see */
.group-list { max-height: 220px; overflow: auto; padding: 4px 0; }
.group-option { display: block; white-space: nowrap; }
.group-option input { width: auto; margin: 0 6px 0 0; vertical-align: middle; }
/* Admin -> Users: data access (platform switches + filters) */
.access { display: grid; gap: 8px; min-width: 260px; }
.access-platform { display: grid; gap: 2px; }
.access .platform { font-weight: 600; white-space: nowrap; }
.access .platform input { width: auto; margin: 0 6px 0 0; vertical-align: middle; }
.picker { margin-left: 22px; }
.group-search { margin: 4px 0; }
