:root {
  color-scheme: dark;
  --background: #0b0b0c;
  --surface: #151516;
  --surface-raised: #1c1c1e;
  --surface-soft: #222225;
  --border: #303034;
  --border-strong: #48484d;
  --text: #f5f5f7;
  --muted: #a1a1aa;
  --subtle: #71717a;
  --accent: #ffffff;
  --accent-text: #111113;
  --success: #54d68c;
  --success-bg: rgba(84, 214, 140, 0.12);
  --danger: #ff8f87;
  --danger-bg: rgba(255, 95, 86, 0.12);
  --warning: #f5c96a;
  --radius-lg: 20px;
  --radius-md: 14px;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--background); }
body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 15% -10%, rgba(255,255,255,0.08), transparent 34rem),
    var(--background);
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}
button, input { font: inherit; }
a { color: inherit; }

.portal-shell { width: min(1120px, calc(100% - 40px)); margin: 0 auto; padding: 28px 0 72px; }
.portal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 56px;
}
.brand { display: flex; align-items: center; gap: 14px; text-decoration: none; }
.brand-logo { display: block; width: 108px; height: auto; }
.brand-divider { width: 1px; height: 28px; background: var(--border-strong); }
.brand-copy { display: grid; line-height: 1.15; }
.brand-copy strong { font-size: 14px; letter-spacing: -0.01em; }
.brand-copy span { color: var(--muted); font-size: 12px; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.user-chip {
  max-width: 260px;
  overflow: hidden;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 650;
}

.hero { margin-bottom: 28px; }
.eyebrow {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
h1 { margin: 0; max-width: 760px; font-size: clamp(32px, 5vw, 52px); line-height: 1.04; letter-spacing: -0.045em; }
.hero-copy { max-width: 680px; margin: 16px 0 0; color: var(--muted); font-size: 16px; }

.environment-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.environment-card {
  min-width: 0;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(255,255,255,0.018), transparent 35%), var(--surface);
  box-shadow: 0 12px 40px rgba(0,0,0,0.16);
}
.card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.card-title { margin: 0; font-size: 22px; letter-spacing: -0.025em; }
.card-subtitle { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.status-badge {
  flex: 0 0 auto;
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.status-badge.active { border-color: rgba(84,214,140,0.4); color: var(--success); background: var(--success-bg); }
.status-badge.warning { border-color: rgba(245,201,106,0.4); color: var(--warning); }
.credential-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  margin: 0 0 22px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(0,0,0,0.16);
}
.summary-item { min-width: 0; }
.summary-item dt { margin-bottom: 4px; color: var(--subtle); font-size: 11px; font-weight: 750; letter-spacing: 0.07em; text-transform: uppercase; }
.summary-item dd { margin: 0; overflow-wrap: anywhere; font-size: 13px; font-weight: 650; }
.empty-state { margin: 0 0 22px; padding: 16px; border: 1px dashed var(--border-strong); border-radius: var(--radius-md); color: var(--muted); font-size: 13px; }

.credential-form { display: grid; gap: 16px; }
.field { display: grid; gap: 7px; }
.field label { font-size: 13px; font-weight: 750; }
.field-hint { margin: 0; color: var(--subtle); font-size: 12px; }
.field input {
  width: 100%;
  min-height: 46px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: none;
  background: #101011;
  color: var(--text);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
.field input:hover { border-color: var(--border-strong); }
.field input:focus-visible { border-color: #73737a; box-shadow: 0 0 0 3px rgba(255,255,255,0.09); }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 2px; }
.inline-form { margin: 0; }
.danger-zone { display: flex; justify-content: flex-start; margin-top: 14px; padding-top: 16px; border-top: 1px solid var(--border); }

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 9px 15px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  cursor: pointer;
  background: var(--surface-soft);
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 750;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}
.button:hover { border-color: #68686f; background: #2b2b2f; }
.button:active { transform: translateY(1px); }
.button:focus-visible { outline: 3px solid rgba(255,255,255,0.18); outline-offset: 2px; }
.button.primary { border-color: var(--accent); background: var(--accent); color: var(--accent-text); }
.button.primary:hover { background: #dedee2; }
.button.danger { border-color: rgba(255,95,86,0.5); background: var(--danger-bg); color: var(--danger); }
.button.danger:hover { border-color: rgba(255,95,86,0.85); background: rgba(255,95,86,0.2); }
.button.full { width: 100%; }

.login-layout { display: grid; min-height: calc(100vh - 56px); grid-template-rows: auto 1fr; }
.login-stage { display: grid; place-items: center; padding: 24px 0 80px; }
.login-card {
  width: min(470px, 100%);
  padding: clamp(26px, 6vw, 42px);
  border: 1px solid var(--border);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255,255,255,0.025), transparent 38%), var(--surface);
  box-shadow: var(--shadow);
}
.login-card h1 { font-size: clamp(30px, 7vw, 42px); }
.login-card p { margin: 14px 0 28px; color: var(--muted); }
.microsoft-mark { display: grid; grid-template-columns: repeat(2, 7px); gap: 2px; }
.microsoft-mark span { width: 7px; height: 7px; background: currentColor; }
.security-note { margin-top: 20px; color: var(--subtle); text-align: center; font-size: 12px; }

.error-card { width: min(560px, 100%); margin: 12vh auto 0; padding: 32px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.error-code { color: var(--subtle); font-size: 12px; font-weight: 800; letter-spacing: 0.1em; }
.error-card h1 { margin-top: 8px; font-size: 32px; }
.error-card p { color: var(--muted); }

@media (max-width: 760px) {
  .portal-shell { width: min(100% - 28px, 1120px); padding-top: 18px; }
  .portal-header { align-items: flex-start; margin-bottom: 40px; }
  .header-actions { align-items: flex-end; flex-direction: column; }
  .user-chip { max-width: 180px; }
  .environment-grid { grid-template-columns: 1fr; }
  .environment-card { padding: 20px; }
}

@media (max-width: 480px) {
  .brand-copy span, .user-chip { display: none; }
  .portal-header { align-items: center; }
  .credential-summary { grid-template-columns: 1fr; }
  .form-actions { align-items: stretch; flex-direction: column-reverse; }
  .form-actions .button, .form-actions form { width: 100%; }
  .inline-form .button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}