/* ECOMS — design system (v2, rebuilt from scratch) */

:root {
    --bg: #f4f6fb;
    --surface: #ffffff;
    --surface-muted: #f8f9fc;
    --border: #e3e7f0;
    --text-main: #1a1f36;
    --text-soft: #5b6478;
    --text-muted: #8892a6;

    /* RCJY-aligned palette (contractor visual alignment with client authority brand guide) */
    --primary: #2633ff;
    --primary-hover: #052976;
    --primary-soft: rgba(38, 51, 255, 0.10);
    --accent-purple: #8142ff;
    --accent-purple-soft: rgba(129, 66, 255, 0.10);

    --success-bg: #e9faf1;
    --success-border: #a6e8c4;
    --success-text: #0a9d76;

    --danger-bg: #fdeeee;
    --danger-border: #f3c4c4;
    --danger-text: #c73838;

    --warning-bg: #fff8e6;
    --warning-border: #f5dfa0;
    --warning-text: #a8720b;

    --shadow-soft: 0 1px 2px rgba(20, 25, 50, 0.04), 0 4px 14px rgba(20, 25, 50, 0.06);
    --shadow-card: 0 2px 4px rgba(20, 25, 50, 0.04), 0 10px 28px rgba(20, 25, 50, 0.07);

    /* The sidebar carries the brand navy regardless of light/dark theme — it's the one
       piece of chrome meant to read as "RCJY-branded" at a glance, not just accent buttons. */
    --sidebar-bg: #052350;
    --sidebar-bg-soft: #0a3a7a;
    --sidebar-text: rgba(255, 255, 255, 0.72);
    --sidebar-text-strong: #ffffff;
    --sidebar-hover-bg: rgba(255, 255, 255, 0.08);
    --sidebar-active-bg: rgba(129, 66, 255, 0.28);
    --sidebar-active-accent: #a78bfa;
    --sidebar-border: rgba(255, 255, 255, 0.10);

    --sidebar-width: 264px;
    --radius: 12px;
}

:root[data-theme="dark"] {
    --bg: #10131c;
    --surface: #171b28;
    --surface-muted: #1c2131;
    --border: #262c3f;
    --text-main: #eef0f6;
    --text-soft: #a4acc4;
    --text-muted: #747d99;

    --primary: #4cc4ff;
    --primary-hover: #7dd3ff;
    --primary-soft: rgba(76, 196, 255, 0.16);
    --accent-purple: #bf9fff;
    --accent-purple-soft: rgba(191, 159, 255, 0.16);

    --success-bg: rgba(32, 204, 118, 0.14);
    --success-border: #1c7a4c;
    --success-text: #4fe0a0;

    --danger-bg: rgba(199, 56, 56, 0.14);
    --danger-border: #8a2c2c;
    --danger-text: #f18585;

    --warning-bg: rgba(168, 114, 11, 0.16);
    --warning-border: #7a5a10;
    --warning-text: #f0b93d;

    --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 14px rgba(0, 0, 0, 0.35);
    --shadow-card: 0 2px 4px rgba(0, 0, 0, 0.3), 0 10px 28px rgba(0, 0, 0, 0.4);
}

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

html, body { height: 100%; }

body {
    /* RCJY's guide specifies "Ping AR + LT" (a licensed font this contractor doesn't hold);
       IBM Plex Sans Arabic is the closest freely-licensed match in weight and geometry. */
    font-family: 'IBM Plex Sans Arabic', 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text-main);
    font-size: 14px;
    line-height: 1.5;
}

a { color: inherit; text-decoration: none; }

/* ---------- App shell ---------- */

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-soft) 130%);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

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

.sidebar-brand-logo {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent-purple) 0%, #2633ff 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 17px;
    flex-shrink: 0;
    box-shadow: 0 4px 14px rgba(38, 51, 255, 0.35);
}

.sidebar-brand-text h2 { font-size: 15px; font-weight: 800; color: var(--sidebar-text-strong); }
.sidebar-brand-text p { font-size: 11px; color: var(--sidebar-text); font-weight: 600; margin-top: 1px; }

.sidebar-nav { padding: 8px 12px 20px; display: flex; flex-direction: column; gap: 2px; }

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 9px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--sidebar-text);
    border-inline-start: 3px solid transparent;
}

.sidebar-link:hover { background: var(--sidebar-hover-bg); color: var(--sidebar-text-strong); }

.sidebar-link.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-text-strong);
    border-inline-start-color: var(--sidebar-active-accent);
}

.sidebar-link.disabled {
    color: var(--sidebar-text);
    opacity: 0.4;
    cursor: default;
}

.sidebar-link-badge {
    margin-inline-start: auto;
    font-size: 9.5px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .03em;
    background: rgba(255, 255, 255, 0.12);
    color: var(--sidebar-text);
    padding: 2px 6px;
    border-radius: 999px;
}

.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.impersonate-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 8px 16px;
    background: var(--warning-bg);
    border-bottom: 1px solid var(--warning-border);
    color: var(--warning-text);
    font-size: 13px;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 50;
}
.impersonate-banner .btn { background: var(--warning-text); color: #fff; border: none; }

.topbar-impersonate select {
    padding: 7px 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface-muted);
    color: var(--text-main);
    font-size: 12.5px;
    max-width: 180px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 28px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}

:root[data-theme="dark"] .topbar { background: rgba(23, 27, 40, 0.85); }

.topbar-title { font-size: 16px; font-weight: 800; }

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 15px;
    position: relative;
}

.icon-btn:hover { background: var(--surface-muted); color: var(--text-main); }

.icon-btn-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    background: var(--danger-text);
    color: #fff;
    font-size: 9px;
    font-weight: 800;
    border-radius: 999px;
    min-width: 15px;
    height: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
}

.content { padding: 24px 28px 60px; flex: 1; }

/* ---------- Cards ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
    padding: 20px 22px;
    margin-bottom: 18px;
}

.card-title { font-size: 15px; font-weight: 800; margin-bottom: 4px; }
.card-text { font-size: 12.5px; color: var(--text-soft); }

.card-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: 9px;
    font-size: 13px;
    font-weight: 700;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform .06s ease;
}

.btn:active { transform: scale(0.98); }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary { background: var(--surface); color: var(--text-main); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-muted); }

.btn-danger { background: var(--danger-bg); color: var(--danger-text); border-color: var(--danger-border); }
.btn-danger:hover { filter: brightness(0.97); }

.btn-sm { padding: 6px 11px; font-size: 12px; }

/* ---------- Forms ---------- */

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px 16px;
    margin-bottom: 16px;
}

.form-group.full-width { grid-column: 1 / -1; }

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-soft);
    margin-bottom: 5px;
}

.form-group input:not([type="radio"]):not([type="checkbox"]),
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 11px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text-main);
    font-size: 13px;
    font-family: inherit;
}

.form-group label.radio-option {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-main);
    cursor: pointer;
    margin-bottom: 0;
}
.radio-option input[type="radio"] { width: auto; margin: 0; flex-shrink: 0; }

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.form-group input:disabled { opacity: 0.55; }

.form-group input[type="file"] {
    padding: 6px 10px 6px 6px;
    cursor: pointer;
    color: var(--text-soft);
    font-size: 12px;
}

.form-group input[type="file"]::file-selector-button {
    padding: 7px 14px;
    margin-inline-end: 12px;
    border: none;
    border-radius: 7px;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: background .1s ease;
}

.form-group input[type="file"]::file-selector-button:hover { background: var(--primary-hover); }

.form-hint { display: block; margin-top: 5px; font-size: 11.5px; color: var(--text-muted); }
.form-error { display: block; margin-top: 5px; font-size: 11.5px; color: var(--danger-text); font-weight: 700; }

.toolbar-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar-check { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--text-soft); }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.toolbar-select,
.toolbar-input {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface);
    color: var(--text-main);
    font-size: 13.5px;
    font-family: inherit;
}
.toolbar-select { min-width: 260px; }
.toolbar-input { min-width: 320px; }
.sidebar-search-input { width: 100%; min-width: 0; }
.toolbar-select:focus,
.toolbar-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}
.data-table th a { color: inherit; text-decoration: none; }
.data-table th a:hover { color: var(--primary); }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; }

.data-table { width: 100%; border-collapse: collapse; }

.data-table th {
    text-align: start;
    font-size: 11px;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .03em;
    padding: 0 12px 10px;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 12px;
    font-size: 13px;
    font-weight: 500;
    border-bottom: 1px solid var(--border);
}

.data-table tbody tr:hover { background: var(--surface-muted); }
.table-row-clickable { cursor: pointer; }

.table-empty { padding: 30px; text-align: center; color: var(--text-muted); font-size: 13px; font-weight: 600; }

/* ---------- Status pills ---------- */

.pill {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
}

.pill-good { background: var(--success-bg); color: var(--success-text); border: 1px solid var(--success-border); }
.pill-warn { background: var(--warning-bg); color: var(--warning-text); border: 1px solid var(--warning-border); }
.pill-bad { background: var(--danger-bg); color: var(--danger-text); border: 1px solid var(--danger-border); }
.pill-neutral { background: var(--surface-muted); color: var(--text-soft); border: 1px solid var(--border); }

/* ---------- Dashboard: personal task summary ---------- */

@keyframes dashFadeUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes dashRingIn {
    from { stroke-dashoffset: var(--ring-circumference); }
    to { stroke-dashoffset: var(--ring-offset); }
}

.dash-hero {
    position: relative;
    overflow: hidden;
    border-radius: 20px;
    padding: 28px 30px;
    margin-bottom: 20px;
    background:
        url('/assets/img/brand-pattern.svg') no-repeat right -60px top -40px / 420px auto,
        linear-gradient(135deg, #052350 0%, #0a3a7a 55%, #2633ff 100%);
    box-shadow: 0 16px 40px rgba(5, 35, 80, 0.28);
    color: #fff;
    animation: dashFadeUp .4s ease both;
}
.dash-hero-top { display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.dash-hero-greeting { font-size: 13px; font-weight: 700; color: rgba(255,255,255,.72); text-transform: uppercase; letter-spacing: .04em; }
.dash-hero-title { font-size: 24px; font-weight: 800; margin-top: 4px; }
.dash-hero-sub { font-size: 12.5px; color: rgba(255,255,255,.68); margin-top: 6px; }

.dash-ring-wrap { position: relative; width: 128px; height: 128px; flex-shrink: 0; }
.dash-ring-wrap svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.dash-ring-bg { fill: none; stroke: rgba(255,255,255,.16); stroke-width: 10; }
.dash-ring-fill { fill: none; stroke: #fff; stroke-width: 10; stroke-linecap: round; animation: dashRingIn 1s cubic-bezier(.22,1,.36,1) .15s both; filter: drop-shadow(0 0 8px rgba(255,255,255,.5)); }
.dash-ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.dash-ring-pct { font-size: 26px; font-weight: 800; }
.dash-ring-label { font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: rgba(255,255,255,.7); }

.dash-glass-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 22px; position: relative; z-index: 1; }
@media (max-width: 900px) { .dash-glass-row { grid-template-columns: repeat(2, 1fr); } }
.dash-glass-tile {
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.14);
    backdrop-filter: blur(6px);
    border-radius: 14px;
    padding: 14px 16px;
    transition: transform .18s ease, background .18s ease;
}
.dash-glass-tile:hover { transform: translateY(-3px); background: rgba(255,255,255,.13); }
.dash-glass-tile .stat-value { font-size: 24px; font-weight: 800; line-height: 1.1; }
.dash-glass-tile .stat-label { font-size: 11.5px; color: rgba(255,255,255,.68); font-weight: 600; margin-top: 4px; }
.dash-glass-tile.tile-danger .stat-value { color: #ff9b9b; }
.dash-glass-tile.tile-warn .stat-value { color: #ffd479; }
.dash-glass-tile.tile-good .stat-value { color: #7de3ab; }

.dash-panel-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 18px; margin-bottom: 18px; align-items: stretch; }
@media (max-width: 980px) { .dash-panel-grid { grid-template-columns: 1fr; } }

.dash-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
    padding: 18px 20px;
    animation: dashFadeUp .45s ease both;
}
.dash-panel-title { font-size: 13px; font-weight: 800; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; }
.dash-panel-title .pill { font-size: 10px; }

.dash-charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.dash-chart-box { text-align: center; }
.dash-chart-box canvas { max-height: 150px; }
.dash-chart-box .chart-caption { font-size: 11px; color: var(--text-soft); font-weight: 700; margin-top: 8px; }

.track-bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.track-bar-row:last-child { margin-bottom: 0; }
.track-bar-code {
    flex: 0 0 auto; font-size: 10.5px; font-weight: 800; color: var(--primary);
    background: var(--primary-soft); padding: 2px 8px; border-radius: 999px; min-width: 34px; text-align: center;
}
.track-bar-track { flex: 1; height: 9px; border-radius: 999px; background: var(--surface-muted); overflow: hidden; }
.track-bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--primary), var(--accent-purple)); animation: dashFadeUp .5s ease both; }
.track-bar-count { flex: 0 0 22px; text-align: end; font-size: 12px; font-weight: 700; color: var(--text-soft); }

.task-mini-list { display: flex; flex-direction: column; }
.task-mini-row {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 11px 12px; margin-bottom: 6px; border-radius: 10px;
    border-inline-start: 3px solid var(--border);
    background: var(--surface-muted);
    transition: transform .15s ease, box-shadow .15s ease;
}
.task-mini-row:last-child { margin-bottom: 0; }
.task-mini-row:hover { transform: translateX(-2px); box-shadow: var(--shadow-soft); }
:root[dir="rtl"] .task-mini-row:hover, .task-mini-row:hover { transform: translateY(-1px); }
.task-mini-title { font-size: 13px; font-weight: 700; }
.task-mini-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.task-mini-countdown { font-size: 10.5px; font-weight: 800; }

/* ---------- Alerts ---------- */

.alert { padding: 12px 16px; border-radius: 9px; font-size: 13px; font-weight: 600; margin-bottom: 16px; }
.alert-success { background: var(--success-bg); border: 1px solid var(--success-border); color: var(--success-text); }
.alert-danger { background: var(--danger-bg); border: 1px solid var(--danger-border); color: var(--danger-text); }

/* ---------- Work plan: layout ---------- */

.toolbar-select-lg { min-width: 420px; padding: 12px 16px; font-size: 14px; }

.workplan-layout { display: flex; gap: 16px; align-items: flex-start; }
.workplan-sidebar { width: 280px; flex-shrink: 0; }
.workplan-main { flex: 1; min-width: 0; }

.pool-list { min-height: 64px; border: 1px dashed var(--border); border-radius: 9px; padding: 10px; display: flex; flex-direction: column; gap: 8px; transition: background-color .12s, border-color .12s; }
.pool-list.drag-over { background: var(--primary-soft); border-color: var(--primary); }

/* ---------- Work plan site cards / drag-and-drop ---------- */

.site-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 16px; margin-bottom: 16px; }
.site-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-card); padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.site-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.site-card-title { font-size: 17px; font-weight: 800; }
.site-card-meta { font-size: 12.5px; }
.site-role-group + .site-role-group { margin-top: 2px; }
.site-role-label { font-size: 11.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin-bottom: 6px; }
.site-dropzone { min-height: 48px; border: 1px dashed var(--border); border-radius: 9px; padding: 10px; display: flex; flex-direction: column; gap: 8px; transition: background-color .12s, border-color .12s; }
.site-dropzone.drag-over { background: var(--primary-soft); border-color: var(--primary); }
.site-dropzone-slot { min-height: 42px; }
.employee-chip {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 10px;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 12.5px;
    cursor: grab;
    user-select: none;
}
.employee-chip:active { cursor: grabbing; opacity: .7; }
.employee-chip-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; margin-inline-start: auto; }
.employee-chip-name { font-weight: 700; }
.employee-chip-sub { color: var(--text-muted); font-size: 10.5px; }
.employee-chip-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 0;
    margin-inline-start: auto;
    flex-shrink: 0;
}
.employee-chip-remove:hover { color: var(--danger-text); border-color: var(--danger-border); background: var(--danger-bg); }
.employee-chip select { font-size: 10.5px; padding: 2px 4px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text-main); }
.employee-chip-tag { font-size: 10px; font-weight: 700; color: var(--primary); }

.offday-checks { display: flex; gap: 4px; flex-wrap: wrap; }
.offday-check { display: inline-flex; align-items: center; gap: 2px; font-size: 9.5px; color: var(--text-muted); cursor: pointer; user-select: none; }
.offday-check input { margin: 0; cursor: pointer; }

/* ---------- Attendance ---------- */

.attendance-meta { display: flex; flex-direction: column; gap: 2px; margin-bottom: 4px; }
.worker-list { display: flex; flex-direction: column; gap: 8px; }
.worker-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 10px;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 12.5px;
}
.worker-row-name { font-weight: 700; }
.worker-row-sub { color: var(--text-muted); font-size: 10.5px; }
.worker-row-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-inline-start: auto; }

.attendance-layout { display: flex; gap: 16px; align-items: flex-start; }
.attendance-personal { width: 380px; flex-shrink: 0; }
.attendance-workers-col { flex: 1; min-width: 0; }
.attendance-map { width: 100%; height: 220px; border-radius: 10px; margin-bottom: 10px; border: 1px solid var(--border); }
.checkin-toggle-btn { width: 100%; padding: 14px; font-size: 15px; font-weight: 800; }

/* ---------- Summary tiles (Monthly Statements) ---------- */

.summary-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.summary-tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
    padding: 14px 16px;
}
.summary-tile-label { display: block; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); margin-bottom: 6px; }
.summary-tile-value { font-size: 20px; font-weight: 800; color: var(--text-main); }
.summary-tile-value.is-total { color: var(--primary); }
.data-table tfoot td { border-bottom: none; border-top: 2px solid var(--border); font-weight: 800; background: var(--surface-muted); }

/* ---------- Modal ---------- */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 18, 30, 0.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.modal-open { display: flex; }

.modal-box {
    background: var(--surface);
    border-radius: 16px;
    box-shadow: var(--shadow-card);
    width: min(640px, 100%);
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    padding: 22px;
}

.modal-box-wide { width: min(920px, 100%); }

.modal-box-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.modal-box-title { font-size: 15px; font-weight: 800; }

.modal-close-btn {
    background: none;
    border: none;
    font-size: 20px;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
}

body.modal-lock { overflow: hidden; }

/* ---------- Collapsible sections ---------- */

.collapsible { margin-bottom: 16px; }

.collapsible-header {
    position: sticky;
    top: 68px;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    cursor: pointer;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 13px 16px;
    font-size: 13.5px;
    font-weight: 800;
}

.collapsible-header::-webkit-details-marker { display: none; }
.collapsible-header::after { content: '\25BC'; font-size: .65rem; color: var(--text-muted); transition: transform .15s; }
.collapsible[open] > .collapsible-header::after { transform: rotate(180deg); }
.collapsible[open] > .collapsible-header { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }

.collapsible-body {
    padding: 16px;
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 10px 10px;
    background: var(--surface-muted);
}

/* ---------- Auth pages ---------- */

.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        url('/assets/img/brand-pattern.svg') no-repeat left bottom / 480px auto,
        linear-gradient(160deg, #052350 0%, #0a3a7a 55%, #2633ff 100%);
    padding: 24px;
}

.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(5, 35, 80, 0.35);
    padding: 36px;
    width: 100%;
    max-width: 380px;
}

.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-card h1 { font-size: 19px; font-weight: 800; margin-bottom: 4px; }
.auth-card .subtitle { color: var(--text-soft); font-size: 13px; margin-bottom: 20px; }
.auth-field { margin-bottom: 14px; }
.auth-field label { display: block; font-size: 12px; font-weight: 700; color: var(--text-soft); margin-bottom: 5px; }
.auth-field input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; font-size: 13.5px; background: var(--surface); color: var(--text-main); }
.auth-field input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

/* ---------- Chat (1:1 contract-scoped direct messages) ---------- */

.chat-shell {
    display: flex;
    height: calc(100vh - 160px);
    min-height: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

.chat-contacts {
    width: 300px;
    flex-shrink: 0;
    border-inline-end: 1px solid var(--border);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.chat-contacts-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    font-weight: 800;
}

.chat-contact {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: var(--text-main);
}

.chat-contact:hover { background: var(--surface-muted); }
.chat-contact.active { background: var(--primary-soft); }

.chat-avatar {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 12.5px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-contact-body { min-width: 0; flex: 1; }
.chat-contact-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.chat-contact-name { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-contact-time { font-size: 10.5px; color: var(--text-muted); flex-shrink: 0; }
.chat-contact-preview {
    font-size: 12px;
    color: var(--text-soft);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.chat-contact-unread {
    flex-shrink: 0;
    min-width: 18px;
    height: 18px;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}

.chat-thread { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.chat-thread-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
}

.chat-thread-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    padding: 24px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: var(--bg);
}

.chat-bubble-row { display: flex; }
.chat-bubble-row.own { justify-content: flex-end; }
.chat-bubble-row.other { justify-content: flex-start; }

.chat-bubble {
    max-width: 62%;
    padding: 8px 12px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 3px 0;
    box-shadow: var(--shadow-soft);
}

.chat-bubble.other { background: var(--surface); border: 1px solid var(--border); border-start-start-radius: 4px; }
.chat-bubble.own { background: var(--primary); color: #fff; border-start-end-radius: 4px; }

.chat-bubble-time {
    display: block;
    margin-top: 4px;
    font-size: 10px;
    font-weight: 600;
    opacity: .7;
}

.chat-send-form {
    display: flex;
    gap: 10px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    align-items: flex-end;
}

.chat-send-form textarea {
    flex: 1;
    resize: none;
    min-height: 40px;
    max-height: 120px;
}

@media (max-width: 880px) {
    .sidebar { position: fixed; inset-inline-start: 0; transform: translateX(-100%); transition: transform .2s; z-index: 300; }
    .sidebar.open { transform: translateX(0); }
    .content { padding: 18px; }
    .chat-shell { flex-direction: column; height: auto; }
    .chat-contacts { width: 100%; max-height: 260px; }
}
