/* ===== Projects Report — base styles ===== */

:root {
    --bg: #f4f5f9;
    --panel: #ffffff;
    --panel-2: #fafbfd;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #e5e7eb;
    --border-2: #d1d5db;
    --primary: #6366f1;
    --primary-2: #4f46e5;
    --primary-soft: #eef2ff;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
    --shadow: 0 4px 12px rgba(15, 23, 42, .07);
    --shadow-lg: 0 10px 30px rgba(15, 23, 42, .08);
    --radius: 10px;
    --radius-lg: 14px;
    --sidebar-w: 240px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.45;
    display: flex;
}

a { color: var(--primary-2); text-decoration: none; }
a:hover { text-decoration: underline; }

code { background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: .9em; }

/* ===== Sidebar ===== */

.sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(180deg, #1f2937 0%, #111827 100%);
    color: #d1d5db;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    flex-shrink: 0;
}
.sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,.07);
    font-weight: 700;
    font-size: 16px;
    color: #fff;
}
.sidebar-logo { font-size: 22px; }
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.sidebar-section {
    margin: 12px 8px 4px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #6b7280;
}
.sidebar-link {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px;
    color: #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    text-decoration: none !important;
}
.sidebar-link:hover { background: rgba(255,255,255,.05); color: #fff; }
.sidebar-link.is-active { background: var(--primary); color: #fff; }
.sidebar-link.small { font-size: 12px; padding: 6px 12px; color: #9ca3af; }
.sidebar-link .ico { width: 20px; text-align: center; }

.sidebar-foot { padding: 12px; border-top: 1px solid rgba(255,255,255,.07); }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 8px 4px; }
.avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
}
.sidebar-user-info { font-size: 13px; }
.sidebar-user-name { color: #fff; font-weight: 600; }
.sidebar-user-role { color: #9ca3af; font-size: 11px; }
.sidebar-actions { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }

.imp-banner {
    background: rgba(245, 158, 11, .15);
    color: #fbbf24;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 12px;
    margin-bottom: 8px;
}
.imp-exit { color: #fbbf24 !important; font-weight: 600; }

/* ===== Main ===== */

.main {
    flex: 1;
    min-width: 0;
    padding: 28px 36px;
    max-width: 100%;
}
.page-login .main { padding: 0; }

/* ===== Page header ===== */

.page-header {
    display: flex; align-items: flex-end; justify-content: space-between;
    margin-bottom: 22px;
    gap: 16px;
}
.page-header-start { display: flex; gap: 14px; align-items: center; }
.page-header-icon {
    width: 44px; height: 44px;
    background: var(--primary-soft); color: var(--primary-2);
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
}
.page-title { margin: 0; font-size: 22px; font-weight: 700; color: var(--text); }
.page-subtitle { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

/* ===== KPI grid ===== */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}
.kpi-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow-sm);
}
.kpi-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { font-size: 26px; font-weight: 700; color: var(--text); margin-top: 4px; }
.kpi-sub { color: var(--muted); font-size: 12px; }

/* ===== Pie charts grid (dashboard) ===== */

.pie-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 18px;
    align-items: start;
}
.pie-cell {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 14px 6px 14px;
    min-width: 0;
}
.pie-title {
    margin: 0 0 8px 4px;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}

/* ===== Cards ===== */

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-bottom: 18px;
    box-shadow: var(--shadow-sm);
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-title { margin: 0; font-size: 15px; font-weight: 700; color: var(--text); }

/* ===== Tables ===== */

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
.data-table thead th {
    text-align: left;
    font-weight: 600;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    padding: 10px 12px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .03em;
    background: var(--panel-2);
}
.data-table tbody td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.data-table tbody tr:hover { background: var(--panel-2); }
.data-table .empty { text-align: center; color: var(--muted); padding: 30px 12px; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .actions { text-align: right; white-space: nowrap; }
.data-table .total-row { background: var(--panel-2); font-weight: 700; }
.data-table .total-row td { border-top: 2px solid var(--border-2); }

.dot {
    display: inline-block;
    width: 10px; height: 10px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 11px;
    border-radius: 999px;
    background: #e5e7eb;
    color: var(--text);
    font-weight: 600;
}
.badge-ok { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-muted { background: #f3f4f6; color: var(--muted); }
.badge-primary { background: var(--primary-soft); color: var(--primary-2); }

/* ===== Buttons ===== */

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    font-size: 13.5px;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none !important;
    font-weight: 500;
    transition: background .15s, border-color .15s, transform .05s;
    line-height: 1.2;
}
.btn:active { transform: translateY(1px); }
.btn-sm { padding: 5px 9px; font-size: 12px; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-2); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border-2); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #dc2626; }
.btn-block { width: 100%; }

/* ===== Forms ===== */

.form-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    max-width: 560px;
    box-shadow: var(--shadow-sm);
}
.form-field { margin-bottom: 14px; }
.form-label { display: block; font-weight: 600; font-size: 12.5px; margin-bottom: 5px; color: var(--text); }
.req { color: var(--danger); }
.form-input {
    width: 100%;
    padding: 8px 11px;
    border: 1px solid var(--border-2);
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    color: var(--text);
    font-family: inherit;
}
.form-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.15); }
.form-field.has-error .form-input { border-color: var(--danger); }
.form-error { color: var(--danger); font-size: 12px; margin-top: 4px; }
.form-check { display: flex; align-items: center; gap: 6px; margin: 6px 0; font-size: 13px; cursor: pointer; }
.form-actions { display: flex; gap: 8px; margin-top: 18px; }

/* ===== Color picker ===== */

.color-field { margin-bottom: 14px; }
.color-row { display: flex; align-items: center; gap: 10px; }
.color-swatch {
    appearance: none;
    -webkit-appearance: none;
    width: 44px;
    height: 38px;
    border: 1px solid var(--border-2);
    border-radius: 8px;
    padding: 2px;
    background: #fff;
    cursor: pointer;
    flex-shrink: 0;
}
.color-swatch::-webkit-color-swatch-wrapper { padding: 0; }
.color-swatch::-webkit-color-swatch { border: none; border-radius: 5px; }
.color-swatch::-moz-color-swatch { border: none; border-radius: 5px; }
.color-hex {
    flex: 1;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 13px;
}
.color-hex.is-invalid { border-color: var(--danger); }
.color-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}
.color-preset {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid rgba(0, 0, 0, .08);
    cursor: pointer;
    padding: 0;
    transition: transform .1s, box-shadow .1s;
}
.color-preset:hover {
    transform: scale(1.12);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, .35);
}
.color-preset:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, .45);
}

/* ===== Filter bar / toolbar ===== */

.filter-bar, .toolbar, .report-row {
    display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}
.filter-field { display: flex; flex-direction: column; gap: 4px; }
.filter-field label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.filter-spacer { flex: 1; }
.filter-total { color: var(--muted); font-size: 14px; }
.filter-total strong { color: var(--text); font-size: 16px; }
.toolbar-check { display: flex; align-items: center; gap: 6px; font-size: 13px; }

/* ===== Flash ===== */

.flash {
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 14px;
    font-size: 13.5px;
    border: 1px solid;
}
.flash-info { background: #eef2ff; border-color: #c7d2fe; color: #3730a3; }
.flash-ok { background: #d1fae5; border-color: #6ee7b7; color: #065f46; }
.flash-error { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }
.flash-warning { background: #fef3c7; border-color: #fcd34d; color: #92400e; }

/* ===== Empty state ===== */

.empty-state {
    text-align: center;
    padding: 32px 16px;
    color: var(--muted);
    font-size: 14px;
}
.empty-state .btn { margin-left: 8px; }

/* ===== Login page ===== */

.page-login { display: flex; min-height: 100vh; }
.login-wrap {
    flex: 1;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    padding: 24px;
}
.login-card {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 36px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}
.login-brand { text-align: center; margin-bottom: 22px; }
.login-logo { font-size: 36px; }
.login-title { margin: 6px 0 4px; font-size: 22px; }
.login-sub { color: var(--muted); font-size: 13px; margin: 0; }
.login-form { display: flex; flex-direction: column; gap: 4px; }
.login-hint {
    margin-top: 18px;
    background: var(--bg);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 12px;
    color: var(--muted);
}

/* ===== Calendar ===== */

.cal-tabs {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.cal-tab {
    padding: 8px 16px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    text-decoration: none !important;
    font-size: 13.5px;
    font-weight: 500;
}
.cal-tab.is-active { background: var(--primary); color: #fff; border-color: var(--primary); }
.cal-nav { display: flex; gap: 6px; margin-left: 12px; }
.cal-period { margin-left: auto; color: var(--muted); font-size: 13.5px; font-weight: 500; }

.cal-week-wrap, .cal-month-wrap {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-x: auto;            /* allow horizontal scroll on mobile */
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    box-shadow: var(--shadow-sm);
}

.cal-week-wrap .cal-week,
.cal-month-wrap .cal-month {
    min-width: 700px;            /* force scroll on narrow viewports */
}
.cal-week, .cal-month { width: 100%; border-collapse: collapse; font-size: 13px; }
.cal-week thead th, .cal-month thead th {
    background: var(--panel-2);
    padding: 10px 8px;
    border-bottom: 1px solid var(--border);
    text-align: center;
    font-weight: 600;
    color: var(--muted);
    font-size: 12px;
}
.cal-day-head { min-width: 80px; }
.cal-day-name { font-weight: 600; color: var(--text); }
.cal-day-date { color: var(--muted); font-size: 11px; }

.cal-proj-col { min-width: 200px; }
.cal-proj-cell { display: flex; align-items: center; gap: 8px; }
.cal-proj-cell .muted { font-size: 11px; color: var(--muted); }
.cal-day-cell {
    text-align: center;
    padding: 8px 6px;
    border-bottom: 1px solid var(--border);
    border-left: 1px solid var(--border);
    min-height: 60px;
    position: relative;
}
.cal-day-cell.is-today { background: rgba(99, 102, 241, .08); }
.cal-day-cell .cal-add {
    color: var(--muted); font-size: 14px;
    opacity: 0; transition: opacity .15s;
}
.cal-day-cell:hover .cal-add { opacity: 1; }
.cal-day-cell .cal-entry {
    display: block;
    font-weight: 600;
    color: var(--primary-2);
}
.cal-day-cell .cal-entry-dur {
    line-height: 1.2;
}
.cal-day-cell .cal-entry-users {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    justify-content: center;
    margin-top: 3px;
}
.cal-day-cell .cal-entry-users .user-color-dot {
    width: 8px;
    height: 8px;
    border-width: 1px;
    box-shadow: none;
}
.cal-day-cell.has-entry .cal-add { display: none; }
.cal-total-head { text-align: center; color: var(--muted); }
.cal-total-cell { text-align: center; font-weight: 700; }
.cal-day-totals td { background: var(--panel-2); border-top: 2px solid var(--border-2); }
.cal-day-totals td.num { text-align: center; }

.cal-month td.cal-m-cell {
    vertical-align: top;
    padding: 6px;
    height: 110px;
    width: 14.28%;
    border: 1px solid var(--border);
    background: var(--panel);
    position: relative;
}
.cal-month td.cal-m-cell.out { background: var(--bg); color: var(--muted); }
.cal-month td.cal-m-cell.is-today { box-shadow: inset 0 0 0 2px var(--primary); }
.cal-m-day { font-size: 12px; font-weight: 600; color: var(--muted); }
.cal-m-cell.is-today .cal-m-day { color: var(--primary-2); }
.cal-m-entries { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.cal-m-entry {
    display: flex; justify-content: space-between; gap: 4px;
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 11px;
    text-decoration: none !important;
    color: var(--text);
}
.cal-m-entry:hover { filter: brightness(.96); }
.cal-m-proj { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-m-dur { color: var(--muted); font-variant-numeric: tabular-nums; }
.cal-m-add { color: var(--muted); font-size: 11px; padding: 0 4px; }

/* ===== Reports ===== */

.report-builder { display: flex; flex-direction: column; gap: 12px; }
.report-row { padding: 12px 16px; }
.report-actions { display: flex; gap: 8px; padding: 0 16px 16px; }

.cells-for-cell .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }

/* ===== Audit diff ===== */

.audit-diff {
    background: var(--bg);
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 11px;
    max-width: 480px;
    overflow-x: auto;
    white-space: pre-wrap;
}

/* ===== Error ===== */

.error-wrap { text-align: center; padding: 80px 20px; }
.error-code { font-size: 64px; font-weight: 800; color: var(--primary); }
.error-title { color: var(--muted); margin: 0 0 22px; }

/* ===== Misc ===== */

.muted { color: var(--muted); }
.small { font-size: 11.5px; }
.header-actions { display: flex; gap: 8px; }

/* ===== Responsive: tablet & mobile (≤900px) ===== */
.mobile-toggle {
    display: none;
    background: transparent;
    border: none;
    color: var(--text, #1f2937);
    cursor: pointer;
    padding: 0;
}

@media (max-width: 900px) {
    /* Hamburger button visible — transparent, 3 bars (matches charts-dashboard pattern) */
    .mobile-toggle {
        display: inline-flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        position: fixed;
        top: 10px;
        left: 10px;
        z-index: 60;
        width: 40px;
        height: 40px;
        gap: 5px;
    }
    .mobile-toggle span {
        display: block;
        width: 22px;
        height: 2px;
        background: currentColor;
        border-radius: 2px;
        transition: transform .2s ease, opacity .2s ease;
    }
    /* Animate to X when drawer open */
    body.sidebar-open .mobile-toggle span:nth-child(1) {
        transform: translateY(7px) rotate(45deg);
    }
    body.sidebar-open .mobile-toggle span:nth-child(2) {
        opacity: 0;
    }
    body.sidebar-open .mobile-toggle span:nth-child(3) {
        transform: translateY(-7px) rotate(-45deg);
    }
    .mobile-toggle:hover { color: var(--accent, #6366f1); }
    /* Hide hamburger when drawer is open (the X close button takes over) */
    body.sidebar-open .mobile-toggle { opacity: 0; pointer-events: none; }

    /* Close button inside the sidebar (top right) */
    .sidebar-close {
        display: none;
        position: absolute;
        top: 12px;
        right: 12px;
        width: 32px;
        height: 32px;
        border: none;
        background: transparent;
        color: #d1d5db;
        cursor: pointer;
        font-size: 22px;
        line-height: 1;
        padding: 0;
        border-radius: 6px;
        z-index: 2;
    }
    .sidebar-close:hover { color: #fff; background: rgba(255,255,255,.08); }
    body.sidebar-open .sidebar-close { display: inline-flex; align-items: center; justify-content: center; }

    /* Sidebar becomes a drawer */
    body.has-sidebar .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 240px;
        transform: translateX(-100%);
        transition: transform .22s ease;
        z-index: 50;
        box-shadow: 2px 0 18px rgba(0,0,0,.45);
    }
    body.has-sidebar.sidebar-open .sidebar {
        transform: translateX(0);
    }
    /* Hide sidebar shadow when drawer is closed (avoids dark band on left edge) */
    body.has-sidebar:not(.sidebar-open) .sidebar {
        box-shadow: none;
    }
    /* Show full sidebar content (icons + text) on mobile */
    body.has-sidebar .sidebar-brand .sidebar-name,
    body.has-sidebar .sidebar-link span:not(.ico),
    body.has-sidebar .sidebar-section,
    body.has-sidebar .sidebar-user-info,
    body.has-sidebar .sidebar-actions { display: revert; }
    body.has-sidebar .sidebar-link { justify-content: flex-start; padding: 10px 14px; }

    /* Backdrop when drawer open */
    body.has-sidebar.sidebar-open::before {
        content: "";
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.45);
        z-index: 45;
    }

    /* Main content gets room and offset for hamburger */
    body.has-sidebar .main { margin-left: 0; padding: 64px 16px 24px; }
    .main { padding: 18px; }
    .cal-week { font-size: 11px; }

    /* Filter bar / toolbar / report-row: stack vertically on mobile */
    .filter-bar, .toolbar, .report-row {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .filter-bar > .filter-field,
    .filter-bar > input,
    .filter-bar > select,
    .filter-bar > button,
    .filter-bar > a,
    .toolbar > *,
    .report-row > * { width: 100%; max-width: 100%; }
    .filter-spacer { display: none; }
    .filter-total { text-align: right; padding-top: 6px; border-top: 1px solid var(--border); }

    /* KPI grid: 2 columns on tablet */
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }

    /* Cards: less padding */
    .card { padding: 14px 16px; }
}

/* ===== Responsive: small phone (≤640px) ===== */
@media (max-width: 640px) {
    .main { padding: 60px 12px 20px; }
    h1 { font-size: 1.35rem; }
    h2 { font-size: 1.1rem; }

    /* Buttons stack */
    .header-actions, .actions, .form-actions {
        flex-wrap: wrap;
        gap: 6px;
    }
    .btn { padding: 8px 12px; font-size: 13px; }

    /* Forms: full-width inputs */
    .form-row { flex-direction: column; align-items: stretch; gap: 6px; }
    .form-row label { width: auto; }
    input[type="text"], input[type="email"], input[type="password"],
    input[type="date"], input[type="time"], input[type="number"],
    textarea, select {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        font-size: 16px; /* avoid iOS zoom on focus */
    }

    /* Cards stack */
    .cards-grid, .stats-grid, .grid-2, .grid-3 {
        grid-template-columns: 1fr !important;
    }

    /* Pie charts: 1 column on phone */
    .pie-grid { grid-template-columns: 1fr !important; }
    .pie-cell { padding: 12px 10px 4px 10px; }

    /* KPI grid: 1 column on phone */
    .kpi-grid { grid-template-columns: 1fr !important; }
    .kpi-card { padding: 12px 14px; }
    .kpi-value { font-size: 22px; }

    /* Page header: stack on phone */
    .page-header { flex-direction: column; align-items: stretch; gap: 10px; }
    .page-header .btn { width: 100%; text-align: center; }

    /* Sidebar drawer full-width */
    body.has-sidebar .sidebar { width: min(86vw, 320px); }

    /* Calendar: tighter cells */
    .cal-grid { font-size: 11px; }
    .cal-day { padding: 4px; min-height: 60px; }
    .cal-tabs { flex-wrap: wrap; gap: 6px; }
    .cal-nav { width: 100%; justify-content: space-between; margin-left: 0; }
    .cal-week { font-size: 10px; }
}

/* ===== Responsive: very small phone (≤420px) ===== */
@media (max-width: 420px) {
    .main { padding: 56px 8px 16px; }
    h1 { font-size: 1.2rem; }
    .mobile-toggle { width: 36px; height: 36px; top: 8px; left: 8px; }
    .sidebar-brand { font-size: 14px; }
}

/* ===== Responsive: data tables → horizontal scroll on phone (≤768px) ===== */
/* On narrow screens, wrap tables in a horizontally-scrollable container
   with the header row sticky. We don't reflow into cards because the
   table is then unreadable (too many columns). A horizontal scroll is
   more honest about the data and the user can swipe left/right. */
@media (max-width: 768px) {
    .table-wrap {
        margin: 0 -8px;          /* bleed to screen edges */
        padding: 0 8px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        scroll-snap-type: x proximity;
    }
    .data-table {
        min-width: 100%;
        width: max-content;       /* let table size to its content */
        border-collapse: separate;
        border-spacing: 0;
        font-size: 0.88rem;
    }
    .data-table thead th {
        position: sticky;
        top: 0;
        background: var(--panel, #fff);
        z-index: 2;
        box-shadow: 0 1px 0 var(--border, #e5e7eb);
        white-space: nowrap;
        padding: 10px 12px;
        font-size: 0.78rem;
        letter-spacing: 0.04em;
        text-transform: uppercase;
    }
    .data-table tbody td {
        padding: 10px 12px;
        white-space: nowrap;
        vertical-align: middle;
    }
    .data-table tbody td[data-label] {
        scroll-snap-align: start;
    }
    .data-table tbody tr {
        scroll-snap-align: start;
    }
    /* Subtle scroll indicator */
    .table-wrap::after {
        content: '';
        position: sticky;
        right: 0;
        top: 0;
        width: 16px;
        height: 100%;
        background: linear-gradient(to left, var(--panel, rgba(255,255,255,0.9)), transparent);
        pointer-events: none;
    }
    /* Keep actions column on the right edge for thumb access */
    .data-table td.actions {
        position: sticky;
        right: 0;
        background: var(--panel, #fff);
        box-shadow: -1px 0 0 var(--border, #e5e7eb);
    }
    .data-table thead th.actions {
        position: sticky;
        right: 0;
        background: var(--panel, #fff);
        z-index: 3;
    }
    .user-chip { font-size: 0.78rem; }

    /* On mobile: unstick the Actions column so users can slide right to reach it */
    .data-table th.actions,
    .data-table td.actions {
        position: static !important;
        background: inherit;
        box-shadow: none;
    }
    .data-table th.actions {
        background: var(--panel-2);
    }
}

/* Even narrower phones: tighten padding */
@media (max-width: 480px) {
    .data-table { font-size: 0.82rem; }
    .data-table thead th,
    .data-table tbody td {
        padding: 8px 10px;
    }
}

/* ===== User chip (admin views) ===== */
.user-chip {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    background: var(--panel-2, #f3f4f6);
    border: 1px solid var(--border);
    color: var(--fg, #111);
    font-size: 0.82rem;
    font-weight: 500;
    line-height: 1.4;
    white-space: nowrap;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== User color label (admin users list) ===== */
.user-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.user-color-dot {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1.5px solid rgba(0, 0, 0, .25);
    flex-shrink: 0;
    vertical-align: middle;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, .15);
}
.user-color-swatch {
    display: inline-block;
    width: 22px;
    height: 22px;
    border-radius: 5px;
    border: 1px solid var(--border-2);
    vertical-align: middle;
}
