@font-face {
    font-family: Inter;
    src: url('assets/inter.woff2') format('woff2');
    font-weight: 100 900;
    font-display: swap;
}

@font-face {
    font-family: Montserrat;
    src: url('assets/montserrat.woff2') format('woff2');
    font-weight: 100 900;
    font-display: swap;
}

:root {
    color-scheme: light;
    --bg-color: #d9cebc;
    --surface: #f0e7d7;
    --plot: #e6dece;
    --control-bg: #e7dcc8;
    --control-hover: #e0d3c6;
    --selected: #ddd0eb;
    --line: #c6b79f;
    --strong-line: #a99ab5;
    --text: #202941;
    --text-muted: #4a5771;
    --accent: #075c86;
    --good: #12694f;
    --good-bg: #e6f3ea;
    --bad: #9b2d3b;
    --bad-bg: #f9eaec;
    --chart-grid: #bfb9ad;
    --chart-grid-3d: #a8a3ac;
    --chart-selection: rgba(7, 92, 134, .14);
    --lane-smoke: #126a91;
    --lane-regression: #6841ad;
    --lane-conversion: #087b71;
    --panel-shadow: 0 5px 16px #3a2c1711;
    --active-accent: #4d2a83;
}

[data-theme="dark"] {
    color-scheme: dark;
    --bg-color: #0a1022;
    --surface: #131d35;
    --plot: #0e1830;
    --control-bg: #192640;
    --control-hover: #273756;
    --selected: #30244e;
    --line: #303f60;
    --strong-line: #554f79;
    --text: #f5f6ff;
    --text-muted: #acbad6;
    --accent: #88d6f4;
    --good: #83efbd;
    --good-bg: #153430;
    --bad: #fcaab0;
    --bad-bg: #381f2a;
    --chart-grid: #304368;
    --chart-grid-3d: #435880;
    --chart-selection: rgba(153, 129, 255, .22);
    --lane-smoke: #62d2fa;
    --lane-regression: #b79dff;
    --lane-conversion: #62e3cb;
    --panel-shadow: 0 7px 22px #05091455;
    --active-accent: #dbccff;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

body {
    position: relative;
    isolation: isolate;
    min-width: 0;
    min-height: 100dvh;
    margin: 0;
    background: var(--bg-color);
    color: var(--text);
    font: 400 14px/1.5 Inter, system-ui, sans-serif;
}

a { color: var(--accent); }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
h1, h2, h3, p { margin-block-start: 0; }

#bg-canvas {
    position: fixed;
    z-index: -1;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: .45;
}

[data-theme="light"] #bg-canvas { opacity: .16; }

.site-header {
    --text: #f4f5ff;
    --text-muted: #b8c3e2;
    --control-bg: #1b2541;
    --control-hover: #2b3454;
    --surface: #141d35;
    --line: #394668;
    --strong-line: #72638f;
    --good: #8defc6;
    --good-bg: #173533;
    --bad: #ffc2ca;
    --bad-bg: #3e263f;
    position: relative;
    border-bottom: 1px solid #4b4c76;
    background: linear-gradient(108deg, #151c36, #221b3b 58%, #131d36);
}

.site-header::after {
    position: absolute;
    right: 0;
    bottom: -1px;
    left: 0;
    height: 1px;
    background: linear-gradient(90deg, #d1a5ff77, #a17bf971 37%, #7ad5eb5c 67%, transparent 95%);
    content: '';
}

.header-content, .dashboard-layout {
    width: min(100% - 64px, 1600px);
    margin-inline: auto;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 24px;
    min-height: 76px;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 11px;
    color: var(--text);
    text-decoration: none;
}

.logo-container img { flex: none; }
.logo-container h1 { margin: 0; font: 760 clamp(19px, 2vw, 28px)/1.05 Montserrat, Inter, sans-serif; letter-spacing: -.048em; }
.logo-container small { display: block; margin-top: 5px; color: #d0b7ff; font: 700 11px/1 Inter, sans-serif; letter-spacing: .18em; text-transform: uppercase; }

.global-status-widget {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 6px 11px;
    color: var(--text-muted);
    background: var(--control-bg);
    font-size: 12px;
    white-space: nowrap;
}

.global-status-widget:has(.operational) {
    border-color: color-mix(in srgb, var(--good) 29%, var(--line));
    background: var(--good-bg);
}

.global-status-widget:has(.degraded) {
    border-color: color-mix(in srgb, var(--bad) 33%, var(--line));
    background: var(--bad-bg);
}

.global-status-widget .operational { color: var(--good); }
.global-status-widget .degraded { color: var(--bad); }
.status-led { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); }
.led-pass { background: var(--good); }
.led-fail { background: var(--bad); }

.header-controls { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.theme-toggle, .music-toggle, .date-picker, .export-select, .export-btn {
    min-height: 34px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface);
    color: var(--text);
}

.theme-toggle, .music-toggle, .export-btn {
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 620;
    white-space: nowrap;
}

.theme-toggle:hover, .music-toggle:hover, .music-toggle.playing,
.date-picker:hover, .export-select:hover, .export-btn:hover {
    border-color: var(--strong-line);
    background: var(--control-hover);
}

.dashboard-layout {
    display: grid;
    grid-template-columns: minmax(240px, 290px) minmax(0, 1fr);
    align-items: stretch;
    gap: 16px;
    padding-block: 18px 20px;
}

.cards-column { display: grid; grid-template-rows: auto repeat(3, 1fr); gap: 9px; min-width: 0; }

.checks-heading, .chart-heading, .history-toolbar, .table-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.checks-heading { min-height: 29px; padding: 0 1px; }
.checks-heading h2 { margin: 0; font-size: 13px; font-weight: 740; }
.run-controls-btn { padding: 3px 0; border: 0; background: transparent; color: var(--text-muted); font-size: 11px; text-underline-offset: 3px; }
.run-controls-btn:hover { color: var(--accent); }

.card, .chart-section {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: var(--panel-shadow);
}

.card {
    --lane: var(--lane-smoke);
    display: grid;
    grid-template-rows: auto auto 1fr auto;
    justify-items: start;
    padding: 14px 14px 11px;
    border-left-color: color-mix(in srgb, var(--lane) 62%, var(--line));
    background: linear-gradient(125deg, color-mix(in srgb, var(--lane) 9%, var(--surface)), var(--surface) 64%);
}
.card[data-lane="regression"] { --lane: var(--lane-regression); }
.card[data-lane="conversion"] { --lane: var(--lane-conversion); }

.title-left { display: flex; align-items: center; gap: 7px; min-width: 0; }
.card .title-left::before { width: 3px; height: 14px; flex: none; border-radius: 2px; background: var(--lane); content: ''; }
.card h3 { margin: 0; color: var(--lane); font-size: 14px; font-weight: 750; letter-spacing: -.012em; }

.info-icon {
    position: relative;
    display: grid;
    width: 17px;
    height: 17px;
    padding: 0;
    flex: none;
    place-items: center;
    border: 1px solid var(--strong-line);
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 750;
    line-height: 1;
}

.tooltip {
    position: absolute;
    z-index: 8;
    top: calc(100% + 9px);
    left: 50%;
    display: none;
    width: min(226px, calc(100vw - 64px));
    padding: 9px 11px;
    transform: translateX(-50%);
    border: 1px solid var(--strong-line);
    border-radius: 7px;
    background: var(--surface);
    box-shadow: 0 6px 16px #0002;
    color: var(--text);
    font-size: 11px;
    font-weight: 500;
    line-height: 1.5;
    text-align: left;
}

.info-icon:hover .tooltip, .info-icon:focus-visible .tooltip { display: block; }

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 8px;
    padding: 3px 7px;
    border-radius: 5px;
    background: var(--control-bg);
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 740;
    letter-spacing: .05em;
}

.status-passed { color: var(--good); background: var(--good-bg); }
.status-failed { color: var(--bad); background: var(--bad-bg); }

.heartbeat-icon { width: 28px; height: 12px; overflow: visible; }
.hb-base, .hb-path { fill: none; stroke: currentColor; stroke-width: 3.4; stroke-linecap: round; stroke-linejoin: round; }
.hb-base { opacity: .36; }
.hb-path { stroke-dasharray: 26 74; stroke-dashoffset: 100; }
.status-passed .hb-path { animation: heartbeat 1.75s linear infinite; }
.status-failed .hb-path { animation: heartbeat .8s linear infinite; }
.status-inactive .hb-path { display: none; }
@keyframes heartbeat { to { stroke-dashoffset: 0; } }

.meta {
    display: grid;
    align-content: center;
    gap: 4px;
    margin: 9px 0 8px;
    color: var(--text-muted);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

.meta p { margin: 0; }
.meta-label { display: block; color: var(--text-muted); font-size: 10px; font-weight: 650; }
.checked { display: inline-flex; align-items: baseline; gap: 7px; }
.check-hour { color: var(--text); font-size: 24px; font-weight: 740; line-height: 1.15; letter-spacing: -.035em; }
.check-date { color: var(--text-muted); font-size: 11px; }
.check-environment { color: var(--text-muted); }
.card-footer {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-end;
    gap: 6px 11px;
    padding-top: 7px;
    border-top: 1px solid var(--line);
}
.card-recent { display: grid; gap: 4px; }
.card-recent > span { color: var(--text-muted); font-size: 10px; }
.recent-markers { display: flex; flex-wrap: wrap; gap: 3px; }
.recent-marker { min-width: 16px; height: 15px; padding: 0; border: 1px solid currentColor; border-bottom-width: 3px; border-radius: 3px; background: var(--control-bg); color: var(--text-muted); }
.recent-marker.pass { background: var(--good-bg); color: var(--good); }
.recent-marker.fail { background: var(--bad-bg); color: var(--bad); }
.recent-marker:hover { background: currentColor; }
.card-evidence .meta { margin-bottom: 0; }
.card-evidence button { max-width: 100%; }

.no-failures, .needs-attention, .table-link {
    padding: 4px 0;
    border: none;
    background: transparent;
    color: var(--accent);
    font-size: 12px;
    font-weight: 640;
    text-align: left;
}

.needs-attention { color: var(--bad); }
.no-failures:hover, .needs-attention:hover, .table-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.screenshot-container { display: flex; align-items: center; gap: 5px; padding: 2px; border: 0; background: transparent; color: var(--bad); font-size: 11px; font-weight: 700; }
.screenshot-container img { display: block; width: 30px; height: 20px; border: 1px solid var(--bad); border-radius: 3px; object-fit: cover; }

.chart-section { display: flex; min-height: 0; flex-direction: column; padding: 14px; border-top-color: var(--strong-line); }
.chart-heading { min-height: 36px; }
.chart-heading h2 { margin: 0; font: 750 23px/1.14 Montserrat, Inter, sans-serif; letter-spacing: -.045em; }

.chart-toggles {
    display: flex;
    gap: 2px;
    flex: none;
    padding: 3px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--control-bg);
}

.chart-btn {
    min-width: 51px;
    min-height: 30px;
    padding: 4px 10px;
    border: 1px solid transparent;
    border-radius: 5px;
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 620;
}

.chart-btn:hover { color: var(--text); background: var(--control-hover); }
.chart-btn[aria-pressed="true"], .chart-btn.active { border-color: var(--strong-line); background: var(--selected); color: var(--active-accent); }

.history-toolbar { align-items: end; gap: 9px 16px; margin: 9px 0 11px; flex-wrap: wrap; }
.date-range { display: flex; gap: 8px; min-width: 0; }
.date-range label { display: grid; gap: 3px; color: var(--text-muted); font-size: 11px; font-weight: 650; }

.date-picker {
    width: 135px;
    min-width: 0;
    padding: 4px 7px;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.date-picker[aria-invalid="true"] { border-color: var(--bad); }
.chart-range { margin: 0; color: var(--text-muted); font-size: 11px; line-height: 1.55; font-variant-numeric: tabular-nums; }
.date-error { margin: 0 0 8px; color: var(--bad); font-size: 12px; }

.chart-container, .table-container {
    position: relative;
    width: 100%;
    height: clamp(390px, calc(100svh - 264px), 790px);
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--plot);
}

#historyChart { width: 100%; height: 100%; }

.graph-message {
    position: absolute;
    top: 50%;
    left: 50%;
    width: max-content;
    max-width: calc(100% - 24px);
    padding: 8px 11px;
    transform: translate(-50%, -50%);
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface);
    color: var(--text-muted);
    font-size: 12px;
    text-align: center;
}

.graph-message button { margin-left: 7px; }
.guide-3d { position: absolute; right: 10px; bottom: 10px; display: flex; gap: 10px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--text-muted); font-size: 11px; pointer-events: none; }
.guide-3d b { color: var(--text); }

.table-container { display: flex; flex-direction: column; padding: 12px; }
.table-header-row { justify-content: space-between; flex-wrap: wrap; margin-bottom: 10px; }
.table-header-row h3 { margin: 0; font-size: 14px; }
.export-controls { display: flex; gap: 6px; }
.export-select { padding: 4px 7px; font-size: 12px; }
.export-btn { background: var(--selected); color: var(--accent); }
.data-table-wrapper { min-height: 0; flex: 1; overflow: auto; }
.data-table { width: 100%; border-collapse: collapse; text-align: left; font-size: 12px; font-variant-numeric: tabular-nums; }
.data-table th, .data-table td { padding: 8px 9px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.data-table th { position: sticky; z-index: 1; top: 0; background: var(--control-bg); color: var(--text-muted); }
.data-table tr:hover td { background: var(--control-bg); }

.modal-content {
    width: min(640px, calc(100% - 24px));
    max-height: 88dvh;
    overflow: auto;
    padding: 20px;
    border: 1px solid var(--strong-line);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 20px 60px #0005;
}

.modal-content::backdrop { background: #08121bb8; }
.modal-close { float: right; width: 32px; height: 32px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: var(--control-bg); color: var(--text); font-size: 20px; line-height: 1; }
.modal-header { margin: 0 42px 12px 0; }
.modal-header h2 { margin: 0; font-size: 19px; }
.detail-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; margin: 0; }
.detail-grid dt { color: var(--text-muted); font-size: 11px; }
.detail-grid dd { margin: 0; font-weight: 650; }
.check-list { padding: 0; list-style: none; }
.check-list li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.check-list p { margin: 3px 0 0; color: var(--text-muted); overflow-wrap: anywhere; }
.pill-pass, .pill-fail { margin-right: 7px; padding: 3px 6px; border-radius: 4px; font-size: 11px; font-weight: 700; }
.pill-pass { background: var(--good-bg); color: var(--good); }
.pill-fail { background: var(--bad-bg); color: var(--bad); }
.modal-images { margin-top: 15px; }
.modal-images h3 { margin: 0 0 6px; font-size: 14px; }
.screenshot-gallery { display: grid; gap: 10px; }
.screenshot-gallery figure { margin: 0; }
.screenshot-gallery figcaption, .evidence-empty { margin: 4px 0 0; color: var(--text-muted); font-size: 12px; }
.modal-images img { display: block; max-width: 100%; border: 1px solid var(--line); border-radius: 6px; }
.download-row, .run-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 12px; }
.download-row a { font-size: 12px; text-underline-offset: 3px; }
#activity, #next-checks { margin: 10px 0 0; color: var(--text-muted); }

@media (min-width: 940px) and (min-height: 680px) {
    .dashboard-layout { height: min(calc(100svh - 77px), 890px); grid-template-rows: minmax(0, 1fr); }
    .cards-column { min-height: 0; grid-template-rows: auto repeat(3, minmax(0, 1fr)); }
    .chart-container, .table-container { height: auto; min-height: 330px; flex: 1 1 0; }
}

@media (min-width: 940px) and (max-height: 790px) {
    .dashboard-layout { padding-block: 12px 14px; }
    .card { padding: 9px 12px 7px; }
    .card .meta { margin-block: 5px; gap: 2px; }
    .check-hour { font-size: 21px; }
    .card-footer { padding-top: 4px; }
    .chart-section { padding: 12px; }
}

@media (max-width: 960px) {
    .header-content, .dashboard-layout { width: calc(100% - 36px); }
    .dashboard-layout { grid-template-columns: minmax(205px, 240px) minmax(0,1fr); gap: 12px; }
}

@media (max-width: 760px) {
    .dashboard-layout { grid-template-columns: minmax(0,1fr); }
    .cards-column { grid-template-columns: repeat(3,minmax(0,1fr)); grid-template-rows: auto auto; gap: 8px; }
    .checks-heading { grid-column: 1 / -1; }
    .card { padding-inline: 9px; }
}

@media (max-width: 580px) {
    .header-content, .dashboard-layout { width: calc(100% - 24px); }
    .header-content { flex-wrap: wrap; gap: 8px 12px; padding-block: 10px; }
    .logo-container { gap: 7px; }
    .logo-container img { width: 31px; height: 31px; }
    .logo-container h1 { font-size: 14px; }
    .logo-container small { margin-top: 2px; font-size: 8px; }
    .global-status-widget { margin-left: auto; padding: 5px 8px; font-size: 11px; }
    .header-controls { width: 100%; justify-content: flex-end; }
    .header-controls button { min-height: 29px; padding: 3px 8px; font-size: 11px; }
    .dashboard-layout { padding-block: 12px; }
    .cards-column { grid-template-columns: 1fr; grid-template-rows: auto; }
    .card { display: grid; grid-template-columns: minmax(0,1fr) auto; grid-template-rows: auto; gap: 5px 8px; padding: 9px 11px; }
    .card .status-badge { justify-self: end; margin-top: 0; }
    .card .meta { margin: 0; }
    .check-time { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 6px; }
    .check-hour { font-size: 15px; }
    .card-footer { grid-column: 1/-1; align-items: center; padding-top: 4px; }
    .card-recent { display: flex; align-items: center; gap: 6px; }
    .card h3 { font-size: 13px; }
    .chart-section { padding: 9px; }
    .chart-heading { gap: 5px; }
    .chart-heading h2 { font-size: clamp(14px, 4.4vw, 20px); }
    .chart-btn { min-width: 0; padding-inline: 6px; font-size: 11px; }
    .history-toolbar { align-items: stretch; margin: 9px 0; }
    .date-range { width: 100%; }
    .date-range label { flex: 1; min-width: 0; }
    .date-picker { width: 100%; }
    .chart-container, .table-container { height: 410px; }
    #bg-canvas { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .status-badge .hb-path { animation: none; stroke-dasharray: none; opacity: .67; }
}
