:root {
  --bg: #f4f6fa; --panel: #ffffff; --panel-2: #f8fafc; --text: #18202c; --muted: #5d6878; --border: #dfe4ec; --brand: #1f4e8c; --brand-2: #2f6fc0;
  --ok: #1d7a46; --ok-bg: #e5f5ec; --warn: #9a5b00; --warn-bg: #fff3dc; --bad: #b42318; --bad-bg: #fde8e6; --info: #1f5fa8; --info-bg: #e6effa; --neutral-bg: #eef1f5;
  --shA: #e8f1ff; --shB: #fff1e0; --shC: #ece8ff; --focus: #2f6fc0; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --radius: 10px; --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141b; --panel: #171e28; --panel-2: #1c2531; --text: #e6ebf2; --muted: #9aa6b6; --border: #2a3442; --brand: #6ea4ea; --brand-2: #8db8f0;
    --ok: #5fd08f; --ok-bg: #12301f; --warn: #f1b54d; --warn-bg: #33270f; --bad: #ff8a80; --bad-bg: #3a1714; --info: #8db8f0; --info-bg: #142a45; --neutral-bg: #222c39;
    --shA: #16263d; --shB: #33250f; --shC: #241d3d; --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #0f141b; --panel: #171e28; --panel-2: #1c2531; --text: #e6ebf2; --muted: #9aa6b6; --border: #2a3442; --brand: #6ea4ea; --brand-2: #8db8f0;
  --ok: #5fd08f; --ok-bg: #12301f; --warn: #f1b54d; --warn-bg: #33270f; --bad: #ff8a80; --bad-bg: #3a1714; --info: #8db8f0; --info-bg: #142a45; --neutral-bg: #222c39;
  --shA: #16263d; --shB: #33250f; --shC: #241d3d; --shadow: none;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); }
a { color: var(--brand-2); }
.skip { position: absolute; top: 8px; inset-inline-start: 8px; z-index: 99; background: var(--panel); padding: 8px; }
.skip:not(:focus) { width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
#app { display: flex; min-height: 100vh; }
#sidebar { width: 236px; background: var(--panel); border-inline-end: 1px solid var(--border); position: sticky; top: 0; height: 100vh; overflow-y: auto; flex-shrink: 0; }
.brand { display: flex; gap: 10px; align-items: center; padding: 16px; border-bottom: 1px solid var(--border); }
.brand small { display: block; color: var(--muted); font-size: 11px; }
.logo { width: 34px; height: 34px; border-radius: 8px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; }
#nav { padding: 8px; }
#nav .group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 12px 10px 4px; }
#nav a { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none; }
#nav a:hover { background: var(--panel-2); }
#nav a.active { background: var(--info-bg); color: var(--info); font-weight: 600; }
#nav .badge { margin-inline-start: auto; }
#shell { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#topbar { display: flex; align-items: center; gap: 12px; padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
#context { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; color: var(--muted); }
.spacer { flex: 1; }
#menuBtn { display: none; }
main { padding: 20px; max-width: 1500px; width: 100%; }
h1 { font-size: 22px; margin: 0 0 4px; } h2 { font-size: 17px; margin: 0 0 10px; } h3 { font-size: 15px; margin: 14px 0 8px; }
.sub { color: var(--muted); margin: 0 0 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); } .g3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); } .g4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card.tight { padding: 12px; }
.card h2 { display: flex; gap: 8px; align-items: center; }
.kpi { display: flex; flex-direction: column; gap: 2px; }
.kpi .v { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: 12px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.num { text-align: end; font-variant-numeric: tabular-nums; }
button, .btn { font: inherit; border: 1px solid var(--border); background: var(--panel); color: var(--text); padding: 7px 12px; border-radius: 8px; cursor: pointer; min-height: 34px; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
button:hover, .btn:hover { background: var(--panel-2); }
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; } button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--border)); }
button.ghost { border-color: transparent; background: transparent; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.big { font-size: 20px; padding: 18px 26px; min-height: 64px; border-radius: 12px; }
.icon-btn { border: none; background: transparent; font-size: 18px; padding: 4px 8px; min-height: 0; }
input, select, textarea { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; min-height: 34px; }
textarea { width: 100%; min-height: 90px; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
label.field > input, label.field > select, label.field > textarea { color: var(--text); font-size: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.table-wrap { position: relative; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--border); text-align: start; vertical-align: top; white-space: nowrap; }
td.wrap, th.wrap { white-space: normal; min-width: 220px; }
th { background: var(--panel-2); font-size: 12px; color: var(--muted); font-weight: 600; position: sticky; top: 0; }
tbody tr:hover { background: var(--panel-2); }
tr:last-child td { border-bottom: none; }
.pill { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 1px 9px; font-size: 12px; font-weight: 600; background: var(--neutral-bg); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); } .pill.warn { background: var(--warn-bg); color: var(--warn); } .pill.bad { background: var(--bad-bg); color: var(--bad); } .pill.info { background: var(--info-bg); color: var(--info); }
.badge { background: var(--bad); color: #fff; border-radius: 999px; font-size: 11px; padding: 0 7px; font-weight: 700; }
.banner { border-radius: var(--radius); padding: 10px 14px; margin: 0 0 14px; border: 1px solid; }
.banner.warn { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.banner.bad { background: var(--bad-bg); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.banner.info { background: var(--info-bg); color: var(--info); border-color: color-mix(in srgb, var(--info) 30%, transparent); }
.banner.ok { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; overflow-x: auto; }
.tabs button { border: none; border-bottom: 2px solid transparent; border-radius: 0; background: none; color: var(--muted); }
.tabs button[aria-selected="true"] { color: var(--brand-2); border-bottom-color: var(--brand-2); font-weight: 600; }
ul.clean { list-style: none; padding: 0; margin: 0; } ul.clean li { padding: 6px 0; border-bottom: 1px dashed var(--border); } ul.clean li:last-child { border: none; }
.bar { height: 8px; background: var(--neutral-bg); border-radius: 99px; overflow: hidden; } .bar > i { display: block; height: 100%; background: var(--ok); }
.bar.warn > i { background: var(--warn); } .bar.bad > i { background: var(--bad); }
.cell { border-radius: 6px; padding: 2px 6px; font-size: 12px; display: inline-block; margin: 1px 0; }
.cell.A { background: var(--shA); } .cell.B { background: var(--shB); } .cell.C { background: var(--shC); }
.cell.blocked { background: var(--bad-bg); color: var(--bad); text-decoration: line-through; } .cell.cancelled { opacity: .5; text-decoration: line-through; }
.cell.uncovered { background: var(--bad-bg); color: var(--bad); font-weight: 600; }
.slot { display: flex; justify-content: space-between; gap: 6px; align-items: center; padding: 4px 6px; border-radius: 6px; border: 1px solid var(--border); margin-bottom: 4px; background: var(--panel); }
.slot.uncovered { border-color: var(--bad); background: var(--bad-bg); }
.slot button { padding: 2px 8px; min-height: 0; font-size: 12px; }
#toasts { position: fixed; inset-inline-end: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: var(--panel); border: 1px solid var(--border); border-inline-start: 4px solid var(--info); padding: 10px 14px; border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.15); max-width: 420px; }
.toast.ok { border-inline-start-color: var(--ok); } .toast.bad { border-inline-start-color: var(--bad); } .toast ul { margin: 4px 0 0; padding-inline-start: 18px; }
dialog { border: 1px solid var(--border); border-radius: 12px; padding: 0; background: var(--panel); color: var(--text); width: min(760px, 94vw); max-height: 90vh; }
dialog::backdrop { background: rgba(10,15,25,.45); }
dialog header { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
dialog header h2 { margin: 0; }
#modalBody { padding: 16px 18px; overflow-y: auto; max-height: 64vh; }
dialog footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); }
.kiosk { max-width: 640px; margin: 20px auto; text-align: center; }
.kiosk .state { font-size: 22px; margin: 12px 0; }
.kiosk input { font-size: 28px; text-align: center; width: 240px; letter-spacing: .1em; }
.kiosk .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.empty { padding: 24px; text-align: center; color: var(--muted); }
details summary { cursor: pointer; color: var(--brand-2); }
.week-grid th, .week-grid td { min-width: 92px; }
.legend { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12px; }
@media (max-width: 900px) {
  #sidebar { position: fixed; inset-inline-start: -260px; z-index: 20; transition: inset-inline-start .2s; box-shadow: 0 0 30px rgba(0,0,0,.2); }
  #sidebar.open { inset-inline-start: 0; }
  #menuBtn { display: inline-flex; }
  main { padding: 14px 16px; }
}
@media print {
  #sidebar, #topbar, .no-print, #toasts { display: none !important; }
  main { padding: 0; } .card { box-shadow: none; border: none; }
}
.split { grid-template-columns: minmax(260px, 1fr) 2fr; }
@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } }

/* ---------- sign-in page ---------- */
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
#login-root { min-height: 100vh; display: flex; flex-direction: column; }
.login-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 24px; background: var(--panel); border-bottom: 1px solid var(--border); }
.login-top .brand { border: none; padding: 0; }
.login-main { padding: 28px 24px; max-width: 1400px; width: 100%; margin: 0 auto; }
.login-grid { display: grid; grid-template-columns: minmax(0, 420px); justify-content: center; gap: 20px; align-items: start; padding-top: 4vh; }
.login-card { position: static; }
.login-card form { display: grid; gap: 12px; margin-bottom: 12px; }
.pw-wrap { display: flex; gap: 6px; }
.pw-wrap input { flex: 1; min-width: 0; }
button.block { width: 100%; justify-content: center; min-height: 42px; }
button.small { font-size: 12px; padding: 4px 10px; }
.form-error { color: var(--bad); font-size: 13px; min-height: 1em; }
.demo-box { margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--border); }
.demo-box h2 { font-size: 15px; margin: 0 0 4px; }
.help-card h2 { font-size: 17px; }
.help-roles th[scope="row"] { white-space: nowrap; color: var(--text); font-size: 14px; background: none; position: static; }
.help-roles tr.me { background: var(--info-bg); }
.help-matrix-card { grid-column: 1 / -1; }
.help-matrix { font-size: 13px; }
.help-matrix thead th { background: var(--brand-solid, var(--brand)); color: #fff; font-size: 12px; font-weight: 700; z-index: 2; }
.help-matrix th.role-col { white-space: normal; text-align: center; vertical-align: bottom; min-width: 76px; max-width: 104px; line-height: 1.25; }
.help-matrix th.role-col.me { box-shadow: inset 0 -4px 0 var(--accent); }
.help-matrix th.perm-col { min-width: 280px; vertical-align: bottom; }
.help-matrix tbody th[scope="row"] { position: sticky; inset-inline-start: 0; top: auto; z-index: 1; background: var(--panel); color: var(--text);
  font-weight: 400; font-size: 13px; white-space: normal; padding-inline-start: 22px; }
.help-matrix thead th.perm-col { position: sticky; inset-inline-start: 0; z-index: 3; }
.help-matrix .area-row th { position: static; background: color-mix(in srgb, var(--brand) 12%, var(--panel)); color: var(--text); font-weight: 700; font-size: 13px; }
.help-matrix td.mark { text-align: center; font-weight: 800; color: var(--brand); min-width: 76px; }
.help-matrix td.me { background: var(--info-bg); }
.help-matrix tbody tr:not(.area-row):hover th, .help-matrix tbody tr:not(.area-row):hover td { background: var(--panel-2); }
@media (max-width: 900px) {
  .login-grid { grid-template-columns: 1fr; }
  .login-card { position: static; }
  .login-main { padding: 16px; }
  .login-top { padding: 10px 16px; }
}

/* ---------- branding ---------- */
:root { --accent: #f2b419; }
.logo-tile { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 3px 6px; display: inline-flex; align-items: center; flex-shrink: 0; }
.logo-tile img { height: 38px; width: auto; max-width: 96px; object-fit: contain; display: block; }
.brand-text strong { display: block; line-height: 1.2; }
#brandBox { border-bottom: 3px solid var(--accent); }
#nav a.active { box-shadow: inset 3px 0 0 var(--accent); }
[dir="rtl"] #nav a.active { box-shadow: inset -3px 0 0 var(--accent); }
.login-top { border-bottom: 3px solid var(--accent); }
.login-top .logo-tile img { height: 44px; max-width: 120px; }
.lang-switch select { min-height: 30px; padding: 2px 6px; }
/* ---------- platform admin ---------- */
fieldset.plain { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px 12px; margin: 0; display: grid; gap: 10px; }
fieldset.plain legend { padding: 0 6px; font-weight: 600; }
.field-label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.logo-preview { width: 180px; height: 96px; border: 1px dashed var(--border); border-radius: 10px; background: #fff; display: grid; place-items: center; padding: 6px; text-align: center; }
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.color-row { display: grid; grid-template-columns: 1fr 44px 96px; gap: 8px; align-items: center; }
.color-row input[type="color"] { width: 44px; height: 34px; padding: 2px; }
.color-row .hex { font-family: ui-monospace, Menlo, monospace; text-transform: uppercase; }
.swatch-btn { gap: 4px; font-size: 12px; min-height: 30px; padding: 4px 8px; }
.swatch { width: 14px; height: 14px; border-radius: 4px; display: inline-block; border: 1px solid rgba(0,0,0,.15); }
.preview-box { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; background: var(--panel-2); display: grid; gap: 8px; }
.preview-brand { padding: 0; border: none; }
.accent-bar { width: 48px; height: 6px; border-radius: 3px; background: var(--accent); }
/* ---------- right-to-left ---------- */
[dir="rtl"] body { font-family: system-ui, "Segoe UI", "Geeza Pro", "Noto Sans Arabic", Tahoma, sans-serif; }
[dir="rtl"] .mono, [dir="rtl"] input[type="date"], [dir="rtl"] input[type="datetime-local"] { direction: ltr; }

/* Profile menu (far right of the top bar) */
.profile { position: relative; }
.avatar-btn { border: none; background: transparent; padding: 2px; min-height: 0; border-radius: 50%; }
.avatar-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.avatar { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--brand-solid, var(--brand)); color: #fff;
  font-weight: 700; font-size: 14px; letter-spacing: .02em; box-shadow: 0 0 0 2px var(--accent); }
.profile-menu { position: absolute; inset-inline-end: 0; top: calc(100% + 8px); min-width: 230px; max-width: calc(100vw - 32px); z-index: 20;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0,0,0,.25); padding: 6px; }
.profile-head { display: grid; gap: 2px; padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: none; background: transparent; color: var(--text);
  text-decoration: none; text-align: start; font: inherit; border-radius: 6px; cursor: pointer; min-height: 0; }
.menu-item:hover, .menu-item:focus-visible { background: var(--panel-2); outline: none; }
#topbar { flex-wrap: nowrap; }
.topbar-main { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
#userBox { margin-inline-start: auto; }
#userBox .row { justify-content: flex-end; }
#profileBox { flex: none; align-self: flex-start; padding-top: 2px; }
