:root {
  --bg: #12201c;
  --bg-2: #183028;
  --panel: rgba(236, 244, 238, 0.04);
  --panel-border: rgba(214, 232, 220, 0.12);
  --text: #e8f2eb;
  --muted: #9bb5a6;
  --accent: #d4a35c;
  --accent-2: #3fbf8f;
  --danger: #e36b5d;
  --warn: #d9b45c;
  --ok: #4ecb96;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  --radius: 18px;
  --font: "Sora", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(212, 163, 92, 0.16), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(63, 191, 143, 0.14), transparent 50%),
    linear-gradient(160deg, #0e1815 0%, var(--bg) 45%, #1a2d26 100%);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: 0.9em; color: #d7e8dc; }

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

.rail {
  padding: 1.4rem 1rem 1rem;
  border-right: 1px solid var(--panel-border);
  background: rgba(8, 16, 13, 0.45);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; gap: 0.8rem; align-items: center; padding: 0.4rem; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--accent), #b9782f);
  color: #1a1208; font-weight: 700; letter-spacing: 0.04em;
}
.brand-mark.lg { width: 56px; height: 56px; border-radius: 16px; margin-bottom: 0.8rem; }
.brand-name { font-weight: 650; letter-spacing: -0.02em; }
.brand-sub { color: var(--muted); font-size: 0.75rem; }

.platform-pill {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.55rem 0.8rem; border-radius: 999px;
  border: 1px solid var(--panel-border); color: var(--muted); font-size: 0.82rem;
}
.platform-pill .dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent-2);
  box-shadow: 0 0 0 4px rgba(63, 191, 143, 0.18);
}
.platform-calendly .dot { background: var(--accent); box-shadow: 0 0 0 4px rgba(212, 163, 92, 0.2); }

.clock-card {
  padding: 0.85rem 0.9rem;
  border-radius: 14px;
  border: 1px solid var(--panel-border);
  background: linear-gradient(160deg, rgba(212, 163, 92, 0.12), rgba(63, 191, 143, 0.08));
}
.clock-label {
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.35rem;
}
.clock-time {
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
}
.clock-zone {
  margin-top: 0.35rem;
  color: var(--accent);
  font-size: 0.72rem;
}

.timezone-field { margin-top: 0.85rem; display: grid; gap: 0.35rem; color: var(--muted); font-size: 0.86rem; }
.timezone-field select { max-width: 100%; }

.rail nav { display: flex; flex-direction: column; gap: 0.25rem; }
.rail nav a {
  color: var(--muted);
  padding: 0.7rem 0.85rem;
  border-radius: 12px;
  text-decoration: none;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}
.rail nav a:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.rail nav a.active {
  color: #102018;
  background: linear-gradient(120deg, #d9b56a, #3fbf8f);
  font-weight: 600;
}

.rail-foot { margin-top: auto; display: grid; gap: 0.4rem; }
.ghost {
  width: 100%;
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--muted);
  border-radius: 12px;
  padding: 0.65rem 0.8rem;
  cursor: pointer;
  font: inherit;
}
.ghost:hover { color: var(--text); border-color: rgba(255,255,255,0.25); }

.main { padding: 1.6rem 1.8rem 2.5rem; max-width: 1280px; }

.page-head {
  display: flex; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap;
  margin-bottom: 1.4rem;
  animation: rise 420ms ease both;
}
.eyebrow { margin: 0 0 0.35rem; color: var(--accent); text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.72rem; }
.page-head h1 { margin: 0; font-size: clamp(1.6rem, 2.4vw, 2.2rem); letter-spacing: -0.03em; }
.lede { margin: 0.45rem 0 0; color: var(--muted); max-width: 52ch; }
.head-meta {
  display: grid; gap: 0.45rem; align-content: start;
  padding: 0.9rem 1rem; border-radius: 14px; background: var(--panel); border: 1px solid var(--panel-border);
  color: var(--muted); font-size: 0.86rem;
}
.head-meta strong { color: var(--text); font-weight: 600; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.8rem;
  margin-bottom: 1.2rem;
}
.stat {
  padding: 1rem;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  animation: rise 500ms ease both;
}
.stat span { display: block; color: var(--muted); font-size: 0.78rem; margin-bottom: 0.45rem; }
.stat strong { font-size: 1.55rem; letter-spacing: -0.03em; }
.bad-text { color: var(--danger); }

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem 1.15rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
  animation: rise 560ms ease both;
}
.panel-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
  margin-bottom: 0.8rem;
}
.panel-head h2 { margin: 0; font-size: 1.05rem; }

.split {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 1rem;
}

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.75rem 0.55rem; border-bottom: 1px solid rgba(255,255,255,0.06); vertical-align: top; }
th { color: var(--muted); font-size: 0.75rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.small { font-size: 0.8rem; }
.empty { color: var(--muted); padding: 1rem 0.2rem; }

.tag, .badge, .chip {
  display: inline-flex; align-items: center;
  border-radius: 999px; padding: 0.18rem 0.55rem;
  font-size: 0.72rem; border: 1px solid transparent;
}
.tag { background: rgba(255,255,255,0.06); color: var(--muted); }
.badge.ok, .chip.ok { background: rgba(78, 203, 150, 0.14); color: var(--ok); }
.badge.bad { background: rgba(227, 107, 93, 0.16); color: #ffb1a7; }
.badge.warn, .chip.warn { background: rgba(217, 180, 92, 0.16); color: #f0d48a; }
.badge.muted, .chip.muted { background: rgba(255,255,255,0.05); color: var(--muted); }
.pipe { display: flex; gap: 0.3rem; flex-wrap: wrap; }

.feed, .timeline, .steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; }
.feed li, .timeline li {
  display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start;
  padding-bottom: 0.75rem; border-bottom: 1px solid rgba(255,255,255,0.06);
}
.feed .right { text-align: right; }
.timeline.dense li { align-items: flex-start; }
.timeline .meta, .steps .muted { font-size: 0.8rem; color: var(--muted); margin-top: 0.2rem; }
.timeline p, .steps p { margin: 0.35rem 0 0; color: #d7e7dc; font-size: 0.92rem; }

.steps li { display: grid; grid-template-columns: 18px 1fr; gap: 0.75rem; position: relative; }
.step-dot {
  width: 12px; height: 12px; border-radius: 50%; margin-top: 0.35rem;
  background: var(--muted);
  box-shadow: 0 0 0 4px rgba(255,255,255,0.04);
}
.step-dot.ok { background: var(--ok); }
.step-dot.bad { background: var(--danger); }
.step-dot.warn { background: var(--warn); }

.thread { display: grid; gap: 0.7rem; max-height: 480px; overflow: auto; padding-right: 0.25rem; }
.thread.tall { max-height: 70vh; }
.bubble {
  max-width: 92%;
  padding: 0.8rem 0.9rem;
  border-radius: 16px;
  border: 1px solid var(--panel-border);
  background: rgba(255,255,255,0.04);
}
.bubble.outbound { justify-self: end; background: rgba(63, 191, 143, 0.12); border-color: rgba(63, 191, 143, 0.25); }
.bubble.inbound { justify-self: start; background: rgba(212, 163, 92, 0.1); border-color: rgba(212, 163, 92, 0.22); }
.bubble.status-failed { border-color: rgba(227, 107, 93, 0.45); }
.bubble-meta { color: var(--muted); font-size: 0.75rem; margin-bottom: 0.35rem; display: flex; gap: 0.35rem; flex-wrap: wrap; align-items: center; }
.bubble-body { white-space: pre-wrap; line-height: 1.45; }
.bubble-error { margin-top: 0.4rem; color: #ffb1a7; font-size: 0.8rem; }

.filters {
  display: flex; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 1rem;
}
input, select, textarea, button {
  font: inherit;
}
input, select, textarea {
  width: 100%;
  background: rgba(0,0,0,0.22);
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
}
.filters input, .filters select { width: auto; min-width: 180px; }
button, .filters button {
  background: linear-gradient(120deg, #d4a35c, #c6862f);
  color: #1a1208;
  border: 0;
  border-radius: 12px;
  padding: 0.7rem 1rem;
  font-weight: 650;
  cursor: pointer;
}
button:hover { filter: brightness(1.05); }
button.danger { background: linear-gradient(120deg, #e36b5d, #b9483c); color: #fff; }
.danger-text { color: #ffb1a7 !important; border-color: rgba(227,107,93,0.35) !important; }

.form-grid { display: grid; gap: 0.85rem; }
.form-grid label, .settings-form label { display: grid; gap: 0.35rem; color: var(--muted); font-size: 0.86rem; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 0.85rem; }
.row-actions { display: flex; gap: 0.8rem; align-items: center; justify-content: space-between; }
.check { display: inline-flex !important; align-items: center; gap: 0.5rem; grid-template-columns: none !important; color: var(--text) !important; }
.check input { width: auto; }
.hint { color: var(--muted); font-size: 0.82rem; margin: 0; }
.danger-form { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid rgba(255,255,255,0.06); }

fieldset {
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 0.9rem 1rem 1rem;
  margin: 0;
}
legend { padding: 0 0.35rem; color: var(--text); font-weight: 600; }
.platform-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.platform-switch label {
  display: flex; align-items: center; gap: 0.55rem;
  padding: 0.85rem 0.9rem; border-radius: 12px;
  border: 1px solid var(--panel-border); background: rgba(0,0,0,0.18);
  color: var(--text) !important;
}
.platform-switch label.on {
  border-color: rgba(63, 191, 143, 0.5);
  background: rgba(63, 191, 143, 0.12);
}
.platform-switch input { width: auto; }

.tabs { display: flex; gap: 0.45rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tabs a {
  padding: 0.55rem 0.85rem; border-radius: 999px;
  border: 1px solid var(--panel-border); color: var(--muted); text-decoration: none;
}
.tabs a.active { color: #102018; background: linear-gradient(120deg, #d9b56a, #3fbf8f); border-color: transparent; font-weight: 600; }

.template-card { margin-bottom: 0.35rem; }
.template-card textarea { margin-bottom: 0.55rem; }
.inline-danger { margin: 0 0 1.1rem; }

.kv { display: grid; gap: 0.7rem; margin: 0; }
.kv > div {
  display: grid; grid-template-columns: 180px 1fr; gap: 0.8rem;
  padding-bottom: 0.7rem; border-bottom: 1px solid rgba(255,255,255,0.06);
}
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.flash {
  margin-bottom: 1rem; padding: 0.8rem 1rem; border-radius: 12px;
  border: 1px solid var(--panel-border);
  animation: rise 280ms ease both;
}
.flash-ok { background: rgba(78, 203, 150, 0.12); color: #b9f0d4; }
.flash-bad { background: rgba(227, 107, 93, 0.14); color: #ffc2ba; }

.login-body {
  min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
}
.login-panel {
  width: min(420px, 100%);
  padding: 1.6rem;
  border-radius: 22px;
  background: rgba(18, 32, 28, 0.88);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  display: grid; gap: 0.8rem;
}
.login-panel h1 { margin: 0; }
.login-panel p { margin: 0; color: var(--muted); }
.clamp { max-width: 360px; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .split, .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .rail {
    position: static; height: auto;
    border-right: 0; border-bottom: 1px solid var(--panel-border);
  }
  .rail nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .main { padding: 1.1rem; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kv > div { grid-template-columns: 1fr; gap: 0.2rem; }
}
