:root {
  --ink: #14251e;
  --muted: #64736c;
  --soft: #edf2ee;
  --surface: rgba(255, 255, 252, 0.92);
  --paper: #f8faf6;
  --white: #ffffff;
  --line: #dfe7e1;
  --green: #176b4d;
  --green-dark: #0e5139;
  --green-soft: #dceee4;
  --lime: #cce56a;
  --amber: #e69a42;
  --rose: #c75d62;
  --blue: #4b7bec;
  --shadow: 0 22px 70px rgba(30, 53, 43, 0.1);
  --radius: 22px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { min-width: 0; background: var(--paper); }

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(233, 241, 229, 0.75), transparent 42%),
    var(--paper);
}

button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:disabled, select:disabled { cursor: not-allowed; opacity: 0.58; }
a { color: inherit; }
[hidden] { display: none !important; }

.ambient {
  position: fixed;
  z-index: -1;
  border-radius: 50%;
  filter: blur(18px);
  opacity: 0.6;
  pointer-events: none;
}

.ambient-one {
  width: 420px;
  height: 420px;
  top: -190px;
  left: -160px;
  background: rgba(197, 226, 189, 0.58);
}

.ambient-two {
  width: 360px;
  height: 360px;
  right: -190px;
  bottom: -140px;
  background: rgba(224, 231, 177, 0.42);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  font-size: 17px;
  font-weight: 760;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  grid-template-columns: repeat(3, 5px);
  align-items: end;
  gap: 3px;
  width: 28px;
  height: 28px;
  padding: 6px;
  border-radius: 9px;
  background: var(--ink);
}

.brand-mark i { display: block; width: 5px; border-radius: 3px; background: var(--lime); }
.brand-mark i:nth-child(1) { height: 7px; }
.brand-mark i:nth-child(2) { height: 15px; }
.brand-mark i:nth-child(3) { height: 11px; }
.brand.compact { font-size: 16px; }

.auth-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.04fr) minmax(420px, 0.96fr);
  width: min(1180px, calc(100% - 48px));
  min-height: min(760px, calc(100vh - 64px));
  margin: 32px auto;
  overflow: hidden;
  border: 1px solid rgba(211, 223, 214, 0.8);
  border-radius: 30px;
  background: rgba(248, 250, 246, 0.78);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.auth-intro {
  display: flex;
  flex-direction: column;
  padding: 48px 58px;
  background:
    radial-gradient(circle at 82% 20%, rgba(204, 229, 106, 0.42), transparent 26%),
    linear-gradient(145deg, #e7efe5 0%, #f5f8f1 64%, #e9f0df 100%);
}

.auth-copy { max-width: 570px; margin: auto 0; padding: 58px 0; }
.eyebrow, .panel-kicker, .step-label {
  margin: 0 0 10px;
  color: var(--green);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.auth-copy h1 {
  max-width: 590px;
  margin: 0;
  font-family: ui-serif, Georgia, "Times New Roman", serif;
  font-size: clamp(46px, 5vw, 72px);
  font-weight: 540;
  letter-spacing: -0.055em;
  line-height: 0.98;
}

.lede {
  max-width: 520px;
  margin: 26px 0 0;
  color: #52635b;
  font-size: 18px;
  line-height: 1.65;
}

.privacy-note {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  max-width: 470px;
  padding-top: 22px;
  border-top: 1px solid rgba(88, 112, 98, 0.19);
}

.privacy-dot {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border: 3px solid #bcd78b;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(23, 107, 77, 0.08);
}

.privacy-note strong { font-size: 13px; }
.privacy-note p { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.55; }

.auth-panel {
  display: grid;
  place-items: center;
  padding: 48px 58px;
  background: rgba(255, 255, 253, 0.95);
}

.auth-status-card { width: min(100%, 460px); }
.form-heading { margin-bottom: 28px; }
.form-heading h2 { margin: 0; font-size: 30px; letter-spacing: -0.04em; }
.form-heading > p:last-child { margin: 9px 0 0; color: var(--muted); font-size: 14px; }

label { display: grid; gap: 8px; color: #3f5048; font-size: 12px; font-weight: 700; }
.auth-panel label { margin-bottom: 17px; }
.field-grid { display: grid; gap: 14px; }
.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }

input, select, textarea {
  width: 100%;
  border: 1px solid #d7e0d9;
  border-radius: 11px;
  outline: none;
  background: #fbfcfa;
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input, select { height: 45px; padding: 0 13px; }
textarea { min-height: 126px; padding: 12px 13px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: #75a68f; background: white; box-shadow: 0 0 0 4px rgba(23, 107, 77, 0.09); }
input::placeholder, textarea::placeholder { color: #9daaa3; }

.file-row { display: flex; align-items: center; gap: 12px; margin: -5px 0 21px; }
.file-row input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.file-button { display: inline-flex; width: auto; margin: 0 !important; padding: 8px 11px; border: 1px solid #d8e1da; border-radius: 9px; background: white; cursor: pointer; }
.file-row span { overflow: hidden; color: #7b8882; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.auth-loader { display: flex; align-items: center; gap: 8px; min-height: 48px; margin: 24px 0; }
.auth-loader i { width: 10px; height: 10px; border-radius: 50%; background: var(--green); animation: pulse 1.1s ease-in-out infinite; }
.auth-loader i:nth-child(2) { animation-delay: 120ms; }
.auth-loader i:nth-child(3) { animation-delay: 240ms; }
.auth-alternative { margin-top: 14px; text-decoration: none; }
.field-help { margin: -8px 0 18px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.auth-panel input[readonly] { background: #eef3ef; color: #53635c; }

.primary-button, .secondary-button, .ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 0;
  border-radius: 11px;
  font-weight: 760;
}

.primary-button { min-height: 48px; padding: 0 18px; background: var(--ink); color: white; box-shadow: 0 8px 22px rgba(20, 37, 30, 0.14); }
.primary-button:hover { background: var(--green-dark); transform: translateY(-1px); }
.primary-button:disabled { transform: none; }
.wide { width: 100%; }
.button-arrow { color: var(--lime); font-size: 18px; }
.microcopy { margin: 15px 0 0; color: #88948e; font-size: 10px; line-height: 1.5; text-align: center; }
.microcopy code { font-size: 10px; }
.form-error, .app-error { border: 1px solid #efd1d2; border-radius: 10px; background: #fff3f3; color: #9d3f46; font-size: 12px; line-height: 1.5; }
.form-error { margin: -3px 0 15px; padding: 10px 12px; }

.app-shell { min-height: 100vh; }
.connection-status { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 650; }
.connection-status i { width: 7px; height: 7px; border-radius: 50%; background: #55a571; box-shadow: 0 0 0 4px rgba(85, 165, 113, 0.12); }
.user-identity { display: grid; gap: 1px; text-align: right; }
.user-identity strong { max-width: 260px; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.user-identity em { color: var(--muted); font-size: 10px; font-style: normal; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; }
.ghost-button { min-height: 34px; padding: 0 11px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.65); color: #53635c; font-size: 11px; }

.admin-panel { margin: 26px 0 18px; padding: 24px; border: 1px solid #cdded2; border-radius: 18px; background: rgba(244, 249, 243, 0.97); box-shadow: 0 14px 36px rgba(30, 53, 43, 0.08); }
.admin-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.admin-heading h2 { margin: 0; font-size: 24px; letter-spacing: -0.035em; }
.admin-heading p:last-child { margin: 7px 0 0; color: var(--muted); font-size: 13px; }
.guest-access { margin-top: 24px; padding: 20px; border: 1px solid #cdded2; border-radius: 14px; background: rgba(255,255,255,.7); }
.guest-heading, .invitation-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.guest-heading h3 { margin: 0; font-size: 19px; letter-spacing: -.025em; }
.guest-heading p:last-child { max-width: 720px; margin: 7px 0 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.invite-user-form { display: flex; align-items: end; gap: 12px; margin: 20px 0; }
.invite-user-form label { flex: 1; max-width: 520px; }
.invite-user-form .primary-button { min-height: 45px; }
.guest-invitation { margin: 16px 0; padding: 16px; border: 1px solid #a8cdb7; border-radius: 12px; background: #e6f4eb; }
.invitation-heading { align-items: center; }
.invitation-heading strong { overflow-wrap: anywhere; font-size: 13px; }
.guest-invitation p { margin: 8px 0; color: #42604f; font-size: 11px; line-height: 1.55; }
.invitation-link-label { margin-top: 14px; margin-bottom: 7px; }
.invitation-link-row { display: flex; align-items: center; gap: 10px; }
.invitation-link-row input { min-width: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.invitation-link-row button { flex-shrink: 0; }
.guest-list-status { margin: 18px 0 10px; color: var(--muted); font-size: 12px; }
.guest-users-list { display: grid; gap: 8px; }
.guest-user { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 18px; padding: 13px; border: 1px solid var(--line); border-radius: 10px; background: white; }
.guest-user-identity { display: grid; min-width: 0; gap: 5px; }
.guest-user-identity strong { font-size: 12px; overflow-wrap: anywhere; }
.guest-user-identity > span { color: var(--muted); font-size: 10px; line-height: 1.5; }
.guest-user-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.guest-status { padding: 5px 8px; border-radius: 7px; background: #edf2ee; color: #52675b; font-size: 10px; font-weight: 750; }
.guest-status.active { background: #e1f2e7; color: #176b4d; }
.guest-status.pending { background: #fff2d8; color: #84621d; }
.guest-status.revoked, .guest-status.expired { background: #f8e8e8; color: #9d3f46; }
.revoke-user { color: #9d3f46; }
.guest-revoke-confirmation { grid-column: 1 / -1; padding: 13px; border: 1px solid #efd1d2; border-radius: 9px; background: #fff5f4; }
.guest-revoke-confirmation p { margin: 0 0 12px; color: #873c42; font-size: 12px; line-height: 1.5; }
.guest-revoke-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.revoke-confirm-button { min-height: 36px; background: #9d3f46; box-shadow: none; font-size: 11px; }
.revoke-confirm-button:hover { background: #7d3339; }
.admin-section-heading { margin-top: 24px; }
.admin-section-heading h3 { margin: 0; font-size: 18px; letter-spacing: -.025em; }
.admin-key-grid { display: grid; grid-template-columns: 0.8fr 1.5fr 1fr; gap: 18px; margin-top: 22px; }
.key-status, .generate-key { display: grid; align-content: start; gap: 7px; padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: white; }
.key-status > span, .generate-key > span { color: var(--muted); font-size: 11px; font-weight: 750; text-transform: uppercase; }
.key-status small { color: var(--muted); line-height: 1.5; }
.reveal-key-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; width: fit-content; margin-top: 5px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 9px; background: #f8faf8; color: var(--ink); font: inherit; font-size: 11px; font-weight: 750; cursor: pointer; }
.reveal-key-button:hover:not(:disabled) { border-color: #a9beb0; background: white; }
.reveal-key-button:disabled { cursor: not-allowed; opacity: .5; }
.reveal-key-button svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
#mcp-key-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 10px; padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: white; }
.generate-key .primary-button { align-self: end; margin-top: 9px; }
.generated-key { margin-top: 15px; padding: 15px; border: 1px solid #a8cdb7; border-radius: 12px; background: #e6f4eb; }
.generated-key > strong { font-size: 12px; }
.generated-key > div { display: flex; align-items: center; gap: 10px; margin-top: 9px; }
.generated-key code { flex: 1; overflow-wrap: anywhere; font-size: 12px; }
.bigquery-setup { margin-top: 24px; padding-top: 22px; border-top: 1px solid #dce7df; }
.bigquery-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.bigquery-heading h3 { margin: 0; font-size: 19px; letter-spacing: -.025em; }
.bigquery-heading > div:first-child > p:last-child { max-width: 720px; margin: 7px 0 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.bigquery-status-card { display: grid; min-width: 220px; gap: 3px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 11px; background: white; }
.bigquery-status-card span { color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.bigquery-status-card strong { font-size: 13px; }
.bigquery-status-card small { color: var(--muted); font-size: 9px; line-height: 1.45; }
#bigquery-form { margin-top: 16px; }
.bigquery-config-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: white; }
.bigquery-config-grid input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }
.bigquery-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 12px; }
.bigquery-actions .primary-button { min-height: 39px; }
#bigquery-error { margin-top: 12px; }
.mcp-setup { margin-top: 20px; padding-top: 20px; border-top: 1px solid #dce7df; }
.mcp-setup-heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; }
.mcp-setup-heading h3 { margin: 2px 0 0; font-size: 19px; letter-spacing: -.025em; }
.mcp-setup-heading > code { padding: 5px 8px; border-radius: 7px; background: #e3ece5; color: #42604f; font-size: 10px; }
.mcp-setup-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 14px; }
.mcp-setup article { min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: white; }
.mcp-setup h4 { margin: 0; font-size: 14px; }
.mcp-setup article > p { margin: 6px 0 12px; color: var(--muted); font-size: 11px; line-height: 1.55; }
.mcp-setup pre { margin: 0; padding: 12px; overflow-x: auto; border-radius: 9px; background: #13271e; color: #e8f5ec; font-size: 10px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.mcp-secret-note { margin: 11px 0 0; color: var(--muted); font-size: 10px; }
.result-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.control-panel { margin-top: 34px; padding: 19px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,255,253,.9); box-shadow: 0 12px 38px rgba(34, 56, 46, .06); }
#analysis-form { scroll-margin-top: 80px; }
.control-grid { display: grid; grid-template-columns: 1.25fr 1.45fr .82fr .82fr auto; gap: 12px; align-items: end; }
.control-grid label, .advanced-grid label { gap: 6px; }
.control-grid input, .control-grid select { height: 43px; }
.control-help { margin: 8px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.control-help:empty { display: none; }
.date-correction { margin: 12px 0 0; padding: 12px 14px; border: 1px solid #d0dfbd; border-radius: 9px; background: #edf3e5; color: #465a40; font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.run-button { min-width: 154px; height: 43px; min-height: 43px; }
.advanced-controls { margin-top: 17px; border-top: 1px solid #e8ede9; }
.advanced-controls summary { padding: 14px 2px 0; color: #485850; cursor: pointer; font-size: 12px; font-weight: 760; list-style-position: inside; }
.advanced-controls summary span { margin-left: 8px; color: #909b95; font-size: 10px; font-weight: 500; }
.advanced-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; padding-top: 17px; }

.app-error { margin: 18px 0; padding: 13px 15px; }
#countries-warning { scroll-margin-top: 90px; }
.empty-state, .loading-state { display: grid; grid-template-columns: minmax(260px, .85fr) minmax(320px, 1.15fr); align-items: center; min-height: 410px; margin-top: 26px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(255,255,252,.66); }
.empty-state > div:last-child { max-width: 530px; padding: 50px; }
.empty-state h2 { margin: 0; font-family: ui-serif, Georgia, serif; font-size: 37px; font-weight: 540; letter-spacing: -.045em; line-height: 1.05; }
.empty-state p:last-child { margin: 18px 0 0; color: var(--muted); font-size: 14px; line-height: 1.65; }
.empty-visual { position: relative; align-self: stretch; min-height: 360px; background: radial-gradient(circle at center, #eef4e7 0 31%, transparent 32%), linear-gradient(140deg, #ddeadd, #f3f6eb); }
.search-orbit { position: absolute; top: 50%; left: 50%; width: 140px; height: 140px; border: 1px solid rgba(23, 107, 77, .28); border-radius: 50%; transform: translate(-50%, -50%); }
.search-orbit::before, .search-orbit::after { content: ""; position: absolute; border-radius: 50%; }
.search-orbit::before { inset: 25px; background: var(--ink); box-shadow: inset 0 0 0 13px var(--lime); }
.search-orbit::after { width: 53px; height: 13px; right: -34px; bottom: 3px; border-radius: 8px; background: var(--ink); transform: rotate(45deg); }
.search-orbit span { position: absolute; z-index: 2; top: 60px; left: 56px; width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 17px -16px 0 #4e8d70, 29px 5px 0 #9bc072, -17px 17px 0 #799f87; }
.signal { position: absolute; border-radius: 10px; background: rgba(255,255,255,.74); box-shadow: 0 8px 20px rgba(45,70,56,.08); }
.signal::after { content: ""; display: block; height: 6px; margin: 10px; border-radius: 4px; background: #a8c194; }
.signal-a { width: 86px; height: 28px; top: 24%; left: 14%; transform: rotate(-8deg); }
.signal-b { width: 70px; height: 28px; right: 12%; top: 35%; transform: rotate(7deg); }
.signal-c { width: 100px; height: 28px; right: 16%; bottom: 22%; transform: rotate(-5deg); }

.loading-state { grid-template-columns: auto 1fr; gap: 26px; min-height: 190px; padding: 40px; }
.loading-state p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.loader { display: flex; gap: 5px; align-items: end; width: 48px; height: 34px; padding: 8px; border-radius: 11px; background: var(--ink); }
.loader i { width: 6px; border-radius: 3px; background: var(--lime); animation: pulse 1s ease-in-out infinite; }
.loader i:nth-child(1) { height: 8px; }
.loader i:nth-child(2) { height: 18px; animation-delay: 120ms; }
.loader i:nth-child(3) { height: 12px; animation-delay: 240ms; }
@keyframes pulse { 0%,100% { opacity: .42; transform: scaleY(.7); } 50% { opacity: 1; transform: scaleY(1); } }

.results { margin-top: 42px; }
.result-warnings { margin-top: 18px; padding: 12px 14px; border: 1px solid #efd7a8; border-radius: 10px; background: #fff8e8; color: #74551d; font-size: 11px; line-height: 1.55; }
.result-heading h2 { margin: 0; font-size: 30px; letter-spacing: -.045em; }
.result-heading > div > p:last-child { margin: 8px 0 0; color: var(--muted); font-size: 12px; }
.result-actions { display: flex; align-items: center; gap: 8px; }
.export-menu { position: relative; }
.secondary-button { min-height: 39px; padding: 0 14px; border: 1px solid #cfd9d2; background: white; color: #42534b; font-size: 12px; }
.compact-button { min-height: 35px; padding: 0 12px; font-size: 11px; }
.export-options { position: absolute; z-index: 15; top: calc(100% + 8px); right: 0; width: 220px; padding: 7px; border: 1px solid var(--line); border-radius: 12px; background: white; box-shadow: 0 15px 35px rgba(26, 46, 37, .14); }
.export-options a { display: block; padding: 9px 10px; border-radius: 7px; color: #46574e; font-size: 11px; text-decoration: none; }
.export-options a:hover { background: var(--soft); }

.kpi-strip { display: grid; grid-template-columns: repeat(5, 1fr); margin-top: 21px; overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: white; }
.kpi { min-width: 0; padding: 22px 21px; border-left: 1px solid #e7ece8; }
.kpi:first-child { border-left: 0; }
.kpi span { color: #75837c; font-size: 10px; font-weight: 780; letter-spacing: .08em; text-transform: uppercase; }
.kpi strong { display: block; overflow: hidden; margin-top: 9px; font-size: clamp(25px, 2.6vw, 37px); letter-spacing: -.055em; text-overflow: ellipsis; white-space: nowrap; }
.kpi small { display: block; margin-top: 6px; color: #8c9892; font-size: 10px; }
.primary-kpi { background: var(--ink); color: white; }
.primary-kpi span, .primary-kpi small { color: #b9c8c0; }
.outcome-kpis { grid-template-columns: repeat(6, 1fr); margin-top: 12px; }
.outcome-kpis .kpi strong { font-size: clamp(23px, 2.25vw, 33px); }

.insight-grid { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(300px, .75fr); gap: 18px; margin-top: 18px; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 10px 32px rgba(36, 58, 48, .045); }
.chart-panel, .action-panel { min-height: 410px; padding: 24px; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.panel-heading h3 { margin: 0; font-size: 18px; letter-spacing: -.03em; }
.panel-kicker { margin-bottom: 6px; font-size: 9px; }
.legend { display: flex; align-items: center; gap: 6px; color: #7c8982; font-size: 9px; }
.legend i { width: 8px; height: 8px; border-radius: 2px; }
.install-color { background: var(--green); }
.tap-color { margin-left: 5px; background: #a9d1ba; }
.chart { min-height: 325px; margin-top: 18px; }
.chart svg { display: block; width: 100%; height: 325px; overflow: visible; }
.chart-empty { display: grid; place-items: center; min-height: 300px; color: #8a9690; font-size: 12px; text-align: center; }

.action-panel { position: relative; overflow: hidden; }
.action-panel::after { content: ""; position: absolute; right: -68px; bottom: -82px; width: 190px; height: 190px; border-radius: 50%; background: #eff4e6; }
.donut-wrap { position: relative; width: 180px; height: 180px; margin: 28px auto 18px; }
.donut-chart, .donut-chart svg { width: 180px; height: 180px; }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; }
.donut-center strong { font-size: 32px; letter-spacing: -.05em; }
.donut-center span { color: #8a9690; font-size: 9px; text-transform: uppercase; letter-spacing: .1em; }
.action-legend { position: relative; z-index: 1; display: grid; gap: 10px; }
.action-legend > div { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 9px; color: #66756e; font-size: 10px; }
.action-legend i { width: 8px; height: 8px; border-radius: 50%; }
.action-legend strong { color: var(--ink); font-size: 12px; }
.exact-dot { background: var(--green); }
.negative-dot { background: var(--amber); }
.monitor-dot { background: #cbd6d0; }

.mapping-panel { margin-top: 18px; padding: 24px; }
.query-cost { color: var(--muted); font-size: 9px; }
.mapping-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1px; margin-top: 18px; overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: var(--line); }
.mapping-grid > div { min-width: 0; padding: 15px; background: white; }
.mapping-grid span { display: block; color: var(--muted); font-size: 8px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.mapping-grid strong { display: block; overflow: hidden; margin-top: 7px; font-size: 20px; letter-spacing: -.035em; text-overflow: ellipsis; white-space: nowrap; }
.mapping-note { margin: 12px 0 0; color: var(--muted); font-size: 10px; line-height: 1.55; }

.opportunity-panel, .explorer-panel { margin-top: 18px; padding: 24px; }
.table-heading, .explorer-heading { align-items: center; }
.table-controls { display: flex; gap: 8px; }
.table-controls input { width: 190px; height: 35px; font-size: 11px; }
.table-controls select { width: 150px; height: 35px; font-size: 11px; }
.table-scroll { margin-top: 20px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 11px; }
th { padding: 10px 12px; border-bottom: 1px solid #dfe6e1; color: #829087; font-size: 8px; font-weight: 800; letter-spacing: .08em; text-align: right; text-transform: uppercase; white-space: nowrap; }
th:first-child, th:nth-child(2) { text-align: left; }
.sort-button { display: flex; align-items: center; justify-content: flex-end; gap: 5px; width: 100%; min-height: 24px; padding: 0; border: 0; background: transparent; color: inherit; font: inherit; letter-spacing: inherit; text-align: inherit; text-transform: inherit; white-space: nowrap; }
th:first-child .sort-button, th:nth-child(2) .sort-button { justify-content: flex-start; }
.sort-button:hover { color: var(--ink); }
.sort-button:focus-visible { border-radius: 4px; outline: 2px solid var(--green); outline-offset: 3px; }
.sort-indicator { width: 9px; color: #aab5af; font-size: 10px; line-height: 1; text-align: center; }
th[aria-sort="ascending"] .sort-indicator, th[aria-sort="descending"] .sort-indicator { color: var(--green); }
td { padding: 12px; border-bottom: 1px solid #edf1ee; color: #526159; text-align: right; white-space: nowrap; }
td:first-child, td:nth-child(2) { max-width: 240px; overflow: hidden; color: var(--ink); font-weight: 650; text-align: left; text-overflow: ellipsis; }
td:nth-child(2) { color: #75827b; font-weight: 500; }
tbody tr:hover { background: #f8faf7; }
.action-chip { display: inline-block; padding: 5px 7px; border-radius: 7px; font-size: 8px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.action-add_exact_candidate { background: #dff0e5; color: #176b4d; }
.action-negative_keyword_review { background: #fae9d7; color: #a05c18; }
.action-monitor { background: #edf1ee; color: #6e7c74; }
.table-count { margin: 11px 0 0; color: #909b95; font-size: 9px; text-align: right; }
.no-rows { padding: 36px 10px !important; color: #89958f !important; text-align: center !important; }

.tabs { display: flex; gap: 3px; padding: 3px; border-radius: 10px; background: #edf2ee; }
.tab { min-height: 31px; padding: 0 11px; border: 0; border-radius: 8px; background: transparent; color: #748078; font-size: 10px; font-weight: 700; }
.tab.active { background: white; color: var(--ink); box-shadow: 0 2px 8px rgba(30,50,41,.07); }
.explorer-content { min-height: 180px; }
.explorer-content th:first-child, .explorer-content th:nth-child(2), .explorer-content td:first-child, .explorer-content td:nth-child(2) { text-align: left; }

.data-note { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-top: 18px; }
.data-note > div { padding: 19px 21px; border: 1px solid var(--line); border-radius: 15px; background: rgba(241, 245, 240, .74); }
.data-note strong { font-size: 11px; }
.data-note p { margin: 6px 0 0; color: #748078; font-size: 10px; line-height: 1.55; }
.methodology-footer { margin-top: 18px; border: 1px solid var(--line); border-radius: 15px; background: rgba(241, 245, 240, .74); }
.methodology-footer > summary { padding: 15px 18px; color: #55655d; cursor: pointer; font-size: 11px; font-weight: 760; }
.methodology-footer .data-note { margin: 0; padding: 0 16px 16px; }
.methodology-footer .data-note > div { background: white; }

.toast { position: fixed; z-index: 100; right: 22px; bottom: 22px; max-width: 360px; padding: 13px 16px; border-radius: 12px; background: var(--ink); color: white; box-shadow: 0 18px 40px rgba(20,37,30,.25); font-size: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

@media (max-width: 1050px) {
  .auth-shell { grid-template-columns: 1fr 1fr; width: calc(100% - 32px); }
  .auth-intro, .auth-panel { padding: 38px; }
  .control-grid { grid-template-columns: 1fr 1.25fr .8fr .8fr; }
  .run-button { grid-column: 1 / -1; width: 100%; }
  .kpi-strip { grid-template-columns: repeat(3, 1fr); }
  .kpi:nth-child(4) { border-left: 0; }
  .kpi:nth-child(n+4) { border-top: 1px solid #e7ece8; }
  .insight-grid { grid-template-columns: 1fr; }
  .action-panel { min-height: auto; }
  .admin-key-grid { grid-template-columns: 1fr; }
  .guest-user { grid-template-columns: minmax(0, 1fr) auto; }
  .guest-user-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .outcome-kpis { grid-template-columns: repeat(3, 1fr); }
  .outcome-kpis .kpi:nth-child(4) { border-left: 0; }
  .outcome-kpis .kpi:nth-child(n+4) { border-top: 1px solid #e7ece8; }
  .mapping-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .mcp-setup-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .auth-shell { display: block; width: calc(100% - 22px); margin: 11px auto; }
  .auth-intro { min-height: 420px; padding: 30px; }
  .auth-copy { padding: 64px 0; }
  .auth-copy h1 { font-size: 48px; }
  .auth-panel { padding: 34px 26px; }
  .guest-access { padding: 15px; }
  .invite-user-form, .invitation-link-row { flex-direction: column; align-items: stretch; }
  .invite-user-form label { max-width: none; }
  .two-columns { grid-template-columns: 1fr; gap: 0; }
  .control-grid, .advanced-grid { grid-template-columns: 1fr; }
  .empty-state { grid-template-columns: 1fr; }
  .empty-visual { min-height: 260px; }
  .empty-state > div:last-child { padding: 36px 28px; }
  .kpi-strip { grid-template-columns: repeat(2, 1fr); }
  .kpi:nth-child(3), .kpi:nth-child(5) { border-left: 0; }
  .kpi:nth-child(n+3) { border-top: 1px solid #e7ece8; }
  .outcome-kpis .kpi:nth-child(4) { border-left: 1px solid #e7ece8; }
  .result-heading { align-items: flex-start; }
  .result-actions { flex-shrink: 0; }
  .table-heading, .explorer-heading { align-items: flex-start; flex-direction: column; }
  .table-controls { width: 100%; }
  .table-controls label, .table-controls input, .table-controls select { width: 100%; }
  .tabs { max-width: 100%; overflow-x: auto; }
  .data-note { grid-template-columns: 1fr; }
  .bigquery-heading { flex-direction: column; }
  .bigquery-status-card { width: 100%; }
  .bigquery-config-grid { grid-template-columns: 1fr; }
  .bigquery-actions { flex-direction: column; }
  .bigquery-actions button { width: 100%; }
  .mapping-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #mcp-key-form { grid-template-columns: 1fr; }
  .panel { border-radius: 17px; }
}

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