:root {
  --portal-ink: #303030;
  --portal-ink-strong: #1f2023;
  --portal-muted: #74777d;
  --portal-red: #fb4627;
  --portal-red-soft: #fff0ec;
  --portal-green: #24805d;
  --portal-mint: #85e7c1;
  --portal-line: #e1e3e7;
  --portal-bg: #f3f4f6;
  --portal-surface: #fbfbfc;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--portal-ink); background: var(--portal-bg); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select { font: inherit; }

.portal-brand { display: inline-flex; align-items: center; gap: 13px; color: var(--portal-ink); text-decoration: none; }
.portal-brand img { width: 58px; height: 44px; object-fit: contain; }
.portal-brand span { padding-left: 13px; border-left: 1px solid var(--portal-line); color: var(--portal-muted); font-size: 13px; font-weight: 650; }

.portal-auth-page { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, 1fr) minmax(480px, .85fr); background: var(--portal-bg); }
.portal-auth-brand { position: relative; display: flex; flex-direction: column; justify-content: space-between; min-height: 100vh; overflow: hidden; padding: clamp(34px, 6vw, 78px); color: white; background: var(--portal-ink-strong); }
.portal-auth-brand::before { content: ""; position: absolute; right: -120px; bottom: -180px; width: 540px; height: 540px; border: 95px solid rgba(251,70,39,.86); border-radius: 50%; }
.portal-auth-brand::after { content: ""; position: absolute; right: 150px; top: 110px; width: 190px; height: 190px; border-radius: 48px; background: var(--portal-mint); transform: rotate(18deg); opacity: .9; }
.portal-auth-brand .portal-brand { position: relative; z-index: 1; color: white; }
.portal-auth-brand .portal-brand span { color: rgba(255,255,255,.67); border-color: rgba(255,255,255,.2); }
.portal-auth-brand-copy { position: relative; z-index: 1; max-width: 650px; }
.portal-auth-brand-copy h2 { max-width: 720px; margin: 0; font-size: clamp(40px, 5.2vw, 78px); font-weight: 520; line-height: .98; letter-spacing: -.05em; }
.portal-auth-brand-copy p { max-width: 560px; margin: 22px 0 0; color: rgba(255,255,255,.7); font-size: 16px; line-height: 1.55; }
.portal-auth-main { display: grid; place-items: center; min-height: 100vh; padding: 36px; }
.portal-auth-card { width: min(470px, 100%); padding: 40px; border: 1px solid var(--portal-line); border-radius: 26px; background: var(--portal-surface); box-shadow: 0 28px 80px -42px rgba(31,32,35,.48); }
.portal-auth-card h1, .portal-page h1 { margin: 8px 0 10px; color: var(--portal-ink-strong); font-size: clamp(30px, 4vw, 46px); font-weight: 540; line-height: 1.04; letter-spacing: -.04em; }
.portal-auth-card p, .portal-page p { color: var(--portal-muted); line-height: 1.5; }

.eyebrow { margin: 0 0 8px; color: var(--portal-red) !important; font-size: 10px; font-weight: 900; letter-spacing: .13em; text-transform: uppercase; }
.portal-form { display: grid; gap: 16px; margin-top: 26px; }
.portal-form label { display: grid; gap: 7px; color: var(--portal-muted); font-size: 10px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.portal-form input, .portal-form select, .portal-table input, .portal-table select { width: 100%; min-height: 46px; padding: 10px 13px; border: 1px solid var(--portal-line); border-radius: 12px; outline: 0; color: var(--portal-ink); background: white; font: inherit; }
.portal-form input:focus, .portal-form select:focus, .portal-table select:focus { border-color: var(--portal-red); box-shadow: 0 0 0 3px var(--portal-red-soft); }
.primary-action { min-height: 46px; padding: 0 19px; border: 0; border-radius: 999px; color: white; background: var(--portal-red); box-shadow: 0 10px 24px -16px rgba(251,70,39,.9); font: inherit; font-weight: 850; cursor: pointer; }
.primary-action:hover { filter: brightness(1.04); }
.secondary-action { min-height: 40px; padding: 0 15px; border: 1px solid var(--portal-line); border-radius: 999px; color: var(--portal-ink); background: white; font: inherit; font-size: 12px; font-weight: 800; cursor: pointer; }
.danger-action { color: #c73232; }
.portal-error, .portal-success { padding: 12px 14px; border-radius: 11px; font-size: 13px; line-height: 1.45; }
.portal-error { color: #b42626; background: #fff0f0; }
.portal-success { color: #177454; background: #e9fbf4; }

.portal-topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 74px; padding: 11px max(24px, calc((100vw - 1400px) / 2)); border-bottom: 1px solid rgba(48,48,48,.07); background: rgba(243,244,246,.94); backdrop-filter: blur(18px); }
.portal-topbar nav { display: flex; align-items: center; gap: 4px; padding: 5px; border-radius: 999px; background: white; }
.portal-topbar nav a { min-height: 34px; display: inline-flex; align-items: center; padding: 0 13px; border-radius: 999px; color: var(--portal-muted); text-decoration: none; font-size: 12px; font-weight: 750; }
.portal-topbar nav a:hover { color: white; background: var(--portal-ink-strong); }
.portal-page { width: min(1400px, calc(100% - 40px)); margin: 38px auto 80px; }
.portal-page-head { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 24px; }
.portal-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.portal-panel { padding: 26px; border: 1px solid var(--portal-line); border-radius: 22px; background: var(--portal-surface); box-shadow: 0 18px 54px -44px rgba(31,32,35,.55); }
.portal-panel h2 { margin: 0 0 8px; color: var(--portal-ink-strong); font-size: 22px; font-weight: 560; letter-spacing: -.025em; }
.portal-panel dl { display: grid; grid-template-columns: 160px 1fr; gap: 10px 18px; padding: 16px; border-radius: 14px; background: white; }
.portal-panel dt { color: var(--portal-muted); font-size: 12px; }.portal-panel dd { margin: 0; font-size: 13px; font-weight: 750; }
.connection-status { display: inline-flex; align-items: center; gap: 8px; margin: 10px 0 18px; padding: 8px 11px; border-radius: 999px; color: var(--portal-muted); background: #f1f3f6; font-size: 12px; font-weight: 800; }
.connection-status.is-connected { color: #147153; background: #e8faf3; }
.portal-panel-heading { display: flex; align-items: start; justify-content: space-between; gap: 24px; }
.portal-panel-heading > div:first-child { min-width: 0; }
.portal-panel-heading p { max-width: 720px; margin: 4px 0 0; font-size: 13px; }
.connection-controls { display: flex; flex: 0 0 auto; align-items: center; gap: 7px; }
.connection-controls .connection-status { max-width: 330px; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.connection-disconnect { min-height: 34px; padding: 0 11px; border: 1px solid #f0cfd1; border-radius: 999px; color: #b53238; background: #fff; font-size: 10px; font-weight: 800; cursor: pointer; }
.connection-disconnect:hover { color: #fff; border-color: #c83f45; background: #c83f45; }
.portal-connection-form { grid-template-columns: minmax(0,1fr) auto; align-items: end; gap: 10px; margin-top: 17px; }
.portal-connection-form .primary-action { min-width: 190px; height: 46px; white-space: nowrap; }
.portal-connection-form .portal-error, .portal-connection-form .portal-success { grid-column: 1 / -1; }
.portal-table-shell { overflow-x: auto; border: 1px solid var(--portal-line); border-radius: 18px; background: white; }
.portal-table { width: 100%; min-width: 1180px; border-collapse: collapse; }
.portal-table th, .portal-table td { padding: 12px 11px; border-bottom: 1px solid var(--portal-line); text-align: left; vertical-align: middle; font-size: 12px; }
.portal-table th { color: var(--portal-muted); font-size: 9px; letter-spacing: .05em; text-transform: uppercase; }
.portal-table tr:last-child td { border-bottom: 0; }
.portal-table .muted { color: var(--portal-muted); }
.portal-table .password-state { display: inline-flex; padding: 5px 8px; border-radius: 999px; color: var(--portal-green); background: #e8faf3; font-size: 10px; font-weight: 800; }
.portal-table .password-state.is-temporary { color: #a8610b; background: #fff4df; }
.portal-identity-editor { display: grid; gap: 8px; min-width: 230px; }
.portal-identity-editor label { display: grid; grid-template-columns: 42px minmax(0,1fr); align-items: center; gap: 7px; }
.portal-identity-editor label > span { color: var(--portal-muted); font-size: 8px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.portal-identity-editor input { min-height: 34px; padding: 7px 9px; border-radius: 9px; font-size: 11px; }
.portal-identity-editor input:disabled { color: var(--portal-muted); background: var(--portal-bg); }
.identity-source-action { margin-top: 6px; padding: 0; border: 0; color: var(--portal-red); background: transparent; font-size: 10px; font-weight: 800; cursor: pointer; }
.identity-source-action:hover { text-decoration: underline; text-underline-offset: 2px; }
.portal-actions { display: flex; gap: 9px; flex-wrap: wrap; }
.credentials-result { display: grid; gap: 12px; margin-top: 16px; padding: 16px; border: 1px solid #bfe8d7; border-radius: 15px; background: #effbf6; }
.credentials-result code { display: block; padding: 12px; border-radius: 10px; color: var(--portal-ink-strong); background: white; font: 700 13px/1.65 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; }
.portal-note { padding: 13px 15px; border-left: 3px solid var(--portal-red); border-radius: 0 12px 12px 0; color: var(--portal-muted); background: var(--portal-red-soft); font-size: 13px; line-height: 1.5; }

@media (max-width: 980px) {
  .portal-auth-page { grid-template-columns: 1fr; }
  .portal-auth-brand { display: none; }
  .portal-grid { grid-template-columns: 1fr; }
  .portal-page-head { align-items: start; flex-direction: column; }
  .portal-topbar { padding-inline: 20px; }
  .portal-panel-heading { display: grid; gap: 13px; }
  .connection-controls { justify-content: space-between; }
  .portal-connection-form { grid-template-columns: 1fr; }
  .portal-connection-form .primary-action { width: 100%; }
}
