:root {
  color-scheme: light;
  --bg: #f6f7f8;
  --panel: #ffffff;
  --panel-2: #f0f2f4;
  --ink: #171717;
  --muted: #667085;
  --line: #d8dde3;
  --line-strong: #aab2bd;
  --blue: #2563eb;
  --red: #c2410c;
  --red-bg: #fff2ed;
  --amber: #b45309;
  --amber-bg: #fff7e6;
  --green: #047857;
  --green-bg: #eefbf5;
  --violet: #6d28d9;
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 56px 1fr;
  min-height: 100vh;
}

.rail {
  border-right: 1px solid var(--line);
  background: #111827;
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 6px;
  gap: 8px;
}

.rail-item {
  position: relative;
  width: 40px;
  height: 40px;
  border: 1px solid #253044;
  border-radius: var(--radius);
  background: #172033;
  color: #dbe4ef;
  font-weight: 700;
}

.rail-item.is-active {
  background: #f8fafc;
  color: #0f172a;
  border-color: #f8fafc;
}

.badge-dot {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--red);
  color: white;
  font-size: 10px;
  line-height: 18px;
}

.rail-spacer {
  flex: 1;
}

.env-pill {
  width: 44px;
  border: 1px solid #344256;
  border-radius: 999px;
  text-align: center;
  font-size: 10px;
  padding: 4px 0;
  color: #a7f3d0;
}

.workspace {
  min-width: 0;
  display: grid;
  grid-template-rows: 48px 1fr;
}

.topbar {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  padding: 0 14px;
}

.breadcrumb {
  font-weight: 700;
}

.top-meta,
.muted {
  color: var(--muted);
  font-size: 12px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search,
.input,
.textarea,
.select {
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  padding: 7px 9px;
  min-height: 32px;
}

.search {
  width: 240px;
}

.textarea {
  width: 100%;
  min-height: 92px;
  resize: vertical;
  line-height: 1.45;
}

.primary-button,
.ghost-button,
.danger-button,
.ok-button {
  min-height: 32px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 0 10px;
  font-weight: 650;
}

.primary-button {
  background: var(--blue);
  color: #fff;
}

.ghost-button {
  background: #fff;
  color: var(--ink);
  border-color: var(--line-strong);
}

.danger-button {
  background: var(--red-bg);
  color: var(--red);
  border-color: #ffcbb9;
}

.ok-button {
  background: var(--green-bg);
  color: var(--green);
  border-color: #a7f3d0;
}

.view-grid {
  display: grid;
  grid-template-columns: minmax(360px, 440px) 1fr;
  min-height: calc(100vh - 48px);
}

.list-pane {
  border-right: 1px solid var(--line);
  background: var(--panel);
  min-width: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr;
}

.detail-pane {
  min-width: 0;
  overflow: auto;
  background: var(--bg);
}

.filterbar {
  display: flex;
  gap: 8px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 8px;
  background: var(--panel);
}

.rows {
  overflow: auto;
}

.row {
  min-height: 42px;
  border-bottom: 1px solid var(--line);
  padding: 6px 9px;
  display: grid;
  gap: 2px;
}

.row:hover,
.row.is-selected {
  background: #edf4ff;
}

.row-main,
.row-sub {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.row-title {
  font-weight: 700;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.row-text {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--muted);
}

.mono,
.id {
  font-family: "JetBrains Mono", "Cascadia Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
}

.id {
  color: var(--muted);
  font-size: 11px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #94a3b8;
  flex: 0 0 auto;
}

.dot.red {
  background: var(--red);
}

.dot.amber {
  background: var(--amber);
}

.dot.green {
  background: var(--green);
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: white;
  padding: 0 7px;
  color: #344054;
  font-size: 11px;
  white-space: nowrap;
}

.chip.red {
  color: var(--red);
  background: var(--red-bg);
  border-color: #ffcbb9;
}

.chip.amber {
  color: var(--amber);
  background: var(--amber-bg);
  border-color: #fed7aa;
}

.chip.green {
  color: var(--green);
  background: var(--green-bg);
  border-color: #a7f3d0;
}

.lead-header {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(6px);
}

.lead-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(420px, 1.35fr) minmax(320px, 0.9fr);
  gap: 12px;
  padding: 12px;
}

.section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  margin-bottom: 12px;
}

.section-head {
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding: 0 10px;
  font-weight: 700;
}

.section-body {
  padding: 10px;
}

.timeline {
  display: grid;
  gap: 8px;
}

.message {
  border-left: 3px solid #94a3b8;
  background: #fff;
  border-radius: 0 6px 6px 0;
  border-top: 1px solid var(--line);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 8px 9px;
}

.message.customer {
  border-left-color: var(--blue);
}

.message.ai {
  border-left-color: var(--violet);
}

.message.human {
  border-left-color: var(--green);
}

.message.system {
  border-left-color: var(--amber);
}

.message-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 5px;
}

.message-text {
  white-space: pre-wrap;
  line-height: 1.42;
}

.composer {
  display: grid;
  gap: 8px;
}

.kv {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 6px;
  align-items: start;
  margin-bottom: 6px;
}

.kv-label {
  color: var(--muted);
}

.json-box {
  background: #111827;
  color: #e5e7eb;
  padding: 10px;
  border-radius: 6px;
  overflow: auto;
  max-height: 340px;
  font-size: 11px;
}

.split-page {
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(360px, 460px) 1fr;
  gap: 12px;
  min-height: calc(100vh - 48px);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  padding: 10px;
}

.metric-value {
  font-size: 22px;
  font-weight: 800;
}

.bar-row {
  display: grid;
  grid-template-columns: 160px 1fr 48px;
  align-items: center;
  gap: 8px;
  margin: 7px 0;
}

.bar {
  height: 10px;
  border-radius: 999px;
  background: #dbeafe;
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  background: var(--blue);
}

.empty {
  padding: 32px;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 980px) {
  .view-grid,
  .split-page,
  .detail-layout {
    grid-template-columns: 1fr;
  }

  .list-pane {
    min-height: 320px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .search {
    width: 150px;
  }

  .metric-strip {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }
}

