:root {
  color-scheme: light;
  --font: "Avenir Next", "Helvetica Neue", Arial, sans-serif;
  --canvas: #f2f4f6;
  --paper: #ffffff;
  --ink: #151815;
  --muted: #606a72;
  --line: #d2d8de;
  --line-strong: #b9c0c7;
  --soft: #e9edf1;
  --top: #111411;
  --accent: #2157dd;
  --accent-strong: #1540ae;
  --accent-soft: #eaf0ff;
  --positive: #1c7048;
  --positive-soft: #edf8f1;
  --warning: #965410;
  --warning-soft: #fff7e9;
  --danger: #b52e3a;
  --danger-soft: #fff0f1;
  --focus: #7e9ce8;
  --shadow: 0 18px 55px rgb(18 24 31 / 8%);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: #b9caff; color: #0c1a3c; }
a { color: var(--accent); }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1, h2, h3 { color: var(--ink); }
h1 {
  margin: 0;
  font-size: clamp(2.25rem, 4vw, 3.35rem);
  font-weight: 600;
  line-height: .98;
  letter-spacing: -.045em;
}
h2 { margin: 0 0 16px; font-size: 1.2rem; font-weight: 650; letter-spacing: -.02em; }
h3 { margin: 0 0 10px; font-size: 1rem; }
button, input, select, textarea { font: inherit; }
button, .button, .btn {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--accent);
  border-radius: 7px;
  padding: 8px 14px;
  background: var(--accent);
  color: #fff;
  font-size: .86rem;
  font-weight: 650;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s, border-color .15s, transform .15s;
}
button:hover, .button:hover, .btn:hover {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
  transform: translateY(-1px);
}
.button-secondary, .button.secondary, .btn.secondary, .secondary {
  border-color: var(--line);
  background: var(--paper);
  color: var(--ink);
}
.button-secondary:hover, .button.secondary:hover, .btn.secondary:hover, .secondary:hover {
  border-color: #939ca4;
  background: var(--soft);
  color: var(--ink);
}
.button-danger, .button.danger, .btn.danger, button.danger, .danger {
  border-color: var(--danger);
  background: var(--danger);
  color: #fff;
}
.button-danger:hover, .button.danger:hover, .btn.danger:hover, button.danger:hover, .danger:hover {
  border-color: #97252e;
  background: #97252e;
  color: #fff;
}
button:disabled { opacity: .55; cursor: not-allowed; transform: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 12px;
  padding: 10px 14px;
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow);
  transform: translateY(-160%);
}
.skip-link:focus { transform: none; }

.shell { min-height: 100vh; }
.app-header {
  position: sticky;
  z-index: 20;
  top: 0;
  border-top: 3px solid var(--accent);
  border-bottom: 1px solid #353a35;
  background: var(--top);
  color: #fff;
}
.topline {
  display: flex;
  min-height: 66px;
  align-items: center;
  gap: 28px;
  padding: 0 clamp(18px, 3vw, 38px);
}
.brand {
  color: #fff;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -.015em;
  text-decoration: none;
}
.brand span {
  display: block;
  margin-top: 3px;
  color: #9da69e;
  font-size: .58rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.account-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.account-actions form { margin: 0; }
.account-actions .button-secondary {
  min-height: 35px;
  border-color: #424843;
  background: transparent;
  color: #fff;
}
.account-actions .button-secondary:hover { border-color: #59615a; background: #262b27; }
.role { padding-right: 12px; border-right: 1px solid #3d433e; color: #cbd0cc; font-size: .78rem; }
.navigation {
  display: flex;
  gap: 26px;
  overflow-x: auto;
  padding: 0 clamp(18px, 3vw, 38px);
  scrollbar-width: thin;
}
.navigation a {
  position: relative;
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 6px;
  border-bottom: 3px solid transparent;
  color: #aab2ac;
  font-size: .8rem;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}
.navigation a:hover, .navigation a[aria-current="page"] { border-color: var(--accent); color: #fff; }
.nav-badge {
  display: inline-grid;
  min-width: 19px;
  height: 19px;
  place-items: center;
  border-radius: 10px;
  padding: 0 5px;
  background: #ec5b31;
  color: #fff;
  font-size: .68rem;
  font-variant-numeric: tabular-nums;
}

.main { width: min(100%, 1600px); margin: 0 auto; padding: 34px clamp(18px, 3vw, 38px) 72px; }
.topbar {
  display: flex;
  min-height: 96px;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
  padding-bottom: 21px;
  border-bottom: 1px solid var(--line);
}
.page-context {
  margin: 0 0 9px;
  color: var(--muted);
  font-size: .67rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.muted, .definition { color: var(--muted); }
.definition { font-size: .82rem; line-height: 1.5; }

.panel, .card {
  margin-top: 12px;
  padding: clamp(18px, 2.25vw, 24px);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
}
.card { margin-top: 16px; }
.panel > :first-child, .card > :first-child { margin-top: 0; }
.panel > :last-child, .card > :last-child { margin-bottom: 0; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.section-heading h2 { margin-bottom: 0; }
.grid, .row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.filters {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}
label { display: grid; gap: 6px; margin: 10px 0; font-size: .76rem; font-weight: 650; }
input, select, textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
}
input:hover, select:hover, textarea:hover { border-color: #939ca4; }
input[type="checkbox"], input[type="radio"] { width: 18px; min-height: 18px; margin: 0; accent-color: var(--accent); }
label:has(> input[type="checkbox"]), label:has(> input[type="radio"]) {
  display: flex;
  align-items: flex-start;
  gap: 9px;
}
textarea { min-height: 120px; resize: vertical; }
.compact-input { min-width: 220px; }
.loading-state { margin: 10px 0 0; color: var(--muted); }
.js .loading-state { display: none; }
.js .is-loading .loading-state { display: block; }

.attention-grid, .channel-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}
.attention-item, .channel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 15px;
  background: var(--paper);
  color: var(--ink);
  text-decoration: none;
}
.attention-item { transition: border-color .15s, box-shadow .15s, transform .15s; }
a.attention-item:hover { border-color: var(--accent); box-shadow: 0 6px 18px rgb(27 40 69 / 8%); transform: translateY(-1px); }
.attention-item[data-count="0"] { background: #f7f8f9; color: var(--muted); }
.attention-item[data-count]:not([data-count="0"]) { border-top: 3px solid #ec5b31; }
.count, .metric-value {
  display: block;
  margin-top: 8px;
  font-size: 1.9rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
}
.metric {
  min-width: 0;
  min-height: 118px;
  margin: 0;
  padding: 17px 18px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: var(--paper);
}
.metric:last-child { border-right: 0; }
.metric > span:first-child { color: var(--muted); font-size: .74rem; font-weight: 650; }
.metric .definition { margin: 8px 0 0; }
.ratio { display: block; margin-top: 5px; color: var(--positive); font-size: .72rem; font-variant-numeric: tabular-nums; }
.metrics-grid.compact { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metrics-grid.compact .metric { min-height: 92px; }
.report-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.channel { border-top: 3px solid var(--positive); }
.channel p { margin-bottom: 0; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); background: var(--paper); }
table { width: 100%; border-collapse: collapse; font-size: .84rem; font-variant-numeric: tabular-nums; }
th, td { padding: 12px; border-bottom: 1px solid #e3e6e9; text-align: left; vertical-align: top; }
th {
  background: #f4f6f8;
  color: #515953;
  font-size: .69rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}
th a { color: inherit; text-decoration: none; }
tbody tr:last-child > * { border-bottom: 0; }
tbody tr:hover { background: #f7f8f9; }
th .definition { display: block; margin-top: 4px; font-weight: 400; letter-spacing: 0; text-transform: none; }
.number { text-align: right; font-variant-numeric: tabular-nums; }

.empty, .error-state {
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 20px;
  background: #f8f9fa;
  color: var(--muted);
}
.notice {
  border-left: 3px solid var(--danger);
  border-radius: 6px;
  padding: 11px 13px;
  background: var(--danger-soft);
  color: #8f2630;
}
.max-auth-figure { width: fit-content; max-width: 100%; margin: 18px 0; }
.max-auth-qr {
  display: block;
  width: min(320px, 100%);
  height: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #fff;
}
.max-auth-figure figcaption { max-width: 320px; margin-top: 8px; color: var(--muted); font-size: .8rem; }
.notice-list:empty { display: none; }
.preview { margin-top: 16px; padding: 16px; border: 1px solid #bcc9e8; border-radius: 8px; background: var(--accent-soft); }

.wizard-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0 0 12px; padding: 0; list-style: none; }
.wizard-steps li { display: grid; gap: 3px; border: 1px solid var(--line); border-radius: 7px; padding: 10px 12px; background: var(--paper); }
.wizard-steps li a { color: var(--ink); font-size: .8rem; font-weight: 650; text-decoration: none; }
.wizard-steps li span { color: var(--muted); font-size: .7rem; }
.wizard-steps .step-ready { border-color: #b9d5c4; background: var(--positive-soft); }
.wizard-steps .step-pending { border-left: 3px solid var(--line-strong); }
.wizard-step { scroll-margin-top: 124px; }
.wizard-step form { display: grid; gap: 12px; }

.lead-filters { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); }
.lead-list { display: grid; gap: 7px; margin: 0; padding: 0; list-style: none; }
.lead-list a { display: grid; gap: 3px; border: 1px solid var(--line); border-radius: 7px; padding: 12px; color: var(--ink); text-decoration: none; }
.lead-list a:hover, .lead-list a[aria-current="page"] { border-color: var(--accent); background: var(--accent-soft); }
.lead-list span { color: var(--muted); font-size: .78rem; }
.pagination { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.pagination a { display: inline-grid; min-width: 40px; min-height: 40px; place-items: center; border: 1px solid var(--line); border-radius: 7px; background: #fff; text-decoration: none; }
.pagination a[aria-current="page"] { border-color: var(--accent); background: var(--accent); color: #fff; }

.inbox-layout { display: grid; grid-template-columns: minmax(210px, .8fr) minmax(260px, 1fr) minmax(360px, 1.8fr); gap: 10px; align-items: start; }
.inbox-layout > .panel { margin-top: 0; padding: 16px; }
.inbox-queues { position: sticky; top: 126px; }
.inbox-thread { min-width: 0; }
.lead-card, .reply-box, .notes { display: grid; gap: 12px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.lead-card form, .reply-box form, .notes form { display: grid; gap: 10px; }
.message-list { display: grid; gap: 10px; max-height: 55vh; overflow-y: auto; padding: 18px 0; }
.message { max-width: 82%; border: 1px solid var(--line); border-radius: 8px; padding: 11px 12px; background: #f7f8f9; overflow-wrap: anywhere; }
.message.outbound { justify-self: end; border-color: #bcc9e8; background: var(--accent-soft); }
.message header, .message footer, .notes span { color: var(--muted); font-size: .72rem; }
.message p { white-space: pre-wrap; }
.notes ul { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.notes li { border-left: 3px solid var(--line); padding-left: 10px; }

.report-filters { display: grid; grid-template-columns: repeat(3, minmax(160px, 1fr)); }
.report-filters button { align-self: end; }
.report-stages { min-width: 210px; margin: 0; padding: 0; list-style: none; font-size: .76rem; }
.report-stages li { padding: 2px 0; }
.report-stages li[data-done="true"] { color: var(--positive); font-weight: 650; }
.report-stages li[data-done="false"] { color: var(--muted); }
details summary { cursor: pointer; font-weight: 650; }
details form { display: grid; gap: 10px; margin-top: 12px; min-width: 240px; }

.login-page { min-height: 100vh; background: #101310; }
.login-main { width: min(100% - 32px, 1000px); margin: clamp(18px, 6vh, 70px) auto; }
.login-card { padding: 28px; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: var(--shadow); }
.login-split { display: grid; min-height: min(640px, calc(100vh - 72px)); grid-template-columns: 1.12fr .88fr; overflow: hidden; padding: 0; border-color: #343a35; border-radius: 14px; box-shadow: 0 28px 90px rgb(0 0 0 / 45%); }
.login-copy { display: flex; flex-direction: column; justify-content: space-between; padding: clamp(32px, 5vw, 54px); background: radial-gradient(circle at 78% 18%, #284ea8 0, transparent 34%), #1a1f1b; color: #fff; }
.login-copy h1 { max-width: 650px; color: #fff; font-size: clamp(2.9rem, 5.4vw, 4.7rem); line-height: .94; }
.login-copy p { max-width: 520px; color: #b7c0b9; }
.login-brand { margin: 0; color: #fff !important; font-size: 1rem; font-weight: 700; letter-spacing: -.01em; }
.login-form { align-self: center; padding: clamp(28px, 4vw, 48px); }
.login-form h2 { font-size: 1.85rem; }
.login-form form { display: grid; gap: 10px; }
.login-form button { width: 100%; margin-top: 8px; }

@media (max-width: 1150px) {
  .attention-grid, .metrics-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .metric { border-bottom: 1px solid var(--line); }
  .metric:nth-child(3n) { border-right: 0; }
  .metric:last-child { border-bottom: 0; }
  .channel-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inbox-layout { grid-template-columns: minmax(210px, .8fr) minmax(340px, 1.5fr); }
  .inbox-queues { grid-column: 1 / -1; position: static; }
  .report-metrics, .metrics-grid.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .app-header { position: static; }
  .topline { min-height: 58px; gap: 10px; padding: 8px 14px; }
  .brand { flex: 1; font-size: 1rem; }
  .brand span, .role { display: none; }
  .account-actions { margin-left: 0; }
  .account-actions .button-secondary { min-height: 34px; padding: 7px 10px; }
  .navigation { gap: 18px; padding: 0 14px; }
  .navigation a { min-height: 40px; }
  .main { padding: 24px 14px 42px; }
  .topbar { min-height: 78px; margin-bottom: 16px; padding-bottom: 18px; }
  h1 { font-size: 2.35rem; }
  .attention-grid, .metrics-grid, .channel-grid { grid-template-columns: 1fr; }
  .metric { border-right: 0; border-bottom: 1px solid var(--line); }
  .metric:last-child { border-bottom: 0; }
  .grid, .row, .wizard-steps, .lead-filters, .inbox-layout, .report-filters, .report-metrics, .metrics-grid.compact { grid-template-columns: 1fr; }
  .inbox-layout > .panel { margin-top: 0; }
  .inbox-queues, .inbox-list, .inbox-thread { grid-column: auto; }
  .message-list { max-height: none; }
  .section-heading { display: block; }
  .section-heading .actions { margin-top: 14px; }
  .login-main { width: min(100% - 24px, 1000px); margin: 12px auto; }
  .login-split { display: block; min-height: 0; }
  .login-copy { min-height: 310px; padding: 28px; }
  .login-copy h1 { font-size: 2.85rem; }
  .login-form { padding: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
