:root {
  --bg: #f3f1ec;
  --panel: #ffffff;
  --text: #1c1917;
  --muted: #57534e;
  --border: #e7e5e4;
  /* Independent brand — not Intuit green */
  --primary: #0f766e;
  --primary-dark: #0d5f59;
  --secondary: #9a3412;
  --danger: #b91c1c;
  --sidebar-bg: #1c1917;
  --sidebar-text: #f5f5f4;
  --sidebar-muted: #a8a29e;
  --sidebar-width: 260px;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(28, 25, 23, 0.08);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

/* Full-width app shell */
.shell {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* —— Sidebar —— */
.sidebar {
  position: sticky;
  top: 0;
  align-self: flex-start;
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: margin-left 0.2s ease, opacity 0.2s ease;
}

.shell.sidebar-collapsed .sidebar {
  margin-left: calc(-1 * var(--sidebar-width));
  opacity: 0;
  pointer-events: none;
}

.sidebar-brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(145deg, #0f766e 0%, #134e4a 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.72rem;
  letter-spacing: -0.02em;
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.brand-text strong {
  font-size: 0.95rem;
  white-space: nowrap;
}

.brand-sub {
  font-size: 0.75rem;
  color: var(--sidebar-muted);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 10px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--sidebar-text);
  font: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* Users nav: never show unless shell marked admin (set only from server isAdmin) */
#nav-users {
  display: none !important;
}

.shell.is-admin:not(.signed-out) #nav-users {
  display: flex !important;
}

.nav-pro-badge {
  margin-left: auto;
  flex-shrink: 0;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  line-height: 1.2;
  background: #166534;
  color: #fff;
}

.nav-item .nav-pro-badge.hidden {
  display: none;
}

.nav-item.active {
  background: rgba(15, 118, 110, 0.35);
  color: #fff;
}

.nav-icon {
  width: 1.25rem;
  text-align: center;
  opacity: 0.9;
}

.sidebar-footer {
  padding: 12px 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-conn {
  font-size: 0.78rem;
  color: var(--sidebar-muted);
  line-height: 1.35;
}

.btn-sidebar {
  color: var(--sidebar-text) !important;
  border-color: rgba(255, 255, 255, 0.2) !important;
  justify-content: flex-start;
  width: 100%;
}

.btn-sidebar:hover {
  background: rgba(255, 255, 255, 0.08) !important;
}

.sidebar-show-btn {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 50;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: var(--shadow);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}

.sidebar-show-btn:hover {
  background: #eef1f4;
}

/* —— Main column —— */
.main {
  flex: 1;
  min-width: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  justify-content: space-between;
  align-items: flex-start;
  padding: 18px 24px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.shell.sidebar-collapsed .topbar {
  padding-left: 64px;
}

.topbar-title h1 {
  margin: 0 0 4px;
  font-size: 1.35rem;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

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

.badge-plan {
  font-weight: 700;
  letter-spacing: 0.02em;
}

.badge-plan.plan-free {
  background: #0f766e;
  color: #fff;
}

.badge-plan.plan-pro {
  background: #166534;
  color: #fff;
}

.badge-plan.plan-payg {
  background: #1e3a5f;
  color: #e2e8f0;
  border: 1px solid #334155;
}

.content {
  flex: 1;
  width: 100%;
  padding: 20px 24px 40px;
}

.page {
  width: 100%;
}

/* —— Dashboard —— */
.welcome {
  margin-bottom: 16px;
}

.dashboard-home {
  max-width: 46rem;
  padding: 28px 30px 32px;
}

.welcome-kicker {
  margin: 0 0 6px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--primary);
}

.welcome h2 {
  margin: 0 0 8px;
  font-size: 1.75rem;
  line-height: 1.25;
}

.welcome-status {
  margin: 0 0 20px;
  font-size: 0.98rem;
  max-width: 40rem;
}

.welcome-body {
  margin: 0 0 16px;
  color: var(--muted);
  max-width: 48rem;
  font-size: 1.02rem;
}

.welcome-explain {
  margin: 0 0 28px;
  max-width: 40rem;
}

.welcome-lead {
  margin: 0 0 14px;
  font-size: 1.08rem;
  line-height: 1.55;
  color: var(--text, #1a1a1a);
}

.welcome-explain > p {
  margin: 0 0 14px;
  line-height: 1.55;
  color: var(--muted);
  font-size: 1rem;
}

.welcome-explain > p:last-child {
  margin-bottom: 0;
}

.welcome-steps {
  margin: 0 0 16px;
  padding-left: 1.25rem;
  color: var(--muted);
  line-height: 1.55;
}

.welcome-steps li {
  margin-bottom: 10px;
}

.welcome-steps li:last-child {
  margin-bottom: 0;
}

.welcome-steps strong {
  color: var(--text, #1a1a1a);
}

.welcome-note {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.5;
}

.welcome-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.btn-dash {
  min-width: 12.5rem;
  padding: 16px 28px;
  font-size: 1.08rem;
  font-weight: 600;
  border-radius: 10px;
  line-height: 1.3;
}

/* —— Shared panels —— */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  margin-bottom: 16px;
}

.login-panel h2 {
  margin: 0 0 8px;
  font-size: 1.1rem;
}

.login-panel p {
  margin: 0 0 12px;
  color: var(--muted);
}

.setup-steps {
  margin: 0 0 8px;
  padding-left: 1.25rem;
  color: var(--text);
  line-height: 1.55;
}

.setup-steps code,
code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.85em;
  background: #eef1f4;
  padding: 1px 6px;
  border-radius: 4px;
}

.company-line {
  margin-top: 8px;
  font-weight: 600;
  color: #1b6b14;
}

.letter-status {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

/* —— Reports page —— */
.reports-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: flex-end;
  margin-bottom: 12px;
  padding: 10px 12px;
}

.reports-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.reports-toolbar .field {
  margin: 0;
}

.reports-toolbar .field label {
  margin-bottom: 2px;
  font-size: 0.72rem;
}

.year-field {
  min-width: 110px;
}

.select-year {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 28px 6px 10px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  background: #fff
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%235c6570' d='M1 1l5 5 5-5'/%3E%3C/svg%3E")
    no-repeat right 10px center;
  min-width: 110px;
  height: 34px;
  cursor: pointer;
}

.select-year:focus {
  outline: 2px solid rgba(44, 160, 28, 0.35);
  outline-offset: 1px;
}

.reports-toolbar .btn {
  padding: 6px 12px;
  font-size: 0.88rem;
  height: 34px;
  line-height: 1.2;
}

.unlock-min-hint {
  margin: 10px 0 0;
  font-size: 0.88rem;
  line-height: 1.45;
  max-width: 40rem;
}

.unlock-min-hint.is-ok {
  color: var(--muted);
}

.unlock-min-hint.is-warn {
  color: #9a3412;
}

.shell.is-free .unlock-min-hint,
.shell.is-pro .unlock-min-hint {
  display: none;
}

.btn-lg {
  padding: 10px 18px;
}

.btn-danger {
  background: #b91c1c;
  color: #fff;
  border: 1px solid #991b1b;
}

.btn-danger:hover:not(:disabled) {
  background: #991b1b;
}

.btn-danger:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.settings-panel {
  margin-bottom: 16px;
}

.settings-danger-panel {
  border-color: #fecaca;
  background: linear-gradient(180deg, #fff5f5 0%, var(--panel) 40%);
  max-width: 40rem;
}

.danger-kicker {
  color: #b91c1c;
}

.settings-stat {
  margin: 10px 0 14px;
  font-weight: 600;
  color: var(--text);
}

.settings-confirm-field {
  margin-bottom: 14px;
}

.settings-confirm-field input {
  width: 100%;
  max-width: 28rem;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
}

.settings-confirm-field input:focus {
  outline: 2px solid rgba(185, 28, 28, 0.25);
  outline-offset: 1px;
  border-color: #fca5a5;
}

/* Signed-out: marketing landing, hide app chrome */
.shell.signed-out .sidebar {
  display: none;
}

.shell.signed-out .sidebar-show-btn {
  display: none !important;
}

.shell.signed-out .topbar {
  display: none;
}

.shell.signed-out .main {
  width: 100%;
  max-width: 100%;
}

.shell.signed-out .content {
  max-width: 100%;
  padding: 0;
  margin: 0;
}

.shell.signed-out {
  background: #f3f1ec;
}

/* Before JS: show marketing page for crawlers/no-js; app chrome stays usable after login */
body:not(.app-ready) .sidebar,
body:not(.app-ready) .topbar,
body:not(.app-ready) .sidebar-show-btn {
  display: none !important;
}

body:not(.app-ready) .main {
  width: 100%;
}

body:not(.app-ready) .content {
  padding: 0;
  max-width: 100%;
}

/* —— Marketing landing (login) —— */
.landing {
  width: 100%;
  min-height: 100%;
  background:
    radial-gradient(1200px 480px at 10% -10%, color-mix(in srgb, var(--primary) 12%, transparent), transparent 60%),
    radial-gradient(900px 400px at 100% 0%, color-mix(in srgb, #1e3a5f 8%, transparent), transparent 55%),
    #f6f4f0;
  color: var(--text);
}

.landing-inner {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 28px 48px;
  box-sizing: border-box;
}

@media (min-width: 900px) {
  .landing-inner {
    padding: 36px 40px 64px;
  }
}

.landing-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px 20px;
  margin-bottom: 12px;
  padding: 12px 16px;
  background: color-mix(in srgb, #fff 88%, transparent);
  border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
  backdrop-filter: blur(8px);
}

.landing-nav-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
}

.landing-nav-links > a:not(.btn) {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
}

.landing-nav-links > a:not(.btn):hover {
  color: var(--primary-dark, #0f766e);
}

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

.landing-brand .brand-sub {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
}

.landing-hero {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 36px 44px;
  align-items: center;
  margin: 0;
  padding: 36px 8px 52px;
}

.landing-split {
  display: grid;
  grid-template-columns: 1fr 1.05fr;
  gap: 32px 40px;
  align-items: center;
}

.landing-section-lead-left {
  margin-left: 0;
  max-width: 34rem;
}

.landing-eyebrow {
  margin: 0 0 10px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--primary-dark);
}

.landing-hero h1 {
  margin: 0 0 14px;
  font-size: clamp(1.75rem, 3.5vw, 2.45rem);
  line-height: 1.18;
  letter-spacing: -0.02em;
}

.landing-lead {
  margin: 0 0 20px;
  font-size: 1.05rem;
  line-height: 1.55;
  color: #3d4650;
  max-width: 36rem;
}

.landing-cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.landing-trust {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.92rem;
  color: var(--muted);
}

.landing-trust li::before {
  content: "✓ ";
  color: var(--primary);
  font-weight: 700;
}

.landing-hero-media {
  margin: 0;
}

.landing-screenshot {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--border) 70%, #cbd5e1);
  box-shadow:
    0 4px 6px rgba(15, 23, 42, 0.04),
    0 20px 48px rgba(15, 23, 42, 0.12);
  background: #fff;
}

.landing-screenshot-hero {
  box-shadow:
    0 8px 16px rgba(15, 23, 42, 0.06),
    0 28px 56px rgba(15, 118, 110, 0.14);
}

.landing-hero-media figcaption {
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
}

.landing-section {
  max-width: none;
  margin: 0;
  padding: 48px 8px;
}

.landing-section-alt {
  background: #fff;
  max-width: none;
  margin: 0 -8px;
  padding: 48px 24px;
  border-radius: 18px;
  border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}

.landing-section-alt > * {
  max-width: none;
  margin-left: 0;
  margin-right: 0;
  padding-left: 0;
  padding-right: 0;
}

.landing-section h2 {
  margin: 0 0 10px;
  font-size: clamp(1.4rem, 2.5vw, 1.85rem);
  letter-spacing: -0.015em;
}

.landing-section-lead {
  margin: 0 0 28px;
  max-width: 40rem;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.55;
}

.landing-features {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.landing-feature {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  box-shadow: var(--shadow);
}

.landing-section-alt .landing-feature {
  background: #f7f9fb;
}

.landing-feature h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.landing-feature p {
  margin: 0;
  font-size: 0.94rem;
  color: #3d4650;
  line-height: 1.5;
}

.landing-pricing-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  align-items: stretch;
  max-width: 52rem;
}

.landing-pricing-card {
  display: flex;
  flex-direction: column;
  background: linear-gradient(160deg, #f0fdfa 0%, #fff 55%);
  border: 1px solid #99f6e4;
  border-radius: 14px;
  padding: 28px 24px;
  box-shadow: var(--shadow);
}

.landing-pricing-card-pro {
  background: linear-gradient(160deg, #ecfdf5 0%, #fff 50%);
  border-color: #86efac;
  box-shadow: 0 8px 28px rgba(22, 101, 52, 0.1);
}

.landing-plan-kicker {
  margin: 0 0 6px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--primary);
}

.landing-plan-kicker-pro {
  color: #166534;
}

.landing-plan-name {
  margin: 0 0 10px;
  font-size: 1.45rem;
  line-height: 1.2;
}

.landing-plan-tagline {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.45;
}

.landing-price {
  margin: 0 0 8px;
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.landing-price-amount {
  font-size: 2.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--primary-dark);
  line-height: 1;
}

.landing-pricing-card-pro .landing-price-amount {
  color: #166534;
}

.landing-price-unit {
  font-size: 1.02rem;
  color: var(--muted);
  font-weight: 600;
}

.landing-price-list {
  margin: 0 0 20px;
  padding-left: 1.15rem;
  color: #3d4650;
  line-height: 1.55;
  flex: 1;
}

.landing-price-list li {
  margin-bottom: 8px;
}

.landing-pricing-card .btn {
  align-self: flex-start;
  margin-top: auto;
}

.landing-pricing-footnote {
  margin: 18px 0 0;
  max-width: 40rem;
  font-size: 0.9rem;
  line-height: 1.5;
}

@media (max-width: 800px) {
  .landing-pricing-grid {
    grid-template-columns: 1fr;
  }
}

.landing-steps {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
  display: grid;
  gap: 14px;
}

.landing-steps li {
  counter-increment: step;
  position: relative;
  padding: 16px 16px 16px 56px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  line-height: 1.5;
  color: #3d4650;
}

.landing-steps li::before {
  content: counter(step);
  position: absolute;
  left: 14px;
  top: 16px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.landing-steps strong {
  display: block;
  color: var(--text);
  margin-bottom: 4px;
}

.landing-audience {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 20px;
  margin: 0;
  padding-left: 1.1rem;
  color: #3d4650;
  font-size: 1.02rem;
}

.landing-cta-band {
  max-width: none;
  margin: 8px 0 28px;
  padding: 40px 28px;
  text-align: center;
  border-radius: 18px;
  background: linear-gradient(125deg, #1c1917 0%, #292524 45%, #134e4a 100%);
  color: #fafaf9;
}

.landing-cta-band h2 {
  margin: 0 0 10px;
  font-size: 1.6rem;
}

.landing-cta-band p {
  margin: 0 auto 18px;
  max-width: 32rem;
  color: #c5ced8;
  line-height: 1.5;
}

.landing-cta-band .btn-primary {
  background: var(--primary);
  border-color: var(--primary);
}

.landing-footer {
  margin: 0;
  padding: 28px 8px 8px;
  border-top: 1px solid color-mix(in srgb, var(--border) 85%, transparent);
  font-size: 0.9rem;
  color: var(--muted);
  text-align: center;
}

.landing-footer p {
  margin: 0 0 8px;
}

.landing-footer-links {
  margin-top: 12px !important;
}

.landing-footer-links a {
  font-weight: 600;
  color: var(--primary-dark, #0f766e);
  text-decoration: none;
}

.landing-footer-links a:hover {
  text-decoration: underline;
}

.landing-section {
  max-width: none;
  padding-left: 8px;
  padding-right: 8px;
}

.landing-section-alt {
  margin-left: -8px;
  margin-right: -8px;
  padding-left: 24px;
  padding-right: 24px;
  border-radius: 18px;
}

@media (max-width: 900px) {
  .landing-inner {
    padding: 16px 14px 36px;
  }

  .landing-nav-links > a:not(.btn) {
    display: none;
  }

  .landing-hero {
    grid-template-columns: 1fr;
    padding: 16px 0 32px;
  }

  .landing-split {
    grid-template-columns: 1fr;
  }

  .landing-features {
    grid-template-columns: 1fr;
  }

  .landing-audience {
    grid-template-columns: 1fr;
  }

  .landing-section-alt {
    margin-left: 0;
    margin-right: 0;
    padding-left: 16px;
    padding-right: 16px;
  }
}

.org-email-notice {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid #cfe8fc;
  background: #f0f8ff;
  color: #1e3a5f;
  font-size: 0.92rem;
  line-height: 1.45;
}

.org-email-notice strong {
  display: block;
  margin-bottom: 4px;
}

.link-btn {
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  color: var(--secondary);
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}

.data-notice {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid #dcefe0;
  background: #f4faf5;
  box-shadow: var(--shadow);
}

.data-notice-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #e0f0e3;
  color: #1b6b14;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 700;
}

.data-notice-text {
  margin: 0;
  color: #3d4a40;
  font-size: 0.92rem;
  line-height: 1.45;
}

.data-notice-label {
  display: inline-block;
  margin-right: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e0f0e3;
  color: #1b6b14;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  vertical-align: middle;
}

.badge-ephemeral {
  background: #eef6ec;
  color: #1b6b14;
  border: 1px solid #d0e8d2;
}

.badge-locked {
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid #fed7aa;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  vertical-align: middle;
  margin-left: 6px;
}

.donor-name .badge-ephemeral {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 7px;
  vertical-align: middle;
  margin-left: 6px;
}

.table-toolbar-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card-ephemeral {
  border-color: #d0e8d2;
  background: #f7fbf7;
  justify-content: center;
}

.stat-value-sm {
  font-size: 0.95rem;
  line-height: 1.35;
  font-weight: 700;
  word-break: break-word;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.stat-value {
  font-size: 1.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stat-card-note {
  justify-content: center;
}

.billing-panel {
  margin-bottom: 16px;
  border-color: #f0e0c8;
  background: linear-gradient(180deg, #fffbf5 0%, var(--panel) 48%);
}

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

.billing-title {
  margin: 0 0 6px;
  font-size: 1.15rem;
}

.billing-desc {
  margin: 0;
  max-width: 52rem;
  line-height: 1.45;
}

.billing-badge {
  flex-shrink: 0;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
}

.billing-badge-ok {
  background: #e8f6ec;
  color: #166534;
  border-color: #bbf7d0;
}

.billing-badge-warn {
  background: #fff7ed;
  color: #9a3412;
  border-color: #fed7aa;
}

.billing-badge-muted {
  background: #f3f4f6;
  color: #4b5563;
  border-color: #e5e7eb;
}

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

.billing-stat {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.billing-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

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

.table-panel {
  padding-top: 14px;
}

.donor-pager {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.donor-pager-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.donor-pager-pages {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  min-width: 5.5rem;
  text-align: center;
}

.data-table tbody tr:hover {
  background: #f7faf7;
}

.data-table tbody tr.is-selected {
  background: #e8f3ec;
  box-shadow: inset 3px 0 0 var(--primary, #2d6a4f);
}

.data-table tbody tr.is-selected:hover {
  background: #dceee3;
}

.data-table th {
  background: #f8fafb;
  position: sticky;
  top: 0;
}

.col-actions {
  min-width: 9.5rem;
  white-space: nowrap;
}

.empty-state {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 8px;
  align-items: center;
}

.empty-state strong {
  color: var(--text);
}

.detail-panel {
  border-left: 4px solid var(--primary);
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.detail-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.total-row td {
  border-bottom: none;
  padding-top: 14px;
  background: #f8fafb;
}

/* —— Report builder —— */
.builder-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 42%);
  gap: 16px;
  align-items: start;
}

.builder-preview-panel {
  position: sticky;
  top: 76px;
  align-self: start;
  max-height: calc(100vh - 96px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.preview-title {
  margin: 0;
  font-size: 1.1rem;
}

.preview-note {
  margin: 0 0 12px;
  font-size: 0.85rem;
}

.preview-frame-wrap {
  position: relative;
  flex: 1;
  min-height: 480px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #e8eaed;
  overflow: hidden;
}

.pdf-preview {
  width: 100%;
  height: 100%;
  min-height: 480px;
  border: 0;
  background: #525659;
}

.pdf-preview-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.preview-steps {
  margin: 12px 0 0;
  font-size: 0.85rem;
}

.builder-main-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

/* Distinct builder blocks (org, year, title, letter, bottom) */
.builder-section {
  margin-bottom: 0;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.builder-section-org {
  border-color: #99f6e4;
  background: linear-gradient(180deg, #f0fdfa 0%, var(--panel) 48px);
}

.builder-section-year {
  border-color: #e7e5e4;
}

.builder-section-title {
  border-color: #ddd6fe;
  background: linear-gradient(180deg, #f5f3ff 0%, var(--panel) 48px);
}

.builder-section-letter {
  border-color: #a5f3fc;
  background: linear-gradient(180deg, #ecfeff 0%, var(--panel) 48px);
}

.builder-section-footer {
  border-color: #fde68a;
  background: linear-gradient(180deg, #fffbeb 0%, var(--panel) 48px);
}

.builder-section-actions {
  background: #fafaf9;
  border-style: dashed;
}

.builder-section-head {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: flex-start;
  margin-bottom: 12px;
  padding-bottom: 0;
  border-bottom: none;
}

.builder-section-head-main {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  flex: 1;
  min-width: 0;
}

.builder-section-num {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

.builder-section-letter .builder-section-num {
  background: #0891b2;
}

.builder-section-footer .builder-section-num {
  background: #d97706;
}

.builder-section-title .builder-section-num {
  background: #7c3aed;
}

.builder-section-year .builder-section-num {
  background: #57534e;
}

.builder-section-body {
  padding-top: 2px;
}

.builder-section-body .field {
  margin-bottom: 0;
}

.builder-section-actions .builder-actions {
  margin: 0;
}

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

.org-panel-header .builder-intro {
  margin-bottom: 0;
}

.org-panel-header .builder-section-num {
  margin-top: 4px;
}

.org-grid {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.org-logo-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  text-align: center;
}

.org-logo {
  max-width: 140px;
  max-height: 100px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
}

.org-logo-placeholder {
  width: 140px;
  height: 100px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.85rem;
  background: #fafbfc;
}

.org-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

input[type="text"],
input[type="email"] {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  color: var(--text);
  background: #fff;
  width: 100%;
}

.builder-title {
  margin: 0 0 8px;
  font-size: 1.35rem;
}

.builder-intro {
  margin: 0 0 20px;
  max-width: 40rem;
}

.builder-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.rt-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 8px 8px 0 0;
  background: #f8fafb;
}

.rt-btn {
  border: 1px solid transparent;
  background: transparent;
  border-radius: 6px;
  padding: 4px 8px;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text);
}

.rt-btn:hover {
  background: #e8ecf0;
  border-color: var(--border);
}

.rt-sep {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 4px;
}

.letter-editor.rt-editor {
  min-height: 200px;
  max-height: 360px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 8px 8px;
  padding: 12px 14px;
  font-size: 1rem;
  line-height: 1.55;
  outline: none;
}

.letter-editor.rt-editor:focus {
  box-shadow: inset 0 0 0 2px rgba(44, 160, 28, 0.2);
}

.letter-editor.rt-editor:empty::before {
  content: attr(data-placeholder);
  color: #9aa3ad;
  pointer-events: none;
}

.letter-editor.rt-editor p {
  margin: 0 0 0.65em;
}

.letter-editor.rt-editor p:last-child {
  margin-bottom: 0;
}

.placeholder-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin: 8px 0;
}

.chip {
  border: 1px solid var(--border);
  background: #eef6ec;
  color: #1b6b14;
  border-radius: 999px;
  padding: 3px 10px;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: ui-monospace, Consolas, monospace;
  cursor: pointer;
}

.chip:hover {
  background: #d9efd4;
}

.report-title-input {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  background: #fff;
  width: 100%;
}

.report-title-input:focus {
  outline: 2px solid rgba(44, 160, 28, 0.35);
  outline-offset: 1px;
}

.footer-editor.rt-editor {
  min-height: 120px;
  max-height: 240px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 8px 8px;
  padding: 12px 14px;
  font-size: 0.95rem;
  line-height: 1.5;
  outline: none;
}

.footer-editor.rt-editor:focus {
  box-shadow: inset 0 0 0 2px rgba(44, 160, 28, 0.2);
}

.footer-editor.rt-editor:empty::before {
  content: attr(data-placeholder);
  color: #9aa3ad;
  pointer-events: none;
}

.footer-editor.rt-editor p {
  margin: 0 0 0.5em;
}

.footer-editor.rt-editor p:last-child {
  margin-bottom: 0;
}

.builder-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.builder-steps {
  margin: 0 0 16px;
  padding-left: 1.2rem;
  line-height: 1.55;
  color: var(--text);
  font-size: 0.92rem;
}

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

.field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

input[type="number"],
input[type="search"],
textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  color: var(--text);
  background: #fff;
  width: 100%;
}

textarea {
  resize: vertical;
  min-height: 96px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  background: #eef1f4;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--secondary);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
}

.btn-small {
  padding: 4px 10px;
  font-size: 0.85rem;
  font-weight: 600;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.badge-ok {
  background: #e6f6e4;
  color: #1b6b14;
}

.badge-muted {
  background: #eef1f4;
  color: var(--muted);
}

.badge-warn {
  background: #fff4e5;
  color: #9a5b00;
}

.table-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.check-all {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--muted);
}

.filter {
  min-width: 220px;
  flex: 1;
  max-width: 420px;
}

.table-wrap {
  overflow-x: auto;
  width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

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

th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.col-check {
  width: 36px;
}

.col-address {
  min-width: 140px;
  max-width: 220px;
  font-size: 0.85rem;
  line-height: 1.35;
  color: var(--text);
  white-space: pre-line;
}

.col-email {
  min-width: 120px;
  max-width: 200px;
  word-break: break-word;
}

.empty-row td {
  color: var(--muted);
  text-align: center;
  padding: 28px 8px;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 10px;
  line-height: 1.25;
}

.row-link {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--primary-dark);
  text-decoration: none;
  white-space: nowrap;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
}

.row-link:hover {
  text-decoration: underline;
  color: var(--primary);
}

.row-link.is-disabled,
.row-link[aria-disabled='true'] {
  color: var(--muted);
  cursor: not-allowed;
  text-decoration: none;
  pointer-events: none;
  opacity: 0.65;
}

.data-table td {
  padding-top: 6px;
  padding-bottom: 6px;
  vertical-align: middle;
}

.donor-name {
  font-weight: 600;
}

.muted {
  color: var(--muted);
  font-size: 0.85rem;
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  max-width: 360px;
  background: #1a1d21;
  color: #fff;
  padding: 12px 16px;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  z-index: 60;
}

.toast.error {
  background: var(--danger);
}

.toast.ok {
  background: #1b6b14;
}

/* —— Admin-only settings panels —— */
.admin-only-panel {
  border-color: color-mix(in srgb, var(--primary) 45%, var(--border));
  background: color-mix(in srgb, var(--primary) 6%, var(--panel));
  box-shadow: inset 3px 0 0 var(--primary);
}

.admin-only-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  margin-bottom: 4px;
}

.admin-only-header .welcome-kicker {
  margin: 0;
}

.badge-admin-only {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--primary);
  color: #fff;
}

/* —— Plan / Pro —— */
.settings-plan-actions {
  margin-top: 12px;
  gap: 10px;
}

.plan-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  margin-bottom: 14px;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--primary) 8%, var(--panel));
}

.plan-banner p {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.45;
  max-width: 40rem;
}

.plan-banner.is-pro {
  background: color-mix(in srgb, #16a34a 10%, var(--panel));
  border-color: color-mix(in srgb, #16a34a 35%, var(--border));
}

.badge-pro {
  background: #166534;
  color: #fff;
}

/* —— Insights (premium) —— */
.insights-toolbar {
  margin-bottom: 16px;
}

/* Contact form */
.contact-panel {
  max-width: 36rem;
}

.contact-form .field {
  margin-bottom: 14px;
}

.contact-form textarea {
  width: 100%;
  min-height: 8rem;
  resize: vertical;
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

.contact-form input[type='text'],
.contact-form input[type='email'] {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

.contact-hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

#btn-insights-toggle-names.is-active {
  border-color: color-mix(in srgb, var(--primary) 45%, var(--border));
  color: var(--primary-dark, #0f766e);
  background: color-mix(in srgb, var(--primary) 8%, var(--panel));
}

.insights-compare-field {
  min-width: 8rem;
  margin: 0;
}

.insights-compare-field label {
  font-size: 0.72rem;
}

/* YoY / prior-year snippet under stats and cards */
.insights-compare-note {
  margin: 4px 0 0;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--muted);
}

.stat-card .insights-compare-note {
  display: block;
  margin-top: 4px;
}

.insights-compare-note.is-up {
  color: #15803d;
}

.insights-compare-note.is-down {
  color: #b91c1c;
}

.insights-compare-note.is-flat {
  color: var(--muted);
}

/* Paired year values on KPI strip + metric cards */
.stat-value.is-dual-metric,
.insights-card-metric.is-dual-metric {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: flex-end;
  font-size: 1rem;
  line-height: 1.2;
}

.dual-year-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.dual-year-tag {
  font-size: 0.68rem;
  font-weight: 700;
  font-style: normal;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Year labels in comparison copy (50/80, top giver, frequency, goal, etc.) */
.insights-year-label,
strong.insights-year-label {
  font-weight: 700;
  font-style: normal;
}

.insights-pie-year-label {
  font-weight: 700;
}

.insights-yoy-legend [data-year-current],
.insights-yoy-legend [data-year-previous] {
  font-weight: 700;
}

.dual-year-block.is-current .dual-year-tag {
  color: #0f766e;
}

.dual-year-block.is-previous .dual-year-tag {
  color: #1e3a5f;
}

.dual-year-val {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.stat-value.is-dual-metric .dual-year-val {
  font-size: 1.15rem;
}

.insights-card-metric.is-dual-metric .dual-year-val {
  font-size: 1.35rem;
  color: var(--primary-dark, #0f766e);
}

.dual-year-block.is-previous .dual-year-val {
  color: #1e3a5f;
  opacity: 0.92;
}

.insights-inline-legend {
  flex-shrink: 0;
}

/* Dual bars inside the main "By month" panel when compare is on */
.insights-vbar-chart .insights-monthly-pair {
  min-height: 150px;
}

.insights-vbar-chart .insights-yoy-pair {
  height: 120px;
}

/* Dual horizontal bar rows */
.insights-hbar-row.is-dual {
  grid-template-columns: minmax(0, 11rem) 1fr;
  align-items: start;
}

.insights-hbar-tracks {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.insights-hbar-track-pair {
  display: grid;
  grid-template-columns: 2.6rem 1fr auto;
  gap: 8px;
  align-items: center;
}

.insights-hbar-yr {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
}

.insights-hbar-yr.is-current {
  color: #0f766e;
}

.insights-hbar-yr.is-previous {
  color: #1e3a5f;
}

.insights-hbar-fill.is-current {
  background: linear-gradient(90deg, #0f766e, #2dd4bf);
}

.insights-hbar-fill.is-previous {
  background: linear-gradient(90deg, #1e3a5f, #93c5fd);
}

.insights-hbar-amt {
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  white-space: nowrap;
  text-align: right;
  min-width: 6rem;
}

/* Dual pies */
.insights-pies-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 20px;
  align-items: flex-start;
  justify-content: center;
}

.insights-pie-col {
  flex: 1 1 160px;
  max-width: 280px;
  min-width: 140px;
}

.insights-pie-year-label {
  margin: 0 0 8px;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
}

.insights-pie-layout.is-dual {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  align-items: start;
}

@media (max-width: 900px) {
  .insights-hbar-row.is-dual {
    grid-template-columns: 1fr;
  }

  .insights-hbar-track-pair {
    grid-template-columns: 2.4rem 1fr;
  }

  .insights-hbar-amt {
    grid-column: 2;
    text-align: left;
    min-width: 0;
  }

  .insights-pie-layout.is-dual {
    grid-template-columns: 1fr;
  }
}

.insights-pro-invite {
  max-width: 40rem;
  padding: 24px 26px 28px;
  border-color: color-mix(in srgb, #16a34a 40%, var(--border));
  background: color-mix(in srgb, #16a34a 8%, var(--panel));
  margin-bottom: 16px;
}

.insights-pro-invite-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  margin-bottom: 6px;
}

.insights-pro-invite-top .welcome-kicker {
  margin: 0;
}

.insights-paywall {
  max-width: 36rem;
  padding: 24px 26px 28px;
}

.insights-paywall-copy {
  margin: 0 0 16px;
  line-height: 1.55;
  max-width: 32rem;
}

.insights-price {
  margin: 0 0 18px;
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.02em;
}

.insights-stats {
  margin-bottom: 16px;
}

.insights-chart-panel {
  padding: 20px 22px 24px;
}

.insights-chart-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px 20px;
  margin-bottom: 18px;
}

.insights-chart-header .builder-title {
  margin-bottom: 4px;
}

.insights-topn-field {
  min-width: 7rem;
}

.insights-kpi-note {
  margin: -4px 0 16px;
  font-size: 0.88rem;
  line-height: 1.45;
  max-width: 48rem;
}

/* Shared year swatches / dual monthly bars (used on chart panels) */
.insights-yoy-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  font-size: 0.85rem;
  color: var(--muted);
}

.insights-yoy-swatch {
  display: inline-block;
  width: 14px;
  height: 10px;
  border-radius: 3px;
}

.insights-yoy-swatch.is-current {
  background: linear-gradient(180deg, #2dd4bf 0%, #0f766e 100%);
}

.insights-yoy-swatch.is-previous {
  background: linear-gradient(180deg, #93c5fd 0%, #1e3a5f 100%);
}

.insights-yoy-month {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.insights-yoy-pair {
  width: 100%;
  height: 130px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
}

.insights-yoy-bar {
  width: 40%;
  max-width: 16px;
  min-height: 2px;
  border-radius: 4px 4px 1px 1px;
}

.insights-yoy-bar.is-current {
  background: linear-gradient(180deg, #2dd4bf 0%, #0f766e 100%);
}

.insights-yoy-bar.is-previous {
  background: linear-gradient(180deg, #93c5fd 0%, #1e3a5f 100%);
}

.insights-yoy-month-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
}

.insights-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

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

.insights-card {
  margin-bottom: 0;
  padding: 16px 18px 18px;
}

.insights-card-highlight {
  border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
  background: color-mix(in srgb, var(--primary) 5%, var(--panel));
}

.insights-card-title {
  margin: 0 0 8px;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
}

.insights-card-metric {
  margin: 0 0 6px;
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--primary-dark, #0f766e);
}

/* One line per year under 50% / 80% concentration cards */
.insights-conc-line {
  display: block;
  margin: 0;
  line-height: 1.45;
}

.insights-conc-line + .insights-conc-line {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
}

/* Concentration card: share % dropdown top-right */
.insights-card-conc {
  position: relative;
  padding-right: 6.5rem;
}

.insights-conc-field {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 5.25rem;
  margin: 0;
  z-index: 1;
}

.insights-conc-field label {
  font-size: 0.72rem;
  margin-bottom: 4px;
  display: block;
  color: var(--muted);
}

.insights-conc-field select {
  width: 100%;
  font-weight: 700;
}

@media (max-width: 720px) {
  .insights-card-conc {
    padding-right: 18px;
  }

  .insights-conc-field {
    position: static;
    width: 100%;
    max-width: 8rem;
    margin: 0 0 10px;
  }
}

.insights-card-goal {
  position: relative;
  grid-column: 1 / -1;
  border-color: color-mix(in srgb, var(--primary) 30%, var(--border));
  /* Room for the target amount field pinned top-right */
  padding-right: 12.5rem;
}

.insights-goal-help {
  margin: 4px 0 10px;
  font-size: 0.9rem;
  line-height: 1.4;
  max-width: 36rem;
}

.insights-goal-field {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 10.5rem;
  margin: 0;
  z-index: 1;
}

.insights-goal-field label {
  font-size: 0.75rem;
  margin-bottom: 4px;
  display: block;
  color: var(--muted);
}

.insights-goal-field input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  background: var(--panel);
}

@media (max-width: 720px) {
  .insights-card-goal {
    padding-right: 18px;
  }

  .insights-goal-field {
    position: static;
    width: 100%;
    max-width: 16rem;
    margin: 0 0 12px;
  }
}

.insights-vbar-chart {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 8px;
  align-items: end;
  min-height: 180px;
  padding: 8px 4px 0;
}

.insights-vbar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.insights-vbar-fill-wrap {
  width: 100%;
  height: 140px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.insights-vbar-fill {
  width: 70%;
  max-width: 36px;
  min-height: 2px;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, #2dd4bf 0%, #0f766e 100%);
}

.insights-vbar-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
}

.insights-vbar-value {
  font-size: 0.68rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.2;
  word-break: break-word;
}

.insights-hbar-chart,
.insights-hbar-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
}

.insights-hbar-row {
  display: grid;
  grid-template-columns: minmax(0, 11rem) 1fr auto;
  gap: 10px 12px;
  align-items: center;
  min-width: 0;
  max-width: 100%;
}

.insights-hbar-name {
  font-size: 0.88rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.insights-hbar-track {
  height: 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--border) 80%, transparent);
  overflow: hidden;
  min-width: 0;
}

.insights-hbar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #0f766e, #2dd4bf);
  min-width: 2px;
}

.insights-hbar-fill.is-secondary {
  background: linear-gradient(90deg, #1e3a5f, #60a5fa);
}

.insights-hbar-fill.is-muted {
  background: linear-gradient(90deg, #64748b, #94a3b8);
}

.insights-hbar-value {
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--muted);
  text-align: right;
  min-width: 5.5rem;
}

/* Narrow card (One-time vs repeat): stack so labels never spill out */
.insights-card .insights-hbar-list,
.insights-card .insights-hbar-chart {
  width: 100%;
}

.insights-card .insights-hbar-row,
.insights-card .insights-hbar-row.is-dual {
  grid-template-columns: 1fr;
  gap: 4px;
}

.insights-card .insights-hbar-name {
  white-space: normal;
}

.insights-card .insights-hbar-track-pair {
  grid-template-columns: 2.5rem minmax(0, 1fr);
  gap: 6px 8px;
}

.insights-card .insights-hbar-amt {
  grid-column: 2;
  min-width: 0;
  max-width: 100%;
  white-space: normal;
  text-align: left;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.3;
}

.insights-card .insights-hbar-value {
  white-space: normal;
  text-align: left;
  min-width: 0;
  overflow-wrap: anywhere;
}

.insights-card #insights-frequency-detail,
.insights-card #insights-top-donor-detail,
.insights-card #insights-conc-detail,
.insights-card .insights-compare-note {
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 100%;
}

.insights-card {
  min-width: 0;
  overflow: hidden;
}

.insights-pie-layout {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
  gap: 20px 28px;
  align-items: center;
}

@media (max-width: 900px) {
  .insights-cards-grid-2 {
    grid-template-columns: 1fr;
  }

  .insights-hbar-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .insights-hbar-value {
    text-align: left;
  }

  .insights-vbar-chart {
    gap: 4px;
  }
}

.insights-pie-wrap {
  width: 100%;
  max-width: 300px;
  margin: 0 auto;
  aspect-ratio: 1;
}

.insights-pie-wrap svg {
  width: 100%;
  height: auto;
  display: block;
}

.insights-legend-wrap {
  overflow-x: auto;
}

.insights-legend-table th,
.insights-legend-table td {
  font-size: 0.92rem;
}

.insights-legend-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  vertical-align: middle;
}

.insights-legend-table .num {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.insights-legend-table tr.is-others td {
  font-style: italic;
  color: var(--muted);
}

@media (max-width: 900px) {
  .insights-pie-layout {
    grid-template-columns: 1fr;
  }

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

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

  .field-row {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 720px) {
  .content {
    padding: 16px 14px 32px;
  }

  .topbar {
    padding: 14px 14px 10px;
  }

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

  .reports-toolbar {
    width: 100%;
  }

  .reports-toolbar-actions {
    width: 100%;
  }
}
