:root {
  --bg: #f6f4ef;
  --card: #ffffff;
  --ink: #1d2433;
  --muted: #667085;
  --line: #e4e0d6;
  --brand: #2f4bd8;
  --brand-ink: #ffffff;
  --ok: #15803d;
  --ok-bg: #e7f6ec;
  --warn: #b45309;
  --warn-bg: #fff4dd;
  --bad: #b42318;
  --bad-bg: #fde8e6;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 25, 40, .06), 0 8px 24px rgba(20, 25, 40, .06);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -.01em; }
h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.08rem; }
p { margin: 0; }
a { color: var(--brand); }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px clamp(16px, 4vw, 40px);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 1.1rem; color: var(--ink); text-decoration: none; }
.brand-mark { width: 22px; height: 22px; border-radius: 7px; background: linear-gradient(135deg, var(--brand), #8b5cf6); }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { padding: 7px 12px; border-radius: 999px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: .95rem; }
.nav a:hover { color: var(--ink); background: #f0ede5; }
.nav a.active { color: var(--brand); background: #e9edff; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.who { color: var(--muted); font-size: .9rem; }
.who button { background: none; border: 0; color: var(--brand); cursor: pointer; font: inherit; padding: 0 0 0 6px; }

/* ---------- buttons, inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 10px; border: 1px solid transparent;
  background: var(--brand); color: var(--brand-ink);
  font: inherit; font-weight: 650; text-decoration: none; cursor: pointer;
}
.btn:hover:not(:disabled) { filter: brightness(1.08); }
.btn:disabled { cursor: not-allowed; background: #ece9e1; color: #8a8f9c; }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.held { background: var(--warn-bg); color: var(--warn); border-color: #f3d9a4; }
.btn.done:disabled { background: var(--ok-bg); color: var(--ok); }
.btn.danger { background: #fff; color: var(--bad); border-color: #f1c4bf; }
.btn.small { padding: 6px 10px; font-size: .88rem; border-radius: 8px; }
.btn.block { width: 100%; }
#cart-count { background: var(--brand); color: #fff; border-radius: 999px; padding: 0 8px; font-size: .85rem; }

input, select, textarea {
  font: inherit; color: inherit; width: 100%;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid #b9c5ff; outline-offset: 1px;
}
textarea { min-height: 84px; resize: vertical; }
label { display: grid; gap: 5px; font-weight: 600; font-size: .92rem; }
label small, .hint { font-weight: 400; color: var(--muted); font-size: .86rem; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; white-space: nowrap; }
.check input { width: auto; }

/* ---------- layout ---------- */
main { padding: clamp(16px, 4vw, 40px); max-width: 1280px; margin: 0 auto; }
.narrow { max-width: 760px; margin: 0 auto; display: grid; gap: 18px; }
.hero { margin-bottom: 20px; display: grid; gap: 6px; }
.hero p, .lead { color: var(--muted); }
.filters { display: grid; grid-template-columns: minmax(200px, 2fr) 1fr auto; gap: 10px; margin-bottom: 20px; align-items: center; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 18px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); display: grid; gap: 14px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .wide { grid-column: 1 / -1; }
.empty { text-align: center; color: var(--muted); padding: 36px 12px; }
.error { color: var(--bad); font-weight: 600; min-height: 1.2em; }

/* ---------- workshop cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.media { display: block; width: 100%; aspect-ratio: 4 / 3; background: #ddd; position: relative; }
.media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph { width: 100%; height: 100%; display: grid; place-items: center; color: rgba(255, 255, 255, .92); font-size: 3.2rem; font-weight: 800; }
.card-body { padding: 14px 16px 16px; display: grid; gap: 8px; flex: 1; align-content: start; }
.card-body .btn { margin-top: 6px; }
.chip { justify-self: start; display: inline-block; padding: 2px 10px; border-radius: 999px; background: #eef0f6; color: #475069; font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.meta { color: var(--muted); font-size: .92rem; }
.title-btn { all: unset; cursor: pointer; font-weight: 700; font-size: 1.08rem; line-height: 1.25; }
.title-btn:hover { color: var(--brand); }
.seats { display: grid; gap: 4px; font-size: .86rem; color: var(--muted); }
.bar { height: 6px; border-radius: 999px; background: #ece9e1; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--ok); border-radius: inherit; }
.bar.low i { background: var(--warn); }
.bar.none i { background: var(--bad); }
.timer { font-variant-numeric: tabular-nums; font-weight: 750; }
.timer.urgent { color: var(--bad); }

.add-row { display: grid; grid-template-columns: 76px 1fr; gap: 8px; margin-top: 6px; }
.add-row .btn { margin-top: 0; }
.stepper { display: inline-flex; align-items: center; gap: 12px; }
.stepper button { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font: inherit; font-weight: 700; cursor: pointer; }
.stepper button:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- cart drawer ---------- */
.scrim { position: fixed; inset: 0; background: rgba(15, 20, 35, .4); z-index: 30; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 31;
  width: min(420px, 100vw); background: var(--card);
  display: flex; flex-direction: column; box-shadow: -12px 0 40px rgba(15, 20, 35, .18);
}
.drawer header, .drawer footer { padding: 16px 20px; border-bottom: 1px solid var(--line); }
.drawer footer { border-bottom: 0; border-top: 1px solid var(--line); display: grid; gap: 10px; }
.drawer .items { flex: 1; overflow: auto; padding: 8px 20px; }
.item { padding: 14px 0; border-bottom: 1px solid var(--line); display: grid; gap: 4px; }
.item:last-child { border-bottom: 0; }
.x { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; text-decoration: underline; padding: 0; }
.x:hover { color: var(--bad); }

/* ---------- detail dialog ---------- */
.detail { border: 0; border-radius: 18px; padding: 0; width: min(640px, calc(100vw - 24px)); box-shadow: 0 30px 80px rgba(15, 20, 35, .35); }
.detail::backdrop { background: rgba(15, 20, 35, .5); }
.detail .media { aspect-ratio: 16 / 8; cursor: default; }
.detail .body { padding: 20px 24px 24px; display: grid; gap: 12px; }
.detail dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; }
.detail dt { color: var(--muted); }
.detail dd { margin: 0; font-weight: 600; }
.close { position: absolute; top: 10px; right: 10px; z-index: 2; width: 36px; height: 36px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .92); cursor: pointer; font-size: 1.1rem; }

/* ---------- schedule, supplies, tables ---------- */
.slot { display: grid; grid-template-columns: 120px 1fr auto; gap: 14px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); }
.slot:last-child { border-bottom: 0; }
.slot time { font-weight: 700; font-variant-numeric: tabular-nums; }
.budget { display: grid; gap: 4px; font-size: .9rem; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td input, td select { padding: 6px 8px; min-width: 70px; }
tr.over td { background: #fff8f6; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs button { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font: inherit; font-weight: 650; cursor: pointer; }
.tabs button.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.thumb { width: 64px; height: 44px; border-radius: 8px; object-fit: cover; background: #e8e5dd; display: block; }

/* ---------- toasts ---------- */
.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 50; width: min(440px, calc(100vw - 24px)); }
.toast { background: #1d2433; color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow); font-weight: 550; }
.toast.bad { background: var(--bad); }
.toast.ok { background: var(--ok); }

@media (max-width: 760px) {
  .filters { grid-template-columns: 1fr 1fr; }
  .filters input[type=search], .filters .check { grid-column: 1 / -1; }
  .form-grid { grid-template-columns: 1fr; }
  .slot { grid-template-columns: 1fr auto; }
  .slot time { grid-column: 1 / -1; }
  .who span { display: none; }
}

@media print {
  .top, .filters, .btn, .x, .toasts { display: none !important; }
  body { background: #fff; }
  .panel { box-shadow: none; border: 0; padding: 0; }
}
