:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #17202a;
  --muted: #667085;
  --line: #e4e7ec;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --success: #067647;
  --warning: #b54708;
  --danger: #b42318;
  --sidebar: #101828;
  --sidebar-muted: #98a2b3;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(16, 24, 40, 0.08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--text); background: var(--bg); }
button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.eyebrow { margin: 0 0 8px; font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: #b7c4d8; }
.eyebrow.dark { color: #667085; }
.muted { color: var(--muted); margin: 0; }
.muted-light { color: #c9d2df; max-width: 560px; font-size: 17px; line-height: 1.6; }

.brand-mark { width: 58px; height: 58px; border-radius: 18px; background: #fff; color: #101828; display: grid; place-items: center; font-weight: 900; letter-spacing: -.04em; box-shadow: 0 10px 35px rgba(0,0,0,.2); }
.brand-mark.small { width: 38px; height: 38px; border-radius: 12px; font-size: 13px; box-shadow: none; }

.auth-body { min-height: 100vh; background: #0f172a; }
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, 1.05fr) minmax(420px, .95fr); }
.auth-brand { padding: clamp(40px, 7vw, 96px); display: flex; flex-direction: column; justify-content: center; background: radial-gradient(circle at 15% 10%, #24488d 0, transparent 36%), linear-gradient(145deg, #101828 0%, #17233c 100%); }
.auth-brand h1 { margin: 32px 0 12px; color: #fff; font-size: clamp(36px, 5vw, 64px); line-height: 1.02; letter-spacing: -.045em; max-width: 780px; }
.security-note { margin-top: 36px; padding: 18px 20px; border: 1px solid rgba(255,255,255,.15); border-radius: 14px; background: rgba(255,255,255,.06); color: white; display: grid; gap: 4px; max-width: 560px; }
.security-note span { color: #c9d2df; font-size: 14px; line-height: 1.45; }
.auth-card { background: #fff; padding: clamp(36px, 7vw, 92px); display: flex; flex-direction: column; justify-content: center; }
.auth-card-head h2 { margin: 0 0 8px; font-size: 36px; letter-spacing: -.035em; }
.tabs { display: flex; gap: 8px; padding: 5px; border-radius: 12px; background: #f2f4f7; margin: 28px 0 22px; }
.tab { border: 0; background: transparent; color: #667085; padding: 10px 14px; border-radius: 9px; font-weight: 700; flex: 1; }
.tab.active { background: #fff; color: #101828; box-shadow: 0 1px 3px rgba(16,24,40,.12); }
.auth-form { display: grid; gap: 16px; }
.auth-form label { display: grid; gap: 7px; font-size: 13px; font-weight: 700; color: #344054; }
.auth-form input { width: 100%; border: 1px solid #d0d5dd; border-radius: 10px; padding: 12px 13px; outline: none; background: #fff; color: #101828; }
.auth-form input:focus { border-color: #84adff; box-shadow: 0 0 0 4px #eff4ff; }
.auth-form small { color: #667085; font-weight: 500; line-height: 1.4; }
.primary-button, .secondary-button, .ghost-button { border: 0; border-radius: 10px; padding: 11px 15px; font-weight: 800; transition: transform .12s ease, opacity .12s ease; }
.primary-button { background: var(--accent); color: white; margin-top: 4px; }
.secondary-button { background: #fff; color: #344054; border: 1px solid #d0d5dd; }
.ghost-button { background: #f2f4f7; color: #344054; }
.primary-button:hover, .secondary-button:hover, .ghost-button:hover { transform: translateY(-1px); }
button:disabled, input:disabled { opacity: .55; cursor: not-allowed; transform: none !important; }
.banner, .form-message { border-radius: 10px; padding: 12px 14px; margin: 18px 0; font-size: 14px; line-height: 1.4; }
.banner { background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; }
.form-message.error { background: #fff1f3; border: 1px solid #fda4af; color: #9f1239; }
.form-message.success { background: #ecfdf3; border: 1px solid #a6f4c5; color: #067647; }
.build-line { color: #98a2b3; font-size: 12px; margin: 24px 0 0; }

.app-body { background: var(--bg); min-height: 100vh; }
.app-shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--sidebar); color: #fff; padding: 22px 16px; display: flex; flex-direction: column; }
.sidebar-brand { display: flex; align-items: center; gap: 11px; color: #fff; text-decoration: none; font-weight: 800; padding: 0 8px 22px; }
.sidebar-nav { display: grid; gap: 3px; }
.nav-link { color: var(--sidebar-muted); text-decoration: none; padding: 10px 12px; border-radius: 9px; font-size: 14px; font-weight: 650; }
.nav-link:hover, .nav-link.active { color: #fff; background: rgba(255,255,255,.08); }
.sidebar-foot { margin-top: auto; padding: 14px 10px 4px; border-top: 1px solid rgba(255,255,255,.09); color: #98a2b3; font-size: 12px; display: flex; gap: 8px; align-items: center; }
.system-dot { width: 8px; height: 8px; border-radius: 999px; background: #32d583; box-shadow: 0 0 0 4px rgba(50,213,131,.12); }
.main-content { padding: 28px clamp(22px, 4vw, 54px) 70px; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 24px; margin-bottom: 26px; }
.topbar h1 { margin: 0; font-size: 30px; letter-spacing: -.035em; }
.topbar-actions { display: flex; gap: 12px; align-items: center; }
.tenant-switcher { display: grid; gap: 3px; color: #667085; font-size: 11px; font-weight: 700; }
.tenant-switcher select { min-width: 180px; border: 1px solid #d0d5dd; background: white; border-radius: 9px; padding: 8px 10px; color: #344054; }
.user-chip { display: flex; gap: 10px; align-items: center; min-width: 150px; }
.user-chip > span:last-child { display: grid; }
.user-chip strong { font-size: 13px; }
.user-chip small { color: #667085; text-transform: capitalize; }
.user-avatar { width: 36px; height: 36px; border-radius: 50%; background: #e0e7ff; color: #3730a3; display: grid; place-items: center; font-weight: 900; font-size: 12px; }
.section-block { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; margin-bottom: 18px; box-shadow: 0 1px 2px rgba(16,24,40,.02); scroll-margin-top: 22px; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 20px; }
.section-heading h2, .module-row h2 { margin: 0; font-size: 21px; letter-spacing: -.025em; }
.metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.metric-card { border: 1px solid var(--line); border-radius: 13px; padding: 18px; display: grid; gap: 4px; background: linear-gradient(180deg, #fff 0%, #fcfcfd 100%); }
.metric-card span { color: #667085; font-size: 13px; font-weight: 650; }
.metric-card strong { font-size: 32px; letter-spacing: -.04em; }
.metric-card small { color: #98a2b3; }
.two-column-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.status-card { border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.status-card-head { display: flex; gap: 13px; align-items: flex-start; margin-bottom: 16px; }
.status-card-head h3 { margin: 1px 0 4px; font-size: 16px; }
.status-card-head p { margin: 0; color: #667085; font-size: 13px; line-height: 1.45; }
.service-icon { width: 40px; height: 40px; border-radius: 11px; background: var(--accent-soft); color: #1d4ed8; display: grid; place-items: center; font-weight: 900; flex: 0 0 auto; }
.status-row { display: flex; justify-content: space-between; padding: 10px 0; border-top: 1px solid #f2f4f7; color: #667085; font-size: 13px; }
.status-row strong { color: #101828; }
.pill-row { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.pill { background: #f2f4f7; border-radius: 999px; padding: 5px 9px; font-size: 11px; color: #475467; font-weight: 700; }
.compact-section { padding: 20px 24px; }
.module-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.module-row p { color: #667085; margin: 6px 0 0; font-size: 13px; }
.module-number { display: flex; align-items: baseline; gap: 6px; color: #667085; }
.module-number strong { color: #101828; font-size: 28px; }
.count-badge { padding: 6px 10px; border-radius: 999px; background: #f2f4f7; color: #475467; font-size: 12px; font-weight: 700; }
.status-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.status-item { background: var(--surface-soft); border: 1px solid #eef2f6; border-radius: 11px; padding: 12px; display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.status-item span { color: #667085; font-size: 12px; text-transform: capitalize; }
.status-item strong { font-size: 16px; }
.empty-state { color: #98a2b3; font-size: 13px; padding: 8px 0; }

@media (max-width: 1000px) {
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { align-items: flex-start; }
  .topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
}

@media (max-width: 760px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-brand { min-height: 36vh; padding: 36px 24px; }
  .auth-brand h1 { font-size: 36px; margin-top: 22px; }
  .auth-card { padding: 34px 22px 50px; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 14px; }
  .sidebar-nav { display: flex; overflow-x: auto; gap: 4px; }
  .nav-link { white-space: nowrap; }
  .sidebar-foot { display: none; }
  .main-content { padding: 20px 14px 50px; }
  .topbar { display: grid; }
  .topbar-actions { justify-content: flex-start; }
  .tenant-switcher { width: 100%; }
  .tenant-switcher select { width: 100%; }
  .metrics-grid, .two-column-grid { grid-template-columns: 1fr; }
  .section-block { padding: 18px; }
}

/* Onboarding */
.section-copy { color: #667085; margin: 6px 0 0; font-size: 13px; line-height: 1.5; max-width: 760px; }
.setup-form { display: grid; gap: 18px; }
.form-grid { display: grid; gap: 14px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.setup-form label { display: grid; gap: 7px; color: #344054; font-size: 12px; font-weight: 750; }
.setup-form input:not([type="checkbox"]), .setup-form select { width: 100%; min-height: 42px; border: 1px solid #d0d5dd; border-radius: 9px; padding: 9px 11px; background: #fff; color: #101828; outline: none; }
.setup-form input:focus, .setup-form select:focus { border-color: #84adff; box-shadow: 0 0 0 4px #eff4ff; }
.form-actions { display: flex; gap: 9px; flex-wrap: wrap; }
.toggle-row { display: flex; gap: 18px; flex-wrap: wrap; padding: 13px 15px; background: #f8fafc; border: 1px solid #eef2f6; border-radius: 10px; }
.toggle-row label { display: flex; align-items: center; gap: 7px; color: #475467; font-weight: 650; }
.input-action { display: flex; gap: 7px; }
.input-action .secondary-button { white-space: nowrap; padding-inline: 12px; }
.connection-list { display: grid; gap: 10px; margin-top: 20px; }
.connection-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; border: 1px solid #e4e7ec; border-radius: 12px; padding: 15px 16px; background: #fcfcfd; }
.connection-main { min-width: 0; }
.connection-main h3 { margin: 0 0 4px; font-size: 14px; }
.connection-main p { margin: 0; color: #667085; font-size: 12px; overflow-wrap: anywhere; }
.connection-actions { display: flex; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
.mini-button { border: 1px solid #d0d5dd; border-radius: 8px; background: #fff; color: #344054; padding: 7px 9px; font-size: 11px; font-weight: 750; }
.mini-button.primary { border-color: #b2ccff; background: #eff4ff; color: #1849a9; }
.status-badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 8px; font-size: 10px; font-weight: 800; text-transform: uppercase; margin-left: 6px; }
.status-badge.connected, .status-badge.succeeded, .status-badge.in_sync { color: #067647; background: #ecfdf3; }
.status-badge.error, .status-badge.failed { color: #b42318; background: #fef3f2; }
.status-badge.untested, .status-badge.pending, .status-badge.queued, .status-badge.running { color: #b54708; background: #fffaeb; }
.inline-status { border: 1px dashed #d0d5dd; border-radius: 10px; padding: 11px 13px; color: #667085; font-size: 13px; }
.preview-table-wrap { overflow-x: auto; margin-top: 18px; }
.preview-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.preview-table th, .preview-table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid #eaecf0; white-space: nowrap; }
.preview-table th { color: #475467; background: #f9fafb; }
.setup-progress-grid .metric-card strong { font-size: 28px; }
.form-disabled { opacity: .68; pointer-events: none; }
@media (max-width: 1000px) { .form-grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .form-grid.two, .form-grid.three { grid-template-columns: 1fr; } .connection-card { align-items: flex-start; flex-direction: column; } .connection-actions { justify-content: flex-start; } .input-action { align-items: stretch; } }
