/* ─── Variables ─────────────────────────────────────────────────────────── */
:root {
    --sidebar-bg:     #0f172a;
    --sidebar-text:   rgba(255,255,255,0.6);
    --accent:         #3b82f6;
    --accent-dark:    #2563eb;
    --bg:             #f8fafc;
    --white:          #ffffff;
    --border:         #e2e8f0;
    --text:           #0f172a;
    --text-light:     #64748b;
    --danger:         #ef4444;
    --success:        #10b981;
    --warning:        #f59e0b;
    --sidebar-w:      250px;
    --topbar-h:       60px;
    --radius:         12px;
    --shadow-sm:      0 1px 3px rgba(0,0,0,0.06);
    --shadow:         0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg:      0 12px 40px rgba(0,0,0,0.15);
}

/* ─── Reset ─────────────────────────────────────────────────────────────── */
*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; overflow-x: hidden; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; min-height: 100vh; overflow-x: hidden; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Layout ────────────────────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

/* ─── Sidebar ───────────────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w); background: var(--sidebar-bg);
    position: fixed; top: 0; left: 0; bottom: 0;
    display: flex; flex-direction: column;
    z-index: 300; transition: width 0.22s ease, transform 0.25s ease;
    overflow-y: auto; overflow-x: hidden;
}
.sidebar-logo { display: flex; align-items: center; gap: 12px; padding: 20px 16px; border-bottom: 1px solid rgba(255,255,255,0.07); transition: padding 0.22s; }
.logo-icon { width: 36px; height: 36px; background: var(--accent); border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1rem; color: #fff; flex-shrink: 0; }
.logo-text { font-size: 1rem; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; transition: opacity 0.15s, width 0.22s; }
.sidebar-nav { flex: 1; padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 8px; color: var(--sidebar-text); font-size: 0.875rem; font-weight: 500; transition: all 0.15s; text-decoration: none; min-height: 44px; white-space: nowrap; }
.nav-link:hover { background: rgba(255,255,255,0.08); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--accent); color: #fff; font-weight: 600; }
.nav-icon { width: 20px; text-align: center; flex-shrink: 0; font-style: normal; }
.nav-label { overflow: hidden; transition: opacity 0.15s; }
.sidebar-footer { padding: 10px 8px; border-top: 1px solid rgba(255,255,255,0.07); }

/* ─── Sidebar collapsed (desktop) ──────────────────────────────────────── */
body.sidebar-collapsed { --sidebar-w: 64px; }
body.sidebar-collapsed .sidebar { width: 64px; }
body.sidebar-collapsed .logo-text { opacity: 0; width: 0; }
body.sidebar-collapsed .nav-label { opacity: 0; width: 0; }
body.sidebar-collapsed .sidebar-logo { justify-content: center; padding: 20px 14px; }
body.sidebar-collapsed .nav-link { justify-content: center; padding: 11px 10px; gap: 0; }
body.sidebar-collapsed .nav-icon { width: 22px; }
.logout-link { color: rgba(239,68,68,0.8); }
.logout-link:hover { background: rgba(239,68,68,0.12) !important; color: #ef4444; }

/* ─── Main ──────────────────────────────────────────────────────────────── */
.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-height: 100vh; }

/* ─── Topbar ────────────────────────────────────────────────────────────── */
.topbar { height: var(--topbar-h); background: var(--white); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 24px; position: sticky; top: 0; z-index: 100; box-shadow: var(--shadow-sm); }
.sidebar-toggle { display: flex; flex-direction: column; gap: 5px; background: none; border: none; cursor: pointer; padding: 8px; border-radius: 8px; min-width: 44px; min-height: 44px; align-items: center; justify-content: center; }
.sidebar-toggle:hover { background: var(--bg); }
.sidebar-toggle span { display: block; width: 20px; height: 2px; background: var(--text); border-radius: 2px; transition: all 0.2s; }
.topbar-title { font-size: 0.9rem; font-weight: 600; color: var(--text); }
.topbar-user { display: flex; align-items: center; gap: 8px; }
.user-avatar { width: 34px; height: 34px; background: linear-gradient(135deg, var(--accent), #6366f1); color: #fff; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.82rem; font-weight: 700; flex-shrink: 0; }
.user-name { font-size: 0.825rem; color: var(--text-light); font-weight: 500; }
.mobile-logout-btn { display: none; padding: 6px 14px; border-radius: 8px; background: rgba(239,68,68,0.1); color: var(--danger); font-size: 0.82rem; font-weight: 600; align-items: center; justify-content: center; text-decoration: none; flex-shrink: 0; white-space: nowrap; }
.mobile-logout-btn:hover { background: rgba(239,68,68,0.2); text-decoration: none; color: var(--danger); }

/* ─── Content ───────────────────────────────────────────────────────────── */
.content { padding: 24px 28px; flex: 1; }

/* ─── Page Header ───────────────────────────────────────────────────────── */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; gap: 12px; flex-wrap: wrap; }
.page-title { font-size: 1.4rem; font-weight: 700; color: var(--text); line-height: 1.2; }
.page-subtitle { font-size: 0.825rem; color: var(--text-light); margin-top: 3px; }
.back-link { font-size: 0.8rem; color: var(--text-light); display: block; margin-bottom: 4px; }
.back-link:hover { color: var(--accent); }

/* ─── Stat Cards ────────────────────────────────────────────────────────── */
.stat-cards { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--white); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); border: 1px solid var(--border); display: flex; align-items: center; gap: 14px; }
.stat-icon { width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; flex-shrink: 0; }
.stat-icon-blue   { background: rgba(59,130,246,0.12); color: #3b82f6; }
.stat-icon-purple { background: rgba(139,92,246,0.12); color: #8b5cf6; }
.stat-icon-green  { background: rgba(16,185,129,0.12); color: #10b981; }
.stat-icon-orange { background: rgba(245,158,11,0.12); color: #f59e0b; }
.stat-value { font-size: 1.75rem; font-weight: 800; color: var(--text); line-height: 1; }
.stat-label { font-size: 0.78rem; color: var(--text-light); margin-top: 4px; font-weight: 500; }

/* ─── Dashboard Grid ────────────────────────────────────────────────────── */
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

/* ─── Card ──────────────────────────────────────────────────────────────── */
.card { background: var(--white); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
.search-card { padding: 14px 18px; margin-bottom: 14px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.card-title { font-size: 0.925rem; font-weight: 600; }
.card-link { font-size: 0.8rem; color: var(--accent); font-weight: 500; }
.card-section-title { font-size: 1rem; font-weight: 600; margin-bottom: 6px; }
.card-description { font-size: 0.875rem; color: var(--text-light); margin-bottom: 18px; }

/* ─── Department ────────────────────────────────────────────────────────── */
.dept-list { display: flex; flex-direction: column; gap: 12px; }
.dept-search-wrap { position: relative; padding: 0 20px 12px; }
.dept-search-icon { position: absolute; left: 32px; top: 50%; transform: translateY(-50%); color: var(--text-light); font-size: 0.85rem; pointer-events: none; }
.dept-search-input { width: 100%; padding: 7px 12px 7px 30px; border: 1.5px solid var(--border); border-radius: 8px; font-size: 16px; color: var(--text); background: var(--bg); outline: none; box-sizing: border-box; }
.dept-search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }
.dept-list-scroll { max-height: 420px; overflow-y: auto; padding-right: 4px; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.dept-list-scroll::-webkit-scrollbar { width: 4px; }
.dept-list-scroll::-webkit-scrollbar-track { background: transparent; }
.dept-list-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
.dept-item { display: flex; flex-direction: column; gap: 5px; }
.dept-info { display: flex; align-items: center; justify-content: space-between; }
.dept-name { font-size: 0.875rem; font-weight: 500; }
.dept-bar-wrap { height: 5px; background: var(--border); border-radius: 99px; overflow: hidden; }
.dept-bar { height: 100%; background: var(--accent); border-radius: 99px; min-width: 4px; transition: width 0.4s; }

/* ─── Recent ────────────────────────────────────────────────────────────── */
.recent-list { display: flex; flex-direction: column; gap: 2px; }
.recent-item { display: flex; align-items: center; gap: 10px; padding: 9px 8px; border-radius: 8px; transition: background 0.1s; }
.recent-item:hover { background: var(--bg); }
.recent-avatar { width: 36px; height: 36px; background: linear-gradient(135deg,var(--accent),#6366f1); color:#fff; border-radius:50%; display:flex; align-items:center; justify-content:center; font-size:0.875rem; font-weight:700; flex-shrink:0; }
.recent-info { flex:1; min-width:0; }
.recent-name { font-size:0.875rem; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.recent-meta { font-size:0.75rem; color:var(--text-light); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.recent-date { font-size:0.75rem; color:var(--text-light); flex-shrink:0; }

/* ─── Empty ─────────────────────────────────────────────────────────────── */
.empty-state { text-align:center; padding:32px 16px; color:var(--text-light); font-size:0.9rem; }
.empty-cell  { text-align:center; padding:48px 24px !important; color:var(--text-light); font-size:0.9rem; }
.no-results-cell { text-align:center; padding:56px 24px !important; color:var(--text-light); font-size:0.9rem; }
.no-results-icon { font-size:2.2rem; display:block; margin-bottom:8px; opacity:0.3; }

/* ─── Toolbar ───────────────────────────────────────────────────────────── */
.results-info { font-size:0.82rem; color:var(--text-light); margin-bottom:10px; }
.toolbar { display:flex; align-items:center; justify-content:space-between; gap:10px; flex-wrap:wrap; }
.toolbar-left { display:flex; align-items:center; gap:8px; flex:1; min-width:0; flex-wrap:wrap; }
.toolbar-right { display:flex; align-items:center; gap:8px; flex-shrink:0; }
.toolbar-label { font-size:0.8rem; color:var(--text-light); white-space:nowrap; }
.dept-filter { width:auto; min-width:160px; }
.search-wrap { position:relative; flex:1; min-width:200px; }
.search-icon { position:absolute; left:11px; top:50%; transform:translateY(-50%); color:var(--text-light); pointer-events:none; }
.search-wrap .form-input { padding-left:34px; padding-right:32px; }
.search-clear { position:absolute; right:8px; top:50%; transform:translateY(-50%); background:none; border:none; color:var(--text-light); cursor:pointer; font-size:0.9rem; padding:4px; border-radius:4px; line-height:1; }
.search-clear:hover { color:var(--text); background:var(--border); }

/* ─── Table (desktop) ───────────────────────────────────────────────────── */
/* Table card: border-radius is on the card border only. NO overflow:hidden —
   that would create a scroll container and clip .table-wrap's scrollbar.
   Instead we apply radius directly to the corner th cells and table-footer. */
.table-card { /* overflow intentionally not set — do NOT add overflow:hidden */ }
.table-wrap { overflow-x: auto; }
/* Clip top corners of the table inside the card */
.data-table thead tr th:first-child { border-top-left-radius: calc(var(--radius) - 1px); }
.data-table thead tr th:last-child  { border-top-right-radius: calc(var(--radius) - 1px); }
.data-table { width:100%; border-collapse:collapse; font-size:0.875rem; table-layout:fixed; min-width:700px; }
.data-table th { background:#f8fafc; padding:10px 14px; text-align:left; font-size:0.72rem; font-weight:700; color:var(--text-light); text-transform:uppercase; letter-spacing:0.05em; border-bottom:2px solid var(--border); white-space:nowrap; }
.data-table td { padding:11px 14px; border-bottom:1px solid #f1f5f9; vertical-align:middle; max-width:0; }
.data-table tbody tr:last-child td { border-bottom:none; }
.data-table tbody tr:hover { background:#f8fafc; cursor:pointer; }
/* Column widths — table-layout:fixed honours these */
.data-table th:nth-child(1),.data-table td:nth-child(1) { width:18%; }
.data-table th:nth-child(2),.data-table td:nth-child(2) { width:15%; }
.data-table th:nth-child(3),.data-table td:nth-child(3) { width:15%; }
.data-table th:nth-child(4),.data-table td:nth-child(4) { width:12%; }
.data-table th:nth-child(5),.data-table td:nth-child(5) { width:12%; }
.data-table th:nth-child(6),.data-table td:nth-child(6) { width:16%; }
.data-table th:nth-child(7),.data-table td:nth-child(7) { width:9%; }
.data-table th:nth-child(8),.data-table td:nth-child(8) { width:9%; }
/* Truncate — inner elements clip text, td has max-width:0 so ellipsis works in fixed layout */
.contact-name { font-weight:600; font-size:0.875rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; display:block; }
.badge { display:inline-block; max-width:100%; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.table-link { display:block; max-width:100%; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; color:var(--accent); font-size:0.875rem; }
.table-link:hover { text-decoration:underline; }
.cell-text { display:block; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.actions-cell { display:flex; gap:4px; align-items:center; cursor:default; }
.text-muted { color:var(--text-light); }
.th-sort { cursor:pointer; user-select:none; }
.th-sort:hover { background:#edf2f7; }
.th-sort .sort-arrow { font-size:0.7rem; opacity:0.45; margin-left:3px; }
.th-sort.asc .sort-arrow, .th-sort.desc .sort-arrow { opacity:1; color:var(--accent); }
@keyframes rowIn { from{opacity:0;transform:translateY(3px)} to{opacity:1;transform:none} }
.data-table tbody tr { animation:rowIn 0.15s ease both; }

/* ─── Table Footer ──────────────────────────────────────────────────────── */
.table-footer { display:flex; align-items:center; justify-content:space-between; padding:12px 18px; border-top:1px solid var(--border); flex-wrap:wrap; gap:8px; }
.page-info-text { font-size:0.8rem; color:var(--text-light); }

/* ─── Badges ────────────────────────────────────────────────────────────── */
.badge { display:inline-block; padding:2px 9px; border-radius:99px; font-size:0.72rem; font-weight:600; background:rgba(59,130,246,0.1); color:#1d4ed8; white-space:nowrap; }

/* ─── Buttons ───────────────────────────────────────────────────────────── */
.btn { display:inline-flex; align-items:center; justify-content:center; gap:6px; padding:9px 16px; border-radius:8px; font-size:0.875rem; font-weight:500; cursor:pointer; border:1px solid transparent; transition:all 0.15s; text-decoration:none; white-space:nowrap; line-height:1; min-height:38px; }
.btn:hover { text-decoration:none; }
.btn:active { transform:translateY(1px); }
.btn-primary { background:var(--accent); color:#fff; border-color:var(--accent); }
.btn-primary:hover { background:var(--accent-dark); border-color:var(--accent-dark); }
.btn-danger  { background:var(--danger); color:#fff; border-color:var(--danger); }
.btn-danger:hover { background:#dc2626; border-color:#dc2626; }
.btn-outline { background:transparent; color:var(--text); border-color:var(--border); }
.btn-outline:hover { background:var(--bg); }
.btn-sm { padding:5px 11px; font-size:0.78rem; border-radius:6px; min-height:32px; }
.btn-block { width:100%; justify-content:center; padding:12px 16px; }

/* ─── Forms ─────────────────────────────────────────────────────────────── */
.form-card { max-width:860px; }
.form-grid { display:grid; grid-template-columns:1fr 1fr; gap:16px; margin-bottom:22px; }
.form-group { display:flex; flex-direction:column; gap:6px; }
.form-group-full { grid-column:1/-1; }
.form-label { font-size:0.82rem; font-weight:600; color:var(--text); }
.required { color:var(--danger); }
.form-input, .form-select { padding:10px 12px; border:1.5px solid var(--border); border-radius:8px; font-size:16px; color:var(--text); background:var(--white); width:100%; transition:border-color 0.15s, box-shadow 0.15s; font-family:inherit; min-height:42px; }
.form-input:focus, .form-select:focus { outline:none; border-color:var(--accent); box-shadow:0 0 0 3px rgba(59,130,246,0.12); }
.form-textarea { resize:vertical; min-height:90px; }
.form-actions { display:flex; gap:10px; align-items:center; padding-top:8px; flex-wrap:wrap; }

/* ─── Pagination ────────────────────────────────────────────────────────── */
.pagination { display:flex; align-items:center; justify-content:center; gap:4px; flex-wrap:wrap; }
.page-btn { display:inline-flex; align-items:center; justify-content:center; min-width:36px; height:36px; padding:0 10px; border-radius:8px; font-size:0.85rem; color:var(--text-light); border:1.5px solid var(--border); background:var(--white); text-decoration:none; transition:all 0.1s; cursor:pointer; }
.page-btn:hover { background:var(--bg); color:var(--accent); text-decoration:none; }
.page-btn.active { background:var(--accent); border-color:var(--accent); color:#fff; font-weight:600; }
.page-ellipsis { color:var(--text-light); padding:0 4px; }

/* ─── Alerts ────────────────────────────────────────────────────────────── */
.alert { padding:12px 16px; border-radius:8px; margin-bottom:16px; font-size:0.875rem; border:1px solid transparent; }
.alert-success { background:rgba(16,185,129,0.08); border-color:rgba(16,185,129,0.25); color:#065f46; }
.alert-error   { background:rgba(239,68,68,0.06); border-color:rgba(239,68,68,0.2); color:#991b1b; }

/* ─── Loading bar ───────────────────────────────────────────────────────── */
.table-loader { position:fixed; top:0; left:0; right:0; height:3px; z-index:9999; }
.loader-spinner { height:100%; background:linear-gradient(90deg,var(--accent),#6366f1,var(--accent)); background-size:200% 100%; animation:shimmer 1s infinite linear; }
@keyframes shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

/* ─── Login ─────────────────────────────────────────────────────────────── */
.login-body { background:linear-gradient(135deg,#0f172a 0%,#1e3a5f 60%,#0f172a 100%); min-height:100vh; display:flex; align-items:center; justify-content:center; padding:16px; }
.login-page { width:100%; max-width:420px; }
.login-card { background:var(--white); border-radius:18px; padding:40px 36px; box-shadow:0 24px 80px rgba(0,0,0,0.35); }
.login-logo { text-align:center; margin-bottom:28px; }
.logo-icon-lg { width:54px; height:54px; background:var(--accent); border-radius:14px; display:flex; align-items:center; justify-content:center; margin:0 auto 12px; font-size:1.4rem; color:#fff; }
.login-brand { font-size:1.5rem; font-weight:800; color:var(--text); letter-spacing:-0.02em; }
.login-subtitle { font-size:0.85rem; color:var(--text-light); margin-top:4px; }
.login-form { display:flex; flex-direction:column; gap:18px; }

/* ─── Import Steps ──────────────────────────────────────────────────────── */
.step-indicators { display:flex; align-items:center; margin-bottom:24px; }
.step-item { display:flex; flex-direction:column; align-items:center; gap:5px; flex: 0 0 auto; }
.step-num { width:36px; height:36px; border-radius:50%; border:2px solid var(--border); background:var(--white); display:flex; align-items:center; justify-content:center; font-size:0.875rem; font-weight:700; color:var(--text-light); transition:all 0.2s; }
.step-item.active .step-num { border-color:var(--accent); background:var(--accent); color:#fff; }
.step-item.done   .step-num { border-color:var(--success); background:var(--success); color:#fff; }
.step-label { font-size:0.72rem; font-weight:500; color:var(--text-light); white-space:nowrap; }
.step-item.active .step-label { color:var(--accent); font-weight:600; }
.step-item.done   .step-label { color:var(--success); }
.step-connector { flex:1; height:2px; background:var(--border); margin:0 8px 20px; min-width:24px; }

/* ─── Upload ────────────────────────────────────────────────────────────── */
.upload-area { border:2px dashed var(--border); border-radius:12px; padding:40px 20px; text-align:center; margin-bottom:18px; transition:all 0.2s; cursor:pointer; position:relative; }
.upload-area:hover, .upload-area.drag-over { border-color:var(--accent); background:rgba(59,130,246,0.02); }
.upload-icon { font-size:2.5rem; color:var(--text-light); margin-bottom:10px; display:block; }
.upload-text { color:var(--text-light); font-size:0.875rem; margin-bottom:14px; }
.upload-input { position:absolute; width:1px; height:1px; opacity:0; pointer-events:none; }
.upload-hint { margin-top:10px; font-size:0.8rem; color:var(--text-light); }
.upload-label { cursor:pointer; }
.mapping-table-wrap { margin-bottom:20px; overflow-x:auto; border-radius:var(--radius); border:1px solid var(--border); }
.mapping-table { width:100%; border-collapse:collapse; font-size:0.875rem; }
.mapping-table th { background:#f8fafc; padding:10px 14px; text-align:left; font-size:0.72rem; font-weight:700; color:var(--text-light); text-transform:uppercase; border-bottom:1px solid var(--border); }
.mapping-table td { padding:10px 14px; border-bottom:1px solid #f1f5f9; vertical-align:middle; }
.mapping-table tr:last-child td { border-bottom:none; }
.col-badge { display:inline-block; padding:3px 9px; background:var(--bg); border:1px solid var(--border); border-radius:6px; font-size:0.82rem; font-family:monospace; }
.mapping-select { max-width:200px; }
.preview-title { font-size:0.875rem; font-weight:600; margin:16px 0 10px; }
.preview-table { font-size:0.78rem; }
.preview-table td { max-width:140px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.import-done-card { text-align:center; padding:48px 24px; max-width:480px; }
.done-icon { font-size:3rem; color:var(--success); margin-bottom:14px; display:block; }
.done-title { font-size:1.3rem; font-weight:700; margin-bottom:8px; }
.done-message { color:var(--text-light); margin-bottom:22px; }
.done-actions { justify-content:center; }

/* ─── Call Remarks ──────────────────────────────────────────────────────── */
.remark-cell { max-width:160px; }
.remark-display { cursor:pointer; padding:4px 6px; border-radius:6px; transition:background 0.15s; min-height:28px; }
.remark-display:hover { background:rgba(59,130,246,0.08); }
.remark-text { font-size:0.78rem; color:var(--text); line-height:1.4; word-break:break-word; }
.remark-empty { font-size:0.75rem; color:#94a3b8; font-style:italic; }
.remark-popover { position:fixed; z-index:2000; background:#fff; border:1px solid var(--border); border-radius:12px; padding:14px; box-shadow:var(--shadow-lg); width:260px; animation:slideUp 0.15s ease; }
.remark-popover textarea { width:100%; border:1.5px solid var(--border); border-radius:7px; padding:8px 10px; font-size:0.85rem; font-family:inherit; resize:none; outline:none; color:var(--text); transition:border-color 0.15s; line-height:1.5; }
.remark-popover textarea:focus { border-color:var(--accent); box-shadow:0 0 0 3px rgba(59,130,246,0.12); }
.remark-popover-footer { display:flex; gap:6px; margin-top:8px; justify-content:space-between; align-items:center; }
.remark-popover-label { font-size:0.72rem; font-weight:700; color:var(--text-light); text-transform:uppercase; letter-spacing:0.05em; margin-bottom:8px; }
.btn-datetime { font-size:0.75rem; color:var(--accent); background:none; border:none; cursor:pointer; padding:4px 6px; border-radius:5px; }
.btn-datetime:hover { background:rgba(59,130,246,0.08); }

/* ─── Modal ─────────────────────────────────────────────────────────────── */
.modal-backdrop { position:fixed; inset:0; background:rgba(0,0,0,0.5); z-index:1000; display:flex; align-items:center; justify-content:center; padding:16px; }
.modal-box { background:#fff; border-radius:16px; width:100%; max-width:700px; max-height:92vh; overflow-y:auto; box-shadow:var(--shadow-lg); animation:slideUp 0.2s ease; }
@keyframes slideUp { from{transform:translateY(14px);opacity:0} to{transform:none;opacity:1} }
.modal-header { display:flex; align-items:center; justify-content:space-between; padding:18px 22px 14px; border-bottom:1px solid var(--border); position:sticky; top:0; background:#fff; z-index:1; border-radius:16px 16px 0 0; }
.modal-title { font-size:1rem; font-weight:700; color:var(--text); }
.modal-close { width:32px; height:32px; border-radius:8px; border:none; background:var(--bg); cursor:pointer; font-size:1.2rem; color:var(--text-light); display:flex; align-items:center; justify-content:center; transition:background 0.1s; line-height:1; }
.modal-close:hover { background:var(--border); color:var(--text); }
.modal-body { padding:18px 22px; }
.modal-footer { display:flex; gap:10px; justify-content:flex-end; padding:14px 22px; border-top:1px solid var(--border); background:var(--bg); border-radius:0 0 16px 16px; }

/* View rows */
.view-row { display:flex; gap:12px; padding:10px 0; border-bottom:1px solid #f1f5f9; font-size:0.875rem; }
.view-row:last-child { border-bottom:none; }
.view-label { width:110px; flex-shrink:0; color:var(--text-light); font-weight:600; font-size:0.75rem; text-transform:uppercase; letter-spacing:0.04em; padding-top:2px; }
.view-val { color:var(--text); word-break:break-word; }
.view-avatar { width:52px; height:52px; border-radius:50%; background:linear-gradient(135deg,var(--accent),#6366f1); color:#fff; display:flex; align-items:center; justify-content:center; font-size:1.3rem; font-weight:700; margin:0 auto 16px; }

/* ─── Sidebar overlay ───────────────────────────────────────────────────── */
.sidebar-overlay { display:block; position:fixed; inset:0; background:rgba(0,0,0,0.45); z-index:299; }

/* ─── Mobile Bottom Navigation ──────────────────────────────────────────── */
.mobile-bottom-nav { display: none; /* hidden on desktop */ }

/* ─── Mobile Contact Cards ───────────────────────────────────────────────── */
.mobile-cards { display: none; padding: 12px; }
.mc-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px;
    margin-bottom: 10px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    animation: rowIn 0.15s ease both;
    transition: box-shadow 0.15s, border-color 0.15s;
}
.mc-card:active { border-color: var(--accent); box-shadow: var(--shadow); }
.mc-header { display: flex; align-items: center; gap: 12px; }
.mc-avatar {
    width: 42px; height: 42px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #6366f1);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem; font-weight: 700; flex-shrink: 0;
}
.mc-info { flex: 1; min-width: 0; }
.mc-name { font-size: 0.95rem; font-weight: 700; color: var(--text); line-height: 1.3; }
.mc-dept { font-size: 0.75rem; color: var(--accent); font-weight: 600; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mc-actions { display: flex; gap: 6px; flex-shrink: 0; }
.mc-phone { font-size: 0.85rem; color: var(--text-light); margin-top: 8px; padding-top: 8px; border-top: 1px solid #f1f5f9; }
.mc-tel-link { color: var(--text-light); text-decoration: none; }
.mc-tel-link:hover, .mc-tel-link:active { color: var(--accent); }
.mc-desig { font-size: 0.78rem; color: var(--text-light); margin-top: 3px; }
.mc-empty { text-align: center; padding: 48px 16px; color: var(--text-light); font-size: 0.9rem; }

/* ════════════════════════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════════════════════ */

/* Tablet */
@media (max-width: 1100px) {
    .stat-cards     { grid-template-columns: repeat(2,1fr); }
    .dashboard-grid { grid-template-columns: 1fr; }
}

/* Mobile / Tablet portrait */
@media (max-width: 768px) {
    :root { --topbar-h: 56px; }
    input, textarea, select { font-size: 16px !important; }

    /* ── Sidebar: slides in from left, hidden by default ─────────── */
    .sidebar { transform: translateX(-100%); box-shadow: none; width: var(--sidebar-w); }
    .sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,0.25); }

    /* Sidebar-collapsed class must NOT shrink sidebar on mobile —
       the JS already guards with window.innerWidth > 768, but override
       here in case the class leaks through (e.g. resize from desktop) */
    body.sidebar-collapsed { --sidebar-w: 250px; }
    body.sidebar-collapsed .sidebar { width: 250px; }
    body.sidebar-collapsed .logo-text { opacity: 1; width: auto; }
    body.sidebar-collapsed .nav-label { opacity: 1; width: auto; }
    body.sidebar-collapsed .sidebar-logo { justify-content: flex-start; padding: 20px 16px; }
    body.sidebar-collapsed .nav-link { justify-content: flex-start; padding: 11px 12px; gap: 10px; }
    body.sidebar-collapsed .nav-icon { width: 20px; }

    /* ── Main: full width, hard-constrained ──────────────────────── */
    .main { margin-left: 0; max-width: 100vw; overflow-x: hidden; }
    .content { padding: 12px 12px 80px !important; max-width: 100%; }

    /* ── Topbar ──────────────────────────────────────────────────── */
    .topbar { padding: 0 12px; }
    .topbar-title { font-size: 0.85rem; }
    .user-name { display: none; }
    .desktop-only { display: none; }
    .mobile-logout-btn { display: flex; }
    /* Hide sidebar toggle on mobile — bottom nav replaces it */
    .sidebar-toggle { display: none; }

    /* ── Bottom Navigation ───────────────────────────────────────── */
    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0; left: 0; right: 0;
        height: 60px;
        background: #fff;
        border-top: 1px solid var(--border);
        z-index: 400;
        box-shadow: 0 -4px 16px rgba(0,0,0,0.08);
    }
    .mbn-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        text-decoration: none;
        color: var(--text-light);
        font-size: 0.6rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        transition: color 0.15s;
        -webkit-tap-highlight-color: transparent;
    }
    .mbn-item.active { color: var(--accent); }
    .mbn-item:hover { text-decoration: none; color: var(--accent); }
    .mbn-icon { font-size: 1.3rem; line-height: 1; }
    .mbn-label { font-size: 0.58rem; }
    .mbn-add {
        background: var(--accent);
        color: #fff !important;
        border-radius: 50%;
        width: 48px; height: 48px;
        flex: none;
        margin: 6px auto;
        box-shadow: 0 4px 12px rgba(59,130,246,0.4);
        text-decoration: none !important;
    }
    .mbn-add .mbn-icon { font-size: 1.6rem; font-weight: 300; }

    /* ── Page header: stack vertically, buttons wrap ─────────────── */
    .page-header { flex-direction: column; gap: 10px; align-items: stretch; }
    .page-header > div:last-child { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
    /* On mobile: hide all page header buttons — bottom nav handles them */
    .page-header > div:last-child { display: none !important; }
    .page-title { font-size: 1.25rem; }

    /* ── Toolbar stack ───────────────────────────────────────────── */
    .toolbar { flex-direction: column; align-items: stretch; gap: 8px; }
    .toolbar-left { flex-direction: column; align-items: stretch; gap: 8px; }
    .toolbar-right { display: none; }
    .search-wrap { min-width: unset; width: 100%; }
    .search-wrap .form-input { width: 100%; }
    /* Ensure selects and inputs meet 44px touch target */
    .form-input, .form-select { min-height: 44px; font-size: 16px; }
    .dept-filter { width: 100%; min-width: unset; }

    /* ── Stat cards: 2-column grid ───────────────────────────────── */
    .stat-cards { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-card  { padding: 14px; gap: 10px; }
    .stat-icon  { width: 38px; height: 38px; font-size: 1rem; }
    .stat-value { font-size: 1.4rem; }

    /* ── Table: hidden on mobile — cards are shown instead ──────── */
    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .data-table {
        table-layout: auto;
        min-width: unset;
        width: 100%;
    }
    .data-table td { max-width: none; }

    /* Show: Name(1), Department(3), Actions(8) — hide rest */
    .data-table th:nth-child(2), .data-table td:nth-child(2),
    .data-table th:nth-child(4), .data-table td:nth-child(4),
    .data-table th:nth-child(5), .data-table td:nth-child(5),
    .data-table th:nth-child(6), .data-table td:nth-child(6),
    .data-table th:nth-child(7), .data-table td:nth-child(7) { display: none; }

    /* Reset desktop truncation on visible columns */
    .contact-name { white-space: normal; overflow: visible; text-overflow: unset; font-size: 0.875rem; }
    .cell-text    { white-space: normal; overflow: visible; text-overflow: unset; }
    .table-link   { white-space: normal; overflow: visible; text-overflow: unset; }

    /* Cell padding and font on mobile */
    .data-table td { padding: 10px 12px; font-size: 0.85rem; }
    .data-table th { padding: 10px 12px; font-size: 0.7rem; }

    /* Actions cell — ensure touch targets */
    .actions-cell { flex-wrap: wrap; gap: 6px; }
    .btn-sm { padding: 6px 10px; font-size: 0.78rem; min-height: 36px; }

    /* Table footer: stack vertically on narrow screens */
    .table-footer { flex-direction: column; align-items: center; gap: 12px; padding: 14px; }

    /* ── Forms ───────────────────────────────────────────────────── */
    .form-grid { grid-template-columns: 1fr; }
    .form-group-full { grid-column: auto; }
    .form-card { max-width: 100%; }

    /* ── Modal: slides up from bottom ────────────────────────────── */
    .modal-backdrop { align-items: flex-end; padding: 0; }
    .modal-box { max-width: 100%; border-radius: 20px 20px 0 0; max-height: 95vh; animation: slideUp 0.25s ease; }
    .modal-header { border-radius: 20px 20px 0 0; }
    .modal-footer { border-radius: 0; }
    .modal-body .form-grid { grid-template-columns: 1fr; }

    /* ── Remark popover ──────────────────────────────────────────── */
    .remark-popover { width: calc(100vw - 32px); left: 16px !important; right: 16px; }

    /* ── Login ───────────────────────────────────────────────────── */
    .login-body { padding: 20px; align-items: center; }
    .login-page { width: 100%; max-width: 100%; }
    .login-card { padding: 32px 20px; border-radius: 16px; box-shadow: 0 12px 40px rgba(0,0,0,0.25); }
    .login-logo { margin-bottom: 20px; }
    .logo-icon-lg { width: 48px; height: 48px; font-size: 1.2rem; border-radius: 12px; }
    .login-brand { font-size: 1.35rem; }
    .login-subtitle { font-size: 0.82rem; }
    .login-form { gap: 16px; }
    .login-form .form-input { min-height: 48px; font-size: 1rem; padding: 12px 14px; }
    .login-form .btn-block { min-height: 50px; font-size: 1rem; margin-top: 4px; border-radius: 10px; }

    /* ── Pagination ──────────────────────────────────────────────── */
    .page-btn { min-width: 40px; height: 40px; }
}

/* Small phones */
@media (max-width: 420px) {
    .stat-cards { grid-template-columns: 1fr 1fr; }
    .stat-value { font-size: 1.25rem; }
    .page-title { font-size: 1.15rem; }
    /* On very small screens each action button gets its own row */
    .page-header > div:last-child .btn { flex: 1 1 100%; }
    .data-table td { padding: 9px 10px; }
    .data-table th { padding: 9px 10px; }
    .content { padding: 10px 10px 20px; }
}
