:root {
  --ink: #08110e;
  --moss: #12211c;
  --leaf: #1b3229;
  --line: #2a463b;
  --mint: #3ddc97;
  --lime: #c4f542;
  --paper: #e7f5ee;
  --mute: #8eaa9c;
  --danger: #e25c5c;
  --warn: #f5c542;
  --font: "Figtree", system-ui, sans-serif;
  --display: "Syne", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  background: var(--ink);
  color: var(--paper);
  line-height: 1.45;
}
a { color: var(--mint); text-decoration: none; }
h1, h2, .word, .hero-title { font-family: var(--display); letter-spacing: -0.03em; }

.public-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
}
.public-story {
  padding: 56px 64px;
  background:
    radial-gradient(900px 400px at -10% -20%, rgba(61, 220, 151, 0.18), transparent 55%),
    linear-gradient(160deg, #0b1713, #08110e 60%);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.brand-row { display: flex; align-items: center; gap: 12px; }
.mark {
  width: 36px; height: 36px; border-radius: 11px;
  background: var(--lime); color: #08110e;
  display: grid; place-items: center;
  font-family: var(--display); font-weight: 800; font-size: 13px;
}
.word { font-size: 22px; }
.hero-title { font-size: clamp(2.4rem, 4vw, 4.2rem); line-height: 0.95; margin: 48px 0 16px; max-width: 11ch; }
.lede { color: var(--mute); font-size: 1.05rem; max-width: 38ch; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 28px; }
.chip { border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; color: var(--mute); font-size: 13px; }
.chip.on { border-color: var(--mint); color: var(--paper); background: var(--leaf); }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.chip-row a.chip { color: inherit; }
[hidden] { display: none !important; }
.bulk-bar {
  position: sticky; top: 8px; z-index: 5;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--leaf); border: 1px solid var(--mint); border-radius: 14px;
  padding: 10px 14px; margin: 8px 0 12px;
}
.bulk-compose textarea { min-height: 140px; }

.public-form {
  display: grid;
  place-items: center;
  padding: 40px 24px;
}
.card {
  width: min(420px, 100%);
  background: var(--moss);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 28px;
}
.card h2 { margin: 0 0 6px; font-size: 1.6rem; }
.hint { color: var(--mute); margin: 0 0 22px; }
label { display: block; font-size: 13px; color: var(--mute); margin: 12px 0 6px; }
input, textarea, select {
  width: 100%;
  background: var(--ink);
  border: 1px solid var(--line);
  color: var(--paper);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
}
textarea { min-height: 88px; resize: vertical; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 999px; padding: 12px 18px; font: 600 15px var(--font);
  cursor: pointer; background: var(--lime); color: #08110e;
}
.btn.wide { width: 100%; margin-top: 18px; }
.btn.ghost { background: transparent; color: var(--paper); border: 1px solid var(--line); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.small { padding: 7px 12px; font-size: 12px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.order-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.order-actions form { margin: 0; }
.muted { color: var(--mute); font-size: 14px; }
.center { text-align: center; margin-top: 16px; }

.app-shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sider {
  background: var(--moss);
  border-right: 1px solid var(--line);
  padding: 22px 16px;
  display: flex; flex-direction: column; gap: 28px;
}
.sider .brand { display: flex; align-items: center; gap: 10px; color: var(--paper); }
.sider nav { display: grid; gap: 4px; }
.sider nav a {
  color: var(--mute); padding: 10px 12px; border-radius: 10px;
}
.sider nav a.on, .sider nav a:hover { background: var(--leaf); color: var(--paper); }
.sider-foot { margin-top: auto; }
.who strong { display: block; }
.who span { color: var(--mute); font-size: 12px; }
.out { display: inline-block; margin-top: 10px; color: var(--mute); font-size: 13px; }

.stage { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.stage-top {
  padding: 22px 28px 0;
  border-bottom: 1px solid transparent;
  flex-shrink: 0;
}
.stage-top h1 { margin: 0; font-size: 1.7rem; }
.stage-body { padding: 22px 28px 48px; flex: 1; min-height: 0; }

body.page-inbox { height: 100dvh; overflow: hidden; }
.page-inbox .app-shell { height: 100%; min-height: 0; overflow: hidden; }
.page-inbox .stage { min-height: 0; max-height: none; overflow: hidden; flex: 1; }
.page-inbox .stage-body {
  padding: 12px 20px 16px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.inbox-toolbar {
  position: relative;
  z-index: 8;
  flex-shrink: 0;
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
  overflow: visible;
}
.inbox-open label { margin-top: 0; }
.page-inbox .bulk-bar,
.page-inbox .bulk-compose { flex-shrink: 0; }
.inbox-open-row { display: flex; gap: 8px; align-items: center; }
.typeahead { position: relative; flex: 1; max-width: 480px; }
.typeahead input[data-typeahead-q] { width: 100%; margin: 0; }
.typeahead-list {
  position: absolute;
  left: 0; right: 0; top: calc(100% + 4px);
  max-height: 280px;
  overflow-y: auto;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--moss);
  border: 1px solid var(--line);
  border-radius: 12px;
  z-index: 30;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.4);
}
.typeahead-list li { margin: 0; }
.typeahead-opt {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: var(--paper);
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
}
.typeahead-opt:hover,
.typeahead-opt.is-on { background: var(--leaf); }
.typeahead-opt strong { display: block; font-size: 14px; }
.typeahead-opt small { display: block; color: var(--mute); font-size: 12px; margin-top: 2px; }
.typeahead-empty { padding: 10px 12px; color: var(--mute); font-size: 13px; }

.inbox {
  display: grid;
  grid-template-columns: 300px 1fr;
  flex: 1;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
}
.thread-list { background: var(--moss); border-right: 1px solid var(--line); overflow-y: auto; min-height: 0; }
.thread-master {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; margin: 0; color: var(--mute); font-size: 12px;
  border-bottom: 1px solid var(--line);
}
.thread-master input { width: auto; }
.thread-row {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.thread-row.on { background: var(--leaf); }
.thread-row input.row-check { width: auto; margin: 0; }
.thread-row a { display: block; color: var(--paper); min-width: 0; padding: 0; border: 0; }
.thread-row a strong { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-row a small { display: block; color: var(--mute); font-size: 12px; margin-top: 2px; }
.thread-count {
  min-width: 22px; height: 22px; border-radius: 999px;
  background: var(--lime); color: #08110e;
  font-size: 11px; font-weight: 700;
  display: grid; place-items: center; padding: 0 6px;
}
.chat { display: flex; flex-direction: column; background: #0c1713; min-height: 0; min-width: 0; }
.chat-head {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--moss);
}
.chat-head strong { display: block; }
.chat-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.msg { max-width: 70%; padding: 10px 12px; border-radius: 14px; word-break: break-word; }
.msg.agent { margin-left: auto; background: var(--mint); color: #08110e; }
.msg.customer { background: var(--leaf); }
.msg time { color: var(--mute); font-size: 11px; }
.composer {
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: var(--moss);
}
.composer textarea { min-height: 44px; max-height: 120px; margin: 0; resize: none; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.kpi {
  background: var(--moss); border: 1px solid var(--line); border-radius: 18px; padding: 18px;
  color: inherit; text-decoration: none; display: block;
}
.kpi span { color: var(--mute); font-size: 13px; }
.kpi strong { display: block; font-size: 1.8rem; margin-top: 8px; font-family: var(--display); }

.panel {
  background: var(--moss); border: 1px solid var(--line); border-radius: 18px; padding: 18px; margin-top: 16px;
}
.row { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); font-size: 14px; }
.table th { color: var(--mute); font-weight: 500; }

.empty {
  padding: 48px 20px; text-align: center; color: var(--mute);
}
.empty h3 { color: var(--paper); margin-bottom: 8px; }

.flash { border-radius: 12px; padding: 10px 14px; margin-bottom: 16px; }
.flash-ok { background: rgba(61,220,151,.12); color: var(--mint); }
.flash-err { background: rgba(226,92,92,.12); color: #ffb3b3; }

.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.col { background: var(--moss); border: 1px solid var(--line); border-radius: 16px; min-height: 420px; padding: 12px; display: flex; flex-direction: column; }
.col-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.col h3 { margin: 0; font-size: 14px; }
.col-count { font-size: 11px; color: var(--mute); background: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; }
.col-empty { flex: 1; display: grid; place-items: center; text-align: center; color: var(--mute); font-size: 13px; line-height: 1.45; border: 1px dashed var(--line); border-radius: 12px; padding: 28px 14px; }
.deal { background: var(--ink); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.deal b { display: block; }
.deal em { color: var(--lime); font-style: normal; font-size: 13px; }
.deal-who { display: block; color: var(--mute); font-size: 12px; margin-top: 6px; }
.pipe-lede { color: var(--mute); font-size: 14px; max-width: 62ch; margin: 0 0 4px; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.box-note {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  margin: 12px 0 18px;
  color: var(--mute);
  font-size: 13px;
}
code {
  background: var(--ink);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 12px;
  word-break: break-all;
}

@media (max-width: 900px) {
  .public-wrap, .app-shell, .inbox, .kpis, .split { grid-template-columns: 1fr; }
  .page-inbox .app-shell { grid-template-rows: auto 1fr; }
  .page-inbox .thread-list { max-height: 28vh; }
  .page-inbox .inbox { min-height: 0; }
  .kanban { grid-auto-columns: minmax(200px, 78vw); }
  .public-story { display: none; }
  .sider { flex-direction: row; flex-wrap: wrap; }
  .sider nav { display: flex; overflow: auto; width: 100%; }
  .sider-foot { width: 100%; }
  .bulk-bar { top: auto; bottom: 8px; }
  .inbox-open-row { flex-wrap: wrap; }
  .typeahead { max-width: none; min-width: 0; }
}
