/* VORTEX owner app. Mobile first, RTL, light/dark. No external fonts or scripts (works offline, strict CSP). */
:root {
  --bg: #f3f5f9; --card: #ffffff; --card2: #f7f8fb; --ink: #0f172a; --muted: #64748b; --faint: #94a3b8; --line: #e5e9f0;
  --brand: #2456e8; --brand-ink: #ffffff; --brand-soft: #e8eefe;
  --good: #059669; --good-soft: #dcfce7; --bad: #dc2626; --bad-soft: #fee2e2; --warn: #d97706; --warn-soft: #fef3c7; --info: #0284c7; --info-soft: #e0f2fe;
  --c1: #2456e8; --c2: #0ea5a4; --c3: #f59e0b; --c4: #8b5cf6; --c5: #ec4899; --c6: #64748b;
  --hero-a: #0f1b3d; --hero-b: #1f3fa8; --shadow: 0 1px 2px rgba(15,23,42,.05), 0 6px 20px rgba(15,23,42,.06);
  --r: 18px; --r-sm: 12px; --tab-h: 64px;
  --font: system-ui, -apple-system, "Segoe UI", "Noto Sans Arabic", Tahoma, Arial, sans-serif;
}
:root[data-theme="dark"] {
  --bg: #080c14; --card: #111827; --card2: #0d1420; --ink: #e8edf5; --muted: #94a3b8; --faint: #64748b; --line: #1f2937;
  --brand: #6b95ff; --brand-ink: #0b1220; --brand-soft: #16233f;
  --good: #34d399; --good-soft: #0b2e22; --bad: #f87171; --bad-soft: #3a1414; --warn: #fbbf24; --warn-soft: #3a2a0a; --info: #38bdf8; --info-soft: #0b2a3a;
  --c1: #6b95ff; --c2: #2dd4bf; --c3: #fbbf24; --c4: #a78bfa; --c5: #f472b6; --c6: #94a3b8;
  --hero-a: #0b1430; --hero-b: #1a3a9c; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.35);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #080c14; --card: #111827; --card2: #0d1420; --ink: #e8edf5; --muted: #94a3b8; --faint: #64748b; --line: #1f2937;
    --brand: #6b95ff; --brand-ink: #0b1220; --brand-soft: #16233f;
    --good: #34d399; --good-soft: #0b2e22; --bad: #f87171; --bad-soft: #3a1414; --warn: #fbbf24; --warn-soft: #3a2a0a; --info: #38bdf8; --info-soft: #0b2a3a;
    --c1: #6b95ff; --c2: #2dd4bf; --c3: #fbbf24; --c4: #a78bfa; --c5: #f472b6; --c6: #94a3b8;
    --hero-a: #0b1430; --hero-b: #1a3a9c; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.35);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.5; overscroll-behavior-y: contain; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--brand); text-decoration: none; }
a.item, a.tbl, a.row { color: inherit; }
.num, .ltr { direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); } .faint { color: var(--faint); }
.good { color: var(--good); } .bad { color: var(--bad); } .warn { color: var(--warn); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.hidden { display: none !important; }

/* ---------- shell ---------- */
#app { min-height: 100dvh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid transparent; }
.topbar.scrolled { border-bottom-color: var(--line); }
.topbar .title { flex: 1; min-width: 0; }
.topbar h1 { margin: 0; font-size: 18px; font-weight: 800; letter-spacing: -.2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .sub { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); display: inline-block; flex: none; }
.dot.on { background: var(--good); box-shadow: 0 0 0 4px color-mix(in srgb, var(--good) 22%, transparent); }
.dot.off { background: var(--bad); box-shadow: 0 0 0 4px color-mix(in srgb, var(--bad) 22%, transparent); }
.iconbtn { position: relative; width: 40px; height: 40px; border-radius: 12px; background: var(--card); box-shadow: var(--shadow); display: grid; place-items: center; }
.iconbtn svg { width: 20px; height: 20px; stroke: var(--ink); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.badge-dot { direction: ltr; position: absolute; top: -4px; inset-inline-start: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
main { flex: 1; padding: 6px 16px calc(var(--tab-h) + env(safe-area-inset-bottom) + 24px); max-width: 720px; width: 100%; margin: 0 auto; }
.tabbar { position: fixed; inset-inline: 0; bottom: 0; z-index: 30; display: flex; justify-content: center; padding: 8px 12px calc(env(safe-area-inset-bottom) + 8px); background: linear-gradient(to top, var(--bg) 60%, transparent); pointer-events: none; }
.tabs { pointer-events: auto; display: flex; width: 100%; max-width: 560px; gap: 2px; padding: 6px; background: var(--card); border-radius: 22px; box-shadow: var(--shadow), 0 0 0 1px var(--line); }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 0 5px; border-radius: 16px; color: var(--muted); font-size: 11px; font-weight: 600; position: relative; }
.tab svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab.active { color: var(--brand); background: var(--brand-soft); }
.tab .badge-dot { top: 2px; inset-inline-start: calc(50% + 6px); }

/* ---------- building blocks ---------- */
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px; margin-top: 14px; }
.card > h2, .section-title { margin: 0 0 12px; font-size: 14px; font-weight: 800; color: var(--ink); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.section-title { margin: 22px 4px 0; font-size: 13px; color: var(--muted); font-weight: 700; }
.section-title + .card { margin-top: 8px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 99px; font-size: 12px; font-weight: 700; background: var(--card2); color: var(--muted); white-space: nowrap; }
.chip svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chip.good { background: var(--good-soft); color: var(--good); } .chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.warn { background: var(--warn-soft); color: var(--warn); } .chip.info { background: var(--info-soft); color: var(--info); } .chip.brand { background: var(--brand-soft); color: var(--brand); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 18px; border-radius: 14px; background: var(--brand); color: var(--brand-ink); font-weight: 700; }
.btn.secondary { background: var(--card2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.btn.block { width: 100%; } .btn:disabled { opacity: .55; }
.list > * + * { border-top: 1px solid var(--line); }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 0; width: 100%; text-align: start; }
button.item:active { opacity: .7; }
.item .grow .t { font-weight: 700; } .item .grow .s { font-size: 12.5px; color: var(--muted); }
.amount { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; direction: ltr; unicode-bidi: isolate; }
.empty { text-align: center; color: var(--muted); padding: 28px 8px; }
.empty .big { font-size: 34px; margin-bottom: 6px; }
.skeleton { background: linear-gradient(90deg, var(--card2) 25%, var(--line) 37%, var(--card2) 63%); background-size: 400% 100%; animation: sk 1.4s ease infinite; border-radius: 10px; }
@keyframes sk { 0% { background-position: 100% 50% } 100% { background-position: 0 50% } }
.banner { margin: 8px 0 0; padding: 10px 14px; border-radius: 14px; font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.banner.warn { background: var(--warn-soft); color: var(--warn); } .banner.bad { background: var(--bad-soft); color: var(--bad); } .banner.info { background: var(--info-soft); color: var(--info); }
.seg { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: none; margin: 0 -16px; padding-inline: 16px; }
.seg::-webkit-scrollbar { display: none; }
.seg button { flex: none; padding: 8px 14px; border-radius: 99px; background: var(--card); box-shadow: inset 0 0 0 1px var(--line); font-size: 13px; font-weight: 700; color: var(--muted); }
.seg button.active { background: var(--brand); color: var(--brand-ink); box-shadow: none; }
.field { display: block; width: 100%; min-height: 46px; padding: 0 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); outline: none; }
.field:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent); }
label.lbl { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin: 14px 2px 6px; }

/* ---------- hero ---------- */
.hero { margin-top: 10px; padding: 20px 18px 16px; border-radius: 24px; color: #fff; background: radial-gradient(120% 140% at 100% 0%, var(--hero-b), var(--hero-a)); box-shadow: 0 10px 30px rgba(20,40,120,.28); position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; width: 220px; height: 220px; border-radius: 50%; inset-inline-end: -70px; top: -90px; background: rgba(255,255,255,.07); }
.hero .lbl { font-size: 13px; opacity: .8; font-weight: 600; }
.hero .big { font-size: 40px; font-weight: 800; letter-spacing: -1px; line-height: 1.15; margin: 4px 0 2px; direction: ltr; text-align: start; unicode-bidi: isolate; }
.hero .big small { font-size: 16px; font-weight: 600; opacity: .75; margin-inline-start: 6px; letter-spacing: 0; }
.hero .meta { font-size: 13px; opacity: .85; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.progress { height: 8px; border-radius: 99px; background: rgba(255,255,255,.18); margin-top: 14px; overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, #7dd3fc, #fff); transition: width .8s cubic-bezier(.2,.8,.2,1); }
.hero .compare { margin-top: 8px; font-size: 12.5px; opacity: .88; display: flex; justify-content: space-between; gap: 8px; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.kpi { background: var(--card); border-radius: var(--r-sm); box-shadow: var(--shadow); padding: 13px 14px; }
.kpi .k { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.kpi .v { font-size: 22px; font-weight: 800; margin-top: 2px; letter-spacing: -.4px; direction: ltr; text-align: start; unicode-bidi: isolate; font-variant-numeric: tabular-nums; }
.kpi .d { font-size: 12px; color: var(--muted); margin-top: 1px; }

/* ---------- charts ---------- */
.chart { width: 100%; display: block; direction: ltr; }
.chart text { font-family: var(--font); fill: var(--muted); font-size: 10.5px; }
.chart .bar { fill: var(--brand); } .chart .bar.dim { fill: color-mix(in srgb, var(--brand) 35%, var(--card)); }
.chart .axis { stroke: var(--line); stroke-width: 1; } .chart .grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 4; }
.legend { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.legend .li { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.stackbar { display: flex; height: 14px; border-radius: 99px; overflow: hidden; background: var(--card2); gap: 2px; }
.stackbar > i { display: block; height: 100%; }
.hbar { display: flex; flex-direction: column; gap: 10px; }
.hbar .r { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: baseline; }
.hbar .r .n { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .r .track { grid-column: 1 / -1; height: 7px; border-radius: 99px; background: var(--card2); overflow: hidden; }
.hbar .r .track > i { display: block; height: 100%; border-radius: 99px; background: var(--brand); }
.tip { position: absolute; z-index: 5; background: var(--ink); color: var(--bg); padding: 6px 10px; border-radius: 10px; font-size: 12px; font-weight: 700; pointer-events: none; white-space: nowrap; transform: translate(-50%, -110%); direction: ltr; }
.chartbox { position: relative; }

/* ---------- tables & orders ---------- */
.tables { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tbl { border-radius: 16px; padding: 12px 8px; text-align: center; background: var(--card); box-shadow: var(--shadow), inset 0 0 0 1px var(--line); min-height: 92px; display: flex; flex-direction: column; justify-content: center; gap: 2px; width: 100%; }
.tbl .n { font-weight: 800; } .tbl .a { font-weight: 800; font-size: 15px; direction: ltr; } .tbl .s { font-size: 11.5px; color: var(--muted); }
.tbl.free { color: var(--muted); } .tbl.free .n { color: var(--ink); }
.tbl.busy { background: var(--brand-soft); box-shadow: inset 0 0 0 1.5px var(--brand); } .tbl.busy .a { color: var(--brand); }
.tbl.pay { background: var(--warn-soft); box-shadow: inset 0 0 0 1.5px var(--warn); } .tbl.pay .a { color: var(--warn); }
.late { color: var(--bad) !important; font-weight: 700; }

/* ---------- sheet & toast ---------- */
.scrim { position: fixed; inset: 0; z-index: 50; background: rgba(8,12,20,.5); opacity: 0; transition: opacity .2s; }
.scrim.show { opacity: 1; }
.sheet { position: fixed; inset-inline: 0; bottom: 0; z-index: 51; max-height: 88dvh; background: var(--card); border-radius: 26px 26px 0 0; padding: 8px 18px calc(env(safe-area-inset-bottom) + 20px); overflow-y: auto; transform: translateY(100%); transition: transform .28s cubic-bezier(.2,.8,.2,1); max-width: 720px; margin: 0 auto; box-shadow: 0 -10px 40px rgba(0,0,0,.25); }
.sheet.show { transform: translateY(0); }
.sheet .grab { width: 42px; height: 5px; border-radius: 3px; background: var(--line); margin: 6px auto 14px; }
.sheet h3 { margin: 0 0 4px; font-size: 18px; }
.sheet h3.num { text-align: right; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.kv:first-of-type { border-top: 0; } .kv .k { color: var(--muted); } .kv .v { font-weight: 700; text-align: end; }
.toast { position: fixed; inset-inline: 16px; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 28px); z-index: 60; margin: 0 auto; max-width: 420px; padding: 12px 16px; border-radius: 14px; background: var(--ink); color: var(--bg); font-weight: 600; text-align: center; animation: tin .25s ease; }
@keyframes tin { from { transform: translateY(12px); opacity: 0 } to { transform: none; opacity: 1 } }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: 24px; max-width: 420px; margin: 0 auto; }
.login .logo { width: 72px; height: 72px; border-radius: 22px; background: radial-gradient(120% 140% at 100% 0%, var(--hero-b), var(--hero-a)); display: grid; place-items: center; box-shadow: 0 12px 30px rgba(20,40,120,.3); margin-bottom: 18px; }
.login .logo svg { width: 40px; height: 40px; }
.login h1 { margin: 0 0 6px; font-size: 26px; } .login p { margin: 0 0 18px; color: var(--muted); }
.err { color: var(--bad); font-size: 13.5px; margin-top: 10px; min-height: 20px; font-weight: 600; }

@media (min-width: 760px) { main { padding-top: 14px; } .tables { grid-template-columns: repeat(4, 1fr); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
