:root {
  --bg: #080b12;
  --surface: #10151f;
  --surface-2: #151c29;
  --line: #252e3d;
  --line-soft: #1d2532;
  --text: #f2f5fb;
  --muted: #8d99ab;
  --muted-2: #657184;
  --blue: #3277ff;
  --blue-2: #65a0ff;
  --green: #35d07f;
  --amber: #f8bd57;
  --red: #f06a72;
  --radius: 16px;
  --shadow: 0 24px 80px rgba(0, 0, 0, .28);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { min-height: 100vh; margin: 0; background: radial-gradient(circle at 70% -20%, rgba(50,119,255,.12), transparent 36%), var(--bg); }
button, input, select { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--blue-2); outline-offset: 2px; }
[hidden] { display: none !important; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(430px, 100%); padding: 42px; border: 1px solid var(--line); border-radius: 22px; background: rgba(16,21,31,.95); box-shadow: var(--shadow); }
.login-card h1 { margin: 14px 0 10px; font-size: 30px; letter-spacing: -.03em; }
.brand-mark { width: 48px; height: 48px; display: grid; place-items: center; border: 1px solid #3e7cff; border-radius: 13px; color: white; background: linear-gradient(145deg, #347bff, #17429a); box-shadow: 0 12px 30px rgba(50,119,255,.25); font-size: 13px; font-weight: 800; letter-spacing: .04em; }
.brand-mark.small { width: 36px; height: 36px; border-radius: 10px; font-size: 11px; }
.stack { display: grid; gap: 11px; margin-top: 26px; }
label { color: #c7cfdb; font-size: 12px; font-weight: 650; letter-spacing: .02em; }
input, select { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; color: var(--text); background: #0b1019; transition: border-color .2s, box-shadow .2s; }
input:hover, select:hover { border-color: #364156; }
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(50,119,255,.12); }
.form-error { min-height: 20px; margin: 2px 0 0; color: #ff8990; font-size: 13px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 232px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 24px 16px 20px; border-right: 1px solid var(--line-soft); background: rgba(9,12,19,.91); backdrop-filter: blur(20px); display: flex; flex-direction: column; }
.sidebar { scrollbar-width: none; }
.sidebar::-webkit-scrollbar { display: none; }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 30px; }
.brand strong { display: block; font-size: 14px; }
.brand span { display: block; margin-top: 2px; color: var(--muted-2); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; }
.nav { display: grid; gap: 5px; }
.nav-item { width: 100%; display: flex; align-items: center; gap: 12px; padding: 11px 12px; border: 0; border-radius: 10px; color: var(--muted); background: transparent; cursor: pointer; text-align: left; font-size: 13px; transition: .18s ease; }
.nav-item span { color: #4f5c70; font-size: 10px; font-variant-numeric: tabular-nums; }
.nav-item:hover { color: var(--text); background: rgba(255,255,255,.035); }
.nav-item.active { color: white; background: #171e2b; box-shadow: inset 2px 0 var(--blue); }
.nav-item.active span { color: var(--blue-2); }
.sidebar-footer { margin-top: auto; padding: 18px 9px 2px; border-top: 1px solid var(--line-soft); display: grid; gap: 12px; }
.provider-state { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; }
.provider-state i, .health-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(53,208,127,.1); }

.workspace { min-width: 0; }
.topbar { height: 106px; display: flex; align-items: center; justify-content: space-between; padding: 0 clamp(24px, 4vw, 58px); border-bottom: 1px solid var(--line-soft); background: rgba(8,11,18,.72); backdrop-filter: blur(16px); position: sticky; top: 0; z-index: 10; }
.topbar h1 { margin: 4px 0 0; font-size: 24px; letter-spacing: -.025em; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.content { width: min(1480px, 100%); margin: 0 auto; padding: 34px clamp(24px, 4vw, 58px) 70px; }
.view { display: none; animation: fade .2s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
.eyebrow { margin: 0; color: #65748c; font-size: 9px; line-height: 1.3; font-weight: 750; letter-spacing: .16em; text-transform: uppercase; }
.muted, .panel p { color: var(--muted); line-height: 1.65; }

.button { border: 1px solid transparent; border-radius: 9px; padding: 10px 14px; font-size: 12px; font-weight: 700; cursor: pointer; transition: transform .15s, background .15s, border-color .15s, opacity .15s; }
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .5; cursor: wait; transform: none; }
.button.primary { background: var(--blue); color: white; box-shadow: 0 8px 22px rgba(50,119,255,.2); }
.button.primary:hover { background: #4484ff; }
.button.secondary { border-color: #39465c; background: #182131; color: #eef3fc; }
.button.secondary:hover { border-color: #53627b; background: #1c2739; }
.button.ghost { border-color: var(--line); background: transparent; color: #bdc7d7; }
.button.danger { border-color: rgba(240,106,114,.3); background: rgba(240,106,114,.08); color: #ff9299; }
.button.wide { width: 100%; padding: 12px; }
.text-button { padding: 0; border: 0; color: var(--blue-2); background: none; cursor: pointer; font-size: 12px; }
.text-button:hover { color: #8bb7ff; }

.health-pill, .status { display: inline-flex; align-items: center; gap: 8px; width: fit-content; border: 1px solid var(--line); border-radius: 999px; padding: 6px 10px; color: var(--muted); background: rgba(255,255,255,.02); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.health-pill.healthy, .status.healthy, .status.completed { border-color: rgba(53,208,127,.22); color: #6ae59f; background: rgba(53,208,127,.07); }
.health-pill.warning, .status.warning, .status.partial, .status.expiring { border-color: rgba(248,189,87,.25); color: #ffd17e; background: rgba(248,189,87,.07); }
.health-pill.error, .status.error, .status.failed, .status.reauth_required { border-color: rgba(240,106,114,.25); color: #ff9299; background: rgba(240,106,114,.07); }
.health-pill.neutral i { background: #66748a; box-shadow: none; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; margin-bottom: 14px; }
.metric-card, .panel { border: 1px solid var(--line-soft); border-radius: var(--radius); background: linear-gradient(145deg, rgba(18,24,35,.96), rgba(13,18,27,.96)); box-shadow: 0 8px 24px rgba(0,0,0,.08); }
.metric-card { min-height: 126px; padding: 21px; display: grid; align-content: space-between; }
.metric-card > span { color: var(--muted); font-size: 11px; }
.metric-card strong { margin-top: 13px; font-size: clamp(24px, 3vw, 32px); font-weight: 650; letter-spacing: -.035em; font-variant-numeric: tabular-nums; }
.metric-card small { margin-top: 8px; color: var(--muted-2); font-size: 10px; }
.panel { padding: 24px; }
.panel h2 { margin: 5px 0 0; font-size: 18px; letter-spacing: -.02em; }
.panel h3 { margin: 3px 0 4px; }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.split-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 14px; margin: 14px 0; }
.hero-panel { position: relative; overflow: hidden; }
.hero-panel::after { content: ""; position: absolute; width: 220px; height: 220px; right: -80px; bottom: -110px; border: 1px solid rgba(70,130,255,.16); border-radius: 50%; box-shadow: 0 0 70px rgba(50,119,255,.12); pointer-events: none; }
.meta-badge { display: grid; place-items: center; height: 30px; padding: 0 11px; border-radius: 8px; color: #a9c7ff; background: rgba(50,119,255,.1); border: 1px solid rgba(50,119,255,.2); font-size: 9px; font-weight: 800; letter-spacing: .12em; }
.hero-actions { display: flex; gap: 9px; margin: 20px 0; }
.flow-line { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; color: #7d899c; font-size: 10px; }
.flow-line span { border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; background: #0c111b; }
.flow-line b { color: #3d4a5f; }
.detail-list { margin: 20px 0 0; }
.detail-list div { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; border-top: 1px solid var(--line-soft); font-size: 11px; }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; color: #d7dfec; font-variant-numeric: tabular-nums; }

.table-panel { margin-top: 14px; padding: 0; overflow: hidden; }
.table-panel .panel-heading { padding: 22px 24px 17px; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 11px; white-space: nowrap; }
th { padding: 11px 17px; color: #68758a; background: #0c111a; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); text-align: left; font-size: 9px; text-transform: uppercase; letter-spacing: .1em; }
td { padding: 14px 17px; color: #cbd3df; border-bottom: 1px solid var(--line-soft); font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(255,255,255,.015); }
td small { display: block; margin-top: 3px; color: var(--muted-2); }
.empty { padding: 32px; text-align: center; color: var(--muted-2); }
.switch { display: inline-flex; position: relative; width: 35px; height: 20px; }
.switch input { width: 1px; height: 1px; opacity: 0; position: absolute; }
.switch span { width: 100%; height: 100%; border-radius: 999px; background: #2a3342; cursor: pointer; transition: .2s; }
.switch span::after { content: ""; position: absolute; width: 14px; height: 14px; left: 3px; top: 3px; border-radius: 50%; background: #8b96a7; transition: .2s; }
.switch input:checked + span { background: rgba(50,119,255,.75); }
.switch input:checked + span::after { transform: translateX(15px); background: white; }

.section-intro { display: flex; align-items: center; justify-content: space-between; gap: 28px; margin-bottom: 14px; }
.section-intro p { max-width: 700px; margin: 0; color: var(--muted); line-height: 1.6; font-size: 12px; }
.connection-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.business-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; margin-top: 14px; }
.business-card { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 15px 17px; border: 1px solid var(--line-soft); border-radius: 12px; background: #0d131d; }
.business-card h3 { margin: 3px 0; font-size: 13px; }
.business-card p { margin: 0; color: var(--muted-2); font-size: 10px; }
.connection-card { padding: 21px; border: 1px solid var(--line-soft); border-radius: var(--radius); background: var(--surface); }
.connection-card-top { display: flex; justify-content: space-between; gap: 20px; }
.connection-card h3 { margin: 4px 0; font-size: 16px; }
.connection-card p { margin: 0; color: var(--muted); font-size: 11px; }
.connection-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 18px; }
.connection-meta div { padding: 10px; border: 1px solid var(--line-soft); border-radius: 9px; background: #0c111a; }
.connection-meta span { display: block; color: var(--muted-2); font-size: 9px; text-transform: uppercase; letter-spacing: .08em; }
.connection-meta strong { display: block; margin-top: 4px; font-size: 12px; font-weight: 600; }
.connection-actions { display: flex; gap: 12px; margin-top: 16px; }
.roadmap-panel { margin-top: 14px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.roadmap-panel > div { display: flex; align-items: center; gap: 15px; }
.roadmap-panel p { margin: 3px 0 0; font-size: 11px; }
.roadmap-dot { width: 34px; height: 34px; border: 1px dashed #3d4a5e; border-radius: 10px; }

.filter-panel { display: grid; grid-template-columns: repeat(4, 1fr) auto; align-items: end; gap: 12px; }
.filter-panel > div { display: grid; gap: 7px; }
.custom-metric-panel { margin-top: 14px; }
.metric-builder { display: grid; grid-template-columns: 1.2fr repeat(4, 1fr) auto; align-items: end; gap: 9px; margin-top: 18px; }
.metric-builder > div { display: grid; gap: 7px; }
.metric-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 15px; }
.metric-chip { display: inline-flex; align-items: center; gap: 9px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 999px; color: #c0cad9; background: #0b1019; font-size: 10px; }
.metric-chip button { width: 17px; height: 17px; padding: 0; border: 0; border-radius: 50%; color: #9ba7b9; background: #202938; cursor: pointer; line-height: 1; }
.hint { color: var(--muted-2); font-size: 10px; }
.api-grid { grid-template-columns: 1.2fr 1fr; }
.inline-form { display: grid; gap: 8px; margin-top: 23px; }
.inline-form > div { display: flex; gap: 8px; }
.secret-box { margin-top: 16px; padding: 14px; border: 1px solid rgba(53,208,127,.22); border-radius: 10px; background: rgba(53,208,127,.05); }
.secret-box > div { display: flex; justify-content: space-between; }
.secret-box code { display: block; margin: 12px 0 8px; color: #a9eec5; word-break: break-all; font-size: 11px; }
.secret-box small { color: var(--muted); }
.code-panel pre { margin: 18px 0; padding: 17px; overflow: auto; border: 1px solid var(--line-soft); border-radius: 10px; background: #090d14; color: #9fc0ff; font: 11px/1.75 ui-monospace, SFMono-Regular, Consolas, monospace; }
.code-panel code { font-family: inherit; }
.setup-grid { grid-template-columns: 1fr 1.15fr; }
.check-list, .url-list { display: grid; gap: 8px; margin-top: 20px; }
.check-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line-soft); border-radius: 9px; color: #b8c2d1; font-size: 11px; }
.check-item i { width: 8px; height: 8px; border-radius: 50%; background: var(--red); }
.check-item.ok i { background: var(--green); }
.url-item { padding: 10px 12px; border: 1px solid var(--line-soft); border-radius: 9px; background: #0b1018; }
.url-item span { display: block; color: var(--muted-2); font-size: 9px; text-transform: uppercase; letter-spacing: .08em; }
.url-item code { display: block; margin-top: 5px; color: #adc7f5; font-size: 10px; white-space: normal; word-break: break-all; }
.review-panel { display: grid; grid-template-columns: 1.5fr 1fr; gap: 34px; margin-top: 14px; }
.review-panel ul { margin: 8px 0 0; padding-left: 18px; color: var(--muted); font-size: 11px; line-height: 2; }
.approval-panel { display: grid; gap: 20px; margin-top: 14px; }
.approval-panel ol { margin: 0; padding-left: 22px; display: grid; gap: 8px; color: var(--muted); }
.approval-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.approval-actions .button { text-decoration: none; }
.activity-intro { display: flex; align-items: end; justify-content: space-between; gap: 34px; }
.activity-intro > div:first-child { max-width: 760px; }
.activity-intro h2 { margin-bottom: 8px; }
.activity-intro p { margin-bottom: 0; }
.activity-filters { min-width: 480px; display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: end; }
.activity-filters > div { display: grid; gap: 7px; }
.url-stack { display: grid; gap: 4px; max-width: 340px; white-space: normal; }
.url-stack a { color: #8ab5ff; text-decoration: none; word-break: break-all; }
.url-stack a:hover { text-decoration: underline; }
.change-list { display: grid; gap: 5px; max-width: 340px; white-space: normal; }
.change-detail { padding: 6px 7px; border: 1px solid var(--line); border-radius: 6px; background: #0b1018; font-size: 9px; line-height: 1.45; }
.change-detail b { color: #b8c5d8; }
.change-detail del { color: #f39197; text-decoration: none; }
.change-detail ins { color: #69dfa0; text-decoration: none; }

.toast-region { position: fixed; right: 22px; bottom: 22px; z-index: 100; display: grid; gap: 8px; pointer-events: none; }
.toast { width: min(380px, calc(100vw - 44px)); padding: 13px 15px; border: 1px solid var(--line); border-radius: 10px; background: #17202e; color: #e7edf7; box-shadow: var(--shadow); font-size: 12px; animation: toast-in .2s ease; }
.toast.error { border-color: rgba(240,106,114,.35); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 1050px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .split-grid { grid-template-columns: 1fr; }
  .connection-grid { grid-template-columns: 1fr; }
  .business-grid { grid-template-columns: 1fr 1fr; }
  .metric-builder { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: sticky; z-index: 20; height: auto; padding: 12px 14px; border-right: 0; border-bottom: 1px solid var(--line-soft); flex-direction: row; align-items: center; overflow-x: auto; }
  .brand { padding: 0 12px 0 0; flex: 0 0 auto; }
  .brand > div:last-child, .sidebar-footer { display: none; }
  .nav { display: flex; gap: 4px; }
  .nav-item { width: auto; flex: 0 0 auto; padding: 9px 10px; }
  .nav-item span { display: none; }
  .topbar { height: auto; min-height: 88px; padding: 16px 20px; }
  .topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
  .content { padding: 24px 16px 60px; }
  .filter-panel { grid-template-columns: 1fr 1fr; }
  .filter-panel > div:first-child, .filter-panel .button { grid-column: 1 / -1; }
  .metric-builder { grid-template-columns: 1fr 1fr; }
  .metric-builder > div:first-child, .metric-builder .button { grid-column: 1 / -1; }
  .section-intro { align-items: flex-start; flex-direction: column; }
  .review-panel { grid-template-columns: 1fr; gap: 10px; }
  .activity-intro { align-items: stretch; flex-direction: column; }
  .activity-filters { min-width: 0; }
}

@media (max-width: 500px) {
  .login-card { padding: 30px 24px; }
  .metric-grid { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; }
  .topbar h1 { font-size: 20px; }
  .health-pill { display: none; }
  .panel { padding: 20px; }
  .table-panel { padding: 0; }
  .inline-form > div { display: grid; }
  .roadmap-panel { align-items: flex-start; flex-direction: column; }
  .business-grid { grid-template-columns: 1fr; }
  .activity-filters { grid-template-columns: 1fr; }
}
