/* CMS stylesheet. Refined, not showy: warm neutrals shared with the
 * default board theme, generous whitespace, one accent, no decoration
 * that doesn't earn its place. Laptop-first; usable on a phone. */

:root {
  --paper: #f6f3ee;
  --card: #fffdfa;
  --ink: #221d17;
  --muted: #756c60;
  --line: #e6dfd4;
  --line-strong: #d5cbbc;
  --accent: #b3451e;
  --accent-soft: #b3451e14;
  --ok: #3d7a48;
  --ok-soft: #3d7a4816;
  --danger: #a02c2c;
  --danger-soft: #a02c2c14;
  --radius: 10px;
  --radius-small: 7px;
  --shadow: 0 1px 2px rgb(34 29 23 / 0.05), 0 4px 16px rgb(34 29 23 / 0.05);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; }

html { height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1 { font-size: 1.45rem; font-weight: 650; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 1.02rem; font-weight: 650; margin: 0; letter-spacing: -0.005em; }
a { color: inherit; }
em { font-style: normal; color: var(--muted); font-weight: 400; }

/* ── Top bar ─────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar__inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.topbar__product {
  font-weight: 700;
  letter-spacing: 0.01em;
}
.topbar__org {
  color: var(--muted);
  padding-left: 16px;
  border-left: 1px solid var(--line);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar__nav { display: flex; gap: 4px; margin-left: auto; }
.topbar__nav a {
  text-decoration: none;
  padding: 7px 14px;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 550;
}
.topbar__nav a:hover { color: var(--ink); background: var(--accent-soft); }
.topbar__nav a.is-active { color: var(--ink); background: var(--accent-soft); }

/* ── Page frame ──────────────────────────────────────── */

.page { max-width: 1280px; margin: 0 auto; padding: 28px 24px 96px; }
.page--bare {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.page-actions { margin: 18px 0 34px; }
.crumb { color: var(--muted); text-decoration: none; font-weight: 450; }
.crumb:hover { color: var(--ink); }
.empty-note { color: var(--muted); }

/* ── Buttons, fields, forms ──────────────────────────── */

.btn {
  font: inherit;
  font-weight: 570;
  border: 1px solid transparent;
  border-radius: var(--radius-small);
  padding: 8px 16px;
  cursor: pointer;
  background: var(--ink);
  color: var(--card);
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.05s ease;
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: color-mix(in srgb, var(--accent) 88%, black); }
.btn--ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line-strong);
}
.btn--ghost:hover { border-color: var(--ink); background: var(--card); }
.btn--danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.btn--danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn--small { padding: 5px 11px; font-size: 0.88rem; }
.btn--full { width: 100%; }
.btn[disabled] { opacity: 0.55; cursor: default; }

:is(button, a, input, select, textarea):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-small);
}

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field > span { font-size: 0.88rem; font-weight: 570; }
.field__hint { font-size: 0.82rem; color: var(--muted); margin: -6px 0 14px; }
.field--check { flex-direction: row; align-items: center; gap: 9px; font-weight: 500; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }

input, select, textarea {
  font: inherit;
  color: inherit;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-small);
  padding: 8px 11px;
}
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--ink) 40%, var(--line-strong)); }
input[type='checkbox'] { width: 16px; height: 16px; accent-color: var(--accent); padding: 0; }
input[type='number'] { width: 5.2em; }

.inline-form { display: flex; gap: 8px; }
.form-error { color: var(--danger); font-size: 0.9rem; margin: 2px 0 12px; }

/* ── Auth card ───────────────────────────────────────── */

.auth-card {
  width: min(400px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 34px 34px 28px;
}
.auth-card__product {
  margin: 0 0 4px;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.auth-card h1 { margin-bottom: 20px; }
.auth-card__hint { color: var(--muted); margin: -12px 0 20px; }

/* ── The board strip ─────────────────────────────────── */

.board-strip {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 30px;
}
.board-strip__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.board-strip__head h2 { text-transform: uppercase; letter-spacing: 0.07em; font-size: 0.85rem; color: var(--accent); }
.board-strip__actions { display: flex; gap: 8px; }
.board-strip__empty { color: var(--muted); margin: 12px 0 2px; }
.board-strip__list {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  counter-reset: board;
}
.board-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  padding: 8px 12px;
}
.board-chip::before {
  counter-increment: board;
  content: counter(board);
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  min-width: 1.2em;
  text-align: center;
}
.board-chip__name { font-weight: 600; }
.board-chip__meta { color: var(--muted); font-size: 0.88rem; }
.board-chip__down {
  margin-left: auto;
  font: inherit;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-small);
}
.board-chip__down:hover { color: var(--danger); background: var(--danger-soft); }

/* ── Categories and item rows ────────────────────────── */

.category {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  overflow: hidden;
}
.category__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
}
.category__count { color: var(--muted); font-size: 0.86rem; }
.category__hint { color: var(--muted); font-size: 0.86rem; }
.category__actions { margin-left: auto; display: flex; gap: 6px; }
.category__empty { color: var(--muted); padding: 14px 18px; margin: 0; }
.category--library { border-style: dashed; border-color: var(--line-strong); }
.category--library .category__head h2 { color: var(--accent); }

.items { list-style: none; margin: 0; padding: 0; }
.item-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 18px;
  border-bottom: 1px solid var(--line);
}
.item-row:last-child { border-bottom: 0; }
.item-row:hover { background: color-mix(in srgb, var(--paper) 55%, var(--card)); }
.item-row__main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.item-row__name { font-weight: 600; }
.item-row__desc {
  color: var(--muted);
  font-size: 0.86rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item-row__price { font-variant-numeric: tabular-nums; font-weight: 620; white-space: nowrap; }
.item-row__toggles { display: flex; gap: 6px; }
.is-86ed .item-row__name { text-decoration: line-through; color: var(--muted); }
.is-86ed .item-row__price { color: var(--muted); }

/* The two daily actions. State reads at a glance; one tap flips it. */
.toggle {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 620;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--card);
  padding: 5px 13px;
  cursor: pointer;
  min-width: 86px;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.toggle .toggle__off { display: none; }
.toggle.is-off .toggle__on { display: none; }
.toggle.is-off .toggle__off { display: inline; }

.toggle--avail.is-on { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); background: var(--ok-soft); }
.toggle--avail.is-off { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); background: var(--danger-soft); }
.toggle--feat.is-on { color: #fff; background: var(--accent); border-color: var(--accent); }
.toggle--feat.is-off { color: var(--muted); }
.toggle--feat.is-off:hover { color: var(--accent); border-color: var(--accent); }

.drag-handle {
  color: var(--line-strong);
  cursor: grab;
  touch-action: none;
  padding: 4px 2px;
  display: inline-flex;
  align-items: center;
}
.item-row:hover .drag-handle, .category__head:hover .drag-handle, .board-chip:hover .drag-handle { color: var(--muted); }
.dragging { opacity: 0.4; }
.drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 100;
  opacity: 0.92;
  box-shadow: 0 10px 30px rgb(34 29 23 / 0.22);
  background: var(--card);
  border-radius: var(--radius-small);
}

/* ── Dialogs ─────────────────────────────────────────── */

.dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 24px 80px rgb(34 29 23 / 0.25);
  padding: 26px 28px;
  width: min(440px, calc(100vw - 32px));
  background: var(--card);
  color: inherit;
}
.dialog::backdrop { background: rgb(34 29 23 / 0.35); backdrop-filter: blur(2px); }
.dialog h2 { margin-bottom: 16px; font-size: 1.15rem; }
.dialog__hint { color: var(--muted); font-size: 0.9rem; margin: -8px 0 16px; }
.dialog__actions { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.dialog__spacer { flex: 1; }

/* ── Screens ─────────────────────────────────────────── */

.display-list { display: flex; flex-direction: column; gap: 14px; }
.display-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.display-card__main { flex: 1; min-width: 0; }
.display-card__main a { text-decoration: none; }
.display-card__main a:hover { color: var(--accent); }
.display-card__meta { color: var(--muted); margin: 3px 0 0; font-size: 0.9rem; }
.display-card__device { display: flex; align-items: center; gap: 10px; }
.device-status { display: flex; align-items: center; gap: 7px; margin: 0; color: var(--muted); font-size: 0.9rem; white-space: nowrap; }
.device-status--off { color: var(--muted); }
.device-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); display: inline-block; }
.pair-form { display: flex; gap: 6px; }
.pair-form input { width: 9.5em; text-transform: uppercase; letter-spacing: 0.06em; }

/* ── Display detail ──────────────────────────────────── */

.detail-grid { display: grid; grid-template-columns: minmax(430px, 5fr) 7fr; gap: 22px; align-items: start; }
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 18px;
}
.panel h2 { margin-bottom: 14px; }
.panel__hint { color: var(--muted); font-size: 0.88rem; margin: -8px 0 14px; }

.placement-row {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.placement-row__name { font-weight: 620; min-width: 120px; flex: 1; }
.placement-row label { display: inline-flex; align-items: center; gap: 5px; font-size: 0.84rem; color: var(--muted); }
.placement-row input[type='number'] { width: 4em; padding: 5px 7px; }
.placement-row__check { font-size: 0.84rem; }
.placement-row__wide { flex-basis: 100%; }
.placement-row__wide input { flex: 1; }
.placement-row:not(.is-placed) { opacity: 0.88; }
.placement-row--specials .placement-row__name { color: var(--accent); }

.detail-grid__preview { position: sticky; top: 76px; }
.preview-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  overflow: hidden;
  border: 6px solid #221d17;
  background: #221d17;
}
.preview-frame--portrait { aspect-ratio: 9 / 16; max-width: 420px; }
.panel--preview .panel__hint { margin: 14px 0 0; }
.preview-frame iframe {
  position: absolute;
  top: 0;
  left: 0;
  border: 0;
  transform-origin: top left;
  pointer-events: none;
}

/* ── Settings: the hours editor and the link box ─────── */

.settings-page { max-width: 720px; }

.hours-day {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.hours-day__label { min-width: 92px; font-weight: 620; padding-top: 7px; }
.hours-day__intervals { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.hours-day__closed { color: var(--muted); padding-top: 7px; }
.hours-day__actions { display: flex; gap: 6px; padding-top: 3px; }

.hours-interval { display: flex; align-items: center; gap: 8px; }
.hours-interval input[type='time'] { padding: 5px 8px; }
.hours-interval__dash { color: var(--muted); }
.hours-interval__remove {
  font: inherit;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-small);
}
.hours-interval__remove:hover { color: var(--danger); background: var(--danger-soft); }

.linkbox { display: flex; gap: 8px; }
.linkbox input { flex: 1; color: var(--muted); }

/* ── Toast ───────────────────────────────────────────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--card);
  border-radius: 999px;
  padding: 10px 20px;
  box-shadow: 0 10px 30px rgb(34 29 23 / 0.3);
  z-index: 60;
  max-width: min(560px, calc(100vw - 40px));
}
.toast--error { background: var(--danger); color: #fff; }

/* ── Small screens ───────────────────────────────────── */

@media (max-width: 980px) {
  .detail-grid { grid-template-columns: 1fr; }
  .detail-grid__preview { position: static; }
}
@media (max-width: 640px) {
  .topbar__org { display: none; }
  .item-row { flex-wrap: wrap; }
  .item-row__toggles { order: 5; width: 100%; justify-content: flex-end; }
  .display-card { flex-wrap: wrap; }
}
