:root {
  --bg: #14171b;
  --panel: #1b1f24;
  --panel-alt: #20252c;
  --border: #2c323b;
  --text: #e7e9ec;
  --text-dim: #8b93a0;
  --text-faint: #5b626e;
  --accent: #ff7a29;
  --accent-dim: #c75f1f;
  --accent-soft: rgba(255, 122, 41, 0.12);
  --success: #57b894;
  --success-soft: rgba(87, 184, 148, 0.14);
  --danger: #e5555f;
  --danger-soft: rgba(229, 85, 95, 0.12);
  --radius: 10px;
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  height: 100vh;
  overflow: hidden;
}

button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; }

/* ---------- Layout ---------- */

.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  height: 100vh;
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
}

.sidebar-head { margin-bottom: 20px; }

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.06em;
  color: var(--text);
}

.brand-mark {
  color: var(--accent);
  transform: rotate(45deg);
  display: inline-block;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-top: 2px;
  margin-left: 24px;
}

.list-nav {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.list-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  color: var(--text-dim);
  font-size: 14px;
}

.list-nav-item:hover { background: var(--panel-alt); cursor: pointer; }

.list-nav-item.active {
  background: var(--accent-soft);
  border-color: rgba(255, 122, 41, 0.35);
  color: var(--text);
}

.list-nav-emoji { font-size: 16px; }
.list-nav-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-nav-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
}

.btn-new-list {
  margin-top: 12px;
  width: 100%;
  justify-content: center;
}

.sidebar-foot {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--panel-alt);
  color: var(--text);
  border-radius: var(--radius);
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 500;
  transition: transform 0.08s ease, border-color 0.15s ease;
}

.btn:hover { border-color: var(--text-faint); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-ghost { background: transparent; }
.btn-small { padding: 6px 10px; font-size: 12px; }
.btn-large { padding: 13px 22px; font-size: 14px; font-weight: 600; }

.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a0f06;
  font-weight: 600;
}
.btn-accent:hover { background: #ff8a42; border-color: #ff8a42; }

.plus { color: var(--accent); font-weight: 700; }

.link-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 12px;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.link-btn.danger { color: var(--danger); }

.icon-btn {
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 14px;
  padding: 4px 6px;
  border-radius: 6px;
}
.icon-btn:hover { background: var(--panel-alt); color: var(--text); }

/* ---------- Main / empty state ---------- */

.main { overflow: hidden; height: 100vh; }

.empty-state {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-dim);
  padding: 40px;
}
.empty-mark {
  font-size: 40px;
  color: var(--text-faint);
  transform: rotate(45deg);
  margin-bottom: 12px;
}
.empty-state h2 { font-family: var(--font-display); color: var(--text); margin: 0 0 8px; }
.empty-state p { max-width: 320px; margin: 0; font-size: 14px; }

/* ---------- Workspace ---------- */

.workspace { height: 100%; display: flex; flex-direction: column; padding: 28px 32px; overflow-y: auto; }

.workspace-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.list-title { display: flex; align-items: center; gap: 10px; }
.list-emoji { font-size: 26px; }
.list-title h1 { font-family: var(--font-display); font-size: 24px; margin: 0; font-weight: 600; }

.list-meta { display: flex; align-items: center; gap: 16px; color: var(--text-faint); font-size: 12px; font-family: var(--font-mono); }

.workspace-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 20px;
  flex: 1;
  min-height: 0;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.panel-head h3 {
  font-family: var(--font-display);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin: 0;
}

/* ---------- Contacts (manifest lines) ---------- */

.contacts-table { flex: 1; overflow-y: auto; display: flex; flex-direction: column; margin: -4px; padding: 4px; }

.contact-row {
  display: grid;
  grid-template-columns: 22px 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 9px 6px;
  border-bottom: 1px dashed var(--border);
  font-size: 13px;
}
.contact-row:last-child { border-bottom: none; }

.contact-row input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--accent);
}

.contact-name { font-weight: 500; }
.contact-phone { font-family: var(--font-mono); color: var(--text-dim); font-size: 12px; }

.contact-remove {
  background: none; border: none; color: var(--text-faint);
  font-size: 13px; padding: 2px 6px;
}
.contact-remove:hover { color: var(--danger); }

.add-contact-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.add-contact-form input {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 13px;
}
.add-contact-form input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* ---------- Compose ---------- */

.compose-panel { }
.char-count { font-size: 11px; color: var(--text-faint); font-family: var(--font-mono); }

#messageBox {
  flex: 1;
  resize: none;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 14px;
  font-size: 14px;
  line-height: 1.5;
  min-height: 160px;
}
#messageBox:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.compose-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
}
.selected-tally { font-size: 12px; color: var(--text-dim); }
.selected-tally strong { color: var(--accent); font-family: var(--font-mono); }

/* ---------- Overlays / modals ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 14, 0.72);
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.overlay[hidden] { display: none; }
.overlay:not([hidden]) { display: flex; 
}

.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  width: 380px;
}
.modal h3 { font-family: var(--font-display); margin: 0 0 16px; font-size: 16px; }
.modal-row { display: flex; gap: 8px; margin-bottom: 8px; }
.emoji-input { width: 60px; text-align: center; }
.modal input {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  flex: 1;
}
.modal input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.field-label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
.field-hint { font-size: 11px; color: var(--text-faint); margin: 8px 0 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ---------- Dispatch overlay (boarding-pass ticket stack) ---------- */

.dispatch-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 480px;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  padding: 24px;
}

.dispatch-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}
.dispatch-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin-bottom: 4px;
}
.dispatch-head h2 { font-family: var(--font-display); margin: 0; font-size: 19px; }

.dispatch-progress {
  height: 5px;
  background: var(--panel-alt);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}
.dispatch-progress-bar {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.25s ease;
}
.dispatch-progress-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  margin-bottom: 16px;
}

.ticket-stack {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 2px;
}

.ticket {
  position: relative;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: grid;
  grid-template-columns: 1fr 132px;
  align-items: center;
  overflow: hidden;
}

.ticket.dispatched { opacity: 0.45; }

.ticket-info { padding: 14px 16px; }
.ticket-seq {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-faint);
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}
.ticket-name { font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.ticket-phone { font-family: var(--font-mono); font-size: 12px; color: var(--text-dim); }

.ticket-action {
  border-left: 1px dashed var(--border);
  padding: 14px;
  display: flex;
  align-items: center;
}

.ticket-btn {
  background: var(--accent);
  color: #1a0f06;
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.ticket-btn:hover { background: #ff8a42; }

.ticket-done {
  color: var(--success);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-mono);
  padding: 0 6px;
}

/* perforation notches: sit on the tear line between info and action columns */
.ticket::before, .ticket::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 50%;
  left: calc(100% - 132px);
  transform: translateX(-50%);
}
.ticket::before { top: 0; transform: translate(-50%, -50%); }
.ticket::after { top: 100%; transform: translate(-50%, -50%); }

@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .workspace-grid { grid-template-columns: 1fr; }
}
