:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --sidebar: #0f172a;
  --sidebar-hover: #1e293b;
  --primary: #0ea5e9;
  --primary-dark: #0284c7;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --ok: #10b981;
  --warn: #f59e0b;
  --err: #ef4444;
  --radius: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
.hidden { display: none !important; }

/* Auth Screen */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%); }
.auth-card { width: 100%; max-width: 430px; background: var(--surface); border-radius: 14px; padding: 28px; box-shadow: 0 20px 50px rgba(0,0,0,.35); }
.auth-brand { text-align: center; margin-bottom: 20px; }
.auth-brand h1 { margin: 0; font-size: 22px; color: #0f172a; letter-spacing: .5px; }
.auth-brand p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: #f1f5f9; padding: 4px; border-radius: 8px; margin-bottom: 18px; }
.auth-tabs button { border: 0; background: transparent; padding: 8px; border-radius: 6px; cursor: pointer; font-weight: 600; color: var(--muted); }
.auth-tabs button.active { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.1); }

/* App Shell */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 245px; background: var(--sidebar); color: #cbd5e1; display: flex; flex-direction: column; flex-shrink: 0; }
.sb-head { padding: 18px 18px 14px; border-bottom: 1px solid #1e293b; }
.sb-head h2 { margin: 0; color: #fff; font-size: 17px; letter-spacing: .4px; }
.sb-head small { color: #38bdf8; font-size: 11px; }
.sb-nav { padding: 12px 10px; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.nav-btn { display: flex; align-items: center; justify-content: space-between; width: 100%; border: 0; background: transparent; color: #cbd5e1; padding: 10px 12px; border-radius: 8px; cursor: pointer; font-size: 13.5px; text-align: left; }
.nav-btn:hover { background: var(--sidebar-hover); color: #fff; }
.nav-btn.active { background: var(--primary-dark); color: #fff; font-weight: 600; }
.nav-badge { background: var(--err); color: #fff; font-size: 11px; padding: 1px 7px; border-radius: 99px; font-weight: 700; }
.sb-foot { padding: 12px 16px; border-top: 1px solid #1e293b; font-size: 11px; color: #64748b; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); padding: 12px 22px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tb-title { font-size: 16px; font-weight: 700; }
.tb-user { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.content { padding: 20px 22px; flex: 1; overflow-x: auto; }

/* Cards & Grid */
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-bottom: 18px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.card-title { margin: 0 0 12px; font-size: 15px; font-weight: 700; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stat-label { font-size: 12px; color: var(--muted); }
.stat-val { font-size: 21px; font-weight: 700; margin-top: 4px; color: var(--text); }
.stat-sub { font-size: 11.5px; color: var(--muted); margin-top: 4px; }

/* Forms & Buttons */
.fg { margin-bottom: 12px; }
.fg label { display: block; font-size: 12px; font-weight: 600; color: #334155; margin-bottom: 4px; }
input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 7px; font: inherit; background: #fff; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(14,165,233,.15); }
.input-valid { border-color: var(--ok) !important; background: #f0fdf4 !important; }
.input-invalid { border-color: var(--err) !important; background: #fef2f2 !important; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar input, .toolbar select { width: auto; min-width: 150px; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 7px; border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; font-size: 13px; }
.btn-primary { background: var(--primary-dark); color: #fff; }
.btn-primary:hover { background: #0369a1; }
.btn-ok { background: var(--ok); color: #fff; }
.btn-warn { background: var(--warn); color: #fff; }
.btn-err { background: var(--err); color: #fff; }
.btn-ghost { background: #fff; border-color: #cbd5e1; color: var(--text); }
.btn-ghost:hover { background: #f8fafc; }
.btn-sm { padding: 5px 9px; font-size: 12px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* Tables & Badges */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { background: #f8fafc; font-weight: 700; color: #334155; white-space: nowrap; }
tr:hover td { background: #f8fafc; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.b-ok { background: #dcfce7; color: #166534; }
.b-warn { background: #fef3c7; color: #92400e; }
.b-err { background: #fee2e2; color: #991b1b; }
.b-info { background: #e0f2fe; color: #075985; }
.b-muted { background: #e2e8f0; color: #475569; }

/* Modal, Loader & Toast */
.overlay { position: fixed; inset: 0; background: rgba(15,23,42,.55); display: grid; place-items: center; z-index: 900; padding: 16px; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; padding: 20px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.loader-box { background: #fff; padding: 22px 28px; border-radius: 12px; text-align: center; min-width: 280px; box-shadow: 0 12px 35px rgba(0,0,0,.25); }
.spinner { width: 34px; height: 34px; border: 4px solid #e2e8f0; border-top-color: var(--primary-dark); border-radius: 50%; margin: 0 auto 12px; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.prog-track { height: 7px; background: #e2e8f0; border-radius: 99px; overflow: hidden; margin-top: 10px; }
.prog-bar { height: 100%; background: var(--primary-dark); width: 0%; transition: width .2s; }
.toast-wrap { position: fixed; right: 18px; bottom: 18px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 10px 14px; border-radius: 8px; color: #fff; font-weight: 600; font-size: 13px; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.t-ok { background: #059669; } .t-err { background: #dc2626; } .t-info { background: #0284c7; }
.pager { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; gap: 10px; flex-wrap: wrap; }
@media (max-width: 820px) { .shell { flex-direction: column; } .sidebar { width: 100%; } .sb-nav { flex-direction: row; flex-wrap: wrap; } }