/* ========== Madinat Masr — design tokens ========== */
:root {
  /* Type */
  --font-display: Sharp, sans-serif;
  --font-sans: Sharp, sans-serif;
  --font-mono: Sharp, sans-serif;
  --font-ar: Sharp, sans-serif;
  --font-ar-display: Sharp, sans-serif;

  /* Brand — Madinat Masr red */
  --red-50: #fdf2f3;
  --red-100: #fce4e7;
  --red-200: #f9c9d0;
  --red-300: #f4a0ab;
  --red-400: #ec6c7e;
  --red-500: #dc2640;
  --red-600: #c8102e;   /* primary */
  --red-700: #a30b25;
  --red-800: #82081e;
  --red-900: #5b0615;

  --accent: var(--red-600);
  --accent-bright: var(--red-500);
  --accent-soft: rgba(200, 16, 46, 0.08);
  --accent-stronger: rgba(200, 16, 46, 0.16);

  /* Surfaces / text — LIGHT */
  --bg: #f5f3f0;
  --bg-deep: #ece9e4;
  --bg-noise: rgba(0,0,0,0.012);
  --surface: #ffffff;
  --surface-2: #faf8f5;
  --surface-glass: rgba(255, 255, 255, 0.55);
  --surface-glass-strong: rgba(255, 255, 255, 0.78);
  --border: rgba(15, 12, 12, 0.08);
  --border-strong: rgba(15, 12, 12, 0.14);
  --text: #14110f;
  --text-2: #4a4541;
  --text-3: #847d76;
  --text-4: #b4ada5;
  --shadow-card: 0 1px 2px rgba(20,17,15,0.04), 0 8px 24px -8px rgba(20,17,15,0.08);
  --shadow-pop: 0 4px 12px rgba(20,17,15,0.08), 0 24px 60px -16px rgba(20,17,15,0.18);

  /* Sidebar (always dark, like a brand chrome) */
  --rail-bg: #120c0d;
  --rail-bg-2: #1c1314;
  --rail-text: #efe7e3;
  --rail-text-dim: #8a7c79;
  --rail-border: rgba(255,255,255,0.06);

  /* Charts data palette (red-led, harmonious) */
  --c1: #c8102e;
  --c2: #e63946;
  --c3: #f08a93;
  --c4: #6b2230;
  --c5: #8b3a4a;
  --c6: #d1735c;
  --c7: #b89b8e;

  /* Status */
  --good: #1a7d5a;
  --warn: #b8782b;
  --bad: #c8102e;
  --info: #2a5f8a;

  /* Radii / motion */
  --r-xs: 6px;
  --r-sm: 10px;
  --r: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-full: 999px;

  --ease: cubic-bezier(.2,.7,.2,1);
  --ease-out: cubic-bezier(.16,.84,.24,1);

  /* Glass intensity (tweakable) */
  --glass-blur: 18px;
  --glass-sat: 1.4;
}

:root[data-theme="dark"] {
  --bg: #0a0608;
  --bg-deep: #060304;
  --surface: #15101280;
  --surface-2: #1c1517;
  --surface-glass: rgba(28, 21, 23, 0.55);
  --surface-glass-strong: rgba(28, 21, 23, 0.78);
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #f4ece9;
  --text-2: #b8aca8;
  --text-3: #7a6e6a;
  --text-4: #4a4341;
  --accent: #e63946;
  --accent-bright: #ff5b6a;
  --accent-soft: rgba(230, 57, 70, 0.10);
  --accent-stronger: rgba(230, 57, 70, 0.20);
  --rail-bg: #060304;
  --rail-bg-2: #0d0708;
  --rail-text: #efe7e3;
  --rail-text-dim: #6e5f5c;
  --rail-border: rgba(255,255,255,0.05);
  --shadow-card: 0 1px 0 rgba(255,255,255,0.04) inset, 0 8px 24px -8px rgba(0,0,0,0.6);
  --shadow-pop: 0 8px 24px rgba(0,0,0,0.5), 0 24px 60px -16px rgba(0,0,0,0.7);
  --c1: #e63946;
  --c2: #ff6b7a;
  --c3: #ffa3ab;
  --c4: #963243;
  --c5: #c25164;
  --c6: #e88a73;
  --c7: #a98f85;
  --bg-noise: rgba(255,255,255,0.02);
}

/* Base */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { background: var(--bg); color: var(--text); }
body {
  font-family: var(--font-sans);
  background:
    radial-gradient(1200px 600px at 80% -10%, var(--accent-soft) 0%, transparent 60%),
    radial-gradient(900px 500px at -10% 100%, var(--accent-soft) 0%, transparent 50%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01", "cv11";
  min-height: 100vh;
}

[lang="ar"], [dir="rtl"] { font-family: var(--font-ar); }
[lang="ar"] .display, [dir="rtl"] .display { font-family: var(--font-ar-display); }

.display { font-family: var(--font-display); font-weight: 400; letter-spacing: -0.01em; }

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: padding-box; border: 2px solid transparent; }

/* Reusable */
.glass {
  background: var(--surface-glass);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
}
.glass-strong {
  background: var(--surface-glass-strong);
  backdrop-filter: blur(calc(var(--glass-blur) * 1.2)) saturate(var(--glass-sat));
  -webkit-backdrop-filter: blur(calc(var(--glass-blur) * 1.2)) saturate(var(--glass-sat));
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-card);
}

.kicker {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
  font-weight: 500;
}
.h-display {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(32px, 4vw, 56px);
  letter-spacing: -0.02em;
  line-height: 1.02;
}
.h-section {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 28px;
  line-height: 1.1;
  letter-spacing: -0.01em;
}
.mono { font-family: var(--font-mono); font-feature-settings: "tnum"; }
.tnum { font-variant-numeric: tabular-nums; }

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }

/* Btn */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 14px;
  border-radius: var(--r-full);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px; font-weight: 500;
  transition: all .2s var(--ease);
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn-primary {
  background: var(--accent);
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 14px -4px var(--accent-stronger), 0 1px 0 rgba(255,255,255,0.12) inset;
}
.btn-primary:hover { background: var(--red-700); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 14px; }

/* Chip */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 10px;
  border-radius: var(--r-full);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.02em;
}
.chip-muted { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }

/* Inputs */
.input {
  height: 38px; padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 13px;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.input::placeholder { color: var(--text-4); }

/* Custom Select Dropdowns - Universal styling for ALL selects */
select,
select.input,
.twk-field,
select[class] {
  appearance: none !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  background-color: var(--surface) !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237a6e6a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 12px center !important;
  background-size: 16px !important;
  padding-right: 40px !important;
  padding-left: 14px;
  border: 1px solid var(--border) !important;
  border-radius: var(--r-sm) !important;
  color: var(--text) !important;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer !important;
  transition: all .15s var(--ease) !important;
  min-height: 38px;
  line-height: 1.4;
}
select:not(.input) {
  height: 38px;
  padding: 0 40px 0 14px;
}
[dir="rtl"] select,
[dir="rtl"] select.input,
[dir="rtl"] .twk-field {
  background-position: left 12px center !important;
  padding-right: 14px !important;
  padding-left: 40px !important;
}
select:hover,
select.input:hover,
.twk-field:hover {
  border-color: var(--border-strong) !important;
  background-color: var(--surface-2) !important;
}
select:focus,
select.input:focus,
.twk-field:focus {
  outline: none !important;
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 4px var(--accent-soft) !important;
}
select option,
select.input option,
.twk-field option {
  background: var(--surface) !important;
  color: var(--text) !important;
  padding: 12px 16px !important;
  font-size: 13px !important;
  font-family: inherit;
  min-height: 40px;
}
select option:hover,
select option:focus,
select option:checked,
select.input option:hover,
select.input option:focus,
select.input option:checked {
  background: var(--accent-soft) !important;
  background-color: var(--accent-soft) !important;
  color: var(--accent) !important;
}
select:disabled,
select.input:disabled,
.twk-field:disabled {
  opacity: 0.5 !important;
  cursor: not-allowed !important;
}
/* Remove default arrow in IE/Edge */
select::-ms-expand {
  display: none;
}
/* Firefox specific fixes */
@-moz-document url-prefix() {
  select,
  select.input,
  .twk-field {
    text-indent: 0.01px;
    text-overflow: '';
    padding-top: 8px;
    padding-bottom: 8px;
  }
}
/* Dark theme adjustments */
:root[data-theme="dark"] select,
:root[data-theme="dark"] select.input,
:root[data-theme="dark"] .twk-field {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23b8aca8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") !important;
  background-color: var(--surface) !important;
}
:root[data-theme="dark"] select option,
:root[data-theme="dark"] select.input option {
  background: var(--surface-2) !important;
  color: var(--text) !important;
}

/* Table */
.t-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.t-table th, .t-table td { text-align: start; padding: 14px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.t-table th { font-size: 10px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-3); background: transparent; position: sticky; top: 0; }
.t-table tbody tr { transition: background .15s; }
.t-table tbody tr:hover { background: var(--accent-soft); }
.t-table tbody tr:hover td:first-child { color: var(--accent); }
.t-table td:first-child { font-weight: 600; color: var(--text-2); }

/* Animations */
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
@keyframes pulseGlow { 0%, 100% { box-shadow: 0 0 0 0 var(--accent-stronger); } 50% { box-shadow: 0 0 0 14px transparent; } }
@keyframes grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes growW { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

.fade-up { animation: fadeUp .5s var(--ease) both; }
.fade-in { animation: fadeIn .5s var(--ease) both; }

/* Stagger helper */
.stagger > * { animation: fadeUp .5s var(--ease) both; }
.stagger > *:nth-child(1) { animation-delay: .04s; }
.stagger > *:nth-child(2) { animation-delay: .08s; }
.stagger > *:nth-child(3) { animation-delay: .12s; }
.stagger > *:nth-child(4) { animation-delay: .16s; }
.stagger > *:nth-child(5) { animation-delay: .20s; }
.stagger > *:nth-child(6) { animation-delay: .24s; }
.stagger > *:nth-child(7) { animation-delay: .28s; }
.stagger > *:nth-child(8) { animation-delay: .32s; }

/* RTL helpers */
[dir="rtl"] .flip-rtl { transform: scaleX(-1); }

/* Splash gradient */
.splash-bg {
  background:
    radial-gradient(circle at 20% 30%, rgba(230,57,70,0.4) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(91,6,21,0.5) 0%, transparent 55%),
    linear-gradient(135deg, #1a0306 0%, #5b0615 50%, #0a0608 100%);
}

/* Skeleton */
.skeleton { background: linear-gradient(90deg, var(--surface-2) 0%, var(--border) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: shimmer 1.5s infinite linear; border-radius: 8px; }

/* Page transitions */
.screen { animation: fadeUp .35s var(--ease) both; }

/* Utility */
.row { display: flex; align-items: center; }
.col { display: flex; flex-direction: column; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; } .gap-5 { gap: 20px; } .gap-6 { gap: 24px; } .gap-8 { gap: 32px; }
.grow { flex: 1; }
.center { display: flex; align-items: center; justify-content: center; }
.between { display: flex; align-items: center; justify-content: space-between; }
.hidden { display: none !important; }
