:root {
  color-scheme: light;
  --font-body: "Segoe UI", "Helvetica Neue", sans-serif;
  --font-display: "Trebuchet MS", "Segoe UI", sans-serif;
  --bg: #eef3f8;
  --surface: #ffffff;
  --surface-alt: #dfe8f2;
  --surface-strong: #0f1d2e;
  --text: #142033;
  --muted: #546579;
  --accent: #0a6ee8;
  --accent-strong: #084fa5;
  --border: #c7d4e3;
  --success: #11795a;
  --error: #b23737;
  --warning: #9c5d00;
  --shadow: 0 20px 50px rgba(15, 29, 46, 0.12);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #08111d;
  --surface: #0f1b2b;
  --surface-alt: #122338;
  --surface-strong: #dbe8f8;
  --text: #edf4ff;
  --muted: #97abc3;
  --accent: #5cb2ff;
  --accent-strong: #8ecbff;
  --border: #233850;
  --success: #48c798;
  --error: #ff8077;
  --warning: #ffbf66;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font-body);
  background:
    radial-gradient(circle at top right, rgba(10, 110, 232, 0.14), transparent 28%),
    linear-gradient(180deg, var(--bg), color-mix(in srgb, var(--bg) 88%, #03111f));
  color: var(--text);
}
a { color: inherit; }
button, input { font: inherit; }
.sr-only, .skip-link:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
.skip-link:focus {
  position: fixed;
  top: 1rem;
  left: 1rem;
  background: var(--surface-strong);
  color: var(--bg);
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  z-index: 40;
}

.portal-shell { display: grid; grid-template-columns: 18rem 1fr; min-height: 100vh; }
.portal-sidebar {
  background: color-mix(in srgb, var(--surface) 84%, #08111d);
  border-right: 1px solid var(--border);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.brand-lockup { display: flex; align-items: center; gap: 1rem; }
.brand-mark {
  width: 3rem;
  height: 3rem;
  border-radius: 1rem;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--surface-strong));
  color: #fff;
  font-weight: 700;
}
.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.brand-lockup h1, .topbar h2, .page-header h1, .auth-panel h1, .status-panel h1 { margin: 0; font-family: var(--font-display); }
.sidebar-nav { display: grid; gap: 0.45rem; }
.nav-link {
  display: flex;
  align-items: center;
  padding: 0.8rem 0.95rem;
  border-radius: 0.9rem;
  text-decoration: none;
  color: var(--muted);
}
.nav-link:hover, .nav-link:focus-visible, .nav-link.is-active {
  background: var(--surface-alt);
  color: var(--text);
}
.logout-form { margin-top: auto; }
.button {
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  padding: 0.8rem 1rem;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
}
.button:hover, .button:focus-visible, .icon-button:hover, .icon-button:focus-visible, .profile-chip:focus-visible, input:focus-visible, .nav-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.button-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.button-primary:hover { background: var(--accent-strong); }
.button-secondary { background: transparent; }
.button-full { width: 100%; }

.portal-main { min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-start, .topbar-actions, .profile-chip, .status-pill, .password-field { display: flex; align-items: center; gap: 0.75rem; }
.profile-chip {
  text-decoration: none;
  border: 1px solid var(--border);
  padding: 0.45rem 0.65rem;
  border-radius: 999px;
}
.avatar {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-alt);
  font-weight: 700;
}
.icon-button {
  width: 2.8rem;
  height: 2.8rem;
  border-radius: 0.9rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
.mobile-nav-toggle { display: none; }
.status-pill {
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.status-dot {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: currentColor;
}
.status-ok { color: var(--success); }
.status-degraded { color: var(--warning); }

.content, .standalone { padding: 1.5rem; }
.content { max-width: 1280px; }
.breadcrumbs { display: flex; gap: 0.75rem; margin-bottom: 1rem; color: var(--muted); }
.breadcrumbs a { text-decoration: none; }
.alert {
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 0.85rem 1rem;
  border-radius: 1rem;
  margin-bottom: 1rem;
}
.alert-error { border-color: color-mix(in srgb, var(--error) 45%, var(--border)); }
.alert-info { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }

.page-header, .dashboard-columns, .auth-panel {
  display: grid;
  gap: 1.5rem;
}
.page-header {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  margin-bottom: 1.5rem;
}
.quick-links { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.dashboard-grid { display: grid; gap: 1.5rem; }
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}
.metric-card, .panel, .auth-form, .auth-copy, .status-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.metric-card strong { display: block; margin: 0.5rem 0; font-size: 2rem; }
.dashboard-columns { grid-template-columns: 1.4fr 1fr; }
.panel-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.timeline, .feature-list, .health-list { margin: 0; padding: 0; list-style: none; }
.timeline { display: grid; gap: 0.75rem; }
.timeline-item {
  display: grid;
  gap: 0.2rem;
  padding: 0.85rem 0;
  border-top: 1px solid var(--border);
}
.timeline-item:first-child { border-top: 0; padding-top: 0; }
.health-list { display: grid; gap: 1rem; }
.health-list div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--border);
}
.muted, small { color: var(--muted); }
.dashboard-state, .empty-note { color: var(--muted); }

.standalone {
  display: grid;
  place-items: center;
  min-height: 100vh;
}
.auth-panel {
  grid-template-columns: 1.1fr 0.9fr;
  width: min(1040px, calc(100vw - 2rem));
}
.auth-copy {
  background: linear-gradient(160deg, color-mix(in srgb, var(--surface) 76%, var(--accent) 24%), var(--surface));
}
.auth-form { display: grid; gap: 1rem; }
.field { display: grid; gap: 0.45rem; }
input {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 0.9rem;
  padding: 0.8rem 0.9rem;
}
.password-field input { flex: 1; }
.form-status { color: var(--muted); min-height: 1.25rem; }
.status-panel { width: min(540px, calc(100vw - 2rem)); text-align: center; }
.placeholder-panel { max-width: 760px; }

.portal-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 17, 29, 0.55);
  z-index: 24;
}

.hostname-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 1.5rem; }
.hostname-toolbar { display: grid; grid-template-columns: minmax(0, 2fr) minmax(10rem, 1fr) auto; align-items: end; gap: 1rem; margin-bottom: 1.5rem; }
.live-region { min-height: 1.5rem; margin-bottom: 1rem; font-weight: 600; }
.live-success { color: var(--success); }.live-error, .field-error { color: var(--error); }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; min-width: 880px; }
.data-table th, .data-table td { padding: 0.9rem 0.75rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.data-table th { color: var(--muted); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em; }
.sort-button { border: 0; background: transparent; color: inherit; font: inherit; font-weight: 700; cursor: pointer; padding: 0; }
.status-badge { display: inline-flex; align-items: center; border: 1px solid currentColor; border-radius: 999px; padding: 0.25rem 0.55rem; font-size: 0.82rem; font-weight: 700; }
.status-active { color: var(--success); }.status-disabled { color: var(--warning); }.status-suspended { color: var(--error); }
.row-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; min-width: 14rem; }.button-small { padding: 0.45rem 0.6rem; border-radius: 0.65rem; font-size: 0.82rem; }.button-danger { color: var(--error); border-color: currentColor; background: transparent; }
.hostname-state { padding: 2rem 0; text-align: center; color: var(--muted); }.hostname-cards { display: grid; gap: 1rem; }.hostname-card { border: 1px solid var(--border); border-radius: 1rem; padding: 1rem; }.hostname-card h3 { margin-top: 0; overflow-wrap: anywhere; }.hostname-card dl { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }.hostname-card dt { color: var(--muted); font-size: 0.85rem; }.hostname-card dd { margin: 0; text-align: right; overflow-wrap: anywhere; }.card-status { margin-bottom: 0.9rem; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 1rem; padding-top: 1.25rem; }
.modal-backdrop { position: fixed; inset: 0; z-index: 30; background: rgba(8, 17, 29, 0.65); }.modal { position: fixed; z-index: 31; inset: 50% auto auto 50%; transform: translate(-50%, -50%); width: min(34rem, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 1.25rem; padding: 1.25rem; box-shadow: var(--shadow); }.modal-header { display: flex; justify-content: space-between; gap: 1rem; align-items: start; margin-bottom: 1rem; }.modal-header h2 { margin: 0; font-family: var(--font-display); }.modal-form { display: grid; gap: 1rem; }.modal-actions { display: flex; justify-content: flex-end; gap: 0.75rem; margin-top: 1.25rem; }.details-body p { margin: 0.7rem 0; }.details-body code { display: block; overflow-wrap: anywhere; white-space: pre-wrap; background: var(--surface-alt); padding: 0.8rem; border-radius: 0.75rem; }
select { width: 100%; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 0.9rem; padding: 0.8rem 0.9rem; }

@media (max-width: 1024px) {
  .metrics-grid, .dashboard-columns, .auth-panel, .page-header {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .portal-shell { grid-template-columns: 1fr; }
  .portal-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(20rem, 88vw);
    transform: translateX(-105%);
    transition: transform 180ms ease;
    z-index: 25;
  }
  .portal-sidebar.is-open { transform: translateX(0); }
  .mobile-nav-toggle { display: inline-flex; }
  .hostname-toolbar { grid-template-columns: 1fr; }
  .data-table { display: none; }.table-wrap { display: none; }.hostname-cards { display: grid !important; }
}

@media (min-width: 861px) { .hostname-cards { display: none !important; } }

@media (max-width: 600px) { .hostname-metrics { grid-template-columns: 1fr; }.content { padding: 1rem; }.modal { padding: 1rem; }.modal-actions { flex-direction: column-reverse; }.modal-actions .button { width: 100%; } }

.credentials-toolbar { display: flex; align-items: end; gap: 1rem; margin-bottom: 1rem; }.credentials-toolbar .field { flex: 1; }.credential-state { padding: 2rem 1rem; text-align: center; }.credential-cards { display: none; gap: 1rem; }.credential-card { border: 1px solid var(--border); border-radius: 1rem; padding: 1rem; background: var(--surface-alt); }.credential-card h3 { margin: 0; }.credential-card dl, .credential-details { display: grid; grid-template-columns: minmax(7rem, 0.8fr) 1.2fr; gap: .5rem 1rem; margin: 1rem 0; }.credential-card dt, .credential-details dt { color: var(--muted); }.credential-card dd, .credential-details dd { margin: 0; overflow-wrap: anywhere; }.card-status { margin-top: .75rem; }.warning-box { border-left: 4px solid var(--warning); padding: .8rem; background: var(--surface-alt); }.secret-examples { display: flex; flex-wrap: wrap; gap: .6rem; }.acknowledge-secret { display: flex; gap: .6rem; align-items: start; margin-top: 1rem; }.data-table td { vertical-align: top; }
@media (max-width: 800px) { .credentials-toolbar { display: grid; align-items: stretch; }.credentials-toolbar .button { width: 100%; } #credentials-root .table-wrap { display: none; }.credential-cards { display: grid; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
