/* MiQdar — shared styles (RTL first) */
:root {
  --brand: #0f766e;
  --brand-600: #0d5f59;
  --brand-50: #e7f4f2;
  --accent: #f59e0b;
  --accent-50: #fef6e7;
  --ink: #17212b;
  --muted: #64707d;
  --line: #e6e8e4;
  --bg: #f5f6f3;
  --card: #ffffff;
  --ok: #15803d;
  --ok-50: #e8f6ec;
  --warn: #b45309;
  --warn-50: #fdf3e2;
  --bad: #b91c1c;
  --bad-50: #fdeaea;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 32, 0.04), 0 4px 16px rgba(16, 24, 32, 0.05);
  --font: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
  --deep: #0c2d2a;
  --deep-ink: #cfe3df;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.6; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
h1, h2, h3 { margin: 0; line-height: 1.3; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--deep); color: var(--deep-ink); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.sb-brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; }
.sb-brand svg { width: 34px; height: 34px; }
.sb-brand b { font-size: 22px; font-weight: 800; letter-spacing: 0.3px; }
.sb-brand span { display: block; font-size: 12px; color: var(--deep-ink); opacity: .8; margin-top: -4px; }
.nav h4 { margin: 12px 12px 4px; font-size: 11px; letter-spacing: .5px; color: var(--deep-ink); opacity: .55; font-weight: 700; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 12px; border-radius: 10px; color: var(--deep-ink); text-decoration: none; font-weight: 600; font-size: 14.5px; }
.nav a:hover { background: rgba(255, 255, 255, 0.06); }
.nav a.active { background: var(--brand); color: #fff; }
.nav .ico { width: 22px; text-align: center; }
.nav .badge { margin-inline-start: auto; background: var(--accent); color: #2b1a00; border-radius: 99px; padding: 0 8px; font-size: 12px; }
.sidebar .foot { margin-top: auto; font-size: 12.5px; padding: 12px 10px 4px; display: flex; flex-direction: column; gap: 6px; }
.sidebar .foot a, .sidebar .foot button { color: var(--deep-ink); opacity: .85; background: none; border: 0; padding: 0; cursor: pointer; text-align: start; font: inherit; }
.lang-btn { border: 1px solid rgba(255,255,255,.25) !important; border-radius: 8px !important; padding: 4px 10px !important; align-self: flex-start; font-weight: 700 !important; }
.topbar { display: none; }
.banner { padding: 8px 14px; border-radius: 10px; margin-bottom: 14px; font-weight: 700; font-size: 14px; display: flex; gap: 10px; align-items: center; }
.banner.trial { background: var(--accent-50); color: var(--warn); }
.banner.bad { background: var(--bad-50); color: var(--bad); }
.banner a { margin-inline-start: auto; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatches button { width: 34px; height: 34px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.swatches button.on { box-shadow: 0 0 0 3px var(--ink); }
.thumb { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: var(--accent-50); display: grid; place-items: center; font-size: 26px; flex: none; }
.photo-box { display: flex; gap: 12px; align-items: center; }
.photo-box img, .photo-box .ph { width: 96px; height: 72px; border-radius: 12px; object-fit: cover; background: var(--accent-50); display: grid; place-items: center; font-size: 34px; }
.day-pick { display: flex; gap: 4px; flex-wrap: wrap; }
.day-pick label { display: inline-flex; align-items: center; gap: 4px; padding: 4px 9px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; }
.day-pick input { margin: 0; }
.keybox { font-family: monospace; direction: ltr; font-size: 15px; background: var(--bg); border-radius: 10px; padding: 8px 12px; display: inline-block; letter-spacing: 1px; font-weight: 700; }
.checklist li { margin-bottom: 6px; }
.checklist a { font-weight: 700; }
.main { padding: 26px 30px 60px; min-width: 0; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; font-weight: 800; }
.page-head .sub { color: var(--muted); font-size: 14px; }
.page-head .actions { margin-inline-start: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Cards & grids ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card h2 { font-size: 16px; font-weight: 800; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .label { color: var(--muted); font-size: 13px; font-weight: 600; }
.kpi .value { font-size: clamp(18px, 1.5vw, 24px); font-weight: 800; margin-top: 2px; white-space: nowrap; }
.kpi .hint { font-size: 12px; color: var(--muted); }
.kpi.good .value { color: var(--ok); }
.kpi.warn .value { color: var(--warn); }
.kpi.bad .value { color: var(--bad); }
.kpi.brand { background: linear-gradient(135deg, var(--brand), #13998e); color: #fff; border: 0; }
.kpi.brand .label, .kpi.brand .hint { color: #d3eeea; }

/* ---------- Buttons & forms ---------- */
.btn { border: 1px solid var(--line); background: #fff; padding: 8px 14px; border-radius: 10px; cursor: pointer; font-weight: 700; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { border-color: #cfd4cc; background: #fafbf9; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-600); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #2b1a00; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 4px 10px; font-size: 13px; border-radius: 8px; }
.btn.lg { padding: 12px 18px; font-size: 16px; }
.btn.block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 700; color: #3b4652; }
.input, select.input, textarea.input { border: 1px solid #d8dcd5; background: #fff; border-radius: 10px; padding: 8px 12px; width: 100%; font-weight: 500; }
.input:focus { outline: 2px solid var(--brand-50); border-color: var(--brand); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.seg { display: inline-flex; background: #eef0ec; border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; cursor: pointer; font-weight: 700; color: var(--muted); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
.t th { text-align: start; color: var(--muted); font-weight: 700; font-size: 12.5px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.t td { padding: 10px; border-bottom: 1px solid #f0f1ee; vertical-align: middle; white-space: nowrap; }
.t td.wrap { white-space: normal; min-width: 180px; }
.t tr:hover td { background: #fafbf9; }
.t .acts { display: flex; gap: 4px; }
.t tfoot td { font-weight: 800; border-top: 2px solid var(--line); }

/* ---------- Badges & alerts ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 9px; border-radius: 99px; font-size: 12px; font-weight: 700; background: #eef0ec; color: #44505c; white-space: nowrap; }
.badge.ok { background: var(--ok-50); color: var(--ok); }
.badge.warn { background: var(--warn-50); color: var(--warn); }
.badge.bad { background: var(--bad-50); color: var(--bad); }
.badge.brand { background: var(--brand-50); color: var(--brand); }
.alert-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; margin-bottom: 6px; }
.alert-row.bad { background: var(--bad-50); }
.alert-row.warn { background: var(--warn-50); }
.alert-row.info { background: var(--brand-50); }
.alert-row .what { flex: 1; min-width: 0; }
.alert-row .what b { display: block; }
.empty { text-align: center; color: var(--muted); padding: 22px; }

/* ---------- Chart ---------- */
.chart svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 4px; vertical-align: middle; }

/* ---------- POS ---------- */
.pos { display: grid; grid-template-columns: 1fr 360px; gap: 18px; align-items: start; }
.items-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.item-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; cursor: pointer; text-align: start; transition: transform 0.08s, border-color 0.08s; display: flex; flex-direction: column; gap: 2px; }
.item-card:hover { border-color: var(--brand); transform: translateY(-1px); }
.item-card .emoji { font-size: 34px; line-height: 1.2; }
.item-card .name { font-weight: 800; }
.item-card .price { color: var(--brand); font-weight: 800; }
.item-card.out { opacity: 0.45; cursor: not-allowed; }
.cart { position: sticky; top: 20px; }
.cart-line { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.cart-line .n { flex: 1; font-weight: 700; }
.qty { display: inline-flex; align-items: center; gap: 6px; }
.qty button { width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-weight: 800; }
.total-row { display: flex; justify-content: space-between; font-size: 20px; font-weight: 800; margin: 12px 0; }
.error-box { background: var(--bad-50); color: var(--bad); padding: 10px 12px; border-radius: 10px; font-weight: 600; font-size: 14px; margin: 8px 0; }

/* ---------- Kitchen board ---------- */
.board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.col { background: #eceee9; border-radius: var(--radius); padding: 12px; min-height: 300px; }
.col h3 { font-size: 15px; margin: 2px 4px 10px; display: flex; gap: 8px; align-items: center; }
.ticket { background: #fff; border-radius: 12px; padding: 12px; margin-bottom: 10px; box-shadow: var(--shadow); border-top: 4px solid var(--brand); }
.ticket.new { border-top-color: var(--accent); }
.ticket.ready { border-top-color: var(--ok); }
.ticket .head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.ticket .head b { font-size: 17px; }
.ticket ul { margin: 6px 0; padding-inline-start: 18px; }
.ticket .foot { display: flex; gap: 6px; margin-top: 8px; }

/* ---------- Menu cards (admin) ---------- */
.mcard { display: grid; grid-template-columns: 52px 1fr auto; gap: 12px; align-items: center; }
.mcard .emoji { font-size: 36px; text-align: center; }
.bar { height: 8px; background: #eef0ec; border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; }
.recipe-table td { padding: 6px 8px; }
.recipe-table .input { padding: 6px 8px; }
.cost-summary { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; background: var(--brand-50); padding: 12px; border-radius: 12px; margin-top: 12px; }
.cost-summary div { text-align: center; }
.cost-summary b { display: block; font-size: 18px; }
.cost-summary div > span:first-child { display: block; font-size: 12px; color: var(--muted); font-weight: 700; }

/* ---------- Modal & toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(12, 22, 28, 0.45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; overflow-y: auto; }
.modal { background: #fff; border-radius: 18px; width: min(560px, 100%); padding: 22px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25); }
.modal.wide { width: min(880px, 100%); }
.modal h2 { font-size: 19px; font-weight: 800; margin-bottom: 14px; }
.modal .foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--deep); color: #fff; padding: 10px 18px; border-radius: 12px; font-weight: 700; z-index: 60; box-shadow: var(--shadow); }
.toast.bad { background: var(--bad); }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(circle at 30% 20%, var(--brand), var(--deep) 65%); padding: 16px; }
.login .box { background: #fff; border-radius: 22px; padding: 30px; width: min(360px, 100%); text-align: center; }
.login .box svg { width: 56px; height: 56px; }
.login h1 { font-size: 28px; font-weight: 800; }
.pin { font-size: 28px; letter-spacing: 12px; text-align: center; }

/* ---------- Release 2: checks, payments, floor, options, reports ---------- */
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
a.btn { text-decoration: none; }
.seg a { padding: 6px 12px; border-radius: 8px; font-weight: 700; color: var(--muted); text-decoration: none; }
.seg a.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }
.input.sm { padding: 4px 8px; font-size: 13px; width: auto; }
.link { cursor: pointer; color: var(--brand); text-decoration: underline; }
.item-card .item-img { width: 100%; height: 84px; object-fit: cover; border-radius: 10px; margin-bottom: 4px; }
.totals { margin: 10px 0; }
.cart-total { display: flex; justify-content: space-between; padding: 2px 0; font-size: 14px; }
.cart-total.neg span:last-child { color: var(--bad); }
.cart-total.grand { font-size: 19px; font-weight: 800; border-top: 1px solid var(--line); margin-top: 4px; padding-top: 6px; }
.cart-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin-top: 10px; }
.cart-line.voided { opacity: 0.45; text-decoration: line-through; }
.round-head { font-size: 12px; font-weight: 800; color: var(--brand); margin-top: 8px; }
.ticket li.new-round { background: var(--accent-50); border-radius: 6px; padding: 0 4px; }
.pay-due { display: flex; justify-content: space-between; align-items: center; background: var(--brand-50); border-radius: 12px; padding: 12px 16px; font-size: 18px; }
.pay-due b { font-size: 26px; color: var(--brand); }
.pay-change { font-size: 22px; font-weight: 800; color: var(--ok); padding-top: 4px; }
.pay-sum { margin-top: 8px; font-weight: 700; }
.opt-group { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; margin: 0 0 10px; }
.opt-group legend { padding: 0 6px; }
.opt-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 6px; }
.opt { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.opt span { flex: 1; }
.opt:has(input:checked) { border-color: var(--brand); background: var(--brand-50); }
.opt-edit { border: 1px solid var(--line); border-radius: 10px; padding: 8px; margin-bottom: 8px; }
details.more { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; margin-top: 12px; }
details.more summary { cursor: pointer; font-weight: 800; }
/* floor plan */
.area-title { font-size: 15px; margin: 16px 0 8px; color: var(--muted); }
.floor { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.table-tile { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 14px 8px; border-radius: 16px; border: 2px solid var(--line); background: #fff; cursor: pointer; min-height: 112px; justify-content: center; font: inherit; transition: transform 0.08s; }
.table-tile:hover { transform: translateY(-2px); }
.table-tile .tname { font-size: 24px; font-weight: 800; }
.table-tile.free { border-color: var(--ok); }
.table-tile.free .tname { color: var(--ok); }
.table-tile.busy { border-color: var(--accent); background: var(--accent-50); }
.table-tile.served { border-color: var(--brand); background: var(--brand-50); }
.legend-dots { display: inline-flex; gap: 10px; align-items: center; font-size: 13px; }
.legend-dots i { display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-inline-end: 4px; vertical-align: middle; }
.legend-dots i.free { background: var(--ok); }
.legend-dots i.busy { background: var(--accent); }
.legend-dots i.served { background: var(--brand); }
/* shift */
.z-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 12px; }
.z-grid div { background: var(--bg); border-radius: 10px; padding: 8px 12px; }
.z-grid div > span:first-child { display: block; font-size: 12px; color: var(--muted); font-weight: 700; }
.z-grid div b { font-size: 17px; }
.z-grid div.ok { background: var(--ok-50); }
.z-grid div.warn { background: var(--warn-50); }
.z-grid div.bad { background: var(--bad-50); }
/* reports */
.bars { display: flex; align-items: flex-end; gap: 4px; height: 170px; padding-top: 6px; }
.bars .b { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; gap: 4px; min-width: 0; }
.bars .b i { display: block; width: 100%; max-width: 30px; background: var(--brand); border-radius: 6px 6px 2px 2px; min-height: 2px; }
.bars .b span { font-size: 11px; color: var(--muted); white-space: nowrap; }
.me-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.me { border-radius: 12px; padding: 10px 12px; }
.me h3 { margin: 0; font-size: 15px; }
.me p { margin: 2px 0 8px; color: var(--muted); }
.me.star { background: var(--ok-50); }
.me.plowhorse { background: var(--accent-50); }
.me.puzzle { background: var(--brand-50); }
.me.dog { background: var(--bad-50); }
.me-item { display: flex; justify-content: space-between; gap: 6px; padding: 3px 0; border-bottom: 1px dashed rgba(0, 0, 0, 0.08); }
.ai-answer { margin-top: 12px; line-height: 1.8; white-space: normal; }
.ai-answer:not(:empty) { background: var(--brand-50); border-radius: 12px; padding: 12px 16px; }

@media (max-width: 1000px) {
  .shell { grid-template-columns: 1fr; }
  .topbar { display: flex; align-items: center; gap: 10px; background: var(--deep); color: #fff; padding: 10px 16px; position: sticky; top: 0; z-index: 40; }
  .topbar svg { width: 30px; height: 30px; }
  .topbar b { font-size: 18px; flex: 1; }
  .topbar button { background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: 10px; padding: 6px 12px; font: inherit; font-weight: 700; }
  .sidebar { position: fixed; top: 0; bottom: 0; inset-inline-start: 0; width: 270px; height: 100vh; z-index: 45; transform: translateX(110%); transition: transform .2s; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  [dir="ltr"] .sidebar { transform: translateX(-110%); }
  .shell.open .sidebar { transform: none; }
  .shell.open::after { content: ''; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 44; }
  .main { padding: 16px 16px 50px; }
  .page-head h1 { font-size: 21px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi .value { font-size: 19px; }
  .pos, .g2, .g3, .board { grid-template-columns: 1fr; }
  .g4, .me-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cost-summary { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr !important; }
  .form-grid > * { grid-column: auto !important; }
}

@media print {
  .sidebar, .page-head .actions, .toolbar, .no-print { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; }
  .card, .kpi { box-shadow: none; break-inside: avoid; }
  body { background: #fff; }
}
