:root {
  --bg: #fff9f0; --panel: #ffffff; --ink: #2b2118; --muted: #7a6a5b; --line: #eadfce;
  --accent: #e8801c; --accent-ink: #ffffff; --accent-soft: #fdebd6;
  --ok: #1f7a45; --ok-soft: #dff3e6; --warn: #8a5300; --warn-soft: #ffefc7;
  --bad: #b3281a; --bad-soft: #fbe0dc; --info: #1f58a0; --info-soft: #dfeafa; --gray-soft: #eee8df;
  --radius: 12px; --shadow: 0 1px 2px rgba(60, 40, 10, .08), 0 6px 18px rgba(60, 40, 10, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17130f; --panel: #221c16; --ink: #f3ebe1; --muted: #b0a191; --line: #3a3027;
    --accent: #f09a3e; --accent-ink: #1a1209; --accent-soft: #3b2a16;
    --ok: #6fd99a; --ok-soft: #173826; --warn: #f0b64a; --warn-soft: #3b2d10;
    --bad: #ff9a8d; --bad-soft: #401d19; --info: #8bb8f5; --info-soft: #17283f; --gray-soft: #2b241d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .3);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- шапка и вкладки ---------- */
.top {
  background: var(--accent); color: var(--accent-ink); padding: 10px 16px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;
}
.top h1 { font-size: 18px; margin: 0; font-weight: 700; letter-spacing: .2px; margin-right: auto; }
.top select, .top input, .top button {
  background: rgba(255, 255, 255, .92); color: #2b2118; border: 0; border-radius: 8px; padding: 7px 10px;
}
.top button { cursor: pointer; font-weight: 600; }
.top .who { font-size: 13px; opacity: .95; }
.top select, .top input[type=date] { width: auto; max-width: 100%; }   /* выше по весу, чем общее правило полей */
.toolbar select, .toolbar input[type=time] { width: auto; }
.datebar { flex-wrap: wrap; }
@media (max-width: 640px) {
  .datebar .label { display: none; }
  .top h1 { width: 100%; }
}
.datebar { display: flex; gap: 6px; align-items: center; }
.datebar .label { font-weight: 600; min-width: 9ch; text-align: center; }
.tabs { display: flex; gap: 4px; padding: 10px 16px 0; overflow-x: auto; border-bottom: 1px solid var(--line); background: var(--panel); }
.tabs button {
  border: 0; background: none; padding: 10px 14px; cursor: pointer; font-weight: 600; color: var(--muted);
  border-bottom: 3px solid transparent; white-space: nowrap;
}
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.tabs .badge { background: var(--bad); color: #fff; border-radius: 99px; padding: 0 7px; font-size: 12px; margin-left: 6px; }
main { padding: 16px; max-width: 1180px; margin: 0 auto; }

/* ---------- элементы ---------- */
.btn {
  border: 1px solid var(--line); background: var(--panel); border-radius: 9px; padding: 7px 12px; cursor: pointer;
  font-weight: 600;
}
.btn:hover { border-color: var(--accent); }
a.btn { text-decoration: none; color: inherit; display: inline-block; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 4px 9px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
input[type=text], input[type=tel], input[type=number], input[type=date], input[type=time], input[type=search],
input[type=password], input[type=email], select, textarea {
  width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px;
}
textarea { min-height: 70px; resize: vertical; }
label.field { display: block; margin-bottom: 10px; font-size: 13px; color: var(--muted); }
label.field > :not(span) { margin-top: 4px; color: var(--ink); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .grow { flex: 1; min-width: 200px; }
.summary { color: var(--muted); font-size: 14px; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }

.chip { display: inline-block; border-radius: 99px; padding: 2px 10px; font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.s-new { background: var(--warn-soft); color: var(--warn); }
.s-confirmed { background: var(--ok-soft); color: var(--ok); }
.s-seated { background: var(--info-soft); color: var(--info); }
.s-done, .s-cancelled { background: var(--gray-soft); color: var(--muted); }
.s-no_show { background: var(--bad-soft); color: var(--bad); }
.flag { color: var(--bad); font-weight: 700; font-size: 13px; }

/* ---------- список броней ---------- */
.res { display: grid; grid-template-columns: 64px 1fr auto; gap: 6px 12px; padding: 12px 14px; align-items: center; }
.res + .res { margin-top: 10px; }
.res.cancelled, .res.done { opacity: .62; }
.res .time { font-size: 20px; font-weight: 800; }
.res .who b { font-size: 16px; }
.res .meta { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--muted); font-size: 13.5px; }
.res .actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.res .more { grid-column: 1 / -1; border-top: 1px dashed var(--line); padding-top: 10px; font-size: 14px; }
.res .more p { margin: 4px 0; }
.res.attn { border-left: 5px solid var(--bad); }
@media (max-width: 640px) {
  .res { grid-template-columns: 56px 1fr; }
  .res .actions { grid-column: 1 / -1; justify-content: flex-start; }
  .grid2 { grid-template-columns: 1fr; }
}

/* ---------- схема зала ---------- */
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.floor-wrap { display: grid; grid-template-columns: 1fr 300px; gap: 14px; align-items: start; }
@media (max-width: 900px) { .floor-wrap { grid-template-columns: 1fr; } }
.floor-wrap > * { min-width: 0; }
.canvas {
  position: relative; background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius);
  overflow-x: auto; overflow-y: hidden; min-height: 240px;
}
.canvas.dark { background: #10131c; border: 1px solid #232838; }          /* зал всегда тёмный, как у ReMarked */
.canvas.editing {
  background-image: linear-gradient(#232838 1px, transparent 1px), linear-gradient(90deg, #232838 1px, transparent 1px);
  background-size: 20px 20px;
}
.tbl { position: absolute; cursor: pointer; user-select: none; --c: #3ecf9a; color: #0c1a14; }
.tbl.st-booked { --c: #d63a3f; color: #fff; }
.tbl.st-late { --c: #e8590c; color: #fff; }
.tbl.st-late .surf { animation: late-pulse 1.6s ease-in-out infinite; }
.tbl.st-seated { --c: #6366f1; color: #fff; }
@keyframes late-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 140, 60, .0); } 50% { box-shadow: 0 0 0 6px rgba(255, 140, 60, .45); } }
@media (prefers-reduced-motion: reduce) { .tbl.st-late .surf { animation: none; } }
.tbl.st-booked .tm, .tbl.st-late .tm, .tbl.st-seated .tm { color: #fff; }
.tbl.merged .surf { border-style: dashed; border: 2px dashed rgba(255,255,255,.7); }
.tbl .surf {
  position: absolute; inset: 0; border-radius: 10px; background: var(--c); overflow: hidden;
  display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; line-height: 1.1;
}
.tbl.round .surf { border-radius: 50%; }
.tbl.oval .surf { border-radius: 999px; }
.tbl.conf .surf { box-shadow: inset 0 0 0 3px #fff; }
.tbl .chair { position: absolute; background: var(--c); opacity: .5; border-radius: 3px; }
.tbl b { font-size: 15px; }
.tbl .tm { font-size: 11px; font-weight: 800; }
.tbl .nx { font-size: 10.5px; opacity: .75; font-weight: 600; }
.tbl .cap {
  position: absolute; left: 50%; transform: translateX(-50%); top: calc(100% + 11px); max-width: 110px;
  font-size: 11px; font-weight: 600; color: #e8ecf5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tbl.sel .surf { outline: 3px dashed #fff; outline-offset: 3px; }
.tbl:focus-visible { outline: none; }
.tbl:focus-visible .surf { outline: 3px solid #fff; outline-offset: 3px; }
.canvas.editing .tbl { cursor: grab; touch-action: none; }
.pill { background: var(--accent-soft); color: var(--ink); border-radius: 99px; padding: 4px 12px; font-size: 13.5px; font-weight: 700; white-space: nowrap; }
.zones { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.strip {
  position: relative; display: flex; gap: 6px; overflow-x: auto; margin-top: 10px; padding: 8px;
  background: #10131c; border: 1px solid #232838; border-radius: var(--radius);
}
.slot {
  flex: 0 0 auto; min-width: 74px; padding: 6px 8px; border: 1px solid #2a3042; background: #171b27; color: #aab2c7;
  border-radius: 10px; cursor: pointer; text-align: center; line-height: 1.25;
}
.slot b { display: block; font-size: 17px; color: #fff; }
.slot small { display: block; font-size: 12px; }
.slot[aria-pressed="true"] { border-color: #3ecf9a; background: #14302a; }
.slot[aria-pressed="true"] b { color: #f0b64a; }
.panel h3 { margin: 0 0 8px; }
.panel .block { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.stack > * + * { margin-top: 8px; }

/* ---------- диалоги и уведомления ---------- */
.overlay { position: fixed; inset: 0; background: rgba(20, 12, 4, .5); display: flex; align-items: flex-start; justify-content: center; overflow: auto; padding: 24px 12px; z-index: 20; }
.dialog { background: var(--panel); border-radius: var(--radius); width: min(560px, 100%); padding: 18px; box-shadow: var(--shadow); }
.dialog h2 { margin: 0 0 12px; font-size: 19px; }
.dialog .foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
.notice { border-radius: 9px; padding: 8px 12px; margin: 8px 0; font-size: 14px; }
.notice.err { background: var(--bad-soft); color: var(--bad); }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.notice.info { background: var(--info-soft); color: var(--info); }
.slots { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
#toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 40; width: min(420px, 94vw); }
.toast { background: #2b2118; color: #fff; padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); }
.toast.err { background: var(--bad); color: #fff; }

/* ---------- гости, сообщения ---------- */
.list-item { padding: 12px 14px; cursor: pointer; }
.list-item + .list-item { margin-top: 8px; }
.stats { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0; }
.stats div { background: var(--accent-soft); border-radius: 10px; padding: 8px 14px; text-align: center; }
.stats b { display: block; font-size: 20px; }
.msg-body { white-space: pre-wrap; background: var(--gray-soft); border-radius: 9px; padding: 10px; margin: 8px 0; font-size: 14px; }
table.hist { width: 100%; border-collapse: collapse; font-size: 14px; }
table.hist td, table.hist th { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; }

/* ---------- вход и страница гостя ---------- */
.login { max-width: 400px; margin: 12vh auto; }
.login h1 { margin-top: 0; }
body.guest { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
body.guest .card { width: min(420px, 100%); text-align: center; padding: 24px; }
body.guest h1 { margin: 0 0 4px; font-size: 20px; }
body.guest .big { font-size: 26px; font-weight: 800; margin: 6px 0; }
body.guest form { display: grid; gap: 10px; margin-top: 18px; }
body.guest button { border: 0; border-radius: 10px; padding: 13px; font-size: 16px; font-weight: 700; cursor: pointer; }
body.guest .ok { background: var(--ok); color: #fff; }
body.guest .no { background: var(--gray-soft); color: var(--ink); }
body.guest .msg { background: var(--ok-soft); color: var(--ok); padding: 8px; border-radius: 9px; }

.menu-btn { width: 100%; text-align: left; padding: 13px 14px; font-size: 16px; }

/* ---------- настройки ---------- */
.settings { display: grid; gap: 14px; max-width: 780px; }
.settings h3 { margin: 0; }
.settings .item { padding: 6px 0; border-bottom: 1px solid var(--line); }
.settings .item .grow { flex: 1; }
.tscroll { overflow-x: auto; }

/* ---------- объекты зала ---------- */
.obj {
  position: absolute; display: flex; align-items: center; justify-content: center; text-align: center; padding: 0 4px;
  font-size: 11px; font-weight: 700; letter-spacing: .3px; color: #aab2c7; background: #1b2030; border: 1.5px solid #3a4260;
  border-radius: 6px; pointer-events: none; overflow: hidden;
}
.obj span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.obj-entrance { background: #10281f; border-color: #3ecf9a; border-style: dashed; color: #3ecf9a; }
.obj-stage { background: #2a1d3d; border-color: #9b6bdc; color: #cdb0f5; }
.obj-bar { background: #3a2a16; border-color: #d69a3d; color: #f0c476; }
.obj-column { background: #3a4260; border-color: #59638a; border-radius: 50%; }
.obj-dj { background: #14283a; border-color: #4da3d9; color: #9bd0f0; }
.obj-wc { background: #1f2a2a; border-color: #5f8f8f; color: #9fc4c4; }
.obj-kitchen { background: #2b2320; border-color: #8a6a58; color: #cdb0a0; }
.obj-wall { background: #59638a; border-color: #59638a; border-radius: 2px; }
.obj-label { background: transparent; border-color: transparent; color: #e8ecf5; font-size: 13px; }
.canvas.editing .obj { pointer-events: auto; cursor: grab; touch-action: none; }
.obj.sel { outline: 3px dashed #fff; outline-offset: 2px; }

/* лист зала: переименование и удаление */
.zones .zone-tools { display: inline-flex; gap: 6px; margin-left: 8px; }
.merge-box { border: 1px solid var(--line, #d9dde7); border-radius: 10px; padding: 8px 10px; display: grid; gap: 4px; }
.merge-box label { display: flex; gap: 8px; align-items: center; font-size: 14px; }

/* боковое окно «Брони дня» */
.drawer-btn { white-space: nowrap; }
.drawer {
  position: fixed; left: 0; top: 0; bottom: 0; width: 320px; max-width: 92vw; z-index: 40; background: var(--bg, #fff); color: var(--ink);
  border-right: 1px solid var(--line, #d9dde7); box-shadow: 4px 0 24px rgba(0,0,0,.18); display: flex; flex-direction: column;
  transform: translateX(-102%); transition: transform .2s ease; visibility: hidden;
}
.drawer.open { transform: none; visibility: visible; }
.drawer header { display: flex; align-items: center; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--line, #d9dde7); }
.drawer header h2 { font-size: 16px; margin: 0; flex: 1; }
.drawer .dd { display: flex; align-items: center; gap: 4px; padding: 8px 12px; }
.drawer .dd .label { flex: 1; text-align: center; font-weight: 700; }
.drawer .sum { padding: 0 12px 8px; font-size: 13px; color: var(--muted); }
.drawer .list { overflow-y: auto; padding: 0 10px 14px; display: grid; gap: 8px; align-content: start; flex: 1; }
.drawer .it { border: 1px solid var(--line, #d9dde7); border-radius: 10px; padding: 8px 10px; cursor: pointer; text-align: left; background: transparent; color: inherit; font: inherit; }
.drawer .it:hover, .drawer .it:focus-visible { border-color: #3ecf9a; }
.drawer .it .t { font-weight: 800; }
.drawer .it.late { border-color: #e8590c; background: rgba(232, 89, 12, .10); }
.drawer .it.seated { border-color: #6366f1; }
.drawer .flag { color: #e8590c; font-weight: 800; font-size: 12px; }
@media (min-width: 1100px) { body.drawer-open main { margin-left: 332px; max-width: none; } }
