:root {
  --bg: #f4f7f8;
  --ink: #17232d;
  --muted: #66737d;
  --line: #dce4e8;
  --soft-line: #edf2f4;
  --surface: #ffffff;
  --nav: #102536;
  --nav-2: #0b1c2a;
  --teal: #0f9489;
  --teal-dark: #0b766f;
  --red: #b42318;
  --amber: #b76b00;
  --green: #16743c;
  --shadow: 0 16px 42px rgba(21, 34, 43, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0 14px;
  font-size: 13px;
  font-weight: 720;
  text-decoration: none;
  cursor: pointer;
}

button.primary,
.primary {
  border-color: var(--teal);
  background: var(--teal);
  color: white;
}

button:hover,
.button:hover {
  border-color: var(--teal);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
  font-size: 13px;
}

.app-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 20px;
  background: linear-gradient(180deg, var(--nav), var(--nav-2));
  color: #e8f0f3;
  padding: 22px 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px 10px;
  font-weight: 820;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 7px;
  color: #6ee7de;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-item {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 11px;
  border-radius: 6px;
  padding: 0 12px;
  color: #b7c6ce;
  text-decoration: none;
  font-size: 14px;
  font-weight: 650;
}

.nav-item.active,
.nav-item:hover {
  color: #fff;
  background: rgba(255,255,255,0.1);
}

.suite-card {
  margin-top: auto;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 7px;
  padding: 12px;
  display: grid;
  gap: 5px;
}

.suite-card span {
  color: #b7c6ce;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.workspace {
  min-width: 0;
  padding: 20px;
  display: grid;
  gap: 16px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.topbar h1,
.panel h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.15;
}

.topbar p,
.panel-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.top-actions,
.panel-actions {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.top-actions input {
  width: min(360px, 32vw);
}

.top-actions select {
  width: 180px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(138px, 1fr));
  gap: 12px;
}

.metric,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric {
  padding: 14px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 7px;
  font-size: 24px;
}

.metric.warning strong {
  color: var(--amber);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(620px, 1fr) 340px;
  gap: 16px;
  align-items: start;
}

.panel {
  min-width: 0;
  overflow: hidden;
}

.panel-head {
  min-height: 70px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.board {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(236px, 1fr);
  gap: 10px;
  padding: 14px;
  overflow: auto;
}

.stage-column {
  min-height: 340px;
  display: grid;
  grid-template-rows: auto 1fr;
  border: 1px solid var(--soft-line);
  border-radius: 7px;
  background: #f8fbfc;
}

.stage-column.drag-over {
  border-color: var(--teal);
  background: #eefafa;
}

.stage-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 11px;
  border-bottom: 1px solid var(--soft-line);
}

.stage-head strong {
  font-size: 13px;
}

.stage-head span {
  color: var(--muted);
  font-size: 12px;
}

.deal-list {
  display: grid;
  align-content: start;
  gap: 9px;
  padding: 10px;
}

.deal-card {
  border: 1px solid var(--line);
  border-left: 4px solid var(--teal);
  border-radius: 7px;
  background: #fff;
  padding: 10px;
  display: grid;
  gap: 7px;
  cursor: grab;
}

.deal-card:active {
  cursor: grabbing;
}

.deal-card strong {
  font-size: 13px;
}

.deal-card span,
.deal-card small {
  color: var(--muted);
  font-size: 12px;
}

.deal-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid var(--soft-line);
  padding-top: 7px;
}

.stage-picker {
  display: grid;
  gap: 4px;
}

.stage-picker span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.stage-picker select {
  width: 100%;
  min-height: 34px;
  border-radius: 6px;
  font-size: 12px;
}

.score-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: #e8f7f5;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 800;
}

.detail-body {
  padding: 14px 16px;
  display: grid;
  gap: 12px;
}

.detail-card {
  display: grid;
  gap: 8px;
}

.detail-card h3 {
  margin: 0;
  font-size: 18px;
}

.detail-list {
  display: grid;
  gap: 7px;
}

.detail-list div,
.timeline-row,
.stack-card {
  border: 1px solid var(--soft-line);
  border-radius: 6px;
  background: #fbfcfc;
  padding: 9px;
}

.detail-list span,
.timeline-row span,
.stack-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
}

.detail-list strong,
.timeline-row strong,
.stack-card strong {
  display: block;
  margin-top: 3px;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.timeline {
  display: grid;
  gap: 8px;
}

.activity-form {
  display: grid;
  gap: 8px;
  padding: 14px 16px 16px;
  border-top: 1px solid var(--line);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.table-scroll {
  overflow: auto;
}

table {
  width: 100%;
  min-width: 1160px;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 13px;
  border-bottom: 1px solid var(--soft-line);
  text-align: left;
  font-size: 13px;
  vertical-align: middle;
}

th {
  background: #fbfcfc;
  color: #4d5a64;
  font-size: 12px;
  font-weight: 800;
}

td a {
  color: var(--teal-dark);
  text-decoration: none;
  font-weight: 700;
}

tr.contact-row {
  cursor: pointer;
}

tr.contact-row:hover td {
  background: #f6fbfb;
}

.ops-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.outreach-grid {
  display: grid;
  grid-template-columns: minmax(420px, 0.95fr) minmax(520px, 1.25fr);
  gap: 16px;
  align-items: start;
}

.outreach-editor,
.outreach-controls {
  display: grid;
  gap: 10px;
  padding: 14px 16px 16px;
}

.outreach-editor textarea {
  min-height: 190px;
  resize: vertical;
  line-height: 1.45;
}

.compact-editor {
  border-top: 1px solid var(--soft-line);
  padding-top: 12px;
}

.compact-editor input,
.compact-editor select {
  min-height: 36px;
}

.check-line {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.check-line input {
  width: auto;
  min-height: 0;
  margin-top: 2px;
}

.template-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  padding: 0 16px 16px;
}

.template-chip {
  border: 1px solid var(--soft-line);
  border-radius: 6px;
  background: #fbfcfc;
  padding: 9px;
  display: grid;
  gap: 4px;
  text-align: left;
}

.template-chip strong {
  font-size: 13px;
}

.template-chip span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
  text-transform: uppercase;
}

.template-chip.active {
  border-color: var(--teal);
  background: #f0fbfa;
}

.outreach-config {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.config-pill,
.mini-metric {
  border: 1px solid var(--soft-line);
  border-radius: 6px;
  background: #fbfcfc;
  padding: 9px;
}

.config-pill span,
.mini-metric span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.config-pill strong,
.mini-metric strong {
  display: block;
  margin-top: 3px;
  font-size: 13px;
}

.config-pill.ready strong {
  color: var(--green);
}

.config-pill.blocked strong {
  color: var(--amber);
}

.mini-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.queue-scroll {
  max-height: 430px;
}

.queue-table {
  min-width: 920px;
}

.sequence-step-list {
  max-height: 260px;
  border-top: 1px solid var(--soft-line);
}

.sequence-step-list .stack-card {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.status-pill {
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  border-radius: 999px;
  padding: 0 8px;
  background: #eef2f4;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.status-pill.sent {
  background: #e8f6ee;
  color: var(--green);
}

.status-pill.failed,
.status-pill.skipped {
  background: #fff4e5;
  color: var(--amber);
}

.status-pill.queued,
.status-pill.processing {
  background: #e8f7f5;
  color: var(--teal-dark);
}

.stack-list {
  display: grid;
  gap: 9px;
  padding: 14px 16px 16px;
  max-height: 360px;
  overflow: auto;
}

.stack-card {
  display: grid;
  gap: 6px;
}

.stack-actions {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  padding-top: 5px;
}

.help-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 16px;
}

.help-grid div {
  border: 1px solid var(--soft-line);
  border-radius: 7px;
  padding: 12px;
  background: #fbfcfc;
  display: grid;
  gap: 7px;
}

code {
  display: block;
  color: var(--teal-dark);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.empty {
  min-height: 90px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  max-width: min(440px, calc(100vw - 36px));
  background: #102536;
  color: white;
  border-radius: 7px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(16px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  font-size: 13px;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.help-button {
  min-height: 34px;
  padding: 0 10px;
  color: var(--teal);
  border-color: #bfe1dd;
  background: #f3fbfa;
  white-space: nowrap;
}

.help-button:hover {
  color: var(--teal-dark);
  border-color: var(--teal);
  background: #e8f7f5;
}

.topbar > div:first-child {
  min-width: 0;
}

.topbar > div:first-child .help-button {
  margin-top: 10px;
}

.icon-button {
  width: 36px;
  min-height: 36px;
  padding: 0;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  place-items: center;
  padding: 18px;
  background: rgba(9, 17, 25, 0.42);
}

.modal-backdrop.open {
  display: grid;
}

.modal {
  width: min(640px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(10, 22, 30, 0.22);
  padding: 20px;
}

.help-backdrop {
  z-index: 40;
}

.modal.help-modal {
  width: min(980px, 100%);
  max-height: min(760px, calc(100vh - 36px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.modal-head,
.help-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.help-head {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--soft-line);
}

.modal h2 {
  margin: 0;
  font-size: 20px;
}

.modal p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.help-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 18px;
}

.help-menu {
  border-right: 1px solid var(--soft-line);
  padding: 12px 12px 12px 0;
  overflow: auto;
}

.help-menu a {
  display: block;
  color: var(--ink);
  text-decoration: none;
  border-radius: 6px;
  padding: 9px 10px;
  font-size: 13px;
  font-weight: 700;
}

.help-menu a:hover {
  color: var(--teal);
  background: #f1f7f7;
}

.help-body {
  min-width: 0;
  overflow: auto;
  padding: 12px 4px 12px 0;
  scroll-behavior: smooth;
}

.help-section {
  padding: 0 0 16px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--soft-line);
}

.help-section:last-child {
  border-bottom: 0;
  margin-bottom: 0;
}

.help-section h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.help-section ul {
  margin: 0;
  padding-left: 20px;
}

.help-section li {
  margin-bottom: 8px;
  color: #34434c;
  font-size: 14px;
  line-height: 1.45;
}

@media (max-width: 1180px) {
  .metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .content-grid,
  .outreach-grid,
  .ops-grid,
  .help-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  .topbar,
  .panel-head {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .top-actions,
  .panel-actions {
    min-width: 0;
    flex-wrap: wrap;
  }

  .top-actions input,
  .top-actions select,
  .panel-actions select {
    min-width: 0;
    flex: 1 1 180px;
  }

  .content-grid,
  .outreach-grid,
  .ops-grid,
  .help-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 780px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .nav-list {
    grid-template-columns: repeat(6, minmax(42px, 1fr));
  }

  .nav-item {
    justify-content: center;
    font-size: 0;
  }

  .workspace {
    padding: 12px;
  }

  .topbar,
  .panel-head {
    flex-direction: column;
  }

  .top-actions,
  .top-actions input,
  .top-actions select,
  .top-actions button,
  .panel-actions,
  .panel-actions select,
  .panel-actions .button {
    width: 100%;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .template-list,
  .outreach-config,
  .mini-metrics {
    grid-template-columns: 1fr;
  }

  .help-layout {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .help-menu {
    border-right: 0;
    border-bottom: 1px solid var(--soft-line);
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 10px 0;
  }

  .help-menu a {
    min-width: max-content;
  }

  .modal.help-modal {
    max-height: calc(100vh - 20px);
    padding: 16px;
  }
}
