:root {
  --bg: #070b12;
  --bg-2: #0b111c;
  --surface: #101824;
  --surface-2: #131e2d;
  --surface-3: #182436;
  --text: #ecf3f8;
  --text-strong: #ffffff;
  --muted: #95a4b8;
  --muted-2: #6f8097;
  --border: rgba(148, 163, 184, .18);
  --border-strong: rgba(148, 163, 184, .3);
  --primary: #2f80ff;
  --primary-strong: #76a9ff;
  --primary-soft: rgba(47, 128, 255, .16);
  --accent: #4f9cff;
  --accent-soft: rgba(79, 156, 255, .15);
  --danger: #f05252;
  --danger-strong: #ff6b6b;
  --danger-soft: rgba(240, 82, 82, .14);
  --warning: #f5b84b;
  --warning-soft: rgba(245, 184, 75, .14);
  --success: #8bbcff;
  --success-soft: rgba(47, 128, 255, .13);
  --shadow-sm: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 10px 28px rgba(0, 0, 0, .22);
  --shadow-md: 0 18px 50px rgba(0, 0, 0, .34);
  --radius: 8px;
  --radius-sm: 6px;
  --focus: 0 0 0 4px rgba(47, 128, 255, .2);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(47, 128, 255, .08), transparent 340px),
    linear-gradient(120deg, rgba(79, 156, 255, .08), transparent 420px),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

img { max-width: 100%; height: auto; }
a { color: var(--primary-strong); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, .24);
  color: var(--text-strong);
  padding: 2px 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: .92em;
}
p { margin: 0; }
pre { overflow: auto; max-width: 100%; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: rgba(0, 0, 0, .28); color: var(--text); }
.hidden { display: none !important; }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 76px;
  padding: 14px clamp(18px, 4vw, 48px);
  border-bottom: 1px solid var(--border);
  background: rgba(7, 11, 18, .86);
  backdrop-filter: blur(18px);
  box-shadow: 0 12px 34px rgba(0, 0, 0, .28);
}
.brand, .logo { display: flex; align-items: center; min-width: 0; }
.logo img { display: block; width: 168px; max-height: 44px; object-fit: contain; }
.topnav { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 700;
  font-size: 14px;
}
.nav-link:hover { color: var(--text-strong); border-color: var(--border); background: rgba(255, 255, 255, .05); text-decoration: none; }
.content { width: min(1220px, calc(100% - 36px)); margin: 32px auto 48px; flex: 1; display: flex; flex-direction: column; gap: 22px; }
.footer { padding: 18px clamp(18px, 4vw, 48px); border-top: 1px solid var(--border); background: rgba(7, 11, 18, .72); color: var(--muted-2); font-size: 13px; }

.card, .auth-card, .error-card {
  width: 100%;
  background: linear-gradient(180deg, rgba(19, 30, 45, .96), rgba(13, 20, 31, .96));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.card-body { padding: clamp(18px, 3vw, 28px); }

.page-header, .title-wrap, .card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}
.page-header .title, .title-wrap .title, .h1 {
  margin: 0;
  color: var(--text-strong);
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.12;
  font-weight: 780;
}
.page-header .subtitle, .title-wrap .subtitle, .muted, .tile-desc, .form-tile-desc { color: var(--muted); }
.page-header .subtitle, .title-wrap .subtitle { margin-top: 5px; font-size: 15px; }
.page-header .icon, .title-wrap .icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .045);
}
.page-actions, .right-align { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.page-actions form { display: inline-flex; align-items: center; gap: 10px; margin: 0; }

.page-section, .card-section {
  padding: 22px 0;
  border-top: 1px solid var(--border);
}
.page-section:first-child, .card-section:first-child { border-top: 0; padding-top: 0; }
.page-header + .page-section, .page-header + form > .page-section { border-top: 0; padding-top: 0; }
.page-section:last-child, .card-section:last-child { padding-bottom: 0; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.section-title, .form-tile-title, .tile-title, .hp-status-node .title { color: var(--text-strong); font-weight: 760; }
.section-kicker, .label { color: var(--muted); font-size: 12px; font-weight: 760; letter-spacing: .04em; text-transform: uppercase; }
.h2 { margin: 0 0 10px; color: var(--text-strong); font-size: 21px; }
.h3 { margin: 0 0 8px; color: var(--text-strong); font-size: 16px; }

.auth-card { width: min(480px, 100%); margin: 44px auto; padding: clamp(22px, 5vw, 34px); }
.auth-card .h1 { font-size: clamp(26px, 4vw, 38px); }
.form-heading { display: flex; flex-direction: column; gap: 7px; padding-bottom: 12px; }
.error-card { padding: clamp(22px, 4vw, 32px); }

.form, form.form { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 18px; width: 100%; }
.form-grid + .form-grid { margin-top: 18px; }
.col-12 { grid-column: span 12; } .col-8 { grid-column: span 8; } .col-6 { grid-column: span 6; } .col-4 { grid-column: span 4; } .col-2 { grid-column: span 2; }
.form-tile, .detail-panel {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .035);
}
.form-tile:has(.table-wrap) { padding: 16px; }
.form-tile-title { margin-bottom: 2px; font-size: 15px; }
.form-tile-desc, .tile-desc { font-size: 13px; line-height: 1.45; }
.field { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field p { min-height: 26px; color: var(--text); }
.detail-list { display: grid; gap: 10px; margin: 0; }
.detail-row { display: grid; grid-template-columns: minmax(120px, 180px) minmax(0, 1fr); gap: 12px; align-items: baseline; }
.detail-row dt { margin: 0; }
.detail-row dd { margin: 0; min-width: 0; color: var(--text); overflow-wrap: anywhere; }
.confirm-summary { margin-top: 8px; }
.status-icon { display: inline-block; width: 24px; height: 24px; vertical-align: middle; }
.text-danger { color: var(--danger-strong); }
.text-success { color: var(--success); }
.input, .select, select, textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: rgba(3, 7, 18, .46);
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
textarea.input { min-height: 180px; resize: vertical; }
.input:focus, .select:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: var(--focus); background: rgba(3, 7, 18, .72); }
.input::placeholder, textarea::placeholder { color: var(--muted-2); }
.input-cb, .input-rb { display: flex; align-items: center; gap: 12px; min-height: 42px; color: var(--text); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); }

.action-row, .btn-group-hori, .form-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.action-row-right, .btn-group-hori-right, .form-actions { justify-content: flex-end; }
.action-stack, .btn-group-vert { display: flex; align-items: stretch; flex-direction: column; gap: 10px; margin-top: 12px; }
.form-actions.left { justify-content: flex-start; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, .06);
  color: var(--text-strong);
  font: inherit;
  font-weight: 740;
  line-height: 1.1;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease, border-color .12s ease, color .12s ease;
}
.btn:hover { border-color: rgba(255, 255, 255, .34); background: rgba(255, 255, 255, .1); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn-sm { min-height: 34px; padding: 8px 11px; font-size: 13px; }
.btn-primary { border-color: rgba(47, 128, 255, .68); background: linear-gradient(180deg, #3b82f6, #1d4ed8); color: #eef6ff; }
.btn-primary:hover { border-color: var(--primary-strong); background: linear-gradient(180deg, #60a5fa, #2563eb); }
.btn-secondary, .btn-ghost { background: rgba(255, 255, 255, .04); color: var(--text-strong); }
.btn-danger { border-color: rgba(240, 82, 82, .58); background: linear-gradient(180deg, #ef4444, #b91c1c); color: #fff; }
.btn-danger:hover { border-color: var(--danger-strong); background: linear-gradient(180deg, #ff6262, #ca2626); }
.btn[data-busy="1"], .btn[data-disabled="1"], .btn:disabled { opacity: .55; pointer-events: none; cursor: not-allowed; filter: grayscale(.2); }
.inline { display: inline; margin: 0; }

.alert {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  margin: 14px 0;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .045);
  color: var(--text);
}
.alert-success { border-color: rgba(47, 128, 255, .38); background: var(--success-soft); color: #e7f0ff; }
.alert-warning { border-color: rgba(245, 184, 75, .36); background: var(--warning-soft); color: #fff2ce; }
.alert-danger { border-color: rgba(240, 82, 82, .38); background: var(--danger-soft); color: #ffe1e1; }
.command-error-wrap {
  width: 100%;
  min-width: 0;
}
.command-error {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  max-height: 420px;
  margin: 12px 0 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid rgba(240, 82, 82, .3);
  border-radius: var(--radius-sm);
  background: rgba(3, 7, 18, .65);
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.command-error code {
  display: block;
  max-width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  white-space: inherit;
  overflow-wrap: inherit;
  word-break: inherit;
}
.alert-nocenter { align-items: flex-start; }
.alert-msg-wrap { min-width: 0; }
.alert-msg-msg { font-weight: 760; }
.alert-msg-ts { color: inherit; opacity: .72; font-size: 12px; }
.alert-btn-wrap { flex: 0 0 auto; display: flex; justify-content: flex-end; }
.alert-text { color: var(--danger-strong); font-weight: 760; }
.hint { margin-top: 16px; font-size: 13px; }

.pill-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.pill, .tile-tag, .table-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, .055);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.table-status.active { border-color: rgba(47, 128, 255, .38); background: var(--success-soft); color: var(--success); }
.table-status.danger { border-color: rgba(240, 82, 82, .38); background: var(--danger-soft); color: var(--danger-strong); }
.table-status.disabled { opacity: .7; }
.list { margin: 10px 0 0; padding-left: 18px; }
.list li { margin: 6px 0; }
.grid { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center; }

.tile-grid, .tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 14px; }
.tile {
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-height: 132px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, .055), rgba(255, 255, 255, .028));
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease, background .12s ease;
}
.tile:hover { border-color: rgba(47, 128, 255, .5); background: linear-gradient(180deg, rgba(47, 128, 255, .16), rgba(255, 255, 255, .038)); box-shadow: 0 18px 34px rgba(0, 0, 0, .28); text-decoration: none; transform: translateY(-1px); }
.tile:active { transform: translateY(0); }
.tile-foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 6px; }
.tile-disabled { opacity: .48; cursor: not-allowed; pointer-events: none; filter: grayscale(.12); }

.toolbar, .table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .035);
}
.toolbar form, .toolbar .left, .toolbar .right, .table-toolbar form, .table-toolbar .left, .table-toolbar .right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.toolbar .left, .table-toolbar .left { flex: 1 1 auto; }
.toolbar .right, .table-toolbar .right { margin-left: auto; }
.toolbar .input, .table-toolbar .input { width: auto; }
.toolbar input.input[type="text"], .toolbar input.input[type="email"], .toolbar input.input[type="search"], .toolbar input.input[name="q"], .table-toolbar input.input[type="text"], .table-toolbar input.input[name="q"] {
  flex: 1 1 260px;
  width: min(340px, 34vw);
  min-width: 220px;
}
.toolbar .select, .toolbar select, .table-toolbar .select, .table-toolbar select {
  flex: 0 0 auto;
  width: auto;
  min-width: 138px;
  max-width: 220px;
}
.toolbar .btn, .table-toolbar .btn { flex: 0 0 auto; width: auto; }
.toolbar .btn-sm, .table-toolbar .btn-sm { min-height: 42px; }
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: rgba(3, 7, 18, .32); }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.table thead th { position: sticky; top: 0; z-index: 1; padding: 12px 14px; border-bottom: 1px solid var(--border); background: rgba(255, 255, 255, .045); color: var(--muted); text-align: left; font-weight: 760; white-space: nowrap; }
.table tbody td { padding: 13px 14px; border-bottom: 1px solid rgba(148, 163, 184, .11); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: rgba(255, 255, 255, .035); }
.table-compact thead th, .table-compact tbody td { padding: 9px 11px; font-size: 13px; }
.table-actions { text-align: right; white-space: nowrap; }
.table-actions .action-row { justify-content: flex-end; flex-wrap: nowrap; margin-top: 0; }
.table-empty { padding: 24px !important; text-align: center; color: var(--muted); }
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 96px; color: var(--muted); text-align: center; }
.empty-state-title { color: var(--text-strong); font-weight: 760; }
.empty-state-desc { max-width: 520px; font-size: 13px; }
.th-sort a { display: inline-flex; align-items: center; gap: 6px; color: inherit; }
.th-sort a:hover { color: var(--text-strong); text-decoration: none; }
.sort-ind { opacity: .72; font-size: 12px; }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.pager a, .pager span { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 34px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: rgba(255, 255, 255, .045); color: var(--text); font-weight: 700; }
.pager a:hover { border-color: var(--primary); color: var(--primary-strong); text-decoration: none; }
.pager .current { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-strong); }
.pager .disabled { opacity: .45; pointer-events: none; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat-card { padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: rgba(255, 255, 255, .035); }
.stat-value { color: var(--text-strong); font-size: 28px; font-weight: 800; line-height: 1; }
.stat-label { margin-top: 6px; color: var(--muted); font-size: 12px; font-weight: 760; letter-spacing: .04em; text-transform: uppercase; }
.danger-zone { border-color: rgba(240, 82, 82, .35); background: rgba(240, 82, 82, .07); }

.summary-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px; }
.summary-card {
  grid-column: span 3;
  min-width: 0;
  padding: 16px;
  border: 1px solid rgba(148, 163, 184, .14);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, .052), rgba(255, 255, 255, .024));
}
.summary-card-wide { grid-column: span 6; }
.summary-label { color: var(--muted); font-size: 12px; font-weight: 760; letter-spacing: .04em; text-transform: uppercase; }
.summary-value { margin-top: 8px; color: var(--text-strong); font-size: 22px; font-weight: 800; line-height: 1.15; overflow-wrap: anywhere; }
.summary-desc { margin-top: 6px; color: var(--muted); font-size: 13px; }

.profile-hero {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(47, 128, 255, .12), rgba(255, 255, 255, .028));
}
.profile-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  border: 1px solid rgba(47, 128, 255, .38);
  border-radius: var(--radius);
  background: rgba(47, 128, 255, .16);
  color: var(--primary-strong);
  font-size: 18px;
  font-weight: 840;
}
.profile-title { color: var(--text-strong); font-size: 22px; font-weight: 800; line-height: 1.15; overflow-wrap: anywhere; }
.profile-subtitle { margin-top: 4px; color: var(--muted); overflow-wrap: anywhere; }
.profile-hero .pill-row { justify-content: flex-end; margin-top: 0; }

.admin-action-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: stretch; }
.admin-action-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .032);
}
.admin-action-card > .btn, .admin-action-card > form { margin-top: auto; }
.admin-action-card > [id$="_wrapper"]:not(.hidden) { display: grid; gap: 10px; }
.admin-action-card .field + .field { margin-top: 10px; }
.admin-action-card .action-row { margin-top: 12px; }
.admin-action-card > .action-row { margin-top: auto; }

.credential-panel {
  display: grid;
  gap: 14px;
  width: 100%;
}
.credential-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}
.credential-title { color: var(--text-strong); font-weight: 800; }
.credential-note { margin-top: 3px; color: var(--muted); font-size: 13px; }
.credential-grid { display: grid; gap: 10px; }
.credential-row {
  display: grid;
  grid-template-columns: minmax(120px, 160px) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid rgba(148, 163, 184, .16);
  border-radius: var(--radius-sm);
  background: rgba(3, 7, 18, .36);
}
.credential-label { color: var(--muted); font-size: 12px; font-weight: 760; letter-spacing: .04em; text-transform: uppercase; }
.credential-value {
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid rgba(148, 163, 184, .16);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, .24);
  color: var(--text-strong);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.credential-value.secret { border-color: rgba(245, 184, 75, .24); background: rgba(245, 184, 75, .08); }

#preview_subtitle { font-size: 12px; font-style: italic; font-weight: 500; color: var(--muted); }
#html_preview { width: 100%; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
#sigPreview, .sig-preview { display: block; width: 100%; min-height: 180px; border: 0; border-radius: var(--radius-sm); overflow: hidden; }
#sig-preview { scrollbar-width: none; }
#sig-preview::-webkit-scrollbar { display: none; }
#user-attribute-wrapper { width: 100%; }
.helper-header { margin: 16px 0; }
.cm-host { overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); }
.cm-editor { background-color: #080c14; color: #e5e7eb; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace; font-size: 13px; line-height: 1.45; }
.cm-scroller { min-height: 360px; }
.cm-gutter, .cm-gutters { background: #070b12; }
.cm-gutters { border-right: 1px solid rgba(255, 255, 255, .12); }
.cm-cursor { border-left-color: #f8fafc !important; }
.cm-selectionBackground, .cm-editor.cm-focused .cm-selectionBackground { background: rgba(148, 163, 184, .28); }
.cm-activeLine { background: rgba(255, 255, 255, .05); }
.cm-invalidVar, .cmTok-invalid { color: #fb7185; text-decoration-line: underline; text-decoration-style: wavy; text-decoration-color: #ef4444; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.cmTok-tag { color: #67e8f9; } .cmTok-attr { color: #fbbf24; } .cmTok-string { color: #86efac; } .cmTok-comment { color: #c4b5fd; font-style: italic; }
.cm-ifBlock { background-color: rgba(251, 191, 36, .18); } .cm-addonBlock { background-color: rgba(196, 181, 253, .22); }

.session-modal-backdrop[hidden] { display: none; }
.session-modal-backdrop { position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center; padding: 18px; background: rgba(0, 0, 0, .64); }
.session-modal { width: min(420px, 100%); padding: 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: 0 24px 60px rgba(0, 0, 0, .5); }
.session-modal h3 { margin: 0 0 8px; color: var(--text-strong); font-size: 18px; }
.session-modal p { margin: 0 0 16px; color: var(--muted); }
.session-modal-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.hp-status-node { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.hp-status-node .subtitle { color: var(--muted); font-size: 13px; }
.hp-status-node .body { margin-top: 6px; color: var(--muted); font-size: 13px; }
.hp-status-img { display: flex; justify-content: flex-end; }

@media (max-width: 980px) {
  .content { width: min(100% - 28px, 760px); margin-top: 24px; }
  .tile-grid, .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary-card, .summary-card-wide { grid-column: span 6; }
  .admin-action-grid { grid-template-columns: 1fr; }
  .col-8, .col-6, .col-4, .col-2 { grid-column: span 12; }
}
@media (max-width: 680px) {
  .topbar { align-items: flex-start; flex-direction: column; gap: 12px; }
  .topnav { width: 100%; justify-content: flex-start; }
  .card-body { padding: 18px; }
  .page-header, .title-wrap, .card-header, .toolbar, .table-toolbar, .alert { flex-direction: column; align-items: stretch; }
  .tile-grid, .tiles, .field-row, .stat-grid { grid-template-columns: 1fr; }
  .toolbar form, .toolbar .left, .toolbar .right, .table-toolbar form, .table-toolbar .left, .table-toolbar .right, .action-row, .btn-group-hori, .action-row-right, .btn-group-hori-right, .form-actions, .page-actions { align-items: stretch; width: 100%; }
  .btn, .page-actions form, .toolbar .input, .toolbar .select, .toolbar select, .table-toolbar .input, .table-toolbar .select, .table-toolbar select { width: 100%; max-width: none; }
  .table-actions { text-align: left; }
  .pager { justify-content: flex-start; }
  .detail-row { grid-template-columns: 1fr; gap: 2px; }
  .summary-grid, .profile-hero, .credential-row { grid-template-columns: 1fr; }
  .summary-card, .summary-card-wide { grid-column: span 12; }
  .credential-header { flex-direction: column; }
}
/* Enterprise console shell */
.app-shell-authed {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  background:
    linear-gradient(180deg, rgba(47, 128, 255, .07), transparent 320px),
    linear-gradient(135deg, rgba(79, 156, 255, .06), transparent 460px),
    #070b12;
}

.app-shell-public {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 18px 16px;
  border-right: 1px solid rgba(148, 163, 184, .16);
  background:
    linear-gradient(180deg, rgba(15, 23, 42, .94), rgba(3, 7, 18, .96)),
    #080c14;
  box-shadow: 18px 0 50px rgba(0, 0, 0, .24);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 2px 4px 18px;
  border-bottom: 1px solid rgba(148, 163, 184, .13);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  min-width: 0;
}

.brand-mark img {
  display: block;
  width: 138px;
  max-height: 38px;
  object-fit: contain;
}

.brand-meta {
  display: none;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.brand-meta span {
  color: var(--muted-2);
  font-size: 11px;
  font-weight: 760;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.brand-meta strong {
  color: var(--text-strong);
  font-size: 13px;
}

.side-nav {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 18px 0;
  scrollbar-color: rgba(118, 169, 255, .56) rgba(255, 255, 255, .035);
  scrollbar-width: thin;
}

.side-nav::-webkit-scrollbar {
  width: 8px;
}

.side-nav::-webkit-scrollbar-track {
  border-radius: 999px;
  background: rgba(255, 255, 255, .035);
}

.side-nav::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: rgba(118, 169, 255, .48);
  background-clip: padding-box;
}

.side-nav::-webkit-scrollbar-thumb:hover {
  background: rgba(118, 169, 255, .72);
  background-clip: padding-box;
}

.side-nav-group + .side-nav-group {
  margin-top: 22px;
}

.side-nav-label {
  margin: 0 8px 8px;
  color: var(--muted-2);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.side-nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  margin: 3px 0;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #aebbd0;
  font-size: 14px;
  font-weight: 720;
}

.side-nav-link:hover {
  color: var(--text-strong);
  border-color: rgba(148, 163, 184, .16);
  background: rgba(255, 255, 255, .045);
  text-decoration: none;
}

.side-nav-link.is-active {
  color: #eef6ff;
  border-color: rgba(47, 128, 255, .38);
  background: linear-gradient(90deg, rgba(47, 128, 255, .22), rgba(47, 128, 255, .07));
  box-shadow: inset 3px 0 0 var(--primary);
}

.side-nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: 1px solid rgba(148, 163, 184, .18);
  border-radius: 7px;
  background: rgba(255, 255, 255, .045);
  color: var(--muted);
  font-size: 11px;
  font-weight: 840;
  line-height: 1;
}

.side-nav-link.is-active .side-nav-icon {
  border-color: rgba(47, 128, 255, .44);
  background: rgba(47, 128, 255, .2);
  color: var(--primary-strong);
}

.side-nav-nested {
  margin: 3px 0;
}

.side-nav-parent {
  cursor: default;
}

.side-nav-children {
  display: grid;
  gap: 2px;
  margin: 4px 0 8px 22px;
  padding-left: 12px;
  border-left: 1px solid rgba(148, 163, 184, .14);
}

.side-nav-sublink {
  display: flex;
  align-items: center;
  min-height: 32px;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: #9facbf;
  font-size: 13px;
  font-weight: 700;
}

.side-nav-sublink:hover {
  color: var(--text-strong);
  border-color: rgba(148, 163, 184, .14);
  background: rgba(255, 255, 255, .035);
  text-decoration: none;
}

.side-nav-sublink.is-active {
  color: #eef6ff;
  border-color: rgba(47, 128, 255, .34);
  background: rgba(47, 128, 255, .14);
}

.sidebar-footer {
  padding-top: 14px;
  border-top: 1px solid rgba(148, 163, 184, .13);
}

.sidebar-toggle,
.sidebar-close,
.sidebar-backdrop {
  display: none;
}

.logout-link {
  color: #f7b4b4;
}

.app-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.workspace-header {
  position: sticky;
  top: 0;
  z-index: 9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 76px;
  padding: 16px clamp(22px, 4vw, 46px);
  border-bottom: 1px solid rgba(148, 163, 184, .14);
  background: rgba(7, 11, 18, .8);
  backdrop-filter: blur(18px);
}

.workspace-heading {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.workspace-kicker {
  color: var(--primary-strong);
  font-size: 12px;
  font-weight: 820;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.workspace-title {
  margin-top: 2px;
  color: var(--text-strong);
  font-size: 20px;
  font-weight: 780;
  letter-spacing: .01em;
}

.workspace-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.public-header {
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(520px, calc(100% - 36px));
  margin: 0 auto;
  padding: clamp(24px, 5vh, 42px) 0 0;
}

.app-shell-public .public-header .brand-mark img {
  width: 190px;
  max-height: 56px;
}

.app-shell-authed .topbar {
  display: none;
}

.app-shell-authed .content {
  width: min(1320px, calc(100% - 44px));
  margin: 28px auto 44px;
  gap: 20px;
}

.app-shell-public .content {
  width: min(520px, calc(100% - 36px));
  margin: clamp(20px, 5vh, 42px) auto clamp(28px, 6vh, 54px);
  justify-content: center;
  gap: 16px;
}

.app-shell-public .footer {
  text-align: center;
  background: transparent;
  border-top: 1px solid rgba(148, 163, 184, .11);
}

.app-shell-authed .footer {
  margin-top: auto;
  background: transparent;
  border-top: 1px solid rgba(148, 163, 184, .12);
}

/* More premium content surfaces */
.card {
  background: linear-gradient(180deg, rgba(17, 27, 41, .92), rgba(10, 16, 26, .92));
  border-color: rgba(148, 163, 184, .16);
  box-shadow: 0 16px 42px rgba(0, 0, 0, .22);
}

.card-body {
  padding: clamp(20px, 2.5vw, 30px);
}

.page-header {
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(148, 163, 184, .12);
}

.page-header .title,
.h1 {
  font-size: clamp(25px, 2.5vw, 34px);
  letter-spacing: 0;
}

.page-header .subtitle {
  max-width: 760px;
  color: #a6b8cf;
}

.page-section {
  padding: 24px 0;
}

.section-heading {
  margin-bottom: 16px;
}

.section-title {
  font-size: 16px;
}

.toolbar {
  padding: 14px;
  background: rgba(3, 7, 18, .26);
  border-color: rgba(148, 163, 184, .14);
}

.table-wrap {
  background: rgba(3, 7, 18, .22);
  border-color: rgba(148, 163, 184, .14);
}

.table thead th {
  background: rgba(255, 255, 255, .035);
}

.tile {
  min-height: 142px;
  padding: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .05), rgba(255, 255, 255, .025));
  border-color: rgba(148, 163, 184, .14);
}

.tile-title {
  font-size: 16px;
}

.stat-card {
  min-height: 118px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .052), rgba(255, 255, 255, .026));
  border-color: rgba(148, 163, 184, .14);
}

.stat-value {
  font-size: 34px;
}

.auth-card {
  position: relative;
  width: min(500px, 100%);
  margin: 0 auto;
  padding: clamp(24px, 5vw, 36px);
  border-color: rgba(47, 128, 255, .26);
  background:
    linear-gradient(180deg, rgba(22, 35, 52, .96), rgba(10, 16, 27, .98)),
    var(--surface);
  box-shadow: 0 28px 80px rgba(0, 0, 0, .38);
}

.auth-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, transparent, rgba(47, 128, 255, .82), transparent);
}

.auth-card .form-heading {
  gap: 8px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(148, 163, 184, .12);
}

.auth-card .h1 {
  font-size: 32px;
}

.auth-card .muted {
  max-width: 420px;
  color: #a8b8cd;
  line-height: 1.5;
}

.auth-card .form {
  gap: 14px;
  margin-top: 18px;
}

.auth-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.auth-actions .btn-primary {
  flex: 1 1 auto;
}

.auth-actions-secondary {
  margin-top: 0;
  padding-top: 2px;
}

.auth-secondary-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid rgba(148, 163, 184, .12);
  color: var(--muted);
  font-size: 13px;
}

.auth-secondary-form {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(148, 163, 184, .12);
}

.auth-secondary-form .btn {
  width: 100%;
}

.auth-code-input {
  min-height: 50px;
  text-align: center;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0;
}

.auth-invite-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 18px;
  padding: 14px;
  border: 1px solid rgba(148, 163, 184, .14);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .035);
}

.auth-invite-email {
  margin-top: 4px;
  color: var(--text-strong);
  font-weight: 760;
  overflow-wrap: anywhere;
}

@media (min-width: 1420px) {
  .brand-meta { display: flex; }
  .brand-mark img { width: 124px; }
}

@media (max-width: 760px) {
  .public-header {
    width: min(100% - 28px, 520px);
    padding-top: 22px;
  }

  .app-shell-public .content {
    width: min(100% - 28px, 520px);
    margin-top: 20px;
  }

  .auth-card {
    padding: 22px;
  }

  .auth-card .h1 {
    font-size: 28px;
  }

  .auth-actions,
  .auth-secondary-action,
  .auth-invite-summary {
    align-items: stretch;
    flex-direction: column;
  }

  .auth-actions .btn,
  .auth-actions a.btn {
    width: 100%;
  }

  .app-shell-authed {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 31;
    width: min(320px, 88vw);
    height: 100dvh;
    padding: 16px;
    border-right: 1px solid rgba(148, 163, 184, .2);
    transform: translateX(-101%);
    transition: transform .22s ease, visibility 0s linear .22s;
    visibility: hidden;
  }

  body.sidebar-open {
    overflow: hidden;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
    transition-delay: 0s;
    visibility: visible;
  }

  .sidebar-brand {
    padding-bottom: 12px;
  }

  .side-nav {
    display: block;
    overflow-y: auto;
    padding: 16px 0;
  }

  .side-nav-group {
    min-width: 0;
  }

  .side-nav-children {
    margin-left: 22px;
  }

  .side-nav-group + .side-nav-group {
    margin-top: 22px;
  }

  .sidebar-footer {
    display: block;
  }

  .sidebar-toggle,
  .sidebar-close {
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 1px solid rgba(148, 163, 184, .22);
    border-radius: 8px;
    background: rgba(255, 255, 255, .045);
    color: var(--text);
    cursor: pointer;
  }

  .sidebar-toggle {
    display: inline-flex;
    flex-direction: column;
    gap: 4px;
  }

  .sidebar-toggle span {
    width: 18px;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
  }

  .sidebar-close {
    display: inline-flex;
    margin-left: auto;
    font-size: 28px;
    line-height: 1;
  }

  .sidebar-toggle:hover,
  .sidebar-close:hover {
    border-color: rgba(47, 128, 255, .45);
    background: var(--primary-soft);
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 30;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: rgba(0, 0, 0, .62);
    backdrop-filter: blur(2px);
    cursor: default;
  }

  body.sidebar-open .sidebar-backdrop {
    display: block;
  }

  .workspace-header {
    position: sticky;
  }
}

@media (max-width: 680px) {
  .app-shell-authed .content {
    width: min(100% - 28px, 760px);
    margin-top: 20px;
  }

  .workspace-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .workspace-heading {
    width: 100%;
  }

  .workspace-actions,
  .workspace-actions .btn {
    width: 100%;
  }
}
