/* ===== Type ===== */

@font-face {
    font-family: "JetBrains Mono";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/JetBrainsMono-400.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F, U+2122;
}

@font-face {
    font-family: "JetBrains Mono";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("../fonts/JetBrainsMono-500.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F, U+2122;
}

@font-face {
    font-family: "JetBrains Mono";
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url("../fonts/JetBrainsMono-600.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F, U+2122;
}

@font-face {
    font-family: "JetBrains Mono";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("../fonts/JetBrainsMono-700.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F, U+2122;
}

/* ===== Tokens =====
   Ground/accent inherited from the WinForms desktop app's own dark theme (#14161D / #23252F / #FFC52D
   amber / #43A047 / #E53935) so the web platform reads as the same product, not a bolted-on afterthought -
   refined here with a considered (not default) muted-text hue and raised/hover steps the desktop app has no
   equivalent of. Single committed dark world (the desktop app has no light mode either) - painted explicitly
   below rather than left to inherit, so no separate light/dark branch is needed. */
:root {
    --bg: #14161d;
    --bg-raised: #191c25;
    --surface: #23252f;
    --surface-hover: #2b2e3a;
    --border: #34374499;
    --border-strong: #454a5c;

    --accent: #ffc52d;
    --accent-ink: #1a1305;
    --accent-dim: #ffc52d26;

    --text: #f2f1ed;
    --text-muted: #999cad;
    --text-faint: #5c6070;

    --success: #43a047;
    --success-bg: #43a04722;
    --danger: #e5453f;
    --danger-bg: #e5453f1c;
    --warning: #fb8c00;
    --warning-bg: #fb8c0022;

    --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Code", Consolas, monospace;
    --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", sans-serif;

    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-7: 48px;

    --radius: 10px;
    --radius-sm: 6px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    color-scheme: dark;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

@media (prefers-reduced-motion: no-preference) {
    a, button, .card-link, .score-btn {
        transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, transform 80ms ease;
    }
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ===== Instrument bar ===== */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-3) var(--space-6);
    background: var(--bg-raised);
    border-bottom: 1px solid var(--border);
}

.brand {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 14px;
    letter-spacing: 0.02em;
}

.brand-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 3px var(--success-bg);
    flex: none;
}

.account {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    color: var(--text-muted);
    font-size: 13px;
}

.account-name {
    font-family: var(--font-mono);
    color: var(--text);
}

.topbar form {
    margin: 0;
}

/* ===== Layout ===== */

.container {
    max-width: 1040px;
    margin: 0 auto;
    padding: var(--space-7) var(--space-6);
}

.container-narrow {
    max-width: 420px;
}

/* Opt-in wider container for the Admin/SuperAdmin panels' dense tables - set via ViewData["Wide"], see
   _Layout.cshtml. Everything else (Judge/Order/Login) keeps the narrower default above. */
.container-wide {
    max-width: 1280px;
}

.eyebrow {
    display: block;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-faint);
    margin: 0 0 var(--space-2);
}

.page-title {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin: 0 0 var(--space-2);
    text-wrap: balance;
}

.page-subtitle {
    color: var(--text-muted);
    margin: 0 0 var(--space-6);
    font-size: 14px;
    max-width: 60ch;
}

/* ===== Cards ===== */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-5);
}

.stack > * + * {
    margin-top: var(--space-3);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: var(--space-4);
}

.card-link {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    color: var(--text);
    border-color: var(--border);
}

.card-link:hover {
    border-color: var(--border-strong);
    background: var(--surface-hover);
    text-decoration: none;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
}

.card-meta {
    color: var(--text-muted);
    font-size: 13px;
}

.card-meta-mono {
    color: var(--text-faint);
    font-family: var(--font-mono);
    font-size: 12px;
}

/* ===== Status pills ===== */

.pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px 3px 8px;
    border-radius: 999px;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.pill::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex: none;
}

.pill-success {
    background: var(--success-bg);
    color: var(--success);
}

.pill-success::before {
    background: var(--success);
}

.pill-pending {
    background: var(--surface-hover);
    color: var(--text-muted);
}

.pill-pending::before {
    background: var(--text-faint);
}

/* ===== Presentation queue (order carries real information here) ===== */

.queue {
    display: flex;
    flex-direction: column;
}

.queue-row {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4) 0;
    border-bottom: 1px solid var(--border);
}

.queue-row:last-child {
    border-bottom: none;
}

.queue-index {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 13px;
    color: var(--text-faint);
    width: 28px;
    flex: none;
    text-align: right;
}

.queue-body {
    flex: 1 1 auto;
    min-width: 0;
}

.queue-name {
    font-weight: 600;
}

.queue-title {
    color: var(--text-muted);
    font-size: 13px;
}

.queue-actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex: none;
}

/* ===== Buttons ===== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    background: var(--accent);
    color: var(--accent-ink);
}

.btn:hover {
    background: #ffd35c;
    text-decoration: none;
}

.btn:active {
    transform: translateY(1px);
}

.btn-outline {
    background: transparent;
    border-color: var(--border-strong);
    color: var(--text);
    font-weight: 500;
}

.btn-outline:hover {
    background: var(--surface-hover);
    border-color: var(--text-faint);
}

.btn-block {
    width: 100%;
}

/* ===== Forms ===== */

.field {
    margin-bottom: var(--space-4);
}

.field label {
    display: block;
    margin-bottom: var(--space-2);
    color: var(--text-muted);
    font-size: 12px;
    font-family: var(--font-mono);
    letter-spacing: 0.02em;
}

.field input[type="text"],
.field input[type="password"],
.field input[type="number"],
.field input[type="date"],
.field input[type="time"],
.field select {
    width: 100%;
    padding: 11px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--bg-raised);
    color: var(--text);
    font-size: 14px;
    font-family: var(--font-body);
}

.field input:focus,
.field select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.field-hint {
    color: var(--text-faint);
    font-size: 12px;
    margin-top: var(--space-1);
}

.validation-summary {
    color: var(--danger);
    background: var(--danger-bg);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: var(--space-3) var(--space-4);
    font-size: 13px;
    margin-bottom: var(--space-4);
}

.validation-summary ul {
    margin: 0;
    padding-left: 18px;
}

.notice-success {
    color: var(--success);
    background: var(--success-bg);
    border-radius: var(--radius-sm);
    padding: var(--space-3) var(--space-4);
    font-size: 13px;
    margin-bottom: var(--space-4);
}

/* ===== Login ===== */

.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-6);
}

.login-card {
    width: 100%;
    max-width: 380px;
    padding: var(--space-6);
}

.login-mark {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-faint);
    margin-bottom: var(--space-5);
}

/* ===== Scoring ===== */

.criterion-block {
    padding: var(--space-4) 0;
    border-bottom: 1px solid var(--border);
}

.criterion-block:last-child {
    border-bottom: none;
}

.criterion-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: var(--space-3);
}

.criterion-name {
    font-weight: 600;
}

.criterion-max {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-faint);
}

.score-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.score-buttons form {
    margin: 0;
}

.score-btn {
    min-width: 42px;
    height: 38px;
    padding: 0 4px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--bg-raised);
    color: var(--text);
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
}

.score-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.score-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
}

/* ===== Section tabs (Admin/SuperAdmin panels - switching between a project's/panel's sections) ===== */

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-bottom: var(--space-5);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--border);
}

.tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 999px;
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--text-muted);
    background: transparent;
    border: 1px solid var(--border);
}

.tab:hover {
    color: var(--text);
    background: var(--surface-hover);
    text-decoration: none;
}

.tab.active {
    color: var(--accent-ink);
    background: var(--accent);
    border-color: var(--accent);
}

/* ===== Dashboard stat cards (SuperAdmin overview) ===== */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-4) var(--space-5);
}

.stat-value {
    font-family: var(--font-mono);
    font-size: 30px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.15;
}

.stat-label {
    color: var(--text-muted);
    font-size: 12.5px;
    margin-top: var(--space-1);
}

/* ===== Toolbar (search box + action button, above a table) ===== */

.toolbar {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
    flex-wrap: wrap;
}

.toolbar form {
    margin: 0;
    flex: 1 1 260px;
}

.toolbar input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--bg-raised);
    color: var(--text);
    font-size: 14px;
    font-family: var(--font-body);
}

.toolbar input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.toolbar-actions {
    display: flex;
    gap: var(--space-2);
    flex: none;
}

/* ===== Data table (first dense-grid layout in this stylesheet - existing views only ever needed
   .card/.queue-row) ===== */

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: var(--space-5);
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    font-size: 13.5px;
}

.table th,
.table td {
    padding: var(--space-3) var(--space-4);
    text-align: left;
    white-space: nowrap;
}

.table td.wrap {
    white-space: normal;
}

.table th {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-faint);
    background: var(--bg-raised);
    border-bottom: 1px solid var(--border);
}

.table td {
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr:hover td {
    background: var(--surface-hover);
}

.table .row-actions {
    display: flex;
    gap: var(--space-2);
}

/* ===== Badges (role/status pills inside table cells) ===== */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    background: var(--surface-hover);
    color: var(--text-muted);
    white-space: nowrap;
}

.badge-accent {
    background: var(--accent-dim);
    color: var(--accent);
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
}

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger);
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning);
}

/* ===== Small/danger button variants (table row actions) ===== */

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: #ff5a54;
}

/* ===== Icons (inline SVG, not emoji - see order/randomize/logout markup) ===== */

.icon {
    width: 16px;
    height: 16px;
    flex: none;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ===== Empty state ===== */

.empty-state {
    color: var(--text-muted);
    text-align: center;
    padding: var(--space-7) var(--space-4);
    font-size: 14px;
}

@media (max-width: 560px) {
    .container {
        padding: var(--space-5) var(--space-4);
    }

    .topbar {
        padding: var(--space-3) var(--space-4);
    }
}
