/* RapidRC Studio admin — tokens from the RapidRC Studio design system */
:root {
  --brand: #1D4ED8; --brand-strong: #163FB0; --brand-soft: #E6EDFD;
  --accent: #F28C28; --navy: #0E1F3F;
  --ink: #0F172A; --ink-muted: #475569;
  --surface: #FFFFFF; --surface-alt: #F3F5F8; --head: #F3F5F8;
  --line: #D5DBE3; --line-strong: #7C8899;
  --on-brand: #FFFFFF; --link: #1D4ED8;
  --ok: #15803D; --ok-bg: #DCFCE7; --warn: #B45309; --warn-bg: #FEF3C7;
  --bad: #B91C1C; --bad-bg: #FEE2E2; --neu: #475569; --neu-bg: #EEF1F5;
  --shadow-card: 0 1px 2px rgba(15,23,42,.06), 0 4px 12px rgba(15,23,42,.06);
  --shadow-pop: 0 12px 32px rgba(15,23,42,.18);
  --card-border: transparent;
  --r-sm: 6px; --r-md: 10px; --r-lg: 16px;
  --sans: Inter, "Segoe UI", system-ui, sans-serif;
  --arabic: "IBM Plex Sans Arabic", Tahoma, sans-serif;
  --mono: "JetBrains Mono", Consolas, monospace;
  color-scheme: light;
}
[data-theme="dark"] {
  --brand: #2F62E8; --brand-strong: #5B85F2; --brand-soft: #16264A;
  --accent: #F59A3F;
  --ink: #E8EDF7; --ink-muted: #A3B0C8;
  --surface: #111C33; --surface-alt: #0B1426; --head: #0E1A31;
  --line: #2A3A5C; --line-strong: #6477A0; --link: #8FB0FF;
  --ok: #4ADE80; --ok-bg: #123326; --warn: #FBBF24; --warn-bg: #3A2E10;
  --bad: #F87171; --bad-bg: #3B1A1F; --neu: #A3B0C8; --neu-bg: #1B2846;
  --shadow-card: none; --card-border: #2A3A5C;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--sans); font-size: 15px; line-height: 22px; background: var(--surface-alt); color: var(--ink); -webkit-font-smoothing: antialiased; }
[lang="ar"] body, body[dir="rtl"] { font-family: var(--arabic), var(--sans); }
a { color: var(--link); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-muted); }
.ltr { direction: ltr; unicode-bidi: embed; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { border-color: var(--ink-muted); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger-text { color: var(--bad); }
.btn.lg { height: 44px; padding: 0 18px; font-size: 15px; }
.btn.sm { height: 32px; padding: 0 10px; font-size: 13px; }
.btn.icon { width: 36px; padding: 0; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-muted); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.linkbtn { border: 0; background: none; padding: 0; color: var(--link); font-weight: 600; font-size: 13px; cursor: pointer; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-muted); }
.field .hint { font-weight: 400; }
.input { height: 40px; width: 100%; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); font-size: 15px; font-weight: 400; }
textarea.input { height: auto; min-height: 90px; padding: 8px 12px; resize: vertical; }
.input.code { height: 52px; text-align: center; font-family: var(--mono); font-size: 24px; letter-spacing: 8px; }
.pw { position: relative; display: block; }
.pw .input { padding-inline-end: 44px; }
.pw .eye { position: absolute; inset-inline-end: 4px; top: 4px; width: 32px; height: 32px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--ink-muted); display: grid; place-items: center; cursor: pointer; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--brand); }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg button { height: 40px; padding: 0 14px; border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font-size: 14px; font-weight: 600; cursor: pointer; }
.seg button[aria-checked="true"] { border-color: var(--brand); background: var(--brand-soft); color: var(--link); }
.switch { width: 48px; height: 28px; border-radius: 999px; border: 0; padding: 3px; background: var(--line-strong); display: flex; cursor: pointer; flex: none; }
.switch::after { content: ""; width: 22px; height: 22px; border-radius: 999px; background: #fff; }
.switch[aria-checked="true"] { background: var(--brand); justify-content: flex-end; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); } .badge.ok::before { content: ""; width: 6px; height: 6px; border-radius: 99px; background: currentColor; }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.neu { background: var(--neu-bg); color: var(--neu); }
.badge.brand { background: var(--brand-soft); color: var(--link); }

/* ---------- layout ---------- */
.app { min-height: 100vh; display: flex; flex-wrap: wrap; }
.side { flex: 1 1 248px; max-width: 280px; min-width: 220px; background: var(--navy); padding: 20px 14px; display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brandline { display: flex; align-items: center; gap: 10px; padding: 4px 8px; color: #fff; font-size: 18px; letter-spacing: -.3px; white-space: nowrap; }
.brandline img { width: 38px; height: 38px; }
.brandline b { font-weight: 800; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 0 12px; border-radius: var(--r-sm); text-decoration: none; font-size: 14px; font-weight: 500; color: #C3CEE3; position: relative; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a[aria-current="page"] { background: #1D4ED8; color: #fff; font-weight: 600; }
.nav .count { margin-inline-start: auto; background: var(--accent); color: #0F172A; border-radius: 999px; font-size: 11px; font-weight: 700; padding: 0 7px; line-height: 18px; }
.me { margin-top: auto; border-top: 1px solid #24365E; padding: 14px 8px 0; display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 999px; background: var(--accent); color: #0F172A; display: grid; place-items: center; font-weight: 800; font-size: 14px; flex: none; }
.me .who { min-width: 0; flex: 1; }
.me .who div:first-child { color: #fff; font-size: 13px; font-weight: 600; }
.me .who div:last-child { color: #A3B0C8; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me .btn.ghost { color: #C3CEE3; }
.main { flex: 999 1 640px; min-width: 0; padding: 28px 32px 48px; display: flex; flex-direction: column; gap: 24px; }
.topbar { display: none; }
.pagehead { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pagehead .titles { flex: 1 1 240px; min-width: 0; }
h1 { margin: 0; font-size: 28px; line-height: 34px; font-weight: 800; letter-spacing: -.4px; }
h2 { margin: 0; font-size: 18px; line-height: 26px; font-weight: 700; }
h3 { margin: 0; font-size: 15px; line-height: 22px; font-weight: 700; }
.sub { margin: 4px 0 0; font-size: 13px; color: var(--ink-muted); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.search { position: relative; flex: 0 1 300px; }
.search svg { position: absolute; inset-inline-start: 10px; top: 9px; color: var(--ink-muted); }
.search .input { height: 36px; padding-inline-start: 36px; font-size: 14px; }
.card { background: var(--surface); border-radius: var(--r-md); box-shadow: var(--shadow-card); border: 1px solid var(--card-border); }
.card.pad { padding: 20px 22px; }
.cardhead { display: flex; align-items: center; gap: 12px; padding: 16px 20px; flex-wrap: wrap; }
.cardhead h2 { flex: 1; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; }
.kpi { padding: 20px 22px; display: flex; flex-direction: column; gap: 4px; }
.kpi .lab { font-size: 13px; font-weight: 600; color: var(--ink-muted); }
.kpi .val { font-size: 34px; line-height: 40px; font-weight: 800; letter-spacing: -.6px; font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.grow { flex: 999 1 600px; min-width: 0; }
.aside { flex: 1 1 320px; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tabs button { height: 36px; padding: 0 14px; border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font-size: 13px; font-weight: 600; cursor: pointer; }
.tabs button[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); color: var(--link); }
.tabs .n { font-weight: 500; margin-inline-start: 4px; }

/* ---------- tables ---------- */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: start; padding: 10px 14px; font-size: 12.5px; font-weight: 600; color: var(--ink-muted); background: var(--head); border-bottom: 1px solid var(--line); white-space: nowrap; }
td { text-align: start; padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: var(--head); }
tbody tr.sel { background: var(--brand-soft); }
.cell2 div:first-child { font-weight: 600; }
.cell2 div:last-child { font-size: 12.5px; color: var(--ink-muted); }
.copyable { display: inline-flex; align-items: center; gap: 4px; }
.copy { width: 26px; height: 26px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--ink-muted); display: inline-grid; place-items: center; cursor: pointer; flex: none; }
.copy:hover { background: var(--head); color: var(--ink); }
.empty { padding: 40px 20px; text-align: center; color: var(--ink-muted); }

/* ---------- alerts list ---------- */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 14px 0; border-top: 1px solid var(--line); }
.alert .ic { flex: none; padding-top: 1px; }
.alert .ic.bad { color: var(--bad); } .alert .ic.warn { color: var(--warn); }
.alert .t { font-size: 14px; font-weight: 600; } .alert .d { font-size: 12.5px; color: var(--ink-muted); margin-top: 2px; }

/* ---------- drawer & dialog ---------- */
.drawer { padding: 20px; display: flex; flex-direction: column; gap: 18px; }
.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; font-size: 13px; }
.kv div div:first-child { color: var(--ink-muted); } .kv div div:last-child { font-weight: 600; }
.lic { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.scrim { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; overflow-y: auto; }
.dialog { width: 100%; max-width: 620px; background: var(--surface); border-radius: var(--r-md); box-shadow: var(--shadow-pop); padding: 28px; display: flex; flex-direction: column; gap: 18px; }
.dialog.small { max-width: 440px; }
.dialoghead { display: flex; align-items: center; gap: 8px; }
.dialoghead h2 { flex: 1; font-size: 20px; }
.result { border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px; display: flex; flex-direction: column; gap: 12px; background: var(--surface-alt); }
.bigcode { font-family: var(--mono); font-size: 26px; font-weight: 500; letter-spacing: 4px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

/* ---------- settings ---------- */
.setgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; align-items: start; }
.setrow { display: flex; align-items: center; gap: 16px; padding: 14px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.setrow .lbl { flex: 1 1 260px; } .setrow .lbl div:first-child { font-size: 14px; font-weight: 600; } .setrow .lbl div:last-child { font-size: 13px; color: var(--ink-muted); margin-top: 2px; }
.setrow .input { width: 120px; }
.unit { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-muted); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: flex; flex-wrap: wrap; }
.login aside { flex: 1 1 420px; background: #1D4ED8; color: #fff; padding: 56px 64px; display: flex; flex-direction: column; justify-content: space-between; gap: 48px; }
.login aside h1 { font-size: 40px; line-height: 44px; letter-spacing: -.8px; }
.login aside .rule { height: 4px; width: 64px; background: #F28C28; }
.login aside p { margin: 0; font-size: 17px; line-height: 26px; color: #DCE5FD; max-width: 460px; }
.login aside small { font-size: 13px; color: #C7D5FB; }
.login main { flex: 999 1 520px; min-width: 0; display: flex; flex-direction: column; padding: 24px; }
.login .tools { display: flex; justify-content: flex-end; gap: 8px; }
.login .center { flex: 1; display: flex; align-items: center; justify-content: center; padding: 32px 0; }
.login form { width: 100%; max-width: 420px; background: var(--surface); border-radius: var(--r-md); box-shadow: var(--shadow-card); border: 1px solid var(--card-border); padding: 36px; display: flex; flex-direction: column; gap: 20px; }
.login form p { margin: 0; color: var(--ink-muted); }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.err { color: var(--bad); font-size: 13px; font-weight: 600; min-height: 18px; }

/* ---------- toast ---------- */
.toasts { position: fixed; inset-inline-end: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--navy); color: #fff; padding: 12px 16px; border-radius: var(--r-sm); box-shadow: var(--shadow-pop); font-size: 14px; max-width: 360px; }
.toast.bad { background: var(--bad); }

.spinner { width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 99px; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

/* ---------- phone ---------- */
@media (max-width: 760px) {
  .side { display: none; }
  .topbar { display: flex; align-items: center; gap: 10px; width: 100%; background: var(--navy); color: #fff; padding: 12px 14px; position: sticky; top: 0; z-index: 20; }
  .topbar img { width: 32px; height: 32px; }
  .topbar .name { flex: 1; font-size: 16px; } .topbar b { font-weight: 800; }
  .topbar .btn.ghost { color: #C3CEE3; width: 44px; height: 44px; }
  .main { padding: 18px 16px 96px; gap: 18px; }
  .tabbar { position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--line); display: flex; padding: 0 8px env(safe-area-inset-bottom); z-index: 30; }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0; min-height: 52px; text-decoration: none; font-size: 11px; font-weight: 600; color: var(--ink-muted); }
  .tabbar a[aria-current="page"] { color: var(--link); }
  .setgrid { grid-template-columns: 1fr; }
  .login aside { padding: 32px 24px; gap: 24px; } .login aside h1 { font-size: 30px; line-height: 36px; }
  .login form { padding: 24px; }
  .dialog { padding: 20px; }
  h1 { font-size: 24px; line-height: 30px; }
}
@media (min-width: 761px) { .tabbar { display: none; } }
.menu-sheet .nav a { color: var(--ink); } .menu-sheet .nav a[aria-current="page"] { color: #fff; }
@media (max-width: 760px) {
  .pagehead > [data-act="lang"], .pagehead > [data-act="theme"] { display: none; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 14px 16px; } .kpi .val { font-size: 28px; line-height: 34px; }
  .search { flex: 1 1 100%; }
}

/* programs, campaigns */
.prodgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.prod { display: flex; flex-direction: column; gap: 14px; }
.plogo { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; flex: none; background: var(--surface-alt); }
.plogo.letter { display: inline-grid; place-items: center; background: var(--navy, #0E1F3F); color: #fff; font-weight: 700; font-size: 18px; }
label.btn { cursor: pointer; }
.prog { display: inline-block; width: 90px; height: 6px; border-radius: 99px; background: var(--surface-alt); overflow: hidden; vertical-align: middle; }
.prog i { display: block; height: 100%; background: var(--brand); }
.campgrid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.campgrid .preview { position: sticky; top: 16px; }
#cFrame { width: 100%; height: 640px; border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff; }
.hlbox { display: flex; flex-direction: column; gap: 8px; }
.hlrow { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr) auto; gap: 8px; align-items: center; }
@media (max-width: 1100px) { .campgrid { grid-template-columns: 1fr; } .campgrid .preview { position: static; } #cFrame { height: 520px; } }
@media (max-width: 760px) { .hlrow { grid-template-columns: 1fr auto; } .hlrow input:nth-child(2) { grid-column: 1; } .prodgrid { grid-template-columns: 1fr; } }
