:root {
  --bg: #f4f2ec; --panel: #ffffff; --ink: #14172a; --muted: #5d6275; --line: #e3e0d6; --soft: #f8f6f1;
  --navy: #0f1d3a; --navy-2: #172a52; --gold: #c9a046; --gold-ink: #8a6a1f; --gold-soft: #f6edd6;
  --ok: #1f8a5b; --ok-soft: #e2f4ea; --bad: #c2412d; --bad-soft: #fbe6e2; --warn: #b7791f;
  --radius: 14px; --shadow: 0 1px 2px rgba(20,23,42,.05), 0 8px 24px -12px rgba(20,23,42,.12);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1020; --panel: #121a30; --ink: #eef0f6; --muted: #9aa2b8; --line: #243051; --soft: #0f162b;
    --gold-ink: #e9c46a; --gold-soft: #2a2614; --ok-soft: #0f2a1f; --bad-soft: #3a1a16; --shadow: none;
  }
}
:root[data-theme="dark"] { --bg: #0b1020; --panel: #121a30; --ink: #eef0f6; --muted: #9aa2b8; --line: #243051; --soft: #0f162b; --gold-ink: #e9c46a; --gold-soft: #2a2614; --ok-soft: #0f2a1f; --bad-soft: #3a1a16; --shadow: none; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif; font-size: 15px; line-height: 1.55; }
a { color: var(--gold-ink); }
h1, h2, h3 { font-family: 'Readex Pro', 'IBM Plex Sans Arabic', sans-serif; margin: 0; line-height: 1.25; }
h1 { font-size: 26px; font-weight: 600; } h2 { font-size: 18px; font-weight: 600; } h3 { font-size: 15px; font-weight: 600; }
.num, input[type=number], input[type=time], .ltr { font-family: 'Readex Pro', sans-serif; font-variant-numeric: tabular-nums; }
.boot { padding: 80px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); } .small { font-size: 13px; }

/* shell */
.shell { display: flex; min-height: 100vh; flex-wrap: wrap; }
.side { width: 240px; flex-shrink: 0; background: var(--navy); color: #fff; padding: 22px 14px; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; font-family: 'Readex Pro', sans-serif; font-weight: 600; font-size: 17px; }
.brand svg { flex-shrink: 0; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: rgba(255,255,255,.78); text-decoration: none; font-weight: 500; min-height: 44px; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.on { background: rgba(233,196,106,.14); color: #f3d98e; }
.nav svg { width: 20px; height: 20px; flex-shrink: 0; }
.side .spacer { flex-grow: 1; }
.side .who { padding: 12px; font-size: 13px; color: rgba(255,255,255,.6); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.side .who button { background: transparent; border: 1px solid rgba(255,255,255,.2); color: #fff; border-radius: 8px; padding: 6px 10px; cursor: pointer; font: inherit; font-size: 13px; }
.main { flex: 999 1 560px; min-width: 0; padding: 28px 32px 60px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

@media (max-width: 860px) {
  .side { width: 100%; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; gap: 2px; }
  .brand { padding: 4px 6px; flex-grow: 1; }
  .nav { display: flex; flex-wrap: wrap; width: 100%; order: 3; }
  .nav a { padding: 8px 10px; font-size: 14px; }
  .side .spacer { display: none; }
  .side .who { padding: 4px; }
  .main { padding: 18px 16px 50px; }
}

/* cards & panels */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-pad { padding: 20px 22px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 22px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 22px; }
.stat { padding: 18px 20px; }
.stat .k { color: var(--muted); font-size: 13px; font-weight: 500; }
.stat .v { font-family: 'Readex Pro', sans-serif; font-size: 34px; font-weight: 600; margin-top: 2px; }
.stat .v small { font-size: 15px; color: var(--muted); font-weight: 500; }
.mosque-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.mcard { display: flex; flex-direction: column; gap: 14px; padding: 18px 20px; text-decoration: none; color: inherit; transition: transform .15s, box-shadow .15s; }
.mcard:hover { transform: translateY(-2px); box-shadow: 0 14px 30px -18px rgba(20,23,42,.35); }
.mcard .top { display: flex; gap: 14px; align-items: center; }
.mcard .badge { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; background: var(--navy); }
.mcard .name { font-family: 'Readex Pro', sans-serif; font-weight: 600; font-size: 17px; }
.mcard .meta { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 13px; flex-wrap: wrap; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: var(--soft); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.pill.gold { background: var(--gold-soft); color: var(--gold-ink); border-color: transparent; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }

/* buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 8px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #c9c4b4; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-2); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #1b1606; }
.btn.danger { color: var(--bad); }
.btn.sm { min-height: 34px; padding: 4px 12px; font-size: 13.5px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 18px; height: 18px; }
label.f { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; }
label.f .hint, .hint { font-weight: 400; color: var(--muted); font-size: 12.5px; }
input[type=text], input[type=password], input[type=number], input[type=time], input[type=url], input[type=date], select, textarea {
  width: 100%; min-height: 42px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: inherit; }
textarea { min-height: 90px; resize: vertical; line-height: 1.7; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.fields.five { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.section { padding: 20px 22px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 16px; }
.section:last-child { border-bottom: 0; }
.section-title { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.section-title .desc { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* toggle */
.tg { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; user-select: none; min-height: 32px; }
.tg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tg .sw { width: 44px; height: 26px; border-radius: 999px; background: #cfcabb; position: relative; transition: background .2s; flex-shrink: 0; }
.tg .sw::after { content: ''; position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.tg input:checked + .sw { background: var(--ok); }
.tg input:checked + .sw::after { transform: translateX(-18px); }
.tg input:focus-visible + .sw { outline: 2px solid var(--gold); outline-offset: 2px; }

/* segmented / radio cards */
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.choice { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border: 1.5px solid var(--line); border-radius: 12px; cursor: pointer; background: var(--panel); }
.choice input { position: absolute; opacity: 0; }
.choice b { font-family: 'Readex Pro', sans-serif; font-weight: 600; }
.choice span { color: var(--muted); font-size: 13px; }
.choice:has(input:checked) { border-color: var(--gold); background: var(--gold-soft); }
.choice:has(input:focus-visible) { outline: 2px solid var(--gold); }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.swatch { width: 40px; height: 40px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; padding: 0; box-shadow: inset 0 0 0 1px rgba(0,0,0,.1); }
.swatch.on { border-color: var(--ink); }

/* editor layout */
.editor { display: flex; gap: 22px; align-items: flex-start; flex-wrap: wrap; }
.editor .form { flex: 999 1 520px; min-width: 0; }
.editor .preview { flex: 1 1 440px; min-width: 0; max-width: 720px; position: sticky; top: 16px; }
@media (max-width: 1100px) { .editor .preview { position: static; max-width: none; } }
.tabs { display: flex; gap: 4px; overflow-x: auto; padding: 6px; border-bottom: 1px solid var(--line); }
.tabs button { flex-shrink: 0; border: 0; background: transparent; padding: 9px 14px; border-radius: 9px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; min-height: 40px; }
.tabs button.on { background: var(--navy); color: #fff; }
.tv-frame { position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: #000; box-shadow: 0 0 0 6px #1b1d22, 0 20px 40px -20px rgba(0,0,0,.6); }
.tv-frame iframe { position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; border: 0; transform-origin: top left; pointer-events: none; }
html[dir=rtl] .tv-frame iframe { right: auto; }
.preview .controls { padding: 16px 4px 0; display: flex; flex-direction: column; gap: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 6px 13px; font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; min-height: 36px; color: var(--ink); }
.chip.on { background: var(--gold); border-color: var(--gold); color: #1b1606; }
.timebar { display: flex; gap: 10px; align-items: center; }
.timebar input[type=range] { flex-grow: 1; accent-color: var(--gold); }
.times-strip { display: grid; grid-template-columns: repeat(6, minmax(0,1fr)); gap: 6px; text-align: center; font-size: 12.5px; }
.times-strip div { background: var(--soft); border: 1px solid var(--line); border-radius: 8px; padding: 6px 2px; }
.times-strip b { display: block; font-family: 'Readex Pro', sans-serif; font-size: 15px; }
.savebar { position: sticky; bottom: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 22px; background: var(--panel); border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); flex-wrap: wrap; }
.dirty { color: var(--warn); font-weight: 600; font-size: 13.5px; }

/* calendar grid */
.cal-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table.cal { border-collapse: collapse; width: 100%; min-width: 620px; }
table.cal th, table.cal td { border-bottom: 1px solid var(--line); padding: 3px 4px; text-align: center; }
table.cal th { background: var(--soft); font-size: 13px; padding: 8px 4px; position: sticky; top: 0; }
table.cal td:first-child { font-family: 'Readex Pro', sans-serif; color: var(--muted); width: 44px; }
table.cal input { min-height: 32px; padding: 2px 4px; text-align: center; border-radius: 6px; border-color: transparent; background: transparent; font-family: 'Readex Pro', sans-serif; }
table.cal input:hover { border-color: var(--line); }
table.cal input.err { background: var(--bad-soft); }
table.cal tr.today td { background: var(--gold-soft); }
.month-tabs { display: flex; flex-wrap: wrap; gap: 6px; }

/* tables */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; min-width: 760px; }
table.tbl th { text-align: right; font-size: 12.5px; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--soft); }
table.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: 0; }

/* content lists */
.items { display: flex; flex-direction: column; gap: 10px; }
.item { display: grid; grid-template-columns: minmax(0, 1fr) 170px 80px auto; gap: 10px; align-items: start; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--soft); }
.item.h { grid-template-columns: minmax(0, 1fr) 190px auto; }
.item textarea { min-height: 64px; font-family: 'Amiri', serif; font-size: 19px; }
@media (max-width: 700px) { .item, .item.h { grid-template-columns: 1fr; } }

/* dialog */
dialog { border: 0; border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 32px)); background: var(--panel); color: var(--ink); box-shadow: 0 30px 80px -20px rgba(0,0,0,.5); }
dialog::backdrop { background: rgba(10,14,30,.55); }
dialog .dh { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
dialog .db { padding: 20px 22px; display: flex; flex-direction: column; gap: 14px; }
dialog .df { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-start; }
.shot { width: 100%; border-radius: 10px; background: #000; display: block; }
.code-input { font-family: 'Readex Pro', sans-serif; font-size: 34px !important; letter-spacing: 10px; text-align: center; direction: ltr; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(ellipse at 50% 0%, #22366a 0%, #0f1d3a 55%, #0a1226 100%); }
.login .box { width: min(420px, 100%); background: var(--panel); border-radius: 20px; padding: 34px 30px; display: flex; flex-direction: column; gap: 18px; box-shadow: 0 40px 80px -30px rgba(0,0,0,.6); }
.login .logo { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.err-box { background: var(--bad-soft); color: var(--bad); padding: 10px 14px; border-radius: 10px; font-weight: 600; font-size: 14px; }
#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--navy); color: #fff; padding: 12px 22px; border-radius: 12px; font-weight: 600; opacity: 0; pointer-events: none; transition: all .25s; z-index: 50; max-width: calc(100vw - 32px); }
#toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.bad { background: var(--bad); }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.log { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; max-height: 320px; overflow: auto; direction: ltr; text-align: left; background: var(--soft); border-radius: 10px; padding: 10px 12px; white-space: pre-wrap; }
input[type=number], input[type=time], input[type=url], input[type=date] { direction: ltr; text-align: right; }
table.tbl td.dev { max-width: 260px; }
table.tbl td.dev div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* screen binding code */
.center { text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.bigcode { font-size: 64px; font-weight: 700; letter-spacing: 8px; color: var(--gold-ink); background: var(--gold-soft); border-radius: 18px; padding: 10px 28px; line-height: 1.2; }
button.pill { cursor: pointer; font-family: inherit; }
button.pill:hover { filter: brightness(.96); }
