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

:root {
    --bg: #e9e9ea;
    --card-bg: #ffffff;
    --border: #e4e4e6;
    --text: #17181a;
    --text-muted: #8b8d94;
    --text-faint: #b4b6bc;
    --accent: #17181a;
    --accent-text: #ffffff;
    --green: #1fa26e;
    --green-bg: #e7f7f0;
    --orange: #c07a17;
    --orange-bg: #fdf3e3;
    --red: #b8433a;
    --red-bg: #fbeceb;
    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 1px 2px rgba(20, 20, 25, 0.04), 0 1px 10px rgba(20, 20, 25, 0.04);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    padding: 0;
    display: flex;
    align-items: flex-start;
    min-height: 100vh;
}

/* Standalone employee report (Telegram Web App) — no sidebar */
body.report-body {
    display: block;
    padding: 16px 14px 40px;
}
.report-page {
    max-width: 640px;
    margin: 0 auto;
}
.report-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}
.report-header-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #eeeeef;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 700;
    flex-shrink: 0;
    object-fit: cover;
}
.report-header-name {
    font-size: 16px;
    font-weight: 700;
}
.report-header-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Left sidebar navigation */
.sidebar {
    width: 232px;
    flex-shrink: 0;
    background: var(--card-bg);
    border-right: 1px solid var(--border);
    padding: 18px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: auto;
    padding: 12px 10px 6px;
    border-top: 1px solid var(--border);
    font-size: 14.5px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text);
}
.sidebar-logo-badge {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: var(--accent);
    color: var(--accent-text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-link {
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}
.sidebar-link:hover { background: #f5f5f6; color: var(--text); }
.sidebar-link.active { background: var(--accent); color: var(--accent-text); }

/* Sidebar footer: current user + logout (positioned at the top of the sidebar) */
.sidebar-footer {
    padding-bottom: 12px;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.sidebar-footer-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.sidebar-footer .lang-switch {
    margin-left: 0;
    align-self: flex-start;
}
.sidebar-user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
    padding: 6px 4px;
}
.sidebar-user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #eeeeef;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11.5px;
    font-weight: 700;
    flex-shrink: 0;
    object-fit: cover;
}
.sidebar-user-text { min-width: 0; }
.sidebar-user-name {
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-user-role {
    font-size: 11px;
    color: var(--text-faint);
}
.sidebar-logout-btn {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
}
.sidebar-logout-btn:hover { background: #f5f5f6; color: var(--red); }
.sidebar-logout-btn svg { width: 16px; height: 16px; }

.sidebar-notify-btn {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
}
.sidebar-notify-btn:hover { background: #f5f5f6; color: var(--text); }
.sidebar-notify-btn.active,
.sidebar-notify-btn.active:hover {
    background: var(--accent);
    color: var(--accent-text);
}
.sidebar-notify-btn svg { width: 16px; height: 16px; }

/* Login page */
.login-body {
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.login-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 32px 28px;
    width: 100%;
    max-width: 360px;
}
.login-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 22px;
}

.lang-switch {
    display: inline-flex;
    background: #f0f0f2;
    border-radius: 999px;
    padding: 2px;
    gap: 2px;
    margin-left: auto;
}
.lang-switch button {
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.lang-switch button.active {
    background: var(--accent);
    color: var(--accent-text);
}
.login-card h1 {
    font-size: 19px;
    font-weight: 700;
    margin-bottom: 4px;
}
.login-sub {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 22px;
}

/* Main content area, to the right of the sidebar */
.main {
    flex: 1;
    min-width: 0;
    padding: 32px 32px 80px;
}

/* Mobile: sidebar becomes an off-canvas drawer behind a hamburger toggle */
.mobile-nav-toggle {
    display: none;
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 60;
    width: 38px;
    height: 38px;
    align-items: center;
    justify-content: center;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    color: var(--text);
    cursor: pointer;
}
.mobile-nav-toggle svg { width: 18px; height: 18px; }

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(20, 20, 25, 0.4);
    z-index: 55;
}

@media (max-width: 860px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        z-index: 65;
        box-shadow: 0 0 24px rgba(0, 0, 0, 0.15);
    }
    body.sidebar-open .sidebar { transform: translateX(0); }
    body.sidebar-open .sidebar-backdrop { display: block; }

    .mobile-nav-toggle { display: flex; }

    .main { padding: 72px 16px 60px; }
}

/* Install banner (persistent, all pages, no dismiss) — position:fixed
   deliberately: both the default `body` (sidebar layout) and `.login-body`
   use `display:flex` with no `flex-direction` set (defaults to row), so an
   in-flow sibling would land beside the sidebar/login card instead of
   above it. Fixed removes it from that flow entirely; the sidebar's own
   `height:100vh`/sticky positioning and the mobile hamburger's fixed
   `top` are compensated separately below since body padding alone
   doesn't reach position:fixed descendants. z-index kept below .overlay
   (70) so an open modal still visually covers the banner. */
body.has-install-banner { padding-top: 54px; }
body.has-install-banner .sidebar { height: calc(100vh - 54px); }
body.has-install-banner .mobile-nav-toggle { top: 68px; }
.install-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: var(--accent);
    color: var(--accent-text);
    padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
    font-size: 12.5px;
}
.install-banner-text { flex: 1; }
.install-banner-btn {
    background: var(--accent-text);
    color: var(--accent);
    border: none;
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    white-space: nowrap;
}
.install-step {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.install-step-num {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--accent-text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}
.install-step-text { font-size: 13px; }

.page {
    max-width: 1080px;
    margin: 0 auto;
}

.topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 28px;
    gap: 16px;
    flex-wrap: wrap;
}

.topbar h1 {
    font-size: 22px;
    font-weight: 650;
    letter-spacing: -0.01em;
}

.topbar p {
    margin-top: 4px;
    font-size: 13px;
    color: var(--text-muted);
}

.refresh-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 14px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: background 0.15s;
}
.refresh-btn:hover { background: #f5f5f6; }
.refresh-btn:disabled { opacity: 0.5; cursor: default; }

.refresh-btn svg { width: 14px; height: 14px; }
.refresh-btn.spinning svg { animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Sections */
.section { margin-bottom: 36px; }
.section:last-child { margin-bottom: 0; }

.section-head {
    display: flex;
    align-items: center;
    margin-bottom: 14px;
}

.section-head h2 {
    font-size: 15px;
    font-weight: 650;
}

.count-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--orange-bg);
    color: var(--orange);
    font-size: 11px;
    font-weight: 700;
    margin-left: 8px;
}
.count-pill.neutral {
    background: #eeeeef;
    color: var(--text-muted);
}

/* Grid of cards */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.card-head {
    display: flex;
    align-items: center;
    gap: 12px;
}
.card-head > .session-icon-comments { margin-left: auto; flex-shrink: 0; }

.avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    background: #f0f0f2;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 650;
    color: var(--text-muted);
    flex-shrink: 0;
}

.card-head-text { min-width: 0; }

.card-name {
    font-size: 14.5px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-username {
    font-size: 12.5px;
    color: var(--text-muted);
    margin-top: 1px;
}

.card-meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12.5px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

.card-meta-row {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.card-meta-label {
    text-transform: uppercase;
    font-size: 10.5px;
    letter-spacing: 0.03em;
    color: var(--text-faint);
}

.card-meta-value {
    color: var(--text);
    font-weight: 500;
    text-align: right;
}

.badge {
    display: inline-flex;
    align-self: flex-start;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 999px;
    padding: 3px 9px 3px 7px;
}
.badge::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
}
.badge-pending {
    color: var(--orange);
    background: var(--orange-bg);
}
.badge-pending::before { background: var(--orange); }
.badge-active {
    color: var(--green);
    background: var(--green-bg);
}
.badge-active::before { background: var(--green); }
.badge-admin {
    color: var(--text-muted);
    background: #eeeeef;
}
.badge-admin::before { background: var(--text-faint); }
.badge-inactive {
    color: var(--red);
    background: var(--red-bg);
}
.badge-inactive::before { background: var(--red); }

.badge-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.action-btn {
    margin-top: 2px;
    background: var(--accent);
    color: var(--accent-text);
    border: none;
    border-radius: var(--radius-sm);
    padding: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}
.action-btn:hover { opacity: 0.85; }
.action-btn.secondary {
    background: #f0f0f2;
    color: var(--text);
}

/* Empty / loading / error states */
.state-box {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13.5px;
}
.state-box .state-icon {
    width: 28px;
    height: 28px;
    margin: 0 auto 10px;
    color: var(--text-faint);
}

.error-box {
    background: #fdecec;
    border: 1px solid #f6c6c6;
    color: #a3312f;
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-size: 13px;
    margin-bottom: 16px;
}

.debt-banner {
    background: var(--orange-bg);
    border: 1px solid #f0dba8;
    color: var(--orange);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-size: 13px;
    margin-bottom: 16px;
}

.pending-banner {
    background: var(--card-bg);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-size: 13px;
    box-shadow: var(--shadow);
}
.pending-banner-comment {
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 12.5px;
    font-style: italic;
}

/* Summary stats */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}
.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px 18px;
}
.stat-card .stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-faint);
    font-weight: 700;
    margin-bottom: 6px;
}
.stat-card .stat-value {
    font-size: 36px;
    font-weight: 700;
    color: #5f646f;
}
.stat-card.unpaid {
    background: var(--red-bg);
    border-color: #f3c9c6;
}
.stat-card.unpaid .stat-label { color: var(--red); }
.stat-card.unpaid .stat-value { color: var(--red); font-size: 25px; }

@media (max-width: 860px) {
    /* Force exactly 2 columns instead of relying on auto-fit, which on a
       narrow phone often can't fit even two 160px-minimum cards side by
       side and silently collapses to one per row — wastes a lot of
       vertical space on the dashboard's summary cards. */
    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }
    .stats-row .stat-card {
        padding: 12px 14px;
    }
    .stats-row .stat-card .stat-value {
        font-size: 26px;
    }
    .stats-row .stat-card.unpaid .stat-value {
        font-size: 20px;
    }

    .stats-row-list {
        display: flex;
        flex-direction: column;
        background: var(--card-bg);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        box-shadow: var(--shadow);
        overflow: hidden;
    }
    .stats-row-list .stat-card {
        background: transparent;
        border: none;
        box-shadow: none;
        border-radius: 0;
        border-bottom: 1px solid var(--border);
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 14px 16px;
    }
    .stats-row-list .stat-card:last-child { border-bottom: none; }
    .stats-row-list .stat-card .stat-label { margin-bottom: 0; }
    .stats-row-list .stat-card .stat-value,
    .stats-row-list .stat-card.unpaid .stat-value { font-size: 20px; }
}

.stat-card.revenue-card {
    grid-column: span 2;
    min-width: 300px;
}
.revenue-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}
.revenue-header .stat-label { margin-bottom: 0; }
.revenue-bar {
    height: 8px;
    border-radius: 999px;
    background: rgba(184, 67, 58, 0.22);
    overflow: hidden;
}
.revenue-bar-paid {
    height: 100%;
    background: var(--green);
    border-radius: 999px;
}
.revenue-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 14px;
}
.revenue-split-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 3px;
}
.revenue-split-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}
.revenue-split-item.unpaid { text-align: right; }
.revenue-split-item.unpaid .revenue-split-value { color: var(--red); }

/* Filters */
.filters-row {
    margin-bottom: 20px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.filters-toggle { display: none; }
.filters-content {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    padding: 14px 16px;
}
.filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 170px;
}
.filter-group label {
    font-size: 11px;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0;
    font-weight: 700;
}
.filter-reset-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.15s;
}
.filter-reset-btn:hover { background: #f5f5f6; color: var(--text); }

@media (max-width: 860px) {
    .filters-toggle {
        display: flex;
        align-items: center;
        gap: 8px;
        width: 100%;
        padding: 12px 16px;
        background: none;
        border: none;
        font-size: 13px;
        font-weight: 700;
        color: var(--text);
        cursor: pointer;
        text-align: left;
    }
    .filters-toggle svg { width: 18px; height: 18px; flex-shrink: 0; }
    .filters-toggle .filters-icon { color: var(--text-muted); }
    .filters-badge {
        display: none;
        align-items: center;
        justify-content: center;
        min-width: 18px;
        height: 18px;
        padding: 0 5px;
        border-radius: 999px;
        background: var(--accent);
        color: var(--accent-text);
        font-size: 11px;
        font-weight: 700;
    }
    .filters-chevron { margin-left: auto; color: var(--text-faint); transition: transform 0.15s ease; flex-shrink: 0; }
    .filters-row.expanded .filters-chevron { transform: rotate(180deg); }
    .filters-content { display: none; padding-top: 14px; border-top: 1px solid var(--border); }
    .filters-row.expanded .filters-content { display: flex; }
    .filter-group { min-width: 0; flex: 1 1 140px; }
}

/* Session rows */
.session-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.session-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.15s;
}
.session-row:hover { background: #fafafa; }
.session-row.paid { border-left: 3px solid var(--green); }

.session-row-top, .session-row-bottom, .session-top-right, .session-bottom-right {
    display: contents;
}

.session-employee {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 200px;
    flex: 1 1 200px;
}
.session-employee .avatar { width: 36px; height: 36px; font-size: 13px; }
.session-employee-text { min-width: 0; }
.session-employee-name {
    font-size: 13.5px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.session-employee-rate {
    font-size: 11.5px;
    color: var(--text-muted);
}

.session-project {
    font-size: 12.5px;
    color: var(--text-muted);
    min-width: 120px;
    flex: 1 1 120px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.session-datetime {
    min-width: 130px;
    flex-shrink: 0;
    text-align: right;
}
.session-weekday {
    font-size: 11.5px;
    color: var(--text-muted);
}
.session-date {
    font-size: 12.5px;
    font-weight: 600;
}
.session-time {
    font-size: 11.5px;
    color: var(--text-muted);
}

.session-hours {
    min-width: 60px;
    flex-shrink: 0;
    text-align: right;
    font-size: 13px;
    font-weight: 600;
}

.session-amount {
    min-width: 90px;
    flex-shrink: 0;
    text-align: right;
    font-size: 14px;
    font-weight: 700;
}
.session-amount.paid { color: var(--green); }
.session-amount-note {
    font-size: 10.5px;
    font-weight: 600;
    color: var(--orange);
    margin-top: 1px;
}
.session-amount-note.rejected { color: var(--red); }
.session-amount-note.travel { color: var(--text-muted); font-weight: 500; }

.session-row.rejected { border-left: 3px solid #ff1200; }

.session-icons {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    min-width: 56px;
    justify-content: flex-end;
}
.session-icon-warning {
    color: var(--orange);
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}
.session-icon-rejected {
    color: var(--red);
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}
.session-icon-media {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: #eeeeef;
    border-radius: 999px;
    padding: 3px 8px 3px 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    border: none;
}
.session-icon-media:hover { background: #e6e6e8; }
.session-icon-media svg { width: 13px; height: 13px; }

.session-icon-comments {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: #eeeeef;
    border-radius: 999px;
    padding: 3px 8px 3px 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    border: none;
}
.session-icon-comments:hover { background: #e6e6e8; }
.session-icon-comments svg { width: 13px; height: 13px; }
.session-icon-comments.add { padding: 5px; background: transparent; border: 1px dashed var(--border); color: var(--text-faint); cursor: pointer; }
.session-icon-comments.add:hover { background: #f5f5f6; }
.session-icon-comments.unread { background: var(--red-bg); color: var(--red); }
.session-icon-comments.unread:hover { background: #f6dcda; }

/* Session chat (comments) — bubble-style thread between the employee
   (mobile app) and any admin (panel), one thread per session. Opens
   fullscreen (not just centered like other modals) — a chat benefits
   from all the room it can get, on both the sessions list and the
   dashboard card entry points, since they share this same overlay. */
#commentsOverlay { padding: 0; }
#commentsOverlay .modal.chat-modal {
    max-width: none;
    width: 100%;
    height: 100%;
    max-height: 100vh;
    border-radius: 0;
    display: flex;
    flex-direction: column;
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 220px;
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    box-sizing: border-box;
}
.chat-empty {
    margin: auto;
    text-align: center;
    color: var(--text-faint);
    font-size: 13px;
}
.chat-bubble {
    max-width: 78%;
    padding: 8px 12px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.4;
}
.chat-bubble .chat-text { white-space: pre-wrap; word-break: break-word; }
.chat-bubble .chat-author { font-size: 11px; font-weight: 700; margin-bottom: 2px; opacity: 0.7; }
.chat-bubble .chat-time { font-size: 10px; opacity: 0.55; margin-top: 3px; text-align: right; }
.chat-bubble.own {
    align-self: flex-end;
    background: var(--accent);
    color: var(--accent-text);
    border-bottom-right-radius: 4px;
}
.chat-bubble.other {
    align-self: flex-start;
    background: #eeeeef;
    color: var(--text);
    border-bottom-left-radius: 4px;
}
.chat-input-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    box-sizing: border-box;
}
.chat-input-row textarea {
    width: 100%;
    box-sizing: border-box;
    resize: none;
    max-height: 90px;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-family: inherit;
    background: #fafafb;
}
.chat-input-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
.chat-send-btn {
    background: var(--accent);
    color: var(--accent-text);
    border: none;
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    flex-shrink: 0;
}
.chat-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.chat-audio { max-width: 260px; height: 36px; }
.chat-voice-btn {
    background: #eeeeef;
    color: var(--text-muted);
    border: none;
    border-radius: 999px;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}
.chat-voice-btn svg { width: 18px; height: 18px; }
.chat-voice-btn.recording { background: var(--red); color: #fff; }
.chat-voice-indicator {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    margin-bottom: 10px;
    border-radius: var(--radius-sm);
    background: var(--red-bg);
    color: var(--red);
    font-size: 13px;
}
.chat-voice-indicator.show { display: flex; }
.chat-voice-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--red);
    animation: chat-voice-pulse 1s ease-in-out infinite;
}
@keyframes chat-voice-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}
#voiceRecordTime { font-variant-numeric: tabular-nums; font-weight: 600; }
.chat-voice-cancel {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--red);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
}

@media (max-width: 860px) {
    .session-row {
        flex-direction: column;
        align-items: stretch;
        row-gap: 8px;
    }
    .session-row-top, .session-row-bottom {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        width: 100%;
    }
    .session-top-right, .session-bottom-right {
        display: flex;
        align-items: center;
        gap: 10px;
        flex-shrink: 0;
    }
    .session-employee { min-width: 0; flex: 1 1 auto; }
    .session-project { min-width: 0; max-width: 140px; flex: none; text-align: right; }
    .session-datetime { min-width: 0; text-align: left; }
    .session-bottom-right { align-items: baseline; }
    .session-hours, .session-amount { min-width: 0; }
}

/* Media modal */
.media-grid {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 0 20px 20px;
}
.media-grid img, .media-grid video {
    width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
    background: #f0f0f2;
    display: block;
}
#mediaOverlay .modal { max-width: 640px; }

/* Reference item rows */
.ref-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.ref-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    padding: 12px 16px;
}
.ref-item-main { min-width: 0; }
.ref-item-title {
    font-size: 13.5px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}
.ref-item-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}
.ref-item-usage {
    font-size: 10.5px;
    font-weight: 600;
    color: var(--text-faint);
    background: #eeeeef;
    border-radius: 999px;
    padding: 2px 8px;
    white-space: nowrap;
}
.ref-item-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}
.ref-item-actions .action-btn {
    margin-top: 0;
    padding: 7px 12px;
    font-size: 12px;
}
.ref-item-actions .action-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* Modal */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(20, 20, 25, 0.4);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    /* Must beat the mobile sidebar apparatus (.mobile-nav-toggle: 60,
       .sidebar-backdrop: 55, .sidebar off-canvas: 65) — a modal is
       exclusive/blocking, so it should never let the hamburger button
       or drawer render on top of it on narrow screens. Was 50, which
       let .mobile-nav-toggle (60) sit above every modal's header. */
    z-index: 70;
    overflow-y: auto;
}
.overlay.show { display: flex; }

.modal {
    background: var(--card-bg);
    border-radius: var(--radius);
    width: 100%;
    max-width: 440px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.18);
    margin: auto;
}

/* Edit modal: sized to content, parent overlay handles scrolling instead of the modal itself */
#editOverlay .modal {
    max-width: 50%;
    min-width: fit-content;
    max-height: none;
    overflow-y: visible;
}

.modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border);
}

.modal-header-active {
    margin-left: auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
    padding-left: 16px;
    flex-shrink: 0;
}
.modal-header-active .toggle-label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
}

.modal-title { font-size: 15.5px; font-weight: 650; }
.modal-subtitle { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }

.modal-body { padding: 18px 20px 4px; }

.form-group { margin-bottom: 16px; }
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text);
}

label .req { color: #c0392b; }
label .opt { color: var(--text-faint); font-weight: 500; }

input[type="text"], input[type="tel"], input[type="password"], input[type="date"], input[type="datetime-local"], select, textarea {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fafafb;
    color: var(--text);
    font-family: inherit;
    appearance: none;
    resize: vertical;
}
textarea { min-height: 60px; }
select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238b8d94' stroke-width='1.5' fill='none' fill-rule='evenodd'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 30px;
}
input[type="text"]:focus, input[type="tel"]:focus, input[type="password"]:focus, input[type="date"]:focus, input[type="datetime-local"]:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #b7b8bf;
    background: #ffffff;
}

.readonly-info {
    background: #f5f5f6;
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-size: 12.5px;
    color: var(--text-muted);
    margin-bottom: 18px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.readonly-info b { color: var(--text); font-weight: 600; }

/* Toggle switch */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-top: 1px solid var(--border);
}
.toggle-row:first-of-type { border-top: 1px solid var(--border); margin-top: 4px; }
.toggle-label { font-size: 13.5px; font-weight: 600; }
.toggle-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }

.switch {
    position: relative;
    width: 38px;
    height: 22px;
    flex-shrink: 0;
}
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.switch-track {
    position: absolute;
    inset: 0;
    background: #d8d8db;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.15s;
}
.switch-track::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 3px;
    top: 3px;
    background: #ffffff;
    border-radius: 50%;
    transition: transform 0.15s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.switch input:disabled + .switch-track { opacity: 0.45; cursor: default; }
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::before { transform: translateX(16px); }

/* Employee groups: member/project checklists */
.checklist-search { margin-bottom: 6px; }
.checklist-box {
    max-height: 220px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 4px;
}
.checklist-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 8px;
    font-size: 13px;
    cursor: pointer;
    border-radius: 6px;
}
.checklist-item:hover { background: #f5f5f6; }
.checklist-item input { flex-shrink: 0; }
.checklist-empty {
    padding: 12px 8px;
    font-size: 12.5px;
    color: var(--text-muted);
    text-align: center;
}

.modal-footer {
    display: flex;
    gap: 10px;
    padding: 16px 20px 20px;
}

.btn {
    flex: 1;
    padding: 11px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: opacity 0.15s, background 0.15s;
}
.btn-cancel {
    background: #f0f0f2;
    color: var(--text);
}
.btn-cancel:hover { background: #e6e6e8; }
.btn-save {
    background: var(--accent);
    color: var(--accent-text);
}
.btn-save:disabled {
    opacity: 0.35;
    cursor: default;
}
.btn-save:not(:disabled):hover { opacity: 0.85; }

.modal-error {
    display: none;
    margin: 0 20px 14px;
    background: #fdecec;
    border: 1px solid #f6c6c6;
    color: #a3312f;
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 12.5px;
}
.modal-error.show { display: block; }

.modal-success {
    display: none;
    margin: 0 20px 14px;
    background: #eafbf0;
    border: 1px solid #b9e8c9;
    color: #1e7a44;
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 12.5px;
}
.modal-success.show { display: block; }

.login-link {
    display: inline-block;
    margin-top: 10px;
    font-size: 12.5px;
    color: var(--accent);
    cursor: pointer;
    text-decoration: none;
    background: none;
    border: none;
    padding: 0;
}
.login-link:hover { text-decoration: underline; }

.form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
    min-height: 15px;
}
.form-hint.error { color: #a3312f; }

.modal-success {
    padding: 40px 24px;
    text-align: center;
    display: none;
}
.modal-success.show { display: block; }
.modal-success .icon {
    width: 40px;
    height: 40px;
    margin: 0 auto 12px;
    color: var(--green);
}
.modal-success .title { font-size: 15px; font-weight: 650; margin-bottom: 4px; }
.modal-success .sub { font-size: 12.5px; color: var(--text-muted); }

/* Section action button (e.g. Add object) */
.section-head-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.add-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--accent);
    color: var(--accent-text);
    border: none;
    border-radius: var(--radius-sm);
    padding: 9px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}
.add-btn:hover { opacity: 0.85; }
.add-btn svg { width: 14px; height: 14px; }

.action-row {
    display: flex;
    gap: 8px;
}
.action-row .action-btn { flex: 1; margin-top: 0; }

/* Project modal: same principle as edit modal — parent overlay scrolls, not the modal itself */
#projectOverlay .modal {
    max-width: 560px;
    max-height: none;
    overflow-y: visible;
}

.map-container {
    height: 260px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
    margin-bottom: 8px;
}
.map-coords {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 16px;
}
.map-hint {
    font-size: 11.5px;
    color: var(--text-faint);
    margin-bottom: 8px;
}

.policy-group-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-faint);
    margin: 4px 0 2px;
}

/* Payments page */
.balance-amount {
    font-size: 21px;
    font-weight: 700;
    color: var(--text);
}
.balance-count {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}
.debt-amount {
    font-size: 13px;
    font-weight: 600;
    color: var(--red);
    margin-top: -6px;
}
.card-actions-row {
    display: flex;
    gap: 8px;
}
.card-actions-row .action-btn {
    flex: 1;
    margin-top: 0;
}
.card-actions-row .action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Payment transaction modal: same principle — parent overlay scrolls, not the modal itself */
#txOverlay .modal {
    max-width: 540px;
    max-height: none;
    overflow-y: visible;
}

.session-picker-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 260px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px;
    background: #fafafb;
}
.session-picker-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 6px;
    border-radius: 7px;
    font-size: 12.5px;
    cursor: pointer;
}
.session-picker-row:hover { background: #f0f0f2; }
.session-picker-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    accent-color: var(--accent);
}
.session-picker-info { flex: 1; min-width: 0; }
.session-picker-project { font-weight: 600; }
.session-picker-meta { color: var(--text-muted); font-size: 11.5px; margin-top: 1px; }
.session-picker-amount { font-weight: 700; flex-shrink: 0; }

.session-picker-total {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 600;
    padding: 10px 2px;
    color: var(--text-muted);
}
.session-picker-total b { color: var(--text); }

.tx-item-dates {
    font-size: 11.5px;
    color: var(--text-faint);
    margin-top: 2px;
}
