:root {
  color-scheme: dark;
  --bg: #070a12;
  --panel: rgba(17, 21, 34, 0.9);
  --panel-strong: #121725;
  --line: rgba(255, 255, 255, 0.085);
  --text: #f2f5fb;
  --muted: #929bb0;
  --purple: #8b5cf6;
  --purple-soft: rgba(139, 92, 246, 0.16);
  --green: #43e6ad;
  --danger: #ff6b81;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); overflow-x: hidden; }
button, input, select { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }

.ambient { position: fixed; width: 520px; height: 520px; border-radius: 50%; filter: blur(120px); opacity: .17; pointer-events: none; }
.ambient-a { background: #7542ff; top: -220px; right: -130px; }
.ambient-b { background: #0ecb9c; bottom: -300px; left: -240px; opacity: .1; }

.auth-layout { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) 470px; align-items: center; gap: 8vw; max-width: 1240px; margin: 0 auto; padding: 64px 42px; position: relative; z-index: 1; }
.auth-copy { max-width: 650px; }
.brand-mark { width: 68px; height: 68px; display: grid; place-items: center; border-radius: 21px; background: linear-gradient(145deg, #9b7cff 0%, #6946ea 56%, #35d7ae 150%); box-shadow: 0 18px 52px rgba(126, 86, 243, .36), inset 0 1px rgba(255,255,255,.3); transform: rotate(-5deg); }
.brand-mark span { font-weight: 900; font-size: 32px; transform: rotate(5deg); }
.brand-mark.compact { width: 42px; height: 42px; border-radius: 13px; }
.brand-mark.compact span { font-size: 20px; }
.eyebrow { margin: 30px 0 12px; font-size: 11px; font-weight: 800; letter-spacing: .19em; color: #a993ff; }
.auth-copy h1 { max-width: 640px; margin: 0; font-size: clamp(44px, 5vw, 72px); line-height: 1.02; letter-spacing: -.05em; }
.lead { max-width: 590px; margin: 24px 0 34px; color: #a8b0c1; font-size: 18px; line-height: 1.65; }
.trust-row { display: flex; flex-wrap: wrap; gap: 10px; }
.trust-row span, .security-badge { border: 1px solid var(--line); background: rgba(255,255,255,.035); padding: 9px 12px; border-radius: 999px; color: #c9cede; font-size: 12px; }

.auth-card { background: linear-gradient(160deg, rgba(25,30,48,.96), rgba(12,15,26,.98)); border: 1px solid var(--line); border-radius: 28px; box-shadow: var(--shadow); padding: 34px; }
.mode-line { display: flex; align-items: center; gap: 8px; color: var(--green); font-size: 10px; font-weight: 800; letter-spacing: .13em; }
.status-dot { width: 7px; height: 7px; background: var(--green); border-radius: 50%; box-shadow: 0 0 0 4px rgba(67,230,173,.08), 0 0 14px rgba(67,230,173,.55); }
.auth-card h2 { margin: 22px 0 7px; font-size: 30px; letter-spacing: -.03em; }
.muted { color: var(--muted); margin: 0; }
.auth-steps { list-style: none; margin: 30px 0 22px; padding: 0; display: grid; gap: 12px; }
.auth-step { display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 13px; border: 1px solid var(--line); background: rgba(255,255,255,.025); border-radius: 17px; padding: 15px; transition: border-color .2s, background .2s; }
.auth-step.verified { border-color: rgba(67,230,173,.38); background: rgba(67,230,173,.055); }
.step-number { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 10px; background: var(--purple-soft); color: #bba9ff; font-weight: 800; font-size: 13px; }
.verified .step-number { color: var(--green); background: rgba(67,230,173,.12); }
.step-content { display: grid; gap: 4px; }
.step-content strong { font-size: 14px; }
.step-content span { color: var(--muted); font-size: 11px; line-height: 1.35; }
.button { border: 0; border-radius: 11px; padding: 10px 14px; font-weight: 750; font-size: 12px; cursor: pointer; transition: transform .15s, opacity .15s, background .15s; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .38; }
.button.primary { color: white; background: linear-gradient(135deg, #8c66f4, #7148e7); box-shadow: 0 8px 26px rgba(111,72,231,.22); }
.button.secondary { background: rgba(255,255,255,.065); border: 1px solid rgba(255,255,255,.07); }
.button.wide { width: 100%; padding: 14px; }
.inline-message { min-height: 20px; margin: 0 0 10px; color: #b8c0d1; font-size: 12px; }
.inline-message.error { color: #ff91a2; }
.fine-print { color: #717b91; font-size: 10px; line-height: 1.5; text-align: center; margin: 17px 15px 0; }

.app-layout { min-height: 100vh; display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; border-right: 1px solid var(--line); background: rgba(9,12,20,.94); backdrop-filter: blur(22px); display: flex; flex-direction: column; padding: 22px 15px; z-index: 4; }
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 0 7px 24px; }
.sidebar-brand > div:last-child { display: grid; gap: 3px; }
.sidebar-brand strong { font-size: 14px; }
.sidebar-brand span { color: var(--muted); font-size: 10px; }
.nav-label { color: #626c81; font-size: 9px; letter-spacing: .17em; font-weight: 800; margin: 17px 12px 8px; }
nav { flex: 1; overflow: auto; }
nav button { width: 100%; display: flex; gap: 11px; align-items: center; border: 0; background: transparent; color: #929caf; border-radius: 11px; padding: 10px 12px; margin: 2px 0; font-size: 12px; text-align: left; cursor: pointer; }
nav button > span { color: #707b92; width: 16px; font-size: 15px; }
nav button:hover { background: rgba(255,255,255,.035); color: #d7dcea; }
nav button.active { color: white; background: linear-gradient(90deg, rgba(132,89,241,.2), rgba(132,89,241,.06)); box-shadow: inset 2px 0 #8b63f3; }
nav button.active > span { color: #ad96ff; }
.sidebar-footer { border-top: 1px solid var(--line); padding: 16px 7px 0; }
.system-state { display: flex; align-items: center; gap: 11px; }
.system-state > div { display: grid; gap: 3px; }
.system-state strong { font-size: 11px; }
.system-state span:last-child { color: var(--muted); font-size: 9px; }
.text-button { border: 0; background: transparent; color: #727d92; cursor: pointer; font-size: 10px; padding: 14px 0 0; }

.workspace { min-width: 0; }
.topbar { height: 88px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); padding: 0 34px; background: rgba(8,11,18,.66); backdrop-filter: blur(18px); position: sticky; top: 0; z-index: 3; }
.topbar .eyebrow { margin: 0 0 5px; font-size: 8px; }
.topbar h2 { margin: 0; font-size: 21px; letter-spacing: -.02em; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.latency-pill, .owner-pill { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: rgba(255,255,255,.03); padding: 8px 11px; border-radius: 12px; color: #afb7c8; font-size: 10px; }
.owner-pill { cursor: pointer; }
.owner-pill > span:first-child { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 8px; background: var(--purple-soft); color: #b8a5ff; font-weight: 900; }
.content-view { padding: 32px 34px 60px; max-width: 1260px; margin: 0 auto; }
.page-intro { display: flex; justify-content: space-between; align-items: start; gap: 20px; margin-bottom: 23px; }
.page-intro h3 { margin: 0 0 7px; font-size: 24px; letter-spacing: -.025em; }
.page-intro p { color: var(--muted); margin: 0; font-size: 13px; }
.security-badge { color: var(--green); border-color: rgba(67,230,173,.17); background: rgba(67,230,173,.06); white-space: nowrap; }
.security-callout { display: flex; gap: 14px; padding: 17px 18px; border: 1px solid rgba(67,230,173,.15); background: linear-gradient(90deg, rgba(67,230,173,.07), rgba(67,230,173,.025)); border-radius: 16px; margin-bottom: 20px; }
.shield-icon { flex: 0 0 auto; width: 31px; height: 31px; display: grid; place-items: center; color: var(--green); border-radius: 10px; background: rgba(67,230,173,.12); font-weight: 900; }
.security-callout strong { font-size: 12px; }
.security-callout p { margin: 4px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.integration-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.integration-card, .hsm-card, .placeholder-card { border: 1px solid var(--line); background: linear-gradient(155deg, rgba(20,25,40,.88), rgba(13,17,28,.88)); border-radius: 19px; box-shadow: 0 15px 45px rgba(0,0,0,.16); }
.integration-card { padding: 20px; }
.card-heading { display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 12px; margin-bottom: 20px; }
.provider-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; font-weight: 900; }
.provider-icon.violet { color: #c8b8ff; background: rgba(139,92,246,.16); }
.provider-icon.blue { color: #9ac9ff; background: rgba(70,144,255,.14); }
.provider-icon.green { color: #85f0cb; background: rgba(67,230,173,.12); }
.provider-icon.amber { color: #ffd295; background: rgba(255,169,69,.13); }
.card-heading h4 { margin: 0 0 3px; font-size: 14px; }
.card-heading p { margin: 0; color: var(--muted); font-size: 10px; }
.connection-state { display: inline-flex; align-items: center; gap: 6px; color: #8c96aa; font-size: 9px; }
.connection-state i { width: 6px; height: 6px; border-radius: 50%; background: #657087; }
.connection-state.connected { color: var(--green); }
.connection-state.connected i { background: var(--green); box-shadow: 0 0 10px rgba(67,230,173,.55); }
.connection-state.optional { color: #c7a16d; }
.integration-form { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(120px, .7fr) auto; gap: 10px; align-items: end; }
label { color: #98a2b5; font-size: 9px; font-weight: 700; display: grid; gap: 6px; }
input, select { width: 100%; min-width: 0; color: #eef1f7; border: 1px solid rgba(255,255,255,.09); background: rgba(5,8,14,.48); border-radius: 10px; padding: 10px 11px; outline: none; font-size: 11px; }
input:focus, select:focus { border-color: rgba(139,92,246,.72); box-shadow: 0 0 0 3px rgba(139,92,246,.1); }
input::placeholder { color: #596277; }
.integration-form .button { min-height: 37px; white-space: nowrap; }
.card-result { min-height: 15px; margin: 11px 0 0; color: var(--muted); font-size: 9px; }
.card-result.success { color: var(--green); }
.card-result.error { color: #ff91a2; }
.hsm-card { margin-top: 16px; padding: 20px; display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.mini-label { color: #a993ff; font-size: 8px; letter-spacing: .16em; font-weight: 800; }
.hsm-card h4 { margin: 6px 0 4px; }
.hsm-card p { margin: 0; color: var(--muted); font-size: 11px; }
.locked-state { color: #a7b0c2; border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; font-size: 9px; white-space: nowrap; }
.placeholder-card { min-height: 420px; display: grid; place-content: center; text-align: center; padding: 60px; }
.placeholder-card > span { color: #8f71f1; font-size: 38px; }
.placeholder-card h3 { margin: 14px 0 7px; }
.placeholder-card p { color: var(--muted); margin: 0; }
.toast { position: fixed; right: 24px; bottom: 24px; max-width: 360px; padding: 13px 16px; border: 1px solid var(--line); background: #171c2c; border-radius: 12px; box-shadow: var(--shadow); color: #dce1ed; font-size: 11px; opacity: 0; transform: translateY(8px); pointer-events: none; transition: .2s; z-index: 10; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1060px) {
  .integration-form { grid-template-columns: 1fr 140px; }
  .integration-form .button { grid-column: 1 / -1; }
}
@media (max-width: 860px) {
  .auth-layout { grid-template-columns: 1fr; max-width: 600px; padding: 40px 24px; }
  .auth-copy h1 { font-size: 44px; }
  .app-layout { grid-template-columns: 76px 1fr; }
  .sidebar { padding-inline: 10px; }
  .sidebar-brand > div:last-child, nav button:not(.active)::after, nav button { font-size: 0; }
  .sidebar-brand { justify-content: center; padding-inline: 0; }
  nav button { justify-content: center; padding: 12px; }
  nav button > span { width: auto; font-size: 17px; }
  .nav-label, .system-state > div, .text-button { display: none; }
  .system-state { justify-content: center; }
  .integration-grid { grid-template-columns: 1fr; }
}
@media (max-width: 590px) {
  .app-layout { display: block; }
  .sidebar { position: fixed; height: 64px; width: 100%; top: auto; bottom: 0; padding: 8px; border-right: 0; border-top: 1px solid var(--line); }
  .sidebar-brand, .nav-label, .sidebar-footer { display: none; }
  nav { display: flex; gap: 3px; }
  nav button { display: none; }
  nav button[data-view="overview"], nav button[data-view="positions"], nav button[data-view="integrations"], nav button[data-view="settings"] { display: flex; flex: 1; margin: 0; }
  .topbar { padding: 0 18px; }
  .latency-pill, #owner-address { display: none; }
  .content-view { padding: 24px 17px 90px; }
  .page-intro, .hsm-card { align-items: flex-start; flex-direction: column; }
  .security-badge { align-self: flex-start; }
  .integration-form { grid-template-columns: 1fr; }
  .integration-form .button { grid-column: auto; }
  .auth-card { padding: 25px 20px; }
  .auth-step { grid-template-columns: 34px 1fr; }
  .auth-step .button { grid-column: 1 / -1; }
}
/* One-time enrollment stays inside the existing owner login flow. */
#enrollment-field { display: grid; gap: 8px; margin: 18px 0; color: #b9c2d9; font-size: 13px; }
#enrollment-field[hidden] { display: none; }
#enrollment-code { min-width: 0; width: 100%; padding: 12px; border: 1px solid #39445f; border-radius: 10px; background: #101726; color: #f4f7ff; }
