/* Aurium gateway — page-specific layer on top of aurium-ui.css.
   (Wave 5 reskin: gateway admin matches the owner's high-fidelity mock,
   docs/design/ui_cleanup/Gateway Admin Cleanup.dc.html. Tokens come from
   aurium-ui.css — do not invent values here.)
   Fully self-contained: no CDNs, no inline styles (CSP style-src 'self'). */

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: radial-gradient(1000px 500px at 80% -10%, #10214a 0%, #070c17 55%) fixed,
              #070c17;
  color: #e5e7eb;
  font-family: var(--au-font-sans);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--au-blue-light); text-decoration: none; }
a:hover { color: var(--au-blue-text); }

code {
  font-family: var(--au-font-mono);
  font-size: 11.5px;
  color: var(--au-blue-text);
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }

/* ---- topbar (mock: logo lockup + "Admin" left; account + Log out right) ---- */
.topbar {
  border-bottom: 1px solid var(--au-border-card);
  background: rgba(9, 15, 28, .7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.topbar-inner {
  max-width: 1160px;
  margin: 0 auto;
  padding: 14px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand { display: inline-flex; align-items: center; }
.brand-logo {
  height: 32px;
  width: auto;
  max-width: 140px;
  display: block;
  object-fit: contain;
  flex: 0 0 auto;
  filter: brightness(0) invert(1);
}
.topbar-label {
  font-size: 12px;
  color: var(--au-text-muted);
  border-left: 1px solid var(--au-border-input);
  padding-left: 12px;
  text-decoration: none;
}
.topbar-label:hover { color: var(--au-text-secondary); }
.nav-links { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.nav-user {
  font-size: 13px;
  color: var(--au-text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.nav-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #1e40af);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #fff;
  font-weight: 700;
  flex-shrink: 0;
}

/* ---- shell ---- */
.container {
  max-width: 1160px;
  width: 100%;
  margin: 0 auto;
  padding: 32px;
  flex: 1;
}
.footer {
  text-align: center;
  color: #475569;
  font-size: 12px;
  padding: 24px;
}

.page-title {
  font-family: var(--au-font-display);
  font-weight: 800;
  font-size: 26px;
  color: var(--au-text-primary);
  margin: 0 0 20px;
}
.muted { color: var(--au-text-muted-2); }
.small { font-size: 11.5px; }

/* ---- cards (legacy .card kept for login / no-access / secret pages) ---- */
.card {
  background: var(--au-bg-shell);
  border: 1px solid var(--au-border-card);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 16px;
}
.card-title {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 700;
  color: var(--au-text-primary);
}
.form-card { max-width: 32rem; }
.empty-state { text-align: center; padding: 2.5rem 1rem; }

/* ---- badges (names kept: update_status.js + templates render these) ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: var(--au-radius-pill);
  font-size: 10.5px;
  font-weight: 600;
  border: 1px solid var(--au-border-input);
  background: var(--au-surface-ghost);
  color: var(--au-text-secondary-2);
  white-space: nowrap;
}
.badge-ok    { color: var(--au-green-light); border-color: rgba(52,211,153,.25); background: rgba(52,211,153,.1); }
.badge-warn  { color: var(--au-amber-light); border-color: rgba(245,158,11,.28); background: rgba(245,158,11,.12); }
.badge-err   { color: #f87171; border-color: rgba(239,68,68,.28); background: rgba(239,68,68,.1); }
.badge-muted { color: var(--au-text-secondary-2); }
.badge-owner { color: var(--au-amber-light); border-color: rgba(245,158,11,.28); background: rgba(245,158,11,.12); }
.badge-viewer { color: var(--au-text-secondary-2); }
.badge-admin { color: var(--au-blue-text); border-color: rgba(59,130,246,.25); background: rgba(59,130,246,.12); }
.badge-default { color: var(--au-blue-text); border-color: rgba(59,130,246,.25); background: rgba(59,130,246,.12); }

/* ---- forms (legacy names kept for login + add-participant forms) ---- */
.field-label {
  display: block;
  margin: 12px 0 6px;
  color: var(--au-text-secondary-2);
  font-size: 12px;
}
.field {
  width: 100%;
  padding: 9px 12px;
  background: var(--au-surface-inset);
  color: #e5e7eb;
  border: 1px solid var(--au-border-input);
  border-radius: var(--au-radius-control);
  font-family: var(--au-font-sans);
  font-size: 13px;
}
.field:focus { outline: none; border-color: var(--au-blue); }
.field-sm { width: auto; padding: 6px 10px; font-size: 12px; }
.field-url { min-width: 16rem; }
.field-mono { font-family: var(--au-font-mono); font-size: 12px; }
.check-label {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin: 12px 0;
  color: var(--au-text-secondary);
  font-size: 13px;
  cursor: pointer;
}
select.field { appearance: auto; }

/* Legacy .btn aliases map onto the au-btn look (login page etc.) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  margin-top: 0.5rem;
  background: var(--au-surface-ghost);
  color: var(--au-text-secondary);
  border: 1px solid var(--au-border-input);
  border-radius: var(--au-radius-control);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { background: rgba(148,163,184,.12); color: var(--au-text-primary-2); text-decoration: none; }
.btn-primary { background: var(--au-blue); border-color: transparent; color: #fff; }
.btn-primary:hover { background: var(--au-blue-light); color: #fff; }
.btn-danger {
  background: rgba(239,68,68,.1);
  border-color: rgba(239,68,68,.28);
  color: #f87171;
}
.btn-danger:hover { background: rgba(239,68,68,.2); color: #f87171; }
/* Solid red — destructive modal confirms (mock: #ef4444, white text) */
.btn-danger-solid { background: var(--au-red); border-color: transparent; color: #fff; }
.btn-danger-solid:hover { background: #f05252; color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--au-text-secondary-2); margin-top: 0; }
.btn-ghost:hover { color: var(--au-text-primary-2); background: var(--au-surface-ghost); }
.btn-sm { padding: 5px 11px; font-size: 11.5px; margin-top: 0; }
.btn-block { width: 100%; margin-top: 1rem; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:disabled:hover { background: var(--au-surface-ghost); }
.inline-form { display: inline-flex; align-items: center; gap: 6px; margin: 0; }

.station-list {
  list-style: none;
  padding: 0;
  margin: 0 0 14px;
  display: grid;
  gap: 10px;
}
.station-row { margin: 0; }
.station-button {
  width: 100%;
  justify-content: flex-start;
  margin-top: 0;
}

/* ---- flashes ---- */
.flashes { margin-bottom: 1rem; }
.flash {
  padding: 0.6rem 0.9rem;
  border-radius: var(--au-radius-control);
  margin-bottom: 0.5rem;
  border: 1px solid var(--au-border-input);
  font-size: 13px;
}
.flash-success { border-color: rgba(52,211,153,.3); background: rgba(52,211,153,.08); color: var(--au-green-light); }
.flash-error { border-color: rgba(239,68,68,.3); background: rgba(239,68,68,.08); color: #fca5a5; }
.flash-warning { border-color: rgba(245,158,11,.3); background: rgba(245,158,11,.08); color: var(--au-amber-light); }

/* ---- login ---- */
/* ---- Auth (portal login) — glass card over a static backdrop ----
   Matches the station login. No station name (aurium.cc portal), so it shows
   the Aurium wordmark. Static backdrop reveals nothing. */
.aul-bg {
  position: fixed; inset: 0; z-index: -2;
  background: radial-gradient(120% 90% at 30% 20%, #1e3a6b 0%, #0e1830 55%, #070d18 100%);
}
.aul-bg-overlay {
  position: fixed; inset: 0; z-index: -1;
  background: linear-gradient(135deg, rgba(10, 17, 32, .72), rgba(14, 24, 48, .82));
}
.auth-card {
  max-width: 22rem;
  margin: 14vh auto 0;
  background: rgba(12, 20, 36, .66);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(148, 163, 184, .16);
  border-radius: 16px;
  padding: 32px 30px;
  box-shadow: 0 20px 60px -20px rgba(0, 0, 0, .6);
}
.auth-head { text-align: center; margin-bottom: 22px; }
.auth-logo { height: 28px; width: auto; filter: brightness(0) invert(1); opacity: .92; }
.auth-sub-lead { color: var(--au-text-muted-2); font-size: 12.5px; margin-top: 12px; }
.auth-foot { text-align: center; margin-top: 18px; font-size: 11px; color: var(--au-text-muted); }

/* ---- tables (mock: 10px uppercase headers, hairline rows) ---- */
.table-wrap { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.table th, .table td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(148,163,184,.06);
  vertical-align: middle;
}
.table th {
  color: var(--au-text-muted-3);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  border-bottom: 1px solid var(--au-border-card);
}
.table tr:last-child td { border-bottom: none; }
.row-disabled { opacity: 0.5; }

/* Table card: the mock's tables sit flush inside a rounded shell */
.table-card {
  background: var(--au-bg-shell);
  border: 1px solid var(--au-border-card);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 16px;
}
.table-card .table-wrap { border-radius: inherit; }

.grants-table td { white-space: nowrap; }
.grant-cell { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.grant-cell .au-select { width: auto; min-width: 108px; padding: 7px 28px 7px 11px; font-size: 12.5px; }

/* ---- secrets ---- */
.secret-box {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 0.75rem 0;
}
.secret-box code {
  flex: 1;
  padding: 11px 12px;
  background: var(--au-surface-inset);
  border: 1px solid rgba(59,130,246,.3);
  border-radius: var(--au-radius-control);
  color: var(--au-blue-text);
  font-size: 12.5px;
  word-break: break-all;
  user-select: all;
}
.secret-warn {
  font-size: 12.5px;
  color: var(--au-amber-light);
  margin: 0 0 16px;
}

/* Hide graceful-degradation buttons when JS is active */
.js .js-hide { display: none; }

/* ---- consolidated admin page (/admin) ---- */

/* Summary tiles (mock: first tile blue gradient, Baloo 34px values) */
.summary-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}
.stat-tile {
  background: var(--au-bg-shell);
  border: 1px solid var(--au-border-card);
  border-radius: 14px;
  padding: 20px;
}
.stat-tile-accent {
  background: linear-gradient(135deg, #0f1c38, #0b1426);
  border-color: rgba(59,130,246,.2);
}
.stat-value {
  font-family: var(--au-font-display);
  font-size: 34px;
  font-weight: 800;
  color: var(--au-text-primary);
  line-height: 1;
  display: flex;
  align-items: baseline;
  gap: 4px;
}
.stat-denominator { color: var(--au-text-muted); font-size: 18px; font-weight: 600; font-family: var(--au-font-display); }
.stat-label { font-size: 13px; color: var(--au-text-secondary); margin-top: 8px; font-weight: 600; }
.stat-sub { color: var(--au-text-muted-2); font-size: 11.5px; margin-top: 3px; }
.stat-sub-ok { color: var(--au-green-light); }
.stat-sub-ok .au-dot { margin-right: 5px; width: 6px; height: 6px; }
.stat-sub-mono { font-family: var(--au-font-mono); }

/* Side nav + sections (mock: 168px sticky rail, pill-highlighted active) */
.admin-layout {
  display: grid;
  grid-template-columns: 168px 1fr;
  gap: 28px;
  align-items: start;
}
.admin-side {
  position: sticky;
  top: 24px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.admin-side a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--au-radius-control);
  border: 1px solid transparent;
  color: var(--au-text-secondary);
  font-size: 13.5px;
  text-decoration: none;
}
.admin-side a:hover { color: var(--au-text-primary-2); background: var(--au-surface-ghost); }
.admin-side a.is-active {
  background: rgba(59,130,246,.12);
  border-color: rgba(59,130,246,.22);
  color: var(--au-text-primary-2);
  font-weight: 600;
}
.admin-sections { min-width: 0; }
.admin-section { scroll-margin-top: 24px; margin-bottom: 40px; }
.section-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--au-text-primary);
  margin: 0 0 4px;
}
.section-sub { font-size: 12.5px; color: var(--au-text-muted-2); margin: 0 0 14px; }
.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}
.section-head .section-sub { margin-bottom: 0; }

/* ---- fleet cards (mock: 2-up status cards) ---- */
.fleet-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.fleet-card {
  background: var(--au-bg-shell);
  border: 1px solid var(--au-border-card);
  border-radius: 12px;
  padding: 16px;
}
.fleet-card.is-disabled { opacity: 0.6; }
.fleet-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.fleet-name { font-size: 14px; font-weight: 600; color: var(--au-text-primary-2); }
.fleet-url {
  font-family: var(--au-font-mono);
  font-size: 11.5px;
  color: var(--au-text-muted-2);
  word-break: break-all;
}
.fleet-meta {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 12px;
  font-size: 11.5px;
  color: var(--au-text-secondary-2);
}
.fleet-meta .au-mono { font-size: 11px; }
.fleet-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }

/* ---- plugin chips (radio tiles) ---- */
.fleet-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.fleet-chips:empty { display: none; }
.fleet-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-family: var(--au-font-mono);
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--au-border-card);
  color: var(--au-text-secondary-2);
  background: var(--au-surface-ghost);
}
.fleet-chip-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--au-text-muted-2);
}
.fleet-chip-ok .fleet-chip-dot { background: var(--au-green-light); }
.fleet-chip-warn .fleet-chip-dot { background: var(--au-amber-light); }

/* ---- station tiles (nested under their host radio) ---- */
.fleet-card-station { border-left: 2px solid rgba(59,130,246,.35); }
.fleet-substation-mark { color: var(--au-text-muted-2); font-weight: 400; }

/* Controls hidden until a live handshake proves the capability. */
.is-hidden { display: none !important; }
.fleet-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(148,163,184,.06);
}
.update-status { display: block; margin-top: 8px; }

/* ---- scheduled-update state (7.5.1) ---- */
.fleet-update-window { margin-top: 8px; }
.fleet-update-pending { margin-top: 8px; color: var(--au-text-secondary-2); font-weight: 500; }
.fleet-update-blocked { margin-top: 4px; color: var(--au-amber-light); }
.warn { color: var(--au-amber-light); }

/* Paired time inputs (topology maintenance window) */
.field-pair { display: flex; align-items: center; gap: 8px; }
.field-pair .field { flex: 1 1 auto; }
.field-pair-sep { color: var(--au-text-muted-2); font-size: 12px; }

/* ---- instances / users action cell ---- */
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.cell-input { width: 100%; min-width: 110px; }
.cell-input-url { min-width: 180px; }

/* ---- cluster node cards (mock: leader gets blue border + crown tile) ---- */
.cluster-list { display: flex; flex-direction: column; gap: 10px; }
.cluster-card {
  background: var(--au-bg-shell);
  border: 1px solid var(--au-border-card);
  border-radius: 12px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.cluster-card.is-leader { border-color: rgba(59,130,246,.25); }
.cluster-card.is-disabled { opacity: 0.55; }
.cluster-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--au-surface-ghost);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--au-text-secondary-2);
  flex-shrink: 0;
}
.cluster-card.is-leader .cluster-icon {
  background: rgba(59,130,246,.14);
  color: var(--au-blue-light);
}
.cluster-icon svg { width: 18px; height: 18px; display: block; }
.cluster-main { flex: 1; min-width: 220px; }
.cluster-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--au-text-primary-2);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.cluster-addr {
  font-family: var(--au-font-mono);
  font-size: 11px;
  color: var(--au-text-muted-2);
  margin-top: 2px;
  word-break: break-all;
}
.cluster-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  width: 100%;
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid rgba(148,163,184,.06);
}
.tray-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* ---- modals (:target pattern — works without JS; admin.js adds
        scrim-click + Escape close). Blurred scrim + centered card per mock. */
.gw-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(3,6,14,.74);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  align-items: flex-start;
  justify-content: center;
  padding: 64px 20px;
  z-index: 50;
  overflow-y: auto;
}
.gw-modal:target { display: flex; }
.gw-modal-card {
  width: 460px;
  max-width: 100%;
  background: var(--au-bg-shell);
  border: 1px solid var(--au-border-modal);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 24px 60px rgba(0,0,0,.55);
}
.gw-modal-card-danger { width: 400px; border-color: rgba(239,68,68,.25); }
.gw-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 18px;
}
.gw-modal-title { font-size: 17px; font-weight: 700; color: var(--au-text-primary); margin: 0; }
.gw-modal-close {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--au-surface-ghost);
  border: 1px solid var(--au-border-input);
  color: var(--au-text-secondary-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  text-decoration: none;
  flex-shrink: 0;
}
.gw-modal-close:hover { color: var(--au-text-primary-2); }
.gw-modal-sub { font-size: 12.5px; color: var(--au-text-muted-2); margin: -8px 0 14px; }
.gw-modal-card .field-label { margin-top: 0; }
.gw-modal-card .field { margin-bottom: 14px; }
.gw-modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.gw-danger-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(239,68,68,.12);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #f87171;
  font-size: 18px;
  margin-bottom: 14px;
}
.gw-danger-icon svg { width: 18px; height: 18px; }
.gw-modal-body { font-size: 13px; color: var(--au-text-secondary-2); margin: 0 0 20px; line-height: 1.5; }

/* Copy button feedback (admin.js swaps the label) */
.copy-btn.is-copied { color: var(--au-green-light); border-color: rgba(52,211,153,.3); }

/* ---- responsive ---- */
@media (max-width: 900px) {
  .container { padding: 16px; }
  .topbar-inner { padding: 12px 16px; }
  .brand-logo { height: 26px; max-width: 116px; }
  .nav-links { gap: 8px; justify-content: flex-end; }
  .nav-user { max-width: 100%; }
  .summary-row { grid-template-columns: 1fr; }
  .fleet-grid { grid-template-columns: 1fr; }
  .admin-layout { grid-template-columns: 1fr; }
  .admin-side {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
  }
}
