/* ── Themes ── */
:root, [data-theme="dark"] {
    --bg: #0f1117;
    --bg-surface: #161b22;
    --bg-surface-2: #1c2128;
    --border: #30363d;
    --border-row: #21262d;
    --text: #c9d1d9;
    --text-muted: #8b949e;
    --text-dim: #484f58;
    --accent: #58a6ff;
    --service-color: #79c0ff;
}
[data-theme="light"] {
    --bg: #f6f8fa;
    --bg-surface: #ffffff;
    --bg-surface-2: #f0f2f5;
    --border: #d0d7de;
    --border-row: #e8ecf0;
    --text: #1f2328;
    --text-muted: #57606a;
    --text-dim: #a0a7b0;
    --accent: #0969da;
    --service-color: #0550ae;
}

/* ── Reset ── */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', system-ui, sans-serif;
    font-size: 14px;
    transition: background 0.2s, color 0.2s;
}

/* ── Header ── */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 24px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
}
.header-left { display: flex; align-items: center; gap: 10px; }
.header-logo { width: 28px; height: 28px; flex-shrink: 0; }
.header-title {
    font-size: 18px; font-weight: 700;
    color: var(--accent); letter-spacing: 1px; text-decoration: none;
}
.header-title:hover { opacity: 0.85; }
.header-right { display: flex; gap: 14px; align-items: center; color: var(--text-muted); font-size: 13px; }
.user-name { color: var(--text-muted); }
.logout-link { color: var(--accent); text-decoration: none; }
.logout-link:hover { text-decoration: underline; }
.btn-nav {
    color: var(--text); text-decoration: none; font-size: 13px;
    padding: 4px 12px; border: 1px solid var(--border); border-radius: 6px;
    transition: border-color 0.15s, background 0.15s;
}
.btn-nav:hover { border-color: var(--accent); background: var(--bg-surface-2); }
#theme-toggle {
    background: none; border: 1px solid var(--border); border-radius: 6px;
    cursor: pointer; font-size: 16px; padding: 2px 8px; line-height: 1.6;
    transition: border-color 0.15s;
}
#theme-toggle:hover { border-color: var(--accent); }

/* ── Icon button (gear etc.) ── */
.btn-icon {
    background: none; border: 1px solid var(--border); border-radius: 6px;
    cursor: pointer; color: var(--text-muted);
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    text-decoration: none; flex-shrink: 0;
    transition: border-color 0.15s, color 0.15s;
}
.btn-icon:hover  { border-color: var(--accent); color: var(--text); }
.btn-icon-active { border-color: var(--accent); color: var(--accent); }

/* ── Main ── */
main { padding: 16px 24px; }

/* ═══════════════════════════════════════════════════════════════════════════
   FILTER BAR + TABLE — общая сетка колонок:
   dt(170px) | svc(88px) | defcon(105px) | logtext(1fr) | other(215px) | reset(auto)
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Filter bar ── */
.filter-bar {
    display: grid;
    grid-template-columns: 170px 88px 105px 1fr 215px auto;
    align-items: end;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 6px 6px 0 0;
    border-bottom: none;
    padding: 10px 0;
}

.filter-spacer { /* пустая ячейка под # */ }

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0 14px; /* совпадает с padding таблицы */
}
.filter-group label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    white-space: nowrap;
}
.filter-group input[type="text"] {
    width: 100%;
    background: var(--bg-surface-2);
    border: 1px solid var(--border);
    border-radius: 5px;
    color: var(--text);
    font-size: 13px;
    padding: 4px 8px;
    outline: none;
    transition: border-color 0.15s;
}
.filter-group input[type="text"]:focus { border-color: var(--accent); }

.filter-reset-group { justify-content: flex-end; }
.btn-reset {
    background: none; border: 1px solid var(--border); border-radius: 5px;
    color: var(--text-muted); cursor: pointer; font-size: 13px; padding: 4px 12px;
    transition: border-color 0.15s, color 0.15s; white-space: nowrap;
}
.btn-reset:hover { border-color: var(--accent); color: var(--text); }

/* ── Dropdown (сервис / критичность) ── */
.dropdown { position: relative; }
.dropdown-btn {
    width: 100%;
    background: var(--bg-surface-2); border: 1px solid var(--border); border-radius: 5px;
    color: var(--text); cursor: pointer; font-size: 13px; padding: 4px 8px;
    text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    transition: border-color 0.15s;
}
.dropdown-btn:hover, .dropdown.open .dropdown-btn { border-color: var(--accent); }
.dropdown-menu {
    display: none; position: absolute; top: calc(100% + 4px); left: 0;
    background: var(--bg-surface); border: 1px solid var(--border); border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4); z-index: 100; min-width: 130px; padding: 4px 0;
}
.dropdown.open .dropdown-menu { display: block; }
.dd-item {
    display: flex; align-items: center; gap: 8px; padding: 5px 12px;
    cursor: pointer; font-size: 13px; transition: background 0.1s;
}
.dd-item:hover { background: var(--bg-surface-2); }
.dd-item input[type="checkbox"] { cursor: pointer; accent-color: var(--accent); }
.dd-item.defcon-High { color: #ff7b72; }
.dd-item.defcon-Std  { color: #e3b341; }
.dd-item.defcon-Low  { color: #7ee787; }
[data-theme="light"] .dd-item.defcon-High { color: #e5393d; }
[data-theme="light"] .dd-item.defcon-Std  { color: #d4920a; }
[data-theme="light"] .dd-item.defcon-Low  { color: #2da44e; }

/* ── Mobile backdrop (filter dropdowns) ── */
#mobile-backdrop { display: none; }

/* ── Mobile FAB + menu (hidden on desktop) ── */
.mobile-fab { display: none; }
.mobile-filter-fab { display: none; }
#mobile-menu-backdrop { display: none; }
#mobile-filter-backdrop { display: none; }
#mobile-filter-sheet { display: none; }
#mobile-menu { display: none; }

/* ── Mobile back button (hidden on desktop) ── */
.mobile-back-btn { display: none; }

/* ── Datepicker button ── */
.datepicker-wrap { position: relative; }
.datepicker-btn {
    display: flex; align-items: center; gap: 6px; width: 100%;
    background: var(--bg-surface-2); border: 1px solid var(--border); border-radius: 5px;
    color: var(--text); cursor: pointer; font-size: 13px; padding: 4px 8px;
    text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    transition: border-color 0.15s;
}
.datepicker-btn:hover { border-color: var(--accent); }

/* ── Results count ── */
.results-count {
    font-size: 12px; color: var(--text-muted);
    padding: 5px 0 4px 14px;
    min-height: 20px;
}

/* ── Table ── */
table {
    width: 100%; table-layout: fixed; border-collapse: collapse;
    background: var(--bg-surface); border: 1px solid var(--border);
    border-radius: 0 0 6px 6px;
}

/* Colgroup widths — зеркалят grid-template-columns filter-bar */
col.col-dt     { width: 170px; }
col.col-svc    { width: 88px; }
col.col-defcon { width: 105px; }
col.col-logtext { /* auto / 1fr */ }
col.col-other  { width: 215px; }

thead th {
    background: var(--bg-surface-2); padding: 8px 14px; text-align: left;
    color: var(--text-muted); font-weight: 600; border-bottom: 1px solid var(--border);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
tbody tr { border-bottom: 1px solid var(--border-row); transition: background 0.1s; }
tbody tr:hover { background: var(--bg-surface-2); }
tbody tr:last-child { border-bottom: none; }

td { padding: 8px 14px; vertical-align: top; overflow: hidden; }
td.dt { color: var(--text-muted); white-space: nowrap; font-family: monospace; font-size: 13px; }
td.service { color: var(--service-color); white-space: nowrap; }
td.logtext { word-break: break-word; }
td.otherinfo { color: var(--text-muted); word-break: break-word; font-size: 13px; }

/* ── Severity colors ── */
td.defcon { text-align: center; font-weight: bold; white-space: nowrap; }
tr.defcon-High td.defcon { color: #e5393d; }
tr.defcon-Std td.defcon  { color: #d4920a; }
tr.defcon-Low td.defcon  { color: #2da44e; }
[data-theme="dark"] tr.defcon-High td.defcon { color: #ff7b72; }
[data-theme="dark"] tr.defcon-Std td.defcon  { color: #e3b341; }
[data-theme="dark"] tr.defcon-Low td.defcon  { color: #7ee787; }
tr.defcon-High { border-left: 3px solid #e5393d; }
tr.defcon-Std  { border-left: 3px solid #d4920a; }
[data-theme="dark"] tr.defcon-High { border-left-color: #ff7b72; }
[data-theme="dark"] tr.defcon-Std  { border-left-color: #e3b341; }

td.empty { text-align: center; color: var(--text-dim); padding: 40px; }

/* ══════════════════════════════════════════════════════════════════════════
   CALENDAR POPUP — 3 месяца
   ══════════════════════════════════════════════════════════════════════════ */
.datepicker-popup {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 8px 28px rgba(0,0,0,0.5);
    z-index: 200;
    width: 810px;
    padding: 0 0 12px 0;
    user-select: none;
    overflow: hidden;
}

.cal-months-container {
    display: grid;
    grid-template-columns: 1fr 1px 1fr 1px 1fr;
}
.cal-sep { background: var(--border); margin: 8px 0; }

.cal-month-panel { padding: 14px 12px 8px; }

.cal-header {
    display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px;
}
.cal-month-label { font-size: 13px; font-weight: 600; color: var(--text); }
.cal-nav {
    background: none; border: 1px solid transparent; border-radius: 5px;
    color: var(--text-muted); cursor: pointer; font-size: 18px; line-height: 1;
    width: 26px; height: 26px; display: flex; align-items: center; justify-content: center;
    transition: border-color 0.15s, color 0.15s;
}
.cal-nav:hover { border-color: var(--border); color: var(--text); }
.cal-nav-ph { width: 26px; height: 26px; } /* placeholder для выравнивания */

.cal-weekdays {
    display: grid; grid-template-columns: repeat(7, 1fr); margin-bottom: 2px;
}
.cal-weekdays span {
    text-align: center; font-size: 11px; color: var(--text-muted); padding: 2px 0 5px;
}
.cal-weekdays .weekend { color: var(--text-dim); }

.cal-body { cursor: pointer; }
.cal-row { display: grid; grid-template-columns: repeat(7, 1fr); }

.cal-day {
    position: relative; text-align: center; font-size: 12px; color: var(--text);
    padding: 5px 0; border-radius: 0; z-index: 1;
}
.cal-day.weekend { color: var(--text-muted); }
.cal-day.cal-empty { pointer-events: none; }

/* Today dot */
.cal-day.today::after {
    content: ''; position: absolute; bottom: 2px; left: 50%; transform: translateX(-50%);
    width: 3px; height: 3px; border-radius: 50%; background: var(--accent);
}

/* Plain hover */
.cal-day:not(.range-start):not(.range-end):not(.in-range):not(.cal-empty):hover {
    background: var(--bg-surface-2); border-radius: 50%;
}

/* Filled circle: start / end / hover-preview */
.cal-day.range-start::before,
.cal-day.range-end::before,
.cal-day.hover-preview::before {
    content: ''; position: absolute; inset: 1px; border-radius: 50%;
    background: var(--accent); z-index: -1;
}
.cal-day.range-start,
.cal-day.range-end,
.cal-day.hover-preview { color: #fff !important; font-weight: 600; }
.cal-day.hover-preview::before { opacity: 0.6; }

/* Single day */
.cal-day.single-day::before {
    content: ''; position: absolute; inset: 1px; border-radius: 50%;
    background: var(--accent); z-index: -1;
}
.cal-day.single-day { background: none !important; color: #fff !important; font-weight: 600; }

/* Range fill */
.cal-day.in-range {
    background: color-mix(in srgb, var(--accent) 16%, transparent);
    border-radius: 0;
}

/* Half-bg caps at start/end of range */
.cal-row .cal-day.range-start:not(.single-day) {
    background: linear-gradient(to right,
        transparent 50%,
        color-mix(in srgb, var(--accent) 16%, transparent) 50%);
}
.cal-row .cal-day.range-end:not(.single-day),
.cal-row .cal-day.hover-preview:not(.range-start) {
    background: linear-gradient(to left,
        transparent 50%,
        color-mix(in srgb, var(--accent) 16%, transparent) 50%);
}

/* Rounded ends on in-range rows */
.cal-row .cal-day.in-range:first-child { border-radius: 50% 0 0 50%; }
.cal-row .cal-day.in-range:last-child  { border-radius: 0 50% 50% 0; }

/* Calendar footer */
.cal-footer {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 14px 0;
    border-top: 1px solid var(--border);
    margin-top: 4px;
}
.cal-foot-btn {
    background: none; border: 1px solid var(--border); border-radius: 5px;
    color: var(--text-muted); cursor: pointer; font-size: 12px; padding: 3px 10px;
    transition: border-color 0.15s, color 0.15s;
}
.cal-foot-btn:hover { border-color: var(--accent); color: var(--text); }
.cal-clear { color: #cf222e !important; border-color: rgba(207,34,46,.3) !important; }
.cal-clear:hover { border-color: #cf222e !important; }
.cal-hint { font-size: 11px; color: var(--text-muted); margin-left: auto; opacity: 0.7; }

/* ── Settings page ── */
.settings-wrap { max-width: 560px; margin: 32px auto; padding: 0 24px; }
.settings-section {
    background: var(--bg-surface); border: 1px solid var(--border);
    border-radius: 6px; padding: 20px;
}
.settings-section h2 {
    font-size: 13px; font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.4px;
    margin-bottom: 16px; padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}
.setting-row {
    display: flex; align-items: center;
    justify-content: space-between; gap: 16px;
}
.setting-label { font-size: 14px; color: var(--text); }
.setting-desc  { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.push-status { font-size: 12px; color: var(--text-muted); margin-top: 12px; min-height: 16px; }
.push-status-error { color: #e5393d; }

/* iOS-style toggle */
.toggle { position: relative; display: inline-block; width: 44px; height: 26px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; inset: 0; background: var(--border);
    border-radius: 26px; cursor: pointer; transition: background 0.2s;
}
.toggle-slider::before {
    content: ''; position: absolute;
    width: 20px; height: 20px; left: 3px; top: 3px;
    background: #fff; border-radius: 50%;
    transition: transform 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }
.toggle input:disabled + .toggle-slider { opacity: 0.4; cursor: not-allowed; }

/* ── Login page ── */
.login-wrap {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; min-height: 100vh; gap: 16px;
}
.login-wrap h1 { font-size: 32px; color: var(--accent); letter-spacing: 2px; }
.login-wrap p { color: var(--text-muted); margin-bottom: 8px; }
.btn-google {
    display: flex; align-items: center; gap: 10px; background: #fff; color: #3c4043;
    font-weight: 500; font-size: 14px; padding: 10px 20px; border-radius: 4px;
    text-decoration: none; transition: box-shadow 0.15s;
}
.btn-google:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.4); }

/* ── Admin page ── */
.admin-wrap { max-width: 900px; margin: 32px auto; padding: 0 24px; }
.admin-wrap h2 {
    font-size: 20px; color: var(--accent); margin-bottom: 20px;
    padding-bottom: 10px; border-bottom: 1px solid var(--border);
}
.admin-section {
    background: var(--bg-surface); border: 1px solid var(--border);
    border-radius: 6px; padding: 20px; margin-bottom: 20px;
}
.admin-section h3 { font-size: 15px; color: var(--text); margin-bottom: 14px; }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th {
    text-align: left; color: var(--text-muted); font-size: 12px; text-transform: uppercase;
    padding: 6px 10px; border-bottom: 1px solid var(--border);
}
.admin-table td { padding: 8px 10px; border-bottom: 1px solid var(--border-row); font-size: 13px; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-td-muted { color: var(--text-muted); font-family: monospace; font-size: 13px; }
.admin-td-action { width: 40px; text-align: center; }
.admin-td-empty { color: var(--text-dim); padding: 20px; text-align: center; }

.btn-delete {
    background: none; border: none; cursor: pointer;
    color: var(--text-dim); font-size: 15px; font-weight: 600;
    width: 26px; height: 26px; border-radius: 4px; line-height: 1;
    transition: color 0.15s, background 0.15s;
}
.btn-delete:hover { color: #e5393d; background: rgba(229,57,61,.1); }

/* Add form */
.admin-add-form { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.admin-add-fields { display: flex; gap: 12px; flex: 1; min-width: 0; flex-wrap: wrap; }
.admin-field { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 180px; }
.admin-field label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; }
.admin-field input {
    background: var(--bg-surface-2); border: 1px solid var(--border); border-radius: 5px;
    color: var(--text); font-size: 13px; padding: 6px 10px; outline: none;
    transition: border-color 0.15s;
}
.admin-field input:focus { border-color: var(--accent); }

.btn-add {
    background: var(--accent); border: none; border-radius: 5px; color: #fff;
    cursor: pointer; font-size: 13px; font-weight: 500; padding: 6px 18px;
    white-space: nowrap; transition: opacity 0.15s;
}
.btn-add:hover { opacity: 0.85; }

/* ── Pagination widget (fixed bottom-right) ── */
.pagination-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    align-items: center;
    gap: 2px;
    background: color-mix(in srgb, var(--bg-surface) 85%, transparent);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 4px;
    box-shadow: 0 2px 16px rgba(0,0,0,0.25);
    z-index: 500;
}
.pag-btn {
    display: flex; align-items: center; justify-content: center;
    width: 30px; height: 30px;
    background: none; border: none; border-radius: 5px;
    color: var(--text-muted); cursor: pointer; font-size: 18px; line-height: 1;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}
.pag-btn:hover { background: var(--bg-surface-2); color: var(--text); }
.pag-btn.pag-disabled { opacity: 0.25; cursor: default; pointer-events: none; }
.pag-info { font-size: 12px; color: var(--text-muted); padding: 0 4px; white-space: nowrap; }
.pag-sep { width: 1px; height: 18px; background: var(--border); margin: 0 2px; flex-shrink: 0; }
.live-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--text-dim);
    margin: 0 4px;
    flex-shrink: 0;
    transition: background 0.3s, box-shadow 0.3s;
}
.live-dot.live-dot-new {
    background: #3fb950;
    box-shadow: 0 0 6px #3fb950;
}
.live-dot.live-dot-err {
    background: #f85149;
    box-shadow: 0 0 6px #f85149;
}
@keyframes rowHighlight {
    0%   { background-color: rgba(63, 185, 80, 0.18); }
    100% { background-color: rgba(63, 185, 80, 0); }
}
.log-new { animation: rowHighlight 2.5s ease-out forwards; }

/* ══════════════════════════════════════════════════════════════════════════
   MOBILE (≤ 768px)
   ══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    /* Header — hide all controls, keep logo + title only */
    header { padding: 8px 12px; }
    .header-right { display: none; }

    /* Main */
    main { padding: 8px 10px; }

    /* Pagination widget — static, 2x bigger; bottom margin for 2 stacked FABs */
    .pagination-widget {
        position: static;
        margin: 0 10px 140px;
        border-radius: 8px;
        justify-content: center;
        padding: 6px 8px;
    }
    .pagination-widget .pag-btn {
        width: 52px;
        height: 52px;
        font-size: 22px;
    }
    .pagination-widget .pag-info { font-size: 15px; }
    .pagination-widget .pag-sep  { height: 28px; }
    .pagination-widget .live-dot { width: 10px; height: 10px; margin: 0 6px; }

    /* Mobile FAB — floating (fixed), bottom-right */
    .mobile-fab {
        display: flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        bottom: 24px;
        right: 24px;
        width: 44px;
        height: 44px;
        border-radius: 12px;
        background: color-mix(in srgb, var(--bg-surface) 90%, transparent);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        border: 1px solid var(--border);
        box-shadow: 0 2px 16px rgba(0,0,0,0.3);
        color: var(--text);
        cursor: pointer;
        z-index: 500;
    }

    /* Mobile back button — same floating style as FAB */
    .mobile-back-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        bottom: 24px;
        right: 24px;
        width: 44px;
        height: 44px;
        border-radius: 12px;
        background: color-mix(in srgb, var(--bg-surface) 90%, transparent);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        border: 1px solid var(--border);
        box-shadow: 0 2px 16px rgba(0,0,0,0.3);
        color: var(--text);
        text-decoration: none;
        z-index: 500;
    }

    /* Filter bar — off-screen (inputs remain accessible for JS, popup remains fixed-positionable) */
    .filter-bar {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    /* Datepicker popup — above filter sheet */
    .datepicker-popup { z-index: 1100; }

    /* Filter FAB — floating, above menu FAB */
    .mobile-filter-fab {
        display: flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        bottom: 80px;
        right: 24px;
        width: 44px;
        height: 44px;
        border-radius: 12px;
        background: color-mix(in srgb, var(--bg-surface) 90%, transparent);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        border: 1px solid var(--border);
        box-shadow: 0 2px 16px rgba(0,0,0,0.3);
        color: var(--text);
        cursor: pointer;
        z-index: 500;
    }
    .mobile-filter-fab.has-filters {
        border-color: var(--accent);
        color: var(--accent);
    }
    .mobile-filter-fab.has-filters::after {
        content: '';
        position: absolute;
        top: 7px; right: 7px;
        width: 7px; height: 7px;
        border-radius: 50%;
        background: var(--accent);
    }

    /* Prevent pull-to-refresh when filter sheet is open */
    body.filter-sheet-open {
        overflow: hidden;
        overscroll-behavior-y: none;
    }

    /* Filter sheet backdrop — fade in/out */
    #mobile-filter-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.45);
        z-index: 1002;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s;
    }
    body.filter-sheet-open #mobile-filter-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    /* Filter sheet — slide up/down */
    #mobile-filter-sheet {
        display: block;
        position: fixed;
        bottom: 0; left: 0; right: 0;
        background: var(--bg-surface);
        border-radius: 16px 16px 0 0;
        border: 1px solid var(--border);
        border-bottom: none;
        box-shadow: 0 -4px 32px rgba(0,0,0,0.5);
        padding-bottom: env(safe-area-inset-bottom, 16px);
        z-index: 1003;
        max-height: 82vh;
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
        transform: translateY(105%);
        transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
        will-change: transform;
        pointer-events: none;
    }
    body.filter-sheet-open #mobile-filter-sheet {
        transform: translateY(0);
        pointer-events: auto;
    }
    .mfs-handle {
        width: 36px; height: 4px;
        background: var(--border); border-radius: 2px;
        margin: 12px auto 16px;
        flex-shrink: 0;
    }
    .mfs-section { padding: 0 16px 16px; }
    .mfs-label {
        font-size: 11px; color: var(--text-muted);
        text-transform: uppercase; letter-spacing: .4px;
        margin-bottom: 8px;
    }
    .mfs-check-item {
        display: flex; align-items: center; gap: 12px;
        padding: 9px 12px; border-radius: 6px;
        font-size: 15px; cursor: pointer;
    }
    .mfs-check-item:active { background: var(--bg-surface-2); }
    .mfs-check-item input[type="checkbox"] {
        width: 18px; height: 18px;
        accent-color: var(--accent);
        cursor: pointer; flex-shrink: 0;
    }
    .mfs-input {
        width: 100%;
        background: var(--bg-surface-2); border: 1px solid var(--border);
        border-radius: 6px; color: var(--text); font-size: 14px;
        padding: 9px 12px; outline: none;
    }
    .mfs-input:focus { border-color: var(--accent); }
    .mfs-period-btn {
        display: flex; align-items: center; gap: 8px;
        width: 100%; padding: 9px 12px;
        background: var(--bg-surface-2); border: 1px solid var(--border);
        border-radius: 6px; color: var(--text); font-size: 14px;
        cursor: pointer; text-align: left;
    }
    .mfs-period-btn:focus { border-color: var(--accent); outline: none; }
    .mfs-actions {
        display: flex;
        gap: 10px;
    }
    .mfs-reset {
        flex: 1;
        padding: 12px;
        font-size: 15px;
    }
    .btn-apply-filters {
        flex: 1;
        padding: 12px;
        font-size: 15px;
        font-weight: 600;
        background: var(--accent);
        color: #fff;
        border: none;
        border-radius: 8px;
        cursor: pointer;
    }
    .btn-apply-filters:active { opacity: 0.85; }

    /* Mobile menu backdrop */
    body.mobile-menu-open #mobile-menu-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.45);
        z-index: 1002;
    }

    /* Mobile menu bottom sheet */
    body.mobile-menu-open #mobile-menu {
        display: block;
        position: fixed;
        bottom: 0; left: 0; right: 0;
        border-radius: 16px 16px 0 0;
        background: var(--bg-surface);
        border: 1px solid var(--border);
        border-bottom: none;
        box-shadow: 0 -4px 32px rgba(0,0,0,0.5);
        padding-bottom: env(safe-area-inset-bottom, 16px);
        z-index: 1003;
    }
    .mobile-menu-user {
        padding: 16px 20px 14px;
        font-size: 15px;
        font-weight: 600;
        color: var(--text-muted);
        border-bottom: 1px solid var(--border);
    }
    .mobile-menu-item {
        display: flex;
        align-items: center;
        gap: 14px;
        width: 100%;
        padding: 15px 20px;
        font-size: 16px;
        color: var(--text);
        text-decoration: none;
        background: none;
        border: none;
        cursor: pointer;
        text-align: left;
    }
    .mobile-menu-item:active { background: var(--bg-surface-2); }
    .mobile-menu-sep {
        height: 1px;
        background: var(--border);
        margin: 4px 0;
    }
    .mobile-menu-logout { color: #f85149; }
    [data-theme="light"] .mobile-menu-logout { color: #e5393d; }

    /* Filter bar — 2-column grid, standalone card */
    .filter-bar {
        grid-template-columns: 1fr 1fr;
        border-radius: 6px;
        border-bottom: 1px solid var(--border);
        padding: 0;
        margin-bottom: 8px;
    }
    .filter-group {
        padding: 8px 10px;
        border-bottom: 1px solid var(--border);
    }
    .filter-group:nth-child(odd):not(:last-child) {
        border-right: 1px solid var(--border);
    }
    .filter-reset-group {
        grid-column: 1 / -1;
        flex-direction: row;
        align-items: center;
        border-bottom: none;
    }
    .btn-reset { width: 100%; }

    /* Bottom sheet dropdowns */
    .dropdown.open .dropdown-menu {
        position: fixed;
        bottom: 0; left: 0; right: 0; top: auto;
        border-radius: 16px 16px 0 0;
        max-height: 55vh;
        overflow-y: auto;
        padding: 8px 0 28px;
        box-shadow: 0 -4px 32px rgba(0,0,0,0.5);
        z-index: 1001;
        min-width: unset;
    }
    .dd-item { padding: 13px 20px; font-size: 16px; }

    /* Backdrop */
    body.has-open-dropdown #mobile-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.45);
        z-index: 1000;
    }

    /* Results count */
    .results-count { padding: 0 0 6px 2px; }

    /* Table — card layout */
    table {
        border-radius: 6px;
        overflow: hidden;
    }
    colgroup, col { display: none; }
    thead { display: none; }

    tbody tr {
        display: block;
        padding: 10px 12px;
        border-bottom: 1px solid var(--border-row);
        border-left-width: 3px; /* keep defcon left-border */
    }
    tbody tr:last-child { border-bottom: none; }

    /* All cells inline by default — dt · service · defcon on one line */
    td {
        display: inline;
        padding: 0;
        overflow: visible;
        vertical-align: baseline;
    }
    td.dt { font-size: 12px; white-space: nowrap; }
    td.dt::after    { content: ' · '; color: var(--text-dim); }
    td.service::after { content: ' · '; color: var(--text-dim); }
    td.defcon { font-size: 12px; text-align: left; }

    /* logtext and otherinfo — block, on separate lines */
    td.logtext {
        display: block;
        margin-top: 5px;
        font-size: 14px;
    }
    td.otherinfo {
        display: block;
        margin-top: 3px;
        font-size: 12px;
    }

    /* Admin / Settings pages — bottom padding for floating back button */
    .admin-wrap    { padding: 0 12px 80px; margin-top: 16px; }
    .settings-wrap { padding: 0 12px 80px; margin-top: 16px; }
    .admin-section { padding: 14px; overflow-x: auto; }

    /* Reset card-layout overrides for admin table — keep it as a real table */
    .admin-table { display: table; width: 100%; table-layout: fixed; }
    .admin-table thead { display: table-header-group; }
    .admin-table tbody tr { display: table-row; padding: 0; border-left-width: 1px; }
    .admin-table td, .admin-table th { display: table-cell; padding: 5px 6px; font-size: 12px;
        overflow-wrap: break-word; word-break: break-word; }
    /* Column widths: email flex, name flex, date fixed, action fixed */
    .admin-table col.col-email  { width: 38%; }
    .admin-table col.col-name   { width: 28%; }
    .admin-table col.col-date   { width: 24%; }
    .admin-table col.col-action { width: 10%; }
    .admin-td-muted { font-size: 11px; white-space: normal; }
    .date-sep::before { content: '\A'; white-space: pre; }

    .admin-add-form { flex-direction: column; gap: 10px; }
    .admin-add-fields { flex-direction: column; width: 100%; }
    .admin-field { min-width: 0; width: 100%; }
    .admin-field input { width: 100%; }
    .btn-add { width: 100%; padding: 10px; font-size: 14px; }

    /* Calendar — 1 month, fixed overlay */
    .datepicker-popup {
        position: fixed;
        top: 56px;
        left: 10px;
        right: 10px;
        width: auto;
    }
    .cal-months-container {
        grid-template-columns: 1fr;
    }
    /* Hide first 2 month panels + separators, show only current month */
    .cal-months-container > :not(:last-child) { display: none; }
}

/* Alerts */
.admin-alert {
    border-radius: 6px; font-size: 13px; margin-bottom: 16px; padding: 10px 14px;
    border: 1px solid;
}
.admin-alert-error   { background: rgba(229,57,61,.1);  border-color: rgba(229,57,61,.4);  color: #e5393d; }
.admin-alert-success { background: rgba(45,164,78,.1);  border-color: rgba(45,164,78,.4);  color: #2da44e; }
