:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-2: #f8faf9;
  --ink: #101817;
  --ink-2: #5c6b68;
  --ink-3: #8a9694;
  --line: #e2e8e6;
  --line-2: #eef2f1;
  --brand: #0e7a5f;
  --brand-2: #0b5f4a;
  --brand-soft: #e6f4ef;
  --accent: #b45309;
  --accent-soft: #fdf3e3;
  --danger: #c0301b;
  --danger-soft: #fdecea;
  --ok: #127a58;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 23, 0.06), 0 8px 24px -16px rgba(16, 24, 23, 0.28);
  --font: "Segoe UI", "Noto Kufi Arabic", "Tahoma", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
h1, h2, h3, h4, p { margin: 0; }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- boot ---------- */
.boot { display: grid; place-items: center; gap: 12px; min-height: 100vh; color: var(--ink-2); }
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--brand);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--line-2), var(--surface-2), var(--line-2)); background-size: 200% 100%; animation: sk 1.2s ease-in-out infinite; border-radius: 8px; }
@keyframes sk { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---------- primitives ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 9px 16px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-2); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--line-2); color: var(--ink); }
.btn-danger { background: var(--danger-soft); border-color: #f6c9c1; color: var(--danger); }
.btn-sm { min-height: 34px; padding: 5px 11px; font-size: 13px; border-radius: 9px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 16px; }
.card-title { font-size: 15px; font-weight: 700; letter-spacing: .1px; }
.card-sub { font-size: 13px; color: var(--ink-2); }

.field { display: grid; gap: 6px; }
.field > label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.input, .select, textarea.input {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.input::placeholder { color: var(--ink-3); }
.hint { font-size: 12px; color: var(--ink-3); }
.error { font-size: 13px; color: var(--danger); background: var(--danger-soft); border: 1px solid #f6c9c1; padding: 9px 12px; border-radius: 10px; }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--line-2); color: var(--ink-2); }
.badge.ok { background: var(--brand-soft); color: var(--brand-2); }
.badge.warn { background: var(--accent-soft); color: var(--accent); }
.badge.bad { background: var(--danger-soft); color: var(--danger); }

.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.tiny { font-size: 12px; color: var(--ink-3); }
.mono { font-variant-numeric: tabular-nums; }
.center { text-align: center; }
.stack { display: grid; gap: 12px; }
.stack-sm { display: grid; gap: 8px; }

/* ---------- shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: rgba(255,255,255,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 11px; background: var(--brand-soft); color: var(--brand-2);
  display: grid; place-items: center; font-weight: 800; font-size: 15px; overflow: hidden; flex: none;
}
.brand-logo img { width: 100%; height: 100%; object-fit: cover; }
.brand-name { font-weight: 800; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 12px; color: var(--ink-3); white-space: nowrap; }

.nav { display: flex; gap: 4px; overflow-x: auto; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--line); scrollbar-width: none; position: sticky; top: 59px; z-index: 19; }
.nav::-webkit-scrollbar { display: none; }
.nav button {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  padding: 8px 13px; border-radius: 10px; border: 1px solid transparent;
  background: transparent; color: var(--ink-2); font-weight: 600; font-size: 13.5px; cursor: pointer;
}
.nav button[aria-current="page"] { background: var(--brand-soft); color: var(--brand-2); border-color: #cfe9e0; }
.nav button:hover { background: var(--line-2); }

.page { padding: 16px; max-width: 1180px; margin: 0 auto; display: grid; gap: 14px; padding-bottom: 96px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-title { font-size: 20px; font-weight: 800; }
.page-sub { font-size: 13px; color: var(--ink-2); }

.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 860px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 480px) { .g2, .g3 { grid-template-columns: 1fr; } .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .kpi-value { font-size: 20px; } }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 50% -10%, #e7f3ee 0%, var(--bg) 55%); }
.login-card { width: 100%; max-width: 420px; display: grid; gap: 16px; padding: 22px; }
.login-head { display: grid; gap: 4px; text-align: center; }
.login-title { font-size: 22px; font-weight: 800; }
.demo-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.demo-chip { display: grid; gap: 2px; padding: 10px 6px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; text-align: center; font-weight: 700; font-size: 13px; }
.demo-chip span { font-weight: 500; font-size: 11px; color: var(--ink-3); }
.demo-chip:hover { border-color: var(--brand); background: var(--brand-soft); }
.divider { display: flex; align-items: center; gap: 10px; color: var(--ink-3); font-size: 12px; }
.divider::before, .divider::after { content: ""; height: 1px; background: var(--line); flex: 1; }

/* ---------- KPI ---------- */
.kpi { padding: 14px 16px; display: grid; gap: 6px; }
.kpi-label { font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
.kpi-value { font-size: 24px; font-weight: 800; letter-spacing: -.3px; font-variant-numeric: tabular-nums; }
.kpi-foot { font-size: 12px; color: var(--ink-3); }

/* ---------- till ---------- */
.till { display: grid; gap: 14px; align-items: start; }
@media (min-width: 960px) { .till { grid-template-columns: minmax(0, 1fr) 340px; } }
.cat-bar { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.cat-bar::-webkit-scrollbar { display: none; }
.cat-chip { padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; color: var(--ink-2); }
.cat-chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.item-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.item-card { display: grid; gap: 6px; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; text-align: start; }
.item-card:hover { border-color: #bcd9cf; }
.item-card:active { transform: scale(.99); }
.item-card.is-off { opacity: .5; cursor: not-allowed; }
.item-name { font-weight: 700; font-size: 14px; line-height: 1.35; }
.item-price { font-size: 13px; font-weight: 700; color: var(--brand-2); font-variant-numeric: tabular-nums; }
.item-card .row-between { margin-top: auto; }

.cart { position: sticky; top: 122px; display: grid; gap: 10px; }
.cart-lines { display: grid; gap: 8px; max-height: 46vh; overflow: auto; }
.cart-line { display: grid; grid-template-columns: 1fr auto; gap: 6px; padding: 9px 10px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line-2); }
.qty { display: inline-flex; align-items: center; gap: 4px; }
.qty button { width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 800; line-height: 1; }
.qty b { min-width: 20px; text-align: center; font-variant-numeric: tabular-nums; }
.totals { display: grid; gap: 4px; padding-top: 8px; border-top: 1px dashed var(--line); }
.total-line { display: flex; justify-content: space-between; font-size: 13.5px; color: var(--ink-2); }
.total-line.grand { font-size: 17px; font-weight: 800; color: var(--ink); padding-top: 4px; }

.cart-fab { position: fixed; inset-inline: 12px; bottom: 12px; z-index: 25; display: none; }
@media (max-width: 959px) {
  .cart { position: fixed; inset-inline: 0; bottom: 0; top: auto; z-index: 30; background: var(--surface); border-top: 1px solid var(--line); border-radius: 18px 18px 0 0; padding: 14px 14px calc(14px + env(safe-area-inset-bottom)); box-shadow: 0 -12px 30px -20px rgba(0,0,0,.4); transform: translateY(102%); transition: transform .22s ease; }
  .cart.is-open { transform: translateY(0); }
  .cart-fab { display: flex; }
  .cart-lines { max-height: 40vh; }
}

/* ---------- lists / tables ---------- */
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.list th { text-align: start; font-size: 12px; color: var(--ink-3); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.list td { padding: 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }

.list-item { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--surface); }
.list-item + .list-item { margin-top: 8px; }

.empty { display: grid; place-items: center; gap: 8px; padding: 32px 16px; text-align: center; color: var(--ink-2); }
.empty-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--line-2); color: var(--ink-3); }
.empty-title { font-weight: 700; color: var(--ink); }

.donut { display: grid; grid-template-columns: 132px 1fr; gap: 14px; align-items: center; }
.donut svg { width: 132px; height: 132px; }
.legend { display: grid; gap: 6px; }
.legend-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }

/* ---------- modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(8, 16, 14, .45); z-index: 60; display: grid; place-items: end center; padding: 0; }
@media (min-width: 640px) { .modal-backdrop { place-items: center; padding: 20px; } }
.modal { width: 100%; max-width: 480px; max-height: 92vh; overflow: auto; background: var(--surface); border-radius: 18px 18px 0 0; padding: 18px; display: grid; gap: 14px; }
@media (min-width: 640px) { .modal { border-radius: 18px; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.modal-title { font-size: 17px; font-weight: 800; }
.pay-methods { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pay-method { padding: 12px 6px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 700; font-size: 13.5px; }
.pay-method[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-2); }
.quick-cash { display: flex; flex-wrap: wrap; gap: 8px; }
.quick-cash button { padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); font-weight: 700; font-size: 13px; cursor: pointer; }
.change-box { padding: 12px; border-radius: 12px; background: var(--brand-soft); color: var(--brand-2); font-weight: 800; display: flex; justify-content: space-between; }

/* ---------- receipt ---------- */
.receipt { width: 100%; max-width: 300px; margin: 0 auto; background: #fff; color: #000; border: 1px dashed #c9d2cf; border-radius: 8px; padding: 12px; font-family: "Courier New", ui-monospace, monospace; font-size: 12px; }
.receipt h4 { font-size: 14px; text-align: center; margin-bottom: 2px; }
.receipt .r-center { text-align: center; }
.receipt .r-line { display: flex; justify-content: space-between; gap: 8px; }
.receipt .r-sep { border-top: 1px dashed #999; margin: 6px 0; }
.receipt .r-total { font-weight: 800; font-size: 13px; }
.receipt .r-bar { margin-top: 8px; display: grid; place-items: center; gap: 2px; }
.receipt .r-bar svg { width: 100%; height: 42px; }
.receipt .r-thanks { text-align: center; margin-top: 6px; font-size: 11px; }

@media print {
  body { background: #fff; }
  body > *:not(#app) { display: none !important; }
  #app .no-print { display: none !important; }
  .modal-backdrop { position: static; background: none; padding: 0; display: block; }
  .modal { max-width: none; border-radius: 0; padding: 0; box-shadow: none; border: 0; }
  .receipt { border: 0; max-width: none; width: 72mm; padding: 0 2mm; font-size: 11.5px; }
  @page { margin: 4mm; }
}
body.print-58 .receipt { width: 52mm; font-size: 11px; }

/* ---------- toast ---------- */
.toast { position: fixed; inset-inline: 0; bottom: 84px; margin: 0 auto; width: max-content; max-width: 90vw; z-index: 80; padding: 11px 16px; border-radius: 12px; background: #10201c; color: #fff; font-size: 13.5px; font-weight: 600; box-shadow: 0 10px 30px -12px rgba(0,0,0,.5); }
.toast.bad { background: #7a1d12; }
.toast.ok { background: #0b5f4a; }

.spin-inline { display: inline-block; width: 15px; height: 15px; border-radius: 50%; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; animation: spin .7s linear infinite; vertical-align: -2px; }
.btn-ghost .spin-inline, .btn:not(.btn-primary) .spin-inline { border-color: rgba(0,0,0,.15); border-top-color: var(--brand); }
