:root {
  --ink: #101827;
  --muted: #667085;
  --surface: #ffffff;
  --canvas: #f2f5f7;
  --green: #059669;
  --green-soft: #e8f7f1;
  --orange: #ff5a1f;
  --orange-soft: #fff0e8;
  --blue: #2563eb;
  --danger: #dc2626;
  --line: #e3e8ee;
  --shadow: 0 18px 45px rgba(16, 24, 39, .10);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); }
body { margin: 0; min-height: 100vh; background: var(--canvas); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.is-hidden { display: none !important; }

.global-loader {
  position: fixed;
  inset: max(12px, env(safe-area-inset-top)) 14px auto;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 10px;
  width: max-content;
  max-width: calc(100% - 28px);
  margin-inline: auto;
  padding: 11px 16px;
  border-radius: 999px;
  color: #fff;
  background: rgba(16, 24, 39, .94);
  box-shadow: var(--shadow);
  font-size: .86rem;
  font-weight: 800;
}
.spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 28px 18px; background: radial-gradient(circle at 80% 10%, #ffe2d5, transparent 34%), linear-gradient(145deg, #101827, #243047 60%, #0f766e); }
.auth-card { width: min(100%, 460px); padding: 30px; border-radius: 28px; background: rgba(255,255,255,.98); box-shadow: 0 28px 70px rgba(0,0,0,.26); }
.brand-mark { display: inline-flex; align-items: center; min-height: 42px; padding: 0 13px; border-radius: 12px; background: var(--ink); color: #fff; font-size: 1.6rem; font-weight: 1000; letter-spacing: -.08em; }
.brand-mark-small { min-height: 34px; font-size: 1.2rem; }
.auth-card h1 { margin: 8px 0; font-size: clamp(2rem, 7vw, 3rem); line-height: .98; letter-spacing: -.05em; }
.auth-card > p:not(.eyebrow):not(.form-message) { color: var(--muted); line-height: 1.55; }
.eyebrow { margin: 18px 0 4px; color: var(--orange); font-size: .72rem; font-weight: 950; letter-spacing: .14em; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin: 22px 0 16px; padding: 5px; border-radius: 14px; background: #edf1f5; }
.auth-tabs button { padding: 10px; border: 0; border-radius: 10px; color: var(--muted); background: transparent; font-weight: 800; }
.auth-tabs button.is-active { color: var(--ink); background: #fff; box-shadow: 0 4px 14px rgba(16,24,39,.08); }
.auth-form, .stack-form { display: grid; gap: 14px; }
label { display: grid; gap: 7px; color: #344054; font-size: .82rem; font-weight: 800; }
input, select, textarea { width: 100%; border: 1px solid #d6dde5; border-radius: 13px; padding: 12px 13px; background: #fff; color: var(--ink); outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
textarea { resize: vertical; }
.consent { grid-template-columns: auto 1fr; align-items: start; }
.consent input { width: 18px; margin-top: 2px; }
.consent span { line-height: 1.4; }
.consent a { color: var(--blue); font-weight: 900; }
.consent small { color: var(--muted); font-size: .72rem; white-space: nowrap; }
.primary-button, .small-button { border: 0; border-radius: 14px; color: #fff; background: linear-gradient(135deg, var(--orange), #ef3f0b); font-weight: 900; box-shadow: 0 10px 24px rgba(255,90,31,.24); }
.primary-button { padding: 14px 18px; }
.small-button { padding: 10px 13px; }
.primary-button:disabled, .small-button:disabled { opacity: .55; cursor: wait; }
.secondary-link { display: block; margin-top: 18px; color: var(--blue); text-align: center; font-weight: 800; text-decoration: none; }
.form-message { min-height: 20px; margin: 12px 0 0; color: var(--danger); font-size: .85rem; font-weight: 800; }

.services-shell { min-height: 100vh; padding-bottom: 98px; }
.topbar { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; justify-content: space-between; padding: max(12px, env(safe-area-inset-top)) 18px 12px; color: #fff; background: rgba(16,24,39,.97); box-shadow: 0 8px 22px rgba(16,24,39,.18); backdrop-filter: blur(16px); }
.topbar > div { display: flex; align-items: center; gap: 9px; }
.app-label { font-weight: 900; }
.topbar-actions { gap: 7px !important; }
.connection-chip { padding: 7px 9px; border-radius: 999px; color: #b8f5dc; background: rgba(5,150,105,.18); font-size: .68rem; font-weight: 900; }
.connection-chip.is-offline { color: #fed7aa; background: rgba(234,88,12,.2); }
.icon-button { width: 40px; height: 40px; border: 1px solid rgba(255,255,255,.13); border-radius: 12px; color: #fff; background: rgba(255,255,255,.08); font-size: 1.25rem; }
.workspace-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; max-width: 1120px; margin: 16px auto 0; padding: 14px 18px; }
.workspace-bar small { display: block; color: var(--muted); font-size: .65rem; font-weight: 900; letter-spacing: .12em; }
.workspace-bar strong { display: block; margin-top: 3px; font-size: 1.04rem; }
.workspace-selectors { display: flex; align-items: end; gap: 10px; }
.workspace-bar label { min-width: 145px; }
.workspace-bar select { padding: 8px 10px; }
.app-content { width: min(100%, 1120px); margin: 0 auto; padding: 12px 18px 30px; }
.app-view { display: none; animation: reveal .18s ease-out; }
.app-view.is-active { display: block; }
@keyframes reveal { from { opacity: .2; transform: translateY(5px); } }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 12px 0 18px; }
.page-heading h1 { margin: 2px 0 0; font-size: clamp(1.7rem, 6vw, 2.5rem); letter-spacing: -.045em; }
.status-chip { padding: 8px 11px; border-radius: 999px; color: #92400e; background: #fef3c7; font-size: .72rem; font-weight: 900; text-transform: uppercase; }
.status-chip.is-approved { color: #047857; background: var(--green-soft); }
.status-chip.is-suspended, .status-chip.is-rejected { color: #b91c1c; background: #fee2e2; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.metric { min-height: 112px; padding: 16px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: 0 7px 22px rgba(16,24,39,.05); }
.metric small { color: var(--muted); font-size: .67rem; font-weight: 900; letter-spacing: .1em; }
.metric strong { display: block; margin-top: 12px; font-size: 1.8rem; letter-spacing: -.04em; }
.panel { margin-bottom: 16px; padding: 18px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); box-shadow: 0 8px 24px rgba(16,24,39,.05); }
.panel-heading { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.panel-heading small { color: var(--orange); font-size: .65rem; font-weight: 900; letter-spacing: .12em; }
.panel h2, .panel-heading h2 { margin: 3px 0; font-size: 1.12rem; }
.card-list { display: grid; gap: 12px; }
.service-card { padding: 16px; border: 1px solid var(--line); border-radius: 18px; background: #fff; box-shadow: 0 5px 17px rgba(16,24,39,.04); }
.service-card header { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.service-card h3 { margin: 0; font-size: 1.02rem; }
.service-card p { margin: 7px 0; color: var(--muted); font-size: .87rem; line-height: 1.45; }
.service-card footer { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 13px; }
.tag { display: inline-flex; padding: 6px 8px; border-radius: 999px; color: #475467; background: #f2f4f7; font-size: .68rem; font-weight: 850; }
.card-action { padding: 9px 11px; border: 1px solid #d5dce4; border-radius: 11px; color: var(--ink); background: #fff; font-size: .78rem; font-weight: 850; }
.card-action.is-primary { border-color: var(--green); color: #fff; background: var(--green); }
.card-action.is-danger { color: var(--danger); }
.account-summary { display: grid; gap: 12px; margin-bottom: 18px; padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: #f8fafc; }
.account-summary p { margin: 0; color: var(--muted); font-size: .84rem; line-height: 1.45; }
.account-id-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.account-id-row code { min-width: 0; overflow-wrap: anywhere; color: var(--ink); font-weight: 900; user-select: all; }
.danger-zone { display: grid; gap: 12px; margin-top: 18px; padding: 16px; border: 1px solid #fecaca; border-radius: 16px; background: #fff7f7; }
.danger-zone h3, .danger-zone p { margin: 0; }
.danger-zone p { color: #7f1d1d; font-size: .84rem; line-height: 1.45; }
.danger-button { padding: 13px 16px; border: 0; border-radius: 13px; color: #fff; background: #b91c1c; font-weight: 900; }
.danger-button:disabled { opacity: .55; cursor: wait; }
.confirmation-word { color: #991b1b; letter-spacing: .08em; }
.empty-state { padding: 28px 16px; border: 1px dashed #ccd5df; border-radius: 16px; color: var(--muted); text-align: center; }
.security-note { padding: 12px; border-radius: 13px; color: #475467; background: #f8fafc; font-size: .8rem; }

.onboarding-view { padding: 28px 18px 110px; }
.onboarding-card { width: min(100%, 680px); margin: 0 auto; padding: 24px; border-radius: 26px; background: #fff; box-shadow: var(--shadow); }
.onboarding-card h1 { margin: 4px 0 8px; font-size: 2rem; letter-spacing: -.04em; }
.onboarding-card > p:not(.eyebrow):not(.security-note) { color: var(--muted); line-height: 1.55; }
.hero-icon { display: grid; place-items: center; width: 62px; height: 62px; border-radius: 18px; background: var(--orange-soft); font-size: 2rem; }
.password-change-card .stack-form { margin-top: 20px; }
.password-change-card .security-note { margin-bottom: 0; }

.bottom-nav { position: fixed; inset: auto max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); z-index: 60; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; width: min(calc(100% - 20px), 760px); margin-inline: auto; padding: 7px; border-radius: 22px; color: #d8dee8; background: #101827; box-shadow: 0 20px 45px rgba(16,24,39,.28); }
.bottom-nav button { min-width: 0; padding: 9px 5px; border: 0; border-radius: 15px; color: inherit; background: transparent; font-size: .68rem; font-weight: 850; }
.bottom-nav button span { display: block; margin-bottom: 3px; font-size: 1.08rem; }
.bottom-nav button.is-active { color: #fff; background: var(--orange); }

.action-dialog { width: min(92vw, 520px); max-height: 88vh; padding: 0; border: 0; border-radius: 24px; box-shadow: 0 28px 70px rgba(16,24,39,.28); }
.action-dialog::backdrop { background: rgba(16,24,39,.64); backdrop-filter: blur(4px); }
.dialog-card { position: relative; padding: 24px; }
.dialog-card h2 { margin: 0 36px 18px 0; }
.dialog-close { position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; border: 0; border-radius: 10px; background: #f1f4f7; font-size: 1.35rem; }
.toast-region { position: fixed; z-index: 2000; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom)); width: min(calc(100% - 28px), 520px); transform: translateX(-50%); }
.toast { margin-top: 8px; padding: 14px 16px; border-radius: 15px; color: #fff; background: #101827; box-shadow: var(--shadow); font-weight: 800; animation: reveal .18s ease-out; }
.toast.is-error { background: #991b1b; }

@media (max-width: 760px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workspace-bar { align-items: end; }
  .workspace-selectors { width: min(62%, 390px); }
  .workspace-bar label { min-width: 0; flex: 1; }
  .app-content { padding-inline: 13px; }
  .bottom-nav { overflow-x: auto; grid-auto-columns: minmax(72px, 1fr); }
}

@media (max-width: 430px) {
  .auth-card { padding: 23px 18px; }
  .topbar { padding-inline: 12px; }
  .connection-chip { display: none; }
  .workspace-bar { align-items: stretch; flex-direction: column; padding-inline: 13px; }
  .workspace-selectors { width: 100%; }
  .metric { min-height: 98px; padding: 13px; }
  .metric strong { font-size: 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; }
}
