/* ============================================================
   HD-PPPCMS Design System
   Help Desk South Sudan — PPP Coordination & Management System
   ============================================================ */

:root {
  /* Brand colors — derived from logo */
  --navy-900: #0F1A5C;
  --navy-800: #1E2A8A;
  --navy-700: #2A3AA8;
  --navy-600: #3A4DC2;
  --navy-50:  #EEF1FB;
  --navy-100: #DDE3F6;

  --cyan-600: #1A9DD0;
  --cyan-500: #2BB7E8;
  --cyan-400: #5BCAEE;
  --cyan-100: #D6F1FB;
  --cyan-50:  #EAF7FD;

  /* Neutrals — warm-cool balanced */
  --ink-900: #0E1422;
  --ink-800: #1B2238;
  --ink-700: #2E3654;
  --ink-600: #4A5275;
  --ink-500: #6B7396;
  --ink-400: #9097B5;
  --ink-300: #BEC3D6;
  --ink-200: #DDE0EC;
  --ink-100: #ECEEF5;
  --ink-50:  #F5F6FA;
  --ink-25:  #FAFBFD;
  --white:   #FFFFFF;

  /* Semantic */
  --success-600: #157F4D;
  --success-500: #1FA862;
  --success-100: #D5F0E1;
  --success-50:  #EAF8F0;

  --warn-600:    #B5740C;
  --warn-500:    #E1930F;
  --warn-100:    #FBEACB;
  --warn-50:     #FDF5E6;

  --danger-600:  #B33232;
  --danger-500:  #DC4B4B;
  --danger-100:  #F8D6D6;
  --danger-50:   #FCEAEA;

  /* Fonts */
  --font-display: "Century Gothic", "Avenir Next", "Futura", "Segoe UI", sans-serif;
  --font-body:    "Segoe UI", "Helvetica Neue", "Arial", sans-serif;
  --font-mono:    "Consolas", "Menlo", "Monaco", monospace;

  /* Radii */
  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 10px;
  --r-xl: 14px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(15, 26, 92, 0.06);
  --shadow-md: 0 2px 6px rgba(15, 26, 92, 0.08), 0 1px 2px rgba(15, 26, 92, 0.04);
  --shadow-lg: 0 8px 24px rgba(15, 26, 92, 0.10), 0 2px 6px rgba(15, 26, 92, 0.06);
  --shadow-xl: 0 24px 60px rgba(15, 26, 92, 0.20);

  /* Layout */
  --sidebar-w: 248px;
  --sidebar-w-collapsed: 64px;
  --header-h: 60px;
}

* { box-sizing: border-box; }

html, body, #root {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-800);
  background: var(--ink-50);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  margin: 0;
  color: var(--ink-900);
  letter-spacing: -0.01em;
}

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }
a { color: var(--navy-700); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================================================
   App Shell
   ============================================================ */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--header-h) 1fr;
  height: 100vh;
  background: var(--ink-50);
}

.app.collapsed { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }
.app.no-chrome { grid-template-columns: 1fr; grid-template-rows: 1fr; }

/* Sidebar */
.sidebar {
  grid-row: 1 / 3;
  background: var(--navy-900);
  color: var(--white);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--navy-800);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  height: var(--header-h);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.sidebar-brand img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  background: white;
  border-radius: 6px;
  padding: 2px;
  flex-shrink: 0;
}

.sidebar-brand .brand-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  line-height: 1.15;
  letter-spacing: 0.02em;
}
.sidebar-brand .brand-text .sub {
  font-weight: 400;
  font-size: 10px;
  color: var(--cyan-400);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar-nav {
  padding: 12px 8px;
  overflow-y: auto;
  flex: 1;
}
.sidebar-nav .nav-section {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.45);
  padding: 14px 12px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: var(--r-md);
  color: rgba(255,255,255,0.78);
  font-size: 13.5px;
  cursor: pointer;
  margin-bottom: 1px;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
  border: 0;
  background: transparent;
  width: 100%;
  text-align: left;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: white; text-decoration: none; }
.nav-item.active { background: var(--navy-700); color: white; }
.nav-item.active .nav-icon { color: var(--cyan-400); }
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; color: rgba(255,255,255,0.55); }
.nav-item .badge {
  margin-left: auto;
  background: var(--cyan-500);
  color: var(--navy-900);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
}

.sidebar-foot {
  padding: 10px 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 11px;
  color: rgba(255,255,255,0.45);
  flex-shrink: 0;
}

.collapsed .sidebar-brand .brand-text,
.collapsed .nav-item span,
.collapsed .nav-item .badge,
.collapsed .nav-section,
.collapsed .sidebar-foot { display: none; }
.collapsed .nav-item { justify-content: center; padding: 9px 0; }

/* Top header */
.topbar {
  grid-column: 2;
  grid-row: 1;
  background: white;
  border-bottom: 1px solid var(--ink-200);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
}
.topbar .crumbs {
  font-size: 13px;
  color: var(--ink-500);
  display: flex;
  align-items: center;
  gap: 6px;
}
.topbar .crumbs strong { color: var(--ink-900); font-weight: 600; }
.topbar .crumb-sep { color: var(--ink-300); }

.topbar .search {
  flex: 1;
  max-width: 420px;
  margin: 0 auto 0 24px;
  position: relative;
}
.topbar .search input {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 36px;
  border: 1px solid var(--ink-200);
  border-radius: var(--r-md);
  background: var(--ink-25);
  font-size: 13px;
  outline: none;
}
.topbar .search input:focus { border-color: var(--navy-600); background: white; box-shadow: 0 0 0 3px var(--navy-50); }
.topbar .search .search-icon {
  position: absolute; left: 11px; top: 9px;
  width: 16px; height: 16px; color: var(--ink-400);
}

.topbar-actions {
  display: flex; align-items: center; gap: 6px;
  margin-left: auto;
}
.icon-btn {
  width: 36px; height: 36px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--r-md);
  color: var(--ink-600);
  display: inline-flex; align-items: center; justify-content: center;
  position: relative;
}
.icon-btn:hover { background: var(--ink-100); color: var(--ink-900); }
.icon-btn .dot {
  position: absolute; top: 8px; right: 9px;
  width: 8px; height: 8px;
  background: var(--danger-500);
  border-radius: 50%;
  border: 2px solid white;
}

.user-pill {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  border: 1px solid var(--ink-200);
  cursor: pointer;
  background: white;
}
.user-pill:hover { background: var(--ink-50); }
.avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--navy-700), var(--cyan-500));
  color: white;
  font-weight: 700;
  font-size: 11px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.avatar.lg { width: 40px; height: 40px; font-size: 14px; }
.avatar.xl { width: 56px; height: 56px; font-size: 18px; }

.user-pill .user-meta { font-size: 12px; line-height: 1.2; }
.user-pill .user-meta strong { color: var(--ink-900); font-weight: 600; }
.user-pill .user-meta span { color: var(--ink-500); }

/* Main content */
.main {
  grid-column: 2;
  grid-row: 2;
  overflow-y: auto;
  background: var(--ink-50);
}

.page {
  padding: 24px 32px 60px;
  max-width: 1440px;
  margin: 0 auto;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--ink-200);
}
.page-header h1 {
  font-size: 24px;
  letter-spacing: -0.015em;
}
.page-header .subtitle {
  color: var(--ink-500);
  font-size: 13.5px;
  margin-top: 4px;
}
.page-header-actions { display: flex; gap: 8px; align-items: center; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.12s, box-shadow 0.12s, transform 0.06s, color 0.12s, border-color 0.12s;
  white-space: nowrap;
  font-family: var(--font-body);
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn .ico { width: 15px; height: 15px; }

.btn-primary {
  background: var(--navy-800);
  color: white;
}
.btn-primary:hover { background: var(--navy-900); text-decoration: none; }

.btn-accent {
  background: var(--cyan-500);
  color: var(--navy-900);
}
.btn-accent:hover { background: var(--cyan-600); color: white; }

.btn-secondary {
  background: white;
  color: var(--ink-800);
  border-color: var(--ink-200);
}
.btn-secondary:hover { border-color: var(--navy-600); color: var(--navy-800); text-decoration: none; }

.btn-ghost {
  background: transparent;
  color: var(--ink-700);
}
.btn-ghost:hover { background: var(--ink-100); text-decoration: none; }

.btn-danger {
  background: white;
  color: var(--danger-600);
  border-color: var(--danger-100);
}
.btn-danger:hover { background: var(--danger-50); }

.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 14px; }

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: white;
  border: 1px solid var(--ink-200);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--ink-100);
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.card-header h3 {
  font-size: 15px;
  font-weight: 700;
  font-family: var(--font-display);
}
.card-header .card-sub { font-size: 12px; color: var(--ink-500); margin-top: 2px; }
.card-body { padding: 20px; }
.card-footer { padding: 12px 20px; border-top: 1px solid var(--ink-100); background: var(--ink-25); border-radius: 0 0 var(--r-lg) var(--r-lg); }

/* ============================================================
   KPIs / Stat tiles
   ============================================================ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat {
  background: white;
  border: 1px solid var(--ink-200);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.stat .stat-label {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-500);
  display: flex; align-items: center; gap: 8px;
}
.stat .stat-value {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 700;
  color: var(--ink-900);
  margin-top: 6px;
  letter-spacing: -0.02em;
  line-height: 1.05;
}
.stat .stat-delta {
  font-size: 12px;
  margin-top: 6px;
  display: inline-flex; align-items: center; gap: 4px;
}
.stat .stat-delta.up { color: var(--success-600); }
.stat .stat-delta.down { color: var(--danger-600); }
.stat .stat-delta .muted { color: var(--ink-500); margin-left: 4px; }
.stat .stat-icon {
  position: absolute;
  top: 16px; right: 16px;
  width: 32px; height: 32px;
  border-radius: var(--r-md);
  background: var(--navy-50);
  color: var(--navy-700);
  display: inline-flex; align-items: center; justify-content: center;
}

/* ============================================================
   Tables
   ============================================================ */
.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-500);
  padding: 10px 16px;
  background: var(--ink-25);
  border-bottom: 1px solid var(--ink-200);
  white-space: nowrap;
}
table.data td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--ink-100);
  color: var(--ink-800);
  vertical-align: middle;
}
table.data tr:hover td { background: var(--navy-50); }
table.data tr:last-child td { border-bottom: 0; }
table.data .tcell-id { font-family: var(--font-mono); font-size: 12px; color: var(--ink-600); }
table.data .tcell-strong { color: var(--ink-900); font-weight: 600; }

/* ============================================================
   Badges & status pills
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
  line-height: 1.4;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; }

.badge-navy   { background: var(--navy-50);    color: var(--navy-800);  border-color: var(--navy-100); }
.badge-cyan   { background: var(--cyan-50);    color: var(--cyan-600);  border-color: var(--cyan-100); }
.badge-green  { background: var(--success-50); color: var(--success-600); border-color: var(--success-100); }
.badge-amber  { background: var(--warn-50);    color: var(--warn-600);  border-color: var(--warn-100); }
.badge-red    { background: var(--danger-50);  color: var(--danger-600); border-color: var(--danger-100); }
.badge-gray   { background: var(--ink-100);    color: var(--ink-700);   border-color: var(--ink-200); }

.badge-green .dot  { background: var(--success-500); }
.badge-amber .dot  { background: var(--warn-500); }
.badge-red .dot    { background: var(--danger-500); }
.badge-cyan .dot   { background: var(--cyan-500); }
.badge-navy .dot   { background: var(--navy-700); }
.badge-gray .dot   { background: var(--ink-400); }

/* ============================================================
   Forms
   ============================================================ */
.form-group { margin-bottom: 18px; }
.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.form-row.three { grid-template-columns: repeat(3, 1fr); }

label.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-700);
  margin-bottom: 6px;
}
label.field-label .req { color: var(--danger-500); margin-left: 2px; }
.field-help { font-size: 11.5px; color: var(--ink-500); margin-top: 6px; }

.input, .select, .textarea {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--ink-200);
  border-radius: var(--r-md);
  background: white;
  font-size: 13.5px;
  color: var(--ink-900);
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.textarea { padding: 10px 12px; height: auto; min-height: 96px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--navy-600);
  box-shadow: 0 0 0 3px var(--navy-50);
}
.input::placeholder, .textarea::placeholder { color: var(--ink-400); }
.input:disabled, .select:disabled { background: var(--ink-50); color: var(--ink-500); }

.input-group {
  display: flex;
  align-items: center;
  border: 1px solid var(--ink-200);
  border-radius: var(--r-md);
  background: white;
  overflow: hidden;
}
.input-group:focus-within { border-color: var(--navy-600); box-shadow: 0 0 0 3px var(--navy-50); }
.input-group .input { border: 0; box-shadow: none; }
.input-group .addon {
  padding: 0 10px;
  color: var(--ink-500);
  font-size: 12.5px;
  background: var(--ink-50);
  border-right: 1px solid var(--ink-200);
  height: 100%;
  display: inline-flex; align-items: center;
}

.checkbox, .radio {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-800);
  cursor: pointer;
  user-select: none;
}
.checkbox input, .radio input { width: 16px; height: 16px; accent-color: var(--navy-700); }

/* File drop */
.dropzone {
  border: 1.5px dashed var(--ink-300);
  border-radius: var(--r-md);
  padding: 22px;
  text-align: center;
  background: var(--ink-25);
  color: var(--ink-600);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.dropzone:hover { border-color: var(--navy-600); background: var(--navy-50); color: var(--navy-800); }
.dropzone .dz-icon {
  width: 32px; height: 32px; color: var(--navy-700); margin: 0 auto 6px;
}
.dropzone strong { color: var(--ink-900); }

/* File item */
.file-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--ink-200);
  border-radius: var(--r-md);
  background: white;
  font-size: 13px;
}
.file-item .file-icon {
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  background: var(--navy-50);
  color: var(--navy-700);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.file-item .file-meta { flex: 1; min-width: 0; }
.file-item .file-meta strong { display: block; color: var(--ink-900); font-size: 13px; font-weight: 600; }
.file-item .file-meta span { color: var(--ink-500); font-size: 11.5px; }

/* Stepper */
.stepper {
  display: flex;
  gap: 0;
  align-items: center;
  margin-bottom: 24px;
  background: white;
  border: 1px solid var(--ink-200);
  border-radius: var(--r-lg);
  padding: 8px;
}
.step {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  cursor: pointer;
  font-size: 12.5px;
  color: var(--ink-500);
  background: transparent;
  border: 0;
  text-align: left;
  font-family: inherit;
}
.step:hover { background: var(--ink-50); color: var(--ink-800); }
.step.active { background: var(--navy-50); color: var(--navy-900); }
.step.done { color: var(--ink-700); }
.step .step-num {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--ink-100);
  color: var(--ink-600);
  font-weight: 700;
  font-size: 11px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.step.active .step-num { background: var(--navy-800); color: white; }
.step.done .step-num { background: var(--success-500); color: white; }
.step .step-label { font-weight: 600; }
.step .step-sub { display: block; font-size: 11px; color: var(--ink-500); font-weight: 400; }

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--ink-200);
  margin-bottom: 20px;
}
.tab {
  padding: 10px 14px;
  font-size: 13px;
  color: var(--ink-600);
  font-weight: 600;
  border: 0;
  background: transparent;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  display: inline-flex; align-items: center; gap: 8px;
}
.tab:hover { color: var(--navy-800); }
.tab.active { color: var(--navy-800); border-bottom-color: var(--navy-800); }
.tab .tab-count {
  font-size: 11px;
  background: var(--ink-100);
  color: var(--ink-700);
  padding: 1px 6px;
  border-radius: 999px;
  font-weight: 700;
}
.tab.active .tab-count { background: var(--navy-100); color: var(--navy-800); }

/* Toolbar / filter row */
.toolbar {
  display: flex; align-items: center; gap: 8px; margin-bottom: 16px;
  flex-wrap: wrap;
}
.toolbar .spacer { flex: 1; }

/* Empty state, info banners */
.banner {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  border: 1px solid;
  font-size: 13px;
  align-items: flex-start;
}
.banner .ico { flex-shrink: 0; width: 18px; height: 18px; margin-top: 1px; }
.banner-info  { background: var(--navy-50);    border-color: var(--navy-100);    color: var(--navy-900); }
.banner-info .ico  { color: var(--navy-700); }
.banner-warn  { background: var(--warn-50);    border-color: var(--warn-100);    color: #6b4602; }
.banner-warn .ico  { color: var(--warn-600); }
.banner-success { background: var(--success-50); border-color: var(--success-100); color: var(--success-600); }
.banner-success .ico { color: var(--success-600); }

/* Avatars list / stack */
.avatars-stack { display: inline-flex; }
.avatars-stack .avatar { border: 2px solid white; margin-left: -8px; }
.avatars-stack .avatar:first-child { margin-left: 0; }

/* Divider */
.hr {
  height: 1px; background: var(--ink-200); border: 0; margin: 16px 0;
}

/* Login & external pages */
.split {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  height: 100vh;
}
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }

/* Generic helpers */
.muted { color: var(--ink-500); }
.tiny { font-size: 11px; }
.mono { font-family: var(--font-mono); }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }

/* Charts (tiny svg) */
.chart-bar {
  height: 8px;
  background: var(--ink-100);
  border-radius: 999px;
  overflow: hidden;
}
.chart-bar > span {
  display: block;
  height: 100%;
  background: var(--navy-700);
  border-radius: inherit;
}

/* Mini sparkline */
.spark { width: 100%; height: 40px; }

/* Two column layout for content pages */
.layout-2col {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  align-items: start;
}
.layout-2col.wide-aside { grid-template-columns: 1fr 380px; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 26, 92, 0.40);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 24px;
  backdrop-filter: blur(2px);
}
.modal {
  background: white;
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 560px;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--ink-200);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--ink-200); display: flex; justify-content: flex-end; gap: 8px; }

/* Scroll style */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--ink-300); border-radius: 10px; border: 2px solid var(--ink-50); }
::-webkit-scrollbar-thumb:hover { background: var(--ink-400); }
::-webkit-scrollbar-track { background: var(--ink-50); }

/* Tweaks panel */
.tweaks-panel {
  position: fixed;
  bottom: 16px; right: 16px;
  width: 280px;
  background: white;
  border: 1px solid var(--ink-200);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xl);
  z-index: 1000;
  font-size: 12px;
  overflow: hidden;
}
.tweaks-panel header {
  background: var(--navy-900);
  color: white;
  padding: 10px 14px;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.04em;
  font-size: 13px;
  display: flex; justify-content: space-between; align-items: center;
}
.tweaks-panel .tw-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.tweaks-panel label.tw-row { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--ink-600); font-weight: 600; }
.tweaks-panel select { height: 30px; padding: 0 8px; border: 1px solid var(--ink-200); border-radius: 4px; }
.tweaks-panel .tw-toggle { display: flex; align-items: center; justify-content: space-between; }

/* ============================================================
   User menu (top-right dropdown) — replaces cycle-role hack
   ============================================================ */
.user-menu { position: relative; }
.user-menu-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 280px;
  background: white;
  border: 1px solid var(--ink-200);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  overflow: hidden;
}
.user-menu-panel[hidden] { display: none; }
.user-menu-panel .umh {
  display: flex; gap: 12px; align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--ink-100);
  background: var(--ink-25);
}
.user-menu-panel .umh-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.user-menu-panel .umh-meta strong { font-size: 13.5px; color: var(--ink-900); }
.user-menu-panel .umh-meta span {
  font-size: 11.5px; color: var(--ink-500);
  text-overflow: ellipsis; overflow: hidden; white-space: nowrap;
}
.user-menu-panel .umh-role { width: fit-content; margin-top: 4px; gap: 4px; }
.user-menu-panel .um-sec {
  padding: 6px;
  border-bottom: 1px solid var(--ink-100);
}
.user-menu-panel .um-sec:last-child { border-bottom: 0; }
.user-menu-panel .um-sec-title {
  font-size: 10px; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--ink-500);
  padding: 6px 10px 4px;
}
.user-menu-panel .um-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--r-sm);
  color: var(--ink-800); font-size: 13px; font-weight: 500;
  text-decoration: none;
}
.user-menu-panel .um-item:hover {
  background: var(--ink-50); color: var(--ink-900); text-decoration: none;
}
.user-menu-panel .um-danger { color: var(--danger-600); }
.user-menu-panel .um-danger:hover { background: var(--danger-50); color: var(--danger-600); }

/* ============================================================
   RTL (Arabic) overrides — keyed off [dir="rtl"] on <html>
   ============================================================ */
[dir="rtl"] { text-align: right; }

/* App shell: put sidebar on the right so logical reading flows RTL */
[dir="rtl"] .app {
  grid-template-columns: 1fr var(--sidebar-w);
}
[dir="rtl"] .app.collapsed {
  grid-template-columns: 1fr var(--sidebar-w-collapsed);
}
[dir="rtl"] .sidebar {
  grid-column: 2;
  border-right: 0;
  border-left: 1px solid var(--navy-800);
}
[dir="rtl"] .topbar,
[dir="rtl"] .main {
  grid-column: 1;
}

/* Nav items: flip icon gap direction */
[dir="rtl"] .nav-item { text-align: right; }
[dir="rtl"] .nav-item .badge { margin-left: 0; margin-right: auto; }

/* Topbar / search */
[dir="rtl"] .topbar .search { margin: 0 24px 0 auto; }
[dir="rtl"] .topbar .search input { padding: 0 36px 0 12px; }
[dir="rtl"] .topbar .search .search-icon { left: auto; right: 11px; }
[dir="rtl"] .topbar-actions { margin-left: 0; margin-right: auto; }

/* Mirror the chevron-right separator in crumbs so arrows point correctly */
[dir="rtl"] .crumbs svg.crumb-sep { transform: scaleX(-1); }

/* User menu panel anchors to the left when RTL */
[dir="rtl"] .user-menu-panel { right: auto; left: 0; }

/* Stat tile icon: was top-right, move to top-left */
[dir="rtl"] .stat .stat-icon { right: auto; left: 16px; }
[dir="rtl"] .stat .stat-delta .muted { margin-left: 0; margin-right: 4px; }

/* Forms */
[dir="rtl"] label.field-label { text-align: right; }
[dir="rtl"] .input-group .addon {
  border-right: 0;
  border-left: 1px solid var(--ink-200);
}

/* Input-icon patterns (search + dropzone rely on absolute left) */
[dir="rtl"] .toolbar input[style*="padding-left:34px"] { padding-left: 12px !important; padding-right: 34px !important; }
[dir="rtl"] .toolbar svg[style*="left:10px"]           { left: auto !important; right: 10px !important; }

/* Tables: left-aligned th/td needs to become right-aligned */
[dir="rtl"] table.data th,
[dir="rtl"] table.data td { text-align: right; }

/* Page-header action cluster stays together on the start side */
[dir="rtl"] .page-header .page-header-actions { margin-left: 0; margin-right: auto; }

/* Chevrons inside buttons ("View all ›") should point the other way */
[dir="rtl"] .btn svg.rtl-flip,
[dir="rtl"] .nav-item svg.rtl-flip { transform: scaleX(-1); }

/* Avatars stack — margin direction */
[dir="rtl"] .avatars-stack .avatar { margin-left: 0; margin-right: -8px; }
[dir="rtl"] .avatars-stack .avatar:first-child { margin-right: 0; }

/* Step numbers and card footers with justify-between already adapt via flex */

/* Language selector (no-chrome pages: login, public grievance).
   Segmented-pill look with solid high-contrast styling so both pills are
   readable regardless of what's behind them. */
.lang-switch {
  position: absolute; top: 20px; right: 32px;
  display: inline-flex; gap: 4px; z-index: 10;
  background: white;
  border: 1px solid var(--ink-200);
  border-radius: 999px;
  padding: 3px;
  box-shadow: var(--shadow-md);
}
[dir="rtl"] .lang-switch { left: 32px; right: auto; }
.lang-switch a {
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-700);
  text-decoration: none;
  line-height: 1.4;
  transition: background 0.12s, color 0.12s;
}
.lang-switch a:hover {
  background: var(--ink-50);
  color: var(--navy-900);
  text-decoration: none;
}
.lang-switch a.active {
  background: var(--navy-800);
  color: white;
}
.lang-switch a.active:hover { background: var(--navy-900); color: white; }

/* Numerals in Arabic: keep LTR-direction numbers readable (don't flip digits) */
[dir="rtl"] .mono,
[dir="rtl"] .tcell-id { direction: ltr; display: inline-block; }
