/* =========================================================
   Elite DS — Design Tokens + Base
   ========================================================= */
:root {
  --navy-950: #061428;
  --navy-900: #0B2A4A;
  --navy-800: #123559;
  --navy-700: #1a4775;
  --teal-500: #17C6C6;
  --teal-600: #10a3a3;
  --teal-50:  #E6FAFA;

  --slate-50:  #F8FAFC;
  --slate-100: #F1F5F9;
  --slate-200: #E2E8F0;
  --slate-300: #CBD5E1;
  --slate-400: #94A3B8;
  --slate-500: #64748B;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1E293B;
  --slate-900: #0F172A;

  --success: #10B981;
  --warning: #F59E0B;
  --danger:  #EF4444;
  --info:    #3B82F6;

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(15,23,42,.06);
  --shadow:    0 4px 16px rgba(15,23,42,.08);
  --shadow-lg: 0 20px 40px rgba(15,23,42,.12);

  --font-sans: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --font-ar:   "Cairo", "Segoe UI", Tahoma, sans-serif;

  --sidebar-w: 248px;
  --topbar-h:  64px;

  --bg: var(--slate-50);
  --surface: #ffffff;
  --text: var(--slate-900);
  --text-muted: var(--slate-500);
  --border: var(--slate-200);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: var(--font-sans); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
html[dir="rtl"] body { font-family: var(--font-ar); }
a { color: var(--navy-900); text-decoration: none; }
a:hover { color: var(--teal-600); }
h1,h2,h3,h4 { color: var(--slate-900); margin: 0 0 8px; font-weight: 700; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
p  { margin: 0 0 8px; color: var(--text-muted); }

/* =========================================================
   Layout shell
   ========================================================= */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
html[dir="rtl"] .shell { grid-template-columns: 1fr var(--sidebar-w); }

.sidebar {
  background: linear-gradient(180deg, var(--navy-950), var(--navy-900));
  color: #cfd8e3;
  padding: 20px 14px;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 20px; }
.sidebar .brand img { height: 34px; }
.sidebar .brand .title { color: #fff; font-weight: 800; font-size: 14px; letter-spacing: 1px; }
.sidebar .brand .title small { display: block; color: var(--teal-500); font-weight: 600; font-size: 10px; letter-spacing: 2px; margin-top: 2px; }

.nav-group { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
.nav-group h4 { color: var(--slate-400); font-size: 10px; text-transform: uppercase; letter-spacing: 2px; font-weight: 700; margin: 14px 10px 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius); color: #cfd8e3; font-weight: 500; cursor: pointer; transition: all .15s ease; }
.nav-item:hover { background: rgba(23,198,198,.1); color: #fff; }
.nav-item.active { background: var(--teal-500); color: var(--navy-950); font-weight: 700; }
.nav-item svg { width: 18px; height: 18px; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  height: var(--topbar-h); padding: 0 24px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.topbar .page-title { font-weight: 700; font-size: 16px; }
.topbar .actions { display: flex; align-items: center; gap: 10px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.content { padding: 24px; display: flex; flex-direction: column; gap: 20px; }

/* =========================================================
   Buttons
   ========================================================= */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  padding: 9px 16px; font-weight: 600; font-size: 14px;
  border: 1px solid transparent; border-radius: var(--radius);
  cursor: pointer; transition: all .15s ease; background: var(--surface);
  color: var(--slate-800); font-family: inherit;
}
.btn:hover { box-shadow: var(--shadow-sm); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--navy-900); color: #fff; border-color: var(--navy-900); }
.btn.primary:hover { background: var(--navy-800); }
.btn.teal { background: var(--teal-500); color: var(--navy-950); border-color: var(--teal-500); }
.btn.teal:hover { background: var(--teal-600); color: #fff; }
.btn.ghost { background: transparent; border-color: var(--border); color: var(--slate-700); }
.btn.ghost:hover { background: var(--slate-100); }
.btn.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.sm { padding: 6px 10px; font-size: 12px; }

/* =========================================================
   Forms
   ========================================================= */
label { display: block; font-size: 12px; color: var(--slate-600); font-weight: 600; margin-bottom: 4px; }
input, select, textarea {
  width: 100%; padding: 9px 12px; border-radius: var(--radius); border: 1px solid var(--border);
  font-family: inherit; font-size: 14px; background: var(--surface); color: var(--slate-900);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--teal-500); box-shadow: 0 0 0 3px rgba(23,198,198,.15);
}
textarea { min-height: 80px; resize: vertical; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }

/* =========================================================
   Cards / Panels
   ========================================================= */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow-sm); }
.card h2 { margin-top: 0; }
.card .card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 10px; flex-wrap: wrap; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow-sm); }
.kpi .label { font-size: 12px; color: var(--slate-500); font-weight: 600; text-transform: uppercase; letter-spacing: 1px; }
.kpi .value { font-size: 28px; font-weight: 800; color: var(--navy-900); }
.kpi .hint { font-size: 12px; color: var(--slate-500); }
.kpi.teal .value { color: var(--teal-600); }
.kpi.warning { border-color: #fbbf24; background: #fffbeb; }
.kpi.warning .value { color: #b45309; }

/* =========================================================
   Tables
   ========================================================= */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 10px 14px; text-align: start; border-bottom: 1px solid var(--border); }
thead th { background: var(--slate-50); color: var(--slate-600); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; position: sticky; top: 0; }
tbody tr:hover { background: var(--slate-50); }
tbody tr:last-child td { border-bottom: none; }
.cell-actions { white-space: nowrap; display: flex; gap: 6px; }

/* =========================================================
   Badges / tags
   ========================================================= */
.badge { display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .3px; }
.badge.success { background: #D1FAE5; color: #065F46; }
.badge.warning { background: #FEF3C7; color: #92400E; }
.badge.danger  { background: #FEE2E2; color: #991B1B; }
.badge.info    { background: #DBEAFE; color: #1E40AF; }
.badge.neutral { background: var(--slate-100); color: var(--slate-700); }
.badge.teal    { background: var(--teal-50); color: var(--teal-600); }

/* =========================================================
   Toast / alert
   ========================================================= */
.toast-host { position: fixed; top: 20px; inset-inline-end: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 9999; }
.toast { padding: 12px 16px; border-radius: var(--radius); background: #fff; box-shadow: var(--shadow-lg); border-inline-start: 4px solid var(--slate-400); min-width: 260px; max-width: 420px; font-size: 13.5px; }
.toast.success { border-color: var(--success); }
.toast.error   { border-color: var(--danger); }
.toast.info    { border-color: var(--info); }
.toast.warning { border-color: var(--warning); }
.toast .t { font-weight: 700; color: var(--slate-800); }
.toast .m { color: var(--slate-600); }

/* =========================================================
   Modal
   ========================================================= */
.modal-host { position: fixed; inset: 0; background: rgba(15,23,42,.55); display: flex; align-items: center; justify-content: center; z-index: 9998; padding: 20px; }
.modal { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); max-width: 640px; width: 100%; max-height: 90vh; overflow: auto; }
.modal .head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal .body { padding: 20px 22px; display: flex; flex-direction: column; gap: 12px; }
.modal .foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* =========================================================
   Utility
   ========================================================= */
.row  { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.col  { display: flex; flex-direction: column; gap: 10px; }
.between { justify-content: space-between; }
.grow { flex: 1; }
.mono { font-family: "JetBrains Mono", Menlo, Consolas, monospace; font-size: 12px; }
.muted { color: var(--text-muted); }
.center { text-align: center; }
.hidden { display: none !important; }
.sep { height: 1px; background: var(--border); margin: 12px 0; }
.empty { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.skeleton { background: linear-gradient(90deg, var(--slate-100) 25%, var(--slate-200) 50%, var(--slate-100) 75%); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: var(--radius); height: 14px; }
@keyframes sk { to { background-position: -200% 0; } }

/* =========================================================
   Login
   ========================================================= */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; background: var(--bg); }
.auth-left { background: linear-gradient(160deg, var(--navy-950), var(--navy-800) 60%, var(--teal-600)); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-left h1 { color: #fff; font-size: 36px; line-height: 1.15; }
.auth-left p  { color: rgba(255,255,255,.78); max-width: 440px; }
.auth-left .logo-lg { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.18); border-radius: var(--radius-lg); padding: 16px; max-width: 280px; backdrop-filter: blur(6px); }
.auth-right { display: flex; align-items: center; justify-content: center; padding: 32px; }
.auth-card  { max-width: 440px; width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 32px; box-shadow: var(--shadow); }
@media (max-width: 900px) { .auth-wrap { grid-template-columns: 1fr; } .auth-left { display: none; } }

/* =========================================================
   RTL fine-tunes
   ========================================================= */
html[dir="rtl"] .sidebar { border-inline-end: 1px solid var(--navy-800); }
html[dir="rtl"] th, html[dir="rtl"] td { text-align: start; }
