@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=DM+Sans:wght@400;500;600&family=Noto+Sans+Arabic:wght@400;500;600;700;800&display=swap');

/* ============================================================
   RESET
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
  /* Brand */
  --primary:        #4f46e5;
  --primary-light:  #818cf8;
  --primary-dark:   #3730a3;
  --primary-bg:     #eef2ff;
  --primary-glow:   rgba(79, 70, 229, 0.18);

  /* Semantic */
  --success:        #10b981;
  --success-bg:     #ecfdf5;
  --success-dark:   #065f46;

  --warning:        #f59e0b;
  --warning-bg:     #fffbeb;
  --warning-dark:   #92400e;

  --danger:         #ef4444;
  --danger-bg:      #fef2f2;
  --danger-dark:    #991b1b;

  --info:           #0ea5e9;
  --info-bg:        #f0f9ff;
  --info-dark:      #075985;

  /* Surfaces */
  --bg:             #f5f6fa;
  --bg-2:           #eef0f7;
  --surface:        #ffffff;
  --surface-2:      #fafbff;
  --surface-glass:  rgba(255, 255, 255, 0.80);

  /* Borders */
  --border:         #e5e7f0;
  --border-focus:   var(--primary);

  /* Text */
  --text:           #111827;
  --text-2:         #4b5563;
  --text-3:         #9ca3af;
  --text-inv:       #ffffff;

  /* Layout */
  --sidebar-w:      260px;
  --topbar-h:       66px;

  /* Shape */
  --radius-xl:      22px;
  --radius:         16px;
  --radius-md:      12px;
  --radius-sm:      8px;
  --radius-xs:      6px;

  /* Elevation */
  --shadow-xs:  0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-sm:  0 4px 16px rgba(16, 24, 40, 0.07);
  --shadow-md:  0 10px 32px rgba(16, 24, 40, 0.10);
  --shadow-lg:  0 24px 56px rgba(16, 24, 40, 0.13);
  --shadow-primary: 0 8px 24px rgba(79, 70, 229, 0.22);

  /* Motion */
  --ease:       cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out:   cubic-bezier(0, 0, 0.2, 1);
  --ease-spring:cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-fast:   140ms;
  --dur:        220ms;
  --dur-slow:   360ms;

  /* Typography */
  --font:       'Plus Jakarta Sans', sans-serif;
  --font-body:  'DM Sans', sans-serif;
}

/* ============================================================
   BASE
   ============================================================ */
html, body {
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6,
.card-title, .page-title, .kpi-value {
  font-family: var(--font);
}

a {
  color: inherit;
  text-decoration: none;
}

/* ============================================================
   APP LAYOUT
   ============================================================ */
.app-layout,
.app-shell {
  display: flex;
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.page-wrapper,
.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.page-content {
  padding: 30px 32px;
  flex: 1;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 220;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  padding: 0 10px 20px;
  scrollbar-width: none;
}

.sidebar::-webkit-scrollbar { display: none; }

/* Brand */
.sidebar-brand,
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 12px 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}

.sidebar-brand h2,
.sidebar-logo span,
.sidebar-logo strong {
  font-family: var(--font);
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.01em;
}

.logo-icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: var(--shadow-primary);
}

/* Nav */
.sidebar-nav {
  padding: 6px 2px 14px;
  flex: 1;
}

.nav-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 14px 10px 5px;
  font-family: var(--font);
}

.sidebar-nav a,
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 600;
  transition:
    background var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease-spring);
  margin-bottom: 2px;
  position: relative;
}

.sidebar-nav a i,
.nav-item i {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-nav a:hover,
.nav-item:hover {
  background: var(--primary-bg);
  color: var(--primary);
  transform: translateX(2px);
}

.sidebar-nav a.active,
.nav-item.active {
  background: linear-gradient(135deg, var(--primary-bg) 0%, #e0e7ff 100%);
  color: var(--primary);
  font-weight: 700;
}

.sidebar-nav a.active::before,
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 999px;
  background: var(--primary);
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  min-height: var(--topbar-h);
  background: var(--surface-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 120;
  gap: 12px;
}

.page-title {
  font-family: var(--font);
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-left: auto;
    flex-shrink: 0;
}

.topbar-right a {
  color: var(--primary);
  font-weight: 600;
  transition: opacity var(--dur-fast);
}

.topbar-right a:hover { opacity: 0.75; }

.sidebar-toggle,
#menuToggle {
  display: none;
  border: none;
  background: var(--bg-2);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  align-items: center;
  justify-content: center;
  transition: background var(--dur-fast);
  flex-shrink: 0;
}

.sidebar-toggle:hover,
#menuToggle:hover {
  background: var(--primary-bg);
  color: var(--primary);
}

/* ============================================================
   KPI CARDS
   ============================================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: transform var(--dur) var(--ease-spring), box-shadow var(--dur) var(--ease);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  border-radius: var(--radius) var(--radius) 0 0;
}

.kpi-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.kpi-card:nth-child(2)::before { background: linear-gradient(90deg, var(--success), #34d399); }
.kpi-card:nth-child(3)::before { background: linear-gradient(90deg, var(--warning), #fcd34d); }
.kpi-card:nth-child(4)::before { background: linear-gradient(90deg, var(--info), #38bdf8); }

.kpi-label {
  font-size: 11.5px;
  color: var(--text-3);
  margin-bottom: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-family: var(--font);
}

.kpi-value {
  font-size: 30px;
  line-height: 1;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}

.kpi-sub {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 8px;
  font-weight: 500;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--dur) var(--ease);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn,
button,
input[type="submit"] {
  font-family: var(--font);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 18px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform var(--dur-fast) var(--ease-spring),
    box-shadow var(--dur-fast) var(--ease),
    background var(--dur-fast) var(--ease),
    opacity var(--dur-fast);
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.btn:hover {
  transform: translateY(-2px);
}

.btn:active {
  transform: translateY(0) scale(0.98);
}

.btn:focus-visible {
  outline: 3px solid var(--primary-bg);
  outline-offset: 2px;
}

/* Variants */
.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #fff;
  box-shadow: var(--shadow-primary);
}

.btn-primary:hover {
  box-shadow: 0 12px 28px rgba(79, 70, 229, 0.32);
}

.btn-success {
  background: linear-gradient(135deg, var(--success) 0%, #34d399 100%);
  color: #fff;
  box-shadow: 0 6px 18px rgba(16, 185, 129, 0.22);
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger) 0%, #f87171 100%);
  color: #fff;
  box-shadow: 0 6px 18px rgba(239, 68, 68, 0.22);
}

.btn-warning {
  background: linear-gradient(135deg, var(--warning) 0%, #fcd34d 100%);
  color: #fff;
  box-shadow: 0 6px 18px rgba(245, 158, 11, 0.22);
}

.btn-whatsapp {
  background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
  color: #fff;
  box-shadow: 0 6px 18px rgba(37, 211, 102, 0.22);
}

.btn-outline {
  background: var(--surface);
  color: var(--text-2);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-xs);
}

.btn-outline:hover {
  background: var(--bg);
  border-color: var(--primary);
  color: var(--primary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border: none;
}

.btn-ghost:hover {
  background: var(--primary-bg);
  color: var(--primary);
}

/* Sizes */
.btn-sm {
  min-height: 32px;
  padding: 0 12px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.btn-lg {
  min-height: 48px;
  padding: 0 24px;
  font-size: 14.5px;
  border-radius: var(--radius-md);
}

/* ============================================================
   FORMS
   ============================================================ */


label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 7px;
  font-family: var(--font);
}

input,
select,
textarea {
  width: 100%;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 14px;
  padding: 11px 14px;
  outline: none;
  transition:
    border-color var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease),
    background var(--dur-fast);
  appearance: none;
  -webkit-appearance: none;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-3);
}

input:hover,
select:hover,
textarea:hover {
  border-color: #c7d0e8;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.10);
  background: #fafbff;
}

textarea {
  resize: vertical;
  min-height: 110px;
  line-height: 1.6;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 24px;
  flex-wrap: wrap;
}

.form-hint {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 5px;
}

.form-error {
  font-size: 12px;
  color: var(--danger);
  margin-top: 5px;
  font-weight: 600;
}

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  background: var(--surface);
}

thead th {
  text-align: left;
  padding: 13px 16px;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

tbody td {
  padding: 14px 16px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  transition: background var(--dur-fast);
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover td {
  background: var(--primary-bg);
}

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 22px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge-success {
  background: var(--success-bg);
  color: var(--success-dark);
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning-dark);
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--danger-dark);
}

.badge-primary {
  background: var(--primary-bg);
  color: var(--primary-dark);
}

.badge-info {
  background: var(--info-bg);
  color: var(--info-dark);
}

.badge-gray {
  background: #f3f4f6;
  color: var(--text-2);
}

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 16px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 18px;
  border-left: 3px solid transparent;
}

.alert-success {
  background: var(--success-bg);
  color: var(--success-dark);
  border-left-color: var(--success);
}

.alert-error {
  background: var(--danger-bg);
  color: var(--danger-dark);
  border-left-color: var(--danger);
}

.alert-warning {
  background: var(--warning-bg);
  color: var(--warning-dark);
  border-left-color: var(--warning);
}

.alert-info {
  background: var(--info-bg);
  color: var(--info-dark);
  border-left-color: var(--info);
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 40px 20px;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(79, 70, 229, 0.10) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(129, 140, 248, 0.12) 0%, transparent 50%),
    linear-gradient(160deg, #f0f2ff 0%, #f5f6fa 50%, #eef0f7 100%);
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1.5px solid rgba(255,255,255,0.85);
  border-radius: var(--radius-xl);
  padding: 44px 38px 36px;
  box-shadow:
    0 2px 4px rgba(79,70,229,0.04),
    0 12px 40px rgba(79,70,229,0.10),
    0 40px 80px rgba(16,24,40,0.10);
  animation: loginFadeUp 0.5s var(--ease-out) both;
}

@keyframes loginFadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.login-intro {
  margin-bottom: 28px;
}

.login-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--primary-bg);
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 18px;
  font-family: var(--font);
  letter-spacing: 0.02em;
}

.login-card h1 {
  font-size: 28px;
  line-height: 1.15;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: -0.03em;
}

.login-card p {
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.6;
}

.login-card .form-group {
  margin-bottom: 16px;
}

.login-card input {
  height: 48px;
  padding: 0 16px;
  font-size: 14.5px;
}

.login-card button[type="submit"] {
  width: 100%;
  height: 50px;
  margin-top: 10px;
  border: none;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #fff;
  font-family: var(--font);
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: var(--shadow-primary);
  transition:
    transform var(--dur-fast) var(--ease-spring),
    box-shadow var(--dur-fast) var(--ease);
}

.login-card button[type="submit"]:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 32px rgba(8, 123, 134, 0.30);
}

.login-card button[type="submit"]:active {
  transform: translateY(0) scale(0.98);
}

/* ============================================================
   UTILITY COMPONENTS
   ============================================================ */

/* Divider */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

/* Section header */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.section-title {
  font-family: var(--font);
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-3);
}

.empty-state .icon {
  font-size: 44px;
  margin-bottom: 14px;
  opacity: 0.6;
}

.empty-state .title {
  font-family: var(--font);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-2);
  margin-bottom: 6px;
}

.empty-state .sub {
  font-size: 13.5px;
  color: var(--text-3);
  line-height: 1.6;
}

/* Spinner */
.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(79, 70, 229, 0.20);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Avatar */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--primary-bg);
  color: var(--primary);
  font-family: var(--font);
  font-weight: 700;
  flex-shrink: 0;
}

.avatar-sm { width: 30px; height: 30px; font-size: 11px; }
.avatar-md { width: 38px; height: 38px; font-size: 14px; }
.avatar-lg { width: 48px; height: 48px; font-size: 18px; }

/* Tag/chip */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--bg-2);
  color: var(--text-2);
  border: 1px solid var(--border);
  font-family: var(--font);
}

/* Footer */
.footer {
  padding: 14px 32px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-3);
  background: transparent;
  font-weight: 500;
}

/* ============================================================
   MOBILE OVERLAY
   ============================================================ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 190;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: fadeIn var(--dur) var(--ease) both;
}

.sidebar-overlay.open {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* Tablet */
@media (max-width: 1024px) {
  :root {
    --sidebar-w: 240px;
  }

  .page-content {
    padding: 24px;
  }
}

/* Small tablet */
@media (max-width: 900px) {
  .form-row {
    grid-template-columns: 1fr;
  }

  .form-row-3 {
    grid-template-columns: 1fr 1fr;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
  }
}

/* Mobile */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform var(--dur-slow) var(--ease-out),
                box-shadow var(--dur-slow) var(--ease);
    box-shadow: none;
  }

  .sidebar.is-open,
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 12px 0 40px rgba(15, 23, 42, 0.12);
  }

  .page-wrapper,
  .main-content {
    margin-left: 0;
  }

  .page-content {
    padding: 0;
    overflow-x: hidden;
  }

  .topbar {
    padding: 0 16px;
  }

  .sidebar-toggle,
  #menuToggle {
    display: inline-flex;
  }

  .card {
    padding: 18px;
    border-radius: var(--radius-md);
  }

  .card-header {
    margin-bottom: 14px;
  }

  .login-card {
    padding: 32px 24px 28px;
    border-radius: var(--radius);
  }

  .login-card h1 {
    font-size: 24px;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
  }

  table {
    font-size: 13px;
  }

  thead th, tbody td {
    padding: 11px 12px;
  }
}

/* Small mobile */
@media (max-width: 480px) {
  .kpi-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .form-row-3 {
    grid-template-columns: 1fr;
  }

  .form-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .form-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .topbar-right {
    gap: 8px;
    font-size: 12px;
  }

  .page-title {
    font-size: 15px;
  }

  .kpi-value {
    font-size: 26px;
  }

  .login-card {
    padding: 28px 18px 24px;
  }
}

/* Very small */
@media (max-width: 360px) {
  .page-content {
    padding: 14px 12px;
  }

  .btn {
    font-size: 12.5px;
    padding: 0 14px;
  }
}

/* ============================================================
   MOBILE FIXES
   ============================================================ */

/* Sidebar full height fix */
@media (max-width: 768px) {
     html, body {
    overflow-x: hidden;
    max-width: 100%;
  }

  .app-layout,
  .app-shell {
    overflow-x: hidden;
    max-width: 100%;
  }

  .main-content,
  .page-wrapper {
    overflow-x: hidden;
    max-width: 100%;
    width: 100%;
  }

  .page-content {
    padding: 0;
    overflow-x: hidden;
    max-width: 100%;
  }
  .sidebar {
    height: 100dvh; /* dynamic viewport height — fixes mobile browser bars */
  }

  /* Close button inside sidebar */
  .sidebar-close {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 10px 12px 0;
  }

  .sidebar-close button {
    background: var(--bg-2);
    border: none;
    border-radius: var(--radius-sm);
    width: 34px;
    height: 34px;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-2);
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .sidebar-close button:hover {
    background: var(--danger-bg);
    color: var(--danger);
  }
}

/* Hide close button on desktop */
@media (min-width: 769px) {
  .sidebar-close {
    display: none;
  }
}

/* ============================================================
   SIDEBAR — SCROLL & ENHANCEMENTS
   ============================================================ */

.sidebar-nav a,
.sidebar-logout {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-icon {
    font-size: 17px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
    line-height: 1;
}

.sidebar-logout {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    color: var(--danger);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--dur-fast), color var(--dur-fast);
    margin-bottom: 2px;
    text-decoration: none;
}

.sidebar-logout:hover {
    background: var(--danger-bg);
    color: var(--danger-dark);
}

/* Scrollbar visible et stylée */
.sidebar {
    scrollbar-width: thin;
    scrollbar-color: var(--primary-light) var(--bg);
}

.sidebar::-webkit-scrollbar {
    width: 5px;
}

.sidebar::-webkit-scrollbar-track {
    background: var(--bg);
    border-radius: 999px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--primary-light);
    border-radius: 999px;
    transition: background var(--dur-fast);
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* Retire le hint arrow — plus besoin avec scrollbar visible */
.sidebar-scroll-hint {
    display: none;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0;
    justify-content: space-between;
    width: 100%;
}

.topbar-username {
    font-weight: 700;
    color: var(--text);
    font-size: 13px;
}

.topbar-logout {
    font-size: 13px;
    font-weight: 600;
    color: var(--danger) !important;
    padding: 6px 14px;
    border-radius: var(--radius-md);
    border: 1.5px solid var(--danger);
    transition: background var(--dur-fast), color var(--dur-fast);
    white-space: nowrap;
}

.topbar-logout:hover {
    background: var(--danger-bg);
    opacity: 1 !important;
}

@media (max-width: 768px) {
  .topbar-right {
    gap: 8px;
    margin-left: auto;
    flex-shrink: 0;
    width: auto;
  }

  .topbar-logout {
    font-size: 11px;
    padding: 5px 8px;
    white-space: nowrap;
  }

  .topbar-username {
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100px;
  }
}

/* ============================================================
   LANGUAGE SWITCH + ARABIC / RTL
   ============================================================ */
.language-switch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  white-space: nowrap;
  flex-shrink: 0;
}

.language-switch__item {
  font-size: 11.5px;
  font-weight: 800;
  line-height: 1;
  color: var(--text-3);
  padding: 3px 4px;
  border-radius: 999px;
  transition: color var(--dur-fast), background var(--dur-fast);
}

.language-switch__item:hover {
  color: var(--primary);
}

.language-switch__item.active {
  color: var(--primary);
  background: var(--primary-bg);
}

.language-switch__sep {
  color: var(--border);
  font-size: 11px;
}

.login-language-switch {
  width: max-content;
  margin-left: auto;
  margin-bottom: 20px;
}

html[dir="rtl"] body {
  direction: rtl;
  text-align: right;
  font-family: 'Noto Sans Arabic', var(--font-body), sans-serif;
}

html[dir="rtl"] h1,
html[dir="rtl"] h2,
html[dir="rtl"] h3,
html[dir="rtl"] h4,
html[dir="rtl"] h5,
html[dir="rtl"] h6,
html[dir="rtl"] .card-title,
html[dir="rtl"] .page-title,
html[dir="rtl"] .kpi-value,
html[dir="rtl"] .nav-label,
html[dir="rtl"] .sidebar-brand h2,
html[dir="rtl"] .sidebar-logo span,
html[dir="rtl"] .sidebar-logo strong {
  font-family: 'Noto Sans Arabic', var(--font), sans-serif;
}

html[dir="rtl"] .sidebar {
  left: auto;
  right: 0;
  border-right: 0;
  border-left: 1px solid var(--border);
}

html[dir="rtl"] .page-wrapper,
html[dir="rtl"] .main-content {
  margin-left: 0;
  margin-right: var(--sidebar-w);
}

html[dir="rtl"] .sidebar-nav a.active::before,
html[dir="rtl"] .nav-item.active::before {
  left: auto;
  right: 0;
}

html[dir="rtl"] .sidebar-nav a:hover,
html[dir="rtl"] .nav-item:hover {
  transform: translateX(-2px);
}

html[dir="rtl"] .topbar-right {
  margin-left: 0;
  margin-right: auto;
}

html[dir="rtl"] .sidebar-close {
  justify-content: flex-start;
}

html[dir="rtl"] .login-language-switch {
  margin-left: 0;
  margin-right: auto;
}

html[dir="rtl"] input,
html[dir="rtl"] textarea,
html[dir="rtl"] select {
  text-align: right;
}

html[dir="rtl"] input[type="email"],
html[dir="rtl"] input[type="tel"],
html[dir="rtl"] input[type="number"],
html[dir="rtl"] input[type="date"],
html[dir="rtl"] input[type="month"],
html[dir="rtl"] input[type="time"],
html[dir="rtl"] input[type="password"],
html[dir="rtl"] .ltr {
  direction: ltr;
  text-align: left;
}

/* Keep prices and monetary totals readable inside the Arabic RTL interface. */
html[dir="rtl"] .numeric-ltr {
  direction: ltr !important;
  unicode-bidi: isolate;
  text-align: right !important;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

html[dir="rtl"] table {
  direction: rtl;
}

html[dir="rtl"] th,
html[dir="rtl"] td {
  text-align: right;
}

html[dir="rtl"] .alert {
  border-left-width: 1px;
  border-right: 3px solid transparent;
}

html[dir="rtl"] .alert-error {
  border-right-color: var(--danger);
}

html[dir="rtl"] .alert-warning {
  border-right-color: var(--warning);
}

html[dir="rtl"] .alert-info {
  border-right-color: var(--info);
}

@media (max-width: 768px) {
  .language-switch {
    gap: 3px;
    padding: 4px 6px;
  }

  .language-switch__item {
    font-size: 10px;
    padding: 2px 3px;
  }

  html[dir="rtl"] .sidebar {
    transform: translateX(100%);
  }

  html[dir="rtl"] .sidebar.is-open,
  html[dir="rtl"] .sidebar.open {
    transform: translateX(0);
    box-shadow: -12px 0 40px rgba(15, 23, 42, 0.12);
  }

  html[dir="rtl"] .page-wrapper,
  html[dir="rtl"] .main-content {
    margin-right: 0;
  }

  html[dir="rtl"] .topbar-right {
    margin-right: auto;
    margin-left: 0;
  }
}

@media (max-width: 480px) {
  .topbar {
    gap: 6px;
    padding-left: 10px;
    padding-right: 10px;
  }

  .topbar-right {
    gap: 5px;
  }

  .topbar-username {
    max-width: 72px;
  }

  .topbar-logout {
    padding: 5px 6px;
  }
}


/* Module-level RTL polish */
html[dir="rtl"] .attendance-filter-box select,
html[dir="rtl"] .expense-filter-group select,
html[dir="rtl"] .expenses-form-page .card form select {
  background-position: left 14px center;
  padding-left: 42px;
  padding-right: 14px;
}

html[dir="rtl"] .class-children-search-box input {
  background-position: calc(100% - 13px) center;
  padding-right: 38px;
  padding-left: 14px;
}

html[dir="rtl"] .personnel-toolbar {
  margin-left: 0;
  margin-right: auto;
}

/* ============================================================
   DAR AL MAARIFA BRANDING
   ============================================================ */
:root {
  --primary: #087b86;
  --primary-light: #0aa7b6;
  --primary-dark: #065c66;
  --primary-bg: #e9f8f8;
  --primary-glow: rgba(8, 123, 134, 0.18);
  --shadow-primary: 0 8px 24px rgba(8, 123, 134, 0.22);
  --brand-accent: #f7a20b;
}

.dar-brand {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 14px 8px 12px;
  text-align: center;
}

.dar-brand__logo {
  width: 92px;
  height: 92px;
  object-fit: contain;
  display: block;
}

.dar-brand__text {
  display: grid;
  gap: 1px;
  justify-items: center;
}

.dar-brand__text strong {
  color: var(--primary-dark);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0.015em;
}

.dar-brand__text span {
  color: var(--brand-accent);
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.25;
}

.dar-login-page {
  background:
    radial-gradient(ellipse at 18% 20%, rgba(8, 123, 134, 0.12) 0%, transparent 48%),
    radial-gradient(ellipse at 82% 82%, rgba(247, 162, 11, 0.10) 0%, transparent 45%),
    linear-gradient(160deg, #effafa 0%, #f7f9f9 50%, #f4f7f7 100%);
}

.dar-login-card {
  max-width: 470px;
  border-top: 4px solid var(--primary);
}

.login-brand {
  display: grid;
  justify-items: center;
  gap: 2px;
  margin: -4px 0 20px;
  text-align: center;
}

.login-brand__logo {
  width: 142px;
  height: 142px;
  object-fit: contain;
  display: block;
}

.login-brand__name {
  margin-top: 2px;
  font-family: var(--font);
  font-size: 20px;
  font-weight: 800;
  line-height: 1.2;
  color: var(--primary-dark);
}

.login-brand__subtitle {
  color: var(--brand-accent);
  font-size: 12px;
  font-weight: 700;
}

.password-field {
  position: relative;
}

.password-field input {
  width: 100%;
  padding-inline-end: 48px;
}

.password-toggle {
  position: absolute;
  inset-inline-end: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 17px;
}

.password-toggle:hover {
  background: var(--primary-bg);
}

.field-help {
  display: block;
  margin-top: 6px;
  color: var(--text-3);
  font-size: 11.5px;
  line-height: 1.45;
}

html[dir="rtl"] .dar-brand__text strong,
html[dir="rtl"] .login-brand__name {
  font-family: 'Noto Sans Arabic', var(--font), sans-serif;
}

html[dir="rtl"] .dar-brand__text strong {
  font-size: 15px;
}

html[dir="rtl"] .dar-brand__text span,
html[dir="rtl"] .login-brand__subtitle {
  font-family: 'Noto Sans Arabic', var(--font-body), sans-serif;
}

@media (max-width: 640px) {
  .dar-login-card {
    padding: 28px 22px 24px;
  }
  .login-brand__logo {
    width: 118px;
    height: 118px;
  }
}

.topbar-brand-mini {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.topbar-brand-mini img {
  width: 38px;
  height: 38px;
  object-fit: contain;
  flex: 0 0 auto;
}

.topbar-brand-mini span {
  color: var(--primary-dark);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

html[dir="rtl"] .topbar-brand-mini span {
  font-family: 'Noto Sans Arabic', var(--font), sans-serif;
  font-size: 14px;
}

@media (max-width: 760px) {
  .topbar-brand-mini span {
    display: none;
  }
  .topbar-brand-mini img {
    width: 34px;
    height: 34px;
  }
}
