@font-face { font-family: 'Inter'; src: url('fonts/inter_regular.ttf') format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('fonts/inter_medium.ttf') format('truetype'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('fonts/inter_bold.ttf') format('truetype'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('fonts/inter_extrabold.ttf') format('truetype'); font-weight: 800; font-display: swap; }
@font-face { font-family: 'Tajawal'; src: url('fonts/tajawal_regular.ttf') format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Tajawal'; src: url('fonts/tajawal_medium.ttf') format('truetype'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Tajawal'; src: url('fonts/tajawal_bold.ttf') format('truetype'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Tajawal'; src: url('fonts/tajawal_extrabold.ttf') format('truetype'); font-weight: 800; font-display: swap; }

:root {
  --radius: 12px; --green: #22c55e; --amber: #f59e0b; --blue: #3b82f6;
  /* the app's fonts: Inter for English, Tajawal for Arabic */
  --font: "Inter", "Tajawal", system-ui, sans-serif;
}
/* ---------- themes: the app's three looks, each in dark and light */
:root, [data-theme="gold"] {
  --bg: #0d0b08; --panel: #13100c; --panel2: #1b1712; --line: #2e271f; --text: #fbf5ea; --muted: #b3a48c; --red: #d9a84e; --red2: #e8bd6a; --on-accent: #1a1206; --glow: #33250f;
}
[data-theme="cinema"] {
  --bg: #0b0b0b; --panel: #121212; --panel2: #1b1b1b; --line: #2a2a2a; --text: #ffffff;
  --muted: #a3a3a3; --red: #e50914; --red2: #ff3b45; --on-accent: #ffffff; --glow: #2a0e10;
}
[data-theme="midnight"] {
  --bg: #070d17; --panel: #0b1422; --panel2: #111d30; --line: #1f2f47; --text: #f1f5fb;
  --muted: #a6b6cc; --red: #1f8bff; --red2: #4aa3ff; --on-accent: #ffffff; --glow: #0b2a50;
}
[data-mode="light"][data-theme="gold"], [data-mode="light"]:not([data-theme]) {
  --bg: #f7f3ec; --panel: #ffffff; --panel2: #f2ece1; --line: #e3dacb; --text: #1d1710;
  --muted: #7a6d5a; --red: #a87a2a; --red2: #c08f37; --on-accent: #ffffff; --glow: #f3e3c4;
}
[data-mode="light"][data-theme="cinema"] {
  --bg: #f5f5f5; --panel: #ffffff; --panel2: #efefef; --line: #e1e1e1; --text: #141414;
  --muted: #6b6b6b; --red: #d40812; --red2: #e50914; --on-accent: #ffffff; --glow: #fde2e3;
}
[data-mode="light"][data-theme="midnight"] {
  --bg: #f2f6fb; --panel: #ffffff; --panel2: #e9eff7; --line: #d7e0ed; --text: #0e1a2b;
  --muted: #5f7088; --red: #1768d6; --red2: #1f8bff; --on-accent: #ffffff; --glow: #dbe9fb;
}
:root { --tint: color-mix(in srgb, var(--red) 14%, transparent); --hover: color-mix(in srgb, var(--text) 5%, transparent);
  --shade: color-mix(in srgb, #000 55%, transparent); }
[data-mode="light"] { --shade: color-mix(in srgb, #0f172a 22%, transparent); }
* { box-sizing: border-box; }
html[lang="ar"] { --font: "Tajawal", "Inter", system-ui, sans-serif; }
html, body { margin: 0; background: var(--bg); transition: background .25s, color .25s; color: var(--text); font: 14px/1.5 var(--font); }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

/* ---------- login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; display: grid; gap: 14px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: .3px; }
.brand .dot { width: 26px; height: 18px; border-radius: 4px; background: var(--red); box-shadow: 0 0 16px color-mix(in srgb, var(--red) 45%, transparent); }

/* ---------- layout */
.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-inline-end: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.side .brand { padding: 4px 10px 16px; }
.side a { display: flex; justify-content: space-between; align-items: center; padding: 9px 12px; border-radius: 9px; text-decoration: none; color: var(--muted); font-weight: 600; }
.side a:hover { background: var(--panel2); color: var(--text); }
.side a.on { background: var(--tint); color: var(--text); box-shadow: inset 3px 0 0 var(--red); }
[dir="rtl"] .side a.on { box-shadow: inset -3px 0 0 var(--red); }
.side .grow { flex: 1; }
.side .who { color: var(--muted); font-size: 12px; padding: 6px 12px; }
.pill { margin-inline-start: 6px; background: var(--red); color: var(--on-accent); border-radius: 99px; padding: 0 7px; font-size: 11px; line-height: 18px; }
main { padding: 26px 30px 60px; min-width: 0; }
h1 { font-size: 22px; margin: 0 0 4px; }
.sub { color: var(--muted); margin: 0 0 20px; max-width: 760px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }

/* ---------- cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 22px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card .n { font-size: 28px; font-weight: 800; }
.card .l { color: var(--muted); font-size: 12px; }
.card.click { cursor: pointer; }
.card.click:hover { border-color: var(--red); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.box h3 { margin: 0 0 10px; font-size: 15px; }

/* ---------- forms */
input, select, textarea { background: var(--panel2); border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; width: 100%; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--red); }
label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; font-weight: 600; }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.form .full { grid-column: 1 / -1; }
.btn { background: var(--panel2); border: 1px solid var(--line); border-radius: 9px; padding: 8px 14px; font-weight: 700; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.red { background: var(--red); border-color: var(--red); color: var(--on-accent); }
.btn.red:hover { background: var(--red2); }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.danger { color: #ff7a80; }
.btn:disabled { opacity: .5; cursor: default; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: transparent; border-radius: 99px; padding: 5px 12px; color: var(--muted); font-weight: 600; }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.err { color: #ff7a80; font-weight: 600; min-height: 20px; }
.pw { display: flex; gap: 6px; }

/* ---------- tables */
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: start; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: 12px; font-weight: 700; background: var(--panel2); position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: var(--hover); }
td.check, th.check { width: 36px; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--red); }
.badge { display: inline-block; border-radius: 99px; padding: 1px 9px; font-size: 12px; font-weight: 700; }
.b-green { background: #22c55e22; color: #4ade80; }
.b-red { background: #ef444424; color: #ff7a80; }
.b-amber { background: #f59e0b22; color: #fbbf24; }
.b-grey { background: var(--hover); color: var(--muted); }
.b-blue { background: #3b82f622; color: #93c5fd; }
.mono { font-family: "Inter", ui-monospace, Consolas, monospace; letter-spacing: 1px; font-weight: 700; }
.muted { color: var(--muted); }
.code-big { font-family: "Inter", ui-monospace, Consolas, monospace; font-size: 20px; letter-spacing: 3px; font-weight: 800; color: var(--text); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); display: inline-block; box-shadow: 0 0 0 0 color-mix(in srgb, var(--red) 65%, transparent); animation: pulse 1.6s infinite; margin-inline-end: 6px; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* ---------- bulk bar */
.bulk { position: sticky; bottom: 14px; margin-top: 14px; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; box-shadow: 0 10px 30px var(--shade); }

/* ---------- modal */
.overlay { position: fixed; inset: 0; background: var(--shade); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { width: min(760px, 100%); max-height: 92vh; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 22px; }
.modal h2 { margin: 0 0 14px; font-size: 18px; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

#toast { position: fixed; bottom: 20px; inset-inline-start: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 10px; font-weight: 700; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 60; }
[dir="rtl"] #toast { transform: translateX(50%); }
#toast.show { opacity: 1; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; }
  .side .grow, .side .brand { display: none; }
  main { padding: 18px 16px 60px; }
  .grid2, .form { grid-template-columns: 1fr; }
}

/* light mode: badge text dark enough to read on white */
[data-mode="light"] .b-green { color: #15803d; } [data-mode="light"] .b-red { color: #b91c1c; }
[data-mode="light"] .b-amber { color: #b45309; } [data-mode="light"] .b-blue { color: #1d4ed8; }
[data-mode="light"] .err, [data-mode="light"] .btn.danger { color: #b91c1c; }
.login { background: radial-gradient(circle at 50% 30%, var(--glow), var(--bg) 70%); }

/* ---------- theme bar (top corner): the three looks + light / dark */
.themebar { position: fixed; top: 12px; inset-inline-end: 14px; z-index: 40; display: flex; align-items: center; gap: 6px;
  background: color-mix(in srgb, var(--panel) 88%, transparent); border: 1px solid var(--line); border-radius: 99px; padding: 5px 6px;
  backdrop-filter: blur(8px); box-shadow: 0 6px 20px var(--shade); }
.themebar .sw { width: 22px; height: 22px; border-radius: 50%; border: 2px solid transparent; padding: 0; cursor: pointer; position: relative; }
.themebar .sw::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--c); }
.themebar .sw.on { border-color: var(--text); }
.themebar .sep { width: 1px; height: 18px; background: var(--line); margin: 0 3px; }
.themebar .mode { width: 30px; height: 26px; border-radius: 99px; border: 0; background: var(--panel2); color: var(--text); display: grid; place-items: center; cursor: pointer; }
.themebar .mode:hover, .themebar .sw:hover { transform: scale(1.08); }
.themebar svg { width: 16px; height: 16px; }
main { padding-top: 58px; }
