/* Quant Data explorer · components shared by every view (see js/ui.js for the builders). */

/* ---- cards ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: var(--pad); min-width: 0; display: grid; gap: var(--gap); align-content: start; }
.card.narrow { max-width: 860px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px var(--gap); flex-wrap: wrap; }
.card-head > div:first-child:not(.figures) { display: grid; gap: 8px; min-width: 0; }
.card-head h2 { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.4; }
.card-head .sub { max-width: 72ch; }
.card-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); align-items: start; }
@media (max-width: 1100px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }

/* ---- text ---- */
.label { font: 500 11px/16px var(--mono); text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.sub { color: var(--muted); font-size: 13px; }
.meta { color: var(--muted); font: 12px var(--mono); overflow-wrap: anywhere; }
.meta:empty { display: none; }
.fineprint { color: var(--faint); font-size: 12px; line-height: 1.55; max-width: 110ch; }
.preview { color: var(--brand); overflow-wrap: anywhere; }
.req { color: var(--warn); margin-left: 3px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---- toolbar: labelled fields that wrap; actions stay together on the right, bottom-aligned with the controls ---- */
.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.toolbar-actions { display: flex; gap: 8px; margin-left: auto; }
.fld { display: grid; gap: 6px; min-width: 0; flex: none; }
.fld > span:first-child { font-size: 12px; font-weight: 500; color: var(--muted); line-height: 16px; white-space: nowrap; }
.fld > span:first-child i { font-style: normal; font-weight: 400; color: var(--faint); margin-left: 4px; }
.fld > input, .fld > select, .fld > textarea { width: 100%; }
.fld.w-xs { width: 112px; } .fld.w-sm { width: 156px; } .fld.w-md { width: 220px; } .fld.w-lg { width: 300px; }
.fld.grow { flex: 1 1 240px; }
.fld.wide { grid-column: 1 / -1; }
.fld-switch { height: var(--ctl); display: flex; align-items: center; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }

/* ---- controls: one height, one look ---- */
input, select, textarea { background: var(--field); color: var(--fg); border: 1px solid var(--field-border); border-radius: var(--r-ctl); padding: 0 12px; height: var(--ctl);
  font: 14px var(--font); font-variant-numeric: tabular-nums; min-width: 0; max-width: 100%; transition: border-color .15s, box-shadow .15s; }
textarea { height: auto; padding: 8px 12px; font: 13px/1.45 var(--mono); resize: vertical; }
/* the family chevron, the same in every app */
select { padding-right: 36px; text-overflow: ellipsis; -webkit-appearance: none; appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239aa0b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 16px; }
:root.light select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23565c74' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }
select option, select optgroup { background: var(--surface); color: var(--fg); }
input::placeholder, textarea::placeholder { color: var(--placeholder); opacity: 1; }
input:hover, select:hover, textarea:hover { border-color: var(--field-border-hover); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent); }
input[type=date] { color-scheme: inherit; }
input[type=number] { -moz-appearance: textfield; appearance: textfield; }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=checkbox] { accent-color: var(--brand); height: 15px; width: 15px; margin: 0; padding: 0; }

/* ---- buttons: pill, white primary that takes the brand colour on hover; busy shows a spinner, never greys out ---- */
button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: 500 14px/1 var(--font); height: var(--ctl); border-radius: 999px; padding: 0 16px;
  cursor: pointer; border: 1px solid var(--field-border); background: transparent; color: var(--fg); white-space: nowrap; transition: background-color .15s, border-color .15s, color .15s; }
button:hover { border-color: var(--field-border-hover); background: var(--surface-2); }
button.primary { background: var(--fg); color: var(--bg); border-color: var(--fg); }
button.primary:hover { background: var(--brand); border-color: var(--brand); color: var(--brand-fg); }
button.ghost { border-color: transparent; color: var(--muted); }
button.ghost:hover { color: var(--fg); background: var(--surface-2); }
button.small { height: var(--ctl-sm); padding: 0 12px; font-size: 13px; }
button.icon { height: 24px; width: 24px; padding: 0; border: 0; color: var(--faint); border-radius: 6px; }
button.icon:hover { color: var(--bad); background: transparent; }
button:disabled { cursor: not-allowed; opacity: .55; }
button[aria-busy=true] { cursor: progress; opacity: 1; }
button[aria-busy=true]::before { content: ""; width: 12px; height: 12px; border-radius: 50%; border: 2px solid currentColor; border-top-color: transparent; animation: spin .7s linear infinite; }

/* ---- feedback ---- */
@keyframes spin { to { transform: rotate(360deg); } }
.spin { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--muted); border-top-color: transparent; animation: spin .7s linear infinite; vertical-align: -1px; flex: none; }
.status { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; white-space: pre-line; color: var(--muted); }
.status .spin { margin-top: 3px; }
.status:empty { display: none; }
.status.err { color: var(--bad); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 1px 10px; border-radius: 999px; font: 500 12px/1.6 var(--mono); border: 1px solid currentColor;
  background: color-mix(in srgb, currentColor 10%, transparent); white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--ok); } .pill.warn { color: var(--warn); } .pill.bad { color: var(--bad); } .pill.off { color: var(--faint); }
.tag { display: inline-block; font: 500 11px/1.5 var(--mono); padding: 0 7px; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--muted); vertical-align: 1px; }
.up, .buy { color: var(--ok); } .down, .sell { color: var(--bad); } .other { color: var(--muted); }

/* ---- figures: labelled numbers above results ---- */
.figures { display: flex; flex-wrap: wrap; gap: 8px; }
.figures:empty { display: none; }
.figure { display: inline-grid; gap: 2px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--r-box); background: var(--surface-2); min-width: 96px; }
.figure-label { font: 500 11px/14px var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.figure b { font-size: 15px; font-weight: 600; color: var(--fg); font-variant-numeric: tabular-nums; white-space: nowrap; }
.figure.up b { color: var(--ok); } .figure.down b { color: var(--bad); }

/* ---- chips ---- */
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.chips:empty { display: none; }
.chips > .label { margin-right: 4px; }
.chip { font: 500 12.5px/1 var(--mono); height: 28px; padding: 0 11px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--fg);
  display: inline-flex; align-items: center; text-decoration: none; }
.chip:hover { border-color: var(--brand); color: var(--brand); background: var(--surface-2); }
.chip.on { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand); }

/* ---- segmented control ---- */
.seg { display: inline-flex; height: var(--ctl); border: 1px solid var(--field-border); border-radius: 999px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; height: 100%; padding: 0 12px; font: 500 13px var(--mono); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--fg); color: var(--bg); }

/* ---- switch ---- */
.switch { position: relative; display: inline-block; width: 36px; height: 20px; flex: none; vertical-align: middle; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line-strong); transition: background .15s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--fg); transition: transform .15s; }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(16px); background: var(--brand-fg); }
.switch input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---- search results ---- */
.results { display: grid; gap: 6px; max-height: 320px; overflow: auto; }
.results-state { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; padding: 4px 0; }
.results-state.err { color: var(--bad); }
.hit { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-box); background: var(--surface-2); }
.hit-title { font-size: 14px; overflow-wrap: anywhere; }
.hit-detail { grid-column: 1; font: 12px var(--mono); color: var(--muted); overflow-wrap: anywhere; }
.hit-actions { grid-column: 2; grid-row: 1 / span 2; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.hit.dim { opacity: .7; }
@media (max-width: 640px) { .hit { grid-template-columns: minmax(0, 1fr); } .hit-actions { grid-column: 1; grid-row: auto; justify-content: flex-start; } }

/* ---- tables ---- */
.scroll { overflow-x: auto; margin: 0 calc(-1 * var(--pad)); padding: 0 var(--pad); }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 0 10px 8px; border-bottom: 1px solid var(--line); font: 500 11px var(--mono); text-transform: uppercase; letter-spacing: .12em; color: var(--muted); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent); vertical-align: middle; font-size: 13.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
th:first-child, td:first-child { padding-left: 0; } th:last-child, td:last-child { padding-right: 0; }
tr:last-child td { border-bottom: 0; }
th.num, td.num { text-align: right; }
td.wrap { white-space: normal; min-width: 200px; }
td.clip { max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
tr.state td { color: var(--muted); padding: 24px 0; text-align: center; white-space: normal; }
tr.state.err td { color: var(--bad); }
.cell-actions { display: inline-flex; gap: 4px; }
dl.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 10px 20px; margin: 0; font-size: 13.5px; }
dl.kv dt { color: var(--muted); } dl.kv dd { margin: 0; overflow-wrap: anywhere; }

/* ---- disclosure ---- */
details.more > summary { cursor: pointer; color: var(--brand); font-size: 13px; width: fit-content; }
details.more[open] > summary { margin-bottom: 12px; }

/* ---- toast, theme toggle ---- */
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 10; background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: var(--r-box); padding: 10px 14px; font-size: 13.5px; box-shadow: 0 16px 48px -16px rgb(var(--shadow) / .45); }
.theme { display: inline-flex; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.theme button { height: 26px; width: 26px; padding: 0; border: 0; border-radius: 999px; color: var(--muted); }
.theme button:hover { color: var(--fg); background: transparent; }
.theme button[aria-checked=true] { background: var(--surface-2); color: var(--fg); }
.theme svg { width: 14px; height: 14px; }

/* ---- sign-in gate and the signed-in person ---- */
.gated .app { display: none; }
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; position: relative; isolation: isolate; }
.gate::before { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background-image: linear-gradient(to right, var(--grid-line) 1px, transparent 1px), linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
  background-size: 56px 56px; mask-image: radial-gradient(60% 50% at 50% 40%, #000 30%, transparent 75%); -webkit-mask-image: radial-gradient(60% 50% at 50% 40%, #000 30%, transparent 75%); }
.gate-card { width: min(440px, 100%); justify-items: start; gap: 12px; padding: 32px; box-shadow: 0 0 80px -20px color-mix(in srgb, var(--brand) 35%, transparent); }
.gate-card h1 { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.gate-brand .logo { width: 40px; height: 40px; }
.gate-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
a.button { display: inline-flex; align-items: center; justify-content: center; height: var(--ctl); padding: 0 16px; border-radius: 999px; font: 500 14px/1 var(--font);
  text-decoration: none; border: 1px solid var(--field-border); color: var(--fg); transition: background-color .15s, border-color .15s, color .15s; }
a.button.primary { background: var(--fg); color: var(--bg); border-color: var(--fg); }
a.button.primary:hover { background: var(--brand); border-color: var(--brand); color: var(--brand-fg); }
.who { gap: 8px; }
.who-email { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fg); font-size: 13px; }
.not-staff [data-staff] { display: none !important; }
/* Your keys: for people other than staff, once signed in (staff use the service's keys). */
body:not(.not-staff) [data-nonstaff] { display: none !important; }
