/* Noka back office */

:root {
  --gold: #c4a777;
  --gold-deep: #a8874f;
  --espresso: #241c16;
  --panel: #ffffff;
  --bg: #f4f1ec;
  --line: #e2ddd4;
  --ink: #2b241e;
  --muted: #7c7168;
  --ok: #2f7d4f;
  --warn: #b7791f;
  --bad: #b3392c;
  --info: #3a6ea5;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0; font-family: var(--font); background: var(--bg); color: var(--ink);
  font-size: 14.5px; line-height: 1.55; -webkit-font-smoothing: antialiased;
}
a { color: var(--gold-deep); }

.shell { display: grid; grid-template-columns: 244px 1fr; min-height: 100vh; }

/* ----------------------------------------------------------------- sidebar */
.side { background: var(--espresso); color: #cfc4b8; padding: 18px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side-brand { display: block; padding: 8px 8px 20px; text-decoration: none; color: #fff; }
.side-logo { width: 152px; max-width: 100%; height: auto; display: block; color: var(--gold); }
.side-brand small { display: block; margin-top: 8px; color: #93857a; font-size: .68rem; letter-spacing: .16em; text-transform: uppercase; }
.side-group { margin-top: 16px; font-size: .68rem; letter-spacing: .16em; text-transform: uppercase; color: #7d6f63; padding: 0 8px 6px; }
.side a.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px;
  text-decoration: none; color: #cfc4b8; font-size: .9rem; margin-bottom: 2px;
}
.side a.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.side a.nav-item.active { background: var(--gold); color: var(--espresso); font-weight: 600; }
.side .badge-count { margin-left: auto; background: rgba(255,255,255,.14); border-radius: 999px; padding: 1px 8px; font-size: .72rem; }
.side a.nav-item.active .badge-count { background: rgba(36,28,22,.18); }
.side-foot { margin-top: 22px; border-top: 1px solid rgba(255,255,255,.1); padding-top: 14px; font-size: .82rem; }

/* -------------------------------------------------------------------- main */
.main { padding: 24px 28px 60px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin: 0; font-size: 1.5rem; }
.page-head p { margin: 3px 0 0; color: var(--muted); font-size: .9rem; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.panel-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.panel-head h2, .panel-head h3 { margin: 0; font-size: 1rem; }
.panel-body { padding: 18px; }

.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g-side { grid-template-columns: 1fr 340px; align-items: start; }

/* ------------------------------------------------------------------- stats */
.stat-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }
.stat-card .lbl { font-size: .74rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.stat-card .val { font-size: 1.7rem; font-weight: 700; line-height: 1.2; margin-top: 4px; }
.stat-card .sub { font-size: .82rem; color: var(--muted); }

/* ------------------------------------------------------------------ tables */
table.grid-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.grid-table th {
  text-align: left; padding: 10px 12px; font-size: .72rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.grid-table td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.grid-table tr:last-child td { border-bottom: 0; }
table.grid-table tbody tr:hover { background: #faf8f4; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------- forms */
label.lbl { display: block; font-weight: 600; font-size: .82rem; margin-bottom: 5px; }
.inp, select.inp, textarea.inp {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; font-size: .9rem; background: #fff; color: var(--ink);
}
.inp:focus { outline: 2px solid var(--gold); outline-offset: 1px; border-color: var(--gold); }
textarea.inp { min-height: 76px; resize: vertical; }
.field { margin-bottom: 14px; }
.row { display: grid; gap: 14px; }
.row-2 { grid-template-columns: 1fr 1fr; }
.row-3 { grid-template-columns: repeat(3, 1fr); }
.row-4 { grid-template-columns: repeat(4, 1fr); }
.hint { font-size: .78rem; color: var(--muted); margin-top: 4px; }
.check { display: flex; align-items: center; gap: 8px; font-size: .88rem; }
.check input { accent-color: var(--espresso); width: 16px; height: 16px; }

/* ----------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  padding: 9px 16px; border-radius: 8px; border: 1px solid transparent; cursor: pointer;
  font: inherit; font-size: .88rem; font-weight: 600; text-decoration: none; white-space: nowrap;
}
.btn-primary { background: var(--espresso); color: #fff; }
.btn-primary:hover { background: #120d09; }
.btn-gold { background: var(--gold); color: var(--espresso); }
.btn-gold:hover { background: var(--gold-deep); color: #fff; }
.btn-line { border-color: var(--line); background: #fff; color: var(--ink); }
.btn-line:hover { border-color: var(--gold); }
.btn-danger { background: #fdecea; color: var(--bad); border-color: #f3cdc8; }
.btn-danger:hover { background: var(--bad); color: #fff; }
.btn-xs { padding: 5px 10px; font-size: .78rem; border-radius: 7px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* -------------------------------------------------------------------- pill */
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .74rem; font-weight: 700; letter-spacing: .02em; white-space: nowrap; }
.pill-new { background: #e9f0fb; color: #2f5c99; }
.pill-preparing { background: #fdf1dc; color: #92650f; }
.pill-ready { background: #e6f4ea; color: #1d6b38; }
.pill-served { background: #eee9fb; color: #5340a0; }
.pill-completed { background: #eef0ee; color: #55605a; }
.pill-cancelled, .pill-no_show { background: #fdecea; color: #a12d21; }
.pill-pending { background: #fdf1dc; color: #92650f; }
.pill-confirmed { background: #e6f4ea; color: #1d6b38; }
.pill-seated { background: #e9f0fb; color: #2f5c99; }
.pill-paid { background: #e6f4ea; color: #1d6b38; }
.pill-unpaid { background: #f3efe9; color: #7c7168; }
.pill-on { background: #e6f4ea; color: #1d6b38; }
.pill-off { background: #f3efe9; color: #7c7168; }

.alert { padding: 11px 14px; border-radius: 9px; font-size: .88rem; margin-bottom: 14px; }
.alert-ok { background: #e6f4ea; color: #1d6b38; }
.alert-err { background: #fdecea; color: #a12d21; }
.alert-info { background: #e9f0fb; color: #2f5c99; }
.alert-warn { background: #fdf1dc; color: #92650f; }

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

/* ------------------------------------------------------------------ tabbar */
.tabbar { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.tabbar a { padding: 9px 15px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; font-size: .9rem; font-weight: 600; }
.tabbar a.active { color: var(--ink); border-bottom-color: var(--gold); }

/* ------------------------------------------------------------------ modals */
.modal-bg { position: fixed; inset: 0; background: rgba(25,19,14,.5); display: none; z-index: 300; }
.modal-bg.open { display: block; }
.modal {
  position: fixed; z-index: 301; left: 50%; top: 50%; transform: translate(-50%, -50%);
  background: #fff; border-radius: 14px; width: min(680px, calc(100% - 32px));
  max-height: 88vh; overflow: auto; display: none;
}
.modal.open { display: block; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { margin: 0; font-size: 1.05rem; }
.modal-body { padding: 18px 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; position: sticky; bottom: 0; background: #fff; }
.x-close { background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }

/* ------------------------------------------------------------- order board */
.board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; align-items: start; }
.board-col { background: #ebe7e0; border-radius: 12px; padding: 10px; min-height: 120px; }
.board-col h3 { margin: 4px 6px 10px; font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; color: #6d6259; display: flex; justify-content: space-between; }
.ticket { background: #fff; border-radius: 10px; padding: 12px; margin-bottom: 10px; border: 1px solid var(--line); }
.ticket-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.ticket-code { font-weight: 800; font-size: .92rem; }
.ticket-meta { font-size: .78rem; color: var(--muted); }
.ticket ul { margin: 9px 0 0; padding-left: 16px; font-size: .84rem; }
.ticket ul li { margin-bottom: 2px; }
.ticket .opt { color: var(--muted); font-size: .78rem; }
.ticket-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.age { font-size: .74rem; font-weight: 700; }
.age.warn { color: var(--warn); }
.age.late { color: var(--bad); }

/* ------------------------------------------------------------ floor editor */
.editor-wrap { display: grid; grid-template-columns: 1fr 300px; gap: 16px; align-items: start; }
/* The shell is the workspace; the canvas inside it is the floor plan itself.
   Making them visually distinct is what stops the surrounding space from
   looking like part of the plan. `margin: auto` centres the canvas while still
   allowing scrolling when the plan is larger than the shell. */
.canvas-shell {
  position: relative; background: #ded5c8; border: 1px solid var(--line); border-radius: 12px;
  overflow: auto; height: calc(100vh - 250px); min-height: 460px;
  display: flex; padding: 16px;
  background-image: radial-gradient(rgba(36,28,22,.10) 1px, transparent 1px);
  background-size: 12px 12px;
}
.ed-canvas {
  position: relative; margin: auto; flex: none;
  box-shadow: 0 6px 22px rgba(36,28,22,.22);
  outline: 2px solid var(--espresso); outline-offset: 0;
}
/* Corner grip that resizes the plan itself. */
.ed-plan-handle {
  position: absolute; right: -9px; bottom: -9px; width: 18px; height: 18px;
  background: var(--espresso); border: 2px solid white; border-radius: 4px;
  cursor: nwse-resize; z-index: 9999;
}
.ed-plan-handle:hover { background: var(--gold-deep); }
.ed-marquee {
  position: absolute; z-index: 9998; pointer-events: none;
  border: 1.5px dashed var(--gold-deep);
  background: rgba(196, 167, 119, 0.14);
  border-radius: 3px;
}
.ed-obj { position: absolute; box-sizing: border-box; cursor: move; user-select: none; }
.ed-obj.selected { outline: 2px solid var(--gold-deep); outline-offset: 2px; z-index: 5; }
.ed-handle {
  position: absolute; right: -7px; bottom: -7px; width: 14px; height: 14px;
  background: #fff; border: 2px solid var(--gold-deep); border-radius: 3px; cursor: nwse-resize;
}
.ed-rot {
  position: absolute; left: 50%; top: -26px; margin-left: -8px; width: 16px; height: 16px;
  background: #fff; border: 2px solid var(--gold-deep); border-radius: 50%; cursor: grab;
}
.palette { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.palette button {
  border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 10px 4px;
  cursor: pointer; font: inherit; font-size: .74rem; display: grid; gap: 4px; place-items: center;
}
.palette button:hover { border-color: var(--gold); background: #fffdf8; }
.palette button .ico { font-size: 18px; }
.insp-empty { color: var(--muted); font-size: .86rem; padding: 18px 4px; text-align: center; }
.ed-hint { font-size: .78rem; color: var(--muted); }
.ed-toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.zoom-label { font-size: .82rem; color: var(--muted); min-width: 46px; text-align: center; }
.plan-size { font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ qr page */
.qr-sheet { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.qr-card { border: 1px dashed #b9ad9c; border-radius: 12px; padding: 16px; text-align: center; background: #fff; break-inside: avoid; }
.qr-card h3 { margin: 0 0 2px; font-size: 1.3rem; }
.qr-logo { width: 96px; height: auto; display: block; margin: 0 auto 10px; color: var(--espresso); }
.login-logo { width: 150px; height: auto; display: block; color: var(--espresso); margin-bottom: 18px; }
.qr-card .area { color: var(--muted); font-size: .8rem; }
.qr-card canvas, .qr-card svg { margin: 12px auto 8px; display: block; }
.qr-card .url { font-size: .68rem; color: var(--muted); word-break: break-all; }

@media (max-width: 1100px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .g-side, .editor-wrap { grid-template-columns: 1fr; }
  .board { grid-template-columns: repeat(2, 1fr); }
  .g4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .g2, .g3, .g4, .row-2, .row-3, .row-4, .board, .qr-sheet { grid-template-columns: 1fr; }
  .main { padding: 18px 16px 50px; }
}

@media print {
  .side, .page-head, .no-print { display: none !important; }
  .shell { grid-template-columns: 1fr; }
  body { background: #fff; }
  .qr-sheet { grid-template-columns: repeat(3, 1fr); }
}

/* ------------------------------------------------- floor editor objects --- */
.ed-obj.k-table {
  background: #fff; border: 2px solid #cbbba0; border-radius: 10px;
  display: grid; place-items: center; text-align: center; box-shadow: 0 2px 0 rgba(36,28,22,.07);
}
.ed-obj.k-table.s-round { border-radius: 50%; }
.ed-obj.k-table.s-booth { border-radius: 10px 10px 26px 26px; }
.ed-obj.k-table .c { font-weight: 800; font-size: .85rem; line-height: 1.1; }
.ed-obj.k-table .s { font-size: .68rem; color: var(--muted); }
.ed-obj.k-table.blocked { border-style: dashed; background: #f2efe9; }
.ed-obj.inactive { opacity: .38; }
.ed-obj.k-wall { background: #3c3129; border-radius: 3px; }
.ed-obj.k-door {
  background: repeating-linear-gradient(45deg, #c4a777, #c4a777 8px, #b3946a 8px, #b3946a 16px);
  border-radius: 4px; display: grid; place-items: center; font-size: .7rem; font-weight: 700; color: #241c16;
}
.ed-obj.k-counter { background: #6b4f36; color: #f7ecdb; border-radius: 8px; display: grid; place-items: center; font-size: .78rem; font-weight: 700; text-align: center; padding: 3px; }
.ed-obj.k-toilet { background: #dfe6ee; border: 2px solid #b9c6d5; border-radius: 8px; display: grid; place-items: center; font-size: .74rem; color: #4a5a6b; font-weight: 700; }
.ed-obj.k-stage { background: #4a3b52; color: #f0e6f5; border-radius: 10px; display: grid; place-items: center; font-size: .78rem; font-weight: 700; text-align: center; padding: 3px; }
.ed-obj.k-stairs { background: repeating-linear-gradient(180deg, #cdbfa9, #cdbfa9 10px, #b9a88e 10px, #b9a88e 20px); border-radius: 6px; }
.ed-obj.k-plant { background: radial-gradient(circle at 50% 45%, #7fa86a, #3f6b34); border-radius: 50%; display: grid; place-items: center; font-size: 1.05rem; }
.ed-obj.k-label { display: grid; place-items: center; font-size: .74rem; font-weight: 700; color: var(--muted); letter-spacing: .1em; text-transform: uppercase; border: 1px dashed #c9bfae; border-radius: 8px; }

/* ---- photo crop tool (admin/menu.php) ---- */
.crop-modal { width: min(760px, calc(100% - 32px)); }
.crop-stage { position: relative; display: inline-block; max-width: 100%; background: #111; border-radius: 10px; overflow: hidden; touch-action: none; user-select: none; }
.crop-stage img { display: block; max-width: 100%; max-height: 62vh; width: auto; height: auto; }
.crop-box { position: absolute; border: 2px solid var(--gold); box-shadow: 0 0 0 9999px rgba(0,0,0,.55); cursor: move; box-sizing: border-box; }
.crop-box::before, .crop-box::after { content: ""; position: absolute; border: 0 dashed rgba(255,255,255,.35); pointer-events: none; }
.crop-box::before { left: 33.33%; right: 33.33%; top: 0; bottom: 0; border-left-width: 1px; border-right-width: 1px; }
.crop-box::after  { top: 33.33%; bottom: 33.33%; left: 0; right: 0; border-top-width: 1px; border-bottom-width: 1px; }
.crop-handle { position: absolute; right: -8px; bottom: -8px; width: 18px; height: 18px; border-radius: 4px; background: var(--gold); border: 2px solid #fff; cursor: nwse-resize; }
.photo-current { display: flex; gap: 12px; align-items: center; margin-top: 8px; }
.photo-current img { width: 120px; height: 90px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
