/* ===================== Themes ===================== */
:root, [data-theme="nwc"] {
  --primary: #0b5ea8; --primary-2: #00a3e0; --accent: #34c3eb;
  --bg: #f2f6fb; --surface: #ffffff; --surface-2: #f6f9fd; --text: #0f2742; --muted: #5d7189; --border: #dde6f0;
  --side-bg: linear-gradient(180deg, #063f75 0%, #0b5ea8 100%); --side-text: #e7f2ff; --side-active: rgba(255,255,255,.16);
  --shadow: 0 6px 22px rgba(15, 39, 66, .07);
}
[data-theme="dark"] {
  --primary: #38bdf8; --primary-2: #0ea5e9; --accent: #7dd3fc;
  --bg: #0b1220; --surface: #121b2d; --surface-2: #17223a; --text: #e6edf7; --muted: #94a3b8; --border: #23314d;
  --side-bg: linear-gradient(180deg, #070d18 0%, #0f1a2e 100%); --side-text: #cbd5e1; --side-active: rgba(56,189,248,.16);
  --shadow: 0 6px 22px rgba(0,0,0,.35);
}
[data-theme="teal"] {
  --primary: #0f766e; --primary-2: #14b8a6; --accent: #5eead4;
  --bg: #f0f9f8; --surface: #ffffff; --surface-2: #f3fbfa; --text: #0b2e2b; --muted: #557571; --border: #d5ebe8;
  --side-bg: linear-gradient(180deg, #064e47 0%, #0f766e 100%); --side-text: #e0fbf6; --side-active: rgba(255,255,255,.16);
  --shadow: 0 6px 22px rgba(11, 46, 43, .07);
}
[data-theme="sand"] {
  --primary: #9a6b1f; --primary-2: #c9952f; --accent: #e6c27a;
  --bg: #faf6ee; --surface: #ffffff; --surface-2: #fcf9f3; --text: #3a2a10; --muted: #7d6a4c; --border: #ece2cf;
  --side-bg: linear-gradient(180deg, #4a3410 0%, #7a5518 100%); --side-text: #fbf1dc; --side-active: rgba(255,255,255,.16);
  --shadow: 0 6px 22px rgba(58, 42, 16, .07);
}
[data-theme="royal"] {
  --primary: #4338ca; --primary-2: #7c3aed; --accent: #a78bfa;
  --bg: #f4f3fc; --surface: #ffffff; --surface-2: #f8f7fe; --text: #1e1b4b; --muted: #635f8a; --border: #e2e0f5;
  --side-bg: linear-gradient(180deg, #1e1b4b 0%, #3730a3 100%); --side-text: #e8e6ff; --side-active: rgba(255,255,255,.16);
  --shadow: 0 6px 22px rgba(30, 27, 75, .08);
}

/* ===================== Base ===================== */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { font-family: 'Cairo', 'Inter', sans-serif; background: var(--bg); color: var(--text); display: flex; min-height: 100vh; transition: background .3s, color .3s; font-size: 14.5px; line-height: 1.6; }
html[lang="en"] body { font-family: 'Inter', 'Cairo', sans-serif; }
a { color: var(--primary); }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; color: var(--text); }

/* ===================== Sidebar ===================== */
.sidebar { width: 268px; flex-shrink: 0; background: var(--side-bg); color: var(--side-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 18px 14px; overflow-y: auto; z-index: 40; }
.brand { background: #fff; border-radius: 14px; padding: 10px 12px; display: flex; align-items: center; justify-content: center; min-height: 70px; }
.brand-logo { max-width: 100%; max-height: 64px; object-fit: contain; }
.brand-sub { font-size: 12px; opacity: .85; margin: 10px 4px 14px; text-align: center; }
.main-nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-link { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--side-text); text-decoration: none; font-weight: 500; font-size: 14px; transition: background .2s; border: 0; background: none; text-align: start; width: 100%; }
.nav-link i { width: 20px; text-align: center; opacity: .9; }
.nav-link:hover { background: rgba(255,255,255,.08); }
.nav-link.active { background: var(--side-active); font-weight: 700; box-shadow: inset 3px 0 0 var(--accent); }
[dir="rtl"] .nav-link.active { box-shadow: inset -3px 0 0 var(--accent); }
.sidebar-foot { opacity: .7; font-size: 11px; text-align: center; padding-top: 14px; }
.sidebar-backdrop { display: none; }

/* ===================== Topbar ===================== */
.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); display: flex; align-items: center; gap: 16px; padding: 16px 28px; border-bottom: 1px solid var(--border); }
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 { font-size: 21px; font-weight: 800; }
.topbar-title p { color: var(--muted); font-size: 13px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.search-box { position: relative; }
.search-box i { position: absolute; top: 50%; transform: translateY(-50%); inset-inline-start: 12px; color: var(--muted); font-size: 13px; }
.search-box input { padding: 9px 14px; padding-inline-start: 34px; border: 1px solid var(--border); background: var(--surface); border-radius: 10px; width: 240px; outline: none; }
.search-box input:focus { border-color: var(--primary); }
.icon-btn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { border-color: var(--primary); color: var(--primary); }
.pill-btn { height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-weight: 700; display: inline-flex; align-items: center; gap: 6px; }
.pill-btn:hover { border-color: var(--primary); color: var(--primary); }
.theme-picker { display: flex; gap: 6px; padding: 5px 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.theme-dot { width: 24px; height: 24px; border-radius: 50%; border: 2px solid transparent; outline: none; }
.theme-dot.active { border-color: var(--text); transform: scale(1.1); }
.mobile-only { display: none; }

/* ===================== Content ===================== */
.content { padding: 24px 28px 48px; }
.view { display: none; animation: fade .3s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.grid { display: grid; gap: 18px; }
.g-4 { grid-template-columns: repeat(4, 1fr); }
.g-3 { grid-template-columns: repeat(3, 1fr); }
.g-2 { grid-template-columns: repeat(2, 1fr); }
.mt { margin-top: 18px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 20px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h3 { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card-head h3 i { color: var(--primary); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* Stat cards */
.stat { display: flex; gap: 14px; align-items: center; }
.stat-icon { width: 52px; height: 52px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 22px; color: #fff; background: linear-gradient(135deg, var(--primary), var(--primary-2)); flex-shrink: 0; }
.stat-val { font-size: 26px; font-weight: 800; line-height: 1.1; }
.stat-lbl { color: var(--muted); font-size: 13px; }

/* Hero */
.hero { background: linear-gradient(120deg, var(--primary), var(--primary-2)); color: #fff; border-radius: 18px; padding: 26px; display: flex; gap: 24px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 18px; position: relative; overflow: hidden; }
.hero::after { content: ''; position: absolute; width: 320px; height: 320px; border-radius: 50%; background: rgba(255,255,255,.08); inset-inline-end: -80px; top: -120px; }
.hero h2 { font-size: 22px; font-weight: 800; margin-bottom: 6px; }
.hero p { opacity: .92; max-width: 720px; }
.ring { --p: 0; width: 120px; height: 120px; border-radius: 50%; background: conic-gradient(#fff calc(var(--p) * 1%), rgba(255,255,255,.22) 0); display: flex; align-items: center; justify-content: center; position: relative; z-index: 1; flex-shrink: 0; }
.ring span { width: 94px; height: 94px; border-radius: 50%; background: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 800; flex-direction: column; line-height: 1.1; }
.ring small { font-size: 10px; font-weight: 500; opacity: .85; }

/* Progress */
.bar { height: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-2)); border-radius: 99px; transition: width .6s; }
[dir="rtl"] .bar > i { background: linear-gradient(-90deg, var(--primary), var(--primary-2)); }
.phase-row { display: grid; grid-template-columns: 1fr 70px; align-items: center; gap: 10px; margin-bottom: 12px; }
.phase-row .lbl { font-size: 13px; font-weight: 600; margin-bottom: 4px; display: flex; justify-content: space-between; gap: 8px; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.b-not_started, .b-closed { background: #e2e8f0; color: #475569; }
.b-in_progress, .b-mitigating { background: #dbeafe; color: #1d4ed8; }
.b-completed { background: #dcfce7; color: #15803d; }
.b-delayed, .b-open { background: #fee2e2; color: #b91c1c; }
.b-on_hold { background: #fef3c7; color: #a16207; }
.b-low { background: #e0f2fe; color: #0369a1; } .b-medium { background: #fef9c3; color: #a16207; } .b-high { background: #ffedd5; color: #c2410c; } .b-critical { background: #fee2e2; color: #b91c1c; }
.cls { display: inline-flex; width: 34px; height: 26px; align-items: center; justify-content: center; border-radius: 8px; color: #fff; font-weight: 800; font-size: 12px; }
.chip { display: inline-block; padding: 4px 11px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12.5px; margin: 3px; }

/* Factory pipeline */
.gov-band { background: linear-gradient(90deg, var(--primary), var(--primary-2)); color: #fff; border-radius: 14px; padding: 14px 18px; font-weight: 600; display: flex; gap: 10px; align-items: center; }
.pipeline { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin: 16px 0; }
.stage { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px 14px; position: relative; box-shadow: var(--shadow); cursor: pointer; transition: transform .2s; }
.stage:hover { transform: translateY(-3px); border-color: var(--primary); }
.stage .num { position: absolute; top: 10px; inset-inline-end: 12px; font-size: 26px; font-weight: 800; color: var(--border); }
.stage .s-icon { width: 42px; height: 42px; border-radius: 12px; background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 18px; margin-bottom: 10px; }
.stage h4 { font-size: 14px; margin-bottom: 4px; }
.stage p { font-size: 12.5px; color: var(--muted); }
.stage .count { margin-top: 10px; font-size: 12px; font-weight: 700; color: var(--primary); }

/* Architecture */
.arch { display: grid; grid-template-columns: 1fr 210px; gap: 14px; }
.layers { display: flex; flex-direction: column; gap: 10px; }
.layer { display: flex; gap: 14px; align-items: flex-start; padding: 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); border-inline-start: 5px solid var(--primary); box-shadow: var(--shadow); }
.layer .l-icon { width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: #fff; background: linear-gradient(135deg, var(--primary), var(--primary-2)); }
.layer h4 { font-size: 15px; margin-bottom: 3px; }
.layer p { font-size: 13px; color: var(--muted); }
.cross { display: flex; flex-direction: column; gap: 10px; }
.cross div { flex: 1; display: flex; align-items: center; justify-content: center; text-align: center; padding: 10px; border-radius: 12px; background: color-mix(in srgb, var(--primary) 10%, var(--surface)); border: 1px dashed var(--primary); font-weight: 600; font-size: 13px; color: var(--primary); }

/* Services */
.svc-card { display: flex; flex-direction: column; gap: 12px; border-top: 4px solid var(--c, var(--primary)); }
.svc-top { display: flex; gap: 12px; align-items: center; }
.svc-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 20px; background: var(--c); flex-shrink: 0; }
.svc-top h3 { font-size: 15.5px; line-height: 1.4; }
.svc-card p { font-size: 13.5px; color: var(--muted); }
.svc-card ul { padding-inline-start: 18px; font-size: 13px; }
.svc-card li { margin-bottom: 4px; }
.svc-benefit { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; font-size: 13px; border-inline-start: 3px solid var(--c); }
.svc-foot { display: flex; align-items: center; gap: 10px; margin-top: auto; }
.svc-foot .bar { flex: 1; }
.target-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.target-chips span { background: color-mix(in srgb, var(--c) 14%, transparent); color: var(--c); font-weight: 700; font-size: 12px; padding: 3px 10px; border-radius: 8px; }
.sec-title { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }

/* Gantt */
.gantt { display: grid; grid-template-columns: 240px repeat(12, 1fr); gap: 0; font-size: 12.5px; overflow-x: auto; }
.gantt .gh { font-weight: 700; color: var(--muted); text-align: center; padding: 6px 0; border-bottom: 1px solid var(--border); }
.gantt .gl { padding: 10px 6px; border-bottom: 1px solid var(--border); font-weight: 600; }
.gantt .gc { border-bottom: 1px solid var(--border); border-inline-start: 1px dashed var(--border); position: relative; min-height: 48px; }
.gbar { position: absolute; top: 10px; bottom: 10px; border-radius: 8px; color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; padding: 0 8px; overflow: hidden; white-space: nowrap; z-index: 1; }
.gbar em { position: absolute; inset: 0; background: rgba(255,255,255,.28); font-style: normal; }
.gbar b { position: relative; }

.gantt2 { display: grid; grid-template-columns: 230px 1fr; row-gap: 6px; column-gap: 12px; align-items: center; overflow-x: auto; }
.gmonths { display: grid; grid-template-columns: repeat(12, 1fr); text-align: center; font-size: 11.5px; font-weight: 700; color: var(--muted); }
.gmonths span.cur { color: #fff; background: var(--primary); border-radius: 6px; }
.gantt2 .gl { font-size: 13px; line-height: 1.35; }
.gtrack { position: relative; height: 40px; border-radius: 10px; background: repeating-linear-gradient(90deg, var(--surface-2) 0, var(--surface-2) calc(100% / 12 - 1px), var(--border) calc(100% / 12 - 1px), var(--border) calc(100% / 12)); }
.gtrack .gbar { top: 5px; bottom: 5px; }
.gnow { position: absolute; top: -4px; bottom: -4px; width: 2px; background: #ef4444; z-index: 2; border-radius: 2px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: start; background: var(--surface-2); color: var(--muted); font-weight: 700; padding: 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:hover td { background: color-mix(in srgb, var(--primary) 4%, transparent); }
.mini-bar { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.mini-bar .bar { flex: 1; }

/* Filters / forms */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 3px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; font-weight: 600; color: var(--muted); font-size: 13px; }
.seg button.active { background: var(--primary); color: #fff; }
.btn { border: 0; padding: 9px 16px; border-radius: 10px; font-weight: 700; display: inline-flex; align-items: center; gap: 7px; font-size: 13.5px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: #fee2e2; color: #b91c1c; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 12.5px; font-weight: 700; margin-bottom: 4px; color: var(--muted); }
.field input, .field select, .field textarea { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); outline: none; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* Activity cards */
.act-list { display: flex; flex-direction: column; gap: 10px; }
.act { border: 1px solid var(--border); border-radius: 14px; background: var(--surface); overflow: hidden; }
.act-head { display: grid; grid-template-columns: 56px 1fr 160px 120px 40px; gap: 12px; align-items: center; padding: 12px 14px; cursor: pointer; }
.act-code { font-weight: 800; color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, transparent); border-radius: 8px; text-align: center; padding: 4px 0; }
.act-name { font-weight: 700; }
.act-name small { display: block; color: var(--muted); font-weight: 500; }
.act-body { display: none; padding: 0 14px 14px; border-top: 1px dashed var(--border); }
.act.open .act-body { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; padding-top: 14px; }
.act-body h5 { font-size: 12.5px; color: var(--primary); margin-bottom: 4px; display: flex; gap: 6px; align-items: center; }
.act-body p { font-size: 13px; }

/* Delivery units */
.du-card { border-top: 4px solid var(--c); }
.du-card .cls { width: 48px; height: 36px; font-size: 16px; background: var(--c); }
.du-card h4 { font-size: 16px; margin: 8px 0 6px; }
.du-meta { display: flex; justify-content: space-between; border-top: 1px dashed var(--border); padding-top: 10px; margin-top: 10px; font-size: 12.5px; gap: 8px; }
.du-meta b { display: block; font-size: 13.5px; }
.kanban { display: grid; grid-template-columns: repeat(6, minmax(170px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.kcol { background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; padding: 10px; min-height: 160px; }
.kcol h5 { font-size: 13px; display: flex; justify-content: space-between; margin-bottom: 8px; }
.kcol h5 span { background: var(--primary); color: #fff; border-radius: 99px; padding: 0 8px; font-size: 11px; }
.kcard { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px; margin-bottom: 8px; font-size: 12.5px; cursor: pointer; }
.kcard:hover { border-color: var(--primary); }
.kcard b { display: block; margin-bottom: 6px; font-size: 13px; }
.kcard .row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* KPI cards */
.kpi-card .k-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.kpi-card .k-icon { width: 40px; height: 40px; border-radius: 10px; background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); display: flex; align-items: center; justify-content: center; }
.kpi-card h4 { font-size: 14px; margin: 10px 0 2px; }
.kpi-card .k-val { font-size: 26px; font-weight: 800; }
.kpi-card .k-val small { font-size: 13px; color: var(--muted); font-weight: 600; }
.kpi-card .k-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 8px; }

/* Governance */
.gov-card { display: flex; flex-direction: column; gap: 8px; }
.gov-card .g-icon { width: 46px; height: 46px; border-radius: 12px; background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 19px; }
.esc { display: flex; align-items: stretch; gap: 0; flex-wrap: wrap; }
.esc-step { flex: 1; min-width: 140px; background: var(--surface-2); border: 1px solid var(--border); padding: 14px; text-align: center; position: relative; }
.esc-step:first-child { border-start-start-radius: 12px; border-end-start-radius: 12px; }
.esc-step:last-child { border-start-end-radius: 12px; border-end-end-radius: 12px; background: var(--primary); color: #fff; }
.esc-step b { display: block; }
.esc-step small { opacity: .8; }
.pm-item { display: flex; gap: 12px; }
.pm-item i { color: var(--primary); font-size: 18px; margin-top: 3px; width: 22px; text-align: center; }
.pm-item h4 { font-size: 14px; }
.pm-item p { font-size: 13px; color: var(--muted); }

/* Heatmap */
.heat { display: grid; grid-template-columns: 70px repeat(4, 1fr); gap: 6px; }
.heat .hc { min-height: 64px; border-radius: 10px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; justify-content: center; padding: 6px; }
.heat .hl { font-size: 11.5px; color: var(--muted); display: flex; align-items: center; justify-content: center; text-align: center; font-weight: 700; }
.heat .dot { width: 26px; height: 26px; border-radius: 50%; background: rgba(255,255,255,.95); color: #111; font-weight: 800; font-size: 11px; display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.h1 { background: #bbf7d0; } .h2 { background: #fde68a; } .h3 { background: #fdba74; } .h4 { background: #f87171; }

/* Settings */
.theme-cards { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.theme-card { border: 2px solid var(--border); border-radius: 14px; padding: 10px; background: var(--surface); text-align: center; font-weight: 700; font-size: 13px; color: var(--text); }
.theme-card.active { border-color: var(--primary); }
.theme-card .sw { height: 54px; border-radius: 10px; margin-bottom: 8px; display: flex; overflow: hidden; }
.theme-card .sw span { flex: 1; }
.logo-preview { background: #fff; border: 1px dashed var(--border); border-radius: 14px; height: 120px; display: flex; align-items: center; justify-content: center; padding: 12px; }
.logo-preview img { max-height: 100%; max-width: 100%; object-fit: contain; }

/* Modal & toast */
.modal { position: fixed; inset: 0; background: rgba(5, 15, 30, .55); display: none; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal.show { display: flex; }
.modal-card { background: var(--surface); color: var(--text); border-radius: 18px; width: min(720px, 100%); max-height: 90vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.modal-head h3 { font-size: 17px; }
.modal-body { padding: 20px; }
.toast { position: fixed; bottom: 24px; inset-inline-start: 50%; transform: translateX(-50%) translateY(100px); background: var(--text); color: var(--surface); padding: 10px 20px; border-radius: 12px; font-weight: 600; z-index: 200; transition: transform .3s; }
[dir="rtl"] .toast { transform: translateX(50%) translateY(100px); }
.toast.show { transform: translateX(-50%) translateY(0); }
[dir="rtl"] .toast.show { transform: translateX(50%) translateY(0); }
.chart-box { position: relative; height: 280px; }
.empty { text-align: center; color: var(--muted); padding: 30px; }

/* ===================== Responsive ===================== */
@media (max-width: 1280px) {
  .pipeline { grid-template-columns: repeat(3, 1fr); }
  .g-4 { grid-template-columns: repeat(2, 1fr); }
  .search-box input { width: 180px; }
}
@media (max-width: 1024px) {
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; transform: translateX(-100%); transition: transform .3s; }
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 35; }
  .mobile-only { display: inline-flex; }
  .g-3 { grid-template-columns: repeat(2, 1fr); }
  .arch { grid-template-columns: 1fr; }
  .cross { flex-direction: row; flex-wrap: wrap; }
  .cross div { min-width: 140px; }
  .theme-cards { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 720px) {
  .topbar { padding: 12px 14px; flex-wrap: wrap; }
  .topbar-title h1 { font-size: 17px; }
  .topbar-actions { width: 100%; }
  .search-box { flex: 1; }
  .search-box input { width: 100%; }
  .content { padding: 16px 14px 40px; }
  .g-4, .g-3, .g-2 { grid-template-columns: 1fr; }
  .g-4.stats { grid-template-columns: 1fr 1fr; }
  .stat { flex-direction: column; align-items: flex-start; gap: 8px; }
  .stat-icon { width: 42px; height: 42px; font-size: 18px; }
  .stat-val { font-size: 22px; }
  .pipeline { grid-template-columns: 1fr 1fr; }
  .act-head { grid-template-columns: 48px 1fr 40px; }
  .act-head .hide-sm { display: none; }
  .act.open .act-body { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .hero { padding: 20px; }
  .hero h2 { font-size: 18px; }
  .ring { width: 96px; height: 96px; } .ring span { width: 74px; height: 74px; font-size: 19px; }
  .gantt2 { grid-template-columns: 110px minmax(420px, 1fr); }
  .gantt2 .gl small { display: none !important; }
  .theme-cards { grid-template-columns: repeat(2, 1fr); }
}
@media print {
  .sidebar, .topbar-actions, .btn, .sidebar-backdrop { display: none !important; }
  .view { display: block !important; page-break-after: always; }
  body { background: #fff; }
}
