:root {
    --bg: #07111f;
    --bg-soft: #0d1a2d;
    --panel: #12233c;
    --panel-strong: #162845;
    --surface-muted: rgba(255, 255, 255, 0.05);
    --surface-input: rgba(5, 12, 22, 0.65);
    --panel-border: rgba(148, 163, 184, 0.18);
    --text: #ecf4ff;
    --muted: #91a5c0;
    --accent: #3dd9b1;
    --accent-soft: rgba(61, 217, 177, 0.16);
    --accent-contrast: #03281f;
    --warning: #ffcc66;
    --danger: #ff7a7a;
    --shadow: 0 18px 40px rgba(0, 0, 0, 0.2);
    --radius: 18px;
}

* {
    box-sizing: border-box;
}

html.light-theme body,
body.light-theme {
    --bg: #eef4fa;
    --bg-soft: #ffffff;
    --panel: rgba(255, 255, 255, 0.96);
    --panel-strong: #f8fbff;
    --surface-muted: #eef3f9;
    --surface-input: #ffffff;
    --panel-border: rgba(15, 23, 42, 0.12);
    --text: #0f172a;
    --muted: #52627c;
    --accent: #0e9f6e;
    --accent-soft: rgba(14, 159, 110, 0.12);
    --accent-contrast: #ffffff;
    --warning: #a16207;
    --danger: #dc2626;
    --shadow: 0 18px 38px rgba(15, 23, 42, 0.08);
}

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background:
        radial-gradient(circle at top right, rgba(61, 217, 177, 0.08), transparent 30%),
        linear-gradient(180deg, #08101b 0%, #0d1727 100%);
    color: var(--text);
}

body.light-theme {
    background:
        radial-gradient(circle at top right, rgba(14, 159, 110, 0.07), transparent 30%),
        linear-gradient(180deg, #f3f7fb 0%, #eaf0f7 100%);
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select {
    font: inherit;
}

.app-shell {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px 16px 40px;
}

.site-header,
.hero-top,
.panel-head,
.filters,
.route-switcher,
.rule-edit-form,
.special-day-form,
.site-nav,
.admin-links {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}

.brand-group {
    display: grid;
    gap: 6px;
}

.brand {
    font-size: 1.4rem;
    font-weight: 700;
}

.tagline,
.muted {
    color: var(--muted);
}

.accent-text {
    color: var(--accent);
}

.site-nav a,
.text-link {
    color: var(--muted);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.icon-button {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 1px solid var(--panel-border);
    border-radius: 999px;
    background: var(--bg-soft);
    color: var(--text);
    cursor: pointer;
    box-shadow: var(--shadow);
}

.lang-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    padding: 0 16px;
    border: 1px solid var(--panel-border);
    border-radius: 999px;
    background: var(--bg-soft);
    color: var(--text);
    cursor: pointer;
    box-shadow: var(--shadow);
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
}

.header-link-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    padding: 0 20px;
    border: 1px solid var(--panel-border);
    border-radius: 999px;
    background: var(--bg-soft);
    color: var(--text);
    box-shadow: var(--shadow);
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
}

.mobile-label {
    display: none;
}

.icon-button svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

.notification-dot {
    position: absolute;
    top: 10px;
    right: 11px;
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.main-content {
    display: grid;
    gap: 18px;
    margin-top: 18px;
}

.site-footer {
    margin-top: 22px;
    text-align: center;
}

.site-footer p {
    margin: 0;
    color: color-mix(in srgb, var(--muted) 78%, transparent);
    font-size: 0.78rem;
    letter-spacing: 0.02em;
}

.site-footer a {
    color: inherit;
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, var(--muted) 45%, transparent);
    text-underline-offset: 2px;
}

.hero-card,
.panel,
.stat-card,
.timeline-card,
.rule-card,
.admin-link-card,
.status-banner,
.info-banner {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    box-shadow: var(--shadow);
    border-radius: var(--radius);
}

.hero-card,
.panel,
.status-banner,
.info-banner {
    padding: 18px;
}

.hero-card h1,
.panel h1,
.panel h2,
.status-banner strong,
.stat-card h2 {
    margin: 0;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.72rem;
    font-weight: 700;
}

.clock-box {
    min-width: 140px;
    padding: 12px 14px;
    background: var(--accent-soft);
    border-radius: 14px;
    text-align: right;
    border: 1px solid var(--panel-border);
}

.hero-metrics {
    display: flex;
    gap: 12px;
    align-items: stretch;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.mini-stat-box {
    min-width: 150px;
    padding: 14px 16px;
    background: var(--surface-muted);
    border-radius: 14px;
    text-align: right;
    border: 1px solid var(--panel-border);
}

.clock-box strong {
    display: block;
    font-size: 1.5rem;
    margin: 4px 0;
    min-width: 13ch;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
}

.mini-stat-box strong {
    display: block;
    margin-top: 6px;
    font-size: 1.15rem;
}

.route-switcher {
    margin-top: 18px;
}

.route-switcher button,
.primary-button,
.danger-button {
    border: 0;
    border-radius: 999px;
    padding: 12px 16px;
    cursor: pointer;
}

.route-switcher button {
    background: var(--surface-muted);
    color: var(--text);
}

.route-switcher button.active,
.primary-button {
    background: var(--accent);
    color: var(--accent-contrast);
    font-weight: 700;
}

.danger-button {
    background: rgba(255, 122, 122, 0.15);
    color: var(--danger);
}

.small {
    padding: 9px 13px;
}

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

.stat-card,
.timeline-card,
.rule-card,
.admin-link-card {
    padding: 16px;
}

.timeline-list,
.rule-list {
    display: grid;
    gap: 12px;
}

.info-content {
    display: grid;
    gap: 12px;
}

.timeline-card,
.rule-card {
    position: relative;
    transition: transform 0.18s ease, border-color 0.18s ease, opacity 0.18s ease;
}

.timeline-card.active,
.rule-card.active {
    border-color: rgba(61, 217, 177, 0.8);
    background: linear-gradient(135deg, var(--accent-soft), var(--panel-strong));
    transform: translateY(-1px);
}

.timeline-card.past,
.rule-card.past {
    opacity: 0.55;
}

.now-pill {
    display: inline-block;
    margin-top: 10px;
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-contrast);
    font-size: 0.78rem;
    font-weight: 800;
}

.status-banner {
    display: grid;
    gap: 6px;
}

.status-banner.running {
    border-color: rgba(61, 217, 177, 0.55);
}

.status-banner.not_started {
    border-color: rgba(255, 204, 102, 0.5);
}

.status-banner.ended {
    border-color: rgba(255, 122, 122, 0.45);
}

.info-banner {
    margin-top: 16px;
}

.form-stack,
.form-grid {
    display: grid;
    gap: 12px;
}

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

label {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-size: 0.95rem;
}

input,
select {
    width: 100%;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 12px;
    padding: 11px 12px;
    background: var(--surface-input);
    color: var(--text);
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.checkbox-row input {
    width: auto;
}

.full-width {
    grid-column: 1 / -1;
}

.admin-section {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid rgba(148, 163, 184, 0.12);
}

.rule-edit-form,
.special-day-form,
.inline-delete-form {
    margin-top: 12px;
}

.rule-edit-form,
.special-day-form {
    align-items: end;
    padding: 14px;
    border: 1px solid rgba(148, 163, 184, 0.14);
    border-radius: 14px;
}

.admin-links {
    margin-top: 18px;
}

.admin-link-card {
    flex: 1 1 220px;
    color: var(--text);
}

.alert {
    padding: 12px 14px;
    border-radius: 12px;
    margin-bottom: 14px;
}

.alert.success {
    background: var(--accent-soft);
    border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}

.alert.error {
    background: rgba(255, 122, 122, 0.12);
    border: 1px solid color-mix(in srgb, var(--danger) 28%, transparent);
}

.auth-wrap,
.admin-wrap {
    display: grid;
    gap: 16px;
}

.auth-card {
    max-width: 480px;
    margin: 32px auto 0;
}

.tomorrow-panel h2 {
    margin: 0;
}

@media (min-width: 768px) {
    .grid-cards {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .app-shell {
        padding: 14px 10px 28px;
    }

    .site-header {
        align-items: flex-start;
    }

    .brand {
        font-size: 1.05rem;
    }

    .tagline {
        font-size: 0.82rem;
        max-width: 210px;
    }

    .hero-card h1 {
        font-size: 1.45rem;
        line-height: 1.15;
    }

    .panel h1,
    .panel h2,
    .status-banner strong,
    .stat-card h2 {
        font-size: 1.1rem;
    }

    .eyebrow {
        font-size: 0.6rem;
    }

    .header-actions {
        gap: 6px;
        align-self: flex-start;
    }

    .icon-button,
    .lang-button,
    .header-link-button {
        height: 34px;
    }

    .icon-button {
        width: 34px;
    }

    .icon-button svg {
        width: 16px;
        height: 16px;
    }

    .lang-button,
    .header-link-button {
        padding: 0 10px;
        font-size: 0.8rem;
    }

    .notification-dot {
        top: 7px;
        right: 7px;
        width: 6px;
        height: 6px;
    }

    .desktop-label {
        display: none;
    }

    .mobile-label {
        display: inline;
    }

    .clock-box {
        width: 100%;
        text-align: left;
    }

    .hero-metrics {
        width: 100%;
        justify-content: stretch;
    }

    .mini-stat-box {
        width: 100%;
        text-align: left;
    }

    .timeline-card h3,
    .rule-card h3 {
        font-size: 0.95rem;
    }

    .timeline-card p,
    .rule-card p,
    .muted,
    label,
    .status-banner span {
        font-size: 0.84rem;
    }

    .site-footer p {
        font-size: 0.72rem;
    }
}
