:root {
  --bg: #f5f7f4;
  --surface: #ffffff;
  --surface-2: #eef2ed;
  --ink: #17211d;
  --muted: #68736e;
  --line: #dce4de;
  --green: #2f7d5c;
  --green-soft: #dcefe6;
  --blue: #4b77be;
  --blue-soft: #e0e8f6;
  --coral: #d3644b;
  --coral-soft: #f6e4df;
  --gold: #b58b22;
  --gold-soft: #f2e9cd;
  --violet: #7b63b7;
  --shadow: 0 16px 35px rgba(18, 32, 25, 0.08);
  --radius: 8px;
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

body.auth-locked {
  min-height: 100vh;
  overflow: hidden;
}

.auth-lock-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(47, 125, 92, 0.12), rgba(75, 119, 190, 0.08)),
    var(--bg);
}

.auth-card {
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 22px 70px rgba(23, 33, 29, 0.16);
  padding: 28px;
}

.auth-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--green);
  color: white;
  font-size: 26px;
  font-weight: 900;
  margin-bottom: 18px;
}

.auth-card h1 {
  margin: 4px 0 22px;
  font-size: 30px;
  line-height: 1.08;
}

.auth-card label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.auth-card input {
  min-width: 0;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font-size: 20px;
  padding: 0 14px;
}

.auth-card .confirm-button {
  width: 100%;
  margin-top: 16px;
}

.auth-message {
  min-height: 22px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.auth-message[data-tone="error"] {
  color: var(--coral);
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 16px;
  background: #14221c;
  color: #f7fbf7;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #75b28c;
  color: #0e1b15;
  font-weight: 850;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 2px;
  color: #b9c8bf;
  font-size: 12px;
}

.nav-tabs {
  display: grid;
  gap: 8px;
}

.nav-tab {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 11px;
  background: transparent;
  color: #c9d8cf;
  text-align: left;
  cursor: pointer;
}

.nav-tab:hover,
.nav-tab.active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.14);
}

.side-note {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #bfd0c5;
  font-size: 12px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #7fd197;
}

.main {
  min-width: 0;
  padding: 20px 22px 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 14px;
}

.topbar-actions {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--green);
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
  font-size: 12px;
}

h1 {
  margin: 0;
  font-size: clamp(26px, 2.6vw, 38px);
  line-height: 1.05;
  letter-spacing: 0;
}

.generated {
  color: var(--muted);
  font-size: 11px;
  text-align: right;
  max-width: 260px;
}

.filters {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  gap: 10px;
  padding: 10px;
  margin-bottom: 14px;
  background: rgba(245, 247, 244, 0.94);
  backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.filters-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.filters-toolbar-copy {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.filters-summary {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.filters-summary-chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.filters-summary-chip.tone-current {
  background: var(--green-soft);
  border-color: rgba(47, 125, 92, 0.2);
  color: var(--green);
}

.filters-summary-chip.tone-compare {
  background: var(--blue-soft);
  border-color: rgba(75, 119, 190, 0.2);
  color: var(--blue);
}

.filters-summary-chip.tone-muted {
  background: #f8faf7;
  color: var(--muted);
}

.filters-toggle {
  min-height: 34px;
  padding-inline: 12px;
  font-weight: 760;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.filters-toggle-icon {
  display: inline-block;
  width: 14px;
  text-align: center;
  font-weight: 820;
}

.filters-body {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.filters.is-collapsed {
  gap: 6px;
  padding-block: 8px;
}

.filters.is-collapsed .filters-toolbar {
  align-items: center;
}

.filter-group {
  min-width: 0;
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.filter-group-general {
  grid-column: 1 / -1;
  background: #f8faf7;
}

.filter-group-ads {
  background: rgba(47, 125, 92, 0.08);
  border-color: rgba(47, 125, 92, 0.16);
}

.filter-group-influencer {
  background: rgba(123, 99, 183, 0.08);
  border-color: rgba(123, 99, 183, 0.16);
}

.filter-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.filter-group-title {
  color: var(--ink);
  font-size: 11px;
  font-weight: 820;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.filter-grid {
  display: grid;
  gap: 8px;
}

.filter-grid-general {
  grid-template-columns: repeat(6, minmax(120px, 1fr));
}

.filter-grid-ads {
  grid-template-columns: repeat(3, minmax(120px, 1fr));
}

.filter-grid-influencer {
  grid-template-columns: repeat(3, minmax(120px, 1fr));
}

.filters label,
.date-range-control {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.filters label > span,
.date-range-control > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.filters input,
.filters select {
  min-width: 0;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  padding: 7px 9px;
  outline: none;
}

.filters input:focus,
.filters select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(47, 125, 92, 0.12);
}

.date-range-control {
  position: relative;
}

.filter-grid-general .date-range-control {
  grid-column: span 2;
}

.date-range-button {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 9px 6px 11px;
  cursor: pointer;
  text-align: left;
}

.date-range-button strong {
  font-size: 12px;
  font-weight: 820;
}

.date-range-button em {
  min-width: 0;
  color: var(--muted);
  font-style: normal;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.range-current .date-range-button {
  border-left: 5px solid var(--green);
}

.range-compare .date-range-button {
  border-left: 5px solid var(--blue);
}

.range-current .date-range-button:focus,
.range-current.open .date-range-button {
  border-color: var(--green);
  border-left-color: var(--green);
  box-shadow: 0 0 0 3px rgba(47, 125, 92, 0.12);
}

.range-compare .date-range-button:focus,
.range-compare.open .date-range-button {
  border-color: var(--blue);
  border-left-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(75, 119, 190, 0.13);
}

.date-range-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 20;
  display: none;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 18px 42px rgba(18, 32, 25, 0.16);
}

.date-range-control.open .date-range-menu {
  display: grid;
}

.date-range-menu label {
  display: grid;
  gap: 5px;
}

.date-range-presets {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.date-preset-button {
  min-height: 31px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8faf7;
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.date-preset-button:hover,
.date-preset-button:focus-visible {
  border-color: color-mix(in srgb, var(--green) 48%, var(--line));
  background: #eef5f0;
  outline: none;
}

.range-compare .date-preset-button:hover,
.range-compare .date-preset-button:focus-visible {
  border-color: color-mix(in srgb, var(--blue) 48%, var(--line));
  background: #eef3fb;
}

.date-range-menu .date-input {
  min-height: 34px;
  width: 100%;
}

.date-range-menu .confirm-button {
  grid-column: 1 / -1;
}

.confirm-button {
  border: 0;
  border-radius: 7px;
  min-height: 33px;
  padding: 7px 10px;
  background: var(--ink);
  color: #ffffff;
  font-weight: 760;
  cursor: pointer;
}

.range-current .confirm-button {
  background: var(--green);
}

.range-compare .confirm-button {
  background: var(--blue);
}

.confirm-button:hover {
  filter: brightness(0.94);
}

.filter-grid-general .search-field {
  grid-column: span 2;
}

.content {
  display: grid;
  gap: 14px;
}

.compare-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8faf7;
  padding: 9px 12px;
  color: var(--muted);
  font-size: 12px;
}

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

.compare-strip span {
  width: 1px;
  height: 18px;
  background: var(--line);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(126px, 1fr));
  gap: 10px;
}

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

.kpi-card {
  padding: 12px;
  min-height: 108px;
  display: grid;
  align-content: space-between;
  gap: 6px;
  position: relative;
  text-align: left;
  color: inherit;
  font: inherit;
  appearance: none;
}

.kpi-card.is-clickable {
  cursor: pointer;
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease,
    transform 140ms ease;
}

.kpi-card.is-clickable:hover,
.kpi-card.is-clickable:focus-visible {
  border-color: color-mix(in srgb, var(--green) 55%, var(--line));
  box-shadow: 0 12px 26px rgba(25, 45, 35, 0.12);
  outline: none;
  transform: translateY(-1px);
}

.kpi-card.active {
  border-color: var(--green);
  box-shadow:
    0 0 0 2px rgba(47, 125, 92, 0.16),
    var(--shadow);
}

.kpi-card.active::after {
  content: "";
  position: absolute;
  top: 10px;
  right: 10px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}

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

.kpi-value {
  font-size: 28px;
  font-weight: 850;
  line-height: 1;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.kpi-sub {
  color: var(--muted);
  font-size: 11px;
  min-height: 16px;
  line-height: 1.28;
}

.panel-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.85fr);
  gap: 14px;
}

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

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

.panel.panel-explorer {
  display: grid;
  gap: 12px;
}

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

.panel-actions {
  min-width: 180px;
}

.panel-actions-inline {
  display: grid;
  grid-template-columns: repeat(2, minmax(140px, 1fr));
  gap: 8px;
}

.panel-control {
  display: grid;
  gap: 4px;
}

.panel-control span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.panel-select {
  min-width: 0;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  padding: 7px 9px;
  outline: none;
}

.panel-select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(47, 125, 92, 0.12);
}

.panel-control.is-disabled {
  opacity: 0.48;
}

.panel-select:disabled {
  background: #eef2ed;
  color: #8a9690;
  cursor: not-allowed;
}

.explorer-controls {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: linear-gradient(180deg, #f9fbf8, #f3f7f3);
}

.explorer-control-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.explorer-chart {
  min-width: 0;
}

.explorer-chart .chart.pie-chart {
  min-height: 286px;
}

.explorer-table-wrap {
  max-height: 280px;
}

.panel-title {
  margin: 0;
  font-size: 15px;
  font-weight: 820;
}

.panel-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.chart {
  width: 100%;
  min-height: 248px;
}

.chart.small {
  min-height: 214px;
}

.chart svg {
  width: 100%;
  height: 100%;
  display: block;
}

.line-chart-figure {
  position: relative;
  min-width: 0;
}

.line-chart-figure svg {
  display: block;
  width: 100%;
  height: auto;
}

.line-hover-card {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 3;
  min-width: 210px;
  max-width: 280px;
  display: grid;
  gap: 5px;
  padding: 10px 12px;
  border: 1px solid rgba(23, 33, 29, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 14px 30px rgba(18, 32, 25, 0.16);
  color: var(--ink);
  font-size: 11px;
  line-height: 1.35;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 120ms ease;
}

.line-hover-card.visible {
  opacity: 1;
  visibility: visible;
}

.line-hover-card strong {
  font-size: 12px;
}

.line-hover-card span {
  display: grid;
  grid-template-columns: 9px minmax(0, 1fr) max-content;
  align-items: center;
  gap: 7px;
  color: var(--muted);
}

.line-hover-card b {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-weight: 720;
}

.line-hover-card em {
  color: var(--ink);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  font-style: normal;
}

.line-hover-card i {
  width: 9px;
  height: 9px;
  border-radius: 99px;
  flex: 0 0 auto;
}

.pie-chart-shell {
  display: grid;
  grid-template-columns: minmax(220px, 260px) minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  min-height: 266px;
}

.pie-chart-figure {
  display: grid;
  place-items: center;
  position: relative;
}

.pie-chart-svg {
  display: block;
  width: min(100%, 232px);
  height: auto;
}

.pie-hover-card {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 3;
  min-width: 170px;
  max-width: 240px;
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid rgba(23, 33, 29, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 14px 30px rgba(18, 32, 25, 0.16);
  color: var(--ink);
  font-size: 11px;
  line-height: 1.35;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 120ms ease;
}

.pie-hover-card.visible {
  opacity: 1;
  visibility: visible;
}

.pie-hover-card strong {
  font-size: 12px;
}

.pie-chart-legend {
  display: grid;
  gap: 8px;
  min-width: 0;
  max-height: 300px;
  overflow: auto;
}

.pie-legend-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  gap: 12px;
  align-items: center;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f9fbf8;
}

.pie-legend-main {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.pie-legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 99px;
  flex: 0 0 auto;
}

.pie-legend-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
}

.pie-legend-stats {
  display: grid;
  justify-items: end;
  gap: 2px;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.pie-legend-stats strong {
  color: var(--ink);
  font-size: 12px;
}

.pie-legend-secondary {
  font-size: 10px;
}

.scatter-chart-shell {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: start;
}

.matrix-highlight-controls {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8faf7;
}

.matrix-highlight-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.matrix-highlight-head div {
  display: grid;
  gap: 2px;
}

.matrix-highlight-head strong {
  font-size: 12px;
  color: var(--ink);
}

.matrix-highlight-head span {
  color: var(--muted);
  font-size: 11px;
}

.matrix-dimension-buttons,
.matrix-highlight-values {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.matrix-dimension-button,
.matrix-value-button,
.matrix-clear-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-size: 11px;
  font-weight: 760;
}

.matrix-dimension-button {
  padding: 7px 10px;
}

.matrix-value-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 220px;
  padding: 6px 9px;
}

.matrix-value-button span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.matrix-value-button em {
  color: var(--muted);
  font-style: normal;
  font-size: 10px;
}

.matrix-clear-button {
  padding: 5px 9px;
  color: var(--muted);
}

.matrix-dimension-button.active,
.matrix-value-button.active {
  border-color: var(--green);
  background: var(--green-soft);
  color: #1d6043;
}

.scatter-chart-figure {
  min-width: 0;
  position: relative;
}

.scatter-chart-figure svg {
  display: block;
  width: 100%;
  height: auto;
}

.scatter-hover-card {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 3;
  min-width: 190px;
  max-width: 260px;
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid rgba(23, 33, 29, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 14px 30px rgba(18, 32, 25, 0.16);
  color: var(--ink);
  font-size: 11px;
  line-height: 1.35;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 120ms ease;
}

.scatter-hover-card.visible {
  opacity: 1;
  visibility: visible;
}

.scatter-hover-card strong {
  font-size: 12px;
}

.scatter-chart-note {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.scatter-row-label {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.scatter-legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 99px;
  flex: 0 0 auto;
}

.scatter-row-label span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
}

.scatter-table-wrap {
  max-height: 320px;
}

.scatter-mini-table th,
.scatter-mini-table td {
  font-size: 11px;
}

.scatter-mini-table tr.is-muted {
  opacity: 0.38;
}

.scatter-mini-table tr.is-highlighted td {
  background: rgba(47, 125, 92, 0.05);
}

.scatter-mini-table td:first-child {
  min-width: 240px;
}

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

.metric-row {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) minmax(120px, max-content);
  gap: 8px;
  align-items: center;
}

.metric-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
  font-weight: 700;
  font-size: 12px;
}

.metric-value {
  text-align: right;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.bar-track {
  grid-column: 1 / -1;
  height: 8px;
  border-radius: 99px;
  background: var(--surface-2);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--green);
}

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

.alert-card {
  padding: 11px;
  display: grid;
  gap: 6px;
}

.alert-card strong {
  font-size: 12px;
}

.alert-card span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

.tone-good {
  background: linear-gradient(180deg, #ffffff, var(--green-soft));
}

.tone-warn {
  background: linear-gradient(180deg, #ffffff, var(--gold-soft));
}

.tone-bad {
  background: linear-gradient(180deg, #ffffff, var(--coral-soft));
}

.table-panel {
  overflow: hidden;
}

.table-header {
  padding: 12px 14px 0;
}

.table-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.ghost-button {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  padding: 6px 9px;
  color: var(--ink);
  cursor: pointer;
}

.ghost-button:hover {
  border-color: var(--green);
}

.budget-settings-button {
  min-height: 34px;
  padding-inline: 12px;
  font-weight: 760;
}

body[data-budget-mode="viewer"] .budget-settings-button,
body[data-budget-mode="viewer"] [data-open-budget="true"] {
  display: none;
}

.budget-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(16, 24, 20, 0.38);
  backdrop-filter: blur(3px);
}

.budget-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 41;
  width: min(860px, 100vw);
  height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 0;
  padding: 22px 22px 20px;
  background: #f7faf7;
  border-left: 1px solid var(--line);
  box-shadow: -24px 0 48px rgba(18, 32, 25, 0.18);
  transform: translateX(100%);
  transition: transform 180ms ease;
}

.budget-drawer.open {
  transform: translateX(0);
}

.budget-drawer-header,
.budget-drawer-footer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.budget-drawer-header {
  padding-bottom: 16px;
}

.budget-drawer-header h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.05;
}

.budget-drawer-body {
  overflow: auto;
  display: grid;
  gap: 18px;
  padding-block: 4px 18px;
}

.budget-drawer-footer {
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

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

.budget-year-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.budget-year-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 12px;
}

.budget-year-header h3 {
  margin: 0;
  font-size: 18px;
}

.budget-year-table {
  width: 100%;
  border-collapse: collapse;
}

.budget-year-table th,
.budget-year-table td {
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  vertical-align: middle;
}

.budget-year-table th {
  position: static;
  background: #f8faf7;
}

.budget-year-table .budget-month-label {
  font-weight: 760;
}

.budget-input {
  min-width: 0;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  padding: 8px 10px;
  outline: none;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.budget-input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(47, 125, 92, 0.12);
}

.budget-total-cell {
  font-weight: 780;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.budget-year-totals {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  padding: 14px 16px 16px;
  border-top: 1px solid var(--line);
  background: #fbfcfa;
}

.budget-year-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 12px;
  font-weight: 720;
}

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

.budget-panel-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.86fr) minmax(420px, 1.14fr);
  gap: 14px;
}

.budget-structure-grid,
.budget-capacity-stack {
  display: grid;
  gap: 12px;
}

.budget-structure-block {
  display: grid;
  gap: 8px;
}

.budget-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 10px;
}

.budget-panel-stack {
  display: grid;
  gap: 12px;
}

.budget-stat {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfa;
  padding: 10px;
  display: grid;
  gap: 5px;
  min-height: 106px;
  align-content: start;
}

.budget-stat-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 760;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.25;
}

.budget-stat-value {
  font-size: clamp(16px, 2vw, 28px);
  font-weight: 820;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.budget-stat-sub {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.budget-track-card,
.budget-split-card,
.budget-month-card {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfa;
  padding: 12px;
}

.budget-track-card {
  display: grid;
  gap: 10px;
}

.budget-track-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.budget-track-title {
  font-size: 14px;
  font-weight: 800;
}

.budget-track-subtitle {
  color: var(--muted);
  font-size: 12px;
}

.budget-track-shell {
  position: relative;
  height: 12px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.budget-track-fill,
.budget-track-fill-secondary {
  position: absolute;
  inset-block: 0;
  left: 0;
  border-radius: 999px;
}

.budget-track-fill {
  background: var(--green);
}

.budget-track-fill-secondary {
  background: rgba(75, 119, 190, 0.68);
}

.budget-track-marker {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  border-radius: 999px;
  background: var(--ink);
}

.budget-track-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--muted);
  font-size: 12px;
}

.budget-track-legend strong {
  color: var(--ink);
}

.budget-split-card {
  margin-top: 12px;
}

.budget-split-card .metric-list {
  gap: 12px;
}

.budget-capacity-card {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfa;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.budget-capacity-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.budget-capacity-head strong {
  font-size: 18px;
  line-height: 1;
}

.budget-capacity-shell {
  position: relative;
  height: 12px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.budget-capacity-fill {
  position: absolute;
  inset-block: 0;
  left: 0;
  border-radius: 999px;
}

.budget-capacity-fill.actual {
  background: rgba(47, 125, 92, 0.84);
}

.budget-capacity-fill.projected {
  background: rgba(77, 122, 198, 0.64);
}

.budget-capacity-marker {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  border-radius: 999px;
}

.budget-capacity-marker.allocated {
  background: rgba(194, 149, 28, 0.96);
}

.budget-capacity-marker.total {
  background: rgba(23, 33, 29, 0.56);
}

.budget-capacity-legend {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  color: var(--muted);
  font-size: 11px;
}

.budget-capacity-legend strong {
  color: var(--ink);
}

.budget-month-card {
  min-width: 0;
  overflow: auto;
}

.budget-month-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.budget-mini-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  table-layout: fixed;
}

.budget-mini-table th,
.budget-mini-table td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.budget-mini-table th:first-child,
.budget-mini-table td:first-child {
  text-align: left;
  padding-left: 0;
}

.budget-mini-table tr.current-month td {
  color: var(--ink);
  font-weight: 760;
}

.budget-note {
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.budget-plan-table th,
.budget-plan-table td {
  white-space: nowrap;
}

.table-wrap {
  max-height: 380px;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

th,
td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8faf7;
  color: #4d5a54;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0;
}

td.numeric,
th.numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

td a {
  color: var(--blue);
  text-decoration: none;
}

td a:hover {
  text-decoration: underline;
}

.change-chip {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 68px;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

td.numeric .change-chip {
  margin-left: auto;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 3px 8px;
  background: var(--surface-2);
  color: #344139;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.pill.green {
  background: var(--green-soft);
  color: #1d6042;
}

.pill.blue {
  background: var(--blue-soft);
  color: #2d5f9d;
}

.pill.gold {
  background: var(--gold-soft);
  color: #806111;
}

.note-strip {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffdf7;
  padding: 10px 12px;
  color: #5e5540;
  font-size: 12px;
  line-height: 1.35;
}

.empty-state {
  padding: 22px;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 1180px) {
  .filter-grid-general {
    grid-template-columns: repeat(4, minmax(120px, 1fr));
  }

  .filter-grid-ads,
  .filter-grid-influencer {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .kpi-grid {
    grid-template-columns: repeat(4, minmax(130px, 1fr));
  }

  .kpi-value {
    font-size: 25px;
  }

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

  .budget-panel-layout {
    grid-template-columns: 1fr;
  }

  .budget-capacity-legend {
    grid-template-columns: 1fr;
  }

  .explorer-control-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .pie-chart-shell {
    grid-template-columns: 1fr;
  }

  .pie-chart-figure {
    justify-self: start;
  }

  .scatter-chart-shell {
    grid-template-columns: 1fr;
  }

  .alert-grid {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }
}

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

  .sidebar {
    position: static;
    height: auto;
    padding: 16px;
  }

  .nav-tabs {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .nav-tab {
    text-align: center;
  }

  .main {
    padding: 16px 12px 24px;
  }

  .topbar {
    display: grid;
  }

  .generated {
    text-align: left;
  }

  .topbar-actions {
    justify-items: start;
  }

  .filters {
    position: static;
  }

  .filters-toolbar {
    display: grid;
  }

  .filters-body {
    grid-template-columns: 1fr;
  }

  .filter-grid-general,
  .filter-grid-ads,
  .filter-grid-influencer {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .panel-actions-inline {
    grid-template-columns: 1fr;
  }

  .filter-grid-general .date-range-control,
  .filter-grid-general .search-field {
    grid-column: span 2;
  }

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

  .budget-stat-grid {
    grid-template-columns: 1fr;
  }

  .budget-drawer {
    width: 100vw;
    padding-inline: 16px;
  }

  .kpi-value {
    font-size: 24px;
  }

  .explorer-chart .chart.pie-chart {
    min-height: 258px;
  }

  .pie-chart-disc {
    width: min(100%, 196px);
  }

  .alert-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .filters-toggle {
    width: 100%;
    justify-content: center;
  }

  .filter-grid-general,
  .filter-grid-ads,
  .filter-grid-influencer,
  .kpi-grid,
  .nav-tabs {
    grid-template-columns: 1fr;
  }

  .explorer-control-grid {
    grid-template-columns: 1fr;
  }

  .filter-grid-general .date-range-control,
  .filter-grid-general .search-field {
    grid-column: span 1;
  }

  .date-range-menu {
    grid-template-columns: 1fr;
  }

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

  .budget-drawer-header,
  .budget-drawer-footer,
  .budget-drawer-actions {
    display: grid;
  }

  .budget-year-table th:nth-child(4),
  .budget-year-table td:nth-child(4),
  .budget-year-table th:nth-child(5),
  .budget-year-table td:nth-child(5) {
    display: none;
  }

  .kpi-value {
    font-size: 28px;
  }
}
