/* =====================================================================
   TaskFlow v2 — components.css
   ===================================================================== */

/* ───── Layout shell ───── */
.app-view { display:flex; min-height:100vh; }
.main     { flex:1; min-width:0; display:flex; flex-direction:column; }
.page     { padding: 20px 24px 60px; max-width: 1400px; margin: 0 auto; width: 100%; }

/* ───── Sidebar ───── */
.sidebar {
    width: 260px;
    background: var(--surface-1, #fff);
    border-right: 1px solid var(--border, #e6e8ee);
    display:flex; flex-direction:column;
    position: sticky; top:0; align-self:flex-start;
    height: 100vh; z-index: 50;
    flex-shrink: 0;
}
.sidebar-brand {
    display:flex; align-items:center; gap:10px;
    padding: 18px 20px; border-bottom: 1px solid var(--border, #e6e8ee);
    color: var(--accent, #4f46e5);
}
.sidebar-brand .sidebar-name { font-weight:700; font-size:16px; color: var(--text-strong, #0c1322); }
.sidebar-brand .brand-mark.sm { color: var(--accent, #4f46e5); }
.sidebar-close { display:none; margin-left:auto; background:none; border:none; cursor:pointer; color: var(--text-muted); }

.sidebar-nav { flex:1; padding: 12px 12px; overflow:auto; }
.sidebar-divider { height:1px; background: var(--border, #e6e8ee); margin: 8px 4px; }

.nav-item {
    display:flex; align-items:center; gap:10px;
    padding: 10px 12px; border-radius:8px;
    color: var(--text, #4a5365); text-decoration:none;
    font-size:14px; font-weight:500; position:relative;
    margin-bottom: 2px;
}
.nav-item:hover  { background: var(--surface-hover, #f4f6fa); }
.nav-item.active { background: var(--accent-soft, #eef2ff); color: var(--accent, #4338ca); }
.nav-item svg    { width:18px; height:18px; flex-shrink:0; }
.nav-badge {
    margin-left:auto; background:#ef4444; color:#fff;
    font-size:11px; padding:2px 7px; border-radius:9px; font-weight:600;
}

.sidebar-footer { padding: 14px; border-top:1px solid var(--border, #e6e8ee); }
.user-card { display:flex; align-items:center; gap:10px; }
.user-card .meta .name { font-weight:600; font-size:13px; color: var(--text-strong, #0c1322); }
.user-card .meta .role { font-size:11.5px; color: var(--text-muted, #8993a4); }

/* ───── 🆕 Mobile sidebar backdrop ───── */
.sidebar-backdrop {
    display:none;
    position:fixed; inset:0;
    background: rgba(7,13,28,0.5);
    z-index: 40;
}
.sidebar-backdrop.visible { display:block; }
.no-scroll { overflow: hidden; }

@media (max-width: 1023px) {
    .sidebar {
        position: fixed; left:0; top:0;
        transform: translateX(-100%); transition: transform .25s ease;
        box-shadow: 2px 0 20px rgba(7,13,28,0.06);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-close { display:inline-flex; }
    .main { width: 100%; }
}
@media (min-width: 1024px) {
    .topbar-menu { display:none; }
}

/* ───── Topbar ───── */
.topbar {
    display:flex; align-items:center; gap:12px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border, #e6e8ee);
    background: var(--surface-1, #fff);
    position: sticky; top:0; z-index: 30;
}
.topbar-menu {
    background:none; border:none; cursor:pointer; padding:6px;
    color: var(--text, #4a5365);
}
.topbar-title { font-size:15px; font-weight:600; color: var(--text-strong, #0c1322); }
.topbar-right { margin-left:auto; display:flex; align-items:center; gap:8px; }

.attendance-pill {
    display:inline-flex; align-items:center; gap:6px;
    padding: 4px 10px; border-radius: 999px;
    background: var(--surface-2, #f1f3f6); font-size: 12.5px;
}
.attendance-pill .dot { width:8px; height:8px; border-radius:50%; background:#9ca3af; }
.attendance-pill .dot.green { background:#10b981; }
.attendance-pill small { color: var(--text-muted, #8993a4); }

.btn-icon-ghost {
    background:none; border:none; cursor:pointer; padding:6px;
    border-radius:6px; color: var(--text, #4a5365);
}
.btn-icon-ghost:hover { background: var(--surface-hover, #f4f6fa); }

/* ───── Flash messages ───── */
.flash {
    margin: 16px 24px 0; padding: 12px 16px;
    border-radius: 10px; font-size: 13.5px;
    display:flex; gap:10px; align-items:center;
}
.flash-success { background:#dcfce7; color:#166534; border:1px solid #bbf7d0; }
.flash-error   { background:#fee2e2; color:#991b1b; border:1px solid #fecaca; }

/* ───── Headers, grids ───── */
.page-header {
    display:flex; justify-content:space-between; align-items:center;
    flex-wrap:wrap; gap:12px; margin-bottom: 20px;
}
.page-header h1 { font-size: 22px; margin: 0; color: var(--text-strong, #0c1322); }
.back-link { font-size:12.5px; color: var(--text-muted, #8993a4); text-decoration:none; }
.section-title { font-size:14px; font-weight:600; color: var(--text-strong, #0c1322); margin: 0 0 12px; }

.stats-grid {
    display:grid; gap:14px;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    margin-bottom: 22px;
}
.stat-card {
    background: var(--surface-1, #fff);
    border:1px solid var(--border, #e6e8ee);
    border-radius:10px; padding:16px;
    display:flex; align-items:center; gap:12px;
}
.stat-icon {
    width:38px; height:38px; border-radius:9px;
    display:flex; align-items:center; justify-content:center;
}
.stat-label { font-size:12px; color: var(--text-muted, #8993a4); }
.stat-number { font-size:22px; font-weight:700; color: var(--text-strong, #0c1322); }

.two-col {
    display:grid; gap:18px;
    grid-template-columns: 1fr;
}
@media (min-width: 900px) {
    .two-col { grid-template-columns: 1.4fr 1fr; }
}

.card {
    background: var(--surface-1, #fff);
    border:1px solid var(--border, #e6e8ee);
    border-radius:10px; padding:18px;
}
.card.form-card { padding: 22px; }
.table-card { padding: 0; overflow:hidden; }

/* ───── Forms ───── */
.form-grid {
    display:grid; gap:14px; grid-template-columns: 1fr 1fr;
}
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }
.span-2 { grid-column: span 2; }
@media (max-width: 700px) { .span-2 { grid-column: span 1; } }

.field { display:flex; flex-direction:column; gap:6px; font-size:13px; }
.field > span { font-weight:500; color: var(--text-strong, #0c1322); }
.field > span em { color:#ef4444; font-style:normal; }
.field input,
.field select,
.field textarea {
    border:1px solid var(--border, #e6e8ee);
    border-radius:8px; padding:9px 12px;
    font: inherit; color: var(--text-strong, #0c1322);
    background: var(--surface-1, #fff);
}
.field input:focus,
.field select:focus,
.field textarea:focus {
    outline:none; border-color: var(--accent, #4f46e5);
    box-shadow: 0 0 0 3px var(--accent-soft, #eef2ff);
}
.field input[type=color] { padding: 2px; height: 38px; }

.form-actions { display:flex; justify-content:flex-end; gap:8px; margin-top:18px; }
.checkbox-inline { display:flex; align-items:center; gap:8px; font-size:13px; }

.filter-bar {
    display:flex; flex-wrap:wrap; gap:8px; margin-bottom: 18px;
    background: var(--surface-1, #fff);
    border:1px solid var(--border, #e6e8ee);
    border-radius:10px; padding:10px;
}
.filter-bar input,
.filter-bar select {
    border:1px solid var(--border, #e6e8ee); border-radius:7px;
    padding:7px 10px; font: inherit; font-size:13px;
}

/* ───── Buttons ───── */
.btn {
    display:inline-flex; align-items:center; gap:8px;
    padding:9px 14px; border-radius:8px;
    font: 600 13.5px/1 'Plus Jakarta Sans', sans-serif;
    border:1px solid transparent; cursor:pointer;
    text-decoration:none; transition: background .15s, border-color .15s;
}
.btn-sm { padding: 6px 10px; font-size: 12.5px; }
.btn-primary { background: var(--accent, #4f46e5); color:#fff; }
.btn-primary:hover { background: var(--accent-strong, #4338ca); }
.btn-ghost { background: var(--surface-1, #fff); color: var(--text, #4a5365); border-color: var(--border, #e6e8ee); }
.btn-ghost:hover { background: var(--surface-hover, #f4f6fa); }
.btn-block { width:100%; justify-content:center; padding: 11px 14px; }

/* ───── Tables ───── */
.data-table { width:100%; border-collapse: collapse; font-size:13.5px; }
.data-table thead th {
    text-align:left; padding: 12px 14px;
    background: var(--surface-2, #f8f9fb);
    color: var(--text-muted, #8993a4);
    border-bottom: 1px solid var(--border, #e6e8ee);
    font-weight:600; font-size:12px; text-transform: uppercase; letter-spacing: .03em;
}
.data-table tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border-soft, #f1f3f6); vertical-align:middle; }
.data-table tbody tr:hover { background: var(--surface-hover, #f8f9fb); }
.empty-row { text-align:center; padding: 36px 14px !important; color: var(--text-muted, #8993a4); }

/* ───── Chips / pills ───── */
.chip {
    display:inline-flex; align-items:center; gap:5px;
    padding: 3px 9px; border-radius: 999px;
    font-size: 11.5px; font-weight:600;
    background: var(--surface-2, #f1f3f6); color: var(--text-strong, #0c1322);
}
.chip-sm { padding: 1px 7px; font-size: 10.5px; }
.chip-ghost   { background: var(--surface-2, #f1f3f6); color: var(--text, #4a5365); }
.chip-success { background:#dcfce7; color:#166534; }
.chip-danger  { background:#fee2e2; color:#991b1b; }

.chip-priority.chip-low      { background:#e0f2fe; color:#075985; }
.chip-priority.chip-medium   { background:#eef2ff; color:#4338ca; }
.chip-priority.chip-high     { background:#fef3c7; color:#92400e; }
.chip-priority.chip-critical { background:#fee2e2; color:#991b1b; }

.chip-status.chip-pending      { background:#fef3c7; color:#92400e; }
.chip-status.chip-in-progress  { background:#dbeafe; color:#1d4ed8; }
.chip-status.chip-under-review { background:#fce7f3; color:#9d174d; }
.chip-status.chip-completed    { background:#dcfce7; color:#166534; }
.chip-status.chip-rejected     { background:#fee2e2; color:#991b1b; }
.chip-status.chip-reopened     { background:#e9d5ff; color:#6b21a8; }

.user-pill {
    display:inline-flex; align-items:center; gap:8px;
}
.avatar {
    display:inline-flex; align-items:center; justify-content:center;
    border-radius:50%; color:#fff; font-weight:700; font-size:12px;
    width:32px; height:32px;
}
.avatar.sm { width:28px; height:28px; font-size:11px; }
.avatar.xs { width:22px; height:22px; font-size:10px; }

.task-link { font-weight:600; color: var(--text-strong, #0c1322); text-decoration:none; }
.task-link:hover { color: var(--accent, #4f46e5); }

.task-show-grid {
    display:grid; gap:18px; grid-template-columns: 1fr;
}
@media (min-width: 900px) {
    .task-show-grid { grid-template-columns: 2fr 1fr; }
}
.task-chips { display:flex; gap:6px; flex-wrap:wrap; }

.progress-bar {
    height:10px; border-radius:6px;
    background: var(--surface-2, #f1f3f6); overflow:hidden;
}
.progress-bar-fill {
    height:100%; background: linear-gradient(90deg, #4f46e5, #6366f1);
    transition: width .25s ease;
}
.progress-mini {
    width:90px; height:6px; background:#eef0f4; border-radius:3px; overflow:hidden;
}
.progress-mini-bar { height:100%; background:#4f46e5; }

.kv-grid {
    display:grid; grid-template-columns: 130px 1fr; gap: 8px 14px;
    margin:14px 0 0; font-size: 13.5px;
}
.kv-grid dt { color: var(--text-muted, #8993a4); }
.kv-grid dd { margin:0; color: var(--text-strong, #0c1322); }

.bare-list { list-style:none; margin:0; padding:0; }
.bare-list li { padding:8px 0; border-bottom: 1px solid var(--border-soft, #f1f3f6); font-size:13.5px; }
.bare-list li:last-child { border-bottom:none; }
.bare-list small { color: var(--text-muted, #8993a4); margin-left: 6px; }

.activity-list { list-style:none; margin:0; padding:0; font-size: 13px; }
.activity-list li {
    padding: 8px 0; border-bottom: 1px solid var(--border-soft, #f1f3f6);
    color: var(--text, #4a5365);
}
.activity-list li:last-child { border-bottom: none; }
.activity-list small { color: var(--text-muted, #8993a4); margin-left: 6px; }
.muted { color: var(--text-muted, #8993a4); }

.audit-row code { background: var(--surface-2, #f1f3f6); padding: 1px 6px; border-radius: 4px; font-size: 11.5px; }

/* ───── Comments ───── */
.comment-list { display:flex; flex-direction: column; gap:14px; }
.comment {
    display:flex; gap:10px; align-items:flex-start;
    padding-bottom:12px; border-bottom: 1px solid var(--border-soft, #f1f3f6);
}
.comment:last-child { border-bottom:none; }
.comment-body { flex:1; }
.comment-meta { display:flex; gap:8px; align-items:baseline; font-size:13px; margin-bottom:4px; }
.comment-meta small { color: var(--text-muted, #8993a4); }
.comment-text { font-size: 14px; line-height: 1.5; white-space: pre-wrap; }

.mention-tag {
    color: var(--accent, #4f46e5); background: var(--accent-soft, #eef2ff);
    padding: 1px 6px; border-radius: 4px; font-weight:600;
}

.attachments { display:flex; flex-wrap:wrap; gap:8px; margin-top:8px; }
.attachment-chip {
    display:inline-flex; align-items:center; gap:6px;
    padding: 4px 8px; border-radius: 8px;
    border: 1px solid var(--border, #e6e8ee);
    background: var(--surface-1, #fff);
    font-size: 12px; color: var(--text-strong, #0c1322);
    text-decoration:none; max-width: 100%;
}
.attachment-chip img { width: 22px; height: 22px; border-radius: 4px; object-fit:cover; }
.attachment-chip small { color: var(--text-muted, #8993a4); margin-left:4px; }

.comment-form { display:flex; flex-direction:column; gap:10px; margin-top: 8px; }
.comment-textarea-wrap { position:relative; }
.comment-form textarea {
    width:100%; min-height:80px;
    border:1px solid var(--border, #e6e8ee); border-radius:8px;
    padding: 10px 12px; font:inherit; font-size: 14px; resize:vertical;
}
.comment-form textarea:focus { outline:none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.progress-row {
    display:flex; align-items:center; gap:14px;
}
.progress-label {
    display:flex; align-items:center; gap:10px; font-size:13px; flex-shrink:0;
}
.progress-value { font-weight:600; color: var(--accent, #4f46e5); min-width: 40px; }
.progress-slider {
    flex:1;
    -webkit-appearance: none; appearance: none;
    height: 6px; border-radius: 3px;
    background: var(--surface-2, #f1f3f6);
}
.progress-slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width:18px; height:18px; border-radius:50%;
    background: var(--accent, #4f46e5); cursor:pointer;
    border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.progress-slider::-moz-range-thumb {
    width:18px; height:18px; border-radius:50%;
    background: var(--accent); cursor:pointer; border: 3px solid #fff;
}

.attach-row { display:flex; flex-wrap:wrap; align-items:center; gap: 10px; font-size: 12.5px; }
.file-pick {
    display:inline-flex; align-items:center; gap:6px;
    padding: 6px 10px; border-radius: 8px;
    border: 1px dashed var(--border, #e6e8ee);
    background: var(--surface-2, #f8f9fb); cursor:pointer; color: var(--text, #4a5365);
}
.file-pick input { display:none; }
.attach-row .hint { color: var(--text-muted, #8993a4); }
.file-preview { display:flex; flex-wrap:wrap; gap:6px; flex-basis:100%; }

.status-quick {
    border:1px solid var(--border); border-radius:7px; padding: 8px 10px; font: inherit;
}

/* ───── Mention dropdown ───── */
.mention-dropdown {
    background: #fff;
    border:1px solid var(--border, #e6e8ee);
    border-radius:10px;
    box-shadow: 0 10px 30px rgba(7,13,28,0.12);
    max-height: 260px; overflow:auto;
    z-index: 1100;
    padding: 4px;
}
.mention-item {
    display:flex; align-items:center; gap:10px;
    padding: 8px 10px; border-radius: 7px; cursor:pointer; font-size:13px;
}
.mention-item.active,
.mention-item:hover { background: var(--surface-hover, #f4f6fa); }
.mention-avatar {
    width:26px; height:26px; border-radius:50%;
    display:inline-flex; align-items:center; justify-content:center;
    color:#fff; font-weight:700; font-size:11px;
}
.mention-name { font-weight:600; color: var(--text-strong, #0c1322); }
.mention-item small { color: var(--text-muted, #8993a4); }
.mention-empty { padding: 10px; color: var(--text-muted, #8993a4); font-size:13px; }

.mention-list {
    list-style:none; margin:0; padding:0;
    display:flex; flex-direction:column; gap:10px;
}
.mention-list li {
    display:flex; gap:10px; align-items:flex-start;
    padding: 12px; border:1px solid var(--border-soft, #f1f3f6); border-radius:9px;
    font-size: 13.5px;
}
.mention-list li small { color: var(--text-muted, #8993a4); display:block; margin-top: 4px; }

/* ───── Attendance card ───── */
.attendance-card { display:flex; justify-content: space-between; align-items: center; gap: 16px; }

/* ───── Todo cards ───── */
.todo-grid {
    display:grid; gap:14px;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.todo-card {
    display:flex; flex-direction:column; gap: 8px;
    padding: 14px; border-radius: 10px;
    background: var(--surface-1, #fff); border: 1px solid var(--border, #e6e8ee);
    text-decoration:none; color: inherit;
    transition: border-color .15s, transform .15s;
}
.todo-card:hover { border-color: var(--accent, #4f46e5); transform: translateY(-1px); }
.todo-card h4 { margin: 4px 0; font-size: 14.5px; color: var(--text-strong, #0c1322); }
.todo-head { display:flex; justify-content:space-between; align-items:center; }
.todo-head small { color: var(--text-muted, #8993a4); }
.todo-meta { display:flex; justify-content:space-between; align-items:center; font-size:12.5px; }
.todo-meta small { color: var(--text-muted, #8993a4); }

/* ───── Calendar ───── */
.calendar-legend {
    display:flex; align-items:center; gap:6px;
    font-size:12.5px; color: var(--text-muted, #8993a4);
    margin-bottom: 12px;
}
.legend-dot {
    display:inline-block; width:10px; height:10px; border-radius:50%; margin-right:4px;
}
.cal-grid-head {
    display:grid; grid-template-columns: repeat(7, 1fr); gap:1px;
    background: var(--border-soft, #f1f3f6);
    padding:1px 1px 0;
}
.cal-grid-head span {
    background: var(--surface-2, #f8f9fb); padding: 8px 6px;
    font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
    color: var(--text-muted, #8993a4); font-weight:600; text-align:center;
}
.cal-grid {
    display:grid; grid-template-columns: repeat(7, 1fr);
    gap:1px; background: var(--border-soft, #f1f3f6); padding: 0 1px 1px;
}
.cal-cell {
    background: var(--surface-1, #fff);
    min-height: 92px; padding: 6px; display:flex; flex-direction:column; gap:4px;
}
.cal-cell.empty { background: var(--surface-2, #f8f9fb); }
.cal-cell.today { background: var(--accent-soft, #eef2ff); }
.cal-day-num { font-size: 12.5px; color: var(--text-muted, #8993a4); font-weight:600; }
.cal-events { display:flex; flex-direction:column; gap:3px; flex:1; }
.cal-ev {
    font-size: 11px; color: #fff !important;
    padding: 2px 6px; border-radius: 4px;
    text-decoration:none;
    overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.cal-ev:hover { opacity:0.9; }

@media (max-width: 700px) {
    .cal-cell { min-height: 64px; }
    .cal-ev { font-size: 10px; }
}

/* ───── Login view ───── */
.login-view {
    min-height: 100vh; display:flex; align-items:center; justify-content:center;
    background: linear-gradient(135deg, #eef2ff 0%, #f6f7f9 100%);
    padding: 24px;
}
.login-shell { width: 100%; max-width: 440px; position:relative; z-index:1; }
.login-brand {
    display:flex; align-items:center; gap:14px; margin-bottom:24px;
    color: var(--accent, #4f46e5);
}
.brand-name { font-size:24px; font-weight:800; margin:0; color: var(--text-strong, #0c1322); }
.brand-tag  { font-size:12.5px; color: var(--text-muted, #8993a4); margin:2px 0 0; }
.login-card {
    background:#fff; border:1px solid #e6e8ee; border-radius:14px;
    padding: 28px; box-shadow: 0 30px 60px rgba(7, 13, 28, 0.05);
}
.login-card-header { margin-bottom: 18px; }
.login-card-header h2 { margin:0 0 4px; font-size:18px; color: var(--text-strong, #0c1322); }
.login-card-header p  { margin:0; color: var(--text-muted, #8993a4); font-size:13px; }
.login-form { display:flex; flex-direction:column; gap:14px; }
.login-error { color:#b91c1c; font-size:12.5px; min-height: 16px; }

.otp-box {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 22px; letter-spacing: 10px; text-align:center; padding:12px;
}
.step-info {
    background: #eef2ff; color: #4338ca;
    border:1px solid #c7d2fe; padding:9px 12px; border-radius:8px;
    font-size:12.5px; margin-bottom:14px;
}
.geo-note {
    display:flex; align-items:center; gap:6px; font-size:12px; color: var(--text-muted);
    background: var(--surface-2, #f8f9fb); padding: 8px 10px; border-radius: 7px;
}
.timer-line {
    display:flex; justify-content:space-between; align-items:center;
    font-size:12.5px; margin-top:10px;
}
.timer-line .countdown { color: var(--text-muted, #8993a4); }
.resend-btn {
    background:none; border:none; font:inherit;
    color: var(--accent, #4f46e5); cursor:pointer; font-weight:600; padding:0;
}
.resend-btn[disabled] { color: var(--text-muted, #8993a4); cursor:not-allowed; }
.login-helper { margin-top: 16px; font-size: 12px; color: var(--text-muted, #8993a4); }
.login-helper summary { cursor:pointer; padding: 4px 0; }
.login-helper ul { margin: 6px 0 6px 18px; padding: 0; }
.login-footer { margin-top: 18px; text-align:center; font-size: 11.5px; color: var(--text-muted, #8993a4); }
.login-bg-grid {
    position:absolute; inset:0;
    background-image: linear-gradient(rgba(99,102,241,0.06) 1px, transparent 1px),
                      linear-gradient(90deg, rgba(99,102,241,0.06) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events:none;
}

/* ───── Dark theme ───── */
[data-theme="dark"] {
    --surface-1: #131722;
    --surface-2: #1a1f2c;
    --surface-hover: #1c2231;
    --border: #2a2f3d;
    --border-soft: #1e2331;
    --text: #c5c9d3;
    --text-strong: #f1f3f7;
    --text-muted: #7b8295;
    --accent: #818cf8;
    --accent-strong: #6366f1;
    --accent-soft: #1e1f3a;
}
[data-theme="dark"] body { background: #0c0f17; color: var(--text); }
[data-theme="dark"] .login-view { background: linear-gradient(135deg, #0c0f17 0%, #131722 100%); }
[data-theme="dark"] .login-card { background: var(--surface-1); border-color: var(--border); }

/* =====================================================================
   HOD Dashboard — Division Snapshot v2
   ===================================================================== */

/* KPI strip */
.snapshot-kpis {
    display:grid; gap:14px;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    margin-bottom: 18px;
}
.kpi {
    position: relative;
    background: var(--surface-1, #fff);
    border:1px solid var(--border, #e6e8ee);
    border-radius:12px; padding:16px 18px;
    display:flex; flex-direction:column; gap:4px;
    overflow:hidden;
}
.kpi::before {
    content:''; position:absolute; top:0; left:0; right:0; height:3px;
    background: linear-gradient(90deg, transparent, var(--accent-soft, #eef2ff));
}
.kpi-icon {
    width:36px; height:36px; border-radius:8px;
    display:flex; align-items:center; justify-content:center;
    background: var(--accent-soft, #eef2ff); color: var(--accent, #4f46e5);
    margin-bottom: 6px;
}
.kpi-num   { font-size: 26px; font-weight: 800; color: var(--text-strong, #0c1322); line-height: 1.1; }
.kpi-label { font-size: 12.5px; color: var(--text, #4a5365); font-weight: 600; }
.kpi-sub   { font-size: 11.5px; color: var(--text-muted, #8993a4); margin-top: 2px; }

.kpi-primary .kpi-icon { background:#eef2ff; color:#4f46e5; }
.kpi-primary::before   { background: linear-gradient(90deg, #4f46e5, transparent); }
.kpi-success .kpi-icon { background:#dcfce7; color:#15803d; }
.kpi-success::before   { background: linear-gradient(90deg, #10b981, transparent); }
.kpi-danger  .kpi-icon { background:#fee2e2; color:#b91c1c; }
.kpi-danger::before    { background: linear-gradient(90deg, #ef4444, transparent); }
.kpi-warn    .kpi-icon { background:#fef3c7; color:#b45309; }
.kpi-warn::before      { background: linear-gradient(90deg, #f59e0b, transparent); }

/* Two-up & three-up grids */
.snapshot-grid {
    display:grid; gap:16px;
    grid-template-columns: 1fr;
    margin-bottom: 18px;
}
@media (min-width: 900px) {
    .snapshot-grid { grid-template-columns: 1.4fr 1fr; }
}
.snapshot-grid-3 {
    display:grid; gap:16px;
    grid-template-columns: 1fr;
}
@media (min-width: 1100px) {
    .snapshot-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
}
@media (min-width: 700px) and (max-width: 1099px) {
    .snapshot-grid-3 { grid-template-columns: 1fr 1fr; }
}

.card-head {
    display:flex; justify-content:space-between; align-items:baseline;
    margin-bottom: 12px;
}
.btn-link {
    font-size: 12px; color: var(--accent, #4f46e5); text-decoration:none; font-weight:600;
}
.btn-link:hover { text-decoration:underline; }

/* Stacked status bar */
.status-bar {
    display:flex; height: 12px; border-radius:6px; overflow:hidden;
    background: var(--surface-2, #f1f3f6); margin-bottom: 14px;
}
.status-seg { transition: opacity .15s; min-width: 3px; }
.status-seg:hover { opacity: 0.85; }

.status-legend {
    list-style:none; padding:0; margin:0;
    display:grid; grid-template-columns: 1fr 1fr; gap: 6px 14px;
    font-size:12.5px;
}
@media (max-width: 500px) {
    .status-legend { grid-template-columns: 1fr; }
}
.status-legend li {
    display:flex; align-items:center; gap:8px;
}
.legend-swatch {
    width:10px; height:10px; border-radius:3px; flex-shrink:0;
}
.legend-label { flex:1; color: var(--text, #4a5365); }
.status-legend b     { color: var(--text-strong, #0c1322); }
.status-legend small { color: var(--text-muted, #8993a4); min-width: 32px; text-align:right; }

/* Priority horizontal bars */
.priority-stack { display:flex; flex-direction:column; gap:10px; }
.priority-row {
    display:grid; grid-template-columns: 70px 1fr 36px; align-items:center; gap:10px;
}
.priority-label { font-size: 12.5px; font-weight:600; color: var(--text, #4a5365); }
.priority-track {
    height:8px; background: var(--surface-2, #f1f3f6); border-radius:5px; overflow:hidden;
}
.priority-fill { height:100%; border-radius:5px; transition: width .3s; }
.priority-num  { font-size: 13px; font-weight: 700; color: var(--text-strong, #0c1322); text-align:right; }

/* Attention rows */
.attention-row {
    display:flex; align-items:center; gap:10px;
    padding: 10px 0; border-bottom: 1px solid var(--border-soft, #f1f3f6);
    text-decoration:none; color:inherit;
}
.attention-row:last-child { border-bottom:none; }
.attention-row:hover .attention-title { color: var(--accent, #4f46e5); }
.attention-body { flex:1; min-width:0; }
.attention-title {
    font-size:13.5px; font-weight:600; color: var(--text-strong, #0c1322);
    overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.attention-row small { color: var(--text-muted, #8993a4); font-size: 11.5px; }
.text-danger { color: #b91c1c; }

/* Member load rows */
.member-row {
    display:flex; align-items:center; gap:10px;
    padding: 10px 0; border-bottom: 1px solid var(--border-soft, #f1f3f6);
}
.member-row:last-child { border-bottom:none; }
.member-info { flex:1; min-width:0; }
.member-name {
    font-size:13px; font-weight:600; color: var(--text-strong, #0c1322);
    overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.member-name small { font-weight:500; margin-left: 4px; }
.member-bar {
    height: 5px; background: var(--surface-2, #f1f3f6);
    border-radius: 3px; margin-top: 5px; overflow:hidden;
}
.member-bar-fill {
    height:100%; background: linear-gradient(90deg, #4f46e5, #818cf8);
}
.member-stat { text-align:right; min-width: 56px; }
.member-stat b { font-size: 15px; color: var(--text-strong, #0c1322); display:block; }
.member-stat small { font-size: 10.5px; }

/* =====================================================================
   Tabs (Settings page)
   ===================================================================== */
.tabs {
    display:flex; gap:4px; padding:6px;
    background: var(--surface-1, #fff);
    border:1px solid var(--border, #e6e8ee);
    border-radius:10px; margin-bottom: 22px;
    overflow-x: auto;
}
.tab {
    flex:1; min-width: 140px;
    display:flex; align-items:center; justify-content:center; gap:8px;
    padding: 10px 16px; border-radius:8px;
    font-size:13px; font-weight:600; white-space:nowrap;
    color: var(--text-muted, #8993a4); text-decoration:none;
    transition: all .15s;
}
.tab:hover { background: var(--surface-hover, #f4f6fa); color: var(--text, #4a5365); }
.tab.active {
    background: var(--accent, #4f46e5); color:#fff;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
}

/* =====================================================================
   Consent page
   ===================================================================== */
.flash-warn {
    background: #fffbeb; color: #92400e; border: 1px solid #fde68a;
    margin: 16px 24px 0; padding: 12px 16px; border-radius: 10px;
    display:flex; gap:10px; align-items:center; font-size: 13.5px;
}

.consent-wrap { display:flex; flex-direction:column; gap: 18px; }

.consent-banner {
    display:flex; gap:14px; align-items:center; flex-wrap:wrap;
    padding: 16px 20px; border-radius:12px;
}
.consent-banner.ok    { background: #dcfce7; border: 1.5px solid #bbf7d0; color:#166534; }
.consent-banner.warn  { background: #fffbeb; border: 1.5px solid #fde68a; color:#854d0e; }
.cb-icon {
    width:46px; height:46px; border-radius:12px;
    display:flex; align-items:center; justify-content:center; flex-shrink:0;
}
.consent-banner.ok   .cb-icon { background:#bbf7d0; }
.consent-banner.warn .cb-icon { background:#fde68a; }
.cb-text { flex:1; min-width: 220px; }
.cb-text h3 { margin:0; font-size:15px; font-weight:700; }
.cb-text p  { margin: 4px 0 0; font-size:12.5px; opacity:0.85; }
.cb-action { margin-left:auto; }

.consent-doc .consent-body {
    padding: 20px; font-size: 13.5px; line-height: 1.7;
    color: var(--text, #4a5365);
    max-height: 540px; overflow-y: auto;
}
.consent-body .lead { font-weight: 500; margin-bottom: 16px; }
.consent-body h4 {
    font-size: 14px; font-weight: 700; color: var(--text-strong, #0c1322);
    margin: 18px 0 8px;
}
.consent-body ul { margin: 0 0 12px 18px; display:flex; flex-direction:column; gap: 4px; }
.consent-body p  { margin: 0 0 10px; }
.dpo-card {
    padding: 12px 16px; background: var(--surface-2, #f8f9fb);
    border: 1px solid var(--border, #e6e8ee); border-radius: 8px;
    font-size: 13px;
}
.consent-body .fineprint {
    margin-top: 16px; font-size: 12px; color: var(--text-muted, #8993a4);
    border-top: 1px solid var(--border-soft, #f1f3f6); padding-top: 14px;
}

/* =====================================================================
   Chat UI (settings + admin support)
   ===================================================================== */
.chat-grid {
    display:grid; gap:16px; grid-template-columns: 1fr;
}
@media (min-width: 900px) {
    .chat-grid { grid-template-columns: 1.6fr 1fr; }
}

.chat-card { padding: 0 !important; overflow: hidden; display:flex; flex-direction:column; }
.chat-head {
    padding: 14px 18px; border-bottom: 1px solid var(--border-soft, #f1f3f6);
    display:flex; justify-content:space-between; align-items:center; gap: 10px; flex-wrap:wrap;
}
.chat-icon {
    width: 36px; height: 36px; border-radius: 10px;
    background: var(--accent, #4f46e5); color: #fff;
    display:flex; align-items:center; justify-content:center;
}
.chat-messages {
    padding: 20px; min-height: 320px; max-height: 480px; overflow-y: auto;
    display:flex; flex-direction:column; gap: 14px;
    background: var(--surface-2, #f8f9fb);
}
.bubble-row { display:flex; flex-direction:column; max-width: 100%; }
.bubble-row.mine   { align-items: flex-end; }
.bubble-row.theirs { align-items: flex-start; }
.bubble-meta {
    display:flex; gap:6px; align-items:center; margin-bottom:4px;
    font-size: 11px; color: var(--text-muted, #8993a4);
}
.bubble-meta b { color: var(--text-strong, #0c1322); }
.bubble-meta small { color: var(--text-muted, #8993a4); }
.bubble {
    max-width: 80%; padding: 10px 14px;
    font-size: 13.5px; line-height: 1.55;
    white-space: pre-wrap; word-break: break-word;
}
.bubble-row.mine .bubble {
    background: var(--accent, #4f46e5); color: #fff;
    border-radius: 14px 14px 4px 14px;
}
.bubble-row.theirs .bubble {
    background: var(--surface-1, #fff); color: var(--text-strong, #0c1322);
    border: 1px solid var(--border, #e6e8ee);
    border-radius: 14px 14px 14px 4px;
}
.empty-chat {
    flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center;
    text-align:center; padding: 40px 20px; color: var(--text-muted, #8993a4);
}
.empty-chat b { font-size: 14px; color: var(--text, #4a5365); display:block; margin-top: 12px; }
.empty-chat small { font-size: 12px; margin-top: 4px; }

.chat-input {
    display:flex; gap:8px; align-items:flex-end;
    padding: 14px 16px;
    border-top: 1px solid var(--border, #e6e8ee);
    background: var(--surface-1, #fff);
}
.chat-input textarea {
    flex: 1; padding: 10px 14px;
    border: 1px solid var(--border, #e6e8ee); border-radius: 8px;
    font: inherit; font-size: 13.5px; resize: none;
    min-height: 42px; max-height: 100px; line-height: 1.5;
}
.chat-input textarea:focus {
    outline: none; border-color: var(--accent, #4f46e5);
    box-shadow: 0 0 0 3px var(--accent-soft, #eef2ff);
}

/* =====================================================================
   Mobile logout — visible only on phones
   ===================================================================== */
.topbar-logout {
    display: none;
    margin: 0;
}
.topbar-logout input { display: none; }

@media (max-width: 1023px) {
    .topbar-logout {
        display: inline-flex;
        margin: 0;
        padding: 0;
        background: none;
        border: none;
    }
    .topbar-logout button { color: #b91c1c; }

    /* On phones, hide the duplicate logout button inside the sidebar
       footer so we don't show two — keep the avatar + name visible. */
    .sidebar-footer #logoutForm { display: none; }
}

/* The sidebar footer must always sit at the bottom of the panel,
   even when the nav list above has overflowed and scrolled. */
.sidebar-footer {
    flex-shrink: 0;
    position: sticky;
    bottom: 0;
    background: var(--surface-1, #fff);
}

/* =====================================================================
   Searchable Select  (progressive enhancement on <select data-searchable>)
   ===================================================================== */
.ss-wrap {
    position: relative;
    width: 100%;
}

.ss-trigger {
    width: 100%;
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 9px 12px;
    background: var(--surface-1, #fff);
    border: 1px solid var(--border, #e6e8ee);
    border-radius: 8px;
    font: inherit; font-size: 13.5px;
    color: var(--text-strong, #0c1322);
    cursor: pointer; text-align: left;
    min-height: 38px;
}
.ss-trigger:hover { border-color: var(--accent, #4f46e5); }
.ss-wrap.open .ss-trigger {
    border-color: var(--accent, #4f46e5);
    box-shadow: 0 0 0 3px var(--accent-soft, #eef2ff);
}
.ss-wrap[data-disabled="1"] .ss-trigger {
    background: var(--surface-2, #f1f3f6);
    color: var(--text-muted, #8993a4);
    cursor: not-allowed;
}

.ss-label {
    flex: 1; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ss-label.placeholder { color: var(--text-muted, #8993a4); }

.ss-caret {
    flex-shrink: 0; color: var(--text-muted, #8993a4);
    transition: transform .15s;
}
.ss-wrap.open .ss-caret { transform: rotate(180deg); }

/* Dropdown panel */
.ss-panel {
    display: none;
    position: absolute; left: 0; right: 0; top: calc(100% + 4px);
    z-index: 1050;
    background: var(--surface-1, #fff);
    border: 1px solid var(--border, #e6e8ee);
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(7, 13, 28, 0.10);
    overflow: hidden;
}
.ss-wrap.open .ss-panel { display: block; }
.ss-wrap.open.open-up .ss-panel {
    top: auto; bottom: calc(100% + 4px);
}

.ss-search {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-soft, #f1f3f6);
}
.ss-search svg { color: var(--text-muted, #8993a4); flex-shrink: 0; }
.ss-search input {
    flex: 1; border: none; outline: none; padding: 0;
    font: inherit; font-size: 13.5px; background: transparent;
    color: var(--text-strong, #0c1322);
}

.ss-list {
    list-style: none; margin: 0; padding: 6px;
    max-height: 250px; overflow-y: auto;
}
.ss-item {
    padding: 8px 10px; border-radius: 6px; cursor: pointer;
    font-size: 13.5px;
    color: var(--text, #4a5365);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ss-item:hover, .ss-item.active {
    background: var(--surface-hover, #f4f6fa);
    color: var(--text-strong, #0c1322);
}
.ss-item.selected {
    background: var(--accent-soft, #eef2ff);
    color: var(--accent, #4f46e5);
    font-weight: 600;
}
.ss-item.selected::after {
    content: '✓'; float: right; color: var(--accent, #4f46e5); font-weight: 700;
}
.ss-item.disabled { opacity: .4; cursor: not-allowed; }
.ss-item.placeholder { color: var(--text-muted, #8993a4); font-style: italic; }
.ss-empty {
    padding: 14px 10px; text-align: center;
    color: var(--text-muted, #8993a4); font-size: 12.5px;
}

/* =====================================================================
   Employee / Manager dashboards
   ===================================================================== */

/* Hero greeting */
.hero-greeting {
    display: flex; align-items: center; justify-content: space-between;
    gap: 20px; flex-wrap: wrap;
    padding: 22px 24px;
    background: linear-gradient(135deg, #eef2ff 0%, #fafbff 100%);
    border: 1px solid var(--border, #e6e8ee);
    border-radius: 14px;
    margin-bottom: 8px;
}
.hero-left { flex: 1; min-width: 240px; }
.hero-left h1 {
    margin: 0 0 6px; font-size: 22px; color: var(--text-strong, #0c1322);
}
.hero-left p {
    margin: 0; font-size: 14px; color: var(--text, #4a5365); line-height: 1.5;
}
.hero-left small { display: block; margin-top: 6px; }
.hero-stat { flex-shrink: 0; }

/* Circle progress (CSS-only conic-gradient) */
.circle-progress {
    width: 96px; height: 96px; border-radius: 50%;
    background:
        conic-gradient(var(--accent, #4f46e5) calc(var(--p, 0) * 1%),
                       var(--surface-2, #eef0f4) 0);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    position: relative;
}
.circle-progress::before {
    content: ''; position: absolute; inset: 8px; border-radius: 50%;
    background: var(--surface-1, #fff);
}
.circle-progress-num {
    position: relative; z-index: 1;
    font-size: 20px; font-weight: 800; color: var(--text-strong, #0c1322);
    line-height: 1;
}
.circle-progress-label {
    position: relative; z-index: 1;
    font-size: 10.5px; color: var(--text-muted, #8993a4);
    text-transform: uppercase; letter-spacing: .05em; margin-top: 3px;
}

/* Todo line in dashboards */
.todo-line {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 0; border-bottom: 1px solid var(--border-soft, #f1f3f6);
    text-decoration: none; color: inherit;
}
.todo-line:last-child { border-bottom: none; }
.todo-line-body { flex: 1; min-width: 0; }
.todo-line-title {
    font-size: 13px; font-weight: 600; color: var(--text-strong, #0c1322);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.todo-line-num {
    font-size: 12px; font-weight: 700; color: var(--accent, #4f46e5);
    min-width: 38px; text-align: right;
}
.todo-line:hover .todo-line-title { color: var(--accent, #4f46e5); }

/* Recently-done rows */
.done-row {
    display: flex; align-items: flex-start; gap: 8px;
    padding: 8px 0; border-bottom: 1px solid var(--border-soft, #f1f3f6);
    font-size: 13px;
}
.done-row:last-child { border-bottom: none; }
.done-info { flex: 1; min-width: 0; }
.done-info a {
    display: block; color: var(--text-strong, #0c1322); text-decoration: none;
    font-weight: 500;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.done-info a:hover { color: var(--accent, #4f46e5); }
.done-info small { color: var(--text-muted, #8993a4); font-size: 11.5px; }

/* Empty state (centered icon + message) */
.empty-state {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    padding: 28px 20px;
    text-align: center;
    color: var(--text-muted, #8993a4);
}
.empty-state b {
    color: var(--text-strong, #0c1322); font-size: 14px; display: block;
}
.empty-state small {
    font-size: 12.5px; max-width: 380px; line-height: 1.5;
}

.text-warn { color: #b45309; }