:root {
  --bg: #f7f4ee;
  --surface: #fffdfa;
  --surface-strong: #ffffff;
  --ink: #1d2430;
  --muted: #697386;
  --line: #d9d4ca;
  --teal: #0f766e;
  --teal-soft: #d8f0ec;
  --coral: #c2410c;
  --coral-soft: #fee7d6;
  --amber: #b7791f;
  --amber-soft: #fff1c7;
  --blue: #315f9a;
  --shadow: 0 14px 36px rgba(29, 36, 48, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px clamp(18px, 4vw, 48px) 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.topbar h1,
.panel h2 {
  margin: 0;
}

.topbar h1 {
  font-size: clamp(24px, 4vw, 40px);
  line-height: 1.05;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

main {
  width: min(1540px, 100%);
  margin: 0 auto;
  padding: 22px clamp(14px, 3vw, 40px) 56px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.filters,
.kpis,
.grid {
  display: grid;
  gap: 14px;
}

.filters {
  grid-template-columns: repeat(5, minmax(120px, 1fr)) auto;
  align-items: end;
  margin-bottom: 18px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--surface-strong);
}

.button,
.icon-button {
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 800;
  color: #ffffff;
  background: var(--ink);
  min-height: 42px;
  padding: 0 16px;
}

.button.secondary {
  color: var(--ink);
  border: 1px solid var(--line);
  background: var(--surface-strong);
}

.icon-button {
  width: 42px;
  padding: 0;
  font-size: 22px;
}

.kpis {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 18px;
}

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

.metric {
  min-height: 112px;
  padding: 18px;
  display: grid;
  align-content: space-between;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric strong {
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1;
}

.metric.accent {
  border-color: #f4c6aa;
  background: linear-gradient(180deg, #fffdfa 0%, var(--coral-soft) 100%);
}

.grid {
  margin-bottom: 18px;
}

.grid.two {
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.8fr);
}

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

.panel {
  padding: 18px;
}

.panel.compact h2 {
  font-size: 18px;
  margin-bottom: 12px;
}

.panel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-head h2 {
  font-size: 22px;
}

.panel-head time {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.digest-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.digest-list li {
  border-left: 4px solid var(--teal);
  padding: 10px 12px;
  background: var(--teal-soft);
  border-radius: 6px;
  line-height: 1.45;
}

.clarity-status {
  display: grid;
  gap: 10px;
  color: var(--muted);
}

.status-pill,
.issue-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  color: var(--ink);
  background: var(--amber-soft);
  border: 1px solid #e5c36f;
}

.status-pill.ok {
  background: var(--teal-soft);
  border-color: #83cfc4;
}

.status-pill.error {
  background: var(--coral-soft);
  border-color: #f3a37a;
}

.funnel-chart {
  display: grid;
  gap: 12px;
}

.funnel-row {
  display: grid;
  grid-template-columns: minmax(150px, 210px) minmax(120px, 1fr) 120px 110px;
  gap: 12px;
  align-items: center;
}

.funnel-label {
  font-weight: 800;
}

.funnel-track {
  position: relative;
  height: 28px;
  overflow: hidden;
  background: #ebe5dc;
  border-radius: 7px;
}

.funnel-bar {
  position: absolute;
  inset: 0 auto 0 0;
  min-width: 2px;
  background: linear-gradient(90deg, var(--blue), var(--teal));
}

.funnel-count,
.funnel-drop {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.issue-list {
  display: grid;
  gap: 12px;
}

.behavior-layout {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.behavior-layout.two-col {
  grid-template-columns: minmax(0, 1.2fr) minmax(300px, 0.8fr);
}

.behavior-layout h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.behavior-list {
  display: grid;
  gap: 8px;
}

.behavior-item {
  display: grid;
  gap: 4px;
  min-height: 74px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.behavior-item strong,
.behavior-item span,
.behavior-item em,
.behavior-item a {
  overflow: hidden;
  text-overflow: ellipsis;
}

.behavior-item strong {
  white-space: nowrap;
}

.behavior-item span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.behavior-item em {
  color: var(--teal);
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.issue {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.issue h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.issue p {
  margin: 6px 0;
  color: var(--muted);
  line-height: 1.45;
}

.issue strong {
  color: var(--ink);
}

.issue-actions {
  display: grid;
  align-content: start;
  gap: 8px;
}

.issue select {
  min-width: 132px;
}

.table {
  display: grid;
  gap: 7px;
}

.table-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 60px 64px;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #ece7df;
  font-size: 13px;
}

.table-row.wide {
  grid-template-columns: minmax(0, 1.5fr) repeat(4, minmax(82px, auto));
}

.table-row:last-child {
  border-bottom: 0;
}

.table-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-row span {
  color: var(--muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  color: var(--surface-strong);
  background: var(--ink);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
}

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

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.login-wrap {
  width: min(460px, 100%);
  padding: 24px;
}

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

.login-panel h1 {
  margin: 0 0 22px;
  font-size: 30px;
  line-height: 1.1;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-message {
  min-height: 20px;
  color: var(--coral);
  font-weight: 800;
}

.empty {
  color: var(--muted);
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

@media (max-width: 1100px) {
  .filters,
  .kpis,
  .behavior-layout,
  .behavior-layout.two-col,
  .grid.two,
  .grid.four {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .topbar,
  .panel-head,
  .issue {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .filters,
  .kpis,
  .behavior-layout,
  .behavior-layout.two-col,
  .grid.two,
  .grid.four {
    grid-template-columns: 1fr;
  }

  .funnel-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .funnel-count,
  .funnel-drop {
    text-align: left;
  }
}
