:root {
  color-scheme: light;
  --accent: #ffd426;
  --accent-soft: #fff7cc;
  --background: #f5f6f4;
  --border: #dfe1dc;
  --border-strong: #b8bbb4;
  --danger: #c9362b;
  --danger-soft: #fff0ee;
  --ink: #11120f;
  --muted: #686b64;
  --panel: #ffffff;
  --success: #147a50;
  --success-soft: #eaf7f0;
  --warning: #a76b00;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html {
  background: var(--background);
  color: var(--ink);
  font-family: Inter, Arial, Helvetica, sans-serif;
  line-height: 1.45;
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
}

button,
input,
select {
  color: inherit;
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(255, 212, 38, 0.52);
  outline-offset: 2px;
}

img {
  display: block;
}

[hidden] {
  display: none;
}

.brand {
  display: block;
  height: 28px;
  overflow: hidden;
  position: relative;
  text-decoration: none;
  width: 182px;
}

.brand img {
  height: auto;
  left: -35px;
  max-width: none;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 252px;
}

.eyebrow {
  color: var(--muted);
  display: block;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
  text-transform: uppercase;
}

.login-view {
  align-items: center;
  background: #fafbf9;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  overflow: hidden;
  padding: 40px 24px;
  position: relative;
}

.login-grid {
  background-image:
    linear-gradient(rgba(17, 18, 15, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(17, 18, 15, 0.055) 1px, transparent 1px);
  background-size: 68px 68px;
  inset: 0;
  mask-image: linear-gradient(to bottom, #000 0%, rgba(0, 0, 0, 0.62) 70%, transparent 100%);
  pointer-events: none;
  position: absolute;
}

.login-shell {
  display: grid;
  gap: 56px;
  max-width: 440px;
  position: relative;
  width: 100%;
  z-index: 1;
}

.login-panel {
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  box-shadow: 18px 18px 0 var(--accent);
  padding: 36px;
}

.login-heading {
  margin-bottom: 30px;
}

.login-heading h1,
.page-heading h1,
.section-heading h2 {
  margin: 0;
}

.login-heading h1 {
  font-size: 30px;
  line-height: 1.15;
  margin-top: 7px;
}

#login-form {
  display: grid;
  gap: 18px;
}

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

.field > span:first-child {
  font-size: 13px;
  font-weight: 650;
}

.field input {
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  height: 48px;
  min-width: 0;
  padding: 0 13px;
  width: 100%;
}

.field input:hover {
  border-color: #7b7e77;
}

.field input:focus {
  border-color: var(--ink);
  outline: none;
}

.password-field {
  display: block;
  position: relative;
}

.password-field input {
  padding-right: 48px;
}

.icon-button {
  align-items: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  display: inline-flex;
  flex: 0 0 auto;
  height: 38px;
  justify-content: center;
  padding: 0;
  transition: background-color 150ms ease, border-color 150ms ease, transform 150ms ease;
  width: 38px;
}

.icon-button:hover {
  background: #f0f1ee;
  border-color: var(--border-strong);
}

.icon-button:active {
  transform: translateY(1px);
}

.icon-button img {
  height: 17px;
  width: 17px;
}

.password-toggle {
  border: 0;
  height: 46px;
  position: absolute;
  right: 1px;
  top: 1px;
  width: 44px;
}

.primary-button,
.compact-button {
  align-items: center;
  border: 1px solid var(--ink);
  border-radius: 4px;
  display: inline-flex;
  font-weight: 700;
  justify-content: center;
}

.primary-button {
  background: var(--accent);
  gap: 12px;
  height: 50px;
  margin-top: 4px;
  padding: 0 20px;
  width: 100%;
}

.primary-button:hover {
  background: #ffdf4d;
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.primary-button img {
  height: 17px;
  width: 17px;
}

.form-error {
  background: var(--danger-soft);
  border-left: 3px solid var(--danger);
  color: #7d2019;
  font-size: 13px;
  margin: 0;
  padding: 10px 12px;
}

.login-meta {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 12px;
  gap: 8px;
}

.status-dot {
  background: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(20, 122, 80, 0.12);
  display: inline-block;
  flex: 0 0 auto;
  height: 8px;
  width: 8px;
}

.app-header {
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--border);
  height: 64px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.app-header-inner {
  align-items: center;
  display: flex;
  height: 100%;
  margin: 0 auto;
  max-width: 1500px;
  padding: 0 32px;
}

.brand-compact {
  height: 20px;
  width: 128px;
}

.brand-compact img {
  left: -24px;
  width: 177px;
}

.header-divider {
  align-self: stretch;
  border-left: 1px solid var(--border);
  margin: 15px 16px;
}

.product-name {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}

.header-project {
  align-items: center;
  display: flex;
  gap: 10px;
  margin-left: auto;
}

.header-project label {
  color: var(--muted);
  font-size: 12px;
}

.select-shell {
  display: inline-flex;
  position: relative;
}

.select-shell select {
  appearance: none;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
  font-weight: 650;
  height: 38px;
  min-width: 154px;
  padding: 0 36px 0 12px;
}

.select-shell img {
  height: 15px;
  pointer-events: none;
  position: absolute;
  right: 11px;
  top: 12px;
  width: 15px;
}

.header-actions {
  align-items: center;
  display: flex;
  gap: 8px;
  margin-left: 20px;
}

.updated-at {
  color: var(--muted);
  font-size: 11px;
  margin-right: 4px;
  white-space: nowrap;
}

.dashboard {
  margin: 0 auto;
  max-width: 1500px;
  padding: 42px 32px 26px;
}

.page-heading {
  align-items: flex-end;
  display: flex;
  justify-content: space-between;
}

.page-heading h1 {
  font-size: 36px;
  line-height: 1.1;
  margin-top: 6px;
}

.sync-state {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 12px;
  gap: 9px;
  padding-bottom: 5px;
}

.sync-state.is-stale .status-dot {
  background: var(--warning);
  box-shadow: 0 0 0 4px rgba(167, 107, 0, 0.12);
}

.period-toolbar {
  align-items: center;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 18px;
  margin-top: 30px;
  min-height: 55px;
  padding-bottom: 14px;
}

.segmented-control {
  background: #e9ebe7;
  border-radius: 5px;
  display: inline-flex;
  gap: 2px;
  padding: 3px;
}

.segmented-control button {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 3px;
  color: #4f524c;
  display: inline-flex;
  font-size: 12px;
  font-weight: 650;
  gap: 7px;
  height: 34px;
  justify-content: center;
  padding: 0 13px;
  white-space: nowrap;
}

.segmented-control button:hover {
  color: var(--ink);
}

.segmented-control button.is-active {
  background: #fff;
  box-shadow: 0 1px 3px rgba(17, 18, 15, 0.12);
  color: var(--ink);
}

.segmented-control button img {
  height: 14px;
  width: 14px;
}

.custom-range {
  align-items: end;
  display: flex;
  gap: 8px;
}

.custom-range label {
  color: var(--muted);
  display: grid;
  font-size: 10px;
  gap: 2px;
}

.custom-range input {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  height: 34px;
  padding: 0 8px;
  width: 132px;
}

.compact-button {
  background: var(--ink);
  color: #fff;
  font-size: 11px;
  height: 34px;
  padding: 0 13px;
}

.period-label {
  color: var(--muted);
  font-size: 12px;
  margin-left: auto;
  white-space: nowrap;
}

.metric-grid {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-top: 24px;
}

.metric {
  min-height: 154px;
  min-width: 0;
  padding: 22px;
  position: relative;
}

.metric + .metric {
  border-left: 1px solid var(--border);
}

.metric-primary::before {
  background: var(--accent);
  content: "";
  height: 4px;
  left: -1px;
  position: absolute;
  right: -1px;
  top: -1px;
}

.metric-label {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 12px;
  gap: 8px;
  white-space: nowrap;
}

.metric-label img {
  height: 16px;
  width: 16px;
}

.metric strong {
  display: block;
  font-size: 38px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  margin-top: 22px;
}

.metric-delta,
.metric-note {
  display: block;
  font-size: 11px;
  margin-top: 10px;
}

.metric-delta,
.metric-note {
  color: var(--muted);
}

.metric-delta.is-positive {
  color: var(--success);
}

.metric-delta.is-negative,
.metric-note.is-danger {
  color: var(--danger);
}

.analytics-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(0, 2.1fr) minmax(280px, 0.9fr);
  margin-top: 20px;
}

.chart-panel,
.period-summary {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  min-width: 0;
}

.chart-panel {
  padding: 24px;
}

.period-summary {
  padding: 24px;
}

.section-heading {
  align-items: flex-start;
  display: flex;
  justify-content: space-between;
}

.section-heading h2 {
  font-size: 20px;
  line-height: 1.25;
  margin-top: 5px;
}

.chart-legend {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 11px;
  gap: 14px;
  padding-top: 4px;
}

.chart-legend span {
  align-items: center;
  display: flex;
  gap: 6px;
}

.legend-line {
  display: inline-block;
  height: 2px;
  width: 17px;
}

.legend-total {
  background: var(--ink);
}

.legend-unique {
  background: var(--success);
}

.chart-wrap {
  aspect-ratio: 2.35 / 1;
  margin-top: 22px;
  min-height: 250px;
  position: relative;
  width: 100%;
}

#leads-chart {
  display: block;
  height: 100%;
  width: 100%;
}

.chart-tooltip {
  background: var(--ink);
  border-radius: 4px;
  color: #fff;
  font-size: 11px;
  line-height: 1.5;
  min-width: 126px;
  padding: 8px 10px;
  pointer-events: none;
  position: absolute;
  transform: translate(-50%, calc(-100% - 12px));
  z-index: 3;
}

.comparison-list {
  margin: 22px 0 0;
}

.comparison-list div {
  align-items: center;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  min-height: 45px;
}

.comparison-list dt {
  color: var(--muted);
  font-size: 12px;
}

.comparison-list dd {
  font-size: 13px;
  font-weight: 750;
  margin: 0;
}

.comparison-list dd.is-positive {
  color: var(--success);
}

.comparison-list dd.is-negative {
  color: var(--danger);
}

.period-insight {
  align-items: flex-start;
  background: var(--accent-soft);
  border-radius: 4px;
  display: flex;
  gap: 10px;
  margin-top: 18px;
  padding: 13px;
}

.insight-mark {
  background: var(--accent);
  border: 1px solid var(--ink);
  border-radius: 50%;
  flex: 0 0 auto;
  height: 9px;
  margin-top: 4px;
  width: 9px;
}

.period-insight p {
  font-size: 11px;
  margin: 0;
}

.breakdown-section,
.leads-section {
  border-top: 1px solid var(--border-strong);
  margin-top: 42px;
  padding-top: 28px;
}

.section-heading-wide {
  align-items: flex-end;
}

.breakdown-grid {
  display: grid;
  gap: 46px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 25px;
}

.breakdown-column {
  min-width: 0;
}

.breakdown-column h3 {
  font-size: 12px;
  margin: 0 0 13px;
  text-transform: uppercase;
}

.breakdown-list {
  display: grid;
  gap: 13px;
}

.breakdown-row {
  min-width: 0;
}

.breakdown-copy {
  align-items: center;
  display: flex;
  font-size: 12px;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 5px;
}

.breakdown-copy span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.breakdown-copy strong {
  font-variant-numeric: tabular-nums;
}

.breakdown-track {
  background: #e5e7e2;
  height: 4px;
  overflow: hidden;
  width: 100%;
}

.breakdown-fill {
  background: var(--ink);
  height: 100%;
  min-width: 2px;
}

.breakdown-column:first-child .breakdown-fill {
  background: var(--accent);
}

.breakdown-empty {
  color: var(--muted);
  font-size: 12px;
  padding: 12px 0;
}

.site-link {
  align-items: center;
  color: var(--ink);
  display: inline-flex;
  font-size: 12px;
  font-weight: 650;
  gap: 7px;
  text-decoration: none;
}

.site-link:hover {
  text-decoration: underline;
}

.site-link img {
  height: 15px;
  width: 15px;
}

.table-scroll {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-top: 22px;
  overflow-x: auto;
}

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

th,
td {
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  padding: 13px 16px;
  text-align: left;
  vertical-align: middle;
}

th {
  background: #f3f4f1;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

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

tbody tr:hover {
  background: #fbfcfa;
}

.lead-number {
  font-variant-numeric: tabular-nums;
  font-weight: 750;
}

.lead-kind,
.mail-badge {
  border-radius: 999px;
  display: inline-flex;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  padding: 6px 8px;
  white-space: nowrap;
}

.lead-kind {
  background: var(--success-soft);
  color: var(--success);
}

.lead-kind.is-repeat {
  background: var(--accent-soft);
  color: #755000;
}

.mail-badge {
  background: #eceeea;
  color: #4a4d47;
}

.mail-badge.is-sent {
  background: var(--success-soft);
  color: var(--success);
}

.mail-badge.is-failed {
  background: var(--danger-soft);
  color: var(--danger);
}

.empty-state {
  color: var(--muted);
  font-size: 13px;
  padding: 34px 20px;
  text-align: center;
}

.dashboard-footer {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 10px;
  justify-content: space-between;
  padding: 28px 0 0;
}

.loading-overlay {
  align-items: center;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 8px 30px rgba(17, 18, 15, 0.12);
  display: flex;
  font-size: 12px;
  font-weight: 700;
  gap: 9px;
  left: 50%;
  padding: 10px 13px;
  position: fixed;
  top: 78px;
  transform: translateX(-50%);
  z-index: 50;
}

.loading-mark {
  animation: loading-spin 750ms linear infinite;
  border: 2px solid #d7d9d4;
  border-radius: 50%;
  border-top-color: var(--ink);
  height: 14px;
  width: 14px;
}

@keyframes loading-spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 1120px) {
  .metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .metric:nth-child(4) {
    border-left: 0;
    border-top: 1px solid var(--border);
  }

  .metric:nth-child(5) {
    border-top: 1px solid var(--border);
  }

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

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

  .comparison-list div {
    display: block;
    min-height: 0;
    padding: 13px 12px 8px 0;
  }

  .comparison-list dd {
    margin-top: 6px;
  }
}

@media (max-width: 840px) {
  .app-header-inner,
  .dashboard {
    padding-left: 20px;
    padding-right: 20px;
  }

  .product-name,
  .header-divider,
  .header-project label,
  .updated-at {
    display: none;
  }

  .header-project {
    margin-left: auto;
  }

  .select-shell select {
    min-width: 130px;
  }

  .period-toolbar {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .segmented-control {
    max-width: 100%;
    overflow-x: auto;
  }

  .period-label {
    margin-left: 0;
    width: 100%;
  }

  .breakdown-grid {
    gap: 30px;
    grid-template-columns: 1fr;
  }

  .chart-wrap {
    aspect-ratio: 1.7 / 1;
  }
}

@media (max-width: 620px) {
  .login-view {
    align-items: flex-start;
    padding: 34px 18px;
  }

  .login-shell {
    gap: 42px;
  }

  .login-panel {
    box-shadow: 9px 9px 0 var(--accent);
    padding: 26px 22px;
  }

  .app-header {
    height: auto;
    min-height: 58px;
  }

  .app-header-inner {
    min-height: 58px;
    padding: 0 14px;
  }

  .brand-compact {
    height: 18px;
    width: 112px;
  }

  .brand-compact img {
    left: -21px;
    width: 155px;
  }

  .header-project {
    display: none;
  }

  .header-actions {
    margin-left: auto;
  }

  .dashboard {
    padding: 28px 14px 18px;
  }

  .page-heading {
    align-items: flex-start;
    gap: 18px;
  }

  .page-heading h1 {
    font-size: 30px;
  }

  .sync-state {
    max-width: 145px;
    padding-top: 3px;
    text-align: right;
  }

  .period-toolbar {
    display: block;
    margin-top: 24px;
  }

  .segmented-control {
    display: flex;
    scrollbar-width: none;
  }

  .segmented-control::-webkit-scrollbar {
    display: none;
  }

  .custom-range {
    align-items: stretch;
    display: grid;
    grid-template-columns: 1fr 1fr;
    margin-top: 10px;
  }

  .custom-range input {
    width: 100%;
  }

  .custom-range .compact-button {
    grid-column: 1 / -1;
  }

  .period-label {
    display: block;
    margin-top: 10px;
  }

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

  .metric {
    min-height: 132px;
    padding: 17px;
  }

  .metric + .metric {
    border-left: 0;
  }

  .metric:nth-child(even) {
    border-left: 1px solid var(--border);
  }

  .metric:nth-child(n + 3) {
    border-top: 1px solid var(--border);
  }

  .metric:nth-child(5) {
    grid-column: 1 / -1;
  }

  .metric strong {
    font-size: 32px;
    margin-top: 18px;
  }

  .metric-label {
    white-space: normal;
  }

  .chart-panel,
  .period-summary {
    padding: 18px;
  }

  .chart-legend {
    gap: 9px;
  }

  .chart-wrap {
    aspect-ratio: 1.15 / 1;
    min-height: 240px;
  }

  .comparison-list {
    grid-template-columns: 1fr 1fr;
  }

  .breakdown-section,
  .leads-section {
    margin-top: 34px;
  }

  .site-link {
    font-size: 0;
  }

  .site-link img {
    height: 18px;
    width: 18px;
  }

  .dashboard-footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto;
    transition-duration: 0.01ms;
  }
}

body [hidden] {
  display: none;
}
