:root {
  --primary: #149FE3;
  --primary-dark: #0C78B2;
  --accent: #6C4DDE;
  --deep: #2B1C4B;
  --success: #82C341;
  --danger: #E84A5F;
  --warning: #D99827;
  --admin-bg: #F6F7FB;
  --bg: var(--admin-bg);
  --surface: #FFFFFF;
  --surface-2: #F8FAFD;
  --surface-3: #EEF3F8;
  --text: #161922;
  --muted: #6B7280;
  --muted-2: #98A0AE;
  --border: #E4E9F0;
  --sidebar: #171228;
  --sidebar-2: #21193A;
  --shadow: 0 16px 40px rgba(24, 25, 47, .08);
  --shadow-soft: 0 8px 20px rgba(24, 25, 47, .05);
  --radius: 16px;
  --radius-sm: 11px;
  --transition: 180ms ease;
  --font: "Montserrat", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html[data-theme="dark"] {
  --bg: #11101A;
  --surface: #181622;
  --surface-2: #1E1B2A;
  --surface-3: #292438;
  --text: #F4F4F7;
  --muted: #B2B1BF;
  --muted-2: #8E8C9B;
  --border: #312C40;
  --sidebar: #0D0A15;
  --sidebar-2: #191329;
  --shadow: 0 16px 40px rgba(0, 0, 0, .25);
  --shadow-soft: 0 8px 20px rgba(0, 0, 0, .18);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { scroll-behavior: smooth; }
body {
  background:
    radial-gradient(circle at 10% 0%, rgba(20,159,227,.08), transparent 30%),
    radial-gradient(circle at 100% 10%, rgba(108,77,222,.09), transparent 26%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  transition: background-color var(--transition), color var(--transition);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; }

.app-root { display: flex; min-height: 100vh; }
.sidebar {
  width: 258px;
  flex: 0 0 258px;
  background: linear-gradient(180deg, var(--sidebar), var(--sidebar-2));
  color: #fff;
  padding: 22px 14px 14px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 50;
  box-shadow: 10px 0 30px rgba(25, 16, 57, .08);
}
.sidebar-brand { padding: 2px 10px 30px; }
.brand-link { display: inline-flex; align-items: center; gap: 12px; }
.brand-mark { width: 30px; height: 35px; flex: 0 0 auto; }
.brand-mark svg { width: 100%; height: 100%; }
.brand-outline { fill: none; stroke: var(--primary); stroke-width: 2; }
.brand-fill { fill: var(--primary); opacity: .95; }
.brand-fill-top { opacity: .85; }
.brand-link strong { display:block; font-size: 15px; letter-spacing: 2.1px; }
.brand-link small { display:block; margin-top: 1px; color: rgba(255,255,255,.56); font-size: 8px; letter-spacing: 1.4px; }

.sidebar-nav { display: flex; flex-direction: column; gap: 7px; }
.nav-label { padding: 0 12px 8px; text-transform: uppercase; letter-spacing: 1.25px; font-size: 9px; color: rgba(255,255,255,.38); }
.nav-link {
  width: 100%;
  border: 0;
  background: transparent;
  color: rgba(255,255,255,.72);
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  transition: transform var(--transition), background var(--transition), color var(--transition);
}
.nav-link:hover { background: rgba(255,255,255,.08); color:#fff; transform: translateX(2px); }
.nav-link.active {
  background: linear-gradient(135deg, rgba(20,159,227,.24), rgba(108,77,222,.26));
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.06);
}
.nav-icon { width: 18px; height: 18px; display:flex; align-items:center; justify-content:center; }
.nav-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-bottom { margin-top: auto; }
.sidebar-profile { display:flex; gap:10px; align-items:center; padding: 12px; margin: 10px 0; border-top: 1px solid rgba(255,255,255,.08); }
.profile-copy { min-width:0; }
.profile-copy strong, .profile-copy span { display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.profile-copy strong { font-size:12px; }
.profile-copy span { color: rgba(255,255,255,.48); font-size:10px; margin-top:2px; }
.logout-form { margin: 0; }
.nav-logout { color: rgba(255,255,255,.5); }

.avatar { width: 34px; height:34px; border-radius: 11px; display:grid; place-items:center; background: linear-gradient(135deg, var(--primary), var(--accent)); color:#fff; font-size:12px; font-weight:800; box-shadow: 0 8px 18px rgba(20,159,227,.2); }
.avatar-small { width: 34px; height:34px; border-radius: 50%; }

.app-main { min-width:0; flex:1; display:flex; flex-direction:column; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: 78px;
  padding: 14px 28px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:20px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 82%, transparent);
}
.topbar-left { display:flex; align-items:center; gap:12px; min-width:0; }
.topbar-left h1 { margin: 1px 0 0; font-size: 21px; letter-spacing: -.45px; }
.eyebrow { text-transform: uppercase; letter-spacing: 1.15px; font-size: 9px; color: var(--primary); font-weight:800; }
.topbar-actions { display:flex; align-items:center; gap:8px; }
.icon-btn {
  position:relative; border:1px solid var(--border); background:var(--surface); width:40px; height:40px; border-radius:12px; color:var(--text);
  display:grid; place-items:center; transition: all var(--transition); box-shadow: var(--shadow-soft);
}
.icon-btn:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); color: var(--primary); }
.icon-btn svg { width:19px; height:19px; fill:none; stroke:currentColor; stroke-width:1.75; stroke-linecap:round; stroke-linejoin:round; }
.icon-moon { display:none; }
html[data-theme="dark"] .icon-sun { display:none; }
html[data-theme="dark"] .icon-moon { display:block; }
.notification-wrap { position:relative; }
.notification-badge { position:absolute; right:-2px; top:-4px; min-width:17px; height:17px; border-radius:20px; padding:0 4px; display:grid; place-items:center; background:var(--danger); color:#fff; font-size:9px; font-weight:800; border:2px solid var(--surface); }
.notification-panel { position:absolute; right:0; top:48px; width:340px; border:1px solid var(--border); background:var(--surface); border-radius:15px; box-shadow:var(--shadow); overflow:hidden; }
.notification-head { padding:14px 16px; border-bottom:1px solid var(--border); display:flex; justify-content:space-between; gap:12px; align-items:flex-start; }
.notification-head strong, .notification-head span { display:block; }
.notification-head strong { font-size:12px; }
.notification-head span { font-size:10px; color:var(--muted); margin-top:2px; }
.text-btn { border:0; background:transparent; color:var(--primary); font-weight:700; font-size:10px; padding:2px 0; }
.notification-list { max-height:330px; overflow:auto; }
.notification-item { display:flex; gap:11px; padding:13px 16px; border-bottom:1px solid var(--border); }
.notification-item:last-child { border-bottom:0; }
.notification-item strong, .notification-item span { display:block; }
.notification-item strong { font-size:10.5px; }
.notification-item span { margin-top:3px; color:var(--muted); font-size:9.5px; }
.notification-dot { width:8px; height:8px; border-radius:50%; flex:0 0 auto; margin-top:6px; background:var(--primary); box-shadow:0 0 0 5px rgba(20,159,227,.09); }
.notification-dot.project { background:var(--accent); box-shadow:0 0 0 5px rgba(108,77,222,.09); }
.notification-dot.lead { background:var(--warning); box-shadow:0 0 0 5px rgba(217,152,39,.09); }
.notification-dot.client { background:var(--success); box-shadow:0 0 0 5px rgba(130,195,65,.09); }
.topbar-user { display:flex; align-items:center; gap:8px; padding-left:8px; }
.topbar-user-copy strong, .topbar-user-copy span { display:block; }
.topbar-user-copy strong { font-size:10.5px; }
.topbar-user-copy span { color:var(--muted); font-size:9px; margin-top:1px; }

.content-area { width:100%; max-width: 1600px; margin:0 auto; padding: 28px; flex:1; }
.app-footer { display:flex; justify-content:space-between; gap:15px; padding: 20px 28px 24px; color:var(--muted); font-size:9.5px; }
.app-footer span:first-child { color:var(--text); font-weight:700; }

.alert { padding:12px 14px; border-radius:12px; margin-bottom:18px; border:1px solid transparent; font-size:11px; }
.alert-success { background: color-mix(in srgb, var(--success) 12%, var(--surface)); color: color-mix(in srgb, var(--success) 72%, var(--text)); border-color: color-mix(in srgb, var(--success) 24%, var(--border)); }
.alert-danger { background: color-mix(in srgb, var(--danger) 10%, var(--surface)); color: color-mix(in srgb, var(--danger) 72%, var(--text)); border-color: color-mix(in srgb, var(--danger) 20%, var(--border)); }

.page-head { display:flex; justify-content:space-between; gap:20px; align-items:flex-end; margin-bottom:22px; }
.page-head h2 { margin:0; font-size:22px; letter-spacing:-.5px; }
.page-head p { margin:6px 0 0; color:var(--muted); font-size:11px; max-width:620px; }
.page-actions { display:flex; flex-wrap:wrap; gap:9px; }

.btn { border:1px solid var(--border); background:var(--surface); color:var(--text); min-height:40px; padding:0 14px; border-radius:11px; display:inline-flex; align-items:center; justify-content:center; gap:7px; font-weight:700; font-size:10.5px; transition:all var(--transition); }
.btn:hover { transform:translateY(-1px); box-shadow:var(--shadow-soft); }
.btn svg { width:15px; height:15px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.btn-primary { background:linear-gradient(135deg,var(--primary),var(--accent)); border-color:transparent; color:#fff; box-shadow:0 10px 24px rgba(108,77,222,.18); }
.btn-danger { color:#fff; background:var(--danger); border-color:var(--danger); }
.btn-ghost { background:transparent; }
.btn-sm { min-height:34px; padding:0 10px; font-size:9.5px; border-radius:9px; }

.card { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); box-shadow:var(--shadow-soft); }
.card-head { display:flex; justify-content:space-between; gap:12px; align-items:flex-start; padding:18px 18px 14px; }
.card-head h3 { margin:0; font-size:13px; }
.card-head p { margin:4px 0 0; font-size:10px; color:var(--muted); }
.card-body { padding:0 18px 18px; }

.table-responsive { width:100%; overflow-x:auto; -webkit-overflow-scrolling:touch; }
.table { width:100%; min-width:760px; border-collapse:collapse; }
.table th { text-transform:uppercase; letter-spacing:.8px; color:var(--muted-2); font-size:8.5px; padding:10px 12px; border-bottom:1px solid var(--border); text-align:left; font-weight:800; }
.table td { padding:12px; border-bottom:1px solid color-mix(in srgb,var(--border) 85%, transparent); font-size:10.5px; vertical-align:middle; }
.table tbody tr:hover { background:color-mix(in srgb,var(--primary) 3.5%, var(--surface)); }
.table tbody tr:last-child td { border-bottom:0; }
.table .primary-cell { font-weight:800; color:var(--text); }
.table .secondary-cell { color:var(--muted); font-size:9.5px; margin-top:2px; }
.table-actions { display:flex; gap:6px; justify-content:flex-end; }

.badge { display:inline-flex; align-items:center; gap:5px; min-height:23px; padding:0 8px; border-radius:999px; font-size:8.5px; font-weight:800; white-space:nowrap; }
.badge::before { content:""; width:5px; height:5px; border-radius:50%; background:currentColor; }
.badge-pending { color:#8D6E2A; background:#F9F0D9; }
.badge-progress { color:#1A76A8; background:#E5F5FF; }
.badge-completed, .badge-paid, .badge-delivered { color:#4D8A1B; background:#EDF7E3; }
.badge-hold, .badge-lost { color:#A34A56; background:#FCEAED; }
.badge-new { color:#8A5C14; background:#FFF2D9; }
.badge-contacted { color:#6C4DDE; background:#EFEAFF; }
.badge-qualified { color:#197D95; background:#E2F5F7; }

.form-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:14px; }
.form-group { display:flex; flex-direction:column; gap:6px; }
.form-group.full { grid-column:1 / -1; }
.form-group label { font-size:9.5px; font-weight:800; color:var(--text); }
.form-control { width:100%; min-height:42px; border:1px solid var(--border); border-radius:10px; background:var(--surface-2); color:var(--text); padding:0 12px; outline:none; transition:border var(--transition), box-shadow var(--transition), background var(--transition); }
.form-control:focus { border-color:color-mix(in srgb,var(--primary) 65%, var(--border)); box-shadow:0 0 0 4px color-mix(in srgb,var(--primary) 11%, transparent); }
textarea.form-control { padding:10px 12px; min-height:100px; resize:vertical; }
.form-hint { color:var(--muted); font-size:9px; }
.form-actions { display:flex; justify-content:flex-end; gap:8px; margin-top:6px; }

.toolbar { display:flex; flex-wrap:wrap; justify-content:space-between; gap:10px; margin-bottom:14px; }
.toolbar-left, .toolbar-right { display:flex; flex-wrap:wrap; gap:8px; align-items:center; }
.search-wrap { position:relative; }
.search-wrap svg { position:absolute; left:12px; top:50%; transform:translateY(-50%); width:15px; height:15px; fill:none; stroke:var(--muted); stroke-width:1.7; stroke-linecap:round; stroke-linejoin:round; }
.search-input { padding-left:35px; min-width:260px; }
.select-input { min-width:140px; }

.empty-state { padding:34px 16px; text-align:center; color:var(--muted); border:1px dashed var(--border); border-radius:12px; background:color-mix(in srgb,var(--surface-2) 65%,transparent); }
.empty-state strong { display:block; color:var(--text); font-size:12px; margin-bottom:4px; }
.empty-state.compact { padding:20px 12px; border:0; background:transparent; }

.modal { position:fixed; inset:0; z-index:100; display:none; align-items:center; justify-content:center; padding:20px; background:rgba(10,7,20,.58); backdrop-filter:blur(6px); }
.modal.open { display:flex; }
.modal-card { width:min(720px,100%); max-height:90vh; overflow:auto; background:var(--surface); border:1px solid var(--border); border-radius:18px; box-shadow:0 30px 90px rgba(0,0,0,.22); }
.modal-card.wide { width:min(980px,100%); }
.modal-head { display:flex; justify-content:space-between; gap:14px; padding:18px 20px; border-bottom:1px solid var(--border); position:sticky; top:0; background:color-mix(in srgb,var(--surface) 94%,transparent); backdrop-filter:blur(14px); z-index:2; }
.modal-head h3 { margin:0; font-size:14px; }
.modal-head p { margin:3px 0 0; font-size:9.5px; color:var(--muted); }
.modal-body { padding:20px; }
.modal-close { width:34px; height:34px; border:1px solid var(--border); background:var(--surface-2); color:var(--muted); border-radius:10px; display:grid; place-items:center; }
.modal-close svg { width:16px; height:16px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; }

.segmented { display:inline-flex; padding:3px; background:var(--surface-3); border-radius:10px; }
.segmented button { border:0; background:transparent; color:var(--muted); padding:7px 10px; font-weight:800; border-radius:8px; font-size:9px; }
.segmented button.active { background:var(--surface); color:var(--primary); box-shadow:var(--shadow-soft); }

.stat-grid-spacer { height:8px; }
.stats-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:14px; margin-bottom:22px; }
.stat-card { position:relative; overflow:hidden; border:1px solid var(--border); background:var(--surface); border-radius:16px; padding:17px; display:flex; align-items:center; gap:13px; box-shadow:var(--shadow-soft); }
.stat-card::after { content:""; position:absolute; width:95px; height:95px; border-radius:50%; right:-42px; bottom:-42px; opacity:.07; background:currentColor; }
.stat-icon { width:40px; height:40px; border-radius:12px; display:grid; place-items:center; flex:0 0 auto; }
.stat-icon svg { width:20px; height:20px; fill:none; stroke:currentColor; stroke-width:1.7; stroke-linecap:round; stroke-linejoin:round; }
.stat-copy span, .stat-copy strong { display:block; }
.stat-copy span { font-size:9px; color:var(--muted); }
.stat-copy strong { margin-top:3px; font-size:18px; letter-spacing:-.45px; }
.stat-blue { color:var(--primary); }
.stat-blue .stat-icon { background:color-mix(in srgb,var(--primary) 12%, var(--surface)); }
.stat-purple { color:var(--accent); }
.stat-purple .stat-icon { background:color-mix(in srgb,var(--accent) 12%, var(--surface)); }
.stat-green { color:var(--success); }
.stat-green .stat-icon { background:color-mix(in srgb,var(--success) 14%, var(--surface)); }
.stat-amber { color:var(--warning); }
.stat-amber .stat-icon { background:color-mix(in srgb,var(--warning) 14%, var(--surface)); }

.kpi { font-size:9px; font-weight:700; color:var(--muted); }
.money { font-weight:800; letter-spacing:-.15px; }
.muted { color:var(--muted); }
.text-right { text-align:right; }
.desktop-only { display:block; }
.mobile-only { display:none; }

.form-switch { display:flex; align-items:center; justify-content:space-between; gap:20px; }
.switch { position:relative; width:46px; height:26px; flex:0 0 auto; }
.switch input { opacity:0; width:0; height:0; }
.switch-track { position:absolute; inset:0; border-radius:999px; background:var(--surface-3); border:1px solid var(--border); transition:all var(--transition); }
.switch-track::after { content:""; width:18px; height:18px; position:absolute; top:3px; left:3px; border-radius:50%; background:#fff; box-shadow:0 2px 6px rgba(0,0,0,.15); transition:left var(--transition); }
.switch input:checked + .switch-track { background:linear-gradient(135deg,var(--primary),var(--accent)); border-color:transparent; }
.switch input:checked + .switch-track::after { left:23px; }

@media (max-width: 1120px) {
  .sidebar { width:228px; flex-basis:228px; }
  .stats-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .content-area { padding:24px; }
}
@media (max-width: 820px) {
  .mobile-only { display:grid; }
  .desktop-only { display:none; }
  .sidebar { position:fixed; left:0; transform:translateX(-104%); transition:transform 220ms ease; width:280px; box-shadow:20px 0 60px rgba(0,0,0,.2); }
  .sidebar.open { transform:translateX(0); }
  .sidebar-scrim { position:fixed; inset:0; background:rgba(10,7,20,.52); opacity:0; pointer-events:none; transition:opacity 220ms ease; z-index:40; }
  .sidebar-scrim.open { opacity:1; pointer-events:auto; }
  .topbar { padding:12px 18px; min-height:70px; }
  .content-area { padding:20px 18px; }
  .topbar-user-copy { display:none; }
}
@media (max-width: 640px) {
  .stats-grid { grid-template-columns:1fr 1fr; gap:10px; }
  .stat-card { padding:14px; }
  .stat-icon { width:36px; height:36px; border-radius:10px; }
  .stat-copy strong { font-size:15px; }
  .page-head { align-items:flex-start; flex-direction:column; }
  .page-actions { width:100%; }
  .page-actions .btn { flex:1; }
  .form-grid { grid-template-columns:1fr; }
  .form-group.full { grid-column:auto; }
  .search-input { min-width:100%; }
  .toolbar { align-items:stretch; }
  .toolbar-left, .toolbar-right { width:100%; }
  .toolbar-left > *, .toolbar-right > * { flex:1; }
  .select-input { min-width:0; width:100%; }
  .app-footer { padding:16px 18px 20px; flex-direction:column; }
  .notification-panel { width:calc(100vw - 32px); right:-52px; }
}
@media (max-width: 420px) {
  .stats-grid { grid-template-columns:1fr; }
  .topbar { gap:8px; }
  .topbar-left h1 { font-size:18px; }
  .topbar-actions { gap:5px; }
  .topbar-user { display:none; }
}
