:root {
  color-scheme: dark;
  --black: #000;
  --panel: #0a0a0a;
  --panel-2: #111;
  --line: #1a1a1a;
  --muted: #888;
  --text: #e5e5e5;
  --red: #d71920;
  --amber: #ff9500;
  --blue: #2e0fe4;
  --green: #22c55e;
  font-family: Inter, "Work Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; padding-top: 54px; background: var(--black); color: var(--text); min-height: 100vh; }
button, input, select, textarea { font: inherit; }
button, select, summary { cursor: pointer; }
[hidden] { display: none !important; }

.app-shell { min-height: calc(100vh - 54px); }
.topbar { position: fixed; z-index: 10; inset: 0 0 auto; min-height: 54px; display: flex; align-items: center; gap: 12px; padding: 4px 32px; border-bottom: 1px solid var(--line); background: rgba(0, 0, 0, .88); backdrop-filter: blur(16px); }
.brand { display: flex; align-items: center; gap: 9px; margin-right: 12px; text-decoration: none; font-size: 17px; font-weight: 800; letter-spacing: .05em; background: linear-gradient(135deg, var(--red), var(--amber)); background-clip: text; color: transparent; }
.brand img { width: 31px; height: 31px; object-fit: contain; }
.module-nav { display: flex; align-items: center; gap: 4px; }
.module-nav a, .module-nav button, .module-nav span { padding: 7px 14px; border: 0; border-radius: 6px; color: var(--muted); background: transparent; text-decoration: none; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.module-nav button:hover { color: var(--text); }
.module-nav .active { color: var(--red); background: rgba(215, 25, 32, .12); }
.module-nav span { color: #555; }
.event-switcher { display: flex; gap: 6px; align-items: center; margin-left: auto; }
.event-switcher select { max-width: 280px; padding: 6px 10px; font-size: 12px; background: rgba(255,255,255,.06); border-color: var(--line); }
.user-block { display: flex; align-items: center; gap: 10px; margin-left: 10px; font-size: 12px; color: var(--muted); }
.main { width: min(1440px, 100%); min-width: 0; margin: 0 auto; padding: 32px; overflow: hidden; }
.empty-state { min-height: 70vh; display: grid; place-content: center; text-align: center; }
.empty-state h1 { font-size: 52px; margin: 8px 0; }
.empty-state p:last-child { color: var(--muted); }
.access-workspace { min-height: 70vh; display: grid; align-content: center; justify-items: center; text-align: center; }
.access-workspace > h1 { margin: 6px 0; font-size: clamp(32px, 5vw, 56px); text-transform: uppercase; background: linear-gradient(135deg, var(--red), var(--amber)); background-clip: text; color: transparent; }
.access-panel { width: min(680px, 100%); margin-top: 28px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 18px; text-align: left; }
.access-panel p { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.access-lock { display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid rgba(215,25,32,.45); border-radius: 50%; color: var(--red); font-size: 24px; transform: rotate(45deg); }
.event-hero { display: flex; justify-content: space-between; align-items: end; margin-bottom: 25px; }
.event-hero h1 { font-size: clamp(30px, 4vw, 48px); letter-spacing: .02em; margin: 5px 0; text-transform: uppercase; background: linear-gradient(135deg, var(--red), var(--amber)); background-clip: text; color: transparent; }
.eyebrow { color: var(--red); font-size: 10px; font-weight: 900; letter-spacing: .2em; margin: 0 0 7px; }
.muted { color: var(--muted); }

.dataset-tabs { display: flex; gap: 7px; overflow-x: auto; margin-bottom: 18px; padding-bottom: 2px; }
.dataset-tab { white-space: nowrap; color: var(--muted); background: #090909; border: 1px solid var(--line); border-radius: 6px; padding: 9px 15px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.dataset-tab.active { color: var(--text); border-color: var(--red); background: #1b0708; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.kpi-grid article { min-height: 130px; padding: 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.kpi-grid span { display: block; color: var(--muted); font-size: 9px; font-weight: 900; letter-spacing: .18em; }
.kpi-grid strong { display: block; margin: 13px 0 7px; color: var(--red); font-size: 30px; letter-spacing: -.04em; }
.kpi-grid small { color: #6f6f74; }
.kpi-grid .receipt-card { border-color: #342600; background: linear-gradient(145deg, #181003, #080603); }
.receipt-card strong { color: var(--amber); font-size: 20px; }
.receipt-card small { display: block; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }

.panel { border: 1px solid var(--line); border-radius: 16px; background: var(--panel); padding: 28px 32px; box-shadow: 0 25px 50px rgba(0,0,0,.5); }
.panel h2 { margin: 3px 0 0; color: var(--red); font-size: 14px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.panel-title-row { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.controls-panel { margin-bottom: 12px; }
.action-row, .query-controls, .chart-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.button { border: 1px solid #333; border-radius: 10px; padding: 11px 18px; color: var(--text); background: #171717; font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; transition: opacity .15s, transform .15s; }
.button:hover { border-color: var(--red); opacity: .9; transform: translateY(-1px); }
.button.primary { color: #fff; background: linear-gradient(135deg, var(--red), var(--amber)); border-color: transparent; }
.button.amber { color: #fff; background: linear-gradient(135deg, var(--red), var(--amber)); border-color: transparent; }
.button.ghost { background: transparent; }
.button:disabled { opacity: .35; cursor: not-allowed; }
.button.full { width: 100%; margin-top: 8px; }
.text-button, .icon-button { border: 0; background: transparent; color: var(--muted); padding: 5px; }
.text-button:hover, .text-button.accent { color: var(--red); }
.icon-button { display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid #333; border-radius: 8px; color: var(--text); font-size: 18px; }

select, input, textarea { border: 1px solid #333; border-radius: 10px; background: #111; color: var(--text); padding: 10px 12px; outline: none; }
select:focus, input:focus, textarea:focus { border-color: var(--red); box-shadow: 0 0 0 2px rgba(215, 25, 32, .15); }
label { display: grid; gap: 7px; color: var(--muted); font-size: 11px; }
.filter-list { display: grid; gap: 8px; margin: 18px 0 10px; }
.filter-row { display: grid; grid-template-columns: minmax(140px, 1fr) 150px minmax(180px, 2fr) 30px; gap: 8px; }
.filter-row .remove-filter { color: var(--muted); background: transparent; border: 1px solid #303030; border-radius: 4px; }
.query-controls { border-top: 1px solid var(--line); padding-top: 13px; }
.query-controls > .button:last-child { margin-left: auto; }
.column-picker { position: relative; }
.column-picker summary { list-style: none; border: 1px solid #333; border-radius: 10px; padding: 10px 12px; color: var(--muted); }
.column-options { position: absolute; z-index: 4; top: 44px; right: 0; width: 260px; max-height: 330px; overflow: auto; padding: 12px; border: 1px solid #363636; border-radius: 10px; background: #080808; box-shadow: 0 20px 45px #000; }
.column-options label { display: flex; align-items: center; gap: 9px; padding: 6px; }

.content-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(280px, .8fr); gap: 12px; margin-bottom: 12px; }
.chart-controls { margin: 17px 0 8px; }
.chart { min-height: 330px; display: grid; place-items: center; overflow: hidden; }
.chart svg { width: 100%; max-height: 330px; }
.axis-label { fill: #777; font-size: 10px; }
.value-label { fill: #eee; font-size: 10px; font-weight: 700; }
.legend-label { font-size: 12px; font-weight: 700; }
.donut-total { fill: #fff; font-size: 28px; font-weight: 900; }
.chart-empty { color: var(--muted); }
.field-quality { margin-top: 18px; display: grid; gap: 12px; max-height: 376px; overflow: auto; padding-right: 5px; }
.quality-item { display: grid; grid-template-columns: 1fr auto; gap: 7px; font-size: 11px; }
.quality-item small { color: var(--muted); }
.quality-bar { grid-column: 1 / -1; width: 100%; height: 4px; border: 0; appearance: none; background: #222; }
.quality-bar::-webkit-progress-bar { background: #222; }
.quality-bar::-webkit-progress-value { background: linear-gradient(90deg, var(--blue), var(--green)); }
.quality-bar::-moz-progress-bar { background: linear-gradient(90deg, var(--blue), var(--green)); }

.table-panel { padding: 0; overflow: hidden; }
.table-panel .panel-title-row { padding: 22px; }
.count-pill { padding: 6px 10px; border-radius: 99px; background: #1d1d1d; color: var(--muted); font-size: 11px; }
.table-wrap { overflow: auto; max-height: 620px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: 11px; }
th { position: sticky; top: 0; z-index: 2; text-align: left; padding: 11px 13px; color: var(--muted); background: #111; border-bottom: 1px solid #333; white-space: nowrap; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
td { max-width: 330px; padding: 10px 13px; border-bottom: 1px solid #191919; color: #c7c7cb; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
tr:hover td { background: rgba(215,25,32,.04); color: #fff; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 14px; color: var(--muted); font-size: 11px; }
.no-dataset { text-align: center; padding: 70px; }

dialog { width: min(520px, calc(100vw - 30px)); padding: 0; color: var(--text); background: #090909; border: 1px solid #383838; border-radius: 16px; box-shadow: 0 30px 100px #000; }
.wide-dialog { width: min(980px, calc(100vw - 30px)); }
dialog::backdrop { background: rgba(0, 0, 0, .78); backdrop-filter: blur(5px); }
dialog form { display: grid; gap: 15px; padding: 24px; }
.dialog-heading { display: flex; justify-content: space-between; align-items: start; margin-bottom: 5px; }
.dialog-heading h2 { margin: 0; font-size: 28px; }
.two-column { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
textarea { min-height: 90px; resize: vertical; }
.file-drop { padding: 18px; border: 1px dashed #4a4a4a; background: #101010; }
.dialog-note { margin: 0; color: #a78b56; font-size: 11px; line-height: 1.5; }
.access-request-list { display: grid; gap: 9px; }
.access-request { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 13px; border: 1px solid var(--line); border-radius: 10px; background: #101010; }
.access-request b, .access-request small { display: block; overflow: hidden; text-overflow: ellipsis; }
.access-request small { margin-top: 4px; color: var(--muted); }
.access-request .action-row { flex-wrap: nowrap; }
.access-request-empty { padding: 28px; color: var(--muted); text-align: center; }
.marketplace-note { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.report-template-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; max-height: 65vh; overflow: auto; }
.report-card { display: grid; align-content: start; gap: 10px; min-width: 0; padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: #101010; }
.report-card h3 { margin: 0; color: var(--text); font-size: 17px; }
.report-card p { margin: 0; min-height: 34px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.report-card-meta, .report-slots { display: flex; flex-wrap: wrap; gap: 6px; }
.report-card-meta span, .report-slots span { padding: 4px 7px; border-radius: 99px; background: #1d1d1d; color: #aaa; font-size: 9px; letter-spacing: .04em; }
.report-card-meta .published { color: var(--green); }
.report-card-meta .draft { color: var(--amber); }
.report-card .action-row { align-self: end; margin-top: auto; }
.report-field-mappings, .report-filter-parameters { display: grid; gap: 9px; }
.report-field-mappings label { grid-template-columns: minmax(120px, 1fr) minmax(180px, 1.4fr); align-items: center; }
.report-filter-parameters:empty { display: none; }
.report-filter-parameters:not(:empty) { padding-top: 14px; border-top: 1px solid var(--line); }
.toast { position: fixed; z-index: 20; right: 22px; bottom: 22px; max-width: 460px; padding: 13px 16px; border-left: 3px solid var(--green); background: #121212; color: #eee; box-shadow: 0 12px 50px #000; transform: translateY(120px); opacity: 0; transition: .2s ease; font-size: 12px; }
.toast.visible { transform: translateY(0); opacity: 1; }
.toast.error { border-color: var(--red); }

.login-screen { min-height: calc(100vh - 54px); display: grid; place-items: center; background: radial-gradient(circle at 50% 35%, rgba(215,25,32,.12), #000 42%); }
.login-card { width: min(440px, calc(100vw - 35px)); text-align: center; padding: 55px 42px; border: 1px solid var(--line); border-radius: 16px; background: rgba(10, 10, 10, .94); box-shadow: 0 25px 50px rgba(0,0,0,.5); }
.login-logo { width: 150px; height: auto; margin: 0 auto 25px; }
.login-card h1 { margin: 7px 0 12px; font-size: 42px; }
.login-card h1 span { color: var(--red); }
.login-card > .button { margin-top: 16px; }
.dev-login { display: grid; gap: 9px; margin-top: 24px; padding-top: 20px; border-top: 1px solid #252525; }
.dev-login span { color: var(--amber); font-size: 9px; font-weight: 900; letter-spacing: .15em; }

@media (max-width: 1050px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .content-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .topbar { padding: 0 14px; }
  .module-nav, .user-block span { display: none; }
  .brand span { font-size: 13px; }
  .event-switcher select { max-width: 145px; }
  .main { padding: 20px 12px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .filter-row { grid-template-columns: 1fr 1fr 30px; }
  .filter-row input { grid-column: 1 / 3; grid-row: 2; }
  .filter-row .remove-filter { grid-column: 3; grid-row: 1 / 3; }
  .panel-title-row, .event-hero { align-items: start; flex-direction: column; }
  .action-row { width: 100%; }
  .access-panel { grid-template-columns: auto 1fr; }
  .access-panel .button { grid-column: 1 / -1; }
  .report-template-list { grid-template-columns: 1fr; }
}
