:root {
  color-scheme: light;
  --bg: #fff8fb;
  --ink: #1f1018;
  --muted: #705466;
  --panel: #fffefd;
  --line: #ead0da;
  --primary: #c73572;
  --primary-dark: #7f173f;
  --primary-deep: #57122d;
  --gold: #c99a36;
  --gold-soft: #fff2cb;
  --gold-deep: #8b681f;
  --accent: #d45772;
  --purple: #7a4bd4;
  --cyan: #0c91a6;
  --green: #168a4a;
  --danger: #b42318;
  --ok: #137333;
  --warn: #8b681f;
  --soft: #fff9fc;
  --shadow: 0 18px 45px rgba(87, 18, 45, 0.12);
  --gold-shadow: 0 14px 34px rgba(201, 154, 54, 0.18);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(115deg, rgba(255, 248, 251, 0.96) 0%, rgba(255, 244, 249, 0.96) 48%, rgba(255, 248, 232, 0.92) 100%),
    repeating-linear-gradient(135deg, rgba(201, 154, 54, 0.08) 0 1px, transparent 1px 22px);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(1120px, 100%);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 252, 248, 0.88));
  border: 1px solid rgba(201, 154, 54, 0.34);
  box-shadow: var(--shadow);
  border-radius: 8px;
  padding: 24px;
  backdrop-filter: blur(18px);
}

.login-brand, .brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.login-brand {
  justify-content: space-between;
  margin-bottom: 18px;
}

.login-brand h1 {
  font-size: clamp(2rem, 5vw, 4rem);
  color: var(--primary-dark);
}

.login-brand .eyebrow {
  color: var(--gold-deep);
}

.login-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.login-panel, .new-school-form {
  border: 1px solid rgba(201, 154, 54, 0.28);
  background: linear-gradient(180deg, #fff, #fffaf0);
  border-radius: 8px;
  padding: 18px;
  display: grid;
  gap: 12px;
  box-shadow: 0 14px 34px rgba(87, 18, 45, 0.08);
}

.login-panel p {
  color: var(--muted);
  margin: 0;
}

.new-school-form {
  margin-top: 16px;
}

.app-shell {
  display: grid;
  grid-template-columns: 284px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  color: #fff;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  background:
    linear-gradient(180deg, rgba(87, 18, 45, 0.98), rgba(127, 23, 63, 0.96) 46%, rgba(181, 49, 98, 0.94)),
    #57122d;
  border-right: 1px solid rgba(201, 154, 54, 0.34);
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #fff, #fff1c7);
  color: var(--primary-dark);
  font-weight: 950;
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.16), inset 0 0 0 1px rgba(201, 154, 54, 0.42);
}

.brand strong, .brand span { display: block; }
.brand span { color: #ffe9b6; font-size: 0.9rem; }

.nav-list { display: grid; gap: 8px; }

.nav-item {
  width: 100%;
  border: 1px solid rgba(255, 239, 190, 0.12);
  background: rgba(255, 255, 255, 0.055);
  color: #fff;
  text-align: left;
  padding: 12px 14px;
  border-radius: 8px;
  font-weight: 850;
}

.nav-item:hover, .nav-item.active {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.17), rgba(255, 232, 170, 0.14));
  border-color: rgba(255, 232, 170, 0.44);
  box-shadow: inset 3px 0 0 var(--gold);
}

.side-note {
  margin-top: auto;
  border: 1px solid rgba(255, 232, 170, 0.32);
  border-radius: 8px;
  padding: 14px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.13), rgba(201, 154, 54, 0.1));
}

.side-note span, .side-note small { display: block; color: #ffe9b6; }
.side-note strong { display: block; font-size: 1.35rem; margin: 5px 0; line-height: 1.2; }

.workspace {
  padding: 24px;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--gold-deep);
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 0.76rem;
  font-weight: 900;
}

h1, h2, h3 { margin: 0; letter-spacing: 0; }
h1 { font-size: clamp(1.75rem, 4vw, 2.55rem); }
h2 { font-size: 1.12rem; }
h3 { font-size: 1rem; }

.top-actions, .toolbar, .dialog-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.primary-btn, .secondary-btn, .ghost-btn, .danger-btn, .icon-btn {
  border: 0;
  border-radius: 8px;
  min-height: 42px;
  padding: 0 14px;
  font-weight: 900;
}

.primary-btn {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary) 62%, #df617a);
  color: white;
  border: 1px solid rgba(255, 232, 170, 0.34);
  box-shadow: 0 10px 24px rgba(127, 23, 63, 0.22);
}

.primary-btn:hover { background: linear-gradient(135deg, var(--primary-deep), var(--primary-dark)); }

.secondary-btn {
  border: 1px solid rgba(201, 154, 54, 0.38);
  background: linear-gradient(180deg, #fff, #fffaf0);
  color: var(--primary-dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ghost-btn { background: transparent; color: var(--primary-dark); border: 1px solid rgba(201, 154, 54, 0.18); }
.danger-btn { background: #fff1ef; color: var(--danger); }

.icon-btn {
  width: 42px;
  padding: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #fff, #fffaf0);
  border: 1px solid rgba(201, 154, 54, 0.34);
  color: var(--primary-dark);
}

.role-badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: linear-gradient(135deg, #fff2cb, #ffe4f1);
  border: 1px solid rgba(201, 154, 54, 0.32);
  color: var(--primary-dark);
  font-size: 0.86rem;
  font-weight: 900;
}

.file-btn input { display: none; }
.data-file-btn {
  cursor: pointer;
}
.view { display: none; }
.view.active { display: block; }

.hero-band {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: center;
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 18px;
  color: white;
  background:
    linear-gradient(135deg, rgba(87, 18, 45, 0.98), rgba(127, 23, 63, 0.94) 55%, rgba(201, 154, 54, 0.78)),
    var(--primary-deep);
  border: 1px solid rgba(255, 232, 170, 0.36);
  box-shadow: var(--shadow), var(--gold-shadow);
}

.hero-band .eyebrow { color: #ffe9b6; }
.hero-band h2 { font-size: clamp(1.35rem, 3vw, 2rem); }
.hero-band p { margin: 6px 0 0; color: #fff2cb; }

.hero-orbit {
  display: grid;
  grid-template-columns: repeat(3, 88px);
  gap: 8px;
}

.hero-orbit span {
  min-height: 70px;
  border: 1px solid rgba(255, 232, 170, 0.36);
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-weight: 900;
  background: rgba(255, 255, 255, 0.13);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-card, .panel, .print-card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 252, 248, 0.94));
  border: 1px solid rgba(201, 154, 54, 0.26);
  box-shadow: var(--shadow);
  border-radius: 8px;
}

.metric-card {
  padding: 18px;
  position: relative;
  overflow: hidden;
}

.metric-card::after {
  content: "";
  position: absolute;
  right: -28px;
  top: -28px;
  width: 96px;
  height: 96px;
  background: linear-gradient(135deg, var(--card-color, var(--primary)), var(--gold));
  opacity: 0.12;
  transform: rotate(12deg);
}

.metric-card.pink { --card-color: #ec4899; }
.metric-card.coral { --card-color: #f97316; }
.metric-card.purple { --card-color: #8b5cf6; }
.metric-card.amber { --card-color: var(--gold); }

.metric-card span, .metric-card small, .muted, .panel-head p { color: var(--muted); }
.metric-card span { font-weight: 900; }
.metric-card strong { display: block; font-size: 2.15rem; margin: 8px 0 4px; color: var(--primary-dark); }

.content-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.wide { grid-column: 1 / -1; }
.panel { padding: 18px; }

.panel h2 {
  color: var(--primary-deep);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 16px;
}

.panel-head.compact { margin-bottom: 12px; }
.panel-head p { margin: 4px 0 0; }

.event-dashboard, .check-list, .school-list, .attendance-list, .stat-list, .event-config, .result-list, .judge-list {
  display: grid;
  gap: 10px;
}

.event-dashboard {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.event-tile, .color-stat-card {
  border: 1px solid color-mix(in srgb, var(--event-color), var(--gold-soft) 52%);
  border-radius: 8px;
  padding: 14px;
  min-height: 148px;
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--event-color), white 90%), #fffaf0);
  display: grid;
  align-content: space-between;
}

.event-tile strong, .color-stat-card span {
  display: block;
  color: #25131d;
  font-weight: 950;
  line-height: 1.25;
}

.event-tile span, .event-tile small, .color-stat-card small { color: var(--muted); }

.donut {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  margin: 10px 0;
  background: conic-gradient(var(--event-color) calc(var(--value) * 1%), #fff2cb 0);
  display: grid;
  place-items: center;
}

.donut b {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: white;
  display: grid;
  place-items: center;
  color: var(--primary-dark);
}

.check-item, .school-item, .attendance-item, .stat-item, .event-item, .judge-group {
  border: 1px solid rgba(201, 154, 54, 0.24);
  background: linear-gradient(180deg, var(--soft), #fffdf8);
  border-radius: 8px;
  padding: 12px;
}

.check-item strong, .school-item strong, .attendance-item strong, .stat-item strong, .event-item strong, .judge-group strong {
  display: block;
}

.ok { color: var(--ok); }
.warn { color: var(--warn); }

.toolbar { margin-bottom: 14px; }

.segmented-tabs {
  display: inline-flex;
  gap: 6px;
  padding: 6px;
  margin-bottom: 14px;
  border: 1px solid rgba(201, 154, 54, 0.28);
  border-radius: 8px;
  background: linear-gradient(180deg, #fff, #fffaf0);
  box-shadow: 0 10px 24px rgba(87, 18, 45, 0.08);
}

.segment {
  border: 0;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 8px;
  background: transparent;
  color: var(--primary-dark);
  font-weight: 950;
}

.segment.active {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: #fff;
  box-shadow: 0 8px 18px rgba(127, 23, 63, 0.2);
}

.searchbox {
  flex: 1 1 280px;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid rgba(201, 154, 54, 0.3);
  border-radius: 8px;
  padding: 0 12px;
}

.searchbox input, label input, label select, label textarea, .toolbar select, .panel-head select {
  width: 100%;
  border: 1px solid rgba(201, 154, 54, 0.26);
  border-radius: 8px;
  min-height: 42px;
  padding: 9px 11px;
  background: white;
}

.searchbox input { border: 0; padding: 0; outline: 0; }

.table-wrap {
  overflow: auto;
  background: white;
  border: 1px solid rgba(201, 154, 54, 0.25);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

table { width: 100%; border-collapse: collapse; min-width: 920px; }
th, td { padding: 13px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th {
  background: linear-gradient(180deg, #fff7e1, #fff1f7);
  font-size: 0.86rem;
  color: var(--primary-deep);
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 900;
  background: linear-gradient(135deg, #fff2cb, #ffe4f1);
  border: 1px solid rgba(201, 154, 54, 0.22);
  color: var(--primary-dark);
  margin: 0 4px 4px 0;
}

.pill.off { background: #f3f4f6; color: #667085; }

.split-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
}

.form-panel, .dialog-card { display: grid; gap: 12px; }

label {
  display: grid;
  gap: 6px;
  color: #51384a;
  font-weight: 900;
}

.field-hint {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

textarea { resize: vertical; }

select:disabled,
input:disabled {
  background: #fffaf0;
  color: var(--primary-dark);
  border-color: rgba(201, 154, 54, 0.32);
  opacity: 1;
  cursor: not-allowed;
}

.school-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.school-meta {
  display: grid;
  gap: 3px;
}

.attendance-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
}

.attendance-item input { width: 22px; height: 22px; }

.staff-list {
  display: grid;
  gap: 10px;
}

.staff-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  border: 1px solid rgba(201, 154, 54, 0.24);
  background: linear-gradient(180deg, var(--soft), #fffdf8);
  border-radius: 8px;
  padding: 12px;
}

.staff-item strong {
  display: block;
}

.staff-item > div:last-child {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.public-attendance-grid {
  margin-top: 16px;
}

.attendance-confirm-form {
  display: grid;
  gap: 14px;
}

.attendance-section-title {
  color: var(--gold-deep);
  font-weight: 950;
  text-transform: uppercase;
  margin: 8px 0 2px;
}

.qr-link-box {
  border: 1px solid rgba(201, 154, 54, 0.32);
  border-radius: 8px;
  padding: 12px;
  background: #fffaf0;
  overflow-wrap: anywhere;
}

.qr-link-box strong,
.qr-link-box span {
  display: block;
}

.qr-code-frame {
  width: 184px;
  min-height: 184px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(201, 154, 54, 0.34);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  margin: 10px 0 12px;
  box-shadow: 0 12px 26px rgba(87, 18, 45, 0.1);
}

.qr-code-frame img {
  width: 160px;
  height: 160px;
  object-fit: contain;
}

.color-stat-grid, .stat-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.color-stat-card strong {
  font-size: 2.2rem;
  color: var(--event-color);
  margin: 8px 0;
}

.print-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

.print-card {
  min-height: 150px;
  padding: 20px;
  text-align: left;
}

.print-card strong { display: block; font-size: 1.2rem; margin-bottom: 8px; }
.print-card span { color: var(--muted); }

.event-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
}

.status-dot { font-weight: 950; color: var(--ok); }
.status-dot.off { color: var(--danger); }
.full { width: 100%; margin-bottom: 10px; }

.result-card {
  border: 1px solid rgba(201, 154, 54, 0.25);
  border-left: 6px solid var(--gold);
  background: linear-gradient(180deg, #fff, #fffaf0);
  border-radius: 8px;
  padding: 14px;
}

.result-card div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-weight: 850;
}

.result-card h3 { margin: 8px 0 3px; color: var(--primary-dark); }
.result-card p { margin: 0 0 5px; font-weight: 850; }
.result-card small { color: var(--muted); }
.rank-gold { border-left-color: #f59e0b; }
.rank-silver { border-left-color: #94a3b8; }
.rank-bronze { border-left-color: #b45309; }

.judge-group { border-left: 6px solid var(--event-color); }
.judge-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  margin-top: 8px;
}

.judge-row small { color: var(--muted); }

.official-form {
  border: 1px solid rgba(201, 154, 54, 0.28);
  border-radius: 8px;
  padding: 18px;
  background: linear-gradient(180deg, #fff, #fffdf8);
  display: grid;
  gap: 18px;
}

.official-form h2 {
  color: var(--primary-dark);
}

.form-agency {
  margin: -8px 0 0;
  color: var(--muted);
  font-weight: 850;
}

.form-page {
  border: 1px solid rgba(201, 154, 54, 0.3);
  border-radius: 8px;
  padding: 16px;
  background: linear-gradient(180deg, #fff, #fffaf0);
}

.form-page h3 {
  color: var(--primary-dark);
  font-size: 1.05rem;
}

.official-form .form-lines, .official-form .signature-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: space-between;
  margin: 12px 0;
  font-weight: 850;
}

.rubric-table {
  min-width: 760px;
}

.rubric-table ol,
.rubric-table ul {
  margin: 0;
  padding-left: 18px;
}

.rubric-table li + li {
  margin-top: 4px;
}

.score-ladder {
  white-space: nowrap;
  line-height: 1.65;
  font-family: "Courier New", monospace;
  font-size: 0.86rem;
}

.score-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 8px;
  margin: 12px 0;
  font-size: 0.9rem;
  font-weight: 850;
}

.score-row span,
.form-lines span,
.signature-row span {
  border-bottom: 1px dotted #d9468d;
  padding-bottom: 4px;
}

.form-note {
  margin: 10px 0 0;
  color: var(--muted);
}

.summary-category {
  font-weight: 950;
  color: var(--primary-dark);
}

.score-inputs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.score-box {
  border: 1px solid rgba(201, 154, 54, 0.28);
  border-radius: 8px;
  background: linear-gradient(135deg, #fff8fb, #fffaf0);
  padding: 12px;
}

.score-box span {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--primary-dark);
}

.score-box small {
  color: var(--muted);
}

.quick-score-panel {
  border-color: rgba(201, 154, 54, .38);
}

.quick-score-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.quick-score-summary {
  margin-bottom: 12px;
}

.mini-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(110px, 1fr));
  gap: 10px;
}

.mini-metrics span {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(255, 255, 255, .94), rgba(255, 244, 250, .92));
  color: var(--muted);
  padding: 12px 14px;
  font-weight: 750;
}

.mini-metrics strong {
  color: var(--primary-dark);
  display: block;
  font-size: 1.45rem;
  line-height: 1;
}

.quick-score-table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  max-height: 520px;
  overflow: auto;
  background: #fff;
}

.quick-score-table {
  width: 100%;
  min-width: 980px;
  border-collapse: separate;
  border-spacing: 0;
}

.quick-score-table th,
.quick-score-table td {
  border-bottom: 1px solid rgba(122, 31, 70, .12);
  padding: 10px;
  text-align: left;
  vertical-align: middle;
}

.quick-score-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: linear-gradient(135deg, #fff7df, #fff);
  color: var(--primary-dark);
  font-size: .88rem;
}

.quick-score-table th span,
.quick-score-table td span {
  display: block;
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.3;
}

.quick-score-table input {
  min-height: 40px;
  padding: 8px 10px;
}

.quick-score-table input[type="number"] {
  width: 92px;
  text-align: center;
  font-weight: 850;
}

.quick-note {
  width: 170px;
}

.score-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 86px;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: .78rem;
  font-weight: 900;
}

.score-status.complete {
  background: #e8f8ee;
  color: #126b35;
}

.score-status.draft {
  background: #fff5d7;
  color: #86620e;
}

.score-status.empty {
  background: #f7edf2;
  color: var(--muted);
}

.quick-score-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

dialog {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: min(920px, calc(100vw - 28px));
  width: 920px;
}

dialog::backdrop { background: rgba(80, 10, 44, 0.46); }

.dialog-card {
  background: linear-gradient(180deg, #fff, #fffaf7);
  border-radius: 8px;
  padding: 20px;
  border: 1px solid rgba(201, 154, 54, 0.3);
  box-shadow: 0 28px 80px rgba(87, 18, 45, 0.28);
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

fieldset {
  border: 1px solid rgba(201, 154, 54, 0.3);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 253, 248, 0.72);
}

legend { font-weight: 950; padding: 0 6px; color: var(--gold-deep); }

.event-picks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.event-picks label {
  position: relative;
  display: grid;
  grid-template-columns: 26px 1fr;
  align-items: center;
  gap: 12px;
  border: 1px solid color-mix(in srgb, var(--event-color), var(--gold-soft) 56%);
  border-radius: 8px;
  padding: 12px 14px;
  min-height: 74px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--event-color), white 92%), #fffaf0);
  color: #253236;
  line-height: 1.22;
  transition: 0.16s ease;
}

.event-picks label:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(127, 23, 63, 0.12);
}

.event-picks input {
  appearance: none;
  width: 26px;
  height: 26px;
  margin: 0;
  border: 2px solid color-mix(in srgb, var(--event-color), var(--gold-deep) 24%);
  border-radius: 7px;
  background: white;
  display: grid;
  place-items: center;
}

.event-picks input::after {
  content: "";
  width: 12px;
  height: 7px;
  border-left: 3px solid white;
  border-bottom: 3px solid white;
  transform: rotate(-45deg) translate(1px, -1px);
  opacity: 0;
}

.event-picks input:checked {
  background: var(--event-color);
  border-color: var(--event-color);
}

.event-picks input:checked::after { opacity: 1; }

.event-picks label:has(input:checked) {
  background: linear-gradient(135deg, color-mix(in srgb, var(--event-color), white 80%), #fff7e1);
  border-color: var(--event-color);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--event-color), var(--gold-soft) 36%);
}

.event-picks strong {
  display: block;
  font-weight: 950;
  overflow-wrap: anywhere;
}

.event-picks small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-weight: 750;
}

.inline-alert {
  border: 1px solid #e9b6c9;
  border-left: 5px solid var(--primary);
  border-radius: 8px;
  background: linear-gradient(180deg, #fff1f7, #fffaf0);
  color: var(--primary-dark);
  font-weight: 900;
  padding: 12px 14px;
  box-shadow: 0 12px 28px rgba(225, 29, 72, 0.12);
}

.dialog-actions {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  background: linear-gradient(135deg, var(--primary-deep), var(--primary-dark));
  color: white;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
  max-width: 340px;
  z-index: 10000;
}

.toast.show { transform: translateY(0); opacity: 1; }

body[data-role="school"] .admin-only,
body[data-role="school"] .ppd-only { display: none !important; }
body[data-role="school"] .scoring-only { display: none !important; }
body[data-role="statistik"] .admin-only,
body[data-role="statistik"] .ppd-only { display: none !important; }
body[data-role="admin"] .school-only,
body[data-role="admin"] .ppd-only { display: none !important; }
body[data-role="ppd"] .school-only { display: none !important; }

.upload-box {
  min-height: 120px;
  border: 2px dashed rgba(201, 154, 54, 0.46);
  border-radius: 8px;
  place-items: center;
  text-align: center;
  background: linear-gradient(180deg, #fff8fb, #fffaf0);
  color: var(--primary-dark);
}

.upload-box input { display: none; }

.signature-preview {
  min-height: 88px;
  border: 1px solid rgba(201, 154, 54, 0.28);
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: white;
}

.signature-preview img {
  max-width: 260px;
  max-height: 80px;
  object-fit: contain;
}

.empty-signature {
  color: var(--muted);
  font-weight: 850;
}

.certificate-preview-wrap {
  overflow: auto;
  border-radius: 8px;
  border: 1px solid rgba(201, 154, 54, 0.32);
  background:
    linear-gradient(135deg, rgba(127, 23, 63, 0.08), rgba(201, 154, 54, 0.15)),
    #fff;
  padding: 18px;
}

.certificate-print {
  min-height: 250mm;
  border: 8px double var(--gold);
  padding: 18mm 22mm 28mm;
  text-align: center;
  background:
    linear-gradient(90deg, rgba(127, 23, 63, 0.08), transparent 18%, transparent 82%, rgba(201, 154, 54, 0.12)),
    linear-gradient(135deg, #fff8fb, #fff, #fff7e1);
  position: relative;
  color: #21121b;
}

.certificate-preview {
  width: min(100%, 1040px);
  min-height: auto;
  aspect-ratio: 1.414 / 1;
  margin: 0 auto;
  padding: clamp(28px, 4vw, 56px) clamp(28px, 5vw, 70px) clamp(36px, 5vw, 70px);
  box-shadow: 0 24px 70px rgba(87, 18, 45, 0.18), 0 10px 28px rgba(201, 154, 54, 0.14);
}

.cert-no {
  position: absolute;
  top: clamp(16px, 3vw, 44px);
  right: clamp(18px, 4vw, 54px);
  color: var(--primary-dark);
  font-weight: 950;
}

.cert-brand {
  position: relative;
  display: grid;
  place-items: center;
  height: clamp(58px, 9vw, 104px);
  margin: 0 auto clamp(18px, 3vw, 38px);
  padding-right: clamp(76px, 14vw, 170px);
  padding-left: clamp(76px, 14vw, 170px);
  overflow: visible;
}

.cert-brand img {
  display: block;
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(calc(38% * var(--cert-logo-scale, 1.15)), calc(285px * var(--cert-logo-scale, 1.15)));
  min-width: 170px;
  height: auto;
  opacity: 1;
  transform: translate(-50%, -50%);
  filter:
    drop-shadow(0 0 0 #fff)
    drop-shadow(1px 0 0 #fff)
    drop-shadow(-1px 0 0 #fff)
    drop-shadow(0 1px 0 #fff)
    drop-shadow(0 -1px 0 #fff);
}

input[type="range"] {
  accent-color: var(--gold);
}

#loginSchoolUsername,
#loginSchoolPassword,
#publicSchoolCode {
  text-transform: uppercase;
}

.certificate-print h1 {
  margin: 0 0 12px;
  color: var(--primary-dark);
  font-size: clamp(2rem, 4vw, 4.4rem);
}

.cert-program {
  display: grid;
  gap: 2px;
  max-width: 860px;
  margin: 0 auto clamp(20px, 3vw, 34px);
  color: var(--gold-deep) !important;
  font-size: clamp(1.1rem, 1.8vw, 1.75rem);
  font-weight: 950 !important;
  text-transform: uppercase;
  line-height: 1.18;
}

.cert-program span {
  display: block;
}

.certificate-print h2 {
  margin: 18px auto 10px;
  max-width: 900px;
  color: #120914;
  font-size: clamp(1.55rem, 3vw, 3.4rem);
  text-transform: uppercase;
}

.certificate-print h3 {
  margin: 0 0 20px;
  color: var(--primary-dark);
  font-size: clamp(1.1rem, 2vw, 1.6rem);
}

.certificate-print p {
  color: #4b3b46;
  font-weight: 750;
}

.cert-award-line {
  margin-bottom: 10px;
  font-weight: 850 !important;
}

.cert-event-list {
  display: grid;
  justify-items: center;
  gap: 4px;
  margin: 0 auto 14px;
  color: #20131b;
  font-size: clamp(1.05rem, 1.8vw, 1.7rem);
  font-weight: 950;
  line-height: 1.15;
}

.cert-event-list span {
  display: block;
}

.cert-detail {
  display: inline-flex;
  justify-content: center;
  max-width: 90%;
  border-radius: 999px;
  background: linear-gradient(135deg, #fff2cb, #ffe4f1);
  border: 1px solid rgba(201, 154, 54, 0.3);
  color: var(--primary-dark) !important;
  padding: 8px 16px;
  font-weight: 950 !important;
}

.cert-footer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(20px, 6vw, 90px);
  margin-top: clamp(28px, 6vw, 86px);
}

.cert-footer strong,
.cert-footer span {
  display: block;
}

.cert-footer span {
  color: var(--muted);
  font-weight: 750;
}

.cert-signature {
  height: clamp(48px, 8vw, 110px);
  max-width: 260px;
  object-fit: contain;
}

.cert-signature-line {
  height: clamp(48px, 8vw, 110px);
  border-bottom: 1px solid var(--gold-deep);
  margin-bottom: 8px;
}

.certificate-list {
  display: grid;
  gap: 8px;
}

.certificate-row {
  display: grid;
  grid-template-columns: 150px 1fr 1fr 1.4fr;
  gap: 10px;
  align-items: center;
  border: 1px solid rgba(201, 154, 54, 0.25);
  border-radius: 8px;
  padding: 10px 12px;
  background: linear-gradient(180deg, #fff8fb, #fffaf0);
}

.certificate-row strong {
  color: var(--primary-dark);
}

@media (max-width: 1180px) {
  .event-dashboard, .color-stat-grid, .print-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quick-score-controls { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 10; padding: 14px; gap: 12px; }
  .nav-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .side-note { display: none; }
  .content-grid, .split-layout, .login-grid { grid-template-columns: 1fr; }
  .mini-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .wide { grid-column: auto; }
  .hero-band { grid-template-columns: 1fr; }
  .hero-orbit { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .workspace { padding: 16px; }
  .topbar, .panel-head, .school-item, .attendance-item, .judge-row { grid-template-columns: 1fr; display: grid; }
  .nav-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics-grid, .form-grid, .event-picks, .event-dashboard, .color-stat-grid, .print-grid, .quick-score-controls, .mini-metrics { grid-template-columns: 1fr; }
  .dialog-actions { grid-template-columns: 1fr; }
}

@media print {
  body { background: white; }
  .sidebar, .topbar, .toolbar, .toast, dialog, .login-screen { display: none !important; }
  .app-shell, .workspace, .view.active { display: block; padding: 0; }
  .panel, .metric-card, .table-wrap { box-shadow: none; }
}
:root { color-scheme: light; }
.draw-toolbar { display: flex; align-items: end; flex-wrap: wrap; gap: 16px; padding: 20px 0; }
.draw-toolbar label { display: grid; gap: 8px; flex: 1 1 190px; min-width: 0; }
.draw-toolbar input, .draw-toolbar select { width: 100%; min-width: 0; max-width: 100%; min-height: 44px; box-sizing: border-box; }
.draw-toolbar label:has(input[type="datetime-local"]) { flex-basis: 265px; }
.draw-toolbar button:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.draw-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; border-top: 1px solid #e3c897; padding-top: 24px; }
.draw-heading h2 { font-size: 22px; line-height: 1.4; overflow-wrap: anywhere; }
.draw-number { color: #8b2850; font-size: 24px; font-variant-numeric: tabular-nums; }
.draw-warning { color: #9a3412; background: #fff1e6; padding: 4px 8px; border-radius: 4px; }
#drawHistory { border-top: 1px solid #e3c897; margin-top: 24px; padding-top: 16px; font-size: 14px; }
#drawNotice { color: #7b2548; min-height: 24px; }
.saving-data #appShell button, .saving-data #appShell input, .saving-data #appShell select, .saving-data #appShell textarea, .saving-data dialog, .saving-data #publicAttendanceScreen { pointer-events: none; }
.saving-data { cursor: progress; }
@media (max-width: 600px) { .draw-toolbar { gap: 12px; } .draw-heading { align-items: flex-start; } }
