:root {
  --primary:#4F46E5; --primary-dark:#3730A3; --primary-light:#EEF2FF;
  --secondary:#0EA5E9; --success:#10B981; --warning:#F59E0B; --danger:#EF4444; --purple:#8B5CF6;
  --text:#0F172A; --text-muted:#64748B; --text-light:#94A3B8;
  --border:#E2E8F0; --surface:#F8FAFC; --bg:#F1F5F9; --card:#FFFFFF;
  --radius:12px;
  --shadow:0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:0 4px 16px rgba(0,0,0,.10);
  --shadow-lg:0 10px 40px rgba(0,0,0,.14);
  --transition:all .18s ease;
  --sidebar-w:250px;
}
.ti-svg { display:inline-flex; align-items:center; justify-content:center; line-height:0; }
.ti-svg svg { width:1em; height:1em; display:block; }
*, *::before, *::after { box-sizing:border-box; }
html, body { height:100%; }
body { margin:0; font-family:-apple-system,'Segoe UI',Roboto,Arial,sans-serif; background:var(--bg); color:var(--text); font-size:14px; overflow:hidden; }
a { color:inherit; }

/* ── Layout: fixed-viewport app shell, independently-scrolling page content (Gmail-style) ── */
.app-shell { display:flex; height:100vh; overflow:hidden; }

/* ── Sidebar rail: collapses to a 68px icon-only rail that expands on hover ── */
.sidebar-rail { flex-shrink:0; width:var(--sidebar-w); transition:width .18s ease; position:relative; }
.sidebar { width:100%; height:100%; background:#1E1B4B; color:#C7D2FE; display:flex; flex-direction:column;
  overflow-y:auto; overflow-x:hidden; transition:var(--transition); position:relative; z-index:200; }

@media (min-width:769px) {
  html.sidebar-mini .sidebar-rail { width:68px; }
  html.sidebar-mini .sidebar-rail .sidebar {
    position:absolute; top:0; left:0; width:68px; height:100vh;
    transition:width .16s ease, box-shadow .16s ease; overflow-x:hidden;
  }
  html.sidebar-mini .sidebar-rail:hover .sidebar { width:var(--sidebar-w); box-shadow:var(--shadow-lg); }
  html.sidebar-mini .sidebar-rail:not(:hover) .sidebar span,
  html.sidebar-mini .sidebar-rail:not(:hover) .sidebar .nav-section-title,
  html.sidebar-mini .sidebar-rail:not(:hover) .sidebar .logo-sub,
  html.sidebar-mini .sidebar-rail:not(:hover) .sidebar .logo-full,
  html.sidebar-mini .sidebar-rail:not(:hover) .sidebar .user-info,
  html.sidebar-mini .sidebar-rail:not(:hover) .sidebar .sidebar-collapse-btn,
  html.sidebar-mini .sidebar-rail:not(:hover) .sidebar .nav-item .nav-badge { display:none; }
  html.sidebar-mini .sidebar-rail:not(:hover) .sidebar-logo .mark { display:flex; }
  html.sidebar-mini .sidebar-rail:not(:hover) .sidebar-logo,
  html.sidebar-mini .sidebar-rail:not(:hover) .nav-item,
  html.sidebar-mini .sidebar-rail:not(:hover) .sidebar-user { justify-content:center; }
  html.sidebar-mini .sidebar-rail .nav-item i,
  html.sidebar-mini .sidebar-rail .sidebar-logo .mark { flex-shrink:0; }
}

.sidebar-logo { display:flex; flex-direction:column; align-items:center; text-align:center; gap:8px; padding:20px 16px 16px; border-bottom:1px solid rgba(255,255,255,.08); flex-shrink:0; position:relative; }
.sidebar-logo .mark { width:32px; height:32px; border-radius:9px; background:linear-gradient(135deg,#818CF8,#A78BFA); display:none; align-items:center; justify-content:center; color:#fff; font-weight:700; font-size:14px; flex-shrink:0; }
.sidebar-logo .logo-full { display:flex; flex-direction:column; align-items:center; gap:8px; }
.sidebar-logo .logo-full img { width:150px; max-width:100%; height:auto; display:block; }
.sidebar-logo span { font-weight:700; font-size:15px; color:#fff; white-space:nowrap; }
.sidebar-logo .sidebar-collapse-btn { position:absolute; top:16px; right:12px; margin-left:0; }
.sidebar-collapse-btn { margin-left:auto; background:none; border:none; color:#818CF8; width:26px; height:26px; border-radius:6px;
  display:flex; align-items:center; justify-content:center; cursor:pointer; font-size:15px; flex-shrink:0; transition:var(--transition); }
.sidebar-collapse-btn:hover { background:rgba(99,102,241,.25); color:#fff; }

.sidebar nav { flex:1; padding:8px; }
.nav-section-title { font-size:10px; font-weight:700; text-transform:uppercase; letter-spacing:.06em; color:#6366F1; padding:14px 12px 4px; white-space:nowrap; }
.nav-item { display:flex; align-items:center; gap:10px; padding:8px 12px; border-radius:8px; color:#C7D2FE; text-decoration:none;
  font-size:13px; margin-bottom:1px; transition:var(--transition); white-space:nowrap; }
.nav-item:hover { background:rgba(99,102,241,.2); color:#fff; }
.nav-item.active { background:rgba(99,102,241,.32); color:#fff; font-weight:600; box-shadow:inset 3px 0 0 #818CF8; }
.nav-item i { font-size:16px; width:18px; text-align:center; flex-shrink:0; }
.nav-badge { margin-left:auto; background:var(--danger); color:#fff; font-size:10px; font-weight:700; padding:1px 6px; border-radius:10px; flex-shrink:0; }

.sidebar-footer { padding:8px; border-top:1px solid rgba(255,255,255,.08); flex-shrink:0; }
.sidebar-user { display:flex; align-items:center; gap:8px; padding:10px 12px; border-radius:8px; cursor:pointer; transition:var(--transition); }
.sidebar-user:hover { background:rgba(99,102,241,.2); }
.sidebar-user .avatar { width:32px; height:32px; background:#818CF8; color:#fff; flex-shrink:0; }
.sidebar-user .user-name { font-size:12.5px; font-weight:600; color:#fff; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.sidebar-user .user-role { font-size:11px; color:#8B87E8; white-space:nowrap; }
.sidebar-user .user-info { min-width:0; flex:1; }

/* ── Main column ── */
.main-col { flex:1; min-width:0; display:flex; flex-direction:column; overflow:hidden; }
.topbar { background:var(--card); border-bottom:1px solid var(--border); padding:0 24px; height:60px;
  display:flex; align-items:center; justify-content:space-between; flex-shrink:0; box-shadow:var(--shadow); z-index:20; gap:16px; }
.topbar-left { display:flex; align-items:center; gap:14px; min-width:0; flex:1; }
.topbar-right { display:flex; align-items:center; gap:10px; flex-shrink:0; }

/* Search */
.search-wrap { position:relative; max-width:320px; width:100%; }
.search-wrap > i { position:absolute; left:11px; top:50%; transform:translateY(-50%); color:var(--text-light); font-size:15px; pointer-events:none; }
.search-input { padding:8px 12px 8px 34px; border:1px solid var(--border); border-radius:8px; font-size:13px; outline:none;
  width:100%; background:var(--surface); color:var(--text); transition:var(--transition); }
.search-input:focus { border-color:var(--primary); background:#fff; box-shadow:0 0 0 3px rgba(79,70,229,.1); }
.search-dropdown { position:absolute; top:calc(100% + 6px); left:0; width:320px; max-height:380px; overflow-y:auto;
  background:var(--card); border:1px solid var(--border); border-radius:var(--radius); box-shadow:var(--shadow-lg); z-index:200; padding:6px; }
.search-dropdown-item { display:flex; align-items:center; gap:10px; padding:8px; border-radius:7px; color:var(--text); transition:var(--transition); text-decoration:none; }
.search-dropdown-item:hover { background:var(--surface); }
.search-dropdown-icon { width:30px; height:30px; border-radius:7px; background:var(--primary-light); color:var(--primary);
  display:flex; align-items:center; justify-content:center; flex-shrink:0; font-size:15px; }
.search-dropdown-text { display:flex; flex-direction:column; min-width:0; }
.search-dropdown-title { font-size:13px; font-weight:500; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.search-dropdown-subtitle { font-size:11px; color:var(--text-muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.search-dropdown-empty { padding:14px 10px; font-size:12px; color:var(--text-muted); text-align:center; }

.context-switcher { display:flex; gap:8px; }
.context-switcher select { font-size:12.5px; padding:6px 10px; border-radius:8px; border:1px solid var(--border); background:#fff; color:var(--text); }

.btn-icon { width:36px; height:36px; border-radius:9px; border:1px solid var(--border); background:#fff;
  display:flex; align-items:center; justify-content:center; cursor:pointer; color:#374151; position:relative; transition:var(--transition); flex-shrink:0; }
.btn-icon:hover { background:var(--surface); border-color:#CBD5E1; }
.notif-dot { position:absolute; top:6px; right:7px; width:7px; height:7px; border-radius:50%; background:var(--danger); border:2px solid #fff; }
.user-chip { display:flex; align-items:center; gap:8px; padding:6px 10px 6px 6px; border-radius:10px; cursor:pointer; transition:var(--transition); }
.user-chip:hover { background:var(--surface); }
.user-chip .avatar { width:30px; height:30px; }
.user-name { font-size:13px; font-weight:600; }
.user-role { font-size:11px; color:var(--text-muted); }

.page-content { padding:24px; flex:1; overflow-y:auto; }

/* ── Notifications ── */
.notif-panel { position:fixed; top:64px; right:24px; width:320px; background:var(--card); border:1px solid var(--border);
  border-radius:var(--radius); box-shadow:var(--shadow-lg); display:none; z-index:500; max-height:70vh; overflow-y:auto; }
.notif-panel.open { display:block; }
.notif-header { display:flex; justify-content:space-between; align-items:center; padding:12px 16px; border-bottom:1px solid var(--border); }
.notif-list { padding:6px; }
.notif-item { display:flex; gap:10px; padding:10px; border-radius:8px; transition:var(--transition); }
.notif-item:hover { background:var(--surface); }
.notif-item.unread { background:var(--primary-light); }
.notif-icon { width:32px; height:32px; border-radius:8px; display:flex; align-items:center; justify-content:center; flex-shrink:0; font-size:15px; }
.notif-title { font-size:12.5px; font-weight:500; }
.notif-time { font-size:11px; color:var(--text-muted); margin-top:2px; }

/* ── Page header ── */
.page-header { display:flex; align-items:flex-start; justify-content:space-between; margin-bottom:20px; flex-wrap:wrap; gap:12px; }
.page-header-left h2 { margin:0 0 4px; font-size:21px; font-weight:700; }
.page-header-left p { margin:0; color:var(--text-muted); font-size:13px; }
.page-header-actions { display:flex; gap:8px; flex-wrap:wrap; }

/* ── Cards / Grid ── */
.card { background:var(--card); border:1px solid var(--border); border-radius:var(--radius); padding:18px; box-shadow:var(--shadow); }
.card-sm { background:var(--card); border:1px solid var(--border); border-radius:10px; padding:12px 14px; box-shadow:var(--shadow); }
.card-title { font-size:13.5px; font-weight:700; display:flex; align-items:center; gap:8px; margin-bottom:14px; }
.card-title i { color:var(--text-muted); }
.grid { display:grid; gap:16px; }
.g2 { grid-template-columns:repeat(2,1fr); }
.g3 { grid-template-columns:repeat(3,1fr); }
.g4 { grid-template-columns:repeat(4,1fr); }
@media (max-width:900px) { .g2,.g3,.g4 { grid-template-columns:repeat(2,1fr); } }
@media (max-width:600px) { .g2,.g3,.g4 { grid-template-columns:1fr; } }

.stat-card { background:var(--card); border:1px solid var(--border); border-radius:var(--radius); padding:16px; box-shadow:var(--shadow); display:flex; align-items:center; gap:12px; transition:var(--transition); }
.stat-card:hover { box-shadow:var(--shadow-md); transform:translateY(-1px); }
.stat-icon { width:44px; height:44px; border-radius:10px; display:flex; align-items:center; justify-content:center; font-size:19px; flex-shrink:0; }
.stat-label { font-size:12px; color:var(--text-muted); }
.stat-value { font-size:19px; font-weight:700; }
.stat-change { font-size:11px; color:var(--text-muted); margin-top:2px; }

/* ── Buttons ── */
.btn { display:inline-flex; align-items:center; gap:6px; padding:9px 16px; border-radius:9px; border:none; font-size:13px; font-weight:600; cursor:pointer; text-decoration:none; transition:var(--transition); }
.btn-primary { background:var(--primary); color:#fff; }
.btn-primary:hover { background:var(--primary-dark); }
.btn-outline { background:#fff; border:1px solid var(--border); color:var(--text); }
.btn-outline:hover { background:var(--surface); border-color:#CBD5E1; }
.btn-success { background:var(--success); color:#fff; }
.btn-success:hover { background:#0e9e6f; }
.btn-warning { background:var(--warning); color:#fff; }
.btn-danger { background:var(--danger); color:#fff; }
.btn-sm { padding:6px 11px; font-size:12px; }
.btn-block { width:100%; justify-content:center; }
.btn:disabled { opacity:.6; cursor:not-allowed; }
.btn-ghost { background:transparent; color:var(--primary); padding:4px 8px; }
.btn-ghost:hover { background:var(--primary-light); }

/* ── Forms ── */
.form-row { display:flex; gap:12px; flex-wrap:wrap; }
.form-row .form-group { flex:1; min-width:140px; }
.form-group { margin-bottom:14px; }
.form-label { display:block; font-size:12.5px; font-weight:600; margin-bottom:6px; color:#374151; }
.form-input, .form-select, .form-textarea { width:100%; padding:9px 12px; border:1px solid var(--border); border-radius:8px; font-size:13px; font-family:inherit; background:#fff; transition:var(--transition); color:var(--text); }
.form-input:focus, .form-select:focus, .form-textarea:focus { outline:none; border-color:var(--primary); box-shadow:0 0 0 3px rgba(79,70,229,.1); }
.form-textarea { resize:vertical; }
.form-hint { font-size:11.5px; color:var(--text-light); margin-top:4px; }
.checkbox-row { display:flex; align-items:center; gap:8px; font-size:13px; }

/* ── Table ── */
.table-wrap { overflow-x:auto; }
.table { width:100%; border-collapse:collapse; }
.table th { text-align:left; font-size:11px; text-transform:uppercase; letter-spacing:.03em; color:var(--text-muted); padding:10px 12px; border-bottom:1px solid var(--border); white-space:nowrap; font-weight:600; }
.table td { padding:11px 12px; border-bottom:1px solid var(--border); font-size:13px; vertical-align:middle; }
.table tbody tr { transition:var(--transition); }
.table tbody tr:hover { background:var(--surface); }
.table tbody tr:last-child td { border-bottom:none; }

/* ── Badges / status ── */
.badge { display:inline-flex; align-items:center; gap:4px; padding:3px 9px; border-radius:20px; font-size:11px; font-weight:600; }
.badge-green { background:#DCFCE7; color:#15803D; }
.badge-red { background:#FEE2E2; color:#B91C1C; }
.badge-orange { background:#FFEDD5; color:#C2410C; }
.badge-blue { background:#DBEAFE; color:#1D4ED8; }
.badge-purple { background:#EDE9FE; color:#6D28D9; }
.badge-gray { background:#F3F4F6; color:#4B5563; }

/* ── Tabs ── */
.tabs { display:flex; gap:4px; border-bottom:2px solid var(--border); margin-bottom:18px; flex-wrap:wrap; }
.tab { padding:9px 16px; font-size:13px; font-weight:600; color:var(--text-muted); cursor:pointer; border-bottom:2px solid transparent; margin-bottom:-2px; display:flex; align-items:center; gap:6px; transition:var(--transition); }
.tab.active { color:var(--primary); border-bottom-color:var(--primary); }
.tab:hover:not(.active) { color:var(--text); }
.tab-panel {}

/* ── Modal ── */
.modal-backdrop { position:fixed; inset:0; background:rgba(15,23,42,.55); display:flex; align-items:center; justify-content:center; z-index:900; padding:20px; }
.modal { background:#fff; border-radius:14px; padding:22px; width:100%; max-width:560px; max-height:90vh; overflow-y:auto; box-shadow:var(--shadow-lg); }
.modal.modal-lg { max-width:820px; }
.modal-header { display:flex; align-items:center; justify-content:space-between; margin-bottom:16px; }
.modal-title { font-size:16px; font-weight:700; display:flex; align-items:center; gap:8px; }
.modal-footer { display:flex; justify-content:flex-end; gap:8px; margin-top:18px; padding-top:14px; border-top:1px solid var(--border); }

/* ── Avatar ── */
.avatar { width:36px; height:36px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-size:13px; font-weight:700; background:var(--primary-light); color:var(--primary); flex-shrink:0; overflow:hidden; }
.avatar img { width:100%; height:100%; object-fit:cover; }

/* ── Progress ── */
.progress { height:7px; border-radius:20px; background:var(--surface); overflow:hidden; }
.progress-bar { height:100%; border-radius:20px; transition:width .4s; }

/* ── Flash / alerts ── */
.flash { display:flex; align-items:center; gap:8px; padding:11px 15px; font-size:13px; }
.flash-success { background:#DCFCE7; color:#15803D; }
.flash-error { background:#FEE2E2; color:#B91C1C; }
.flash-info { background:#DBEAFE; color:#1D4ED8; }
.flash-close { margin-left:auto; background:none; border:none; cursor:pointer; opacity:.6; color:inherit; }
.flash-close:hover { opacity:1; }

/* ── Utility ── */
.flex { display:flex; }
.flex-col { display:flex; flex-direction:column; }
.flex-1 { flex:1; }
.items-center { align-items:center; }
.items-start { align-items:flex-start; }
.justify-between { justify-content:space-between; }
.flex-wrap { flex-wrap:wrap; }
.text-center { text-align:center; }
.text-right { text-align:right; }
.text-sm { font-size:12.5px; }
.text-xs { font-size:11px; }
.text-muted { color:var(--text-muted); }
.fw-500 { font-weight:500; } .fw-600 { font-weight:600; } .fw-700 { font-weight:700; }
.gap-4{gap:4px;} .gap-6{gap:6px;} .gap-8{gap:8px;} .gap-10{gap:10px;} .gap-12{gap:12px;} .gap-14{gap:14px;} .gap-16{gap:16px;}
.mb-0{margin-bottom:0;} .mb-4{margin-bottom:4px;} .mb-6{margin-bottom:6px;} .mb-8{margin-bottom:8px;} .mb-10{margin-bottom:10px;}
.mb-12{margin-bottom:12px;} .mb-16{margin-bottom:16px;} .mb-20{margin-bottom:20px;} .mb-24{margin-bottom:24px;}
.mt-6{margin-top:6px;} .mt-8{margin-top:8px;} .mt-12{margin-top:12px;} .mt-16{margin-top:16px;} .mt-20{margin-top:20px;}
.mr-6{margin-right:6px;}
.status { display:inline-flex; align-items:center; gap:5px; }
.status::before { content:''; width:6px; height:6px; border-radius:50%; background:currentColor; }
.status-active,.status-approved,.status-completed { color:var(--success); }
.status-pending,.status-scheduled { color:var(--primary); }
.status-progress { color:var(--warning); }
.status-inactive,.status-rejected,.status-cancelled { color:var(--danger); }
.status-rescheduled { color:var(--purple); }

/* Column-toggle / filter chips */
.chip { display:inline-flex; align-items:center; gap:6px; padding:6px 10px; border:1px solid var(--border); border-radius:8px; font-size:12.5px; cursor:pointer; background:#fff; transition:var(--transition); }
.chip:hover { border-color:#CBD5E1; }
.chip.active { background:var(--primary-light); border-color:var(--primary); color:var(--primary); }

/* Photo upload box */
.photo-upload { width:110px; height:110px; border-radius:12px; border:2px dashed var(--border); display:flex; align-items:center; justify-content:center; position:relative; overflow:hidden; background:var(--surface); cursor:pointer; transition:var(--transition); }
.photo-upload:hover { border-color:var(--primary); }
.photo-upload img { width:100%; height:100%; object-fit:cover; }
.photo-upload .placeholder { color:var(--text-muted); font-size:11px; text-align:center; padding:8px; }

/* Doc row */
.doc-row { display:flex; align-items:center; justify-content:space-between; padding:10px 12px; border:1px solid var(--border); border-radius:9px; margin-bottom:8px; transition:var(--transition); }
.doc-row:hover { border-color:#CBD5E1; }
.doc-row .doc-name { font-size:13px; }
.doc-row .doc-actions { display:flex; gap:6px; }

/* ── Mobile ── */
.sidebar-toggle { display:none; }
@media (max-width:768px) {
  .sidebar-toggle { display:flex !important; }
  .sidebar-rail { width:0 !important; }
  .sidebar-rail .sidebar, .sidebar { position:fixed; left:-100%; top:0; width:var(--sidebar-w); height:100vh; transition:left .2s; z-index:300; }
  .sidebar.open { left:0; }
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width:6px; height:6px; }
::-webkit-scrollbar-track { background:transparent; }
::-webkit-scrollbar-thumb { background:#CBD5E1; border-radius:3px; }
.sidebar::-webkit-scrollbar-thumb { background:rgba(255,255,255,.15); }

.report-card { margin-bottom:16px; }

@media print {
  .sidebar-rail, .topbar, .no-print, .page-header-actions, .tabs { display:none !important; }
  .page-content { padding:0 !important; overflow:visible !important; }
  body { overflow:visible !important; background:#fff; }
  .report-card { break-inside:avoid; page-break-after:always; border:none; box-shadow:none; }
}
