/* EZKALAR Intelligence — calm, dense, institutional. */
:root {
  --paper: #f5f4ef; --panel: #ffffff; --ink: #121a22; --ink-2: #3b4652; --muted: #66707b;
  --line: #dfddd5; --line-2: #ecebe5; --accent: #1d3f5e; --accent-soft: #e6edf3;
  --up: #17734a; --down: #b03a2e;
  --st-verified: #17734a; --st-verified-bg: #e3f1ea; --st-sourced: #1d4f86; --st-sourced-bg: #e5edf7;
  --st-estimated: #8a5a00; --st-estimated-bg: #f7eedb; --st-unverified: #6b4b4b; --st-unverified-bg: #f0e8e6;
  --demo: #7a4b00; --demo-bg: #fbf1dc; --demo-line: #e9cf96;
  --radius: 6px; --sans: 'IBM Plex Sans', system-ui, sans-serif; --mono: 'IBM Plex Mono', ui-monospace, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0f141a; --panel: #161d25; --ink: #e8ecf0; --ink-2: #c3cad2; --muted: #8e99a5;
    --line: #2a333d; --line-2: #212932; --accent: #9cc2e6; --accent-soft: #1d2a37;
    --up: #5cc495; --down: #ee8577;
    --st-verified: #7dd3a8; --st-verified-bg: #16302a; --st-sourced: #9cc2e6; --st-sourced-bg: #1a2a3b;
    --st-estimated: #e6bf6e; --st-estimated-bg: #33291a; --st-unverified: #d6b3ad; --st-unverified-bg: #33242a;
    --demo: #f0c879; --demo-bg: #2d2416; --demo-line: #5a4523;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.5 var(--sans); font-feature-settings: 'tnum' 1; }
h1, h2, h3, p { margin: 0; }
a { color: var(--accent); text-underline-offset: 3px; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mono { font-family: var(--mono); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 16px; top: -48px; background: var(--panel); padding: 8px 12px; border: 1px solid var(--line); z-index: 10; }
.skip-link:focus { top: 8px; }

.topbar { display: flex; align-items: center; gap: 32px; padding: 0 max(16px, calc((100vw - 1200px) / 2)); height: 56px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: .08em; color: var(--ink); text-decoration: none; font-size: 14px; }
.brand span:not(.brand-mark) { font-weight: 400; letter-spacing: .02em; color: var(--muted); }
.brand-mark { width: 14px; height: 14px; background: var(--accent); clip-path: polygon(0 100%, 100% 0, 100% 100%); }
.topbar nav { display: flex; gap: 4px; overflow-x: auto; }
.topbar nav a { padding: 6px 10px; border-radius: var(--radius); color: var(--ink-2); text-decoration: none; font-size: 14px; white-space: nowrap; }
.topbar nav a:hover { background: var(--line-2); }
.topbar nav a[aria-current="page"] { color: var(--ink); background: var(--accent-soft); font-weight: 500; }

.demo-banner { background: var(--demo-bg); color: var(--demo); border-bottom: 1px solid var(--demo-line); padding: 8px max(16px, calc((100vw - 1200px) / 2)); font-size: 13px; }
.demo-tag { display: inline-block; vertical-align: 2px; font: 600 10px/1 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--demo); background: var(--demo-bg); border: 1px solid var(--demo-line); padding: 3px 5px; border-radius: 3px; }

main { max-width: 1200px; margin: 0 auto; padding: 32px 16px 48px; outline: none; }
.footer { max-width: 1200px; margin: 0 auto; padding: 24px 16px 40px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; display: grid; gap: 4px; }

.eyebrow { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 500; margin-bottom: 6px; }
.page-head { margin-bottom: 24px; max-width: 760px; }
.page-head h1 { font-size: 28px; line-height: 1.2; font-weight: 600; letter-spacing: -.01em; }
.lede { color: var(--ink-2); margin-top: 8px; }
.sub { display: block; color: var(--muted); font-size: 13px; }
.unknown { color: var(--muted); font-style: italic; }
.delta { font-family: var(--mono); font-weight: 500; }
.delta.up { color: var(--up); }
.delta.down { color: var(--down); }

.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; padding: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; }
.field { display: grid; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 500; }
.field.grow { flex: 1 1 260px; }
.field input, .field select { height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); font-size: 15px; min-width: 0; }
.field select { min-width: 200px; }

.count { color: var(--muted); font-size: 13px; margin: 0 0 8px; }
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line-2); vertical-align: top; font-weight: 400; }
thead th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 500; background: var(--panel); white-space: nowrap; }
tbody tr:last-child > * { border-bottom: 0; }
.num { text-align: right; }
.figures tbody tr:hover { background: var(--line-2); }
.person { display: flex; gap: 12px; align-items: center; color: inherit; text-decoration: none; }
.person .name { font-weight: 600; }
.person:hover .name { color: var(--accent); text-decoration: underline; }
.avatar { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font: 600 13px var(--sans); letter-spacing: .04em; }
.avatar.large { width: 64px; height: 64px; font-size: 20px; }

.status { display: inline-block; font-size: 11px; font-weight: 500; padding: 1px 6px; border-radius: 3px; white-space: nowrap; }
.status-verified { color: var(--st-verified); background: var(--st-verified-bg); }
.status-sourced { color: var(--st-sourced); background: var(--st-sourced-bg); }
.status-estimated { color: var(--st-estimated); background: var(--st-estimated-bg); }
.status-unverified { color: var(--st-unverified); background: var(--st-unverified-bg); }
.fresh { font-size: 12px; }
.fresh::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; background: var(--muted); }
.fresh-fresh::before { background: var(--up); }
.fresh-aging::before { background: var(--st-estimated); }
.fresh-stale::before { background: var(--down); }

.button { display: inline-flex; align-items: center; height: 36px; padding: 0 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--ink); text-decoration: none; cursor: pointer; font-size: 14px; }
.button:hover:not(:disabled) { border-color: var(--accent); }
.button:disabled { opacity: .45; cursor: not-allowed; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin-top: 16px; color: var(--muted); font-size: 14px; }

.state { padding: 48px 24px; text-align: center; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink-2); display: grid; gap: 10px; justify-items: center; }
.state h2 { font-size: 18px; font-weight: 600; color: var(--ink); }
.state.compact { padding: 24px; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

.back { display: inline-block; font-size: 14px; margin-bottom: 20px; text-decoration: none; }
.profile-head { display: flex; gap: 20px; align-items: flex-start; margin-bottom: 24px; }
.profile-head h1 { font-size: 30px; line-height: 1.15; font-weight: 600; }
.identity { color: var(--ink-2); margin-top: 4px; }
.summary { margin-top: 12px; max-width: 760px; }
.links { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.links li { font-size: 13px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); display: flex; gap: 6px; align-items: baseline; }
.links .sub { display: inline; }

.key-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 24px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 6px; align-content: start; }
.panel-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 500; }
.big { font-size: 28px; font-weight: 500; line-height: 1.2; }
.status-mix { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; }

.profile-body { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
.block { margin-bottom: 28px; }
.block > h2 { font-size: 16px; font-weight: 600; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.col-side .block { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.col-side .block > h2 { font-size: 14px; }
.series { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.series header { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.series h3 { font-size: 15px; font-weight: 600; margin-right: auto; }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.pill.muted { background: var(--line-2); color: var(--muted); }
.series details { margin-top: 8px; }
.series summary { cursor: pointer; font-size: 13px; color: var(--ink-2); padding: 4px 0; }
.series .table-wrap { border: 0; margin-top: 4px; }
.points th, .points td { padding: 8px 10px; font-size: 13px; }

.chart { margin: 0; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line-2); stroke-width: 1; }
.chart .tick { fill: var(--muted); font: 11px var(--mono); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; }
.chart .dot { stroke: var(--accent); stroke-width: 2; }
.chart .dot.solid { fill: var(--accent); }
.chart .dot.hollow { fill: var(--panel); }
.chart figcaption { margin-top: 4px; font-size: 12px; }

.timeline { list-style: none; padding: 0; margin: 0; display: grid; gap: 0; }
.timeline li { display: grid; grid-template-columns: 150px 1fr; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line-2); }
.timeline time { color: var(--muted); font: 13px var(--mono); padding-top: 1px; }
.timeline li > div { display: grid; gap: 3px; }
.feed { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 16px; }
.feed li:last-child { border-bottom: 0; }
.kind { font-size: 11px; color: var(--muted); border: 1px solid var(--line); padding: 0 6px; border-radius: 3px; }
.checks { list-style: none; padding: 0; margin: 0 0 8px; display: grid; gap: 6px; font-size: 14px; }
.checks li { display: flex; gap: 8px; }
.checks .ok span:first-child { color: var(--up); }
.checks .missing { color: var(--muted); }
.sources { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; font-size: 14px; }
.method-note p { font-size: 14px; margin-bottom: 8px; color: var(--ink-2); }

.prose { max-width: 760px; }
.prose h2 { font-size: 18px; font-weight: 600; margin: 28px 0 8px; }
.prose p { margin-bottom: 10px; color: var(--ink-2); }

/* Account */
.account { margin-left: auto; display: flex; align-items: center; }
.account-link { font-size: 14px; color: var(--ink-2); text-decoration: none; padding: 6px 10px; border-radius: var(--radius); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-link:hover, .account-link.current { background: var(--accent-soft); color: var(--ink); }
.button.small { height: 30px; padding: 0 10px; font-size: 13px; }
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--panel); font-weight: 500; }
.button.primary:hover:not(:disabled) { filter: brightness(1.1); }
.button.danger { color: var(--down); border-color: var(--down); }
.auth-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; max-width: 860px; }
.form { display: grid; gap: 12px; align-content: start; }
.form h2, .form h3 { font-size: 15px; font-weight: 600; }
.panel.danger { border-color: color-mix(in srgb, var(--down) 40%, var(--line)); }
.field em { font-style: normal; font-weight: 400; color: var(--muted); }
.field textarea { padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); font: inherit; font-size: 15px; resize: vertical; }
.form-error { color: var(--down); font-size: 14px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--ink-2); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: var(--radius); font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 20; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Admin */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: -12px 0 20px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs a { padding: 8px 12px; text-decoration: none; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 500; }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-bottom: 12px; }
.toolbar .check { height: 38px; }
.admin-title { font-size: 24px; font-weight: 600; margin-bottom: 2px; }
.admin-table th[scope="row"] { font-weight: 400; }
.admin-table th[scope="row"] a { text-decoration: none; }
.fig-status { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.fig-published { background: var(--st-verified-bg); color: var(--st-verified); }
.fig-draft { background: var(--st-estimated-bg); color: var(--st-estimated); }
.issues { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.issues li { font-size: 12px; padding: 1px 6px; border-radius: 3px; background: var(--line-2); color: var(--ink-2); }
.admin-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; margin-top: 16px; }
.grid-form { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 24px; }
.grid-form .wide { grid-column: 1 / -1; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.form-actions .form-error { flex-basis: 100%; }
.add-form { margin-top: 12px; background: var(--paper); border-style: dashed; }
.col-side .add-form { padding-top: 12px; border-top: 1px dashed var(--line); }
.sub.inline { display: inline; font-weight: 400; margin-left: 6px; }
.admin-rows { list-style: none; padding: 0; margin: 0; display: grid; }
.admin-rows li { display: flex; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line-2); }
.admin-rows li > div { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.admin-rows.compact li { font-size: 14px; }
.icon-button { flex: none; width: 28px; height: 28px; border: 1px solid transparent; border-radius: var(--radius); background: none; color: var(--muted); cursor: pointer; }
.icon-button:hover { border-color: var(--down); color: var(--down); }
select.inline { height: 28px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); font-size: 13px; padding: 0 4px; }
.inline-input { width: 100%; min-width: 100px; height: 32px; padding: 0 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); font-size: 14px; }
.row-actions { white-space: nowrap; }
.row-actions form { display: inline; }
.row-actions .form-error { display: block; white-space: normal; font-size: 12px; }
.history { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; font-size: 13px; color: var(--ink-2); max-height: 320px; overflow: auto; }
.history .sub { display: inline; margin-right: 4px; }

@media (max-width: 900px) {
  .admin-layout { grid-template-columns: 1fr; }
  .profile-body { grid-template-columns: 1fr; }
  .key-grid { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
  .topbar { gap: 12px; }
  .brand span:not(.brand-mark) { display: none; }
  .topbar nav a { padding: 6px 7px; font-size: 13px; }
  main { padding-top: 24px; }
  .page-head h1 { font-size: 23px; }
  .filters { padding: 12px; }
  .field, .field select { flex: 1 1 100%; min-width: 0; }
  .figures thead { display: none; }
  .figures, .figures tbody, .figures tr, .figures th, .figures td { display: block; width: 100%; }
  .figures tr { padding: 12px 14px; border-bottom: 1px solid var(--line-2); display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
  .figures th, .figures td { padding: 0; border: 0; text-align: left; }
  .figures th { grid-column: 1 / -1; }
  .figures td::before { content: attr(data-label); display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
  .profile-head { flex-direction: column; gap: 12px; }
  .profile-head h1 { font-size: 24px; }
  .timeline li { grid-template-columns: 1fr; gap: 2px; }
  .grid-form { grid-template-columns: 1fr; }
  .account-link { max-width: 90px; }
}
