:root {
  --bg: #15171b; --bg-alt: #20232a; --fg: #dde2dd; --muted: #8e9a9a;
  --accent: #51625c; --accent-hover: #3d4a45; --border: #3a3e3a;
  --free: #4fae7a; --busy: #5b5f5a; --danger: #f0a090;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Manrope", -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.5 var(--sans); }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--fg); text-underline-offset: 3px; }
:focus-visible { outline: 3px solid #9ec9b4; outline-offset: 2px; }

.app { max-width: 960px; margin: 0 auto; padding: 20px 16px 32px; }

/* header */
.head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 8px 24px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.brand { font: 600 30px/1 var(--serif); letter-spacing: .22em; margin: 0; }
.sub { margin: 6px 0 0; color: var(--muted); font-size: 14px; letter-spacing: .08em; text-transform: uppercase; }
.head-contacts { text-align: right; }
.addr { margin: 0; color: var(--muted); font-size: 14px; }
.tel { display: inline-flex; align-items: center; min-height: 44px; font: 600 20px var(--sans); text-decoration: none; letter-spacing: .02em; }
.tel:hover { text-decoration: underline; }

/* controls */
.controls { display: grid; gap: 16px; padding: 20px 0 8px; }
.field { display: grid; gap: 6px; }
.field label { font-size: 14px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.field output { color: var(--fg); font-weight: 700; font-size: 18px; }
input[type=date], input[type=time], input:not([type]), input[type=tel], select, textarea {
  width: 100%; min-height: 48px; padding: 10px 12px; background: var(--bg-alt); border: 1px solid var(--border); border-radius: 8px;
}
textarea { resize: vertical; min-height: 72px; }
input::placeholder { color: #6c7676; }
input[type=range] { width: 100%; height: 44px; accent-color: var(--free); background: transparent; margin: 0; }
.scale { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: -6px; }
.until { margin: 4px 0 0; font-size: 14px; color: var(--muted); }
.until b { color: var(--fg); }
.hint { opacity: .8; }

.switches { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; margin: 12px 0; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--bg-alt); }
.seg button { min-height: 44px; padding: 0 18px; background: none; border: 0; cursor: pointer; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--border); }
.seg button[aria-pressed=true] { background: var(--accent); color: #fff; }
.seg button:not([aria-pressed=true]):hover { background: #2a2e36; color: var(--fg); }
.seg-small button { padding: 0 12px; font-size: 14px; }

.notice { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: 8px 0; padding: 12px 14px; background: #2b2a22; border: 1px solid #5c5a3c; border-radius: 8px; font-size: 15px; }
.link { background: none; border: 0; padding: 0 4px; min-height: 44px; text-decoration: underline; cursor: pointer; color: var(--fg); }

/* stage */
.stage { position: relative; margin-top: 8px; }
.loadbar { position: absolute; left: 0; right: 0; top: -6px; height: 2px; background: linear-gradient(90deg, transparent, var(--free), transparent); background-size: 40% 100%; background-repeat: no-repeat; opacity: 0; }
.stage[aria-busy=true] .loadbar { opacity: 1; animation: slide 1.1s linear infinite; }
.stage[aria-busy=true] .plan, .stage[aria-busy=true] .cards { opacity: .75; }
@keyframes slide { from { background-position: -40% 0; } to { background-position: 140% 0; } }

.plan { position: relative; background: var(--bg-alt); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; min-height: 160px; }
.plan-img { display: block; width: 100%; height: auto; user-select: none; }
.plan.noimg { aspect-ratio: 10 / 7; }
.tbl { position: absolute; width: 44px; height: 44px; margin: -22px 0 0 -22px; padding: 0; border-radius: 50%; border: 2px solid transparent; font-weight: 800; font-size: 16px; cursor: pointer; display: grid; place-items: center; }
.tbl.free { background: var(--free); color: #0c1a12; box-shadow: 0 0 0 4px rgba(79,174,122,.22); }
.tbl.free:hover { background: #63c18d; }
.tbl.busy { background: var(--busy); color: #e9ece9; cursor: not-allowed; }
.tbl.unk { background: #3a3e3a; color: var(--muted); cursor: wait; }
.tbl.sel { border-color: #fff; box-shadow: 0 0 0 5px rgba(255,255,255,.25); }
.legend { display: flex; gap: 18px; list-style: none; margin: 10px 2px 0; padding: 0; color: var(--muted); font-size: 14px; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.dot.free { background: var(--free); } .dot.busy { background: var(--busy); }

.pop { position: absolute; z-index: 5; width: 232px; padding: 10px; background: var(--bg); border: 1px solid var(--accent); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.55); }
.pop-zoom { display: block; width: 100%; padding: 0; border: 0; border-radius: 8px; overflow: hidden; background: var(--bg-alt); cursor: zoom-in; }
.pop-img { display: block; width: 100%; height: 110px; object-fit: cover; }
.pop-desc { margin: 0 0 2px; color: var(--muted); font-size: 13px; line-height: 1.3; }
.pop-title { margin: 8px 0 2px; font-weight: 700; font-size: 14px; line-height: 1.3; }
.pop-free { margin: 0 0 8px; color: var(--free); font-size: 14px; }
.x { background: rgba(21,23,27,.8); border: 1px solid var(--border); color: var(--fg); width: 44px; height: 44px; border-radius: 50%; font-size: 26px; line-height: 1; cursor: pointer; }
.x-small { position: absolute; top: 14px; right: 14px; z-index: 1; width: 44px; height: 44px; }

/* list */
.listbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.count { margin: 0; color: var(--muted); }
.cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.card { width: 100%; text-align: left; padding: 0; background: var(--bg-alt); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; cursor: pointer; display: block; }
.card:hover { border-color: var(--accent); }
.card-img { display: block; width: 100%; height: 96px; object-fit: cover; background: var(--bg); }
.card-body { display: grid; gap: 2px; padding: 10px 12px 12px; }
.card-title { font: 600 18px var(--serif); }
.card-meta { color: var(--muted); font-size: 14px; }
.card-row { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; gap: 6px; }
.seats { font-size: 14px; display: inline-flex; align-items: center; gap: 6px; }
.badge { font-size: 12px; font-weight: 700; color: #0c1a12; background: var(--free); padding: 2px 8px; border-radius: 99px; }
.empty { grid-column: 1 / -1; padding: 28px 12px; text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: 10px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 22px; background: var(--accent); color: #fff; border: 0; border-radius: 10px; font-weight: 700; cursor: pointer; width: 100%; }
.btn:hover:not(:disabled) { background: var(--accent-hover); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-small { min-height: 44px; }
.btn-ghost { background: transparent; border: 1px solid var(--accent); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-alt); }

/* dialogs */
dialog { color: var(--fg); background: var(--bg); border: 1px solid var(--border); border-radius: 14px; padding: 0; }
dialog::backdrop { background: rgba(5,6,8,.72); }
.modal { width: min(480px, calc(100% - 32px)); max-height: calc(100dvh - 32px); overflow: auto; }
.modal form, .done-card { padding: 20px 18px 22px; display: grid; gap: 14px; }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.modal h2 { font: 600 24px/1.2 var(--serif); margin: 0; }
.table-line, .date-line { margin: -8px 0 0; color: var(--muted); }
.date-line { margin-top: -10px; color: var(--fg); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.err { margin: 0; min-height: 0; color: var(--danger); font-size: 14px; }
.err:empty { display: none; }
.err-form { padding: 10px 12px; border: 1px solid #6b3f37; border-radius: 8px; background: #2a1c1a; }
.check { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; line-height: 1.4; cursor: pointer; }
.check input { flex: none; width: 24px; height: 24px; margin: 0; accent-color: var(--free); }
.check span { padding-top: 2px; }
.done-card h2 { font: 600 22px/1.25 var(--serif); margin: 0; }
.rows { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; padding: 14px; background: var(--bg-alt); border-radius: 10px; }
.rows dt { color: var(--muted); }
.rows dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.info p { margin: 0 0 6px; color: var(--muted); font-size: 14px; }
.actions { display: grid; gap: 10px; }

.lightbox { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; background: rgba(5,6,8,.94); border: 0; border-radius: 0; display: none; place-items: center; }
.lightbox[open] { display: grid; }
.lightbox img { max-width: 94vw; max-height: 90dvh; object-fit: contain; border-radius: 8px; }
.lightbox .x { position: fixed; top: 12px; right: 12px; }

.foot { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 13px; }
.foot a { color: var(--muted); min-height: 24px; }

@media (min-width: 720px) {
  .app { padding: 32px 24px 48px; }
  .controls { grid-template-columns: 220px 1fr; align-items: start; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
  .card-img { height: 120px; }
  .btn { width: auto; }
  .modal .btn { width: 100%; }
  .actions { grid-auto-flow: column; justify-content: end; }
  .done-card .btn { width: auto; }
}

/* embed */
.embed body { background: transparent; }
.embed .app { max-width: none; padding: 10px 12px 14px; }
.embed .sub, .embed .addr, .embed .foot { display: none; }
.embed .head { padding-bottom: 8px; align-items: center; }
.embed .brand { font-size: 22px; }
.embed .tel { font-size: 17px; }
.embed .controls { padding-top: 12px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
