:root {
  --bg: #f3eee6;
  --paper: #fffdf8;
  --ink: #1c1612;
  --muted: #6d6258;
  --line: #e2d6c8;
  --red: #b42318;
  --red-deep: #8c1c14;
  --green: #2f6b4f;
  --amber: #9a6b12;
  --shadow: 0 18px 40px rgba(28, 22, 18, 0.06);
  --sans: "IBM Plex Sans", sans-serif;
  --serif: "Fraunces", serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: #1c1612;
  color: #f6efe6;
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.brand { font-family: var(--serif); font-size: 1.15rem; letter-spacing: -0.03em; }
.brand span { color: #f0a39c; }
.nav { display: flex; flex-direction: column; gap: 8px; }
.nav a {
  color: #d8cfc4;
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 8px;
}
.nav a:hover, .nav a.active { background: #2a231e; color: #fff; text-decoration: none; }
.nav-label {
  color: #7d7368;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 12px 10px 4px;
}
.nav a.locked { color: #8a8076; }
.nav a.locked span {
  font-size: 0.68rem;
  margin-left: 6px;
  color: #b42318;
  opacity: 0.85;
}
.nav-sub {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: -4px 0 8px 12px;
  padding: 4px 0 4px 10px;
  border-left: 1px solid #3a322c;
}
.nav-sub a {
  font-size: 0.88rem;
  padding: 6px 10px;
  color: #c4bbb0;
}
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 16px 18px;
}
.stat-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.stat-number {
  font-family: var(--serif);
  font-size: 2.2rem;
  letter-spacing: -0.04em;
  line-height: 1.1;
  margin: 6px 0 4px;
}
.stat-phone {
  font-family: var(--serif);
  font-size: 1.35rem;
  letter-spacing: -0.03em;
  margin: 8px 0 4px;
}
.pill.test { background: #efe6da; color: #4d433b; }
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.tool-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  min-height: 170px;
}
.tool-card:hover { text-decoration: none; border-color: #c9b7a6; }
.tool-card.off { opacity: 0.92; }
.tool-card-top { display: flex; justify-content: space-between; gap: 8px; align-items: start; }
.tool-card-foot { margin-top: auto; font-size: 0.85rem; color: var(--red); }

.main { padding: 32px 36px 48px; }
.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 24px;
}
h1, h2, h3 { font-family: var(--serif); letter-spacing: -0.03em; margin: 0 0 8px; }
.sub { color: var(--muted); margin: 0; }

.btn, button, input[type="submit"] {
  font: inherit;
  border: 0;
  background: var(--red);
  color: white;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
}
.btn.secondary, button.secondary { background: #2a231e; }
.btn.ghost, button.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: var(--red-deep); }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 20px;
}

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
tr:hover td { background: #faf6f0; }

.pill {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #efe6da;
  color: #4d433b;
}
.pill.active { background: #e8f3ec; color: var(--green); }
.pill.replied { background: #e8eefc; color: #2a4a9a; }
.pill.booked { background: #e7f6ee; color: var(--green); }
.pill.paused, .pill.completed { background: #f3eee6; color: var(--muted); }
.pill.unsubscribed, .pill.failed, .pill.cancelled { background: #fde8e6; color: var(--red); }
.pill.texted, .pill.answered { background: #e7f6ee; color: var(--green); }
.pill.missed { background: #fff4d6; color: #8a6a12; }
.pill.opted_out { background: #fde8e6; color: var(--red); }
.book-step { margin-top: 20px; }
.book-step h2 { font-size: 1rem; margin: 0 0 8px; }
.book-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.book-chip {
  display: inline-block;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.9rem;
}
.book-chip.on { background: var(--red); color: #fff; border-color: var(--red); }
.book-chip.off { opacity: 0.45; pointer-events: none; }
.book-public {
  min-height: 100vh;
  background: #f3eee6;
  margin: 0;
}
.book-banner { width: 100%; height: 280px; overflow: hidden; background: #ddd; }
.book-banner img { width: 100%; height: 100%; object-fit: cover; display: block; }
.book-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 40px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.book-brand { display: flex; align-items: center; gap: 12px; font-size: 1.05rem; }
.book-brand img { height: 36px; width: auto; max-width: 180px; object-fit: contain; }
.book-home {
  color: var(--book, var(--red));
  font-weight: 500;
  white-space: nowrap;
}
.book-wrap {
  width: min(1120px, calc(100% - 48px));
  margin: -56px auto 72px;
}
.book-card {
  width: 100%;
  padding: 40px 44px 48px;
  border-radius: 20px;
}
.book-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 56px;
  align-items: start;
}
.book-kicker {
  margin: 0 0 8px;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.book-aside h1 { margin: 0 0 8px; font-size: 2.4rem; }
.book-choices { display: grid; gap: 8px; }
.book-choice {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
}
.book-choice span { color: var(--muted); font-size: 0.88rem; }
.book-choice.on {
  background: var(--book, var(--red));
  border-color: var(--book, var(--red));
  color: #fff;
}
.book-choice.on span { color: rgba(255,255,255,0.8); }
.book-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}
.book-day {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 12px 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
}
.book-day .dow,
.book-day .mon { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.book-day .num { font-size: 1.15rem; font-weight: 600; }
.book-day.on {
  background: var(--book, var(--red));
  border-color: var(--book, var(--red));
  color: #fff;
}
.book-day.on .dow,
.book-day.on .mon { color: rgba(255,255,255,0.8); }
.book-day.off { opacity: 0.35; pointer-events: none; }
.book-times {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 8px;
}
.book-time {
  display: grid;
  place-items: center;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.92rem;
}
.book-time.off {
  opacity: 0.38;
  pointer-events: none;
  text-decoration: line-through;
  color: var(--muted);
}
.book-time.on {
  background: var(--book, var(--red));
  border-color: var(--book, var(--red));
  color: #fff;
}
.book-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
  max-width: none;
}
.book-form label:first-of-type,
.book-form button { grid-column: 1 / -1; }
.book-public button[type="submit"] {
  background: var(--book, var(--red));
  border-color: var(--book, var(--red));
  color: #fff;
  justify-self: start;
  padding: 12px 22px;
}
.book-done { max-width: 520px; }
.book-done h1 { margin: 0 0 8px; }
.banner-preview img { width: min(420px, 100%); height: 90px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
@media (max-width: 860px) {
  .book-banner { height: 160px; }
  .book-bar { padding: 12px 16px; }
  .book-wrap { width: calc(100% - 24px); margin-top: -28px; }
  .book-card { padding: 22px 18px 28px; }
  .book-layout { grid-template-columns: 1fr; gap: 8px; }
  .book-aside h1 { font-size: 1.8rem; }
  .book-days { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .book-form { grid-template-columns: 1fr; }
  .book-form label:first-of-type,
  .book-form button { grid-column: auto; }
}

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filters a {
  color: var(--muted);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
}
.filters a.on { border-color: var(--line); background: var(--paper); color: var(--ink); }

form.stack { display: grid; gap: 12px; max-width: 720px; }
label { display: grid; gap: 6px; font-size: 0.9rem; color: #3d342d; }
input, textarea, select {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
}
input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-width: 18px;
  padding: 0;
  accent-color: var(--red);
  cursor: pointer;
}
.check-row {
  display: flex !important;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
}
textarea { min-height: 120px; resize: vertical; }
.flash { background: #fff4d6; border: 1px solid #ead7a0; padding: 10px 12px; border-radius: 8px; margin-bottom: 16px; }

.thread { display: grid; gap: 12px; }
.bubble {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  background: #fff;
}
.bubble.in { background: #f7f1e8; }
.bubble.out { background: #fff; }
.bubble .who { font-size: 0.78rem; color: var(--muted); margin-bottom: 6px; }
.bubble pre { white-space: pre-wrap; font-family: inherit; margin: 0; }

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card { width: min(420px, 100%); }
.code {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.82rem;
  background: #1c1612;
  color: #f6efe6;
  padding: 16px;
  border-radius: 12px;
  overflow: auto;
  white-space: pre-wrap;
}
.color-row { display: flex; align-items: center; gap: 10px; }
.color-row input[type="color"] { width: 48px; height: 40px; padding: 4px; cursor: pointer; }
.color-row input[type="text"] { max-width: 120px; }
.icon-preview { display: flex; align-items: center; gap: 12px; }
.icon-preview img { width: 48px; height: 48px; object-fit: contain; border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 6px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; flex-wrap: wrap; }
  .grid-2 { grid-template-columns: 1fr; }
}