:root {
    --ink: #152238;
    --muted: #68758a;
    --line: #dbe2ec;
    --surface: #ffffff;
    --canvas: #f3f6fa;
    --navy: #10233f;
    --blue: #2764c7;
    --blue-dark: #194b9e;
    --cyan: #21a8bc;
    --orange: #ef7f32;
    --red: #c83a48;
    --green: #21855b;
    --yellow: #aa7110;
    --shadow: 0 14px 40px rgba(18, 38, 68, .09);
    --radius: 16px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); }
body { margin: 0; min-height: 100vh; color: var(--ink); background: radial-gradient(circle at 100% 0, #e7effb 0, transparent 32rem), var(--canvas); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 15px; line-height: 1.5; }
a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-dark); }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: .35rem; font-size: clamp(1.8rem, 4vw, 2.7rem); line-height: 1.1; letter-spacing: -.035em; }
h2 { margin-bottom: .3rem; font-size: 1.2rem; letter-spacing: -.015em; }
p { color: var(--muted); }
small { display: block; color: var(--muted); font-size: .78rem; }
code { overflow-wrap: anywhere; font: .77rem ui-monospace, SFMono-Regular, Menlo, monospace; color: #42516a; }

.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; min-height: 72px; padding: 0 clamp(1rem, 3vw, 2.5rem); color: #fff; background: rgba(16, 35, 63, .97); box-shadow: 0 8px 24px rgba(15, 33, 58, .18); backdrop-filter: blur(16px); }
.brand { display: flex; gap: .75rem; align-items: center; min-width: 235px; color: #fff; }
.brand:hover { color: #fff; }
.brand-mark { display: inline-grid; place-items: center; width: 46px; height: 34px; color: #fff; background: linear-gradient(135deg, var(--orange), #d95a30); border-radius: 7px 12px 7px 7px; font-weight: 900; font-style: italic; letter-spacing: -.08em; transform: skew(-5deg); box-shadow: 0 5px 14px rgba(239, 127, 50, .25); }
.brand strong { display: block; font-size: .95rem; letter-spacing: .015em; }
.brand small { color: #9db0cb; font-size: .68rem; text-transform: uppercase; letter-spacing: .13em; }
.main-nav { display: flex; align-self: stretch; align-items: center; gap: .1rem; }
.main-nav a { display: flex; align-items: center; height: 100%; padding: 0 .68rem; color: #c7d2e3; font-size: .87rem; border-bottom: 3px solid transparent; }
.main-nav a:hover { color: #fff; border-bottom-color: var(--orange); }
.account { display: flex; align-items: center; gap: .8rem; margin-left: auto; }
.account > a { color: #dbe4f2; font-size: .82rem; }
.account form { margin: 0; }
.nav-toggle { display: none; margin-left: auto; color: #fff; background: none; border: 0; font-size: 1.4rem; }

.page-shell { width: min(1500px, calc(100% - 2rem)); min-height: calc(100vh - 130px); margin: 0 auto; padding: clamp(1.5rem, 4vw, 3.25rem) 0 3rem; }
.login-shell { display: grid; min-height: 100vh; place-items: center; padding: 1.2rem; background: radial-gradient(circle at 15% 10%, rgba(39, 100, 199, .45), transparent 35rem), linear-gradient(135deg, #0c1b31, #18365c 68%, #10243f); }
.footer { display: flex; justify-content: space-between; gap: 1rem; padding: 1.2rem clamp(1rem, 3vw, 2.5rem); color: #778399; border-top: 1px solid var(--line); font-size: .75rem; }

.login-card { width: min(440px, 100%); padding: clamp(1.8rem, 5vw, 3rem); background: rgba(255, 255, 255, .98); border: 1px solid rgba(255,255,255,.2); border-radius: 24px; box-shadow: 0 34px 80px rgba(0, 0, 0, .28); }
.login-brand { display: flex; align-items: center; gap: 1rem; margin-bottom: 2.2rem; }
.login-brand h1 { margin: 0; font-size: 1.75rem; }
.login-brand p { margin: .15rem 0 0; font-size: .82rem; text-transform: uppercase; letter-spacing: .12em; }
.brand-mark-large { width: 68px; height: 50px; font-size: 1.25rem; }

.page-header, .report-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 1.5rem; margin-bottom: 1.8rem; }
.page-header p, .report-hero p { margin-bottom: 0; }
.eyebrow { margin-bottom: .4rem !important; color: var(--blue) !important; font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .16em; }
.header-actions { display: flex; flex-wrap: wrap; gap: .6rem; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 41px; padding: .62rem 1rem; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 9px; font: inherit; font-size: .88rem; font-weight: 700; cursor: pointer; transition: transform .15s, border-color .15s, background .15s; }
.button:hover { color: var(--ink); border-color: #afbdd1; transform: translateY(-1px); }
.button-primary { color: #fff; background: linear-gradient(135deg, var(--blue), var(--blue-dark)); border-color: var(--blue); box-shadow: 0 7px 16px rgba(39, 100, 199, .2); }
.button-primary:hover { color: #fff; background: var(--blue-dark); }
.button-accent { color: #fff; background: linear-gradient(135deg, var(--orange), #d96228); border-color: var(--orange); }
.button-accent:hover { color: #fff; }
.button-danger { color: var(--red); background: #fff7f7; border-color: #efbbc1; }
.button-ghost { background: transparent; }
.topbar .button-ghost { color: #dbe4f2; border-color: #48607f; }
.button-small { min-height: 32px; padding: .35rem .65rem; font-size: .77rem; }
.button-wide { width: 100%; margin-top: .35rem; }

.panel { background: var(--surface); border: 1px solid rgba(202, 212, 225, .85); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.35rem 1.45rem 1rem; }
.panel-head p { margin: 0; font-size: .85rem; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.4rem; }
.stat-card { position: relative; overflow: hidden; min-height: 145px; padding: 1.35rem; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.stat-card::after { position: absolute; right: -24px; bottom: -35px; width: 105px; height: 105px; content: ""; background: #e9f0fb; border-radius: 50%; }
.stat-card > span { display: block; color: var(--muted); font-size: .79rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.stat-card strong { display: block; margin: .3rem 0 .25rem; color: var(--navy); font-size: 2.4rem; line-height: 1; }
.stat-card a, .stat-card small { position: relative; z-index: 1; font-size: .78rem; }
.stat-card-alert::after { background: #fff0e8; }
.content-grid { display: grid; gap: 1.2rem; align-items: start; }
.content-grid.two-one { grid-template-columns: minmax(0, 2fr) minmax(290px, 1fr); }
.list-row { display: grid; grid-template-columns: minmax(165px, .8fr) 1.5fr auto; align-items: center; gap: 1rem; padding: 1rem 1.45rem; color: var(--ink); border-top: 1px solid #edf0f5; }
.list-row:hover { color: var(--ink); background: #f8faff; }
.list-row span > strong, .compact-list strong { display: block; }
.date-tile strong { font-size: .82rem; }
.chevron { color: #9eabc0; font-size: 1.5rem; }
.compact-list a { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .85rem 1.35rem; color: var(--ink); border-top: 1px solid #edf0f5; }
.empty-inline, .empty-cell { padding: 2.5rem 1.4rem !important; color: var(--muted); text-align: center; }

.table-panel { overflow: hidden; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: .78rem 1rem; color: #69778c; background: #f7f9fc; border-bottom: 1px solid var(--line); font-size: .69rem; text-align: left; text-transform: uppercase; letter-spacing: .08em; white-space: nowrap; }
td { padding: .9rem 1rem; border-bottom: 1px solid #e8edf3; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafcff; }
td strong { display: block; }
.muted-row { opacity: .58; }
.actions-cell { text-align: right; white-space: nowrap; }
.race-number { display: inline-grid; min-width: 38px; height: 34px; padding: 0 .35rem; place-items: center; color: #fff; background: var(--navy); border-radius: 6px; font-size: 1rem; font-style: italic; }
.tracker-pill { display: inline-block; padding: .25rem .55rem; color: #24517d; background: #e8f3fb; border: 1px solid #c7dfef; border-radius: 999px; font: 700 .78rem ui-monospace, monospace; }
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 28px; padding: .22rem .5rem; border-radius: 999px; font-size: .7rem; font-weight: 800; white-space: nowrap; }
.badge-ok { color: #166a46; background: #dff3e9; }
.badge-danger { color: #a42936; background: #fde5e7; }
.badge-warning { color: #885907; background: #fff0c9; }
.badge-info { color: #1d579d; background: #e4effd; }
.badge-muted { color: #68758a; background: #e9edf2; }

.form-panel { padding: clamp(1.2rem, 3vw, 2rem); }
.form-panel.narrow { max-width: 640px; }
.stack { display: grid; gap: 1.15rem; }
.form-grid { display: grid; gap: 1rem; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
label, legend { color: #34435a; font-size: .79rem; font-weight: 750; }
label > span { color: var(--muted); font-weight: 500; }
input, select, textarea { width: 100%; margin-top: .35rem; padding: .72rem .78rem; color: var(--ink); background: #fff; border: 1px solid #cbd5e2; border-radius: 8px; font: inherit; font-size: .9rem; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(39, 100, 199, .11); }
textarea { resize: vertical; }
fieldset { padding: 1rem; border: 1px solid var(--line); border-radius: 10px; }
legend { padding: 0 .35rem; }
.check-grid { display: flex; flex-wrap: wrap; gap: .65rem 1.2rem; }
.check { display: inline-flex; align-items: center; gap: .5rem; }
.check input { width: 18px; height: 18px; margin: 0; }
.form-actions { display: flex; gap: .7rem; padding-top: .4rem; }
.section-heading { display: flex; align-items: center; justify-content: space-between; margin-top: .6rem; }
.section-heading p { margin: 0; }
.notice { padding: .9rem 1rem; color: #6d520d; background: #fff8dd; border: 1px solid #ebd98e; border-radius: 9px; font-size: .84rem; }
.notice-info { color: #245075; background: #ebf5fb; border-color: #bddcea; }
.parameter-grid input { font-family: ui-monospace, monospace; font-weight: 700; }
.danger-zone { margin-top: 2rem; padding-top: 1.2rem; border-top: 1px dashed #e6c9cc; }
.operation-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 2rem; padding: 1.2rem; background: #fff5ec; border: 1px solid #f1d3bd; border-radius: 11px; }
.operation-row small { margin-top: .2rem; }

.report-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.report-card { display: flex; min-height: 245px; padding: 1.35rem; flex-direction: column; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.report-card:hover { color: var(--ink); border-color: #b8c8dc; transform: translateY(-2px); }
.report-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.4rem; color: var(--muted); font-size: .75rem; }
.report-card h2 { font-size: 1.35rem; }
.report-card p { font-size: .82rem; }
.report-card footer { margin-top: auto; padding-top: 1rem; color: var(--muted); border-top: 1px solid #edf0f4; font-size: .72rem; }
.mini-metrics { display: flex; gap: 1rem; margin: .7rem 0 1rem; }
.mini-metrics span { color: var(--muted); font-size: .69rem; }
.mini-metrics strong { display: block; color: var(--ink); font-size: 1.1rem; }
.report-hero { padding: clamp(1.4rem, 3vw, 2.2rem); color: #fff; background: linear-gradient(115deg, #10233f 0%, #1b426d 68%, #235d82 100%); border-radius: 18px; box-shadow: 0 18px 44px rgba(16, 35, 63, .2); }
.report-hero h1 { margin: 0 0 .45rem; }
.report-hero p { color: #c2d1e4; }
.report-hero .eyebrow { color: #68d3e0 !important; }
.report-hero .button { color: #fff; border-color: #6e86a4; }
.report-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: .8rem; margin: 1rem 0; }
.report-summary article { padding: 1.1rem 1.2rem; background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: 10px; }
.report-summary span { display: block; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; }
.report-summary strong { font-size: 1.8rem; }
.report-summary .summary-warning { border-left-color: #d89b2a; }
.report-summary .summary-danger { border-left-color: var(--red); }
.report-meta { display: grid; grid-template-columns: repeat(6, 1fr); overflow: hidden; margin-bottom: 1rem; }
.report-meta div { padding: 1rem; border-right: 1px solid var(--line); }
.report-meta div:last-child { border-right: 0; }
.report-meta span { display: block; color: var(--muted); font-size: .67rem; text-transform: uppercase; }
.report-meta strong { font-size: .88rem; }
.report-disclaimer { padding: .8rem 1rem; color: #526174; background: #e9eef5; border-radius: 8px; font-size: .76rem; }
.report-section { margin-top: 2rem; }
.count-ring { display: grid; width: 40px; height: 40px; place-items: center; color: #fff; background: var(--red); border-radius: 50%; font-weight: 900; }
.violation-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.violation-card { overflow: hidden; background: #fff; border: 1px solid #ebc8cc; border-radius: 13px; box-shadow: 0 10px 25px rgba(130, 34, 44, .07); }
.violation-number { padding: .8rem 1rem; color: #fff; background: linear-gradient(120deg, #af2e3b, #dc5260); font-size: 1.4rem; font-weight: 900; }
.violation-number small { color: #ffe5e8; font-weight: 500; }
.violation-card dl { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin: 0; padding: 1rem; }
.violation-card dt { color: var(--muted); font-size: .65rem; text-transform: uppercase; }
.violation-card dd { margin: 0; font-size: .82rem; font-weight: 750; }
.card-actions { display: flex; gap: 1rem; padding: .7rem 1rem; background: #fff7f8; font-size: .75rem; font-weight: 700; }
.clean-result { display: flex; align-items: center; gap: 1rem; margin: 2rem 0; padding: 1.2rem; color: #176a48; background: #e4f4ec; border: 1px solid #bde2d0; border-radius: 12px; }
.clean-result > span { display: grid; width: 42px; height: 42px; place-items: center; color: #fff; background: var(--green); border-radius: 50%; font-size: 1.3rem; }
.clean-result p { margin: .2rem 0 0; color: #4f7766; font-size: .8rem; }
.audit-strip { display: grid; grid-template-columns: 1fr 2fr 1fr; gap: 1px; overflow: hidden; margin-top: 1rem; background: var(--line); border: 1px solid var(--line); border-radius: 10px; }
.audit-strip div { padding: .8rem 1rem; background: #eef2f7; }
.audit-strip span { display: block; color: var(--muted); font-size: .63rem; text-transform: uppercase; }

.analysis-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: .8rem; margin-bottom: 1rem; }
.analysis-metrics article { padding: 1rem; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.analysis-metrics span { display: block; color: var(--muted); font-size: .7rem; text-transform: uppercase; }
.analysis-metrics strong { font-size: 1.3rem; }
.chart-panel { padding: 1.2rem; }
.chart-wrap { position: relative; width: 100%; min-height: 480px; }
.chart-wrap canvas { display: block; width: 100%; height: 480px; }
.chart-loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); background: rgba(255,255,255,.8); }
.chart-loading.hidden { display: none; }
.chart-legend { display: flex; gap: 1.2rem; margin-bottom: 1rem; color: var(--muted); font-size: .75rem; }
.chart-legend span::before { display: inline-block; width: 18px; height: 3px; margin-right: .4rem; content: ""; vertical-align: middle; background: var(--blue); }
.chart-legend .legend-integral::before { background: var(--cyan); }
.chart-legend .legend-event::before { height: 9px; background: var(--red); border-radius: 50%; }
.chart-help { margin: .7rem 0 0; font-size: .75rem; }

.tracker-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
.tracker-card { padding: 1.1rem; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 22px rgba(22, 46, 80, .06); }
.tracker-head { display: flex; align-items: center; justify-content: space-between; }
.tracker-card > p { min-height: 42px; margin: .8rem 0; font-size: .82rem; }
.tracker-card dl { display: grid; gap: .4rem; margin: 0; }
.tracker-card dl div { display: flex; justify-content: space-between; gap: 1rem; }
.tracker-card dt { color: var(--muted); font-size: .7rem; }
.tracker-card dd { margin: 0; font-size: .74rem; font-weight: 700; }
.status-dot { width: 11px; height: 11px; background: #aeb7c4; border-radius: 50%; box-shadow: 0 0 0 4px #edf0f4; }
.status-online { background: #27a872; box-shadow: 0 0 0 4px #d9f1e7; }
.status-stale { background: #d69a24; box-shadow: 0 0 0 4px #f9eac9; }
.class-list { display: grid; margin-bottom: 1.2rem; }
.class-list > div { display: flex; align-items: center; gap: .7rem; padding: .65rem 0; border-bottom: 1px solid var(--line); }
.class-list form { margin-left: auto; }
.color-dot { width: 12px; height: 12px; background: var(--blue); border-radius: 50%; }
.icon-button { display: grid; width: 27px; height: 27px; place-items: center; color: var(--red); background: #fff; border: 1px solid #e4c2c5; border-radius: 6px; cursor: pointer; }
.class-form { padding-top: 1rem; }
.flash { max-width: 900px; margin: 0 auto 1rem; padding: .85rem 1rem; border: 1px solid; border-radius: 9px; box-shadow: 0 6px 20px rgba(0,0,0,.05); }
.flash-success { color: #176844; background: #e4f4eb; border-color: #b9dfcb; }
.flash-error { color: #982c36; background: #fdebed; border-color: #efbdc2; }
.flash-warning { color: #775608; background: #fff5d7; border-color: #e9d496; }
.empty-state { max-width: 620px; margin: 10vh auto; padding: 3rem; text-align: center; background: #fff; border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.empty-code { display: block; color: #b8c1ce; font-size: 4rem; font-weight: 900; }

@media (max-width: 1180px) {
    .topbar { flex-wrap: wrap; }
    .brand { min-width: auto; }
    .nav-toggle { display: block; }
    .main-nav { display: none; width: 100%; order: 5; padding: .5rem 0 1rem; flex-wrap: wrap; }
    .main-nav.open { display: flex; }
    .main-nav a { height: 36px; }
    .account { margin-left: .8rem; }
    .stat-grid, .tracker-grid { grid-template-columns: repeat(2, 1fr); }
    .report-grid, .violation-grid { grid-template-columns: repeat(2, 1fr); }
    .report-meta { grid-template-columns: repeat(3, 1fr); }
    .report-meta div:nth-child(3) { border-right: 0; }
}

@media (max-width: 760px) {
    .page-shell { width: min(100% - 1rem, 1500px); padding-top: 1.2rem; }
    .page-header, .report-hero { align-items: flex-start; flex-direction: column; }
    .account > a { display: none; }
    .content-grid.two-one, .report-grid, .violation-grid { grid-template-columns: 1fr; }
    .stat-grid, .report-summary, .analysis-metrics { grid-template-columns: repeat(2, 1fr); }
    .form-grid.two, .form-grid.three { grid-template-columns: 1fr; }
    .report-meta { grid-template-columns: repeat(2, 1fr); }
    .report-meta div:nth-child(3) { border-right: 1px solid var(--line); }
    .report-meta div:nth-child(2n) { border-right: 0; }
    .audit-strip { grid-template-columns: 1fr; }
    .tracker-grid { grid-template-columns: 1fr; }
    .operation-row { align-items: stretch; flex-direction: column; }
    .footer { flex-direction: column; }
}

@media print {
    @page { size: A4 landscape; margin: 10mm; }
    body { color: #000; background: #fff; font-size: 10px; }
    .no-print, .topbar, .footer, .flash { display: none !important; }
    .page-shell { width: 100%; padding: 0; }
    .report-hero { padding: 12px 16px; color: #000; background: #fff; border: 2px solid #222; box-shadow: none; }
    .report-hero p, .report-hero .eyebrow { color: #333 !important; }
    .report-summary { gap: 4px; }
    .report-summary article, .panel, .violation-card { box-shadow: none; break-inside: avoid; }
    .report-section { margin-top: 14px; }
    .violation-grid { grid-template-columns: repeat(3, 1fr); gap: 5px; }
    .violation-number { color: #000; background: #eee; }
    th, td { padding: 5px 6px; }
    .audit-strip { break-inside: avoid; }
}
