:root {
  --bg: #f4f4f1;
  --surface: #ffffff;
  --surface-2: #eef1f0;
  --ink: #1f2a2c;
  --muted: #66726f;
  --line: #dfe4e2;
  --brand: #313f42;
  --brand-2: #4a5b5f;
  --gold: #c49a52;
  --gold-soft: #f6eedd;
  --ok: #1f8a5b;
  --ok-soft: #e2f4ea;
  --warn: #b26b00;
  --warn-soft: #fbefd9;
  --bad: #c0392b;
  --bad-soft: #fbe5e2;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(31, 42, 44, .06), 0 4px 16px rgba(31, 42, 44, .05);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "SF Arabic", "Segoe UI", Tahoma, "Noto Sans Arabic", Roboto, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-size: 15px; line-height: 1.5; min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-2); }
.hidden { display: none !important; }

/* splash + auth */
.splash { min-height: 100vh; display: grid; place-items: center; background: var(--brand); }
.logo-mark { width: 72px; height: 72px; border-radius: 20px; display: grid; place-items: center;
  background: linear-gradient(145deg, var(--gold), #8c6a3a); color: #fff; font-size: 38px; font-weight: 700; letter-spacing: 1px; }
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: var(--brand); }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: 22px; padding: 28px 22px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.auth-card .logo-mark { margin: 0 auto 12px; }
.auth-card h1 { text-align: center; font-size: 20px; margin: 0 0 4px; }
.auth-card p.sub { text-align: center; color: var(--muted); margin: 0 0 20px; font-size: 14px; }
.lang-switch { display: flex; gap: 6px; justify-content: center; margin-top: 18px; }
.lang-switch button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 12px; font-size: 13px; cursor: pointer; }
.lang-switch button.on { background: var(--brand); color: #fff; border-color: var(--brand); }

/* layout */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--brand); color: #fff; padding: calc(10px + var(--safe-t)) 16px 10px;
  display: flex; align-items: center; gap: 10px; }
.topbar .title { font-weight: 700; font-size: 17px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar select { background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.25); border-radius: 10px; padding: 6px 8px; max-width: 46vw; }
.topbar select option { color: var(--ink); }
.icon-btn { background: transparent; border: 0; color: inherit; padding: 6px; border-radius: 10px; cursor: pointer; display: grid; place-items: center; }
.icon-btn svg { width: 22px; height: 22px; }
main { padding: 16px 16px calc(90px + var(--safe-b)); max-width: 1100px; margin: 0 auto; }

.bottomnav { position: fixed; bottom: 0; inset-inline: 0; z-index: 20; background: var(--surface); border-top: 1px solid var(--line);
  display: flex; padding: 6px 4px calc(6px + var(--safe-b)); }
.bottomnav a { flex: 1; text-decoration: none; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; padding: 4px 0; border-radius: 10px; }
.bottomnav a svg { width: 22px; height: 22px; }
.bottomnav a.on { color: var(--brand); font-weight: 600; }
.bottomnav a.on svg { color: var(--gold); }

.drawer-back { position: fixed; inset: 0; background: rgba(15, 22, 24, .45); z-index: 40; }
.drawer { position: fixed; top: 0; bottom: 0; inset-inline-start: 0; width: min(300px, 84vw); background: var(--surface); z-index: 41;
  padding: calc(18px + var(--safe-t)) 12px 18px; overflow-y: auto; box-shadow: 0 0 40px rgba(0,0,0,.25); }
.drawer .me { padding: 8px 10px 14px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.drawer .me b { display: block; font-size: 16px; }
.drawer .me span { color: var(--muted); font-size: 13px; }
.drawer a, .drawer button.link { display: flex; align-items: center; gap: 12px; width: 100%; text-align: start; padding: 11px 10px; border-radius: 10px; color: var(--ink); text-decoration: none; background: none; border: 0; cursor: pointer; font-size: 15px; }
.drawer a svg, .drawer button.link svg { width: 20px; height: 20px; color: var(--brand-2); }
.drawer a.on { background: var(--surface-2); font-weight: 600; }
.drawer hr { border: 0; border-top: 1px solid var(--line); margin: 10px 0; }

@media (min-width: 960px) {
  .drawer-back { display: none; }
  .drawer { position: fixed; top: 0; box-shadow: none; border-inline-end: 1px solid var(--line); width: 250px; display: block !important; }
  .with-drawer .topbar, .with-drawer main { margin-inline-start: 250px; }
  .bottomnav, .menu-btn { display: none !important; }
  main { padding-bottom: 32px; }
}

/* components */
h2.page { font-size: 21px; margin: 4px 0 14px; }
h3 { font-size: 16px; margin: 0 0 10px; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.grid { display: grid; gap: 12px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 720px) { .grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } .grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .grid.md-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.grid.cols-3 .stat { padding: 10px; }
.grid.cols-3 .stat .k { font-size: 12px; line-height: 1.3; min-height: 2.6em; }
.stat { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.stat .k { color: var(--muted); font-size: 13px; }
.stat .v { font-size: 24px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .s { color: var(--muted); font-size: 12px; }
.stat.hero { background: linear-gradient(140deg, var(--brand), var(--brand-2)); color: #fff; }
.stat.hero .k, .stat.hero .s { color: rgba(255,255,255,.75); }
.stat.hero .v { color: #fff; font-size: 30px; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row > .grow { flex: 1; min-width: 140px; }
.spacer { flex: 1; }

label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input, select, textarea { width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(49, 63, 66, .14); }
textarea { min-height: 70px; resize: vertical; }
input[type=checkbox] { width: 18px; height: 18px; min-height: 0; accent-color: var(--brand); }
.inline-input { width: auto; min-width: 0; }
.checks { display: grid; gap: 6px; }
.checks label { display: flex; gap: 8px; align-items: center; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 10px; padding: 10px 16px; min-height: 44px;
  background: var(--brand); color: #fff; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.block { width: 100%; }
.btn.gold { background: var(--gold); }
.btn.ghost { background: var(--surface-2); color: var(--brand); }
.btn.danger { background: var(--bad-soft); color: var(--bad); }
.btn.ok { background: var(--ok-soft); color: var(--ok); }
.btn.sm { padding: 6px 10px; min-height: 34px; font-size: 13px; }
.btn svg { width: 18px; height: 18px; }

.list { display: grid; gap: 8px; }
.item { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); padding: 12px 14px; display: flex; gap: 12px; align-items: center; }
.item .main { flex: 1; min-width: 0; }
.item .main b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .main small { color: var(--muted); display: block; }
.item .side { text-align: end; white-space: nowrap; }
.item.click { cursor: pointer; }
.avatar { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--gold-soft); color: #7a5a2c; font-weight: 700; flex: none; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--brand-2); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.gold { background: var(--gold-soft); color: #7a5a2c; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.empty { text-align: center; color: var(--muted); padding: 28px 10px; }

.table-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: start; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
tfoot td { font-weight: 700; }

.att-row { display: grid; grid-template-columns: 1fr; gap: 8px; }
.att-row .ctrls { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 6px; }
.att-row .ctrls .t { display: flex; gap: 4px; }
.att-row .ctrls .t input { padding: 8px 6px; }
.att-row .ctrls .t button { flex: none; }

.day-col h4 { margin: 0 0 6px; font-size: 14px; color: var(--brand-2); }
.shift { display: flex; justify-content: space-between; gap: 8px; align-items: center; background: var(--surface-2); border-radius: 10px; padding: 8px 10px; margin-bottom: 6px; font-size: 14px; }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(15, 22, 24, .5); z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--surface); width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto; border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + var(--safe-b)); }
.modal header { display: flex; align-items: center; margin-bottom: 12px; }
.modal header h3 { flex: 1; margin: 0; font-size: 18px; }
@media (min-width: 600px) { .modal-back { align-items: center; } .modal { border-radius: 20px; } }

#toast { position: fixed; bottom: calc(86px + var(--safe-b)); left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 14px; z-index: 100; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; }
#toast.bad { background: var(--bad); }

.step { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; color: var(--brand-2); margin: 14px 0 8px; }
.step .n { width: 22px; height: 22px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 12px; }
.pay-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.pay-opts label { position: relative; }
.pay-opts input { position: absolute; opacity: 0; pointer-events: none; }
.pay-opts span { display: block; text-align: center; padding: 12px; border: 2px solid var(--line); border-radius: 12px; font-weight: 700; cursor: pointer; background: var(--surface); }
.pay-opts input:checked + span { border-color: var(--gold); background: var(--gold-soft); color: #7a5a2c; }
.pay-opts input:focus-visible + span { box-shadow: 0 0 0 3px rgba(49, 63, 66, .22); }
.clock-btn { min-height: 64px; font-size: 18px; border-radius: 16px; }
.cust-found { background: var(--gold-soft); border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }

@media print {
  .topbar, .bottomnav, .drawer, .drawer-back, .no-print { display: none !important; }
  .with-drawer main { margin: 0; }
  main { padding: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}

/* Demure logo */
.splash img { width: 96px; height: 96px; }
.auth { align-content: center; justify-items: center; gap: 4px; }
.auth-logo { width: min(260px, 70vw); height: auto; display: block; margin: 0 auto 6px; }
.auth-card h1 { margin-top: 2px; }
.topbar .brand-mark { width: 30px; height: 30px; border-radius: 8px; flex: none; }
.drawer .me { display: flex; gap: 10px; align-items: center; }
.drawer .me img { width: 44px; height: 44px; border-radius: 12px; flex: none; }
.stat.hero { background: linear-gradient(140deg, #313f42, #44555a); }
.stat.hero .v { color: #e7c88a; }
.topbar .brand-title { color: #e2bd78; font-family: Georgia, 'Times New Roman', serif; letter-spacing: 2px; font-weight: 700; }
.topbar .brand-title { flex: 1 0 auto; overflow: visible; font-size: 16px; }
.topbar select { flex: 0 1 auto; min-width: 0; max-width: 42vw; text-overflow: ellipsis; }
