@font-face {
  font-family: 'Cairo';
  src: url('/fonts/cairo-400-arabic.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF;
}
@font-face {
  font-family: 'Cairo';
  src: url('/fonts/cairo-700-arabic.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF;
}
@font-face {
  font-family: 'Cairo';
  src: url('/fonts/cairo-400-latin.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
  unicode-range: U+0000-00FF;
}
@font-face {
  font-family: 'Cairo';
  src: url('/fonts/cairo-700-latin.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
  unicode-range: U+0000-00FF;
}

:root {
  --red: #F00202;
  --red-dark: #B80000;
  --red-light: #FFE9E9;
  --white: #ffffff;
  --ink: #20242b;
  --muted: #6b7280;
  --line: #f0d6d6;
  --bg: #fff7f7;
  --ok: #0a8a3a;
  --radius: 16px;
  --shadow: 0 2px 10px rgba(240, 2, 2, .08);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Cairo', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}
img { max-width: 100%; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

.splash {
  min-height: 100vh; display: flex; flex-direction: column; gap: 14px;
  align-items: center; justify-content: center; color: var(--red);
  font-weight: 700; font-size: 22px;
}
.splash img { width: 120px; height: 120px; border-radius: 28px; box-shadow: var(--shadow); }

/* ---------- header ---------- */
.topbar {
  background: linear-gradient(180deg, var(--red), var(--red-dark));
  color: var(--white);
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  border-radius: 0 0 22px 22px;
  display: flex; align-items: center; gap: 12px;
  position: sticky; top: 0; z-index: 20;
}
.topbar img { width: 44px; height: 44px; border-radius: 12px; background: #fff; }
.topbar .title { font-weight: 700; font-size: 18px; line-height: 1.2; }
.topbar .subtitle { font-size: 12.5px; opacity: .92; }
.topbar .spacer { flex: 1; }
.sync-badge {
  font-size: 11.5px; background: rgba(255,255,255,.18); color: #fff;
  padding: 4px 10px; border-radius: 999px; display: flex; align-items: center; gap: 6px;
  white-space: nowrap;
}
.sync-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: #7CFC9A; }
.sync-badge.off .dot { background: #ffd24d; }
.icon-btn {
  background: rgba(255,255,255,.16); border: 0; color: #fff; border-radius: 12px;
  width: 40px; height: 40px; font-size: 18px; display: flex; align-items: center; justify-content: center;
}

/* ---------- layout ---------- */
.page { padding: 16px; max-width: 720px; margin: 0 auto; padding-bottom: 110px; }
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.card {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow);
}
.card .label { font-size: 12.5px; color: var(--muted); }
.card .value { font-size: 20px; font-weight: 700; color: var(--red); margin-top: 2px; }
.card .value.neutral { color: var(--ink); }
.card.wide { grid-column: 1 / -1; }
.section-title { font-weight: 700; font-size: 15px; margin: 18px 4px 8px; color: var(--ink); }

/* ---------- big action buttons ---------- */
.big-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.big-btn {
  border: 0; border-radius: 20px; padding: 22px 12px; font-size: 18px; font-weight: 700;
  display: flex; flex-direction: column; align-items: center; gap: 8px; box-shadow: var(--shadow);
}
.big-btn .emoji { font-size: 30px; }
.big-btn.out { background: var(--red); color: #fff; }
.big-btn.in { background: #fff; color: var(--red); border: 2px solid var(--red); }
.big-btn:active { transform: scale(.98); }

/* ---------- primary buttons ---------- */
.btn {
  background: var(--red); color: #fff; border: 0; border-radius: 14px;
  padding: 13px 18px; font-size: 16px; font-weight: 700; width: 100%;
}
.btn:active { transform: scale(.99); }
.btn.secondary { background: var(--red-light); color: var(--red); }
.btn.ghost { background: #fff; color: var(--red); border: 1.5px solid var(--red); }
.btn.small { width: auto; padding: 8px 14px; font-size: 14px; border-radius: 10px; }
.btn.danger { background: #fff; color: var(--red-dark); border: 1.5px solid var(--red-dark); }
.btn:disabled { opacity: .5; }

/* ---------- forms ---------- */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13.5px; font-weight: 700; margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 14px;
  font-size: 17px; background: #fff; color: var(--ink);
}
.field input:focus, .field select:focus { outline: 2px solid var(--red); border-color: var(--red); }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; padding: 40px 20px; background: linear-gradient(180deg, var(--red) 0 260px, var(--bg) 260px); }
.login-logo { width: 110px; height: 110px; border-radius: 26px; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.login-name { color: #fff; font-size: 26px; font-weight: 700; margin: 12px 0 24px; }
.login-card { background: #fff; border-radius: 22px; padding: 20px; width: 100%; max-width: 420px; box-shadow: 0 8px 30px rgba(0,0,0,.12); }
.tabs { display: flex; background: var(--red-light); border-radius: 12px; padding: 4px; margin-bottom: 16px; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 10px; font-size: 15px; font-weight: 700; color: var(--red); border-radius: 9px; }
.tabs button.active { background: var(--red); color: #fff; }
.link-btn { background: none; border: 0; color: var(--red); font-weight: 700; font-size: 14px; padding: 10px; width: 100%; text-align: center; }
.joincode-hero { text-align: center; background: var(--red-light); border: 2px dashed var(--red); border-radius: 16px; padding: 16px; margin: 14px 0; }
.joincode-hero .code { font-size: 34px; font-weight: 700; letter-spacing: 6px; color: var(--red); direction: ltr; }

/* ---------- lists ---------- */
.tx-item {
  background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px;
  margin-bottom: 8px; display: flex; align-items: center; gap: 12px; box-shadow: var(--shadow);
}
.tx-item .badge { width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 19px; flex-shrink: 0; }
.tx-item .badge.out { background: var(--red); color: #fff; }
.tx-item .badge.in { background: var(--red-light); color: var(--red); }
.tx-item .info { flex: 1; min-width: 0; }
.tx-item .phone { font-weight: 700; font-size: 15.5px; direction: ltr; text-align: right; }
.tx-item .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tx-item .amounts { text-align: left; }
.tx-item .amount { font-weight: 700; font-size: 16px; }
.tx-item .amount.out { color: var(--red); }
.tx-item .amount.in { color: var(--ok); }
.tx-item .comm { font-size: 11.5px; color: var(--muted); }
.tx-item.void { opacity: .55; }
.pill { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.pill.pending { background: #fff4d6; color: #8a6400; }
.pill.void { background: #eee; color: #555; }
.pill.live { background: var(--red-light); color: var(--red); }

.empty { text-align: center; color: var(--muted); padding: 30px 10px; font-size: 14px; }

/* ---------- bottom nav ---------- */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  background: #fff; border-top: 1px solid var(--line);
  display: flex; padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav button {
  flex: 1; border: 0; background: none; padding: 8px 2px 10px; font-size: 11.5px; font-weight: 700;
  color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.bottomnav button .emoji { font-size: 21px; }
.bottomnav button.active { color: var(--red); }

/* ---------- modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: #fff; width: 100%; max-width: 560px; border-radius: 22px 22px 0 0;
  padding: 20px; max-height: 88vh; overflow-y: auto;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
}
.modal .modal-title { font-size: 18px; font-weight: 700; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.modal .close-x { margin-inline-start: auto; background: var(--red-light); color: var(--red); border: 0; width: 34px; height: 34px; border-radius: 10px; font-size: 16px; }

/* ---------- toasts ---------- */
#toasts { position: fixed; top: 12px; left: 0; right: 0; z-index: 100; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  background: var(--ink); color: #fff; padding: 11px 20px; border-radius: 999px; font-size: 14.5px; font-weight: 700;
  box-shadow: 0 4px 16px rgba(0,0,0,.25); animation: toastin .25s ease;
}
.toast.ok { background: var(--ok); }
.toast.err { background: var(--red-dark); }
@keyframes toastin { from { transform: translateY(-16px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- report table ---------- */
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 10px 12px; text-align: right; border-bottom: 1px solid #f6e3e3; white-space: nowrap; }
th { background: var(--red-light); color: var(--red-dark); font-weight: 700; }
tr:last-child td { border-bottom: 0; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { border: 1.5px solid var(--red); color: var(--red); background: #fff; padding: 8px 14px; border-radius: 999px; font-weight: 700; font-size: 13.5px; }
.chip.active { background: var(--red); color: #fff; }

.balance-hero { background: linear-gradient(135deg, var(--red), var(--red-dark)); color: #fff; border-radius: 20px; padding: 22px; text-align: center; }
.balance-hero .num { font-size: 34px; font-weight: 700; }
.balance-hero .lbl { font-size: 13px; opacity: .9; }

.cashier-row { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-bottom: 8px; display: flex; align-items: center; gap: 12px; box-shadow: var(--shadow); }
.cashier-row .avatar { width: 42px; height: 42px; border-radius: 50%; background: var(--red-light); color: var(--red); display: flex; align-items: center; justify-content: center; font-size: 19px; font-weight: 700; }
.cashier-row .info { flex: 1; }
.cashier-row .name { font-weight: 700; }
.cashier-row .sub { font-size: 12px; color: var(--muted); }
.status-dot { width: 10px; height: 10px; border-radius: 50%; }
.status-dot.on { background: var(--ok); }
.status-dot.off { background: #bbb; }

.kv-row { display: flex; justify-content: space-between; padding: 10px 4px; border-bottom: 1px dashed var(--line); font-size: 14.5px; }
.kv-row:last-child { border-bottom: 0; }
.kv-row .k { color: var(--muted); }
.kv-row .v { font-weight: 700; }

@media (min-width: 640px) {
  .cards { grid-template-columns: repeat(3, 1fr); }
  .modal-overlay { align-items: center; }
  .modal { border-radius: 22px; }
}
