:root {
    --background: #f7f9fb;
    --surface: #ffffff;
    --surface-low: #f2f4f6;
    --surface-high: #e6e8ea;
    --text: #191c1e;
    --muted: #45464d;
    --primary: #0f172a;
    --secondary: #475569;
    --teal: #0d9488;
    --teal-dark: #0f766e;
    --danger: #ba1a1a;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: "Inter", "Segoe UI", sans-serif;
    background: var(--background);
    color: var(--text);
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
.material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}
.pb-safe { padding-bottom: env(safe-area-inset-bottom); }

.shell { max-width: 1280px; margin: 0 auto; padding: 20px 24px 96px; }
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 80;
    display: flex; justify-content: space-between; align-items: center; gap: 24px;
    height: 64px;
    padding: 0 16px;
    background: rgba(255,255,255,0.96);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 1.08rem; font-weight: 700; letter-spacing: -0.01em; color: var(--primary); }
.brand-icon { color: var(--teal); font-size: 1.3rem; }
.version-badge {
    display: inline-flex;
    margin-left: 2px;
    padding: 4px 9px;
    border-radius: 999px;
    background: #d5e3fd;
    color: #3a485c;
    font-size: 0.76rem;
    vertical-align: middle;
}
.nav { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.page { padding: 76px 0 32px; }
.footer-note {
    padding: 8px 4px 20px;
    color: var(--muted);
    font-size: 0.9rem;
}
.flash, .error {
    margin-top: 20px; padding: 14px 16px; border-radius: 16px; border: 1px solid var(--border);
    background: #ffffff;
}
.error { background: #ffdad6; color: #93000a; }
.modal-lock { overflow: hidden; }

.hero, .grid.two-columns, .grid.three-columns, .section-header, .auth-card {
    display: grid; gap: 24px;
}
.hero, .grid.two-columns { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.three-columns { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.section-header.compact { grid-template-columns: 1fr auto; align-items: end; }
.panel {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 16px; padding: 20px; box-shadow: var(--shadow);
}
.soft { background: var(--surface-low); }
.eyebrow { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.72rem; color: var(--secondary); font-weight: 600; }
h1, h2 { margin: 0 0 10px; line-height: 1.1; }
h1 { font-size: clamp(1.5rem, 2.4vw, 2.2rem); max-width: 16ch; color: var(--primary); }
h2 { font-size: 1.2rem; color: var(--primary); }
.lead { color: var(--muted); max-width: 58ch; }
.actions, .tag-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 18px; }
.button, .link-button {
    display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
    border-radius: 10px; border: none; padding: 10px 16px; background: var(--teal);
    color: white; font-weight: 700;
}
.button:hover { background: var(--teal-dark); }
.button-secondary { background: var(--surface-low); color: var(--primary); border: 1px solid var(--border); }
.link-button { background: transparent; color: var(--secondary); padding: 0; }
.tag {
    background: #d5e3fd; color: #3a485c; border-radius: 999px;
    padding: 8px 12px; font-size: 0.9rem; font-weight: 700;
}
.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    border: 1px solid var(--border);
    background: #ecfeff;
    color: #115e59;
}
.chip.is-muted {
    background: #f8fafc;
    color: #475569;
}
.featured-event {
    background: linear-gradient(140deg, #ffffff 0%, #f8fbff 100%);
}
.featured-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.featured-title {
    margin: 0 0 6px;
    font-size: 1.35rem;
}
.featured-meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    color: var(--muted);
    font-size: 0.92rem;
}
.event-list-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}
.event-list-card {
    display: grid;
    gap: 8px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #fff;
    box-shadow: var(--shadow);
}
.table-wrap {
    overflow-x: auto;
}
.stack { display: grid; gap: 14px; }
.row-actions, .row-between, .align-end {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}
.row-between { justify-content: space-between; }
.align-end { align-items: end; }
.feature-list { padding-left: 18px; color: var(--muted); }
.hint { color: var(--muted); font-size: 0.92rem; }
.top-gap { margin-top: 18px; }
.metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.station-metrics { margin-bottom: 24px; }
.metric-label { color: var(--muted); margin: 0 0 8px; }
.metric-value { font-size: 2rem; margin: 0; font-weight: 800; }

label { display: grid; gap: 8px; font-weight: 600; color: var(--secondary); }
input, textarea, select {
    width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--border);
    background: white; color: var(--text);
}
textarea.is-fullscreen {
    position: fixed;
    inset: 16px;
    z-index: 95;
    width: calc(100vw - 32px);
    height: calc(100vh - 32px);
    max-width: none;
    max-height: none;
    border-radius: 16px;
    box-shadow: 0 16px 40px rgba(19, 52, 59, 0.24);
}
.checkbox { grid-template-columns: auto 1fr; align-items: center; }
.checkbox input { width: auto; }
.list-card {
    display: grid; gap: 4px; padding: 14px 16px; border-radius: 16px;
    border: 1px solid var(--border); background: var(--surface);
}
.status-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.86);
    font-size: 0.88rem;
}
.status-badge strong {
    font-size: 0.82rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.sub-list-card {
    display: grid;
    gap: 6px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--border);
}
.form-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; }
.filter-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.json-block {
    padding: 14px 16px;
    border-radius: 16px;
    background: #f6f2eb;
    border: 1px solid var(--border);
    white-space: pre-wrap;
    font-family: Consolas, monospace;
    font-size: 0.92rem;
}
.pagination-wrap {
    margin-top: 18px;
}
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-size: 0.92rem; }

.auth-card {
    max-width: 540px; margin: 4vh auto 0; background: rgba(255,255,255,0.82);
    padding: 28px; border-radius: 30px; border: 1px solid var(--border); box-shadow: var(--shadow);
}
.body-station .topbar { background: rgba(19, 52, 59, 0.92); color: white; }
.body-station .tag { background: rgba(255,255,255,0.16); color: white; }
.body-station .version-badge { background: rgba(255,255,255,0.16); color: white; }
.body-station .metric-value { font-size: clamp(1.4rem, 4vw, 2rem); }
.station-main-grid { align-items: start; }
.helper-actions { justify-content: flex-end; }
.helper-drawer {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 40;
    transform: translateY(102%);
    transition: transform 160ms ease;
    background: rgba(255,255,255,0.98);
    border-top-left-radius: 26px;
    border-top-right-radius: 26px;
    border: 1px solid var(--border);
    box-shadow: 0 -18px 40px rgba(19, 52, 59, 0.18);
    max-height: 78vh;
    overflow: auto;
    padding: 18px;
}
.helper-drawer.is-open { transform: translateY(0); }
.helper-drawer__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}
.helper-panel h3 { margin: 0 0 14px; }
.helper-tool-grid { grid-template-columns: 1fr; }
.helper-keypad {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}
.helper-key { min-height: 46px; }
.helper-key-wide { grid-column: span 4; }
.helper-timer-value {
    font-size: clamp(2rem, 6vw, 3rem);
    font-weight: 800;
    letter-spacing: 0.04em;
}
.helper-conflict-card textarea {
    font-family: Consolas, monospace;
    font-size: 0.92rem;
}
.richtext-content {
    display: grid;
    gap: 8px;
    color: var(--text);
    line-height: 1.45;
    overflow-wrap: anywhere;
}
.richtext-content p,
.richtext-content ul,
.richtext-content ol,
.richtext-content blockquote,
.richtext-content pre {
    margin: 0;
}
.richtext-content img {
    max-width: 100%;
    border-radius: 12px;
    border: 1px solid var(--border);
}
.richtext-fullscreen-content {
    max-height: 70vh;
    overflow: auto;
    padding-right: 4px;
}
.modal {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal.is-open { display: flex; }
.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(9, 20, 23, 0.52);
    backdrop-filter: blur(4px);
}
.modal-card {
    position: relative;
    width: min(920px, 96vw);
    max-height: 90vh;
    overflow: auto;
    background: rgba(255,255,255,0.98);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 22px;
    box-shadow: var(--shadow);
}
.modal-card.narrow {
    width: min(620px, 96vw);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}
.modal-title {
    margin: 0;
    font-size: 1.24rem;
}

.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 79;
    display: none;
    background: #ffffff;
    border-top: 1px solid var(--border);
    box-shadow: 0 -6px 16px rgba(15, 23, 42, 0.08);
    padding: 8px 8px 10px;
}
.bottom-nav__item {
    flex: 1;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--secondary);
    font-size: 0.72rem;
    padding: 6px 4px;
    border-radius: 999px;
}
.bottom-nav__item .material-symbols-outlined { font-size: 1.2rem; }
.bottom-nav__item.is-active {
    background: #d5e3fd;
    color: #0d1c2f;
}

@media (max-width: 720px) {
    .shell { padding: 12px 14px 98px; }
    .topbar, .section-header.compact { grid-template-columns: 1fr; }
    .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    h1 { max-width: none; }
    .helper-actions { justify-content: stretch; }
    .helper-actions .button { flex: 1 1 120px; }
    .nav > a,
    .nav > form,
    .nav > #view-help-open { display: none; }
    .bottom-nav { display: flex; }
    .modal-card {
        width: 100%;
        max-height: 94vh;
        border-radius: 18px;
        padding: 16px;
    }
    .featured-meta {
        display: grid;
        gap: 6px;
    }
}
