:root {
  --bg: #f3f3f0;
  --surface: #ffffff;
  --surface-soft: #f8f8f6;
  --ink: #171714;
  --ink-2: #55554e;
  --ink-3: #77776e;
  --line: #deded8;
  --line-strong: #c8c8c0;
  --accent: #d84026;
  --accent-hover: #b9321d;
  --accent-soft: #fbe9e4;
  --positive: #176b52;
  --positive-soft: #e7f4ef;
  --warning: #8c5b0a;
  --warning-soft: #fbf1d9;
  --danger: #b42318;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(23, 23, 20, .04), 0 14px 38px rgba(23, 23, 20, .06);
  --font: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body { margin: 0; min-width: 320px; min-height: 100dvh; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .48; }
button, input, select, a { touch-action: manipulation; }
:focus-visible { outline: 3px solid rgba(216, 64, 38, .32); outline-offset: 2px; }
.hidden { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; left: 16px; top: -80px; z-index: 1000; padding: 12px 16px; border-radius: 8px; background: var(--ink); color: white; text-decoration: none; }
.skip-link:focus { top: 16px; }
.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.brand-mark { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--accent); color: white; font-weight: 800; letter-spacing: -.04em; }
.eyebrow, .metric-id { margin: 0; color: var(--accent); font-size: 11px; line-height: 1.4; font-weight: 750; letter-spacing: .11em; text-transform: uppercase; }

.auth-shell { min-height: 100dvh; display: grid; grid-template-columns: minmax(280px, 1fr) minmax(420px, 560px); background: var(--ink); }
.auth-brand { padding: 36px 44px; display: flex; align-items: flex-start; gap: 11px; color: white; font-size: 18px; font-weight: 720; }
.auth-brand::after { content: "MATCH + PLACE + BODY + MOMENTS + HISTORY"; align-self: end; margin-left: auto; max-width: 470px; color: #8b8b82; font-size: clamp(42px, 6vw, 84px); font-weight: 760; line-height: .94; letter-spacing: -.055em; writing-mode: vertical-rl; transform: rotate(180deg); }
.auth-panel { min-height: 100dvh; padding: clamp(40px, 8vh, 100px) clamp(28px, 6vw, 72px); display: flex; flex-direction: column; justify-content: center; background: var(--surface); }
.auth-panel h1, .state-card h1 { margin: 12px 0 16px; font-size: clamp(32px, 4vw, 52px); line-height: 1.03; letter-spacing: -.045em; }
.auth-copy { max-width: 44ch; margin: 0 0 32px; color: var(--ink-2); font-size: 17px; }
.button { min-height: 46px; border: 1px solid transparent; border-radius: 10px; padding: 0 18px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; color: var(--ink); background: transparent; font-weight: 680; transition: background 160ms ease, border-color 160ms ease, color 160ms ease, box-shadow 160ms ease; }
.button-primary { background: var(--accent); color: white; }
.button-primary:hover { background: var(--accent-hover); }
.button-secondary, .button-google { border-color: var(--line-strong); background: var(--surface); }
.button-secondary:hover, .button-google:hover { border-color: var(--ink-2); background: var(--surface-soft); }
.button-google { width: 100%; }
.button-google .icon { stroke: none; }
.field { display: grid; gap: 7px; color: var(--ink-2); font-size: 12px; font-weight: 670; }
.field small { color: var(--ink-3); font-weight: 500; }
.field input, .field select { width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface); color: var(--ink); font-size: 14px; }
.field input:hover, .field select:hover { border-color: var(--ink-3); }
.field input:focus, .field select:focus { border-color: var(--accent); outline: 3px solid rgba(216,64,38,.12); }
.privacy-note { max-width: 50ch; margin: 24px 0 0; color: var(--ink-3); font-size: 12px; }
.form-error, .config-warning { padding: 12px 14px; border: 1px solid #efb7ad; border-radius: 9px; background: #fff1ee; color: var(--danger); font-size: 13px; }
.form-error { margin: 14px 0 0; }
.config-warning { margin: 0 0 20px; }

.state-shell { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.state-card { width: min(100%, 620px); padding: clamp(30px, 6vw, 56px); border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); }
.state-card p:not(.eyebrow) { margin: 0 0 26px; max-width: 54ch; color: var(--ink-2); }
.state-icon { display: grid; place-items: center; width: 52px; height: 52px; margin-bottom: 28px; border-radius: 14px; background: var(--warning-soft); color: var(--warning); }
.state-icon svg { width: 27px; fill: none; stroke: currentColor; stroke-width: 1.7; }

.app-shell { min-height: 100dvh; display: grid; grid-template-columns: 232px minmax(0,1fr); }
.sidebar { position: sticky; top: 0; height: 100dvh; padding: 24px 16px; display: flex; flex-direction: column; border-right: 1px solid #2d2d29; background: var(--ink); color: #d7d7d0; }
.sidebar-brand { padding: 0 10px 34px; display: flex; align-items: center; gap: 10px; color: white; font-size: 17px; font-weight: 740; }
.sidebar nav { display: grid; gap: 5px; }
.nav-item { min-height: 44px; padding: 0 12px; display: flex; align-items: center; gap: 11px; border-radius: 9px; color: #a7a79f; text-decoration: none; font-size: 14px; font-weight: 620; transition: background 160ms ease, color 160ms ease; }
.nav-item:hover { background: #242420; color: white; }
.nav-item.active { background: #30231f; color: #ff8e78; }
.sidebar-foot { margin-top: auto; padding: 14px 11px 0; display: flex; align-items: center; gap: 9px; border-top: 1px solid #31312d; color: #8f8f87; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #58c49b; box-shadow: 0 0 0 4px rgba(88,196,155,.12); }
main { min-width: 0; }
.topbar { min-height: 95px; padding: 20px clamp(20px, 4vw, 48px); display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); background: rgba(243,243,240,.92); backdrop-filter: blur(12px); }
.topbar h1 { margin: 3px 0 0; font-size: 25px; line-height: 1.2; letter-spacing: -.025em; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.role-badge, .source-pill, .future-pill { display: inline-flex; align-items: center; min-height: 24px; padding: 0 9px; border-radius: 999px; font-size: 10px; font-weight: 760; letter-spacing: .04em; text-transform: uppercase; }
.role-badge { background: var(--ink); color: white; }
.source-pill { background: var(--positive-soft); color: var(--positive); }
.future-pill { background: #ecece8; color: #686861; }
.icon-button { width: 44px; height: 44px; display: inline-grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); color: var(--ink-2); }
.icon-button:hover { border-color: var(--ink-2); color: var(--ink); }
.content { width: min(100%, 1460px); margin: 0 auto; padding: 28px clamp(16px, 4vw, 48px) 72px; }

.filter-panel { margin-bottom: 22px; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 1px 1px rgba(23,23,20,.02); }
.filter-heading, .card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.filter-heading { margin-bottom: 16px; }
.filter-heading h2, .card-head h2, .kpi h2 { margin: 0; color: var(--ink); font-size: 15px; letter-spacing: -.015em; }
.filter-heading p, .card-head p, .kpi p { margin: 3px 0 0; color: var(--ink-3); font-size: 12px; }
.text-button { min-height: 44px; border: 0; background: transparent; color: var(--accent); font-weight: 680; }
.text-button:hover { color: var(--accent-hover); }
.filter-grid { display: grid; grid-template-columns: repeat(4, minmax(130px,1fr)) minmax(190px,1.5fr) auto; align-items: end; gap: 12px; }
.apply-button { min-width: 108px; }

.loading-grid, .kpi-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 14px; }
.loading-grid span { height: 164px; border-radius: var(--radius); background: linear-gradient(100deg,#e6e6e1 20%,#f1f1ee 40%,#e6e6e1 60%); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; }
@keyframes shimmer { to { background-position-x: -200%; } }
.error-banner { margin-bottom: 20px; padding: 16px 18px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border: 1px solid #efb7ad; border-radius: var(--radius); background: #fff1ee; color: var(--danger); }
.error-banner p { margin: 2px 0 0; }
.dashboard { display: grid; gap: 16px; }
.kpi { min-height: 164px; padding: 19px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 1px 1px rgba(23,23,20,.02); }
.kpi-primary { border-top: 3px solid var(--accent); }
.kpi-muted { background: var(--surface-soft); }
.metric-label { margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--ink-3); font-size: 11px; font-weight: 720; letter-spacing: .06em; }
.kpi > strong { display: block; margin-bottom: 10px; font-size: clamp(30px, 3vw, 42px); line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -.045em; }
.data-card { padding: 21px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 1px 1px rgba(23,23,20,.02); }
.card-head { margin-bottom: 22px; }
.card-head h2 { margin-top: 4px; font-size: 18px; }
.card-head p:not(.metric-id) { max-width: 58ch; }
.button-export { min-height: 44px; flex: 0 0 auto; border-color: var(--line-strong); color: var(--ink-2); font-size: 13px; }
.button-export:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.export-compact { flex: 0 0 auto; }
.chart-wrap { height: 215px; display: flex; align-items: end; gap: clamp(3px, .8vw, 10px); padding: 18px 2px 8px; border-bottom: 1px solid var(--line); }
.chart-bar { position: relative; min-width: 6px; flex: 1 1 0; height: calc(var(--bar-height) * 1.8px); max-height: 180px; border-radius: 5px 5px 1px 1px; background: var(--accent); opacity: .78; transition: opacity 160ms ease; }
.chart-bar:hover, .chart-bar:focus { opacity: 1; }
.chart-bar::after { content: attr(data-value); position: absolute; left: 50%; bottom: calc(100% + 5px); transform: translateX(-50%); padding: 2px 5px; border-radius: 5px; background: var(--ink); color: white; font-size: 10px; opacity: 0; pointer-events: none; }
.chart-bar:hover::after, .chart-bar:focus::after { opacity: 1; }
.split-grid { display: grid; grid-template-columns: minmax(0,1.15fr) minmax(0,.85fr); gap: 16px; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--ink-3); font-size: 10px; letter-spacing: .07em; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
.number { text-align: right; font-variant-numeric: tabular-nums; }
.distribution { display: grid; gap: 9px; margin-bottom: 16px; }
.distribution-row { display: grid; grid-template-columns: minmax(90px,140px) 1fr auto; align-items: center; gap: 10px; color: var(--ink-2); font-size: 12px; }
.distribution-row > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.distribution-track { height: 7px; border-radius: 99px; overflow: hidden; background: #ecece8; }
.distribution-fill { height: 100%; width: var(--fill); border-radius: inherit; background: var(--accent); }
.empty-state { padding: 36px 16px; text-align: center; border: 1px dashed var(--line-strong); border-radius: 10px; background: var(--surface-soft); }
.empty-state p { margin: 5px 0 0; color: var(--ink-3); font-size: 13px; }
.catalog { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; }
.catalog-item { min-height: 92px; padding: 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); }
.catalog-item header { display: flex; justify-content: space-between; gap: 8px; }
.catalog-item strong { font-size: 12px; }
.catalog-item p { margin: 8px 0 0; color: var(--ink-3); font-size: 11px; }
.updated-at { color: var(--ink-3); font-size: 11px; white-space: nowrap; }
code { padding: 1px 4px; border-radius: 4px; background: #efefeb; font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 50; max-width: min(380px,calc(100vw - 32px)); padding: 13px 16px; border-radius: 10px; background: var(--ink); color: white; box-shadow: var(--shadow); font-size: 13px; }
.export-dialog { width: min(500px,calc(100vw - 28px)); padding: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--ink); box-shadow: 0 28px 80px rgba(23,23,20,.24); }
.export-dialog::backdrop { background: rgba(23,23,20,.48); backdrop-filter: blur(2px); }
.export-dialog form { padding: 28px; }
.export-dialog h2 { margin: 8px 0 10px; font-size: 24px; letter-spacing: -.03em; }
.export-dialog p:not(.eyebrow) { margin: 0; color: var(--ink-2); }
.dialog-actions { margin-top: 26px; display: flex; justify-content: flex-end; gap: 10px; }

@media (max-width: 1180px) {
  .filter-grid { grid-template-columns: repeat(3,minmax(140px,1fr)); }
  .wide { grid-column: span 2; }
  .catalog { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 76px minmax(0,1fr); }
  .sidebar { padding-inline: 10px; }
  .sidebar-brand { justify-content: center; padding-inline: 0; }
  .sidebar-brand > span:last-child, .nav-item span, .sidebar-foot span:last-child { display: none; }
  .nav-item { justify-content: center; padding: 0; }
  .sidebar-foot { justify-content: center; padding-inline: 0; }
  .kpi-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .split-grid { grid-template-columns: 1fr; }
  .auth-shell { grid-template-columns: 1fr; }
  .auth-brand { position: absolute; z-index: 1; padding: 22px 24px; color: var(--ink); }
  .auth-brand::after { display: none; }
}
@media (max-width: 680px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: 62px; padding: 10px 16px; flex-direction: row; align-items: center; border: 0; }
  .sidebar-brand { padding: 0; }
  .sidebar nav { margin-left: auto; display: flex; }
  .sidebar .nav-item { width: 44px; }
  .sidebar-foot { display: none; }
  .topbar { min-height: 82px; padding: 14px 16px; }
  .topbar h1 { font-size: 20px; }
  .content { padding: 18px 12px 48px; }
  .filter-grid { grid-template-columns: 1fr 1fr; }
  .filter-grid .field:nth-child(3), .operational-filter, .apply-button { grid-column: 1 / -1; }
  .wide { grid-column: 1 / -1; }
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi { min-height: 142px; }
  .data-card, .filter-panel { padding: 16px; }
  .card-head { align-items: flex-start; }
  .button-export { width: 44px; padding: 0; font-size: 0; }
  .button-export .icon { margin: 0; }
  .catalog { grid-template-columns: 1fr; }
  .sources-card .card-head { display: block; }
  .sources-card .updated-at { display: block; margin-top: 8px; white-space: normal; }
  .role-badge { display: none; }
  .auth-panel { padding-top: 100px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
