/* ==========================================================
   ClientFlow — Core Design System (Pure CSS, no frameworks)
   ========================================================== */

:root{
  --bg:            #F4F6FB;
  --surface:       #FFFFFF;
  --surface-alt:   #F8F9FC;
  --border:        #E6E9F2;
  --border-strong: #D7DCE8;

  --text:          #16192B;
  --text-muted:    #6B7186;
  --text-faint:    #9AA1B4;

  --sidebar-bg:    #10142B;
  --sidebar-bg-2:  #171B37;
  --sidebar-text:  #A9AEC7;
  --sidebar-text-active: #FFFFFF;

  --primary:       #4F6EF7;
  --primary-dark:  #3D57D6;
  --primary-light: #EEF1FE;

  --success:       #1FAA6B;
  --success-bg:    #E7F8EF;
  --warning:       #E2A03F;
  --warning-bg:    #FCF3E3;
  --danger:        #E5484D;
  --danger-bg:     #FCEBEC;
  --info:          #3A8DDE;
  --info-bg:       #E9F3FC;
  --purple:        #8A5CF6;
  --purple-bg:     #F1EBFE;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --shadow-sm: 0 1px 2px rgba(16,20,43,.05);
  --shadow-md: 0 4px 16px rgba(16,20,43,.06);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --sidebar-w: 248px;
  --topbar-h: 64px;
}

[data-theme="dark"]{
  --bg:            #0B0E1F;
  --surface:       #12162C;
  --surface-alt:   #171B33;
  --border:        #262B48;
  --border-strong: #333A5C;

  --text:          #EDEFF7;
  --text-muted:    #9BA0BE;
  --text-faint:    #6D7292;

  --sidebar-bg:    #090C1C;
  --sidebar-bg-2:  #12152C;

  --primary-light: #1A2050;
  --success-bg:    #123326;
  --warning-bg:    #332708;
  --danger-bg:     #34181B;
  --info-bg:       #102639;
  --purple-bg:     #241C3F;
}

*, *::before, *::after{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family:var(--font);
  background:var(--bg);
  color:var(--text);
  font-size:14px;
  line-height:1.5;
  -webkit-font-smoothing:antialiased;
}
a{ color:inherit; text-decoration:none; }
ul{ list-style:none; margin:0; padding:0; }
button{ font-family:inherit; }
img{ max-width:100%; display:block; }

.icon{ width:18px; height:18px; flex-shrink:0; }
.icon-sm{ width:15px; height:15px; }
.icon-lg{ width:24px; height:24px; }

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

.sidebar{
  width:var(--sidebar-w);
  background:linear-gradient(180deg,var(--sidebar-bg),var(--sidebar-bg-2));
  color:var(--sidebar-text);
  flex-shrink:0;
  position:fixed;
  top:0; left:0; bottom:0;
  display:flex;
  flex-direction:column;
  z-index:40;
  transition:transform .2s ease;
}
.sidebar-brand{
  display:flex; align-items:center; gap:10px;
  padding:20px 22px;
  color:#fff;
  font-weight:700;
  font-size:16px;
}
.sidebar-brand .brand-mark{
  width:30px; height:30px; border-radius:9px;
  background:var(--primary);
  display:flex; align-items:center; justify-content:center;
  color:#fff; font-size:14px; font-weight:800;
}
.sidebar-nav{ padding:8px 12px; overflow-y:auto; flex:1; }
.sidebar-section-label{
  font-size:11px; color:#5B6089; padding:16px 10px 6px;
  letter-spacing:.02em;
}
.sidebar-link{
  display:flex; align-items:center; gap:11px;
  padding:10px 12px;
  border-radius:var(--radius-sm);
  color:var(--sidebar-text);
  font-size:13.5px;
  font-weight:500;
  margin-bottom:2px;
}
.sidebar-link:hover{ background:rgba(255,255,255,.06); color:#fff; }
.sidebar-link.active{ background:var(--primary); color:#fff; }
.sidebar-link .badge-dot{
  margin-left:auto; width:8px; height:8px; border-radius:50%; background:var(--danger);
}
.sidebar-foot{
  padding:14px 22px 20px;
  font-size:12px;
  color:#5B6089;
  border-top:1px solid rgba(255,255,255,.06);
}

.main{
  margin-left:var(--sidebar-w);
  flex:1;
  min-width:0;
  display:flex;
  flex-direction:column;
}

.topbar{
  height:var(--topbar-h);
  background:var(--surface);
  border-bottom:1px solid var(--border);
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:0 24px;
  position:sticky;
  top:0;
  z-index:30;
  gap:16px;
}
.topbar-search{
  display:flex; align-items:center; gap:8px;
  background:var(--surface-alt);
  border:1px solid var(--border);
  border-radius:var(--radius-md);
  padding:8px 12px;
  width:320px;
  color:var(--text-faint);
}
.topbar-search input{
  border:none; background:transparent; outline:none; width:100%;
  font-size:13.5px; color:var(--text);
}
.topbar-actions{ display:flex; align-items:center; gap:14px; }
.icon-btn{
  width:36px; height:36px; border-radius:var(--radius-sm);
  display:flex; align-items:center; justify-content:center;
  background:transparent; border:1px solid transparent; color:var(--text-muted);
  cursor:pointer; position:relative;
}
.icon-btn:hover{ background:var(--surface-alt); border-color:var(--border); }
.icon-btn .dot{
  position:absolute; top:6px; right:7px;
  width:7px; height:7px; border-radius:50%; background:var(--danger);
  border:2px solid var(--surface);
}
.topbar-user{ display:flex; align-items:center; gap:10px; cursor:pointer; }
.avatar{
  width:34px; height:34px; border-radius:50%;
  background:var(--primary-light); color:var(--primary-dark);
  display:flex; align-items:center; justify-content:center;
  font-weight:700; font-size:13px; flex-shrink:0; overflow:hidden;
}
.avatar img{ width:100%; height:100%; object-fit:cover; }
.topbar-user-name{ font-size:13.5px; font-weight:600; }
.topbar-user-role{ font-size:11.5px; color:var(--text-muted); }

.content{ padding:26px 28px 60px; max-width:1400px; width:100%; margin:0 auto; }

.page-header{
  display:flex; align-items:flex-start; justify-content:space-between;
  margin-bottom:22px; gap:16px; flex-wrap:wrap;
}
.page-title{ font-size:21px; font-weight:700; margin:0 0 4px; }
.page-subtitle{ color:var(--text-muted); font-size:13.5px; margin:0; }
.breadcrumbs{ display:flex; align-items:center; gap:6px; color:var(--text-muted); font-size:12.5px; margin-bottom:10px; }
.breadcrumbs a:hover{ color:var(--primary); }

/* ---------- Buttons ---------- */
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  padding:9px 16px; border-radius:var(--radius-sm);
  font-size:13.5px; font-weight:600; cursor:pointer;
  border:1px solid transparent; transition:background .15s ease, border-color .15s ease;
  white-space:nowrap;
}
.btn-primary{ background:var(--primary); color:#fff; }
.btn-primary:hover{ background:var(--primary-dark); }
.btn-outline{ background:var(--surface); border-color:var(--border-strong); color:var(--text); }
.btn-outline:hover{ background:var(--surface-alt); }
.btn-ghost{ background:transparent; color:var(--text-muted); }
.btn-ghost:hover{ background:var(--surface-alt); color:var(--text); }
.btn-danger{ background:var(--danger); color:#fff; }
.btn-danger:hover{ background:#CC3A3F; }
.btn-sm{ padding:6px 12px; font-size:12.5px; }
.btn-block{ width:100%; }
.btn:disabled{ opacity:.55; cursor:not-allowed; }

/* ---------- Cards / Stats ---------- */
.card{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--radius-md);
  padding:20px;
}
.stat-grid{ display:grid; grid-template-columns:repeat(4,1fr); gap:16px; margin-bottom:20px; }
.stat-card{
  background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-md);
  padding:18px; display:flex; align-items:center; gap:14px;
}
.stat-icon{
  width:44px; height:44px; border-radius:var(--radius-md);
  display:flex; align-items:center; justify-content:center; flex-shrink:0;
}
.stat-icon.blue{ background:var(--primary-light); color:var(--primary); }
.stat-icon.green{ background:var(--success-bg); color:var(--success); }
.stat-icon.orange{ background:var(--warning-bg); color:var(--warning); }
.stat-icon.purple{ background:var(--purple-bg); color:var(--purple); }
.stat-value{ font-size:22px; font-weight:700; line-height:1.1; }
.stat-label{ font-size:12.5px; color:var(--text-muted); margin-top:2px; }

.grid-2{ display:grid; grid-template-columns:1.6fr 1fr; gap:16px; }
.grid-3{ display:grid; grid-template-columns:repeat(3,1fr); gap:16px; }

.card-head{ display:flex; align-items:center; justify-content:space-between; margin-bottom:16px; }
.card-title{ font-size:14.5px; font-weight:700; margin:0; }
.card-link{ font-size:12.5px; color:var(--primary); font-weight:600; }

/* ---------- Badges ---------- */
.badge{
  display:inline-flex; align-items:center; gap:5px;
  padding:3px 10px; border-radius:99px;
  font-size:11.5px; font-weight:600;
}
.badge-success{ background:var(--success-bg); color:var(--success); }
.badge-warning{ background:var(--warning-bg); color:var(--warning); }
.badge-danger{ background:var(--danger-bg); color:var(--danger); }
.badge-info{ background:var(--info-bg); color:var(--info); }
.badge-purple{ background:var(--purple-bg); color:var(--purple); }
.badge-neutral{ background:var(--surface-alt); color:var(--text-muted); border:1px solid var(--border); }

/* ---------- Tables ---------- */
.table-wrap{ overflow-x:auto; }
table.data-table{ width:100%; border-collapse:collapse; font-size:13.5px; }
.data-table th{
  text-align:left; padding:11px 14px; color:var(--text-muted);
  font-weight:600; font-size:12px; border-bottom:1px solid var(--border);
  white-space:nowrap;
}
.data-table td{ padding:13px 14px; border-bottom:1px solid var(--border); vertical-align:middle; }
.data-table tr:last-child td{ border-bottom:none; }
.data-table tr:hover td{ background:var(--surface-alt); }
.row-title{ font-weight:600; }
.row-sub{ font-size:12px; color:var(--text-muted); }

/* ---------- Forms ---------- */
.form-group{ margin-bottom:16px; }
.form-label{ display:block; font-size:13px; font-weight:600; margin-bottom:6px; }
.form-hint{ font-size:12px; color:var(--text-muted); margin-top:5px; }
.form-control{
  width:100%; padding:10px 12px; border:1px solid var(--border-strong);
  border-radius:var(--radius-sm); background:var(--surface); color:var(--text);
  font-size:13.5px; font-family:inherit; outline:none;
  transition:border-color .15s ease, box-shadow .15s ease;
}
.form-control:focus{ border-color:var(--primary); box-shadow:0 0 0 3px var(--primary-light); }
textarea.form-control{ resize:vertical; min-height:90px; }
.form-row{ display:grid; grid-template-columns:1fr 1fr; gap:16px; }
.required-mark{ color:var(--danger); }

/* ---------- Tabs ---------- */
.tabs{ display:flex; gap:4px; border-bottom:1px solid var(--border); margin-bottom:22px; overflow-x:auto; }
.tab-link{
  padding:11px 16px; font-size:13.5px; font-weight:600; color:var(--text-muted);
  border-bottom:2px solid transparent; white-space:nowrap;
}
.tab-link:hover{ color:var(--text); }
.tab-link.active{ color:var(--primary); border-color:var(--primary); }

/* ---------- Progress ---------- */
.progress{ height:7px; border-radius:99px; background:var(--surface-alt); border:1px solid var(--border); overflow:hidden; }
.progress-bar{ height:100%; background:var(--primary); border-radius:99px; transition:width .3s ease; }
.progress-bar.success{ background:var(--success); }
.progress-bar.warning{ background:var(--warning); }

/* ---------- Empty state ---------- */
.empty-state{ text-align:center; padding:50px 20px; color:var(--text-muted); }
.empty-state .icon{ width:40px; height:40px; margin:0 auto 14px; color:var(--text-faint); }
.empty-state h4{ margin:0 0 6px; color:var(--text); font-size:15px; }

/* ---------- Toasts ---------- */
.toast-container{ position:fixed; top:20px; right:20px; z-index:100; display:flex; flex-direction:column; gap:10px; }
.toast{
  min-width:280px; max-width:360px; background:var(--surface); border:1px solid var(--border);
  border-left:4px solid var(--primary); border-radius:var(--radius-sm); box-shadow:var(--shadow-md);
  padding:13px 16px; font-size:13px; display:flex; gap:10px; align-items:flex-start;
  animation:toast-in .2s ease;
}
.toast.success{ border-left-color:var(--success); }
.toast.error{ border-left-color:var(--danger); }
@keyframes toast-in{ from{ opacity:0; transform:translateX(12px);} to{ opacity:1; transform:translateX(0);} }

/* ---------- Modal ---------- */
.modal-overlay{
  position:fixed; inset:0; background:rgba(10,12,25,.5); z-index:90;
  display:flex; align-items:center; justify-content:center; padding:20px;
}
.modal{ background:var(--surface); border-radius:var(--radius-lg); width:100%; max-width:480px; box-shadow:var(--shadow-md); }
.modal-head{ padding:18px 22px; border-bottom:1px solid var(--border); display:flex; justify-content:space-between; align-items:center; }
.modal-body{ padding:22px; }
.modal-foot{ padding:16px 22px; border-top:1px solid var(--border); display:flex; justify-content:flex-end; gap:10px; }

/* ---------- Auth screens ---------- */
.auth-wrap{
  min-height:100vh; display:flex; align-items:center; justify-content:center;
  background:var(--bg); padding:20px;
}
.auth-card{ width:100%; max-width:380px; background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-lg); padding:34px; }
.auth-logo{ display:flex; align-items:center; gap:10px; margin-bottom:26px; font-weight:700; font-size:17px; }
.auth-logo .brand-mark{ width:32px; height:32px; border-radius:9px; background:var(--primary); color:#fff; display:flex; align-items:center; justify-content:center; font-weight:800; }
.auth-title{ font-size:19px; font-weight:700; margin:0 0 4px; }
.auth-sub{ color:var(--text-muted); font-size:13px; margin:0 0 24px; }
.alert{ padding:11px 14px; border-radius:var(--radius-sm); font-size:13px; margin-bottom:18px; }
.alert-danger{ background:var(--danger-bg); color:var(--danger); }
.alert-success{ background:var(--success-bg); color:var(--success); }

/* ---------- Utility ---------- */
.text-muted{ color:var(--text-muted); }
.text-sm{ font-size:12.5px; }
.mt-0{ margin-top:0; } .mb-0{ margin-bottom:0; }
.flex{ display:flex; } .items-center{ align-items:center; } .justify-between{ justify-content:space-between; }
.gap-8{ gap:8px; } .gap-12{ gap:12px; }

/* ---------- Responsive ---------- */
.mobile-toggle{ display:none; }
@media (max-width: 1100px){
  .stat-grid{ grid-template-columns:repeat(2,1fr); }
  .grid-2, .grid-3{ grid-template-columns:1fr; }
}
@media (max-width: 900px){
  .sidebar{ transform:translateX(-100%); }
  .sidebar.open{ transform:translateX(0); }
  .main{ margin-left:0; }
  .mobile-toggle{ display:flex; }
  .topbar-search{ width:180px; }
  .form-row{ grid-template-columns:1fr; }
}
@media (max-width: 560px){
  .stat-grid{ grid-template-columns:1fr; }
  .content{ padding:18px 16px 40px; }
  .topbar{ padding:0 14px; }
  .topbar-search{ display:none; }
}
