:root {
    --sidebar-width: 260px;
    --header-height: 60px;
}

html[data-theme="light"] {
    --bg-page: #f1f5f9;
    --bg-dark: #0f172a;
    --bg-card: rgba(255, 255, 255, 0.94);
    --sidebar-bg: rgba(255, 255, 255, 0.92);
    --primary: #0284c7;
    --primary-glow: rgba(2, 132, 199, 0.22);
    --accent: #7c3aed;
    --accent-glow: rgba(124, 58, 237, 0.2);
    --success: #15803d;
    --error: #dc2626;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --glass-border: rgba(15, 23, 42, 0.12);
    --surface-ghost: rgba(15, 23, 42, 0.06);
    --surface-ghost-hover: rgba(15, 23, 42, 0.1);
    --nav-hover: rgba(15, 23, 42, 0.06);
    --brand-gradient-start: #0284c7;
    --brand-gradient-end: #7c3aed;
    --card-hover-border: rgba(15, 23, 42, 0.18);
    --mobile-nav-bg: rgba(255, 255, 255, 0.95);
    --log-wrapper-bg: rgba(15, 23, 42, 0.04);
    --chart-line-a: #0284c7;
    --chart-line-b: #7c3aed;
    --chart-fill-a: rgba(2, 132, 199, 0.12);
    --chart-fill-b: rgba(124, 58, 237, 0.12);
    --chart-grid: rgba(15, 23, 42, 0.08);
    --chart-tick: #64748b;
    --range-active-border: rgba(2, 132, 199, 0.45);
    --range-active-bg: rgba(2, 132, 199, 0.1);
    --weather-hero: #0284c7;
    --weather-daily: #7c3aed;
    /* Hi/lo pills: warm max, cool min (readable on light cards) */
    --weather-tmax-fg: #b91c1c;
    --weather-tmax-bg: rgba(185, 28, 28, 0.14);
    --weather-tmin-fg: #1d4ed8;
    --weather-tmin-bg: rgba(29, 78, 216, 0.12);
}

html[data-theme="dark"] {
    --bg-page: #0f172a;
    --bg-dark: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.7);
    --sidebar-bg: rgba(15, 23, 42, 0.8);
    --primary: #38bdf8;
    --primary-glow: rgba(56, 189, 248, 0.3);
    --accent: #c084fc;
    --accent-glow: rgba(192, 132, 252, 0.3);
    --success: #22c55e;
    --error: #ef4444;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --glass-border: rgba(255, 255, 255, 0.1);
    --surface-ghost: rgba(255, 255, 255, 0.05);
    --surface-ghost-hover: rgba(255, 255, 255, 0.1);
    --nav-hover: rgba(255, 255, 255, 0.05);
    --brand-gradient-start: #38bdf8;
    --brand-gradient-end: #c084fc;
    --card-hover-border: rgba(255, 255, 255, 0.2);
    --mobile-nav-bg: rgba(15, 23, 42, 0.9);
    --log-wrapper-bg: rgba(0, 0, 0, 0.2);
    --chart-line-a: #38bdf8;
    --chart-line-b: #c084fc;
    --chart-fill-a: rgba(56, 189, 248, 0.1);
    --chart-fill-b: rgba(192, 132, 252, 0.1);
    --chart-grid: rgba(255, 255, 255, 0.05);
    --chart-tick: #94a3b8;
    --range-active-border: rgba(56, 189, 248, 0.45);
    --range-active-bg: rgba(56, 189, 248, 0.1);
    --weather-hero: #38bdf8;
    --weather-daily: #c084fc;
    --weather-tmax-fg: #fca5a5;
    --weather-tmax-bg: rgba(248, 113, 113, 0.16);
    --weather-tmin-fg: #7dd3fc;
    --weather-tmin-bg: rgba(56, 189, 248, 0.14);
}

html[data-theme="mono"] {
    --bg-page: #0a0a0a;
    --bg-dark: #0a0a0a;
    --bg-card: rgba(23, 23, 23, 0.92);
    --sidebar-bg: rgba(10, 10, 10, 0.95);
    --primary: #d4d4d4;
    --primary-glow: rgba(212, 212, 212, 0.2);
    --accent: #a3a3a3;
    --accent-glow: rgba(163, 163, 163, 0.2);
    --success: #a3a3a3;
    --error: #737373;
    --text-main: #fafafa;
    --text-muted: #a3a3a3;
    --glass-border: rgba(255, 255, 255, 0.1);
    --surface-ghost: rgba(255, 255, 255, 0.06);
    --surface-ghost-hover: rgba(255, 255, 255, 0.1);
    --nav-hover: rgba(255, 255, 255, 0.06);
    --brand-gradient-start: #e5e5e5;
    --brand-gradient-end: #737373;
    --card-hover-border: rgba(255, 255, 255, 0.18);
    --mobile-nav-bg: rgba(10, 10, 10, 0.95);
    --log-wrapper-bg: rgba(0, 0, 0, 0.35);
    --chart-line-a: #e5e5e5;
    --chart-line-b: #a3a3a3;
    --chart-fill-a: rgba(255, 255, 255, 0.08);
    --chart-fill-b: rgba(163, 163, 163, 0.08);
    --chart-grid: rgba(255, 255, 255, 0.06);
    --chart-tick: #a3a3a3;
    --range-active-border: rgba(212, 212, 212, 0.45);
    --range-active-bg: rgba(212, 212, 212, 0.1);
    --weather-hero: #e5e5e5;
    --weather-daily: #a3a3a3;
    /* Mono: warm vs cool neutrals (reads as max vs min without strong hue) */
    --weather-tmax-fg: #fafafa;
    --weather-tmax-bg: #363030;
    --weather-tmin-fg: #e8e8e8;
    --weather-tmin-bg: #2c3036;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-page);
    color: var(--text-main);
    overflow-x: hidden;
    line-height: 1.5;
}

.mono {
    font-family: 'JetBrains Mono', monospace;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-fade {
    animation: fadeIn 0.4s ease-out forwards;
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    max-width: min(var(--sidebar-width), 100vw);
    background: var(--sidebar-bg);
    backdrop-filter: blur(12px);
    border-right: 1px solid var(--glass-border);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    z-index: 100;
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 2rem;
    max-width: 1400px;
    min-width: 0;
    width: 100%;
}

/* Sidebar Branding */
a.brand {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

a.brand:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 3px;
    border-radius: 10px;
}

.brand {
    margin-bottom: 3rem;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.brand-icon {
    flex-shrink: 0;
    margin-top: 0.1rem;
    color: var(--brand-gradient-start);
}

.brand-text-block {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.brand-title-line {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    line-height: 1.2;
}

.brand-gradient-text {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--brand-gradient-start), var(--brand-gradient-end));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-cursor {
    display: inline-block;
    min-width: 0.5ch;
    animation: brand-cursor-blink 1.05s step-end infinite;
}

@keyframes brand-cursor-blink {
    0%,
    100% { opacity: 1; }
    50% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .brand-cursor {
        animation: none;
    }

    .sidebar {
        transition: none;
    }
}

.brand-version {
    margin: 0;
    font-size: 0.55rem;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
    opacity: 0.75;
    line-height: 1.2;
}

/* Nav Menu */
.nav-menu {
    list-style: none;
    flex: 1;
}

.nav-item {
    margin-bottom: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 12px;
    transition: all 0.2s ease;
    font-weight: 500;
    font-size: 0.9375rem;
}

.nav-link:hover {
    background: var(--nav-hover);
    color: var(--text-main);
}

.nav-theme-row {
    margin-bottom: 1rem;
    padding: 0 0.25rem;
}

.theme-select-label {
    display: block;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.theme-select {
    width: 100%;
    padding: 0.5rem 0.65rem;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
    background: var(--surface-ghost);
    color: var(--text-main);
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
}

.theme-select:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.timeframe-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-end;
    align-items: center;
}

#timeframe-selector .btn-ghost {
    padding: 0.25rem 0.75rem;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-radius: 8px;
    opacity: 0.85;
}

#timeframe-selector .btn-ghost.active {
    opacity: 1;
    color: var(--primary);
    border-color: var(--range-active-border);
    background: var(--range-active-bg);
}

.nav-link.active {
    background: var(--primary-glow);
    color: var(--primary);
    border: 1px solid rgba(56, 189, 248, 0.2);
}

.nav-link svg {
    width: 20px;
    height: 20px;
}

/* Table / modal icon actions — same stroke style as .nav-link svg */
.row-action-group {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.4rem;
}

#upload-detail-actions.row-action-group {
    display: flex;
    flex-wrap: wrap;
    margin-top: 1.25rem;
    justify-content: flex-end;
    gap: 0.5rem;
}

.row-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
    background: var(--surface-ghost);
    color: var(--text-muted);
    cursor: pointer;
    text-decoration: none;
    box-sizing: border-box;
    transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
    vertical-align: middle;
    font: inherit;
}

button.row-action {
    -webkit-appearance: none;
    appearance: none;
}

.row-action__icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    pointer-events: none;
}

.row-action:hover {
    background: var(--surface-ghost-hover);
    color: var(--text-main);
    border-color: var(--card-hover-border);
}

.row-action:focus-visible {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-glow);
}

.row-action--primary {
    color: var(--primary);
    border-color: rgba(2, 132, 199, 0.22);
}

html[data-theme="dark"] .row-action--primary {
    border-color: rgba(56, 189, 248, 0.22);
}

html[data-theme="mono"] .row-action--primary {
    border-color: rgba(212, 212, 212, 0.28);
}

.row-action--primary:hover {
    background: var(--primary-glow);
    color: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 0 12px var(--primary-glow);
    transform: translateY(-1px);
}

.row-action--accent {
    color: var(--accent);
    border-color: rgba(124, 58, 237, 0.22);
}

html[data-theme="dark"] .row-action--accent {
    border-color: rgba(192, 132, 252, 0.25);
}

html[data-theme="mono"] .row-action--accent {
    border-color: rgba(163, 163, 163, 0.28);
}

.row-action--accent:hover {
    background: var(--accent-glow);
    color: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 10px var(--accent-glow);
    transform: translateY(-1px);
}

@media (prefers-reduced-motion: reduce) {
    .row-action--primary:hover,
    .row-action--accent:hover {
        transform: none;
    }
}

.row-action--danger {
    color: var(--error);
    border-color: rgba(220, 38, 38, 0.18);
}

html[data-theme="dark"] .row-action--danger,
html[data-theme="mono"] .row-action--danger {
    border-color: rgba(239, 68, 68, 0.2);
}

.row-action--danger:hover {
    background: rgba(220, 38, 38, 0.1);
    border-color: var(--error);
    color: var(--error);
}

html[data-theme="dark"] .row-action--danger:hover,
html[data-theme="mono"] .row-action--danger:hover {
    background: rgba(239, 68, 68, 0.12);
}

.row-action--success {
    color: var(--success);
    border-color: rgba(21, 128, 61, 0.22);
}

html[data-theme="dark"] .row-action--success,
html[data-theme="mono"] .row-action--success {
    border-color: rgba(34, 197, 94, 0.22);
}

.row-action--success:hover {
    background: rgba(34, 197, 94, 0.12);
    color: var(--success);
    border-color: var(--success);
}

/* News table: headline + link icons on one row (icons top-right, title wraps in left column) */
.news-item-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.5rem 0.75rem;
    align-items: start;
    min-width: 0;
}

.news-item-head__main {
    display: flex;
    align-items: flex-start;
    gap: 0.45rem;
    min-width: 0;
}

.news-item-head__title {
    font-weight: 600;
    color: var(--text-main);
    min-width: 0;
    flex: 1 1 auto;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

/* Feed source mark (e.g. HN); more sources can be added later */
.news-source-badge {
    flex-shrink: 0;
    width: 1.4rem;
    height: 1.4rem;
    margin-top: 0.08rem;
    border-radius: 4px;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.news-source-badge--hn {
    background: #ff6600;
    color: #fff;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
}

.news-source-badge--hn .news-hn-y {
    font-family: "Inter", system-ui, -apple-system, sans-serif;
    font-size: 0.62rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.02em;
    user-select: none;
}

html[data-theme="mono"] .news-source-badge--hn {
    background: var(--text-muted);
    color: var(--bg-page);
    box-shadow: none;
}

.news-source-badge--img {
    background: var(--bg-elevated, var(--bg-page));
    box-shadow: 0 0 0 1px var(--glass-border, rgba(0, 0, 0, 0.12));
    padding: 0;
    overflow: hidden;
}

.news-source-badge__img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 3px;
}

.news-source-badge--txt {
    background: var(--text-muted);
    color: var(--bg-page, #fff);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
    font-size: 0.5rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: 0.02em;
    font-family: "Inter", system-ui, -apple-system, sans-serif;
}

html[data-theme="dark"] .news-source-badge--img,
html[data-theme="mono"] .news-source-badge--img {
    box-shadow: 0 0 0 1px var(--glass-border, rgba(255, 255, 255, 0.12));
}

html[data-theme="mono"] .news-source-badge--img {
    background: var(--bg-page);
}

html[data-theme="mono"] .news-source-badge--txt {
    background: var(--text-muted);
    color: var(--bg-page);
    box-shadow: none;
}

.news-item-head .row-action-group {
    margin: 0;
    justify-content: flex-end;
}

@media (min-width: 641px) {
    .data-table--news .news-td--date {
        white-space: nowrap;
    }
}

.rss-feed-status-wrap {
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.08));
}

.rss-feed-status-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.rss-feed-status-list li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    line-height: 1.3;
    color: var(--text);
}

.rss-feed-led {
    display: inline-block;
    width: 10px;
    height: 10px;
    min-width: 10px;
    min-height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 4px currentColor;
}

.rss-feed-led--ok {
    color: var(--success);
    background: var(--success);
}

.rss-feed-led--err {
    color: var(--error);
    background: var(--error);
}

.rss-feed-status-name {
    flex: 1;
    min-width: 0;
    word-break: break-word;
}

.news-toolbar {
    min-width: 0;
}

.news-toolbar .news-search-wrap {
    min-width: 0;
}

.news-toolbar-actions {
    min-width: 0;
}

.news-fetch-info {
    line-height: 1.35;
}

/* News: stack rows as cards on narrow viewports */
@media (max-width: 640px) {
    .news-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .news-toolbar-actions {
        width: 100%;
        justify-content: space-between;
    }

    .news-fetch-info {
        flex: 1 1 12rem;
        min-width: 0;
    }

    .data-table-wrap.news-table-wrap {
        overflow-x: visible;
    }

    .data-table--news,
    .data-table--news thead,
    .data-table--news tbody,
    .data-table--news tr,
    .data-table--news th,
    .data-table--news td {
        display: block;
        width: 100%;
    }

    .data-table--news thead {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        border: 0;
    }

    .data-table--news tbody tr.news-row:not(.news-row--empty) {
        border: 1px solid var(--glass-border);
        border-radius: 10px;
        margin-bottom: 0.75rem;
        overflow: hidden;
        background: var(--bg-card, rgba(255, 255, 255, 0.04));
    }

    .data-table--news tbody tr.news-row:not(.news-row--empty) td {
        border: none;
    }

    .data-table--news .news-td--title {
        padding: 0.75rem 1rem 0.5rem 1rem !important;
    }

    .data-table--news .news-td--date,
    .data-table--news .news-td--actions:not(.hidden) {
        padding: 0.4rem 1rem 0.75rem 1rem !important;
        text-align: left !important;
    }

    .data-table--news .news-td--date::before,
    .data-table--news .news-td--actions:not(.hidden)::before {
        content: attr(data-label);
        display: block;
        font-size: 0.65rem;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: var(--text-muted);
        margin-bottom: 0.2rem;
        font-weight: 600;
    }
}

/* Shared list tables: tighter cells on small screens (horizontal scroll kept) */
@media (max-width: 640px) {
    .data-table-wrap {
        -webkit-overflow-scrolling: touch;
    }

    .data-table-wrap .data-table:not(.data-table--news) th,
    .data-table-wrap .data-table:not(.data-table--news) td {
        padding: 0.5rem 0.5rem;
        font-size: 0.8rem;
    }

    .data-table-wrap .data-table.data-table--progtodo th,
    .data-table-wrap .data-table.data-table--progtodo td {
        padding: 0.55rem 0.7rem;
    }
    .data-table-wrap .data-table.data-table--progtodo td + td,
    .data-table-wrap .data-table.data-table--progtodo th + th {
        padding-left: 0.85rem;
    }
}

/* Status Badges */
.status-area {
    margin-top: auto;
    padding-top: 2rem;
    border-top: 1px solid var(--glass-border);
}

.badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.badge-online { color: var(--primary); border-color: rgba(56, 189, 248, 0.2); }
/* Some (not all) configured IRC networks connected — distinct from fully offline. */
.badge-warning { color: #fbbf24; border-color: rgba(251, 191, 36, 0.3); }
.badge-admin { color: var(--accent); border-color: rgba(192, 132, 252, 0.2); }

/* Active admins: IRC vs web dashboard (colored themes = hue difference; mono = light vs dark gray) */
.admin-src-label {
    font-size: 0.55rem;
    opacity: 0.85;
    font-weight: 700;
    letter-spacing: 0.06em;
}

html[data-theme="dark"] .badge-admin-irc {
    color: var(--accent);
    border-color: rgba(192, 132, 252, 0.35);
    background: rgba(192, 132, 252, 0.06);
}
html[data-theme="dark"] .badge-admin-web {
    color: var(--primary);
    border-color: rgba(56, 189, 248, 0.35);
    background: rgba(56, 189, 248, 0.08);
}

html[data-theme="light"] .badge-admin-irc {
    color: var(--accent);
    border-color: rgba(124, 58, 237, 0.35);
    background: rgba(124, 58, 237, 0.08);
}
html[data-theme="light"] .badge-admin-web {
    color: var(--primary);
    border-color: rgba(2, 132, 199, 0.4);
    background: rgba(2, 132, 199, 0.1);
}

html[data-theme="mono"] .badge-admin-irc {
    color: #525252;
    border-color: rgba(82, 82, 82, 0.5);
    background: rgba(0, 0, 0, 0.25);
}
html[data-theme="mono"] .badge-admin-web {
    color: #e5e5e5;
    border-color: rgba(229, 229, 229, 0.35);
    background: rgba(255, 255, 255, 0.06);
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

.pulse {
    animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
    0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(34, 197, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* Content Sections */
.panel {
    display: none;
    animation: fadeIn 0.4s ease-out;
}

.panel.active {
    display: block;
}

.section-header {
    margin-bottom: 2rem;
}

.section-title {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-main);
}

.section-subtitle {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Cards Grid */
.grid {
    display: grid;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.grid-4 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); }

.card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 1.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.card:hover {
    border-color: var(--card-hover-border);
}

.card-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 1rem;
}

.card-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

/* Utils */
.btn {
    padding: 0.625rem 1.25rem;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary);
    color: var(--bg-dark);
}

.btn-primary:hover {
    box-shadow: 0 0 20px var(--primary-glow);
    transform: translateY(-1px);
}

.btn-ghost {
    background: var(--surface-ghost);
    color: var(--text-main);
    border: 1px solid var(--glass-border);
}

.btn-ghost:hover {
    background: var(--surface-ghost-hover);
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

input.btn-ghost:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-glow);
    background: rgba(255, 255, 255, 0.08);
}

/* Mobile top bar & drawer backdrop */
.mobile-top-bar {
    display: none;
}

.mobile-top-bar__menu {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
    background: var(--surface-ghost);
    color: var(--text-main);
    cursor: pointer;
    flex-shrink: 0;
}

.mobile-top-bar__menu:hover {
    background: var(--surface-ghost-hover);
}

.mobile-top-bar__menu:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.mobile-top-bar__title {
    font-size: 1.125rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--brand-gradient-start), var(--brand-gradient-end));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-decoration: none;
    cursor: pointer;
}

a.mobile-top-bar__title:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 3px;
    border-radius: 6px;
}

.sidebar-backdrop {
    display: none;
}

/* Responsive */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        height: 100dvh;
        max-height: 100dvh;
        padding-top: calc(2rem + env(safe-area-inset-top, 0px));
        padding-bottom: calc(2rem + env(safe-area-inset-bottom, 0px));
        box-shadow: none;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 8px 0 32px rgba(0, 0, 0, 0.35);
    }

    .sidebar-backdrop:not(.hidden) {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 99;
        background: rgba(0, 0, 0, 0.45);
        backdrop-filter: blur(2px);
    }

    .main-content {
        margin-left: 0;
        padding: 1.5rem;
    }

    .mobile-top-bar {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        position: sticky;
        top: 0;
        z-index: 80;
        margin: -1.5rem -1.5rem 1.25rem -1.5rem;
        padding: 0.65rem 1rem;
        padding-top: calc(0.65rem + env(safe-area-inset-top, 0px));
        background: var(--sidebar-bg);
        border-bottom: 1px solid var(--glass-border);
        backdrop-filter: blur(12px);
    }

    .grid-2 {
        grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
    }
}

@media (min-width: 1025px) {
    .sidebar-backdrop {
        display: none !important;
    }
}

/* Log styles refactored for new design */
#log-outputs-wrapper {
    background: var(--log-wrapper-bg);
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    padding: 1rem;
}

.log-entry {
    font-size: 0.8125rem;
    line-height: 1.4;
    padding: 0.125rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.01);
}

/* Finance panel */
.finance-top-grid {
    margin-bottom: 0;
}

.finance-chart-card {
    margin-top: 1rem;
    width: 100%;
}

.finance-chart-card .crypto-chart-canvas-wrap {
    height: 280px;
}

.finance-chart-card .forex-charts-grid-wrap {
    height: auto;
    min-height: 280px;
}

.forex-charts-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem 1rem;
    width: 100%;
}

.forex-mini-chart-cell {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 200px;
}

.forex-mini-chart-title {
    margin: 0 0 0.35rem 0;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

.forex-mini-chart-canvas-wrap {
    position: relative;
    flex: 1;
    min-height: 160px;
    width: 100%;
}

@media (max-width: 720px) {
    .forex-charts-grid {
        grid-template-columns: 1fr;
    }
}

.finance-card-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.75rem;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.finance-card-title {
    margin: 0;
}

.finance-last-update {
    font-size: 0.65rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.finance-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.finance-list--grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
}

.finance-list--grid > .finance-row {
    min-width: 0;
}

.crypto-chart-stack {
    margin-bottom: 1rem;
}

.crypto-chart-subtitle {
    font-size: 0.65rem;
    color: var(--text-muted);
    line-height: 1.35;
    margin: 0 0 0.5rem 0;
}

.crypto-range-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.75rem;
}

.crypto-range-btn {
    padding: 0.25rem 0.55rem;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-radius: 8px;
    opacity: 0.85;
}

.crypto-range-btn.active {
    opacity: 1;
    color: var(--primary);
    border-color: var(--range-active-border);
    background: var(--range-active-bg);
}

.crypto-chart-canvas-wrap {
    position: relative;
    height: 240px;
    width: 100%;
    margin-bottom: 0.25rem;
}

.finance-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1rem;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.finance-row:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
    border-color: rgba(56, 189, 248, 0.22);
}

.finance-row-crypto {
    border-left: 3px solid var(--accent);
}

.finance-row-forex {
    border-left: 3px solid var(--primary);
}

.finance-row-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
    flex: 1;
}

.finance-row-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.35rem;
    flex-shrink: 0;
}

.finance-icon-slot {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 12px;
    background: rgba(192, 132, 252, 0.14);
    color: var(--accent);
    flex-shrink: 0;
}

.finance-lucide {
    width: 1.25rem;
    height: 1.25rem;
}

.finance-labels {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 0.1rem;
}

.finance-symbol {
    font-weight: 700;
    font-size: 0.95rem;
}

.finance-name {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 14rem;
}

.finance-price {
    font-weight: 600;
    font-size: 0.95rem;
}

.finance-change-pill {
    font-size: 0.7rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
}

.finance-change-pill.price-up {
    color: var(--success);
    background: rgba(34, 197, 94, 0.16);
}

.finance-change-pill.price-down {
    color: var(--error);
    background: rgba(239, 68, 68, 0.16);
}

.finance-flags {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.finance-flag.fi {
    width: 1.35em;
    height: 1.35em;
    line-height: 1;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.finance-forex-pair {
    font-weight: 700;
    font-size: 0.9rem;
}

.finance-hint {
    display: inline-block;
    margin-top: 0.2rem;
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--primary);
    background: rgba(56, 189, 248, 0.12);
    padding: 0.12rem 0.45rem;
    border-radius: 6px;
    width: fit-content;
}

@media (max-width: 520px) {
    .finance-list--grid {
        grid-template-columns: 1fr;
    }

    .finance-row {
        flex-direction: column;
        align-items: stretch;
    }

    .finance-row-right {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .finance-name {
        max-width: 100%;
    }

    .crypto-chart-canvas-wrap {
        height: 200px;
    }
}

.price-up { color: var(--success); }
.price-down { color: var(--error); }

.text-success { color: var(--success); }
.text-error { color: var(--error); }
.text-primary { color: var(--primary); }

/* Logs panel */
.logs-workspace {
    display: grid;
    grid-template-columns: minmax(220px, 280px) 1fr;
    gap: 1.25rem;
    align-items: stretch;
}

@media (max-width: 900px) {
    .logs-workspace {
        grid-template-columns: 1fr;
    }

    .logs-viewer-placeholder,
    .logs-viewer {
        height: clamp(260px, min(48vh, calc(100vh - 17rem)), 600px);
        max-height: min(600px, calc(100vh - 17rem));
        height: clamp(260px, min(48dvh, calc(100dvh - 17rem)), 600px);
        max-height: min(600px, calc(100dvh - 17rem));
    }
}

.logs-sidebar {
    padding: 1.25rem;
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 6rem);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.logs-sidebar-head {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.logs-sidebar-hint {
    font-size: 0.65rem;
    color: var(--text-muted);
}

.logs-filter-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.25);
    color: var(--text-main);
    font-size: 0.85rem;
}

.logs-channel-groups {
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 120px;
}

.logs-group-title {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.logs-channel-row {
    width: 100%;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.45rem 0.6rem;
    margin-bottom: 0.25rem;
    border-radius: 8px;
    border: 1px solid transparent;
    background: rgba(0, 0, 0, 0.15);
    color: var(--text-main);
    cursor: pointer;
    font-size: 0.8rem;
    transition: border-color 0.15s, background 0.15s;
}

.logs-channel-row:hover {
    border-color: var(--glass-border);
    background: rgba(56, 189, 248, 0.08);
}

.logs-channel-row.active {
    border-color: var(--primary);
    background: rgba(56, 189, 248, 0.12);
}

.logs-channel-row .mono {
    font-weight: 600;
}

.logs-channel-meta {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.log-badge {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    letter-spacing: 0.04em;
}

.log-badge-live {
    color: var(--success);
    background: rgba(34, 197, 94, 0.15);
}

.log-badge-live .dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
    margin-right: 0.25rem;
    vertical-align: middle;
}

.log-badge-live .dot.pulse {
    animation: pulse-ring 2s infinite;
}

.log-badge-disk {
    color: var(--text-muted);
    background: rgba(148, 163, 184, 0.12);
}

.logs-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Same outer height for placeholder and viewer so layout does not jump by log volume */
.logs-viewer-placeholder,
.logs-viewer {
    box-sizing: border-box;
    height: clamp(280px, min(56vh, calc(100vh - 13rem)), 720px);
    max-height: min(720px, calc(100vh - 13rem));
    height: clamp(280px, min(56dvh, calc(100dvh - 13rem)), 720px);
    max-height: min(720px, calc(100dvh - 13rem));
}

.logs-viewer-placeholder {
    padding: 2.5rem;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logs-viewer {
    padding: 0;
    overflow: visible; /* hidden would clip the calendar popover */
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.logs-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    background: rgba(255, 255, 255, 0.04);
    border-bottom: 1px solid var(--glass-border);
}

.logs-toolbar-left {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.logs-view-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0;
}

.logs-view-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.logs-toolbar-right {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.log-calendar-wrap {
    position: relative;
}

.log-calendar-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
}

.log-calendar-btn-icon::before {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 1.5px solid var(--primary);
    box-shadow: inset 0 -3px 0 var(--accent);
}

.log-calendar-popover {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    z-index: 50;
    width: min(300px, calc(100vw - 2rem));
    padding: 0.85rem;
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.log-calendar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.65rem;
}

.log-cal-nav {
    padding: 0.2rem 0.55rem;
    font-size: 1rem;
    line-height: 1;
}

.log-cal-month-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-main);
}

.log-cal-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    font-size: 0.55rem;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 0.35rem;
}

.log-cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.log-cal-cell {
    aspect-ratio: 1;
    max-height: 36px;
    border: none;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
    color: var(--text-main);
    font-size: 0.72rem;
    font-family: inherit;
    cursor: pointer;
    position: relative;
    transition: background 0.12s, color 0.12s;
}

.log-cal-cell:hover:not(:disabled) {
    background: rgba(56, 189, 248, 0.2);
}

.log-cal-cell:disabled {
    opacity: 0.28;
    cursor: not-allowed;
}

.log-cal-cell.today {
    box-shadow: inset 0 0 0 1px var(--primary);
}

.log-cal-cell.selected {
    background: rgba(56, 189, 248, 0.35);
    color: var(--bg-dark);
    font-weight: 700;
}

.log-cal-cell.has-log::after {
    content: '';
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--accent);
}

.log-cal-footnote {
    margin-top: 0.65rem;
    font-size: 0.6rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.logs-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 1rem;
    font-size: 0.78rem;
    line-height: 1.45;
    background: rgba(0, 0, 0, 0.18);
}

.log-line {
    padding: 0.08rem 0;
    word-break: break-word;
}

.logs-toolbar { border-radius: inherit; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.logs-scroll { border-bottom-left-radius: inherit; border-bottom-right-radius: inherit; }

/* Phones: the calendar becomes a bottom sheet so it never runs off-screen, and inputs use
   16px so iOS Safari doesn't zoom the page on focus. */
@media (max-width: 640px) {
    .log-calendar-popover {
        position: fixed;
        left: 1rem;
        right: 1rem;
        top: auto;
        bottom: calc(1rem + env(safe-area-inset-bottom));
        width: auto;
        max-width: 420px;
        margin: 0 auto;
    }
    .log-cal-cell { max-height: none; font-size: 0.9rem; }
    .log-cal-weekdays { font-size: 0.7rem; }
    .logs-toolbar { padding: 0.65rem 0.75rem; }
    .logs-scroll { padding: 0.65rem; font-size: 0.72rem; }
    .logs-sidebar { position: static; max-height: 45vh; padding: 1rem; }
    input, select, textarea { font-size: 16px; }
}

/* Programmer TODOs (panel-todos) */
.data-table-wrap .data-table--progtodo th.progtodo-th,
.data-table-wrap .data-table--progtodo td {
    padding: 0.75rem 1.25rem;
}
.data-table-wrap .data-table--progtodo td + td,
.data-table-wrap .data-table--progtodo th + th {
    padding-left: 1.5rem;
}
.progtodo-toolbar .progtodo-counts {
    font-variant-numeric: tabular-nums;
}

.progtodo-strike,
.progtodo-row--disabled .progtodo-strike {
    text-decoration: line-through;
    opacity: 0.8;
}
.progtodo-row--disabled td {
    color: var(--text-muted);
}
.progtodo-badge {
    display: inline-block;
    font-size: 0.65rem;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}
.progtodo-badge--imp-high {
    color: #fecaca;
    background: rgba(220, 38, 38, 0.25);
}
.progtodo-badge--imp-medium {
    color: #fde68a;
    background: rgba(217, 119, 6, 0.2);
}
.progtodo-badge--imp-low {
    color: #a5b4fc;
    background: rgba(79, 70, 229, 0.2);
}
.progtodo-badge--rev-pending {
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.12);
}
.progtodo-badge--rev-approved {
    color: #86efac;
    background: rgba(22, 163, 74, 0.2);
}
.progtodo-badge--rev-rejected {
    color: #fca5a5;
    background: rgba(185, 28, 28, 0.2);
}
.progtodo-badge--priv {
    color: #c4b5fd;
    background: rgba(91, 33, 182, 0.25);
}

/* Server location weather (theme uses --primary / --accent for SVG currentColor) */
.weather-card__head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem 1.5rem;
    margin-bottom: 1rem;
}
.weather-card__titles {
    min-width: 0;
    flex: 1;
}
.weather-card__place {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0;
}
.weather-card__hero-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.35rem;
    flex-shrink: 0;
    text-align: right;
}
.weather-card__hero-icon {
    width: 3.75rem;
    height: 3.75rem;
    color: var(--weather-hero, var(--primary));
}
.weather-card__hero-readout {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.2rem;
    min-width: 0;
    max-width: 11rem;
}
.weather-card__hero-temp {
    font-size: 1.9rem;
    font-weight: 800;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    color: var(--text-main);
}
.weather-card__hero-label {
    margin: 0;
    font-size: 0.62rem;
    font-weight: 700;
    line-height: 1.2;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    text-align: right;
    text-wrap: balance;
}
.weather-card__hero-extras {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.15rem;
    margin-top: 0.2rem;
    min-height: 0;
}
.weather-card__hero-extras:empty {
    display: none;
    margin: 0;
}
.weather-card__hero-extra {
    margin: 0;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.3;
    color: var(--text-main);
    opacity: 0.9;
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.weather-card__hero-extra--muted {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 500;
    opacity: 1;
}
.weather-card__hero-icon .weather-icon-svg,
.weather-daily__icon .weather-icon-svg {
    width: 100%;
    height: 100%;
    display: block;
}
.weather-card__loading {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}
.weather-card__error {
    margin: 0 0 0.5rem 0;
    color: var(--error);
    font-size: 0.85rem;
}
.weather-card__body {
    padding-top: 0.15rem;
}
.weather-card__meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin: 0 0 1.1rem 0;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--glass-border);
}
.weather-daily {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.5rem 0.35rem;
    margin-bottom: 0.75rem;
}
@media (max-width: 720px) {
    .weather-daily {
        grid-template-columns: repeat(2, 1fr);
    }
}
.weather-daily__cell {
    text-align: center;
    padding: 0.5rem 0.25rem;
    border-radius: 8px;
    background: var(--surface-ghost);
    border: 1px solid var(--glass-border);
}
.weather-daily__icon {
    width: 2rem;
    height: 2rem;
    margin: 0 auto 0.2rem;
    color: var(--weather-daily, var(--accent));
}
.weather-daily__word {
    font-size: 0.58rem;
    font-weight: 700;
    line-height: 1.15;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin: 0 auto 0.25rem;
    max-width: 100%;
    text-align: center;
    text-wrap: balance;
}
.weather-daily__dow {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 0.2rem;
}
.weather-daily__temps {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.2rem 0.25rem;
    font-size: 0.78rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    line-height: 1.35;
}
.weather-daily__temps-sep {
    color: var(--text-muted);
    font-weight: 500;
    opacity: 0.75;
    padding: 0 0.02rem;
}
.weather-temp-pill {
    display: inline-block;
    padding: 0.12rem 0.4rem;
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.76rem;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
    border: 1px solid transparent;
}
.weather-temp-pill--max {
    color: var(--weather-tmax-fg);
    background: var(--weather-tmax-bg);
    border-color: var(--glass-border);
}
.weather-temp-pill--min {
    color: var(--weather-tmin-fg);
    background: var(--weather-tmin-bg);
    border-color: var(--glass-border);
}
.weather-card__today-range {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.2rem;
    margin-top: 0.2rem;
    text-align: right;
    max-width: 11rem;
}
.weather-card__today-range.hidden {
    display: none !important;
}
.weather-today__row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.25rem 0.35rem;
    font-size: 0.72rem;
    line-height: 1.35;
}
.weather-today__label {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin: 0;
}
.weather-daily__pop {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}
.weather-card__attr {
    margin: 0;
    font-size: 0.7rem;
    color: var(--text-muted);
}
.weather-card__link {
    color: var(--primary);
    text-decoration: none;
    border-bottom: 1px solid transparent;
}
.weather-card__link:hover {
    border-bottom-color: var(--primary);
}

.hidden {
    display: none !important;
}

/* Channel Stats */
.cs-controls { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.cs-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.cs-chip { display: inline-flex; align-items: baseline; gap: 0.4rem; padding: 0.35rem 0.85rem; border-radius: 999px; border: 1px solid var(--glass-border); background: var(--surface-ghost); color: var(--text-main); font-size: 0.8rem; font-weight: 600; cursor: pointer; transition: border-color .15s, background .15s; }
.cs-chip:hover { background: var(--surface-ghost-hover); }
.cs-chip.active { color: var(--primary); border-color: var(--range-active-border); background: var(--range-active-bg); }
.cs-chip small { color: var(--text-muted); font-weight: 500; font-size: 0.7rem; }
#cs-range .btn-ghost { padding: 0.25rem 0.75rem; font-size: 0.65rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; border-radius: 8px; opacity: 0.85; }
#cs-range .btn-ghost.active { opacity: 1; color: var(--primary); border-color: var(--range-active-border); background: var(--range-active-bg); }
.cs-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.cs-kpi { background: var(--bg-card); border: 1px solid var(--glass-border); border-radius: 16px; padding: 1rem 1.1rem; }
.cs-kpi__label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); font-weight: 700; }
.cs-kpi__value { font-size: 1.6rem; font-weight: 700; color: var(--text-main); line-height: 1.2; margin-top: 0.25rem; }
.cs-kpi__sub { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.15rem; }
.cs-hint { text-transform: none; letter-spacing: 0; font-weight: 500; margin-left: 0.5rem; opacity: 0.8; }
.cs-chart { position: relative; height: 240px; }
.cs-chart--tall { height: 300px; }
.cs-wide { margin-bottom: 1.5rem; }
.cs-heat { display: grid; grid-template-columns: 2.2rem repeat(24, 1fr); gap: 3px; align-items: center; font-size: 0.65rem; color: var(--text-muted); }
.cs-heat__cell { aspect-ratio: 1; border-radius: 4px; min-height: 12px; transition: transform .1s; }
.cs-heat__cell:hover { transform: scale(1.35); outline: 1px solid var(--text-main); z-index: 1; }
.cs-heat__hour { text-align: center; }
.cs-modes { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 0.6rem; }
.cs-mode { border: 1px solid var(--glass-border); border-radius: 12px; padding: 0.55rem 0.7rem; background: var(--surface-ghost); }
.cs-mode b { display: block; font-size: 1.15rem; color: var(--text-main); }
.cs-mode span { font-size: 0.75rem; font-weight: 700; }
.cs-mode--plus span { color: var(--success); }
.cs-mode--minus span { color: var(--error); }
.cs-modeby { grid-column: 1 / -1; font-size: 0.78rem; color: var(--text-muted); }
.cs-topics { display: flex; flex-direction: column; gap: 0.6rem; max-height: 260px; overflow: auto; }
.cs-topic { font-size: 0.8rem; border-left: 3px solid var(--accent); padding-left: 0.7rem; color: var(--text-main); word-break: break-word; }
.cs-topic small { display: block; color: var(--text-muted); font-size: 0.7rem; }
.cs-none { color: var(--text-muted); font-size: 0.85rem; }
.cs-tip { position: fixed; z-index: 1000; pointer-events: none; background: var(--bg-dark); color: #f1f5f9; border: 1px solid var(--glass-border); border-radius: 10px; padding: 0.5rem 0.7rem; font-size: 0.75rem; line-height: 1.45; box-shadow: 0 8px 24px rgba(0,0,0,.35); max-width: 260px; }
.cs-tip.hidden { display: none; }
.cs-tip b { color: #fff; }
@media (max-width: 720px) { .cs-heat { grid-template-columns: 1.6rem repeat(24, 1fr); gap: 2px; } .cs-heat__hour:nth-child(even) { visibility: hidden; } }

/* ---- Auth dialogs (admin sign-in, forced password change) ---- */
#modal-overlay { padding: 16px; overflow-y: auto; }
.auth-card {
    width: 100%;
    max-width: 400px;
    padding: 2rem 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: auto;
}
.auth-badge {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    color: #fff;
    background: linear-gradient(135deg, var(--brand-gradient-start), var(--brand-gradient-end));
    box-shadow: 0 8px 24px var(--primary-glow);
}
.auth-title { font-size: 1.5rem; line-height: 1.2; margin: 0.25rem 0 0; color: var(--text-main); }
.auth-sub { color: var(--text-muted); font-size: 0.875rem; line-height: 1.5; margin: -0.5rem 0 0.25rem; }
.field { display: flex; flex-direction: column; gap: 0.4rem; }
.field label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}
.input {
    width: 100%;
    padding: 0.7rem 0.9rem;
    font: inherit;
    font-size: 0.95rem;
    color: var(--text-main);
    background: var(--surface-ghost);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.input::placeholder { color: var(--text-muted); }
.input:focus-visible {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 2.75rem; }
.input-toggle {
    position: absolute;
    top: 50%;
    right: 0.35rem;
    transform: translateY(-50%);
    width: 2.25rem;
    height: 2.25rem;
    display: grid;
    place-items: center;
    color: var(--text-muted);
    background: none;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}
.input-toggle:hover { color: var(--text-main); background: var(--surface-ghost-hover); }
.input-toggle:focus-visible { outline: 2px solid var(--primary); }
.field-hint { font-size: 0.75rem; color: var(--text-muted); }
.auth-error {
    font-size: 0.8rem;
    line-height: 1.4;
    color: var(--error);
    background: color-mix(in srgb, var(--error) 10%, transparent);
    border: 1px solid color-mix(in srgb, var(--error) 35%, transparent);
    border-radius: 10px;
    padding: 0.6rem 0.8rem;
}
.auth-submit { justify-content: center; width: 100%; padding: 0.75rem 1.25rem; margin-top: 0.25rem; }
.auth-submit.is-loading { pointer-events: none; opacity: 0.85; }
.auth-cancel {
    align-self: center;
    background: none;
    border: none;
    color: var(--text-muted);
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.4rem 0.75rem;
    border-radius: 8px;
    cursor: pointer;
}
.auth-cancel:hover { color: var(--text-main); background: var(--surface-ghost); }
.auth-cancel:focus-visible { outline: 2px solid var(--primary); }
.btn-spinner {
    display: none;
    width: 1em;
    height: 1em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: btn-spin 0.7s linear infinite;
}
.is-loading .btn-spinner { display: inline-block; }
@keyframes btn-spin { to { transform: rotate(360deg); } }
@media (max-width: 640px) {
    .auth-card { padding: 1.5rem 1.25rem 1.25rem; }
    .input { font-size: 16px; } /* >=16px stops iOS Safari zooming on focus */
}
@media (prefers-reduced-motion: reduce) {
    .btn-spinner { animation-duration: 1.6s; }
}

/* Admin page tabs */
.admin-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--glass-border);
    overflow-x: auto;
}
.admin-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    padding: 0.6rem 1rem;
    font: inherit;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
}
.admin-tab:hover { color: var(--text-main); }
.admin-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.admin-tab-off { display: none !important; }

/* IRC network add/edit form */
.net-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.net-hint { color: var(--text-muted); font-size: 0.85rem; line-height: 1.45; margin: 0.35rem 0 0.75rem; }
.net-form {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--glass-border);
}
.net-form-title { margin: 0 0 1rem; font-size: 1.05rem; color: var(--text-main); }
.net-section {
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 0.9rem 1rem 1rem;
    margin: 0 0 1rem;
    min-width: 0;
}
.net-section legend {
    padding: 0 0.4rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}
.net-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 14rem), 1fr));
    gap: 0.75rem 1rem;
    margin-bottom: 0.5rem;
}
.net-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-main);
    min-width: 0;
}
.net-field input,
.net-field select,
.net-field textarea,
.net-advanced select {
    width: 100%;
    margin: 0;
    text-align: left;
    cursor: text;
    font-weight: 400;
    min-width: 0;
}
.net-field select, .net-advanced select { cursor: pointer; }
.net-field textarea { font-size: 0.75rem; padding: 0.5rem; border-radius: 10px; }
.net-field small, .net-check small { font-weight: 400; color: var(--text-muted); font-size: 0.75rem; }
.net-optional { font-weight: 400; color: var(--text-muted); font-size: 0.72rem; }
.net-check {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: baseline;
    gap: 0.15rem 0.5rem;
    margin: 0.5rem 0 0;
    font-size: 0.85rem;
    color: var(--text-main);
    cursor: pointer;
}
.net-check small { grid-column: 2; }
.net-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }
.net-actions .btn { padding: 0.5rem 1rem; }
.net-details summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-main);
}
.net-details[open] summary { margin-bottom: 0.5rem; }
.net-advanced { margin-top: 0.85rem; }
.net-advanced summary { cursor: pointer; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.net-status { font-size: 0.75rem; color: var(--text-muted); white-space: pre-line; margin: 0.25rem 0 0.5rem; }
.net-form-footer { margin-top: 0; padding-top: 1rem; border-top: 1px solid var(--glass-border); }

@media (max-width: 640px) {
    .net-actions .btn { flex: 1 1 auto; justify-content: center; }
}
