:root {
  --bg: #0a0e14;
  --panel: #111722;
  --panel-2: #151d2b;
  --border: #1e2633;
  --text: #e6edf3;
  --muted: #8b98a9;
  --accent: #34d399;
  --accent-dim: #0f3d2e;
  --danger: #f87171;
  --warn: #fbbf24;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 ui-sans-serif, -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 8px; }
.chair { color: var(--muted); flex: none; vertical-align: -2px; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 340px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 16px; padding: 28px 24px; display: flex; flex-direction: column; gap: 10px; text-align: center;
}
.login-card h1 { font-size: 20px; margin: 4px 0 0; }
.login-card p { margin: 0 0 10px; font-size: 13px; }
.logo { font-size: 32px; color: var(--accent); line-height: 1; }
.logo.small { font-size: 18px; }
.pin {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 12px 14px; font-size: 18px; letter-spacing: 4px; text-align: center;
}
.pin:focus { outline: 2px solid var(--accent-dim); border-color: var(--accent); }

/* ---------- chrome (mobile base: brand + lock on row 1, tabs on row 2) ---------- */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 14px;
  border-bottom: 1px solid var(--border); background: rgba(17,23,34,.92);
  position: sticky; top: 0; z-index: 20; backdrop-filter: blur(8px);
}
.brand { flex: 1; display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
#logout { order: 2; }
.tabs {
  order: 3; display: flex; gap: 4px; width: 100%;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 3px;
}
.tab {
  flex: 1; background: none; border: 0; color: var(--muted); padding: 7px 4px; border-radius: 8px;
  font: inherit; font-size: 12.5px; cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--border); }
main { padding: 14px; max-width: 1180px; margin: 0 auto; }

/* ---------- buttons ---------- */
.btn {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 9px; padding: 9px 14px; font: inherit; font-size: 13px; cursor: pointer;
}
.btn:hover { border-color: #2b384b; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #06231a; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.tiny { padding: 5px 10px; font-size: 12px; }
.btn.nav { padding: 8px 12px; font-size: 16px; line-height: 1; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- week toolbar ---------- */
.weekbar { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.weekbar .range { font-weight: 600; font-size: 14px; margin: 0 2px; }
.weekbar .hint { display: none; font-size: 12px; color: var(--muted); }
.spacer { flex: 1; }

/* ---------- week tables (shared) ---------- */
.week-scroll { overflow-x: auto; border-radius: 14px; }
table.week { border-collapse: separate; border-spacing: 0; width: 100%; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
table.week th, table.week td { border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); padding: 0; }
table.week th:last-child, table.week td:last-child { border-right: 0; }
table.week tr:last-child td, table.week tr:last-child th { border-bottom: 0; }

td.slot { text-align: center; vertical-align: middle; cursor: pointer; transition: background .12s; }
td.slot:hover { background: #172033; }
td.slot.locked { cursor: not-allowed; }
td.slot.locked:hover { background: transparent; }
td.slot .empty { color: #2f3d52; font-size: 17px; line-height: 1; }
td.slot:hover .empty { color: var(--accent); }
td.slot.is-today { background: rgba(52,211,153,.05); }

.chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  padding: 3px 8px 3px 3px; border-radius: 999px; font-size: 12px; line-height: 1.2;
  background: var(--panel-2); border: 1px solid var(--border); white-space: nowrap; overflow: hidden;
}
.chip .dot { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 9px; font-weight: 700; color: #07120d; flex: none; }
.chip .name { overflow: hidden; text-overflow: ellipsis; max-width: 88px; }
.chip.guest { border-style: dashed; }
.chip.solo { padding: 3px; }

/* ---------- MOBILE week: rows = days, columns = seats ---------- */
.week-desktop-wrap { display: none; }
.week-mobile-wrap { display: block; }
table.week-mobile { table-layout: fixed; }
table.week-mobile th.daycol {
  width: 76px; text-align: left; padding: 8px 10px; background: var(--panel-2); font-weight: 500; vertical-align: middle;
}
table.week-mobile th.daycol .dow { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
table.week-mobile th.daycol .dnum { display: block; font-size: 13px; margin-top: 1px; }
table.week-mobile th.daycol .count { display: block; font-size: 10.5px; color: var(--muted); margin-top: 1px; }
table.week-mobile th.seatcol { background: var(--panel-2); padding: 8px 2px; font-size: 12px; font-weight: 600; text-align: center; }
table.week-mobile th.seatcol .chair { display: block; margin: 0 auto 2px; width: 14px; height: 14px; }
table.week-mobile td.slot { height: 46px; }
table.week-mobile td.daycol { background: var(--panel-2); padding: 6px 10px; }
table.week-mobile td.daycol.today { background: #10261f; }
table.week-mobile td.daycol.today .dnum { color: var(--accent); }

/* ---------- DESKTOP week: rows = seats, columns = days ---------- */
@media (min-width: 900px) {
  .week-desktop-wrap { display: block; }
  .week-mobile-wrap { display: none; }
  table.week-desktop { min-width: 700px; }
  th.seathead { width: 96px; background: var(--panel-2); text-align: center; padding: 10px 8px; color: var(--muted); }
  th.dayhead { padding: 10px 8px; background: var(--panel-2); font-weight: 500; text-align: center; min-width: 96px; }
  th.dayhead .dow { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
  th.dayhead .dnum { display: block; font-size: 15px; margin-top: 2px; }
  th.dayhead .count { display: block; font-size: 11px; color: var(--muted); margin-top: 1px; }
  th.dayhead.today { background: #10261f; }
  th.dayhead.today .dnum { color: var(--accent); }
  th.dayhead.past { opacity: .75; }
  td.seatcell { padding: 8px 12px; background: var(--panel-2); white-space: nowrap; }
  td.seatcell .seat-id { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
  td.seatcell .seat-id b { font-weight: 600; }
  td.seatcell .lbl { display: block; font-size: 11px; color: var(--muted); margin-top: 1px; max-width: 84px; overflow: hidden; text-overflow: ellipsis; }
  td.slot { height: 52px; }
  .weekbar .range { margin: 0 6px; }
  .weekbar .hint { display: inline; }
}

@media (min-width: 900px) {
  .topbar { padding: 12px 20px; gap: 16px; flex-wrap: nowrap; }
  .brand { flex: 0 0 auto; font-size: 15px; }
  #logout { order: 0; }
  .tabs { order: 0; margin-left: auto; width: auto; }
  .tab { flex: 0 0 auto; padding: 6px 12px; font-size: 13px; }
  main { padding: 20px; }
}

/* ---------- day view ---------- */
.daybar { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.daybar input[type=date] {
  background: var(--panel); border: 1px solid var(--border); color: var(--text);
  border-radius: 9px; padding: 8px 10px; font: inherit; font-size: 13px; flex: 1; min-width: 130px;
}
.seatcard-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.seatcard { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.seatcard .head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.seatcard .head .num { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.seatcard .head .lbl { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 90px; }
.seatcard .body { min-height: 30px; }
.seatcard .body .free { color: var(--muted); font-size: 13px; }
.seatcard.inactive { opacity: .5; }
.who { display: flex; align-items: center; gap: 8px; font-size: 13.5px; flex-wrap: wrap; }
.who .dot { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 10px; font-weight: 700; color: #07120d; flex: none; }
.who .tag { font-size: 11px; color: var(--warn); border: 1px dashed var(--warn); border-radius: 999px; padding: 1px 7px; }

/* ---------- people & seats ---------- */
.section { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 14px; margin-bottom: 14px; }
.section h2 { font-size: 12px; margin: 0 0 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; }
.row-form { display: flex; gap: 8px; flex-wrap: wrap; }
.row-form input[type=text], .row-form input[type=number] {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: 9px; padding: 10px 12px; font: inherit; font-size: 14px; min-width: 0; flex: 1;
}
.row-form input:focus { outline: none; border-color: var(--accent); }
.list { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row input.name-input {
  background: transparent; border: 1px solid transparent; color: var(--text);
  border-radius: 7px; padding: 6px 8px; font: inherit; font-size: 14px; width: 100%;
}
.list-row input.name-input:hover { border-color: var(--border); }
.list-row input.name-input:focus { outline: none; border-color: var(--accent); background: var(--bg); }
.badge { display: none; font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); flex: none; }
.badge.on { color: var(--accent); border-color: #1f4d3d; background: var(--accent-dim); }
.list-row.inactive { opacity: .55; }

/* ---------- modal (mobile: bottom sheet) ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(3,6,10,.72); backdrop-filter: blur(3px);
  display: grid; place-items: end center; padding: 0; z-index: 50;
}
.modal {
  width: 100%; max-width: 440px; background: var(--panel); border: 1px solid var(--border);
  border-bottom: 0; border-radius: 18px 18px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 -20px 60px rgba(0,0,0,.5); max-height: 92vh; overflow-y: auto;
}
.modal h3 { margin: 0; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.modal .sub { font-size: 12px; color: var(--muted); margin-top: -10px; }
.seg { display: flex; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.seg button { flex: 1; background: none; border: 0; color: var(--muted); font: inherit; font-size: 13px; padding: 8px; border-radius: 8px; cursor: pointer; }
.seg button.active { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--border); }
.modal select, .modal input[type=text] {
  width: 100%; background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 11px 12px; font: inherit; font-size: 15px;
}
.modal select:focus, .modal input[type=text]:focus { outline: none; border-color: var(--accent); }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; }
.modal .actions .btn { padding: 11px 16px; }
.detail { display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.detail .line { display: flex; justify-content: space-between; gap: 12px; }
.detail .line .k { color: var(--muted); font-size: 13px; }

@media (min-width: 900px) {
  .overlay { place-items: center; padding: 20px; }
  .modal { border-radius: 16px; border-bottom: 1px solid var(--border); padding: 20px; box-shadow: 0 24px 60px rgba(0,0,0,.5); }
  .seatcard-grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
  .seatcard { padding: 14px; }
  .row-form input[type=text], .row-form input[type=number] { flex: 0 1 auto; }
  .section { padding: 16px; }
  .list-row input.name-input { max-width: 260px; }
  .badge { display: inline-block; }
}

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: #241a1a; border: 1px solid #4a2626; color: #ffd7d7;
  padding: 10px 16px; border-radius: 10px; font-size: 13px; z-index: 100; max-width: 90vw; text-align: center;
}
.toast.ok { background: #10261f; border-color: #1f4d3d; color: #b8f0da; }
