:root {
  --bg: #eef2f1;
  --bg-soft: #f7f9f8;
  --ink: #161a1d;
  --muted: #5f6972;
  --panel: #ffffff;
  --line: #d8e0df;
  --line-strong: #bfcbc8;
  --green: #174f3f;
  --green-dark: #0f352b;
  --gold: #d99a2b;
  --gold-soft: #fff5df;
  --red: #b7332c;
  --red-soft: #fff0ef;
  --blue: #2f5f8a;
  --blue-soft: #eef5fb;
  --shadow: 0 18px 42px rgba(22, 26, 29, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, #f6f8f7 0, var(--bg) 320px),
    var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

a {
  color: inherit;
}

.app-shell {
  min-height: 100vh;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 30px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.app-brand {
  color: var(--green-dark);
  font-size: 1.05rem;
  font-weight: 950;
  letter-spacing: 0;
  text-decoration: none;
}

.app-nav,
.app-header nav {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.92rem;
}

.app-nav a {
  padding: 8px 10px;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 800;
}

.app-nav a:hover,
.app-nav a:focus {
  background: var(--bg-soft);
}

.app-header form,
.logout-form {
  margin: 0;
}

.user-chip {
  max-width: 260px;
  overflow: hidden;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--green-dark);
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-main {
  width: min(1220px, calc(100% - 44px));
  margin: 0 auto;
  padding: 38px 0 82px;
}

.page-hero {
  display: grid;
  gap: 10px;
  max-width: 880px;
  margin-bottom: 28px;
}

.page-hero h1 {
  margin: 0;
  color: var(--green-dark);
  font-size: 2.45rem;
  line-height: 1.08;
}

.page-hero p {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  font-size: 1.03rem;
}

.page-eyebrow,
.section-heading span,
.card-heading span,
.metric span,
.setting-status span {
  color: var(--blue);
  font-size: 0.74rem;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h2 {
  margin-bottom: 8px;
  color: var(--green-dark);
  font-size: 1.35rem;
  line-height: 1.2;
}

h3 {
  margin: 0 0 8px;
  color: var(--green-dark);
  font-size: 1.08rem;
  line-height: 1.25;
}

p,
.muted,
label,
summary,
pre {
  color: var(--muted);
  line-height: 1.55;
}

.dashboard-section {
  margin-top: 28px;
}

.dashboard-section:first-of-type {
  margin-top: 0;
}

.compact-section {
  display: flex;
}

.section-heading {
  display: grid;
  gap: 6px;
  max-width: 820px;
  margin-bottom: 14px;
}

.section-heading p,
.card-heading p,
.payment-panel p,
.limit-settings p {
  margin-bottom: 0;
}

.card-heading {
  display: grid;
  gap: 4px;
  margin-bottom: 16px;
}

.notice,
.error {
  margin: 0 0 18px;
  padding: 13px 15px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 850;
}

.notice {
  background: rgba(23, 79, 63, 0.1);
  border-color: rgba(23, 79, 63, 0.22);
  color: var(--green-dark);
}

.error {
  background: var(--red-soft);
  border-color: rgba(183, 51, 44, 0.2);
  color: var(--red);
}

.intent-banner {
  display: grid;
  gap: 5px;
  margin-bottom: 18px;
  padding: 16px 18px;
  border: 1px solid rgba(217, 154, 43, 0.38);
  border-radius: 8px;
  background: var(--gold-soft);
}

.checkout-intent {
  border-left: 6px solid var(--gold);
}

.intent-banner span {
  color: #735111;
  font-size: 0.74rem;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.intent-banner strong {
  color: var(--green-dark);
  font-size: 1.08rem;
}

.intent-banner p {
  margin: 0;
}

.two-col,
.metric-row,
.settings-grid,
.limit-grid {
  display: grid;
  gap: 16px;
}

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

.auth-grid {
  align-items: stretch;
}

.auth-card {
  display: grid;
  align-content: start;
}

.auth-card > .muted {
  margin-bottom: 16px;
}

.create-account-card {
  border-color: rgba(217, 154, 43, 0.56);
  box-shadow: 0 18px 42px rgba(217, 154, 43, 0.14);
}

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

.settings-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 16px;
}

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

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

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

.metric strong {
  display: block;
  color: var(--green-dark);
  font-size: 2.35rem;
  line-height: 1;
}

.card {
  margin-bottom: 16px;
  padding: 20px;
}

.card.narrow {
  width: min(100%, 540px);
}

.action-grid .card,
.activity-grid .card {
  margin-bottom: 0;
}

.stack {
  display: grid;
  gap: 13px;
}

.stack.subtle {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.compact {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-soft);
}

.hidden {
  display: none !important;
}

label {
  display: grid;
  gap: 7px;
  font-size: 0.9rem;
  font-weight: 850;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 11px 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    background 0.15s ease;
}

input[readonly] {
  background: var(--bg-soft);
  color: var(--muted);
}

textarea {
  resize: vertical;
}

.small {
  font-size: 0.86rem;
}

.price-preview,
.payment-panel,
.setting-status,
.limit-settings {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-soft);
}

.price-preview {
  padding: 13px;
  color: var(--green-dark);
  font-weight: 900;
}

.payment-panel,
.limit-settings {
  display: grid;
  gap: 12px;
  padding: 15px;
}

.payment-panel h3,
.limit-settings h3 {
  margin: 0;
}

.analyst-history {
  margin-bottom: 14px;
}

.setting-status {
  min-height: 90px;
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 13px;
}

.setting-status strong {
  color: var(--green-dark);
  overflow-wrap: anywhere;
}

.setting-status small {
  color: var(--muted);
  font-weight: 800;
}

.setting-status.warn {
  background: var(--red-soft);
  color: var(--red);
  font-weight: 850;
}

.payment-settings form {
  padding-top: 4px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 9px;
}

.checkbox-label input {
  width: auto;
}

.legal-check {
  align-items: flex-start;
  line-height: 1.45;
}

.legal-check input {
  margin-top: 4px;
}

.legal-check span {
  color: var(--muted);
  font-weight: 800;
}

.legal-check a {
  color: var(--green-dark);
  font-weight: 950;
}

button,
.primary,
.secondary {
  min-height: 42px;
  width: fit-content;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0 15px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.primary,
button.primary {
  border-color: transparent;
  background: var(--gold);
  color: #15110a;
}

.secondary,
button.secondary {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.ghost-button,
button.ghost-button {
  min-height: 36px;
  background: #fff;
  color: var(--green-dark);
}

button:hover,
button:focus,
a:focus,
input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(217, 154, 43, 0.34);
  outline-offset: 2px;
}

.item {
  padding: 15px 0;
  border-top: 1px solid var(--line);
}

.item:first-of-type {
  border-top: 0;
}

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

.item strong,
.message strong {
  color: var(--ink);
}

.item-meta {
  margin: 6px 0 0;
}

.status-pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 950;
  line-height: 1.2;
}

.status-good {
  background: rgba(23, 79, 63, 0.1);
  border-color: rgba(23, 79, 63, 0.22);
  color: var(--green-dark);
}

.status-warn {
  background: var(--gold-soft);
  border-color: rgba(217, 154, 43, 0.32);
  color: #735111;
}

.status-bad {
  background: var(--red-soft);
  border-color: rgba(183, 51, 44, 0.25);
  color: var(--red);
}

.status-neutral {
  background: var(--blue-soft);
  border-color: rgba(47, 95, 138, 0.22);
  color: var(--blue);
}

.message {
  padding: 13px 0;
  border-top: 1px solid var(--line);
}

.message:first-of-type {
  border-top: 0;
}

.message p {
  margin: 5px 0 0;
}

.message span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.inline-actions,
.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.inline-actions {
  margin-top: 12px;
}

.inline-form input {
  width: min(180px, 100%);
}

.table {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.tr {
  display: grid;
  grid-template-columns: minmax(180px, 1.1fr) minmax(90px, 0.45fr) minmax(80px, 0.35fr) minmax(260px, 1.55fr);
  gap: 12px;
  align-items: center;
  padding: 13px;
  border-top: 1px solid var(--line);
}

.tr:first-child {
  border-top: 0;
}

.tr.head {
  background: var(--green-dark);
  color: #fff;
  font-weight: 900;
}

.attribution-table .tr {
  grid-template-columns: minmax(220px, 1.7fr) minmax(80px, 0.45fr) minmax(80px, 0.45fr) minmax(110px, 0.55fr);
}

.funnel-diagnostics {
  margin-top: 24px;
}

.funnel-table .tr {
  grid-template-columns: minmax(220px, 1.4fr) repeat(3, minmax(90px, 0.65fr));
}

details {
  margin: 10px 0;
}

summary {
  cursor: pointer;
  font-weight: 850;
}

pre {
  max-height: 260px;
  overflow: auto;
  padding: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  white-space: pre-wrap;
}

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

  .tr,
  .attribution-table .tr,
  .funnel-table .tr {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .app-header {
    position: static;
    align-items: flex-start;
    flex-direction: column;
    padding: 16px 20px;
  }

  .app-nav,
  .app-header nav,
  .inline-actions,
  .inline-form,
  .item-top {
    align-items: stretch;
    flex-direction: column;
  }

  .two-col,
  .metric-row,
  .settings-grid,
  .limit-grid {
    grid-template-columns: 1fr;
  }

  .app-main {
    width: min(100% - 28px, 1220px);
    padding-top: 28px;
  }

  .page-hero h1 {
    font-size: 2rem;
  }

  .compact-section {
    display: block;
  }

  button,
  .primary,
  .secondary,
  .ghost-button {
    width: 100%;
  }

  .user-chip {
    max-width: 100%;
  }
}
