:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #182230;
  --muted: #667085;
  --line: #d9e0e8;
  --line-soft: #edf1f5;
  --brand: #0f766e;
  --brand-dark: #0b5f59;
  --brand-soft: #e6f4f1;
  --blue: #2563eb;
  --blue-soft: #eaf1ff;
  --amber: #b7791f;
  --amber-soft: #fff7e6;
  --red: #c24135;
  --red-soft: #fff0ed;
  --green: #14804a;
  --green-soft: #e8f6ee;
  --purple: #6d5bd0;
  --purple-soft: #f0edff;
  --shadow: 0 10px 24px rgba(16, 24, 40, 0.06);
  --radius: 8px;
  --sidebar: 264px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.9), rgba(244,246,248,0.86) 240px),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
}
a { color: var(--brand-dark); text-decoration: none; }
a:hover { color: var(--brand); text-decoration: underline; }

.layout {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: rgba(255,255,255,0.94);
  padding: 22px 16px;
}
.brand {
  display: grid;
  gap: 4px;
  margin-bottom: 22px;
  padding: 0 8px 18px;
  border-bottom: 1px solid var(--line-soft);
  color: #111827;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0;
}
.brand span {
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
}
.nav { display: grid; gap: 4px; }
.nav a {
  display: flex;
  align-items: center;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 9px 10px;
  color: #344054;
  font-weight: 700;
  text-decoration: none;
}
.nav a:hover {
  background: var(--panel-soft);
  border-color: var(--line-soft);
  color: var(--text);
  text-decoration: none;
}
.nav a.active {
  background: var(--brand-soft);
  border-color: rgba(15, 118, 110, 0.22);
  color: var(--brand-dark);
  box-shadow: inset 3px 0 0 var(--brand);
}

.main {
  min-width: 0;
  max-width: 1560px;
  width: 100%;
  padding: 28px;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}
h1, h2, h3 { margin: 0; color: var(--text); line-height: 1.18; letter-spacing: 0; }
h1 { font-size: 28px; font-weight: 800; }
h2 { font-size: 19px; font-weight: 800; }
h3 { font-size: 15px; font-weight: 800; }
p { margin: 0; }
.muted { color: var(--muted); }
.help-text { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.4; }

.grid { display: grid; gap: 14px; }
.cards { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.card, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.card {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 112px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.card .label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}
.card .value {
  color: var(--text);
  font-size: clamp(23px, 3vw, 31px);
  font-weight: 850;
  line-height: 1;
}
.card p { margin: 0; }
.card p .badge + .badge { margin-left: 6px; }
.panel {
  margin-bottom: 16px;
  padding: 18px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 14px;
}
.panel-header > div { min-width: 0; }
.panel-title { display: grid; gap: 4px; }

.filters, .form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  align-items: end;
}
.filters { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.field { display: grid; gap: 6px; min-width: 0; }
label {
  color: #344054;
  font-size: 12px;
  font-weight: 800;
}
input, select, textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid #cfd8e3;
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  font: inherit;
  padding: 9px 10px;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
textarea { min-height: 108px; resize: vertical; }
input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--brand);
}
input:focus, select:focus, textarea:focus {
  outline: 0;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}
input::placeholder, textarea::placeholder { color: #98a2b3; }

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 39px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}
.checkbox-field label { margin: 0; }
.span-all { grid-column: 1 / -1; }
.actions, .action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.action-row {
  justify-content: flex-start;
  padding-top: 2px;
}
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  padding: 9px 13px;
  text-decoration: none;
  white-space: nowrap;
}
button:hover, .button:hover {
  background: var(--brand-dark);
  color: #fff;
  text-decoration: none;
}
button:disabled { cursor: not-allowed; opacity: .58; }
button.secondary, .button.secondary {
  background: #fff;
  color: #344054;
  border-color: #cfd8e3;
}
button.secondary:hover, .button.secondary:hover {
  background: var(--panel-soft);
  color: var(--text);
}
button.danger, .button.danger { background: var(--red); }
button.danger:hover, .button.danger:hover { background: #9f2f27; }
button.small, .button.small {
  min-height: 30px;
  padding: 6px 9px;
  font-size: 12px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}
table {
  width: 100%;
  min-width: 960px;
  border-collapse: collapse;
}
th, td {
  padding: 11px 10px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line-soft);
}
th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: #475467;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fbfcfe; }
.table-actions { display: flex; flex-wrap: wrap; gap: 6px; min-width: 210px; }
.breakable { overflow-wrap: anywhere; word-break: break-word; }

.badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  border-radius: 999px;
  background: var(--purple-soft);
  color: var(--purple);
  font-size: 12px;
  font-weight: 850;
  line-height: 1.2;
  padding: 4px 9px;
  white-space: nowrap;
}
.badge.hot { background: var(--red-soft); color: #9f2f27; }
.badge.good { background: var(--green-soft); color: var(--green); }
.badge.warm { background: var(--amber-soft); color: var(--amber); }
.badge.low { background: #edf0f3; color: #475467; }
.badge.status { background: var(--blue-soft); color: #1d4ed8; }
.badge.optout { background: #f2f4f7; color: #667085; }

.empty {
  display: grid;
  place-items: center;
  min-height: 94px;
  border: 1px dashed #cfd8e3;
  border-radius: var(--radius);
  background: var(--panel-soft);
  color: var(--muted);
  padding: 20px;
  text-align: center;
}
.table-empty {
  color: var(--muted);
  padding: 24px;
  text-align: center;
}
.result-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid #c7d7fe;
  border-radius: var(--radius);
  background: var(--blue-soft);
  color: #1d4ed8;
  font-size: 12px;
  line-height: 1.35;
}
.result-summary span {
  padding-right: 8px;
  border-right: 1px solid #b8c8f8;
}
.result-summary span:last-child { border-right: 0; }
.detail-list {
  display: grid;
  gap: 10px;
}
.detail-list div {
  min-width: 0;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
}
.detail-list div:first-child { padding-top: 0; }
.detail-list div:last-child { border-bottom: 0; }
.timeline-title { margin-top: 18px; margin-bottom: 10px; }
.metric-note { color: var(--muted); font-size: 12px; }
.two-col { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(280px, .7fr); gap: 16px; }
.three-col { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
pre {
  overflow: auto;
  margin: 0;
  border-radius: var(--radius);
  background: #101828;
  color: #f8fafc;
  font-size: 12px;
  line-height: 1.55;
  padding: 14px;
}

.roadmap-group {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 0 0;
  color: #344054;
}
.roadmap-group strong { font-size: 14px; }
.roadmap-group span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.hidden { display: none !important; }
.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: min(460px, calc(100vw - 44px));
  border-radius: var(--radius);
  background: #111827;
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  padding: 12px 14px;
  transform: translateY(10px);
  transition: all .2s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.drawer {
  position: fixed;
  right: 0;
  top: 0;
  z-index: 10;
  width: min(560px, 96vw);
  height: 100vh;
  overflow-y: auto;
  border-left: 1px solid var(--line);
  background: #fff;
  box-shadow: -18px 0 40px rgba(16, 24, 40, 0.16);
  padding: 22px;
  transform: translateX(105%);
  transition: transform .22s ease;
}
.drawer.open { transform: translateX(0); }
.drawer .panel-header { padding-bottom: 14px; border-bottom: 1px solid var(--line-soft); }

@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    padding: 16px;
  }
  .brand { margin-bottom: 14px; padding-bottom: 14px; }
  .nav { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .main { padding: 20px; }
  .two-col, .three-col { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  body { font-size: 13px; }
  .main { padding: 16px; }
  .sidebar { padding: 14px 16px 10px; }
  .brand { margin-bottom: 10px; padding-bottom: 10px; }
  .nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: thin;
  }
  .nav a {
    flex: 0 0 auto;
    min-height: 34px;
    padding: 7px 10px;
    white-space: nowrap;
  }
  .nav a.active {
    box-shadow: inset 0 -3px 0 var(--brand);
  }
  .topbar, .panel-header { flex-direction: column; align-items: stretch; }
  .actions, .action-row { align-items: stretch; }
  button, .button { width: 100%; }
  button.small, .button.small { width: auto; }
  .filters, .form-grid, .cards { grid-template-columns: 1fr; }
  h1 { font-size: 24px; }
  .panel { padding: 14px; }
  .card { min-height: 96px; }
  .table-actions { min-width: 0; }
}
