:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --accent: #f59e0b;
    --bg-light: #f5f7fb;
    --surface: #ffffff;
    --surface-muted: #eef2f6;
    --border: #d5dce5;
    --text-main: #0f172a;
    --text-light: #5b6475;
    --shadow-soft: 0 14px 40px rgba(37, 99, 235, 0.15);
}

* { box-sizing: border-box; font-family: 'Segoe UI Variable', 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif; }
body {
    margin: 0;
    padding: 0;
    background: linear-gradient(135deg, #f8fafc 0%, #e9efff 38%, #f8fafc 100%);
    color: var(--text-main);
    font-size: 14px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: hidden;
}

/* Header */
header {
    background: linear-gradient(120deg, #0f172a 0%, #2563eb 55%, #0f172a 100%);
    padding: 16px 22px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    z-index: 20;
    color: #e2e8f0;
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(145deg, #60a5fa, #2563eb);
    color: #0b1724;
    display: grid;
    place-items: center;
    font-weight: 800;
    letter-spacing: 0.4px;
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.35);
}
.brand-copy h1 { margin: 4px 0 2px; font-size: 1.4rem; color: #f8fafc; letter-spacing: -0.02em; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.72rem; color: #c7d2fe; }
.eyebrow-small { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.7rem; color: var(--text-light); }
.subhead { margin: 0; color: #dbeafe; font-size: 0.9rem; }
.header-controls { display: flex; align-items: center; gap: 14px; }
.hidden { display: none !important; }
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.offscreen-copy {
    position: fixed;
    left: -9999px;
    top: 0;
}

/* Nav Tabs */
.nav-tabs { display: flex; gap: 8px; background: rgba(255,255,255,0.12); padding: 6px; border-radius: 12px; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); border: 1px solid rgba(255,255,255,0.18); }
.nav-btn { padding: 12px 16px; min-height: 44px; border: 1px solid transparent; background: transparent; cursor: pointer; border-radius: 10px; color: #dbeafe; font-weight: 600; font-size: 0.92rem; transition: all 0.2s; }
.nav-btn:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.12); }
.nav-btn.active { background: #f8fafc; color: var(--primary); border-color: #cbd5e1; box-shadow: 0 10px 25px rgba(0,0,0,0.12); }
.header-actions .btn { width: auto; }
.header-actions .btn-secondary { background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.28); color: #e5edff; box-shadow: none; }
.header-actions .btn-secondary:hover { background: rgba(255,255,255,0.2); }
.brand-copy { color: #e2e8f0; }

/* Insight row */
.insight-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-bottom: 18px; }
.insight-card { background: #ffffff; border: 1px solid var(--border); border-radius: 14px; padding: 14px; box-shadow: var(--shadow-soft); min-height: 120px; display: flex; flex-direction: column; gap: 8px; }
.insight-title { margin: 0; font-size: 1.05rem; font-weight: 800; color: var(--text-main); }
.insight-sub { margin: 0; color: var(--text-light); font-size: 0.9rem; }
.insight-list { margin: 4px 0 0 14px; padding: 0; color: var(--text-light); line-height: 1.4; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--surface-muted); color: var(--text-main); font-weight: 700; font-size: 0.8rem; width: fit-content; }
.chip-live { background: #ecfdf3; color: #166534; border: 1px solid #bbf7d0; }
.chip-soft { background: #eef2ff; color: #4338ca; border: 1px solid #c7d2fe; }

/* Main Layout */
.main-wrapper {
    display: flex;
    flex: 1;
    overflow: hidden;
    height: 100%;
    padding: 16px;
    gap: 16px;
}

/* Resizable Sidebar */
.sidebar {
    width: 360px;
    min-width: 280px;
    max-width: 600px;
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 20px;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    resize: horizontal;
    position: relative;
    z-index: 10;
    border-radius: 14px;
    box-shadow: var(--shadow-soft);
    align-self: stretch;
    height: 100%;
    max-height: calc(100vh - 140px);
}
.sidebar-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.sidebar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.sidebar-close { display: none; }

.content-area {
    flex: 1;
    min-width: 0;
    padding: 20px;
    overflow-y: auto;
    background: var(--surface);
    position: relative;
    border-radius: 14px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
}

@media (min-width: 1201px) {
    body.editor-collapsed .sidebar { display: none; }
}

/* Forms */
.form-section { border-top: 1px dashed var(--border); margin-top: 15px; padding-top: 12px; }
.form-section-first { border: none; margin-top: 0; padding-top: 0; }
.form-label { display: block; font-size: 0.82rem; font-weight: 700; color: var(--text-main); margin-bottom: 6px; letter-spacing: 0.01em; }
.form-label-spaced { margin-top: 12px; }
.form-control {
    width: 100%;
    padding: 12px 12px;
    min-height: 44px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.94rem;
    background: var(--surface-muted);
    transition: border 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.form-control:focus { outline: none; border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.18); }
.form-note { font-size: 0.75rem; color: #475569; margin-top: 6px; }
.row { display: flex; gap: 10px; }
.row-spaced { margin-top: 10px; }
.col { flex: 1; }

/* Toggle Switch */
.toggle-wrapper { display: flex; justify-content: space-between; align-items: center; background: var(--surface-muted); padding: 10px; border-radius: 10px; border: 1px solid var(--border); }
.toggle-label { font-size: 0.9rem; font-weight: 700; }
.toggle-note { text-align: right; font-size: 0.78rem; color: #64748b; margin-top: 4px; }
.switch { position: relative; display: inline-block; width: 36px; height: 20px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #cbd5e1; transition: .4s; border-radius: 20px; }
.slider:before { position: absolute; content: ""; height: 14px; width: 14px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: var(--primary); }
input:checked + .slider:before { transform: translateX(16px); }

/* Buttons */
.btn { padding: 11px 16px; border: none; border-radius: 10px; font-weight: 700; cursor: pointer; font-size: 0.9rem; transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease; min-height: 44px; line-height: 1.1; }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: white; width: 100%; box-shadow: 0 10px 24px rgba(37, 99, 235, 0.25); }
.btn-primary:hover { transform: translateY(-1px); }
.btn-secondary { background: #0f172a; border: 1px solid #1f2937; color: #e2e8f0; box-shadow: 0 6px 18px rgba(0,0,0,0.15); }
.btn-secondary:hover { transform: translateY(-1px); background: #111827; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text-main); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-1px); }
.btn-danger { background: #fee2e2; color: #dc2626; width: 100%; margin-top: 5px; }
.btn-slim { padding: 8px 12px; min-height: 36px; font-size: 0.82rem; }
.full-width { width: 100%; }
.mt-5 { margin-top: 5px; }

/* Views */
.view-section { display: none; height: 100%; flex-direction: column; }
.view-section.active-view { display: flex; }

/* Dashboard & Stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-box {
    background: linear-gradient(145deg, #ffffff 0%, #f3f8fb 100%);
    padding: 16px;
    border-radius: 14px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
}
.stat-num { font-size: 1.9rem; font-weight: 800; color: var(--primary); letter-spacing: -0.01em; }
.stat-lbl { font-size: 0.8rem; color: var(--text-light); text-transform: uppercase; font-weight: 700; letter-spacing: 0.08em; }

/* Table */
.table-wrap { background: white; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow-soft); }
.table-scroll { max-height: calc(100vh - 360px); min-height: 260px; overflow: auto; position: relative; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th { background: #f1f5f9; text-align: left; padding: 12px; font-weight: 800; color: var(--text-main); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 2; }
td { padding: 12px; border-bottom: 1px solid var(--border); }
tbody tr:nth-child(even) { background: #f9fbfd; }
tr:hover { background: #edf6ff; }
.list-meta { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 6px 0 12px; padding: 10px 0; }
.list-counter { font-weight: 700; color: var(--text-main); }
.list-hint { color: var(--text-light); font-size: 0.85rem; }
.list-meta-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.list-sentinel { height: 1px; }
.list-actions { display: flex; flex-direction: column; gap: 6px; }
.filter-checkbox { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text-main); }
.filter-checkbox input { width: 16px; height: 16px; accent-color: var(--primary); }

/* Calendar */
.cal-controls { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; background: white; padding: 12px; border-radius: 12px; border: 1px solid var(--border); box-shadow: var(--shadow-soft); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); background: var(--border); gap: 1px; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.cal-header { background: #f1f5f9; padding: 8px; text-align: center; font-weight: 700; font-size: 0.8rem; }
.cal-cell { background: white; min-height: 140px; height: 148px; padding: 8px; display: flex; flex-direction: column; gap: 6px; overflow: hidden; }
.cal-cell-empty { background: #f8fafc; }
.cal-cell-header { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.cal-num-btn { appearance: none; border: 0; background: transparent; padding: 2px 8px; border-radius: 10px; font-weight: 800; font-size: 0.9rem; cursor: pointer; line-height: 1.2; min-height: 34px; min-width: 34px; text-align: left; }
.cal-num-btn:hover { background: rgba(37, 99, 235, 0.08); }
.cal-num-btn:focus-visible { outline: 3px solid rgba(37,99,235,0.35); outline-offset: 2px; }
.cal-events { display: flex; flex-direction: column; gap: 4px; flex: 1; min-height: 0; overflow: hidden; }
.cal-event { appearance: none; border: 0; width: 100%; text-align: left; font-size: 0.78rem; padding: 6px 8px; border-radius: 8px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 32px; touch-action: manipulation; }
.cal-event:focus-visible { outline: 3px solid rgba(15,23,42,0.35); outline-offset: 2px; }
.cal-event:active { transform: translateY(0.5px); }
.cal-more-btn { appearance: none; border: 1px dashed rgba(37, 99, 235, 0.5); background: rgba(37, 99, 235, 0.04); color: var(--primary); border-radius: 10px; padding: 6px 8px; width: 100%; text-align: left; font-weight: 800; cursor: pointer; min-height: 32px; touch-action: manipulation; }
.cal-more-btn:hover { background: rgba(37, 99, 235, 0.08); }
.cal-more-btn:focus-visible { outline: 3px solid rgba(37,99,235,0.35); outline-offset: 2px; }
.evt-group { background: #eff6ff; color: #1e40af; border-left: 3px solid #3b82f6; }
.evt-indiv { background: #f0fdf4; color: #166534; border-left: 3px solid #22c55e; }
.evt-holiday { background: #fef2f2; color: #991b1b; border-left: 3px solid #ef4444; }
.cal-title { margin: 0; font-size: 1.1rem; color: var(--primary); }
.cal-nav { display: flex; gap: 5px; }
.cal-grid-body { border-top: none; }

/* Training summary */
.training-summary { border: 1px solid var(--border); border-radius: 12px; padding: 12px; background: var(--surface-muted); display: flex; flex-direction: column; gap: 8px; }
.training-label { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.7rem; font-weight: 700; color: var(--text-light); }
.training-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.training-name { font-weight: 800; color: var(--text-main); }
.training-actions { display: flex; align-items: center; gap: 8px; }
.training-copy-status { font-size: 0.75rem; color: var(--text-light); }

.cal-legend { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin: 10px 0 14px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: rgba(255,255,255,0.85); }
.cal-legend-item { display: inline-flex; align-items: center; gap: 8px; color: var(--text-main); font-weight: 800; font-size: 0.9rem; }
.cal-legend-swatch { width: 18px; height: 12px; border-radius: 6px; display: inline-block; border-left-width: 4px; border-left-style: solid; }
.cal-legend-hint { margin-left: auto; color: var(--text-light); font-weight: 700; font-size: 0.85rem; }

body.cal-day-open { overflow: hidden; }
.cal-day-overlay { position: fixed; inset: 0; background: rgba(15,23,42,0.45); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); z-index: 1500; display: flex; align-items: center; justify-content: center; padding: 14px; }
.cal-day-dialog { width: min(720px, 96vw); max-height: calc(100vh - 28px); background: var(--surface); border-radius: 14px; border: 1px solid rgba(255,255,255,0.15); box-shadow: 0 22px 60px rgba(15,23,42,0.55); display: flex; flex-direction: column; overflow: hidden; }
.cal-day-header { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 14px; background: linear-gradient(135deg, #ffffff 0%, #f7fafc 100%); border-bottom: 1px solid var(--border); }
.cal-day-title { font-weight: 900; letter-spacing: -0.01em; color: var(--text-main); }
.cal-day-close { width: auto; }
.cal-day-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; flex: 1; min-height: 0; }
.cal-day-meta { color: var(--text-light); font-weight: 800; font-size: 0.9rem; }
.cal-day-list { overflow: auto; padding-right: 2px; display: flex; flex-direction: column; gap: 10px; flex: 1; min-height: 0; }
.cal-day-empty { color: var(--text-light); font-style: italic; padding: 10px 0; }
.cal-day-item { appearance: none; border: 1px solid rgba(15,23,42,0.12); border-radius: 12px; padding: 10px 12px; cursor: pointer; text-align: left; width: 100%; touch-action: manipulation; }
.cal-day-item:focus-visible { outline: 3px solid rgba(37,99,235,0.35); outline-offset: 2px; }
.cal-day-item-primary { font-weight: 900; color: inherit; }
.cal-day-item-secondary { margin-top: 3px; color: rgba(15,23,42,0.7); font-weight: 700; font-size: 0.9rem; line-height: 1.2; }

/* Notice bar */
.notice {
    position: fixed;
    top: 70px;
    right: 20px;
    min-width: 240px;
    max-width: 360px;
    background: #ecfeff;
    color: #0f172a;
    border: 1px solid #06b6d4;
    border-radius: 12px;
    box-shadow: var(--shadow-soft);
    padding: 12px 14px;
    z-index: 2000;
    display: none;
}
.notice.error { background: #fef2f2; border-color: #dc2626; color: #7f1d1d; }
.notice.success { background: #f0fdf4; border-color: #16a34a; color: #14532d; }
.notice button { background: transparent; border: none; float: right; cursor: pointer; color: inherit; font-weight: 700; }
.notice-visible { display: block; }
.overlap-box { border: 1px solid #fca5a5; background: #fff1f2; color: #7f1d1d; padding: 10px; border-radius: 6px; }
.overlap-title { font-weight: 800; margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.overlap-item { font-size: 0.85rem; margin-bottom: 4px; }
.overlap-item:last-child { margin-bottom: 0; }
.editor-scrim { display: none; }
.editor-scrim.visible { display: block; }

/* Pills */
.pill { display: inline-block; padding: 2px 6px; border-radius: 10px; font-size: 0.7rem; font-weight: 700; background: #e2e8f0; color: #475569; }

/* Utility */
.login-screen { display: flex; position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: radial-gradient(circle at 20% 20%, rgba(37,99,235,0.12), transparent 35%), linear-gradient(135deg, #0f172a 0%, #2563eb 70%, #0f172a 100%); z-index: 1000; align-items: center; justify-content: center; }
.login-card { background: white; padding: 40px 30px; border-radius: 14px; box-shadow: var(--shadow-soft); min-width: 320px; border: 1px solid var(--border); }
.login-title { color: var(--primary); margin-bottom: 20px; text-align: center; letter-spacing: -0.02em; }
.api-hint { color: #64748b; font-size: 12px; margin-top: 8px; }
.login-error { color: #dc2626; margin-top: 10px; }
.turnstile-container { margin-bottom: 15px; min-height: 65px; display: flex; justify-content: center; align-items: center; }
.turnstile-container.hidden { display: none; }
.no-margin { margin: 0; }
.section-subtitle { font-size: 0.8rem; color: #64748b; margin-top: 5px; }
.mb-10 { margin-bottom: 10px; }
.mb-20 { margin-bottom: 20px; }
.form-actions { margin-top: 20px; }
.filters-shell { margin-bottom: 20px; position: relative; }
.filters-toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.filters-toggle-main { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.filters-summary-btn { background: transparent; border: 1px solid transparent; padding: 6px 8px; text-align: left; cursor: pointer; min-height: 44px; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 2px; flex: 1; min-width: 0; border-radius: 10px; }
.filters-summary-btn:hover { background: rgba(15,23,42,0.03); border-color: rgba(15,23,42,0.08); }
.filters-summary-btn:focus-visible { outline: 3px solid rgba(37, 99, 235, 0.35); outline-offset: 2px; }
.filter-summary { color: var(--text-light); font-weight: 700; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.filters-toggle-hint { color: var(--text-light); font-size: 0.82rem; }
.filters-panel { position: relative; }
.filters-panel-header { display: none; }
.filters-scrim { display: none; }
.filters-bar { background: linear-gradient(135deg, #ffffff 0%, #f7fafc 100%); padding: 16px; border: 1px solid var(--border); border-radius: 14px; margin-bottom: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; align-items: end; box-shadow: var(--shadow-soft); }
.filter-field { min-width: 200px; }
.filter-type { min-width: 160px; }
.filter-from { min-width: 140px; }
.filter-to { min-width: 140px; }
.filter-actions { min-width: 220px; }
.filter-actions-row { display: flex; gap: 8px; flex-wrap: wrap; }
.indiv-card { background: white; padding: 20px; border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-soft); }
.indiv-title { margin-top: 0; color: var(--primary); letter-spacing: -0.01em; }
.indiv-subtitle { color: #64748b; border-bottom: 1px solid #e2e8f0; padding-bottom: 15px; }
.indiv-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.copy-controls { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.copy-controls .btn { min-width: 110px; }
.copy-status { font-size: 0.8rem; color: var(--primary); }
.report-box {
    margin-top: 15px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
    overflow-y: auto;
    max-height: calc(100vh - 200px);
}
.report-text {
    margin: 0;
    line-height: 1.6;
    color: var(--text-main);
}
.report-header {
    font-size: 1.15rem;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary);
    color: var(--primary);
}
.report-header strong {
    font-weight: 800;
    letter-spacing: -0.01em;
}
.report-empty {
    color: var(--text-light);
    font-style: italic;
    margin: 12px 0;
}
.report-week {
    font-size: 1.05rem;
    margin-top: 18px;
    margin-bottom: 8px;
    color: var(--text-main);
}
.report-week strong {
    font-weight: 800;
    color: var(--primary);
}
.report-week-list {
    list-style: none;
    padding-left: 0;
    margin: 0 0 12px 0;
}
.report-week-list li {
    padding: 6px 0 6px 12px;
    border-left: 3px solid var(--border);
    margin-bottom: 4px;
    line-height: 1.5;
    transition: border-color 0.2s ease;
}
.report-week-list li:hover {
    border-left-color: var(--primary);
    background: rgba(37, 99, 235, 0.03);
}
.report-date {
    font-weight: 600;
    color: var(--text-main);
    display: inline-block;
    min-width: 90px;
}
.report-off {
    font-weight: 800;
    color: #dc2626;
    text-transform: uppercase;
    font-size: 0.9em;
    letter-spacing: 0.03em;
}
.muted { color: #64748b; }
.mobile-editor-toggle { display: none; padding: 8px 16px 0; }

/* Responsive */
@media (max-width: 1200px) {
    body { overflow-y: auto; }
    .main-wrapper { flex-direction: column; height: auto; overflow: visible; }
    .sidebar { width: min(560px, 94vw); max-width: none; resize: both; position: fixed; left: 50%; transform: translate(-120%, 0); top: 88px; bottom: 16px; z-index: 1300; max-height: calc(100vh - 104px); overflow: auto; transition: transform 0.25s ease, opacity 0.25s ease; opacity: 0; }
    .sidebar-close { display: inline-flex; }
    body.editor-open .sidebar { transform: translate(-50%, 0); opacity: 1; }
    body:not(.editor-open) .sidebar { pointer-events: none; }
    .editor-scrim { position: fixed; inset: 0; background: rgba(15,23,42,0.35); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); z-index: 1200; }
    .mobile-editor-toggle { display: flex; justify-content: flex-start; }
    .content-area { width: 100%; overflow: visible; }
    .table-scroll { max-height: 65vh; }
}

@media (max-width: 1024px) {
    header { flex-direction: column; align-items: flex-start; gap: 12px; }
    .header-controls { flex-direction: column; align-items: flex-start; width: 100%; gap: 10px; }
    .header-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); width: 100%; gap: 8px; }
    .nav-tabs { width: 100%; flex-wrap: wrap; }
    .nav-btn { flex: 1; text-align: center; }
    .main-wrapper { padding: 12px; }
    .filters-toggle-row { display: flex; }
    .filters-panel { position: fixed; top: 82px; right: 12px; bottom: 12px; width: min(420px, 92vw); background: var(--surface); border-radius: 14px; border: 1px solid var(--border); box-shadow: 0 18px 38px rgba(15,23,42,0.35); transform: translateX(110%); transition: transform 0.25s ease; overflow-y: auto; z-index: 1200; }
    .filters-panel.open { transform: translateX(0); }
    .filters-panel-header { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 16px; position: sticky; top: 0; background: linear-gradient(135deg, #ffffff 0%, #f7fafc 100%); border-bottom: 1px solid var(--border); z-index: 1; }
    .filters-bar { margin-bottom: 0; border-radius: 0; box-shadow: none; grid-template-columns: 1fr; }
    .filters-scrim { position: fixed; inset: 0; background: rgba(15,23,42,0.35); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); display: none; z-index: 1100; }
    .filters-scrim.visible { display: block; }
    .filter-field, .filter-type, .filter-from, .filter-to, .filter-actions { width: 100% !important; min-width: 0; }
    .table-scroll { max-height: 65vh; }
}

@media (min-width: 1025px) {
    .filters-toggle-hint { display: none; }
}

@media (max-width: 820px) {
    .header-actions { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
    .stats-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
}

@media (max-width: 768px) {
    header { padding: 14px 16px; }
    .header-actions .btn { width: 100%; }
    .row { flex-direction: column; }
    .cal-controls { flex-direction: column; gap: 10px; align-items: flex-start; }
    .cal-nav { width: 100%; justify-content: space-between; }
    .table-wrap { overflow-x: auto; }
    .cal-cell { min-height: 128px; height: 132px; padding: 6px; gap: 5px; }
    .cal-event, .cal-more-btn { min-height: 36px; padding: 7px 9px; font-size: 0.8rem; }
    .cal-num-btn { min-height: 38px; min-width: 38px; }
    .cal-legend-hint { width: 100%; margin-left: 0; }
    .cal-day-dialog { width: 96vw; max-height: calc(100vh - 24px); }
}

@media (max-width: 600px) {
    .brand { width: 100%; justify-content: space-between; }
    .filters-panel { top: 72px; width: 92vw; }
    .filters-toggle-row { flex-direction: column; align-items: flex-start; gap: 6px; }
    .filters-toggle-main { width: 100%; }
    .nav-tabs { gap: 6px; }
    .nav-btn { width: 100%; }
    .btn { width: 100%; }
}

/* Print */
@media print {
    .sidebar, header, .no-print { display: none !important; }
    .content-area { overflow: visible; }
    .table-scroll { max-height: none !important; overflow: visible !important; }
}
