:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #111827;
  --muted: #6b7280;
  --muted-2: #9ca3af;
  --line: #e7ebf1;
  --sidebar: #111827;
  --sidebar-soft: #1f2937;
  --accent: #6d5dfc;
  --accent-soft: #eeecff;
  --green: #0f9f6e;
  --green-soft: #eaf9f3;
  --red: #dc5a5a;
  --red-soft: #fff0f0;
  --amber: #b7791f;
  --amber-soft: #fff8e8;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04),
            0 10px 30px rgba(15, 23, 42, 0.04);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  color: #fff;
  padding: 26px 18px 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 28px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(145deg, #7c6cff, #5646e8);
  font-weight: 800;
  font-size: 18px;
  box-shadow: 0 10px 30px rgba(109, 93, 252, 0.32);
}

.brand-name {
  font-size: 16px;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.brand-subtitle {
  margin-top: 2px;
  font-size: 11px;
  color: #8f9aab;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-label {
  padding: 18px 12px 7px;
  color: #657185;
  font-size: 10px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.nav-item {
  width: 100%;
  min-height: 42px;
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: #aeb7c5;
  text-align: left;
  padding: 0 11px;
  cursor: pointer;
}

.nav-item.active {
  background: #222d3c;
  color: #fff;
}

.nav-item:disabled {
  cursor: default;
  opacity: 0.74;
}

.nav-icon {
  width: 22px;
  text-align: center;
  font-size: 16px;
}

.nav-badge {
  color: #6f7b8c;
  font-size: 9px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding: 18px 8px 0;
}

.sync-indicator {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.status-dot {
  width: 8px;
  height: 8px;
  margin-top: 5px;
  border-radius: 50%;
  background: #6b7280;
  box-shadow: 0 0 0 4px rgba(107, 114, 128, 0.13);
}

.status-dot.ok {
  background: #35c88a;
  box-shadow: 0 0 0 4px rgba(53, 200, 138, 0.14);
}

.status-dot.error {
  background: #ef6b6b;
  box-shadow: 0 0 0 4px rgba(239, 107, 107, 0.14);
}

.sync-title {
  font-size: 11px;
  font-weight: 650;
  color: #d6dbe3;
}

.sync-subtitle {
  margin-top: 3px;
  font-size: 10px;
  color: #687487;
}

.version {
  margin-top: 16px;
  color: #596579;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.main {
  min-width: 0;
}

.topbar {
  min-height: 112px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 34px 19px;
  background: rgba(255, 255, 255, 0.84);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.eyebrow,
.section-kicker,
.panel-kicker {
  color: var(--muted-2);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.topbar h1 {
  margin: 4px 0 2px;
  font-size: 26px;
  line-height: 1.1;
  letter-spacing: -0.035em;
}

.page-subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.ghost-button {
  height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  padding: 0 13px;
  cursor: pointer;
  color: #4b5563;
  font-size: 12px;
  font-weight: 650;
}

.ghost-button:hover {
  border-color: #cfd5df;
  background: #fbfcfe;
}

.ghost-button.loading {
  opacity: 0.6;
  pointer-events: none;
}

.avatar {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #ece9ff;
  color: #5b4be0;
  font-size: 11px;
  font-weight: 800;
}

.filter-bar {
  display: flex;
  align-items: flex-end;
  gap: 18px;
  min-height: 82px;
  padding: 15px 34px 17px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-group label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.date-range {
  display: flex;
  align-items: center;
  gap: 8px;
}

input[type="date"],
select {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: #374151;
  padding: 0 10px;
  outline: none;
  font-size: 12px;
}

input[type="date"]:focus,
select:focus {
  border-color: #b8b0ff;
  box-shadow: 0 0 0 3px rgba(109, 93, 252, 0.08);
}

select {
  min-width: 170px;
}

.filter-context {
  margin-left: auto;
  align-self: center;
}

.comparison-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  background: #f0f2f6;
  color: #657085;
  padding: 0 11px;
  font-size: 10px;
  font-weight: 650;
}

.content {
  padding: 26px 34px 50px;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 14px;
}

.section-heading h2 {
  margin: 4px 0 0;
  font-size: 18px;
  letter-spacing: -0.025em;
}

.data-note {
  color: var(--muted-2);
  font-size: 10px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 13px;
  margin-bottom: 13px;
}

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

.kpi-card {
  min-height: 130px;
  padding: 18px 18px 15px;
  position: relative;
  overflow: hidden;
}

.kpi-card.accent::after {
  content: "";
  position: absolute;
  width: 90px;
  height: 90px;
  right: -35px;
  top: -35px;
  border-radius: 50%;
  background: var(--accent-soft);
}

.kpi-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.kpi-value {
  margin-top: 13px;
  font-size: clamp(23px, 2vw, 31px);
  font-weight: 780;
  letter-spacing: -0.04em;
  white-space: nowrap;
}

.delta {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  margin-top: 9px;
  border-radius: 999px;
  padding: 0 8px;
  color: var(--muted);
  background: #f3f5f8;
  font-size: 10px;
  font-weight: 700;
}

.delta.positive {
  color: var(--green);
  background: var(--green-soft);
}

.delta.negative {
  color: var(--red);
  background: var(--red-soft);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(290px, 0.75fr);
  gap: 13px;
  margin-bottom: 13px;
}

.dashboard-grid.equal {
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
}

.panel {
  padding: 18px;
  min-width: 0;
}

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

.panel-header.compact {
  margin-bottom: 12px;
}

.panel-header h3 {
  margin: 4px 0 0;
  font-size: 15px;
  letter-spacing: -0.02em;
}

.panel-kicker.ai {
  color: var(--accent);
}

.chart-summary {
  text-align: right;
}

.chart-summary span {
  display: block;
  font-size: 14px;
  font-weight: 750;
}

.chart-summary small {
  color: var(--muted-2);
  font-size: 9px;
}

.chart-wrap {
  min-height: 248px;
}

.chart-loading {
  min-height: 230px;
  display: grid;
  place-items: center;
  color: var(--muted-2);
  font-size: 11px;
}

.chart-svg {
  width: 100%;
  height: 235px;
  display: block;
  overflow: visible;
}

.chart-grid-line {
  stroke: #edf0f5;
  stroke-width: 1;
}

.chart-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-area {
  fill: url(#areaGradient);
}

.chart-dot {
  fill: #fff;
  stroke: var(--accent);
  stroke-width: 2;
}

.chart-label {
  fill: #9aa2af;
  font-size: 9px;
}

.preview-tag {
  display: inline-flex;
  align-items: center;
  height: 24px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 0 9px;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.insight-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.insight-item {
  border-left: 2px solid #ddd9ff;
  padding-left: 11px;
  color: #485263;
  font-size: 12px;
  line-height: 1.55;
}

.insight-item strong {
  color: var(--text);
}

.ask-box {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  margin-top: 18px;
  border-radius: 12px;
  background: #f7f6ff;
  color: #7167a6;
  padding: 11px 12px;
  font-size: 10px;
  line-height: 1.4;
}

.spark {
  color: var(--accent);
  font-size: 13px;
}

.skeleton-line {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, #f1f3f6, #fafbfc, #f1f3f6);
}

.skeleton-line.short {
  width: 70%;
}

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  border-bottom: 1px solid #eef1f5;
  padding: 11px 8px;
  text-align: right;
  white-space: nowrap;
  font-size: 11px;
}

th {
  color: var(--muted-2);
  font-size: 9px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

th:first-child,
td:first-child {
  text-align: left;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.manager-name {
  font-weight: 750;
  color: #263041;
}

.manager-meta {
  display: block;
  margin-top: 2px;
  color: var(--muted-2);
  font-size: 9px;
  font-weight: 500;
}

.empty-cell {
  text-align: center !important;
  color: var(--muted-2);
  padding: 30px 8px;
}

.funnel {
  padding: 3px 0 2px;
}

.funnel-row {
  margin-bottom: 10px;
}

.funnel-topline {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 7px;
  font-size: 11px;
}

.funnel-topline span {
  color: var(--muted);
}

.funnel-topline strong {
  font-size: 12px;
}

.funnel-track {
  width: 100%;
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #f0f2f6;
}

.funnel-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #7968ff, #998cff);
  transition: width 320ms ease;
}

.funnel-bar.full {
  width: 100%;
}

.conversion-row {
  display: flex;
  justify-content: space-between;
  margin: 4px 0 12px;
  padding: 0 3px;
  color: var(--muted-2);
  font-size: 9px;
}

.conversion-row strong {
  color: var(--accent);
}

.quality-panel {
  margin-top: 0;
}

.quality-state {
  display: inline-flex;
  align-items: center;
  min-height: 27px;
  border-radius: 999px;
  background: #f1f3f7;
  color: #687385;
  padding: 0 10px;
  font-size: 9px;
  font-weight: 750;
}

.quality-state.good {
  background: var(--green-soft);
  color: var(--green);
}

.quality-state.warning {
  background: var(--amber-soft);
  color: var(--amber);
}

.quality-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.quality-item {
  min-width: 0;
  border-radius: 12px;
  background: var(--surface-soft);
  padding: 12px;
}

.quality-item span {
  display: block;
  color: var(--muted);
  font-size: 9px;
}

.quality-item strong {
  display: block;
  margin-top: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
}

.error-banner {
  margin-bottom: 14px;
  border: 1px solid #ffd8d8;
  border-radius: 12px;
  background: #fff3f3;
  color: #b94e4e;
  padding: 11px 13px;
  font-size: 11px;
}

.hidden {
  display: none !important;
}

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

  .dashboard-grid,
  .dashboard-grid.equal {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    padding: 14px 16px;
  }

  .brand {
    padding-bottom: 10px;
  }

  .nav,
  .sidebar-footer {
    display: none;
  }

  .topbar,
  .filter-bar,
  .content {
    padding-left: 18px;
    padding-right: 18px;
  }

  .topbar {
    min-height: auto;
  }

  .filter-bar {
    flex-wrap: wrap;
    align-items: center;
  }

  .filter-context {
    width: 100%;
    margin-left: 0;
  }
}

@media (max-width: 560px) {
  .topbar {
    align-items: flex-start;
  }

  .page-subtitle,
  .ghost-button {
    display: none;
  }

  .filter-group {
    width: 100%;
  }

  .date-range {
    width: 100%;
  }

  input[type="date"],
  select {
    width: 100%;
  }

  .kpi-grid,
  .quality-grid {
    grid-template-columns: 1fr;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }
}
