:root {
    color-scheme: light;
    --brand-bg: #14213d;
    --brand-bg-darker: #101a30;
    --brand-accent: #fca311;
    --page-bg: #f3f5f7;
    --surface-bg: #ffffff;
    --surface-muted: #f0f2f4;
    --border-soft: #d7dce2;
    --text-primary: #1f2933;
    --text-secondary: #52606d;
    font-family: "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    background: var(--page-bg);
    color: var(--text-primary);
}

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

a:hover,
a:focus {
    text-decoration: underline;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--brand-bg);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.75rem;
    box-shadow: 0 2px 8px rgba(16, 26, 48, 0.2);
}

.topbar h1 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.topbar h1 a {
    color: inherit;
}

.topbar nav ul {
    display: flex;
    align-items: center;
    gap: 1rem;
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.95rem;
}

.topbar nav a {
    color: #eef1f7;
    font-weight: 500;
    padding: 0.2rem 0;
}

.topbar nav a.active {
    color: var(--brand-accent);
}

.page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.75rem 2rem 2.5rem;
}

.page > h2 {
    margin: 0 0 1.5rem;
    font-size: 1.45rem;
}

.panel {
    background: var(--surface-bg);
    border-radius: 8px;
    border: 1px solid var(--border-soft);
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04);
    padding: 1.5rem;
    margin-bottom: 1.75rem;
}

.auth-panel {
    max-width: 420px;
    margin: 3rem auto;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.panel-header h2,
.panel-header h3 {
    margin: 0;
    font-size: 1.25rem;
}

.text-secondary {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.panel-header .action {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--brand-bg);
    padding: 0.35rem 0.75rem;
    border: 1px solid var(--brand-bg);
    border-radius: 4px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table thead {
    background: var(--surface-muted);
}

.data-table th,
.data-table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border-soft);
    text-align: left;
    vertical-align: middle;
}

.data-table tbody tr:hover {
    background: rgba(20, 33, 61, 0.07);
}

.data-table .status-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.15rem 0.5rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: var(--surface-muted);
    color: var(--text-secondary);
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
}

.stat-card {
    background: var(--surface-muted);
    border-radius: 6px;
    padding: 0.9rem 1rem;
}

.stat-card header {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
    margin-bottom: 0.4rem;
}

.stat-card p {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
}

.stat-card small {
    display: block;
    margin-top: 0.2rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

form {
    display: grid;
    gap: 1.5rem;
}

fieldset {
    border: 1px solid var(--border-soft);
    border-radius: 6px;
    padding: 1.25rem;
    background: #fff;
}

fieldset legend {
    padding: 0 0.5rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.75rem;
}

label {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.label-title {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-weight: 600;
    color: var(--text-primary);
}

.inline-option {
    flex-direction: row;
    align-items: center;
    gap: 0.6rem;
    color: var(--text-primary);
    font-weight: 500;
}

.inline-option span {
    flex: 1;
}

.inline-option input[type="radio"] {
    flex-shrink: 0;
}

.help-hint {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.125rem;
    height: 1.125rem;
    border-radius: 999px;
    border: 1px solid var(--brand-bg);
    color: var(--brand-bg);
    font-size: 0.65rem;
    font-weight: 700;
    cursor: help;
}

.help-hint::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 0.45rem);
    left: 50%;
    transform: translateX(-50%);
    min-width: 180px;
    max-width: 280px;
    background: var(--brand-bg);
    color: #fff;
    padding: 0.55rem 0.7rem;
    border-radius: 6px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.25);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.12s ease-out, visibility 0.12s ease-out;
    pointer-events: none;
    line-height: 1.35;
    font-weight: 500;
    text-align: left;
    white-space: normal;
    z-index: 20;
}

.help-hint::before {
    content: "";
    position: absolute;
    bottom: calc(100% + 0.2rem);
    left: 50%;
    transform: translateX(-50%);
    width: 10px;
    height: 10px;
    background: var(--brand-bg);
    clip-path: polygon(50% 100%, 0 0, 100% 0);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.12s ease-out, visibility 0.12s ease-out;
}

.help-hint:focus-visible {
    outline: 2px solid rgba(252, 163, 17, 0.8);
    outline-offset: 2px;
}

.help-hint:hover::after,
.help-hint:hover::before,
.help-hint:focus-visible::after,
.help-hint:focus-visible::before {
    opacity: 1;
    visibility: visible;
}

input,
select,
textarea {
    font: inherit;
    padding: 0.45rem 0.55rem;
    border: 1px solid var(--border-soft);
    border-radius: 4px;
    background: #fff;
    color: var(--text-primary);
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid rgba(20, 33, 61, 0.35);
    border-color: var(--brand-bg);
}

textarea {
    resize: vertical;
}

.grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.systems-fieldset .system-grid {
    gap: 1.25rem;
    align-items: start;
}

.system-card {
    display: grid;
    gap: 1rem;
    padding: 1rem;
    border: 1px solid var(--border-soft);
    border-radius: 6px;
    background: var(--surface-muted);
}

.system-card h4 {
    margin: 0 0 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.system-card > * + * {
    margin-top: 1rem;
}

.system-card details {
    margin-top: 0.5rem;
}

.system-fields {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.judge-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
}

fieldset > * + * {
    margin-top: 1rem;
}

details > * + * {
    margin-top: 0.75rem;
}

button,
.button {
    font: inherit;
    font-weight: 600;
    border-radius: 4px;
    border: none;
    background: var(--brand-bg);
    color: #fff;
    padding: 0.55rem 1.25rem;
    cursor: pointer;
    transition: background 0.15s ease-in-out;
}

button:hover,
button:focus,
.button:hover,
.button:focus {
    background: var(--brand-bg-darker);
}

button.secondary,
.button.secondary {
    background: transparent;
    border: 1px solid var(--brand-bg);
    color: var(--brand-bg);
}

.nav-logout {
    background: transparent;
    color: #eef1f7;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 4px;
    padding: 0.35rem 0.75rem;
    font-size: 0.9rem;
    cursor: pointer;
}

.nav-logout:hover,
.nav-logout:focus {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.6);
    color: #ffffff;
}

details {
    background: var(--surface-muted);
    border-radius: 4px;
    padding: 0.75rem 1rem;
}

details summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--text-primary);
}

.judge-card {
    margin: 0;
    border-style: dashed;
    padding: 1rem;
    border-radius: 6px;
}

.judge-card legend {
    margin-bottom: 0.75rem;
}

.inline-form {
    display: inline;
}

.notice {
    border: 1px solid #c3423f;
    background: #ffeceb;
    color: #8f2f2d;
    border-radius: 6px;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
}

@media (max-width: 720px) {
    .topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .topbar nav ul {
        flex-wrap: wrap;
        gap: 0.5rem 0.75rem;
    }

    .page {
        padding: 1.25rem;
    }
}
