/* ─── Design tokens ─────────────────────────────────────────── */
:root {
  --ink: #1f2430;
  --muted: #6b7280;
  --line: #e3e7ee;
  --bg: #f4f6f9;
  --card: #ffffff;
  --accent: #0f5132;
  --accent-2: #157347;
  --soft: #eef2f1;
  --danger: #b02a37;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16,24,40,.06), 0 8px 24px rgba(16,24,40,.05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 14.5px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-2); text-decoration: none; }
h1,h2,h3 { margin: 0 0 .4em; font-weight: 700; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
small { color: var(--muted); }

/* ─── Layout ─────────────────────────────────────────────────── */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar-inner {
  max-width: 1100px; margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; gap: 8px; height: 58px;
}
.brand { font-weight: 800; font-size: 1.05rem; color: var(--accent); margin-right: 12px; white-space: nowrap; }
.brand .dot { color: var(--accent-2); }
.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav a {
  padding: 8px 14px; border-radius: 8px; color: var(--ink); font-weight: 600;
}
.nav a:hover { background: var(--soft); }
.nav a.active { background: var(--accent); color: #fff; }
.userbox { display: flex; align-items: center; gap: 10px; }
.userbox .who { font-weight: 600; }
.container { max-width: 1100px; margin: 24px auto; padding: 0 20px 60px; }

/* ─── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px; margin-bottom: 20px;
}
.card h2, .card h3 { margin-top: 0; }
.grid { display: grid; gap: 20px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 780px){ .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; } }

.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }

/* ─── Forms ──────────────────────────────────────────────────── */
label { display: block; font-weight: 600; margin: 12px 0 5px; font-size: .9rem; }
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 9px; font: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--soft); border-color: var(--accent-2); }
textarea { resize: vertical; min-height: 70px; }
.field-inline { display: flex; gap: 10px; }
.hint { color: var(--muted); font-size: .82rem; margin-top: 4px; }

/* ─── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  padding: 9px 16px; border-radius: 9px; border: 1px solid transparent;
  font: inherit; font-weight: 600; cursor: pointer; background: var(--soft); color: var(--ink);
  transition: transform .04s ease;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.ghost { background: #fff; border-color: var(--line); }
.btn.ghost:hover { background: var(--soft); }
.btn.danger { background: #fff; color: var(--danger); border-color: #f1c6cb; }
.btn.danger:hover { background: #fdecee; }
.btn.sm { padding: 5px 10px; font-size: .82rem; border-radius: 7px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ─── Tables ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
tbody tr:hover { background: #fafbfc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .74rem;
  font-weight: 700; background: var(--soft); color: var(--accent);
}
.badge.gray { background: #eef0f3; color: var(--muted); }

/* ─── Tabs ───────────────────────────────────────────────────── */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.tabs button {
  background: none; border: none; padding: 10px 14px; font: inherit; font-weight: 600;
  color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ─── Login (enlarged ~200%) ─────────────────────────────────── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 640px; padding: 46px 52px; }
.login-card .brand-big { font-size: 3.2rem; font-weight: 800; color: var(--accent); text-align: center; margin-bottom: 8px; }
.login-card .sub { text-align: center; color: var(--muted); font-size: 1.35rem; margin-bottom: 34px; }
.login-card label { font-size: 1.3rem; margin: 22px 0 10px; }
.login-card input { font-size: 1.5rem; padding: 16px 20px; border-radius: 12px; }
.login-card .btn { font-size: 1.6rem; padding: 16px 24px; border-radius: 12px; }
.login-card .btn { margin-top: 30px !important; }

/* ─── Toast ──────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 10px;
  box-shadow: var(--shadow); z-index: 100; font-weight: 600; max-width: 90vw;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--accent); }

/* ─── Modal ──────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(16,24,40,.45); display: grid; place-items: center;
  z-index: 60; padding: 20px;
}
.modal {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  width: 100%; max-width: 480px; padding: 22px; max-height: 90vh; overflow: auto;
}

/* ─── Item editor ────────────────────────────────────────────── */
.items-table td { padding: 6px 8px; vertical-align: top; }
.items-table input, .items-table select { padding: 7px 8px; }
.items-table .col-val { font-weight: 700; text-align: right; white-space: nowrap; padding-top: 14px; }
.totals { max-width: 340px; margin-left: auto; }
.totals .line { display: flex; justify-content: space-between; padding: 6px 0; }
.totals .line.total { font-size: 1.15rem; font-weight: 800; color: var(--accent); border-top: 2px solid var(--line); padding-top: 10px; margin-top: 6px; }

.empty { text-align: center; color: var(--muted); padding: 40px 10px; }

/* ─── Printable receipt ──────────────────────────────────────── */
#print-root { display: none; }

.receipt {
  color: var(--ink); background: #fff; font-family: var(--font);
}
.receipt .r-head { display: flex; justify-content: space-between; gap: 20px; }
.receipt .r-company { font-size: .92rem; }
.receipt .r-company .name { font-weight: 800; font-size: 1.05rem; }
.receipt .r-company .muted { color: var(--muted); white-space: pre-line; }
.receipt .r-numbox { text-align: right; min-width: 200px; }
.receipt .r-numbox .date { color: var(--muted); font-size: .9rem; }
.receipt .r-numbox .box { background: var(--soft); border-radius: 8px; padding: 8px 12px; margin-top: 6px; display: inline-block; }
.receipt .r-numbox .box .lbl { color: var(--accent); font-weight: 700; font-size: .8rem; }
.receipt .r-numbox .box .val { font-weight: 800; font-size: 1.4rem; }
.receipt hr { border: none; border-top: 1px solid var(--line); margin: 16px 0; }
.receipt .r-title { text-align: center; color: var(--accent); font-weight: 800; font-size: 1.35rem; text-transform: uppercase; }
.receipt .r-sub { text-align: center; color: var(--muted); font-size: .9rem; margin-top: 3px; }
.receipt .r-info { margin: 16px 0; font-size: .95rem; }
.receipt .r-info b { }
.receipt table.r-items { width: 100%; border-collapse: collapse; margin-top: 8px; }
.receipt table.r-items th { background: var(--soft); color: var(--ink); text-transform: none; letter-spacing: 0; font-size: .82rem; padding: 8px 10px; }
.receipt table.r-items td { padding: 8px 10px; border-bottom: 1px solid #eef0f3; font-size: .9rem; }
.receipt table.r-items td.num, .receipt table.r-items th.num { text-align: right; font-variant-numeric: tabular-nums; }
.receipt .r-totals { margin-top: 16px; margin-left: auto; width: 300px; }
.receipt .r-totals .line { display: flex; justify-content: space-between; padding: 4px 8px; }
.receipt .r-totals .line.grand { background: var(--soft); color: var(--accent); font-weight: 800; font-size: 1.1rem; border-radius: 8px; padding: 8px; margin-top: 6px; }
.receipt .r-foot { margin-top: 40px; display: flex; justify-content: space-between; align-items: flex-end; }
.receipt .r-stamp { text-align: center; color: var(--muted); font-size: .8rem; }
.receipt .r-stamp .line { border-top: 1px solid var(--line); width: 160px; margin-top: 46px; padding-top: 4px; }
.receipt .r-stamp img { max-width: 160px; max-height: 90px; }
.receipt .r-legal { border-top: 1px solid var(--line); margin-top: 26px; padding-top: 8px; text-align: center; color: var(--muted); font-size: .82rem; white-space: pre-line; }

/* ─── Restaurant POS ─────────────────────────────────────────── */
.floor-scroll { overflow-x: auto; padding-bottom: 6px; }
.floor {
  position: relative; border: 1px solid var(--line); border-radius: var(--radius);
  background-color: #f8fafb;
  background-image: linear-gradient(#eceff3 1px, transparent 1px), linear-gradient(90deg, #eceff3 1px, transparent 1px);
  background-size: 40px 40px; margin-top: 10px;
}
.floor.edit { background-color: #f4f7f6; }
.floor-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }

.table-tile {
  position: absolute; width: 116px; height: 92px; border-radius: 14px; cursor: pointer;
  border: 2px solid var(--line); background: #fff; box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font: inherit; color: var(--ink); padding: 6px; text-align: center; transition: transform .05s ease;
}
.table-tile:hover { transform: translateY(-1px); }
.table-tile .tt-label { font-size: 1.35rem; font-weight: 800; line-height: 1.1; }
.table-tile .tt-free { font-size: .78rem; color: var(--muted); }
.table-tile.occ { background: var(--accent); color: #fff; border-color: var(--accent); }
.table-tile.occ .tt-total { font-size: 1rem; font-weight: 800; }
.table-tile.occ .tt-qty { font-size: .72rem; opacity: .85; }
.table-tile.edit { cursor: grab; touch-action: none; }
.table-tile.edit.dragging { cursor: grabbing; opacity: .9; z-index: 5; box-shadow: 0 10px 24px rgba(16,24,40,.2); }
.table-tile .tt-actions { position: absolute; top: -10px; right: -10px; display: flex; gap: 4px; }
.table-tile .tt-actions button {
  width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--line); background: #fff;
  cursor: pointer; font-size: .8rem; line-height: 1; display: grid; place-items: center; box-shadow: var(--shadow);
}
.table-tile .tt-del { color: var(--danger); }

.pos-head { padding: 14px 22px; }
.pos-grid { display: grid; grid-template-columns: 1fr 380px; gap: 20px; align-items: start; }
@media (max-width: 820px) { .pos-grid { grid-template-columns: 1fr; } }
.pos-menu .menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.menu-btn {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 6px;
  min-height: 66px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff;
  font: inherit; cursor: pointer; text-align: left; transition: transform .04s ease;
}
.menu-btn:hover { background: var(--soft); }
.menu-btn:active { transform: translateY(1px); }
.menu-btn .mb-name { font-weight: 700; line-height: 1.15; }
.menu-btn .mb-price { color: var(--accent); font-weight: 700; font-size: .9rem; }
.menu-btn.custom { border-style: dashed; color: var(--muted); align-items: center; justify-content: center; }

.pos-order { position: sticky; top: 74px; }
.order-list { display: flex; flex-direction: column; }
.order-row { display: grid; grid-template-columns: 1fr auto auto auto; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.or-name { font-weight: 600; line-height: 1.15; }
.or-name small { display: block; color: var(--muted); font-weight: 400; }
.or-qty { display: flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.or-line { font-weight: 700; white-space: nowrap; min-width: 68px; text-align: right; }
.qbtn { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 1.1rem; line-height: 1; display: grid; place-items: center; }
.qbtn:hover { background: var(--soft); }
.qbtn.del { color: var(--danger); border-color: #f1c6cb; }
.order-total { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; padding-top: 12px; border-top: 2px solid var(--line); font-size: 1.3rem; }
.order-total b { color: var(--accent); }
.transfer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }

@media print {
  body * { visibility: hidden; }
  #print-root, #print-root * { visibility: visible; }
  #print-root { display: block; position: absolute; inset: 0; margin: 0; padding: 14mm; }
  .no-print { display: none !important; }
  @page { size: A4; margin: 0; }
}
