/* Restaurant OS design system — shared by website, admin, KDS and driver app.
   RTL-aware: layout uses logical properties (margin-inline, padding-inline, inset-inline). */
:root {
  /* MIRA'S identity: red + white dominant, navy for accents only */
  --brand: #BF040B;
  --brand-strong: #8F0308;
  --brand-soft: #FDECEC;
  --navy: #04395C;
  --navy-strong: #022A45;
  --navy-soft: #E6EEF4;
  --ink: #1c1917;
  --ink-2: #44403c;
  --muted: #78716c;
  --line: #e7e5e4;
  --line-2: #d6d3d1;
  --bg: #fafaf9;
  --surface: #ffffff;
  --surface-2: #f5f5f4;
  --ok: #15803d;   --ok-soft: #dcfce7;
  --warn: #b45309; --warn-soft: #fef3c7;
  --bad: #b91c1c;  --bad-soft: #fee2e2;
  --info: #1d4ed8; --info-soft: #dbeafe;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 12px rgba(0,0,0,.05);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.12);
  --font: "Poppins", "IBM Plex Sans Arabic", "Segoe UI", Tahoma, system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --tap: 44px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #f5f5f4; --ink-2: #d6d3d1; --muted: #a8a29e; --line: #2e2b29; --line-2: #3f3b38;
    --bg: #0f0e0d; --surface: #1a1817; --surface-2: #232120; --brand-soft: #3a0a0c; --navy-soft: #0b2233;
    --ok-soft: #12361f; --warn-soft: #3b2a0b; --bad-soft: #3d1414; --info-soft: #14254a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ink: #f5f5f4; --ink-2: #d6d3d1; --muted: #a8a29e; --line: #2e2b29; --line-2: #3f3b38;
  --bg: #0f0e0d; --surface: #1a1817; --surface-2: #232120; --brand-soft: #3a0a0c; --navy-soft: #0b2233;
  --ok-soft: #12361f; --warn-soft: #3b2a0b; --bad-soft: #3d1414; --info-soft: #14254a;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--ink); background: var(--bg); }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--brand-ink, var(--brand)); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 var(--s3); }
h1 { font-size: 1.6rem; } h2 { font-size: 1.3rem; } h3 { font-size: 1.1rem; }
p { margin: 0 0 var(--s3); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num, .money { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
.mono { font-family: var(--mono); }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; }

/* Layout helpers */
.container { width: 100%; max-width: 1200px; margin-inline: auto; padding-inline: var(--s4); }
.row { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: var(--s3); }
.grid { display: grid; gap: var(--s4); }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.spacer { flex: 1; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--s5); box-shadow: var(--shadow); }
.card.flat { box-shadow: none; }
.card h2, .card h3 { margin-bottom: var(--s3); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: 40px; padding: 0 var(--s4);
  border-radius: var(--radius); border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .12s, border-color .12s, transform .05s; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand-ink, var(--brand)); color: #fff; }
.btn.primary:hover { background: var(--brand-strong); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { min-height: 32px; padding: 0 var(--s3); font-size: .85rem; }
.btn.lg { min-height: 52px; padding: 0 var(--s5); font-size: 1.05rem; }
.btn.block { width: 100%; }

/* Forms */
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: var(--s1); }
.field { margin-bottom: var(--s4); }
.field .hint { font-size: .8rem; color: var(--muted); margin-top: var(--s1); }
.field .err, .error-text { font-size: .85rem; color: var(--bad); margin-top: var(--s1); }
input:not([type]), input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number], input[type=search], input[type=date],
input[type=datetime-local], input[type=time], input[type=url], select, textarea {
  width: 100%; min-height: 42px; padding: var(--s2) var(--s3); border: 1px solid var(--line-2); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); font: inherit; }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brand-ink, var(--brand)); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent); }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--bad); }
.check { display: flex; align-items: center; gap: var(--s2); font-weight: 500; }
.check input { width: 18px; height: 18px; }
.form-grid { display: grid; gap: 0 var(--s4); grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* Badges / status */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700;
  background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge.brand { background: var(--brand-soft); color: var(--brand-strong); border-color: transparent; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--muted); }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }

/* Alerts */
.alert { padding: var(--s3) var(--s4); border-radius: var(--radius); margin-bottom: var(--s4); border: 1px solid transparent; }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.bad { background: var(--bad-soft); color: var(--bad); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.info { background: var(--info-soft); color: var(--info); }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
table.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: 10px 12px; text-align: start; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { background: var(--surface-2); font-size: .8rem; text-transform: uppercase; letter-spacing: .02em; color: var(--muted); font-weight: 700; white-space: nowrap; }
.table th a { color: inherit; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.table td.actions { white-space: nowrap; text-align: end; }
.table .right, .table td.num { text-align: end; }
.empty { padding: var(--s7) var(--s4); text-align: center; color: var(--muted); }
.empty .icon { font-size: 2rem; margin-bottom: var(--s2); }

/* Pagination */
.pager { display: flex; gap: var(--s2); align-items: center; justify-content: flex-end; margin-top: var(--s3); }

/* Modal (native <dialog>) */
dialog.modal { border: 0; border-radius: var(--radius-lg); padding: 0; width: min(560px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); }
dialog.modal::backdrop { background: rgba(0,0,0,.45); }
dialog.modal .modal-head { padding: var(--s4) var(--s5); border-bottom: 1px solid var(--line); font-weight: 700; }
dialog.modal .modal-body { padding: var(--s5); }
dialog.modal .modal-foot { padding: var(--s4) var(--s5); border-top: 1px solid var(--line); display: flex; gap: var(--s2); justify-content: flex-end; }

/* Toasts */
.toasts { position: fixed; inset-block-end: 16px; inset-inline-end: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 1000; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: var(--radius); box-shadow: var(--shadow-lg); max-width: 360px; font-size: .92rem; }
.toast.bad { background: var(--bad); color: #fff; } .toast.ok { background: var(--ok); color: #fff; }

/* Loading */
.spinner { width: 18px; height: 18px; border: 2px solid currentColor; border-inline-end-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: var(--radius); }
@keyframes sk { to { background-position: -200% 0; } }

/* Stat tiles */
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--s4); }
.stat .label { color: var(--muted); font-size: .82rem; font-weight: 600; }
.stat .value { font-size: 1.5rem; font-weight: 800; margin-top: 2px; }
.stat .sub { font-size: .8rem; color: var(--muted); }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: var(--s4); overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active, .tabs a:hover { color: var(--ink); border-color: var(--brand-ink, var(--brand)); text-decoration: none; }

@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .card { padding: var(--s4); }
  h1 { font-size: 1.35rem; }
}
@media print {
  .no-print, nav, header.topbar, aside { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border: 0; padding: 0; }
}

/* Order times (admin order page, tracking page) */
.text-bad { color: var(--bad); }
.order-times { margin-bottom: var(--s4); }
.dur-chips { display: flex; flex-wrap: wrap; gap: var(--s2); margin: var(--s2) 0 var(--s3); }
.dur-chip { display: flex; flex-direction: column; gap: 2px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 10px; min-width: 96px; background: var(--surface, transparent); }
.dur-chip strong { font-size: 1.05rem; }
.dur-chip.total { border-color: var(--brand-ink, var(--brand)); }
.otl { list-style: none; margin: 0; padding: 0; border-inline-start: 2px solid var(--line); }
.otl li { position: relative; display: grid; grid-template-columns: 88px 1fr; column-gap: var(--s2); padding: 6px var(--s3); align-items: baseline; }
.otl li::before { content: ''; position: absolute; inset-inline-start: -7px; top: 13px; width: 12px; height: 12px; border-radius: 50%; background: var(--brand); }
.otl li > .small { grid-column: 2; }
.otl time { color: var(--muted, #6b7280); }
.otl .otl-left_restaurant::before, .otl .otl-delivered::before, .otl .otl-picked_up::before { background: var(--ok); }
.otl .otl-cancelled::before { background: var(--bad); }
@media (max-width: 520px) { .otl li { grid-template-columns: 72px 1fr; } }

/* User guide */
.help-section h2 { font-size: 1.15rem; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0 0 6px; }
.help-steps { padding-inline-start: 1.4em; line-height: 1.9; }
.help-steps li::marker { font-weight: 700; color: var(--brand-ink, var(--brand)); }
.help-tips { list-style: none; padding: 0; margin: 8px 0 0; color: var(--ink-2, inherit); }
.help-tips li { padding: 6px 10px; background: var(--brand-soft, rgba(0,0,0,.04)); border-radius: 8px; margin-top: 6px; }
.help-index { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.chip-link { padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; color: inherit; }
.chip-link:hover { border-color: var(--brand-ink, var(--brand)); }
.help-page { display: grid; gap: 12px; }
.help-dialog { max-width: 640px; width: calc(100% - 32px); }
.help-dialog .modal-body { max-height: 70vh; overflow: auto; }
@media print { .help-page .card { break-inside: avoid; } }

/* line icons (sprite: assets/icons/icons.svg) */
.ic { width: 1.15em; height: 1.15em; flex: none; display: inline-block; vertical-align: -.2em; stroke-width: 2; }
.ic.sm { width: .95em; height: .95em; }
.ic.lg { width: 1.5em; height: 1.5em; }
.ic.xl { width: 2.25em; height: 2.25em; }
.help-section .help-ic { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--brand-soft); color: var(--brand-ink, var(--brand)); }
.help-section .help-ic .ic { width: 18px; height: 18px; }
.help-tips li { list-style: none; display: flex; gap: 8px; align-items: flex-start; }
.help-tips .ic { color: var(--navy); margin-top: 3px; }
.help-btn { display: inline-flex; align-items: center; gap: 6px; }
.chip-link { display: inline-flex; align-items: center; gap: 6px; }
