/* ============================================================
   FEKRA PRODUCTION SYSTEM — Design System
   Skinned to Fekra Filmz "Brand Core v1.0":
   violet is the signal, indigo is the structure,
   obsidian + bone is the cinematic ramp.
   Token-driven: never hardcode colors in screens — use vars.
   ============================================================ */

/* ---------- Fonts ---------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Sora:wght@600;700;800&family=Geist+Mono:wght@400;500&family=Noto+Kufi+Arabic:wght@400;500;700&display=swap');
/* Huwiya Display is the brand face (Drive font pack); used if installed, else falls back to Sora/Inter. */

/* ============================================================
   TOKENS — DARK (default, cinematic)
   ============================================================ */
:root,
[data-theme="dark"] {
  /* surfaces — obsidian-dominant */
  --bg: #0A0810;             /* Obsidian */
  --bg-elevated: #14111E;    /* Obsidian2 */
  --sidebar: #0B0913;
  --topbar: rgba(10, 8, 16, 0.72);
  --card: #14111E;
  --card-2: #1C1830;         /* Ink (indigo-leaning = structure) */
  --surface-hover: #241E3A;
  --overlay: rgba(0, 0, 0, 0.66);

  /* brand duotone — violet signals, indigo structures */
  --primary: #A87EBA;            /* Fekra Violet */
  --primary-hover: #B594C6;
  --primary-press: #8A5E9E;      /* deep violet */
  --accent: #C9AEDB;             /* violet glow */
  --on-primary: #14111E;         /* ink text on violet fills (7.8:1) */
  --primary-soft: rgba(168, 126, 186, 0.16);
  --primary-glow: rgba(168, 126, 186, 0.42);
  --indigo: #363666;             /* Fekra Indigo */
  --indigo-soft: rgba(54, 54, 102, 0.42);
  --brand-icon: url('brand/fekra-icon-mono-bone.png');   /* bone mark on dark */
  --brand-lockup: url('brand/fekra-lockup-dark.png');

  /* text — bone ramp */
  --text: #F2EBDC;               /* Bone */
  --text-2: #C7BFD4;             /* Dim Bone */
  --text-3: #8B86A0;

  /* lines */
  --border: rgba(199, 191, 212, 0.10);
  --border-strong: rgba(199, 191, 212, 0.20);

  /* status (tuned to sit on obsidian) */
  --success: #4ED6A1; --success-soft: rgba(78, 214, 161, 0.14);
  --warning: #E7B34D; --warning-soft: rgba(231, 179, 77, 0.14);
  --danger:  #EB6F6F; --danger-soft:  rgba(235, 111, 111, 0.14);
  --info:    #8AA0E0; --info-soft:    rgba(138, 160, 224, 0.14);

  /* charts — duotone cinematic */
  --chart-1: #A87EBA; --chart-2: #4C4C84; --chart-3: #C9AEDB; --chart-4: #C7BFD4; --chart-5: #8A5E9E;
  --chart-track: rgba(199, 191, 212, 0.08);

  /* depth */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.45);
  --shadow: 0 8px 24px -8px rgba(0, 0, 0, 0.65);
  --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, 0.75);
  --shadow-glow: 0 8px 30px -6px var(--primary-glow);

  /* geometry */
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-xl: 26px;
  --sidebar-w: 264px;
  --topbar-h: 64px;

  --font: 'Inter', 'Noto Kufi Arabic', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Huwiya Display', 'Sora', 'Noto Kufi Arabic', var(--font);
  --font-mono: 'Geist Mono', ui-monospace, monospace;
}

/* ============================================================
   TOKENS — LIGHT (bone surfaces, indigo type/primary)
   ============================================================ */
[data-theme="light"] {
  --bg: #ECE5D6;             /* Bone, deepened for contrast w/ cards */
  --bg-elevated: #FFFFFF;
  --sidebar: #FBF7EF;
  --topbar: rgba(251, 247, 239, 0.82);
  --card: #FBF8F1;
  --card-2: #F4EEE1;
  --surface-hover: #EFE7F0;
  --overlay: rgba(33, 33, 74, 0.35);

  --primary: #363666;            /* indigo = legible primary on bone */
  --primary-hover: #2B2B56;
  --primary-press: #21214A;
  --accent: #8A5E9E;             /* deep violet accent */
  --on-primary: #F2EBDC;         /* bone text on indigo (AAA) */
  --primary-soft: #E7E2F2;       /* faint lavender */
  --primary-glow: rgba(54, 54, 102, 0.22);
  --indigo: #363666;
  --indigo-soft: rgba(54, 54, 102, 0.12);
  --brand-icon: url('brand/fekra-icon-mono-indigo.png');  /* indigo mark on bone */
  --brand-lockup: url('brand/fekra-lockup-light.png');

  --text: #21214A;               /* deep indigo on bone */
  --text-2: #4C4C84;
  --text-3: #8A86A8;

  --border: #DED7C9;
  --border-strong: #CFC6D6;

  --success: #1E9E73; --success-soft: #D6F2E7;
  --warning: #B5832A; --warning-soft: #F6EBD2;
  --danger:  #C8504F; --danger-soft:  #F6DCDB;
  --info:    #3D55A8; --info-soft:    #DFE5F6;

  --chart-1: #8A5E9E; --chart-2: #4C4C84; --chart-3: #A87EBA; --chart-4: #9A93B0; --chart-5: #363666;
  --chart-track: rgba(33, 33, 74, 0.08);

  --shadow-sm: 0 1px 2px rgba(33, 33, 74, 0.07);
  --shadow: 0 10px 30px -12px rgba(33, 33, 74, 0.18);
  --shadow-lg: 0 24px 60px -20px rgba(33, 33, 74, 0.22);
  --shadow-glow: 0 10px 30px -10px var(--primary-glow);
}

/* ============================================================
   BASE
   ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  transition: background .3s ease, color .3s ease;
}
/* ambient cinematic glow on dark — violet signal + indigo structure */
[data-theme="dark"] body {
  background-image:
    radial-gradient(900px 500px at 100% -10%, rgba(168, 126, 186, 0.12), transparent 60%),
    radial-gradient(760px 520px at -10% 110%, rgba(54, 54, 102, 0.22), transparent 60%);
  background-attachment: fixed;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.01em; color: var(--text); }
img { max-width: 100%; display: block; }
::selection { background: var(--primary-soft); }

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

/* ============================================================
   APP SHELL  (injected by app.js into #app-shell)
   ============================================================ */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 60;
  transition: transform .28s cubic-bezier(.4,0,.2,1);
}
.sidebar__brand {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 11px;
  padding: 0 20px; flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}
.brand-mark {
  width: 36px; height: 36px; flex-shrink: 0;
  background: var(--brand-icon) center / contain no-repeat;
  display: grid; place-items: center;
  color: transparent; font-size: 0;  /* real logo mark replaces the letter */
}
.auth-lockup { width: 190px; max-width: 60%; height: auto; display: block; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 15px; letter-spacing: -0.02em; }
.brand-name small { display: block; font-family: var(--font-mono); font-weight: 500; font-size: 9.5px; color: var(--text-3); letter-spacing: .14em; text-transform: uppercase; }

.sidebar__nav { flex: 1; overflow-y: auto; padding: 14px 12px 20px; }
.nav-group { margin-bottom: 18px; }
.nav-group__label { font-family: var(--font-mono); font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .12em; color: var(--text-3); padding: 0 12px 8px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500; font-size: 13.5px;
  margin-bottom: 2px; position: relative;
  transition: background .15s, color .15s;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .85; }
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--text); }
.nav-item.active::before {
  content: ""; position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 0 3px 3px 0; background: var(--primary);
  box-shadow: 0 0 12px var(--primary-glow);
}
.nav-item.active svg { opacity: 1; color: var(--primary); }
.nav-badge { margin-left: auto; background: var(--primary); color: var(--on-primary); font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 99px; }

.sidebar__foot { padding: 12px; border-top: 1px solid var(--border); }
.userchip { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius-sm); }
.userchip:hover { background: var(--surface-hover); }
.userchip__meta { min-width: 0; }
.userchip__name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.userchip__role { font-size: 11.5px; color: var(--text-3); }

/* main column */
.main-col { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h); flex-shrink: 0;
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 14px;
  padding: 0 24px;
  background: var(--topbar); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
}
.topbar__title { font-family: var(--font-display); font-size: 17px; font-weight: 700; }
.topbar__sub { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.topbar__spacer { flex: 1; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  color: var(--text-2); border: 1px solid var(--border); background: var(--card);
  transition: .15s; position: relative;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-hover); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn .dot { position: absolute; top: 8px; right: 9px; width: 7px; height: 7px; border-radius: 99px; background: var(--primary); border: 2px solid var(--card); }
.hamburger { display: none; }

.role-switcher select, .topbar-select {
  appearance: none; background: var(--card); border: 1px solid var(--border);
  color: var(--text); border-radius: 10px; padding: 9px 34px 9px 13px; font-size: 13px; font-weight: 500;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238B86A0' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
  cursor: pointer; transition: .15s;
}
.role-switcher select:hover, .topbar-select:hover { border-color: var(--border-strong); }
.role-switcher { display: flex; align-items: center; gap: 8px; }
.role-switcher__lbl { font-family: var(--font-mono); font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: .1em; font-weight: 600; }

.page { padding: 28px; max-width: 1320px; width: 100%; margin: 0 auto; }
.page--wide { max-width: 1600px; }

/* ============================================================
   TYPOGRAPHY HELPERS
   ============================================================ */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-title { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.page-desc { color: var(--text-2); font-size: 13.5px; margin-top: 4px; max-width: 60ch; }
.section-title { font-family: var(--font-mono); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; color: var(--text-3); margin-bottom: 14px; }
.muted { color: var(--text-2); }
.muted-3 { color: var(--text-3); }
.mono { font-family: var(--font-mono); }
.eyebrow { font-family: var(--font-mono); font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--primary); }
[data-theme="dark"] .eyebrow { color: var(--accent); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 11px; font-weight: 600; font-size: 13.5px;
  border: 1px solid transparent; transition: .15s; white-space: nowrap; line-height: 1;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-press)); color: var(--on-primary); box-shadow: var(--shadow-glow); }
.btn-primary:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn-primary:active { filter: brightness(.96); transform: none; }
.btn-secondary { background: var(--primary-soft); color: var(--primary); }
[data-theme="dark"] .btn-secondary { color: var(--accent); }
.btn-secondary:hover { background: var(--primary); color: var(--on-primary); }
.btn-ghost { background: var(--card); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-success { background: var(--success-soft); color: var(--success); }
.btn-success:hover { background: var(--success); color: #06281C; }
.btn-lg { padding: 14px 22px; font-size: 15px; border-radius: 13px; }
.btn-sm { padding: 7px 12px; font-size: 12.5px; border-radius: 9px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ============================================================
   CARDS / SURFACES
   ============================================================ */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card--pad { padding: 20px; }
.card--hover { transition: .18s; }
.card--hover:hover { border-color: var(--border-strong); box-shadow: var(--shadow); transform: translateY(-2px); }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card__title { font-size: 15px; font-weight: 700; }
.card__body { padding: 20px; }
.card-glow { position: relative; overflow: hidden; }
.card-glow::after { content:""; position:absolute; inset:0; background: radial-gradient(420px 180px at 80% -20%, var(--primary-soft), transparent 70%); pointer-events:none; }

/* stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.stat {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; position: relative; overflow: hidden;
}
.stat__icon { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); margin-bottom: 14px; }
[data-theme="dark"] .stat__icon { color: var(--accent); }
.stat__icon svg { width: 20px; height: 20px; }
.stat__label { font-size: 12.5px; color: var(--text-3); font-weight: 500; }
.stat__value { font-size: 27px; font-weight: 800; font-family: var(--font-display); letter-spacing: -0.02em; margin-top: 3px; }
.stat__delta { font-size: 12px; font-weight: 600; margin-top: 6px; display: inline-flex; align-items: center; gap: 4px; }
.stat__delta.up { color: var(--success); }
.stat__delta.down { color: var(--danger); }

/* ============================================================
   BADGES / CHIPS / PILLS
   ============================================================ */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 99px; font-size: 11.5px; font-weight: 600; line-height: 1.4;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 99px; background: currentColor; }
.badge--no-dot::before { display: none; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger  { background: var(--danger-soft); color: var(--danger); }
.badge-info    { background: var(--info-soft); color: var(--info); }
.badge-primary { background: var(--primary-soft); color: var(--primary); }
[data-theme="dark"] .badge-primary { color: var(--accent); }
.badge-neutral { background: var(--surface-hover); color: var(--text-2); }

.chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px;
  border-radius: 99px; background: var(--card); border: 1px solid var(--border);
  font-size: 12.5px; font-weight: 500; color: var(--text-2);
}
.chip--active { background: var(--primary-soft); border-color: transparent; color: var(--primary); }
[data-theme="dark"] .chip--active { color: var(--accent); }

.tag { display:inline-flex; padding: 2px 9px; border-radius: 7px; font-size: 11px; font-weight: 600; background: var(--surface-hover); color: var(--text-2); }

/* ============================================================
   AVATARS
   ============================================================ */
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #F2EBDC;
  background: linear-gradient(135deg, var(--indigo), var(--primary));
  text-transform: uppercase;
}
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
.avatar-lg { width: 56px; height: 56px; font-size: 20px; }
.avatar-stack { display: flex; }
.avatar-stack .avatar { border: 2px solid var(--card); margin-left: -10px; }
.avatar-stack .avatar:first-child { margin-left: 0; }

/* ============================================================
   FORMS
   ============================================================ */
.field { margin-bottom: 16px; }
.field__label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 7px; }
.field__label .req { color: var(--danger); margin-left: 2px; }
.field__hint { font-size: 11.5px; color: var(--text-3); margin-top: 6px; }
.input, .select, .textarea {
  width: 100%; background: var(--bg-elevated); border: 1px solid var(--border);
  color: var(--text); border-radius: 11px; padding: 11px 14px; font-size: 14px; transition: .15s;
}
[data-theme="light"] .input, [data-theme="light"] .select, [data-theme="light"] .textarea { background: var(--card-2); }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.textarea { resize: vertical; min-height: 96px; }
.select { appearance: none; cursor: pointer;
  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='%238B86A0' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center; padding-right: 38px; }
.input-group { position: relative; }
.input-group .prefix { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-3); font-size: 14px; pointer-events: none; }
.input-group .input { padding-left: 32px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }

/* toggle switch */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { display: none; }
.switch__track { width: 42px; height: 24px; border-radius: 99px; background: var(--border-strong); transition: .2s; position: relative; }
.switch__track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #F2EBDC; transition: .2s; box-shadow: var(--shadow-sm); }
.switch input:checked + .switch__track { background: var(--primary); }
.switch input:checked + .switch__track::after { transform: translateX(18px); }

/* segmented control */
.segment { display: inline-flex; background: var(--card); border: 1px solid var(--border); border-radius: 11px; padding: 3px; gap: 2px; }
.segment button { padding: 7px 15px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--text-2); transition: .15s; }
.segment button.active { background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-sm); }
.segment button:not(.active):hover { color: var(--text); background: var(--surface-hover); }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table.table { width: 100%; border-collapse: collapse; background: var(--card); }
.table thead th {
  text-align: left; font-family: var(--font-mono); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-3); padding: 13px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--card-2);
}
.table tbody td { padding: 14px 16px; border-bottom: 1px solid var(--border); font-size: 13.5px; vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--surface-hover); }
.table .num { font-family: var(--font-mono); text-align: right; }
.table .cell-strong { font-weight: 600; color: var(--text); }
.td-user { display: flex; align-items: center; gap: 10px; }
tfoot td { padding: 14px 16px; font-weight: 700; border-top: 2px solid var(--border-strong); background: var(--card-2); }

/* ============================================================
   TABS
   ============================================================ */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 24px; overflow-x: auto; }
.tab { padding: 12px 16px; font-size: 13.5px; font-weight: 600; color: var(--text-2); border-bottom: 2px solid transparent; white-space: nowrap; transition: .15s; margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
[data-theme="dark"] .tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* pill tabs */
.pill-tabs { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.pill-tab { padding: 8px 15px; border-radius: 99px; font-size: 13px; font-weight: 600; color: var(--text-2); background: var(--card); border: 1px solid var(--border); transition: .15s; }
.pill-tab.active { background: var(--primary); color: var(--on-primary); border-color: transparent; }
.pill-tab:not(.active):hover { background: var(--surface-hover); color: var(--text); }

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0; background: var(--overlay); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-overlay.open { display: flex; animation: fade .2s ease; }
.modal {
  background: var(--bg-elevated); border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg);
  animation: pop .22s cubic-bezier(.4,0,.2,1);
}
.modal--lg { max-width: 760px; }
.modal__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 22px 24px 0; }
.modal__title { font-size: 18px; font-weight: 700; }
.modal__sub { font-size: 13px; color: var(--text-3); margin-top: 3px; }
.modal__body { padding: 22px 24px; }
.modal__foot { padding: 16px 24px 22px; display: flex; gap: 10px; justify-content: flex-end; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.98); } }

/* ============================================================
   PHOTO GRID (scenes: cast / wardrobe / props)
   ============================================================ */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.photo-tile { aspect-ratio: 3/4; border-radius: var(--radius-sm); overflow: hidden; position: relative; background: var(--card-2); border: 1px solid var(--border); }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; }
.photo-tile__cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 10px 8px; font-size: 11.5px; font-weight: 600; color: #F2EBDC; background: linear-gradient(transparent, rgba(10,8,16,.85)); }
.photo-add { aspect-ratio: 3/4; border: 1.5px dashed var(--border-strong); border-radius: var(--radius-sm); display: grid; place-content: center; gap: 8px; color: var(--text-3); font-size: 12px; font-weight: 500; cursor: pointer; transition: .15s; background: var(--card-2); }
.photo-add:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.photo-add svg { width: 22px; height: 22px; margin: 0 auto; }
.photo-locked { opacity: .55; cursor: not-allowed; }

/* ============================================================
   PROGRESS / METERS
   ============================================================ */
.progress { height: 8px; border-radius: 99px; background: var(--chart-track); overflow: hidden; }
.progress__bar { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--indigo), var(--primary)); }
.meter-row { display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; margin-bottom: 7px; }

/* ============================================================
   KANBAN
   ============================================================ */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(280px, 1fr); gap: 16px; overflow-x: auto; padding-bottom: 8px; }
.kanban-col { background: var(--card-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.kanban-col__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; font-size: 13px; font-weight: 700; }
.kanban-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; margin-bottom: 10px; box-shadow: var(--shadow-sm); transition: .15s; cursor: grab; }
.kanban-card:hover { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: var(--shadow); }

/* ============================================================
   TIMELINE / GANTT
   ============================================================ */
.gantt-row { display: grid; grid-template-columns: 180px 1fr; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.gantt-track { position: relative; height: 30px; background: var(--chart-track); border-radius: 8px; }
.gantt-bar { position: absolute; top: 4px; height: 22px; border-radius: 6px; background: linear-gradient(90deg, var(--indigo), var(--primary)); display: flex; align-items: center; padding: 0 8px; font-size: 11px; font-weight: 600; color: #F2EBDC; box-shadow: var(--shadow-sm); }

/* timeline (vertical) */
.tl { position: relative; padding-left: 26px; }
.tl::before { content: ""; position: absolute; left: 7px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding-bottom: 22px; }
.tl-item::before { content: ""; position: absolute; left: -26px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--card); border: 3px solid var(--primary); }
.tl-item--done::before { background: var(--primary); }

/* ============================================================
   CHAT (AI assistant)
   ============================================================ */
.chat { display: flex; flex-direction: column; gap: 12px; }
.bubble { max-width: 78%; padding: 11px 15px; border-radius: 16px; font-size: 13.5px; line-height: 1.45; }
.bubble--in { background: var(--card-2); border: 1px solid var(--border); border-bottom-left-radius: 5px; align-self: flex-start; }
.bubble--out { background: var(--primary); color: var(--on-primary); border-bottom-right-radius: 5px; align-self: flex-end; }
.bubble--ar { direction: rtl; text-align: right; font-family: var(--font-display); }
.bubble__time { font-size: 10px; opacity: .6; margin-top: 4px; }
.phone-frame { width: 340px; max-width: 100%; border-radius: 36px; border: 10px solid #1C1830; background: var(--bg); box-shadow: var(--shadow-lg); overflow: hidden; }

/* ============================================================
   EMPTY STATES / MISC
   ============================================================ */
.empty { text-align: center; padding: 56px 20px; color: var(--text-3); }
.empty svg { width: 44px; height: 44px; margin: 0 auto 14px; opacity: .5; }
.empty h3 { font-size: 16px; color: var(--text-2); margin-bottom: 6px; }
.divider { height: 1px; background: var(--border); margin: 20px 0; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.kv:last-child { border-bottom: none; }
.kv dt { color: var(--text-3); }
.kv dd { font-weight: 600; }

/* lock / restricted notice */
.lock-note { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--warning-soft); border: 1px solid transparent; color: var(--text); font-size: 13px; align-items: flex-start; }
.lock-note svg { width: 18px; height: 18px; color: var(--warning); flex-shrink: 0; margin-top: 1px; }

/* toast */
.toast-wrap { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast { background: var(--bg-elevated); border: 1px solid var(--border-strong); border-radius: 12px; padding: 13px 18px; box-shadow: var(--shadow-lg); font-size: 13.5px; font-weight: 500; display: flex; align-items: center; gap: 10px; animation: slidein .25s ease; }
.toast svg { width: 18px; height: 18px; color: var(--success); }
@keyframes slidein { from { opacity: 0; transform: translateX(20px); } }

/* ============================================================
   UTILITIES
   ============================================================ */
.row { display: flex; align-items: center; gap: 12px; }
.row-wrap { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 12px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.gap-sm { gap: 8px; } .gap-lg { gap: 20px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-sb { grid-template-columns: 2fr 1fr; align-items: start; }
.mt-0{margin-top:0}.mt-1{margin-top:8px}.mt-2{margin-top:16px}.mt-3{margin-top:24px}.mt-4{margin-top:32px}
.mb-1{margin-bottom:8px}.mb-2{margin-bottom:16px}.mb-3{margin-bottom:24px}
.flex-1{flex:1}.center{text-align:center}.right{text-align:right}
.full{width:100%}.nowrap{white-space:nowrap}
.text-success{color:var(--success)}.text-danger{color:var(--danger)}.text-primary{color:var(--primary)}
[data-theme="dark"] .text-primary{color:var(--accent)}
.fw-700{font-weight:700}.fs-sm{font-size:12.5px}.fs-lg{font-size:16px}
.hide{display:none!important}

/* ============================================================
   MOBILE  — bottom nav + drawer sidebar
   ============================================================ */
.scrim { display: none; position: fixed; inset: 0; background: var(--overlay); z-index: 55; }
.bottom-nav { display: none; }

@media (max-width: 1024px) {
  :root { --sidebar-w: 240px; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-sb { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .scrim.open { display: block; }
  .main-col { margin-left: 0; }
  .hamburger { display: grid; }
  .page { padding: 18px 16px 92px; }
  .form-grid { grid-template-columns: 1fr; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .topbar { padding: 0 16px; }
  .role-switcher__lbl { display: none; }
  .page-title { font-size: 22px; }
  .hide-mobile { display: none !important; }

  .bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 56;
    background: var(--topbar); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
    border-top: 1px solid var(--border); padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
    justify-content: space-around;
  }
  .bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10px; font-weight: 600; color: var(--text-3); padding: 4px 10px; border-radius: 9px; }
  .bottom-nav a.active { color: var(--primary); }
  .bottom-nav a svg { width: 21px; height: 21px; }
}

/* ============================================================
   AUTH / STANDALONE PAGES (login, otp, invite, profile-completion)
   ============================================================ */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-aside {
  position: relative; overflow: hidden; padding: 48px;
  display: flex; flex-direction: column; justify-content: space-between;
  background: linear-gradient(150deg, #1C1830 0%, #0A0810 62%);
  border-right: 1px solid var(--border);
}
.auth-aside::before { content:""; position:absolute; inset:0; background: radial-gradient(700px 420px at 20% 10%, rgba(168,126,186,.30), transparent 60%), radial-gradient(620px 520px at 90% 95%, rgba(54,54,102,.45), transparent 60%); }
.auth-aside > * { position: relative; z-index: 1; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--bg); }
.auth-card { width: 100%; max-width: 400px; }
.auth-title { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 8px; }
.auth-sub { color: var(--text-2); margin-bottom: 28px; font-size: 14px; }
.otp-inputs { display: flex; gap: 10px; }
.otp-inputs input { width: 100%; aspect-ratio: 1; text-align: center; font-size: 22px; font-weight: 700; font-family: var(--font-mono);
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 12px; color: var(--text); }
.otp-inputs input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
@media (max-width: 860px) { .auth-wrap { grid-template-columns: 1fr; } .auth-aside { display: none; } }
