:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #0f172a;
  --ink-2: #475569;
  --ink-3: #94a3b8;
  --line: #e2e8f0;
  --brand: #4f46e5;
  --brand-dark: #4338ca;
  --brand-soft: #eef2ff;
  --ok: #059669;
  --ok-soft: #ecfdf5;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --info: #0284c7;
  --info-soft: #f0f9ff;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 12px rgba(15, 23, 42, .04);
  --sidebar: 236px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app-loading { padding: 64px; text-align: center; color: var(--ink-3); }

a { color: var(--brand); }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 21px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }

/* ------------------------------------------------------------- layout --- */

.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }

.sidebar {
  background: #0f172a;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 9px;
  padding: 0 10px 18px; color: #fff; font-weight: 700; font-size: 15px;
}
.sidebar .brand span.dot {
  width: 26px; height: 26px; border-radius: 7px; background: var(--brand);
  display: grid; place-items: center; font-size: 14px;
}
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
  color: #cbd5e1; text-decoration: none; font-size: 13.5px; font-weight: 500;
}
.sidebar nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.sidebar nav a.active { background: var(--brand); color: #fff; }
.sidebar nav a .count {
  margin-left: auto; background: rgba(255, 255, 255, .16);
  border-radius: 20px; padding: 1px 7px; font-size: 11px; font-weight: 600;
}
.sidebar nav a.active .count { background: rgba(255, 255, 255, .25); }
.sidebar .nav-group {
  padding: 16px 10px 6px; font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .09em; color: #64748b; font-weight: 700;
}
.sidebar .who { margin-top: auto; border-top: 1px solid rgba(255,255,255,.1); padding: 12px 10px 0; }
.sidebar .who .name { color: #fff; font-weight: 600; font-size: 13px; }
.sidebar .who .role { color: #64748b; font-size: 11.5px; text-transform: capitalize; }
.sidebar .who button {
  margin-top: 8px; width: 100%; background: rgba(255,255,255,.08); color: #cbd5e1;
  border: 0; padding: 6px; border-radius: 7px; cursor: pointer; font-size: 12.5px;
}
.sidebar .who button:hover { background: rgba(255,255,255,.15); color: #fff; }

.main { padding: 22px 26px 60px; min-width: 0; }
.page-head {
  display: flex; align-items: flex-start; gap: 16px;
  justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap;
}
.page-head p { margin: 4px 0 0; color: var(--ink-2); font-size: 13px; max-width: 70ch; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* -------------------------------------------------------------- pieces --- */

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-head {
  padding: 13px 16px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-body { padding: 16px; }
.card-body.tight { padding: 0; }

/* `min-width: 0` everywhere a grid nests: without it a wide table inside a
   card forces the column past its track and overlaps the next one. */
.grid { display: grid; gap: 14px; min-width: 0; }
.grid > *, .card { min-width: 0; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.side { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }

.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 650; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 3px; letter-spacing: -.02em; }
.stat .hint { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.stat.alert .value { color: var(--danger); }
.stat.good .value { color: var(--ok); }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-size: 13px; font-weight: 550;
  cursor: pointer; font-family: inherit; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--danger); border-color: #fecaca; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

input, select, textarea {
  width: 100%; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; font-size: 13px; background: var(--surface); color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
textarea { resize: vertical; min-height: 78px; }
label.field { display: block; margin-bottom: 11px; }
label.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
label.field > small { display: block; color: var(--ink-3); font-size: 11.5px; margin-top: 3px; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
.field-row.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters input, .filters select { width: auto; min-width: 140px; }
.filters input[type=search] { min-width: 230px; }

table.data { width: 100%; border-collapse: collapse; }
table.data th {
  text-align: left; padding: 9px 14px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--ink-3); font-weight: 650;
  border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap;
}
table.data td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr.clickable:hover { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }
/* Action buttons in a table cell stay on one line rather than stacking. */
table.data td .row { flex-wrap: nowrap; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px;
  border-radius: 20px; font-size: 11.5px; font-weight: 600; white-space: nowrap;
  background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line);
}
.badge.new, .badge.open, .badge.draft { background: var(--info-soft); color: var(--info); border-color: #bae6fd; }
.badge.assigned, .badge.scheduled, .badge.acknowledged { background: var(--brand-soft); color: var(--brand); border-color: #c7d2fe; }
.badge.in_progress, .badge.quoted, .badge.active { background: var(--warn-soft); color: var(--warn); border-color: #fde68a; }
.badge.won, .badge.done, .badge.resolved, .badge.published, .badge.connected { background: var(--ok-soft); color: var(--ok); border-color: #a7f3d0; }
.badge.lost, .badge.failed, .badge.blocked, .badge.error, .badge.critical { background: var(--danger-soft); color: var(--danger); border-color: #fecaca; }
.badge.urgent { background: var(--danger-soft); color: var(--danger); border-color: #fecaca; }
.badge.high { background: var(--warn-soft); color: var(--warn); border-color: #fde68a; }
.badge.medium { background: var(--info-soft); color: var(--info); border-color: #bae6fd; }
.badge.low { background: var(--surface-2); color: var(--ink-3); }
.badge.closed, .badge.cancelled, .badge.waiting_customer, .badge.paused, .badge.disconnected { background: var(--surface-2); color: var(--ink-2); }

.score { display: inline-flex; align-items: center; gap: 6px; font-weight: 650; font-size: 12.5px; }
.score .bar { width: 42px; height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; }
.score .bar i { display: block; height: 100%; background: var(--brand); }
.score.hot .bar i { background: var(--danger); }
.score.warm .bar i { background: var(--warn); }

.muted { color: var(--ink-3); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 34ch; display: block; }
.stack { display: flex; flex-direction: column; gap: 3px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.empty { padding: 34px 18px; text-align: center; color: var(--ink-3); }
.empty strong { display: block; color: var(--ink-2); margin-bottom: 4px; font-size: 14px; }

/* ------------------------------------------------------------ timeline --- */

.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ''; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.timeline .item { position: relative; padding-bottom: 16px; }
.timeline .item::before {
  content: ''; position: absolute; left: -20px; top: 5px;
  width: 9px; height: 9px; border-radius: 50%; background: var(--ink-3); border: 2px solid var(--surface);
}
.timeline .item.created::before { background: var(--info); }
.timeline .item.assigned::before, .timeline .item.routed::before { background: var(--brand); }
.timeline .item.status_changed::before { background: var(--warn); }
.timeline .item.escalated::before, .timeline .item.sla_breach::before { background: var(--danger); }
.timeline .item.reply_sent::before, .timeline .item.task_completed::before { background: var(--ok); }
.timeline .head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.timeline .type { font-weight: 650; font-size: 12.5px; text-transform: capitalize; }
.timeline .when { font-size: 11.5px; color: var(--ink-3); }
.timeline .body { font-size: 13px; color: var(--ink-2); margin-top: 3px; white-space: pre-wrap; }

/* --------------------------------------------------------------- modal --- */

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  display: grid; place-items: center; padding: 24px; z-index: 50;
}
.modal {
  background: var(--surface); border-radius: 14px; width: min(560px, 100%);
  max-height: 88vh; overflow: auto; box-shadow: 0 24px 48px rgba(15, 23, 42, .25);
}
.modal.wide { width: min(860px, 100%); }
.modal header { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal .content { padding: 18px 20px; }
.modal footer { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; background: var(--surface-2); }
.modal .close { background: none; border: 0; font-size: 20px; cursor: pointer; color: var(--ink-3); line-height: 1; }

/* -------------------------------------------------------------- toasts --- */

.toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast {
  background: var(--ink); color: #fff; padding: 10px 15px; border-radius: 9px;
  font-size: 13px; box-shadow: var(--shadow); max-width: 380px;
  animation: slide-in .18s ease-out;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--ok); }
@keyframes slide-in { from { opacity: 0; transform: translateY(8px); } }

/* --------------------------------------------------------------- login --- */

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #0f172a; }
.login-card { background: var(--surface); border-radius: 14px; padding: 30px; width: min(400px, 100%); box-shadow: 0 24px 48px rgba(0,0,0,.3); }
.login-card .brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 17px; margin-bottom: 4px; }
.login-card .brand .dot { width: 30px; height: 30px; border-radius: 8px; background: var(--brand); display: grid; place-items: center; }
.login-card p.sub { color: var(--ink-2); font-size: 13px; margin: 0 0 20px; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 6px; }
.login-hint { margin-top: 16px; padding: 11px 13px; background: var(--surface-2); border-radius: 9px; font-size: 12px; color: var(--ink-2); border: 1px solid var(--line); }
.login-hint code { font-family: ui-monospace, monospace; color: var(--ink); }

/* --------------------------------------------------------------- setup --- */

.setup-wrap { max-width: 900px; margin: 0 auto; padding: 32px 20px 64px; }
.setup-head { margin-bottom: 20px; }
.setup-head .brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 15px; margin-bottom: 14px; }
.setup-head .brand .dot { width: 26px; height: 26px; border-radius: 7px; background: var(--brand); display: grid; place-items: center; color: #fff; }
.setup-head h1 { font-size: 24px; }
.setup-head p { margin: 5px 0 0; color: var(--ink-2); font-size: 14px; }

.stepper { display: flex; gap: 6px; list-style: none; margin: 20px 0 0; padding: 0; flex-wrap: wrap; }
.stepper li {
  display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 550;
  color: var(--ink-3); padding: 6px 12px 6px 6px; border-radius: 20px; background: var(--surface);
  border: 1px solid var(--line);
}
.stepper li .dot {
  width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center;
  background: var(--line); color: var(--ink-2); font-size: 11px; font-weight: 700;
}
.stepper li.active { color: var(--brand); border-color: var(--brand); background: var(--brand-soft); }
.stepper li.active .dot { background: var(--brand); color: #fff; }
.stepper li.done { color: var(--ok); border-color: #a7f3d0; background: var(--ok-soft); }
.stepper li.done .dot { background: var(--ok); color: #fff; }

.card-foot {
  padding: 14px 16px; border-top: 1px solid var(--line); background: var(--surface-2);
  border-radius: 0 0 var(--radius) var(--radius); display: flex; gap: 8px; justify-content: flex-end;
}

.industry-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 9px; margin-bottom: 16px;
}
.industry-card {
  display: flex; flex-direction: column; gap: 3px; text-align: left; cursor: pointer;
  padding: 12px 13px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); font: inherit; color: inherit;
}
.industry-card:hover { border-color: var(--brand); background: var(--surface-2); }
.industry-card.selected { border-color: var(--brand); background: var(--brand-soft); box-shadow: 0 0 0 1px var(--brand); }
.industry-card strong { font-size: 13.5px; }
.industry-card .small { line-height: 1.4; }

/* Pipeline stage kinds, used in the blueprint preview. */
.badge.working { background: var(--warn-soft); color: var(--warn); border-color: #fde68a; }
.badge.waiting { background: var(--surface-2); color: var(--ink-2); }

/* --------------------------------------------------------------- chart --- */

.chart { display: block; max-width: 100%; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .area { fill: var(--brand); opacity: .12; }
.chart .line { fill: none; stroke: var(--brand); stroke-width: 2; stroke-linejoin: round; }
.chart .line.won { stroke: var(--ok); stroke-dasharray: 4 3; }
.chart .dot { fill: var(--brand); }
.chart text { font-size: 10px; fill: var(--ink-3); }

.bars { display: flex; flex-direction: column; gap: 9px; }
.bars .bar-row { display: grid; grid-template-columns: 110px 1fr 40px; align-items: center; gap: 10px; font-size: 12.5px; }
.bars .track { height: 7px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bars .track i { display: block; height: 100%; background: var(--brand); border-radius: 4px; }
.bars .num { text-align: right; font-weight: 650; }

.tabs { display: flex; gap: 3px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button {
  background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 13px;
  font: inherit; font-size: 13px; font-weight: 550; color: var(--ink-2); cursor: pointer; white-space: nowrap;
}
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }
.tabs button:hover { color: var(--ink); }

.code-block {
  background: #0f172a; color: #e2e8f0; padding: 13px 15px; border-radius: 9px;
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px;
  overflow-x: auto; white-space: pre; line-height: 1.6;
}

.issue { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.issue:last-child { border-bottom: 0; }
.issue .sev { width: 7px; height: 7px; border-radius: 50%; margin-top: 6px; flex: none; background: var(--ink-3); }
.issue.critical .sev { background: var(--danger); }
.issue.warning .sev { background: var(--warn); }
.issue.info .sev { background: var(--info); }
.issue .fix { color: var(--ink-3); font-size: 12px; margin-top: 2px; }

.cond-row { display: grid; grid-template-columns: 1fr 1fr 1.4fr auto; gap: 7px; margin-bottom: 7px; align-items: center; }

@media (max-width: 1080px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.side, .grid.cols-3 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .sidebar nav { flex-direction: row; overflow-x: auto; }
  .sidebar .nav-group, .sidebar .who { display: none; }
  .main { padding: 16px; }
  .grid.cols-2, .grid.cols-4 { grid-template-columns: 1fr; }
  .field-row, .field-row.three { grid-template-columns: 1fr; }
}

/* ================================================================ v2 === */
/* Topbar, board, settings editors, billing — added with the CRM and SaaS
   feature wave. */

.shell { grid-template-columns: var(--sidebar) minmax(0, 1fr); }
.workspace { display: flex; flex-direction: column; min-width: 0; }
.workspace > main { padding: 18px 26px 60px; min-width: 0; }

/* ------------------------------------------------------------ topbar --- */

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 26px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}

.search-wrap { position: relative; flex: 1; max-width: 560px; }
.global-search { padding-left: 12px; }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 40;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, .16); max-height: 60vh; overflow-y: auto;
}
.search-group + .search-group { border-top: 1px solid var(--line); }
.search-group-head {
  padding: 7px 13px 4px; font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .07em; color: var(--ink-3); font-weight: 700;
}
.search-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 13px; text-decoration: none; color: inherit;
}
.search-item:hover { background: var(--surface-2); }
.search-empty { padding: 18px; text-align: center; color: var(--ink-3); font-size: 13px; }

.bell-wrap { position: relative; }
.bell {
  background: none; border: 1px solid var(--line); border-radius: 9px; cursor: pointer;
  padding: 6px 10px; font-size: 15px; position: relative; line-height: 1;
}
.bell:hover { background: var(--surface-2); }
.bell-count {
  position: absolute; top: -5px; right: -5px; background: var(--danger); color: #fff;
  border-radius: 20px; font-size: 10px; font-weight: 700; padding: 1px 5px; line-height: 1.5;
}
.bell-panel {
  position: absolute; top: calc(100% + 8px); right: 0; width: min(360px, 90vw); z-index: 40;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, .16); max-height: 70vh; overflow-y: auto;
}
.bell-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 13px; border-bottom: 1px solid var(--line); font-size: 13px;
}
.bell-item { display: block; padding: 10px 13px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.bell-item:last-child { border-bottom: 0; }
.bell-item:hover { background: var(--surface-2); }
.bell-item.unread { border-left: 3px solid var(--brand); background: var(--brand-soft); }

.plan-pill {
  display: inline-flex; align-items: center; padding: 5px 11px; border-radius: 20px;
  font-size: 12px; font-weight: 600; text-decoration: none; white-space: nowrap;
}
.plan-pill.warn { background: var(--warn-soft); color: var(--warn); border: 1px solid #fde68a; }
.plan-pill.danger { background: var(--danger-soft); color: var(--danger); border: 1px solid #fecaca; }

/* ------------------------------------------------------------- board --- */

.view-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.view-toggle button {
  background: var(--surface); border: 0; padding: 7px 13px; font: inherit; font-size: 13px;
  cursor: pointer; color: var(--ink-2);
}
.view-toggle button.active { background: var(--brand); color: #fff; }
.view-toggle button:not(.active):hover { background: var(--surface-2); }

.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.board-column {
  flex: 0 0 272px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 11px; display: flex; flex-direction: column; max-height: calc(100vh - 230px);
}
.board-column.drag-over { border-color: var(--brand); background: var(--brand-soft); }
.board-head { padding: 11px 13px; border-bottom: 1px solid var(--line); border-top: 3px solid var(--ink-3); border-radius: 11px 11px 0 0; }
.board-head.kind-open { border-top-color: var(--info); }
.board-head.kind-working { border-top-color: var(--warn); }
.board-head.kind-waiting { border-top-color: var(--ink-3); }
.board-head.kind-won { border-top-color: var(--ok); }
.board-head.kind-lost { border-top-color: var(--danger); }
.board-head.kind-closed { border-top-color: var(--ink-3); }
.board-head .count {
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
  padding: 1px 8px; font-size: 11.5px; font-weight: 700;
}
.board-cards { padding: 9px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }
.board-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 9px;
  padding: 10px 11px; cursor: grab; box-shadow: var(--shadow);
}
.board-card:hover { border-color: var(--brand); }
.board-card.dragging { opacity: .45; cursor: grabbing; }
.board-card.breached { border-left: 3px solid var(--danger); }
.board-card-title { font-size: 13px; font-weight: 550; line-height: 1.4; }
.board-empty { padding: 20px 10px; text-align: center; color: var(--ink-3); font-size: 12px; }

/* -------------------------------------------- settings: config editors --- */

.stage-list, .field-list { display: flex; flex-direction: column; gap: 7px; }
.stage-row {
  display: grid; grid-template-columns: 20px minmax(0, 2fr) 130px minmax(0, 1.2fr) auto;
  gap: 8px; align-items: center;
}
.stage-row.stage-head, .field-head {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-3); font-weight: 650; padding-bottom: 2px;
}
.stage-row .grip { cursor: grab; color: var(--ink-3); text-align: center; user-select: none; }

.field-row-editor {
  display: grid; grid-template-columns: minmax(0, 1.4fr) 110px minmax(0, 1fr) minmax(0, 1.4fr) 110px auto;
  gap: 8px; align-items: center;
}

.hours-list { display: flex; flex-direction: column; gap: 7px; }
.hours-row { display: grid; grid-template-columns: 90px 110px 1fr 1fr; gap: 8px; align-items: center; }

/* ----------------------------------------------------------- billing --- */

.usage-list { display: flex; flex-direction: column; gap: 9px; }
.usage-row { display: grid; grid-template-columns: 150px 1fr 130px; gap: 11px; align-items: center; }
.usage-row .track { height: 7px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.usage-row .track i { display: block; height: 100%; border-radius: 4px; transition: width .2s; }

.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 11px; }
.plan-card { border: 1px solid var(--line); border-radius: 11px; padding: 14px; background: var(--surface); }
.plan-card.current { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.plan-price { font-size: 24px; font-weight: 700; margin: 6px 0 2px; }
.plan-price .small { font-weight: 400; }

/* ------------------------------------------------------------ inbox ----- */

/* List beside thread. The list scrolls independently so working a queue never
   loses your place in it. */
.conv-layout {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
.conv-layout > * { min-width: 0; }

.conv-list { max-height: calc(100vh - 230px); overflow-y: auto; }

.conv-row {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  padding: 11px 13px;
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.conv-row:hover { background: var(--surface-2); }
.conv-row.active { background: var(--brand-soft); box-shadow: inset 3px 0 0 var(--brand); }
.conv-row .count {
  background: var(--brand); color: #fff; border-radius: 9px; padding: 1px 6px;
  font-size: 11px; font-weight: 700; flex: 0 0 auto;
}

.thread {
  padding: 14px;
  max-height: calc(100vh - 430px);
  min-height: 220px;
  overflow-y: auto;
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bubble-row { display: flex; }
.bubble-row.out { justify-content: flex-end; }

.bubble {
  max-width: min(78%, 560px);
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.55;
  box-shadow: 0 1px 1px rgba(15, 23, 42, .05);
}
.bubble.in { background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bubble.out { background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.bubble.out.failed { background: var(--danger); }

.bubble-meta { font-size: 10.5px; opacity: .72; margin-top: 4px; }
.bubble.in .bubble-meta { color: var(--ink-3); opacity: 1; }

@media (max-width: 1000px) {
  .conv-layout { grid-template-columns: 1fr; }
  .conv-list { max-height: 300px; }
  .thread { max-height: 50vh; }
}

@media (max-width: 900px) {
  .topbar { padding: 10px 16px; flex-wrap: wrap; }
  .workspace > main { padding: 16px; }
  .stage-row, .field-row-editor, .hours-row, .usage-row { grid-template-columns: 1fr; }
  .stage-row.stage-head, .field-head { display: none; }
  .bubble { max-width: 88%; }
}
