:root {
  --brand: #0f766e;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --surface: #ffffff;
  --background: #f8fafc;
  --danger: #b91c1c;
  --success: #047857;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--background);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--background); }
a { color: var(--brand); text-decoration: none; }
button, input, select { font: inherit; }

.app-header {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  min-height: 68px;
  padding: 10px max(20px, calc((100vw - 1120px) / 2));
}
.brand { align-items: center; color: var(--ink); display: flex; font-weight: 750; gap: 10px; }
.brand img { height: 42px; max-width: 150px; object-fit: contain; }
.brand-mark {
  align-items: center; background: var(--brand); border-radius: 12px; color: white;
  display: inline-flex; font-size: 13px; font-weight: 800; height: 42px;
  justify-content: center; letter-spacing: -.04em; width: 42px;
}
.brand-mark-large { border-radius: 18px; font-size: 22px; height: 64px; width: 64px; }
nav { align-items: center; display: flex; gap: 20px; }
nav form { margin: 0; }
.nav-button { background: transparent; border: 0; color: var(--muted); cursor: pointer; padding: 0; }

.page-shell { margin: 0 auto; max-width: 1120px; padding: 40px 20px 80px; }
.page-heading { align-items: flex-end; display: flex; justify-content: space-between; margin-bottom: 28px; }
h1, h2, p { margin-top: 0; }
h1 { font-size: clamp(2rem, 5vw, 3rem); letter-spacing: -.04em; margin-bottom: 8px; }
h2 { letter-spacing: -.025em; }
.eyebrow { color: var(--brand); font-size: .78rem; font-weight: 800; letter-spacing: .12em; margin-bottom: 8px; text-transform: uppercase; }
.muted { color: var(--muted); }
.card, .auth-card, .scan-card, .empty-state {
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
  box-shadow: 0 12px 30px rgb(15 23 42 / 5%); padding: 26px;
}
.auth-card { margin: 5vh auto 0; max-width: 440px; }
.auth-footer { margin: 20px 0 0; text-align: center; }
.product-lockup { align-items: center; display: flex; gap: 16px; margin-bottom: 24px; }
.product-lockup h1 { font-size: 2rem; margin: 0; }
.product-lockup p { margin: 0 0 2px; }
.form-stack { display: grid; gap: 18px; }
label { color: #334155; display: grid; font-size: .88rem; font-weight: 650; gap: 7px; }
input, select {
  background: white; border: 1px solid #cbd5e1; border-radius: 11px; color: var(--ink);
  min-height: 46px; padding: 10px 12px; width: 100%;
}
input:focus, select:focus { border-color: var(--brand); outline: 3px solid color-mix(in srgb, var(--brand) 18%, transparent); }
input[type="checkbox"] { min-height: auto; width: auto; }
.check-label { align-items: center; display: flex; gap: 8px; }
.button {
  align-items: center; border: 1px solid transparent; border-radius: 11px; cursor: pointer;
  display: inline-flex; font-weight: 750; justify-content: center; min-height: 44px; padding: 10px 17px;
}
.button-primary { background: var(--brand); color: white; }
.button-secondary { background: white; border-color: var(--line); color: var(--ink); }
.button-light { background: white; color: var(--brand); }
.button-full { width: 100%; }
.field-error, .message-error { color: var(--danger); font-size: .82rem; }
.form-hint { color: var(--muted); font-size: .82rem; }
.generated-code-note {
  background: #ecfdf5; border: 1px solid #b7ead7; border-radius: 12px; color: #065f46;
  display: grid; font-size: .84rem; gap: 4px; line-height: 1.45; padding: 14px 16px;
}
.generated-code-note strong { font-size: .9rem; }
.flash { border-radius: 12px; margin-bottom: 20px; padding: 12px 16px; }
.flash-success { background: #ecfdf5; color: #065f46; }
.flash-error { background: #fef2f2; color: #991b1b; }

.next-card {
  background: linear-gradient(135deg, var(--brand), color-mix(in srgb, var(--brand), #020617 28%));
  border-radius: 24px; color: white; margin-bottom: 22px; padding: 30px;
}
.next-card .eyebrow { color: #ccfbf1; }
.next-card h2 { font-size: 2rem; margin-bottom: 4px; }
.section-title { align-items: center; display: flex; justify-content: space-between; margin-bottom: 16px; }
.section-title h2 { margin: 0; }
.section-title span { color: var(--muted); font-size: .85rem; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { align-items: center; border-top: 1px solid var(--line); display: grid; gap: 14px; grid-template-columns: 16px 1fr auto; padding: 18px 0; }
.timeline li:first-child { border-top: 0; }
.timeline li > div { display: grid; gap: 3px; }
.timeline li span { color: var(--muted); font-size: .85rem; }
.timeline-dot { border: 2px solid #94a3b8; border-radius: 50%; height: 12px; width: 12px; }
.complete .timeline-dot { background: var(--brand); border-color: var(--brand); }
.record-result { justify-items: end; }
.status { background: #f1f5f9; border-radius: 999px; color: #475569 !important; padding: 4px 9px; white-space: nowrap; }
.status-ok { background: #ecfdf5; color: var(--success) !important; }
.status-late { background: #fef2f2; color: var(--danger) !important; }
.status-pending { background: #f8fafc; }

.admin-grid { display: grid; gap: 20px; grid-template-columns: repeat(2, 1fr); }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; }
.admin-wide { grid-column: 1 / -1; }
.simple-list { list-style: none; margin: 0; padding: 0; }
.simple-list li { align-items: center; border-top: 1px solid var(--line); display: flex; justify-content: space-between; padding: 14px 0; }
.simple-list li:first-child { border-top: 0; }
.simple-list span { display: grid; gap: 3px; }
.simple-list small { color: var(--muted); }
.form-card { margin: 0 auto; max-width: 720px; }
.logo-preview { display: block; max-height: 110px; max-width: 260px; margin: 0 0 24px; }
.schedule-grid { display: grid; gap: 18px; grid-template-columns: repeat(2, 1fr); }
.schedule-event { display: grid; gap: 13px; }
.weekday-grid { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; }
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.qr-board { text-align: center; }
.qr-board img { background: white; border-radius: 24px; display: block; margin: 20px auto; max-width: min(560px, 90vw); padding: 20px; width: 100%; }
.scan-card { margin: 7vh auto; max-width: 520px; text-align: center; }
.scan-symbol { align-items: center; background: #ccfbf1; border-radius: 50%; color: var(--brand); display: inline-flex; font-size: 3rem; height: 90px; justify-content: center; margin-bottom: 20px; width: 90px; }
.scan-result { background: #ecfdf5; border-radius: 12px; color: #065f46; padding: 14px; }
.table-card { overflow-x: auto; }
table { border-collapse: collapse; min-width: 620px; width: 100%; }
th, td { border-bottom: 1px solid var(--line); padding: 14px 10px; text-align: left; }
th { color: var(--muted); font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; }
.metrics-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.metric-card { background: white; border: 1px solid var(--line); border-radius: 16px; display: grid; gap: 4px; padding: 20px; }
.metric-card strong { font-size: 2rem; letter-spacing: -.04em; }
.metric-card span { color: var(--muted); font-size: .86rem; }

.analytics-heading { margin-bottom: 24px; }
.analytics-heading h1 { margin: 14px 0 0; }
.date-selector { align-items: end; display: flex; flex-wrap: wrap; gap: 9px; }
.date-selector label { color: var(--muted); font-size: .72rem; gap: 4px; }
.date-selector input { min-height: 40px; padding: 7px 10px; width: 150px; }
.date-separator { color: var(--muted); padding-bottom: 10px; }
.filter-reset { font-size: .8rem; font-weight: 700; padding: 11px 4px; }
.analytics-overview { display: block; margin-bottom: 22px; }
.overview-visual {
  align-items: center; display: grid; gap: 56px; grid-template-columns: minmax(180px, 260px) minmax(300px, 1fr);
  margin: 8px auto 0; max-width: 820px;
}
.chart-filters {
  align-items: end; background: #f8fafc; border: 1px solid var(--line); border-radius: 14px;
  display: grid; gap: 10px; grid-template-columns: repeat(3, minmax(150px, 1fr)) auto;
  margin-bottom: 24px; padding: 12px;
}
.chart-filters-overview { grid-template-columns: repeat(2, minmax(170px, 1fr)) auto; }
.filter-field { color: var(--muted); font-size: .7rem; gap: 4px; text-transform: uppercase; }
.filter-field select { color: var(--ink); min-height: 40px; padding: 7px 10px; text-transform: none; }
.button-filter {
  align-self: end; background: #e6f4f2; border-color: #c9e7e3; color: var(--brand);
  min-height: 40px; white-space: nowrap;
}
.chart-empty { margin: 24px 0 4px; text-align: center; }
.chart-kicker {
  color: var(--brand); font-size: .72rem; font-weight: 850; letter-spacing: .12em;
  margin-bottom: 6px; text-transform: uppercase;
}
.chart-heading { align-items: flex-start; display: flex; gap: 24px; justify-content: space-between; margin-bottom: 24px; }
.chart-heading h2 { font-size: 1.55rem; margin-bottom: 7px; }
.chart-caption { font-size: .86rem; max-width: 350px; text-align: right; }
.chart-card { margin-top: 22px; }
.chart-scroll { overflow-x: auto; padding-bottom: 4px; }
.donut-chart { display: block; height: auto; width: 100%; }
.donut-track, .donut-segment {
  fill: none; stroke-width: 20; transform: rotate(-90deg); transform-origin: 90px 90px;
}
.donut-track { stroke: #e8eef5; }
.donut-segment { stroke-linecap: butt; }
.donut-on-time { stroke: #0f9f78; }
.donut-late { stroke: #f59e0b; }
.donut-missing { stroke: #e05252; }
.donut-value { fill: var(--ink); font-size: 25px; font-weight: 850; letter-spacing: -.04em; }
.donut-label { fill: var(--muted); font-size: 10px; font-weight: 650; }
.outcome-legend { display: grid; gap: 14px; }
.legend-row { align-items: center; display: grid; gap: 10px; grid-template-columns: 12px 1fr auto; }
.legend-row strong { font-size: .9rem; }
.legend-swatch { border-radius: 4px; display: inline-block; height: 10px; width: 10px; }
.legend-on-time { background: #0f9f78; }
.legend-late { background: #f59e0b; }
.legend-missing { background: #e05252; }
.overview-gauge { border-top: 1px solid var(--line); display: grid; gap: 8px; margin-top: 4px; padding-top: 16px; }
.gauge-label { align-items: center; display: flex; font-size: .86rem; justify-content: space-between; }
.gauge-track, .rank-track { fill: #e8eef5; }
.gauge-fill { fill: var(--brand); }
.chart-footnote { color: var(--muted); font-size: .8rem; line-height: 1.5; margin: 0; }
.inline-legend { display: flex; flex-wrap: wrap; gap: 14px; }
.inline-legend span { align-items: center; color: var(--muted); display: flex; font-size: .78rem; gap: 6px; }
.inline-legend .legend-swatch { border-radius: 3px; }
.trend-chart { display: block; min-width: 760px; width: 100%; }
.chart-grid-line { stroke: #e2e8f0; stroke-width: 1; }
.chart-axis-label { fill: #64748b; font-size: 10px; }
.trend-on-time { fill: #0f9f78; }
.trend-late { fill: #f59e0b; }
.trend-missing { fill: #e05252; }
.delay-chart { display: block; min-width: 720px; width: 100%; }
.delay-label { fill: #475569; font-size: 12px; font-weight: 650; }
.delay-track { fill: #f1f5f9; }
.delay-bar-on-time { fill: #0f9f78; }
.delay-bar-minor { fill: #eab308; }
.delay-bar-moderate { fill: #f97316; }
.delay-bar-severe { fill: #dc2626; }
.delay-value { fill: #0f172a; font-size: 12px; font-weight: 800; }
.ranking-list { display: grid; }
.ranking-row {
  align-items: center; border-top: 1px solid var(--line); display: grid; gap: 16px;
  grid-template-columns: 42px minmax(150px, .7fr) minmax(320px, 1.7fr); padding: 20px 0;
}
.ranking-row:first-child { border-top: 0; padding-top: 4px; }
.rank-number {
  align-items: center; background: #f1f5f9; border-radius: 50%; display: inline-flex;
  font-size: .9rem; font-weight: 850; height: 34px; justify-content: center; width: 34px;
}
.ranking-row:nth-child(1) .rank-number { background: #fef3c7; color: #92400e; }
.ranking-row:nth-child(2) .rank-number { background: #e2e8f0; color: #475569; }
.ranking-row:nth-child(3) .rank-number { background: #ffedd5; color: #9a3412; }
.rank-person { display: grid; gap: 3px; }
.rank-person small { color: var(--muted); }
.rank-visual { display: grid; gap: 8px; }
.rank-visual svg { height: 9px; width: 100%; }
.rank-fill { fill: var(--brand); }
.rank-detail { color: var(--muted); display: flex; flex-wrap: wrap; font-size: .74rem; gap: 5px 14px; }

@media (max-width: 760px) {
  .app-header { align-items: flex-start; gap: 16px; }
  nav { align-items: flex-end; flex-direction: column; gap: 8px; }
  .page-shell { padding-top: 24px; }
  .page-heading { align-items: flex-start; flex-direction: column; gap: 16px; }
  .admin-grid, .schedule-grid { grid-template-columns: 1fr; }
  .admin-wide { grid-column: auto; }
  .timeline li { grid-template-columns: 16px 1fr; }
  .timeline li > :last-child { grid-column: 2; justify-self: start; }
  .date-selector { align-items: stretch; }
  .date-selector label { flex: 1 1 140px; }
  .date-selector input { width: 100%; }
  .date-separator { display: none; }
  .overview-visual { gap: 28px; grid-template-columns: minmax(150px, 210px) 1fr; }
  .chart-filters, .chart-filters-overview { grid-template-columns: 1fr 1fr; }
  .button-filter { width: 100%; }
  .chart-heading { align-items: flex-start; flex-direction: column; gap: 8px; }
  .chart-caption { text-align: left; }
  .ranking-row { align-items: start; grid-template-columns: 38px 1fr; }
  .rank-visual { grid-column: 2; }
}

@media (max-width: 480px) {
  .date-selector .button, .filter-reset { flex: 1 1 100%; text-align: center; }
  .overview-visual { grid-template-columns: 1fr; }
  .donut-chart { margin: 0 auto; max-width: 210px; }
  .chart-filters, .chart-filters-overview { grid-template-columns: 1fr; }
}
