:root {
  --noir: #15110d;
  --noir-2: #1d1712;
  --cream: #f3ead9;
  --muted: #7a6a5c;
  --gold: #b8703f;
  --gold-soft: #e0a878;
  --bg: #f6f1e8;
  --panel: #ffffff;
  --line: #e6dcc9;
  --ink: #2a221c;
  --green: #4a7c59;
  --amber: #b8862f;
  --red: #a4433a;
  --ease: cubic-bezier(.22, 1, .36, 1);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Tajawal', Tahoma, sans-serif; background: var(--bg); color: var(--ink); }
h1, h2, h3 { font-family: 'Amiri', serif; }
button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; }

/* ---------- login ---------- */
.login-body { min-height: 100vh; display: grid; place-items: center; background: var(--noir); }
.login-card {
  background: var(--noir-2); border: 1px solid rgba(224,168,120,.2); border-radius: 6px;
  padding: 2.6rem 2.4rem; width: 340px; text-align: center;
}
.login-card .crest { width: 46px; height: 46px; color: var(--gold-soft); margin-bottom: 1rem; }
.login-card h1 { color: var(--cream); font-size: 1.5rem; margin-bottom: .4rem; }
.login-card .sub { color: var(--muted); font-size: .85rem; margin-bottom: 1.6rem; }
.login-card input {
  width: 100%; padding: .8rem 1rem; border-radius: 3px; border: 1px solid rgba(224,168,120,.3);
  background: rgba(243,234,217,.05); color: var(--cream); margin-bottom: 1rem; font-size: .95rem;
}
.login-card input:focus { outline: none; border-color: var(--gold); }
.login-card button {
  width: 100%; padding: .8rem; border: none; border-radius: 3px; background: var(--gold);
  color: var(--noir); font-weight: 700; font-size: .95rem; transition: background .3s;
}
.login-card button:hover { background: var(--gold-soft); }
.login-card .error { color: #e08a7d; font-size: .82rem; margin-top: .8rem; min-height: 1em; }

/* ---------- app shell ---------- */
.topbar {
  background: var(--noir); color: var(--cream); display: flex; align-items: center; justify-content: space-between;
  padding: .9rem 1.6rem; position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: .6rem; font-family: 'Amiri', serif; font-size: 1.15rem; letter-spacing: .05em; }
.brand .crest { width: 24px; height: 24px; color: var(--gold-soft); }
.topbar-actions { display: flex; align-items: center; gap: .6rem; }
.logout-btn, .lang-toggle-btn {
  background: none; border: 1px solid rgba(224,168,120,.35); color: var(--gold-soft);
  padding: .5rem 1rem; border-radius: 3px; font-size: .82rem; transition: background .3s;
}
.logout-btn:hover, .lang-toggle-btn:hover { background: rgba(224,168,120,.12); }

.tabs { display: flex; gap: .3rem; background: var(--noir-2); padding: 0 1.4rem; overflow-x: auto; }
.tab-btn {
  background: none; border: none; color: var(--muted); padding: .9rem 1.2rem; font-size: .9rem;
  border-bottom: 2px solid transparent; white-space: nowrap; transition: color .25s, border-color .25s;
}
.tab-btn:hover { color: var(--cream); }
.tab-btn.active { color: var(--gold-soft); border-bottom-color: var(--gold); font-weight: 700; }
.badge {
  display: inline-block; background: var(--gold); color: var(--noir); font-size: .68rem; font-weight: 800;
  border-radius: 10px; padding: .05rem .45rem; margin-right: .3rem;
}

.content { padding: 1.6rem; max-width: 1400px; margin: 0 auto; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.2rem; flex-wrap: wrap; gap: .8rem; }
.btn-primary {
  background: var(--gold); color: #fff; border: none; padding: .6rem 1.2rem; border-radius: 4px;
  font-size: .85rem; font-weight: 700; transition: background .25s;
}
.btn-primary:hover { background: #a3612f; }
.btn-ghost {
  background: none; border: 1px solid var(--line); color: var(--ink); padding: .45rem .9rem; border-radius: 4px; font-size: .8rem;
}
.btn-ghost:hover { border-color: var(--gold); color: var(--gold); }
.btn-danger { color: var(--red); border-color: rgba(164,67,58,.35); }
.btn-danger:hover { border-color: var(--red); background: rgba(164,67,58,.06); }

/* ---------- orders board ---------- */
.board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; align-items: start; }
.col { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: .8rem; min-height: 200px; }
.col h3 { font-size: .95rem; margin-bottom: .7rem; color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: .5rem; }
.col-list { display: flex; flex-direction: column; gap: .6rem; }
.order-card {
  background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: .7rem .8rem;
  font-size: .82rem; line-height: 1.6;
}
.order-card .oc-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: .3rem; }
.order-card .oc-type {
  font-size: .68rem; font-weight: 800; padding: .1rem .5rem; border-radius: 10px; color: #fff;
}
.oc-type.dinein { background: var(--gold); }
.oc-type.delivery { background: var(--green); }
.oc-type.pickup { background: var(--amber); }
.order-card .oc-id { color: var(--muted); font-size: .72rem; }
.order-card .oc-who { font-weight: 700; margin-bottom: .2rem; }
.oc-flag {
  display: inline-block; margin-inline-start: .4rem; padding: .1rem .4rem;
  font-size: .68rem; font-weight: 700; border-radius: 4px;
  background: var(--amber); color: #1a1a1a; vertical-align: middle;
}
.order-card .oc-items { color: var(--muted); font-size: .78rem; margin: .3rem 0; }
.order-card .oc-total { font-weight: 800; color: var(--gold); font-family: 'Amiri', serif; font-size: 1rem; }
.order-card .oc-actions { display: flex; gap: .4rem; margin-top: .5rem; flex-wrap: wrap; }
.order-card .oc-actions button {
  flex: 1; background: var(--noir); color: var(--cream); border: none; padding: .35rem .5rem;
  border-radius: 3px; font-size: .72rem; transition: background .2s;
}
.order-card .oc-actions button:hover { background: var(--gold); color: var(--noir); }
.order-card .oc-actions button.cancel { background: none; border: 1px solid rgba(164,67,58,.35); color: var(--red); }
.empty-hint { color: var(--muted); font-size: .8rem; text-align: center; padding: 1rem 0; }

/* ---------- menu editor ---------- */
.menu-cat { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; margin-bottom: 1rem; overflow: hidden; }
.menu-cat h3 { background: var(--noir-2); color: var(--cream); padding: .7rem 1rem; font-size: 1.05rem; display: flex; justify-content: space-between; align-items: center; }
.menu-cat h3 small { color: var(--gold-soft); font-family: 'Tajawal', sans-serif; font-size: .75rem; }
.menu-item-row { display: grid; grid-template-columns: 44px 1.3fr 1.3fr 1.4fr .65fr .65fr .6fr auto; gap: .6rem; align-items: center; padding: .6rem 1rem; border-bottom: 1px solid var(--line); font-size: .84rem; }
.menu-item-row:last-child { border-bottom: none; }
.menu-item-row input[type="text"], .menu-item-row input[type="number"] {
  width: 100%; padding: .4rem .5rem; border: 1px solid var(--line); border-radius: 3px; font-size: .82rem;
}
.menu-item-row input:focus { outline: none; border-color: var(--gold); }
.avail-toggle { display: flex; align-items: center; gap: .3rem; font-size: .75rem; }
.add-item-row { padding: .8rem 1rem; background: var(--bg); }
.add-item-row form { display: grid; grid-template-columns: 44px 1.3fr 1.3fr 1.4fr .65fr .65fr auto; gap: .5rem; align-items: center; }
.add-item-row input { padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 3px; font-size: .82rem; }

.menu-item-photo { position: relative; display: block; width: 44px; height: 44px; cursor: pointer; }
.menu-item-photo input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.menu-item-thumb {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 5px; object-fit: cover;
  border: 1px solid var(--line); background: var(--bg);
}
.menu-item-thumb--empty { color: var(--muted); font-size: 1.1rem; }
.menu-item-photo:hover .menu-item-thumb { border-color: var(--gold); }

/* ---------- tables / QR ---------- */
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1rem; }
.table-card { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 1rem; text-align: center; }
.table-card img, .table-card svg { width: 130px; height: 130px; margin: 0 auto .6rem; border-radius: 4px; display: block; }
.table-card .t-label { font-weight: 700; margin-bottom: .5rem; }
.table-card .t-actions { display: flex; gap: .4rem; justify-content: center; }
.inline-form { display: flex; gap: .5rem; }
.inline-form input { padding: .55rem .8rem; border: 1px solid var(--line); border-radius: 4px; font-size: .85rem; }

/* ---------- table ---------- */
.data-table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: 6px; overflow: hidden; }
.data-table th { background: var(--noir-2); color: var(--cream); text-align: right; padding: .7rem .9rem; font-size: .82rem; }
.data-table td { padding: .65rem .9rem; border-bottom: 1px solid var(--line); font-size: .84rem; }
.data-table select { padding: .3rem .5rem; border-radius: 3px; border: 1px solid var(--line); font-size: .8rem; }

@media (max-width: 900px) {
  .board { grid-template-columns: 1fr 1fr; }
  .menu-item-row, .add-item-row form { grid-template-columns: 1fr 1fr; }
}

/* ---------- Golden tier: accounting sheet link ---------- */
.sheets-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 1rem 1.2rem; margin-bottom: 1rem; }
.sheets-panel h3 { font-size: 1rem; margin-bottom: .5rem; color: var(--noir-2); }
.sheets-row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; font-size: .85rem; margin-bottom: .4rem; }
.sheets-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.sheets-dot--on { background: #2c6e49; }
.sheets-dot--off { background: #b0a89c; }
.sheets-dot--err { background: #c0563c; }
.sheets-panel .mono { font-family: ui-monospace, monospace; font-size: .76rem; direction: ltr; background: var(--bg); padding: .15rem .4rem; border-radius: 3px; }
.cost-input { opacity: .85; }

/* ---------- table QR cards: scan hint (print only) ---------- */
.t-scan-hint { display: none; }

/* ============================================================
   Printing the table QR codes.
   Triggered by the print button adding .printing-qr to <body>;
   everything except the QR grid is hidden so the sheet comes out
   as clean cut-out cards rather than a screenshot of the app.
   ============================================================ */
@media print {
  @page { size: A4; margin: 10mm; }

  body.printing-qr { background: #fff; }
  /* Hide the whole app chrome, then walk the QR grid back into view. */
  body.printing-qr .topbar,
  body.printing-qr .tabs,
  body.printing-qr .panel-head,
  body.printing-qr .sheets-panel,
  body.printing-qr .t-actions { display: none !important; }

  body.printing-qr .tab-panel { display: none !important; }
  body.printing-qr #tab-tables { display: block !important; }
  body.printing-qr .content { padding: 0; max-width: none; }

  body.printing-qr .grid-cards {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr);
    gap: 8mm;
  }
  body.printing-qr .table-card {
    border: 1px dashed #999;          /* cut line */
    border-radius: 0;
    padding: 8mm 4mm;
    text-align: center;
    break-inside: avoid;              /* never split a card across pages */
    page-break-inside: avoid;
    background: #fff;
  }
  body.printing-qr .table-card svg,
  body.printing-qr .table-card img {
    width: 46mm; height: 46mm; margin: 0 auto;
  }
  body.printing-qr .t-label {
    font-family: 'Amiri', serif; font-size: 15pt; font-weight: 700;
    color: #000; margin-top: 4mm;
  }
  body.printing-qr .t-scan-hint {
    display: block; font-size: 8.5pt; color: #444; margin-top: 2mm; line-height: 1.5;
  }
}
