:root {
  --bg: #f7f7f5; --surface: #ffffff; --text: #1d1d1b; --muted: #6b6b66; --border: #e2e2dc;
  --accent: #1f5fbf; --accent-text: #ffffff; --danger: #b3261e; --due: #b45309; --row-hover: #f0f3f9;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161615; --surface: #20201e; --text: #ececea; --muted: #a0a09a; --border: #34342f;
    --accent: #6fa0ef; --accent-text: #0d1a2e; --danger: #f2867d; --due: #f0b35a; --row-hover: #2a2d33;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
h1 { font-size: 1.35rem; margin: 0; }
h2 { font-size: 1.15rem; margin: 0 0 2px; }
h3 { font-size: 1rem; margin: 20px 0 8px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error { color: var(--danger); }
.due { color: var(--due); font-weight: 600; }

button, .button {
  font: inherit; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-text);
  border-radius: 6px; padding: 6px 12px; cursor: pointer; text-decoration: none; display: inline-block;
}
button.secondary, .button.secondary { background: transparent; color: var(--accent); }
button.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
input, select, textarea {
  font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 8px; width: 100%;
}
label { display: block; font-size: 0.85rem; color: var(--muted); }
label > input, label > select, label > textarea { margin-top: 3px; color: var(--text); }
.check { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.check input { width: auto; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.actions.end { justify-content: flex-end; margin-top: 24px; }

.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 16px; border-bottom: 1px solid var(--border); background: var(--surface); }
.filters { display: grid; grid-template-columns: minmax(180px, 2fr) repeat(2, minmax(120px, 1fr)) auto auto; gap: 10px; align-items: center; padding: 12px 16px; }
.layout { display: grid; grid-template-columns: 1fr; gap: 16px; padding: 0 16px 24px; }
.layout:has(#detail:not([hidden])) { grid-template-columns: minmax(0, 1.4fr) minmax(320px, 1fr); }

.list-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
tbody tr { cursor: pointer; }
tbody tr:hover, tbody tr.selected { background: var(--row-hover); }
#empty { padding: 16px; }

.pill { font-size: 0.78rem; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); white-space: nowrap; }
.pill.new { border-color: var(--accent); color: var(--accent); }
.pill.pilot, .pill.customer { border-color: #2e7d32; color: #2e7d32; }
.pill.closed { color: var(--muted); }

#detail { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 16px; align-self: start; }
.detail-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.edit { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.edit .actions, .edit label:last-of-type { grid-column: 1 / -1; }
.note { display: grid; gap: 8px; margin-bottom: 12px; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { border-left: 3px solid var(--border); padding: 4px 0 10px 12px; }
.timeline li.inbound { border-left-color: var(--accent); }
.timeline .text { margin: 4px 0; white-space: pre-wrap; overflow-wrap: anywhere; }

dialog { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); width: min(440px, calc(100vw - 32px)); }
dialog form { display: grid; gap: 10px; }
dialog::backdrop { background: rgb(0 0 0 / 0.4); }

.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 24px; max-width: 380px; width: 100%; }
.card .button { width: 100%; text-align: center; }

@media (max-width: 800px) {
  .filters { grid-template-columns: 1fr 1fr; }
  .filters #q { grid-column: 1 / -1; }
  .layout:has(#detail:not([hidden])) { grid-template-columns: 1fr; }
  #detail { order: -1; }
  .edit { grid-template-columns: 1fr; }
  #list th:nth-child(n+4), #list td:nth-child(n+4) { display: none; }
}

/* Booth page (booth.html): one column, big targets, sized for a phone at an exhibition. */
.booth-main { max-width: 560px; margin: 0 auto; padding: 16px; }
.booth-form { display: grid; gap: 14px; }
.booth-form input, .booth-form select, .booth-form textarea { font-size: 16px; padding: 12px; } /* 16px: phones do not zoom in */
.booth-form button { min-height: 52px; font-size: 1rem; }
.booth-sync { padding: 10px 12px; border-radius: 6px; background: var(--surface); border: 1px solid var(--border); }
.booth-sync.bad { border-color: var(--danger); color: var(--danger); font-weight: 600; }
.booth-refused { list-style: none; padding: 0; display: grid; gap: 10px; }
.booth-refused li { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px; }
