/* سايبر زون — one sheet for every staff screen and the customers' page.
   Four colour sets the owner picks in «الإعدادات ← المميزات والشكل» (data-theme on <html>). Every colour below is a
   variable, so a set is only its own values; a theme card that carries data-theme previews itself.
   Phone first where it matters: below 760px the menu moves to a bottom bar, tables scroll inside their card,
   menus open as bottom sheets. */

@font-face {
  font-family: "Cairo";
  font-weight: 200 1000;
  font-display: swap;
  src: url("../fonts/cairo/cairo-arabic.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+200C-200E, U+2010-2011, U+FB50-FDFF, U+FE70-FEFC;
}
@font-face {
  font-family: "Cairo";
  font-weight: 200 1000;
  font-display: swap;
  src: url("../fonts/cairo/cairo-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212;
}

/* «ليلي»: navy and a sky-blue accent, calm in a dim shop. The default. */
:root, [data-theme="night"] {
  color-scheme: dark;
  --bg: #0a0f1d;
  --panel: #111a2e;
  --panel-2: #16213a;
  --field: #0c1426;
  --sunken: #0d1529;
  --line: #24314f;
  --line-soft: #1b2640;
  --ink: #e9eef8;
  --ink-2: #c3cde0;
  --muted: #94a2c0;
  --accent: #22d3ee;
  --accent-ink: #052a33;
  --accent-2: #a78bfa;
  --logo-ink: #071018;
  --free: #22c55e;
  --busy: #3b82f6;
  --warn: #f59e0b;
  --held: #a78bfa;
  --off: #64748b;
  --danger: #ef4444;
  --up: #34d399;
  --down: #f87171;
  --go: #22c55e;
  --go-ink: #052e14;
  --ok-ink: #86efac;
  --warn-ink: #fcd34d;
  --bad-ink: #fca5a5;
  --bar-bg: rgba(10, 15, 29, .92);
  --hover: rgba(255, 255, 255, .03);
  --scrim: rgba(3, 6, 14, .62);
  --shadow: rgba(0, 0, 0, .45);
  /* chart series, validated (dataviz validator) against each theme's --panel: CVD ΔE ≥ 9.4, normal ≥ 26.5, contrast ≥ 3:1 */
  --s1: #3987e5;
  --s2: #d95926;
  --s3: #199e70;
  --s4: #a86ee0;
  --radius: 12px;
  --font: "Cairo", "Segoe UI", Tahoma, sans-serif;
  --bar-h: 64px;
}

/* «أرينا»: deep violet with a lilac accent; a booked device shows pink so it never reads as the accent. */
[data-theme="arena"] {
  color-scheme: dark;
  --bg: #110c1e;
  --panel: #19132c;
  --panel-2: #211a3a;
  --field: #140f25;
  --sunken: #150f27;
  --line: #352a5c;
  --line-soft: #271f47;
  --ink: #f1ecfd;
  --ink-2: #d2c9ea;
  --muted: #a69bc8;
  --accent: #b794ff;
  --accent-ink: #1e0b47;
  --accent-2: #f472b6;
  --logo-ink: #1e0b47;
  --held: #f472b6;
  --off: #6b6489;
  --bar-bg: rgba(17, 12, 30, .92);
  --scrim: rgba(8, 4, 18, .66);
}

/* «نيون»: almost black with a pink accent. */
[data-theme="neon"] {
  color-scheme: dark;
  --bg: #08080e;
  --panel: #12121c;
  --panel-2: #191926;
  --field: #0d0d16;
  --sunken: #0e0e17;
  --line: #2a2a3d;
  --line-soft: #1e1e2d;
  --ink: #f3f3fa;
  --ink-2: #cfcfe0;
  --muted: #9d9db8;
  --accent: #ff4fa3;
  --accent-ink: #2b0016;
  --accent-2: #7c5cff;
  --logo-ink: #16000c;
  --held: #a78bfa;
  --off: #5f5f78;
  --bar-bg: rgba(8, 8, 14, .92);
  --scrim: rgba(0, 0, 0, .7);
}

/* «نهاري»: light, for a phone in daylight and for printing. Darker steps of the same state colours. */
[data-theme="day"] {
  color-scheme: light;
  --bg: #eef2f7;
  --panel: #ffffff;
  --panel-2: #f4f6fa;
  --field: #ffffff;
  --sunken: #f7f9fc;
  --line: #d3dae5;
  --line-soft: #e4e9f0;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #5a6577;
  --accent: #0e7490;
  --accent-ink: #ffffff;
  --accent-2: #7c3aed;
  --logo-ink: #ffffff;
  --free: #16a34a;
  --busy: #2563eb;
  --warn: #d97706;
  --held: #7c3aed;
  --off: #7b8698;
  --danger: #dc2626;
  --up: #15803d;
  --down: #dc2626;
  --go: #15803d;
  --go-ink: #ffffff;
  --ok-ink: #15803d;
  --warn-ink: #b45309;
  --bad-ink: #b91c1c;
  --bar-bg: rgba(255, 255, 255, .92);
  --hover: rgba(15, 23, 42, .035);
  --scrim: rgba(15, 23, 42, .45);
  --shadow: rgba(15, 23, 42, .16);
  --s1: #2563eb;
  --s2: #d9480f;
  --s3: #0e8a62;
  --s4: #8b4fd6;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0 0 2px; font-weight: 800; letter-spacing: -.2px; }
h2 { font-size: 17px; margin: 0 0 10px; font-weight: 700; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- shell ---------- */
.bar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 16px;
  padding: 8px 18px;
  background: var(--bar-bg);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 800; font-size: 17px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.logo {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--logo-ink); font-size: 13px; font-weight: 900;
}
.nav { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; }
.nav a { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); padding: 6px 10px; border-radius: 9px; font-weight: 600; }
.nav a:hover { color: var(--ink); background: var(--panel); text-decoration: none; }
.nav a.on { color: var(--ink); background: var(--panel-2); box-shadow: inset 0 -2px 0 var(--accent); }
.who { display: flex; align-items: center; gap: 10px; color: var(--muted); margin: 0; white-space: nowrap; }
.chip.sync { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.chip.sync .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.page { max-width: 1400px; margin: 0 auto; padding: 18px; }
.tabbar, .sheet { display: none; }

/* The menu keeps one line: as many entries as the width holds, the rest under «المزيد» (the page you are on always
   stays in the bar). Same idea as the phone's bottom bar. */
.nav { flex-wrap: nowrap; align-items: center; min-width: 0; }
.nav > a { white-space: nowrap; }
.nav-more > summary { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); padding: 6px 10px; border-radius: 9px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.nav-more > summary:hover { color: var(--ink); background: var(--panel); }
.nav-more .more-menu { min-width: 230px; }
.nav > a:nth-of-type(n+10), .nav-more .sheet-item:nth-of-type(-n+9) { display: none; }
.nav-more:not(:has(.sheet-item:nth-of-type(10))) { display: none; }
@media (max-width: 1399px) {
  .nav > a:nth-of-type(n+8) { display: none; }
  .nav-more .sheet-item:nth-of-type(n+8) { display: flex; }
  .nav-more:has(.sheet-item:nth-of-type(8)) { display: block; }
}
@media (max-width: 1179px) {
  .nav > a:nth-of-type(n+6) { display: none; }
  .nav-more .sheet-item:nth-of-type(n+6) { display: flex; }
  .nav-more:has(.sheet-item:nth-of-type(6)) { display: block; }
}
@media (max-width: 959px) {
  .nav > a:nth-of-type(n+5) { display: none; }
  .nav-more .sheet-item:nth-of-type(n+5) { display: flex; }
  .nav-more:has(.sheet-item:nth-of-type(5)) { display: block; }
  .brand-name, .who > span { display: none; }
}
.nav > a.on { display: inline-flex !important; }
.nav-more .sheet-item.on { display: none !important; }

.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.head .tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- messages and the next step ---------- */
.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; font-weight: 600; }
.flash.ok { background: color-mix(in srgb, var(--free) 12%, transparent); border: 1px solid color-mix(in srgb, var(--free) 40%, transparent); color: var(--ok-ink); }
.flash.err { background: color-mix(in srgb, var(--danger) 12%, transparent); border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent); color: var(--bad-ink); }
.next {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 14px; margin-bottom: 14px; border-radius: var(--radius);
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 12%, transparent), color-mix(in srgb, var(--accent-2) 8%, transparent));
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}
.next b { color: var(--accent); }
.next .btn { margin-inline-start: auto; }

/* ---------- cards, tables, forms ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.card + .card { margin-top: 14px; }
.card.narrow { max-width: 460px; margin: 40px auto; }
.grid { display: grid; gap: 14px; }
.grid > .card + .card { margin-top: 0; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-inline: -4px; padding-inline: 4px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; text-align: start; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 13px; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--hover); }
td.money, th.money { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.plus { color: var(--up); }
.minus { color: var(--down); }

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
input, select, textarea {
  width: 100%; padding: 9px 11px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--field); color: var(--ink);
  font: inherit; min-height: 40px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
input[type=checkbox] { width: auto; min-height: 0; accent-color: var(--accent); transform: scale(1.15); }
.check { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 15px; font-weight: 500; margin: 0; min-height: 32px; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > .field { flex: 1 1 150px; margin-bottom: 0; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 3px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 16px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--ink); font: inherit; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.go { background: var(--go); color: var(--go-ink); border-color: var(--go); }
.btn.danger { background: transparent; color: var(--bad-ink); border-color: color-mix(in srgb, var(--danger) 50%, transparent); }
.btn.small { min-height: 34px; padding: 5px 10px; font-size: 13.5px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
button.link { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 0; }
.chip { display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: 12.5px; font-weight: 700; background: var(--panel-2); border: 1px solid var(--line); color: var(--ink-2); }
.chip.ok { color: var(--ok-ink); border-color: color-mix(in srgb, var(--free) 40%, transparent); }
.chip.warn { color: var(--warn-ink); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.chip.held { color: var(--held); border-color: color-mix(in srgb, var(--held) 45%, transparent); }
.chip.off { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 26px 10px; }
.empty .btn { margin-top: 10px; }

.tabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: 8px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--accent); }

/* A small drop-down of rare buttons, so the head keeps one row («كل الأجهزة»). A bottom sheet on a phone. */
details.more-tools { position: relative; }
details.more-tools > summary { list-style: none; }
details.more-tools > summary::-webkit-details-marker { display: none; }
.more-menu {
  position: absolute; z-index: 25; top: calc(100% + 6px); inset-inline-end: 0; min-width: 270px; padding: 6px;
  border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); box-shadow: 0 16px 40px var(--shadow);
}
.more-menu form { margin: 0; }
.sheet-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 13px 6px; border: 0; border-bottom: 1px solid var(--line-soft); background: none; color: var(--ink); font: inherit; font-size: 16px; font-weight: 600; text-align: start; cursor: pointer; }
.sheet-item:hover { text-decoration: none; }
.sheet-item.on { color: var(--accent); }
.sheet-item .ic { width: 22px; height: 22px; color: var(--muted); }
.more-menu .sheet-item { padding: 10px 10px; font-size: 15px; border-radius: 8px; border-bottom: 0; }
.more-menu .sheet-item:hover { background: var(--hover); color: var(--accent); }

/* ---------- stat tiles ---------- */
.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 14px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.stat .k { color: var(--muted); font-size: 13px; }
.stat .v { font-size: 26px; font-weight: 800; line-height: 1.25; }
.stat .v small { font-size: 13px; font-weight: 600; color: var(--muted); }
.delta { display: inline-flex; align-items: center; gap: 2px; font-size: 12.5px; font-weight: 700; color: var(--muted); }
.delta .ic { width: 14px; height: 14px; stroke-width: 2.4; }
.delta.good { color: var(--up); }
.delta.bad { color: var(--down); }
.stat .spark { display: block; width: 100%; max-width: 140px; height: 34px; margin-top: 4px; }
.spark polyline { fill: none; stroke: var(--muted); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.spark circle { fill: var(--accent); stroke: var(--panel); stroke-width: 2; }

/* ---------- the board ---------- */
.board { display: grid; grid-template-columns: 1fr 320px; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .board { grid-template-columns: 1fr; } }
.legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 13.5px; align-items: center; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 5px; vertical-align: middle; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 12px; }

details.tile { position: relative; }
details.tile > summary {
  list-style: none; cursor: pointer; user-select: none;
  min-height: 124px; padding: 12px; border-radius: 14px;
  background: var(--panel); border: 1px solid var(--line);
  border-top: 4px solid var(--st, var(--off));
  display: flex; flex-direction: column; gap: 2px;
  transition: transform .08s ease, border-color .15s;
}
details.tile > summary::-webkit-details-marker { display: none; }
details.tile > summary:hover { transform: translateY(-1px); border-color: var(--st, var(--line)); }
details.tile[open] > summary { border-color: var(--st); box-shadow: 0 0 0 1px var(--st); }
.tile .top { display: flex; justify-content: space-between; align-items: center; }
.tile .no { font-size: 22px; font-weight: 900; font-variant-numeric: tabular-nums; }
.tile .grp { font-size: 12px; font-weight: 700; color: var(--g, var(--muted)); border: 1px solid currentColor; padding: 0 7px; border-radius: 99px; }
.tile .who { font-weight: 700; font-size: 15px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .big { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--st); line-height: 1.25; }
.tile .sub { font-size: 12.5px; color: var(--muted); }
.tile .cmd { display: inline-flex; align-items: center; gap: 5px; margin-top: auto; padding-top: 4px; font-size: 12px; font-weight: 700; color: var(--accent); }
.tile .cmd::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.tile .cmd.bad { color: var(--down); }
.st-free { --st: var(--free); }
.st-busy { --st: var(--busy); }
.st-soon { --st: var(--warn); }
.st-soon > summary { animation: pulse 1.6s ease-in-out infinite; }
.st-held { --st: var(--held); }
.st-off { --st: var(--off); }
.st-off > summary { opacity: .75; }
.st-disabled { --st: var(--line); }
.st-disabled > summary { opacity: .5; }
@keyframes pulse { 50% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 25%, transparent); } }

.tile .menu {
  position: absolute; z-index: 10; top: calc(100% + 6px); inset-inline: 0;
  min-width: 250px; padding: 12px; border-radius: 12px;
  background: var(--panel-2); border: 1px solid var(--line);
  box-shadow: 0 16px 40px var(--shadow);
}
.tile .menu h3 { margin: 0 0 8px; font-size: 14.5px; }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px; }
.opts label { margin: 0; position: relative; }
.opts input { position: absolute; inset: 0; width: 1px; height: 1px; min-height: 0; opacity: 0; pointer-events: none; }
.opts span {
  display: block; text-align: center; padding: 7px 4px; border-radius: 9px; cursor: pointer;
  background: var(--field); border: 1px solid var(--line); color: var(--ink); font-size: 13.5px; font-weight: 600;
}
.opts span small { display: block; color: var(--muted); font-weight: 500; }
.opts span.pkg { border-style: dashed; border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.opts input:checked + span { border-color: var(--accent); border-style: solid; box-shadow: 0 0 0 1px var(--accent); }
.opts input:focus-visible + span { outline: 2px solid var(--accent); }

/* A device as a button to press («انقله لجهاز تاني»): the same face as a tile. */
button.pick {
  display: flex; flex-direction: column; gap: 2px; width: 100%; min-height: 104px; padding: 12px; border-radius: 14px;
  text-align: start; cursor: pointer; font: inherit; color: var(--ink);
  background: var(--panel); border: 1px solid var(--line); border-top: 4px solid var(--st, var(--off));
}
button.pick:hover:not(:disabled) { border-color: var(--st); transform: translateY(-1px); }
button.pick:disabled { opacity: .5; cursor: not-allowed; }
.pick-form { margin: 0; }

/* The device's power buttons, under its menu (when «التحكم عن بعد» is on). */
.power { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.power form { margin: 0; }
/* A button that opens its own small form in place (a message to a device, collecting a fee). */
details.msg > summary { list-style: none; }
details.msg > summary::-webkit-details-marker { display: none; }
details.msg[open] { flex-basis: 100%; }
details.msg[open] > summary { display: none; }

.side .order { padding: 10px 0; border-bottom: 1px solid var(--line); }
.side .order:last-child { border-bottom: 0; }
.side .order .what { font-weight: 700; }
.side form { margin-top: 6px; }
.ref[hidden] { display: none; }

/* ---------- the floor at a glance (summary) ---------- */
.floor { display: flex; flex-wrap: wrap; gap: 6px; direction: rtl; }
.floor a {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px;
  font-size: 12.5px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--ink);
  background: color-mix(in srgb, var(--st) 22%, var(--panel)); border: 1px solid color-mix(in srgb, var(--st) 60%, transparent);
  box-shadow: 0 0 10px color-mix(in srgb, var(--st) 35%, transparent);
}
.floor a:hover { text-decoration: none; }
.floor a.st-off, .floor a.st-disabled { box-shadow: none; color: var(--muted); }
.floor-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.floor-head .now { font-size: 30px; font-weight: 900; line-height: 1; }
.floor-head .now small { font-size: 15px; color: var(--muted); font-weight: 600; }
.attention a { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); color: var(--ink); }
.attention a:last-child { border-bottom: 0; }
.attention a:hover { text-decoration: none; color: var(--accent); }
.attention .ic { color: var(--warn); }

/* ---------- a day's list (bookings) ---------- */
.list-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.list-row .when { flex: none; width: 76px; display: flex; flex-direction: column; line-height: 1.35; }
.list-row .when b { font-size: 16px; font-variant-numeric: tabular-nums; }
.list-row .when small { color: var(--muted); font-size: 12.5px; }
.list-row .what { flex: 1; min-width: 0; }
.list-row .what .muted { font-size: 13.5px; }
.list-row .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.list-row .acts form { margin: 0; }
.list-row:has(details.msg[open]) { flex-wrap: wrap; }
.list-row:has(details.msg[open]) .acts { flex-basis: 100%; justify-content: flex-start; }

/* ---------- toggles and theme cards (settings) ---------- */
.switch { position: relative; display: flex; align-items: center; gap: 10px; margin: 0 0 8px; cursor: pointer; color: var(--ink); font-size: 16px; }
.switch input { position: absolute; width: 1px; height: 1px; min-height: 0; opacity: 0; pointer-events: none; }
.switch span { position: relative; flex: none; width: 46px; height: 26px; border-radius: 99px; background: var(--line); transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--ink-2); transition: transform .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(-20px); background: var(--accent-ink); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch b { font-weight: 800; }
.feature-options { display: none; margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.feature:has(.switch input:checked) { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.feature:has(.switch input:checked) .feature-options { display: block; }
@supports not selector(:has(*)) { .feature.on .feature-options { display: block; } }

.themes { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr)); gap: 10px; }
.theme-card { position: relative; margin: 0; cursor: pointer; }
.theme-card input { position: absolute; width: 1px; height: 1px; min-height: 0; opacity: 0; pointer-events: none; }
.theme-face { display: block; padding: 10px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); color: var(--ink); }
.theme-card input:checked + .theme-face { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.theme-card input:focus-visible + .theme-face { outline: 2px solid var(--accent); outline-offset: 3px; }
.theme-preview { display: flex; align-items: stretch; gap: 6px; height: 64px; padding: 8px; border-radius: 9px; background: var(--bg); border: 1px solid var(--line-soft); margin-bottom: 8px; }
.theme-preview i { flex: 1; border-radius: 6px; background: var(--panel-2); border-top: 3px solid var(--free); }
.theme-preview .p2 { border-top-color: var(--busy); }
.theme-preview .p3 { border-top-color: var(--held); }
.theme-preview b { flex: 0 0 26%; align-self: flex-end; height: 20px; border-radius: 6px; background: var(--accent); }
.theme-name { display: block; font-weight: 800; font-size: 15px; }
.theme-note { display: block; font-size: 12.5px; color: var(--muted); font-weight: 500; line-height: 1.5; }
.save-bar { position: sticky; bottom: 0; z-index: 5; display: flex; justify-content: flex-start; margin-top: 14px; padding: 12px 0; background: linear-gradient(transparent, var(--bg) 45%); }

/* ---------- tournaments ---------- */
.bracket { display: flex; align-items: stretch; gap: 14px; overflow-x: auto; padding-bottom: 8px; -webkit-overflow-scrolling: touch; }
.round { flex: 0 0 220px; display: flex; flex-direction: column; gap: 8px; }
.round h3 { margin: 0; font-size: 13.5px; color: var(--muted); font-weight: 700; }
.round .games { flex: 1; display: flex; flex-direction: column; justify-content: space-around; gap: 10px; }
.match { border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); overflow: hidden; }
.match .p { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 42px; padding: 6px 10px; }
.match .p + .p { border-top: 1px solid var(--line-soft); }
.match .p span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.match .p.win { font-weight: 800; background: color-mix(in srgb, var(--free) 13%, transparent); }
.match .p.win::after { content: "✓"; color: var(--free); font-weight: 900; }
.match .p.lose { color: var(--muted); }
.match .p.tbd { color: var(--muted); font-style: normal; }
.match form { margin: 0; flex: none; }
.match .btn.small { min-height: 30px; padding: 2px 10px; }
.podium { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); gap: 10px; }
.podium div { padding: 12px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); text-align: center; }
.podium .first { border-color: color-mix(in srgb, var(--warn) 60%, var(--line)); }
.podium b { display: block; font-size: 17px; }

/* ---------- charts (HTML columns: text keeps its size on a phone) ---------- */
.cols { margin: 0; }
.cols-plot { position: relative; height: 180px; padding-inline-start: 42px; }
.cols-grid span { position: absolute; inset-inline: 0; border-top: 1px solid var(--line-soft); }
.cols-grid span:first-child { border-top-color: var(--line); }
.cols-grid i { position: absolute; inset-inline-start: 0; transform: translateY(-50%); font-style: normal; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; background: var(--panel); padding-inline-end: 4px; }
.cols-bars { position: absolute; inset: 0; inset-inline-start: 42px; display: flex; align-items: stretch; }
.col { flex: 1 1 0; display: flex; justify-content: center; align-items: flex-end; min-width: 0; cursor: default; border-radius: 6px; }
.col:hover, .col:focus-visible { background: var(--hover); outline: none; }
.stack { width: min(24px, 62%); display: flex; flex-direction: column-reverse; gap: 2px; }
.stack b { display: block; flex-basis: 0; min-height: 2px; }
.stack b:last-child { border-radius: 4px 4px 0 0; }
.s1 { background: var(--s1); }
.s2 { background: var(--s2); }
.s3 { background: var(--s3); }
.s4 { background: var(--s4); }
.single .stack b { background: var(--accent); }
.col.hl .stack { box-shadow: 0 0 0 2px var(--panel), 0 0 0 3px color-mix(in srgb, var(--ink) 50%, transparent); border-radius: 4px 4px 0 0; }
.cols-x { display: flex; padding-inline-start: 42px; margin-top: 6px; }
.cols-x span { flex: 1 1 0; min-width: 0; text-align: center; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: visible; }
.cols-x span.skip { visibility: hidden; }
.cols-x span.strong { color: var(--ink); font-weight: 700; }
.chart-legend { margin: 2px 0 10px; }
.chart-legend .sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-inline-end: 6px; vertical-align: middle; }
.hbar { display: grid; grid-template-columns: minmax(70px, 110px) 1fr auto; gap: 8px 10px; align-items: center; }
.hbar .name { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar .track { height: 10px; border-radius: 0 5px 5px 0; background: var(--line-soft); overflow: hidden; }
.hbar .fill { height: 100%; background: var(--accent); border-radius: 0 5px 5px 0; }
.hbar .val { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; min-width: 48px; text-align: end; }
.segbar { display: flex; gap: 2px; height: 28px; margin: 6px 0 8px; }
.segbar span { border-radius: 4px; display: grid; place-items: center start; padding-inline-start: 8px; font-size: 12.5px; font-weight: 700; color: #fff; overflow: hidden; white-space: nowrap; min-width: 0; }
.tip {
  position: fixed; z-index: 100; pointer-events: none; max-width: 260px;
  padding: 7px 10px; border-radius: 9px; background: var(--panel-2); border: 1px solid var(--line);
  color: var(--ink); font-size: 13px; line-height: 1.5; box-shadow: 0 10px 30px var(--shadow); white-space: pre-line;
}

/* ---------- profit, written like a receipt ---------- */
.receipt { background: var(--sunken); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.receipt .ln { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; }
.receipt .ln span:last-child { font-variant-numeric: tabular-nums; white-space: nowrap; direction: ltr; unicode-bidi: isolate; }
.receipt .ln.sub { color: var(--muted); font-size: 13.5px; padding: 2px 0 2px; padding-inline-start: 14px; }
.receipt .ln.neg span:last-child::before { content: "− "; }
.receipt hr { border: 0; border-top: 1px dashed var(--line); margin: 8px 0; }
.receipt .net { font-size: 20px; font-weight: 900; padding-top: 6px; }
.receipt .net.loss span:last-child { color: var(--down); }
.receipt .note { font-size: 12.5px; color: var(--muted); margin-top: 10px; }

.period { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.period::-webkit-scrollbar { display: none; }
.period a { white-space: nowrap; padding: 6px 12px; border-radius: 99px; border: 1px solid var(--line); color: var(--ink-2); font-weight: 600; font-size: 14px; }
.period a:hover { text-decoration: none; border-color: var(--accent); }
.period a.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* ---------- sign in ---------- */
.login { max-width: 380px; margin: 9vh auto; }
.login .logo { width: 48px; height: 48px; font-size: 18px; border-radius: 12px; margin-bottom: 10px; }

/* ---------- counter sale ---------- */
.pos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.pos-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border-radius: 10px; background: var(--field); border: 1px solid var(--line); }
.qty { display: flex; align-items: center; gap: 4px; }
.qty button { width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--ink); font-size: 18px; cursor: pointer; }
.qty input { width: 52px; text-align: center; padding: 5px; }

/* ---------- online ---------- */
.cloud-note { padding: 8px 18px; background: color-mix(in srgb, var(--accent-2) 12%, transparent); border-bottom: 1px solid color-mix(in srgb, var(--accent-2) 35%, transparent); color: var(--ink-2); font-size: 14px; text-align: center; }
.key { font-family: Consolas, monospace; font-size: 15px; padding: 10px 12px; border-radius: 9px; background: var(--field); border: 1px dashed var(--accent); word-break: break-all; user-select: all; }

/* ---------- customers' page (phone first) ---------- */
.portal { max-width: 560px; margin: 0 auto; }
.portal .hero { text-align: center; padding: 18px 8px 6px; }
.portal .hero .logo { width: 54px; height: 54px; font-size: 20px; border-radius: 14px; margin-bottom: 8px; }
.portal .balance { font-size: 44px; font-weight: 900; line-height: 1.1; }
.portal .card { margin-top: 12px; }
.portal .facts { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; margin-bottom: 10px; }
.slots label { margin: 0; position: relative; }
.slots input { position: absolute; width: 1px; height: 1px; min-height: 0; opacity: 0; pointer-events: none; }
.slots span { display: block; text-align: center; padding: 9px 4px; border-radius: 9px; cursor: pointer; background: var(--field); border: 1px solid var(--line); color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.slots input:checked + span { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); color: var(--accent); }
.slots input:focus-visible + span { outline: 2px solid var(--accent); }
.slots input:disabled + span { opacity: .35; cursor: not-allowed; text-decoration: line-through; }

/* ---------- phone ---------- */
@media (max-width: 760px) {
  body.has-menu { padding-bottom: calc(var(--bar-h) + 14px + env(safe-area-inset-bottom)); }
  .bar { padding: 8px 12px; gap: 10px; }
  .bar .nav, .bar .who { display: none; }
  .bar .chip.sync { margin-inline-start: auto; }
  .cloud-note { font-size: 13px; padding: 6px 12px; }
  .page { padding: 12px; }
  h1 { font-size: 21px; }
  .head { align-items: stretch; }
  .head > div:first-child { flex: 1 1 100%; }
  .head .tools { width: 100%; }
  .head .tools form.row { flex: 1 1 100%; flex-wrap: nowrap; }
  .head .tools form.row input { width: auto !important; flex: 1; min-width: 0; }
  .head .tools > .btn, .head .tools > details { flex: 1; }
  .head .tools > details > summary { width: 100%; }
  input, select, textarea { font-size: 16px; min-height: 44px; } /* 16px: iOS does not zoom into the field */
  .btn { min-height: 44px; }
  .btn.small { min-height: 38px; }
  .card { padding: 14px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 12px; }
  .stat .v { font-size: 21px; }
  .tiles { grid-template-columns: 1fr 1fr; gap: 10px; }
  details.tile > summary { min-height: 104px; padding: 10px; }
  .tile .big { font-size: 20px; }
  .tile .no { font-size: 19px; }
  /* The device menu and the «كل الأجهزة» menu become bottom sheets over a dimmed page. */
  details.tile[open] .menu, details.more-tools[open] .more-menu {
    position: fixed; z-index: 60; inset-inline: 8px; top: auto; bottom: calc(var(--bar-h) + 10px + env(safe-area-inset-bottom));
    max-height: 72vh; overflow: auto; min-width: 0; padding: 16px;
    box-shadow: 0 0 0 100vmax var(--scrim), 0 -10px 40px var(--shadow);
  }
  .power .btn.small { flex: 1 1 auto; }
  /* Every press is a finger: «اللي خلصت», «تعديل الحساب», the feature switches. */
  details:not(.tile):not(.more-tools):not(.msg) > summary { min-height: 44px; display: flex; align-items: center; gap: 6px; }
  .switch { min-height: 44px; }
  button.link { min-height: 44px; padding: 0 14px; }
  .legend { gap: 10px; font-size: 13px; }
  .list-row { flex-wrap: wrap; }
  .list-row .acts { flex-basis: 100%; }
  .list-row .acts form, .list-row .acts .btn { flex: 1; }
  .round { flex-basis: 190px; }
  .save-bar { bottom: calc(var(--bar-h) + env(safe-area-inset-bottom)); }
  .save-bar .btn { width: 100%; }
  .cols-plot { height: 150px; padding-inline-start: 34px; }
  .cols-bars { inset-inline-start: 34px; }
  .cols-x { padding-inline-start: 34px; }
  .cols-x span.tight { font-size: 10.5px; }
  .receipt { padding: 14px; }

  .tabbar {
    display: flex; position: fixed; z-index: 40; inset-inline: 0; bottom: 0;
    height: calc(var(--bar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--bar-bg); border-top: 1px solid var(--line); backdrop-filter: blur(10px);
  }
  .tabbar a, .tabbar button {
    flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; position: relative;
    color: var(--muted); font: inherit; font-size: 11.5px; font-weight: 700; background: none; border: 0; padding: 6px 2px; cursor: pointer;
  }
  .tabbar .ic { width: 22px; height: 22px; }
  .tabbar a:hover { text-decoration: none; }
  .tabbar .on { color: var(--accent); }
  .tabbar .on::before { content: ""; position: absolute; top: 0; width: 28px; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent); }
  .tabbar .badge { position: absolute; top: 5px; inset-inline-start: calc(50% + 6px); min-width: 18px; height: 18px; border-radius: 9px; background: var(--warn); color: #1a1100; font-size: 11px; display: grid; place-items: center; padding: 0 4px; }

  .sheet[open] {
    display: block; position: fixed; inset: auto 0 0 0; margin: 0; width: 100%; max-width: none; max-height: 80vh; overflow: auto;
    padding: 8px 14px calc(14px + env(safe-area-inset-bottom)); border: 0; border-top: 1px solid var(--line); border-radius: 18px 18px 0 0;
    background: var(--panel); color: var(--ink);
  }
  .sheet::backdrop { background: rgba(3, 6, 14, .62); }
  .sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 4px auto 10px; }
  .sheet-who { color: var(--muted); font-size: 13px; padding: 0 4px 6px; }
  .sheet form { margin: 0; }
}

/* ---------- print: light, no menus ---------- */
@media print {
  :root, [data-theme] { --bg: #fff; --panel: #fff; --panel-2: #fff; --sunken: #fff; --line: #ccc; --line-soft: #e5e5e5; --ink: #000; --ink-2: #222; --muted: #555; }
  body { background: #fff; color: #000; padding: 0 !important; }
  .bar, .tabbar, .sheet, .cloud-note, .period, .no-print, .flash, .tools { display: none !important; }
  .card, .stat, .receipt { break-inside: avoid; box-shadow: none; }
  .page { max-width: none; padding: 0; }
}

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
details#range > summary { list-style: none; }
