:root {
  color-scheme: dark;
  --bg: #030508;
  --panel: #101823;
  --line: rgba(168, 196, 228, .11);
  --line-strong: rgba(168, 196, 228, .2);
  --text: #e9f1f9;
  --muted: #7f92a5;
  --accent: #157cff;
  --green: #31c98a;
  --amber: #e8b04b;
  --red: #ff6672;
  --ease: cubic-bezier(.16, 1, .3, 1);
  font-family: ui-rounded, "SF Pro Rounded", "PingFang SC", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(80% 60% at 12% 0%, rgba(26, 91, 160, .2), transparent 62%),
    radial-gradient(70% 70% at 92% 100%, rgba(16, 66, 110, .12), transparent 60%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}
.portal-shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 28px 0 64px; }
header { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand > span { width: 44px; aspect-ratio: 1; display: grid; place-items: center; border-radius: 12px; color: white; background: linear-gradient(145deg, #3291ff, #0752b5); box-shadow: 0 8px 28px rgba(21, 124, 255, .25); font-size: 12px; font-weight: 800; letter-spacing: .04em; }
.brand strong { display: block; font-size: 16px; }
.brand small { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .1em; }
.portal-health { display: grid; grid-template-columns: 8px auto; align-items: center; gap: 5px 8px; color: #a8b8c7; font-size: 12px; }
.portal-health i { width: 8px; aspect-ratio: 1; grid-row: 1 / 3; border-radius: 50%; background: var(--green); box-shadow: 0 0 12px rgba(49, 201, 138, .7); }
.portal-health time { color: var(--muted); font-size: 11px; }
.hero { padding: 74px 0 38px; }
.eyebrow { color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .13em; }
h1 { margin: 9px 0 0; font-size: clamp(34px, 5vw, 58px); line-height: 1.05; letter-spacing: -.035em; }
.terminal-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.terminal-card { position: relative; min-width: 0; padding: 22px; overflow: hidden; border: 1px solid var(--line); border-radius: 20px; background: linear-gradient(150deg, rgba(17, 27, 40, .96), rgba(8, 13, 20, .96)); box-shadow: 0 18px 52px rgba(0, 0, 0, .28); transition: transform .35s var(--ease), border-color .25s var(--ease), box-shadow .25s var(--ease); }
.terminal-card::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(70% 60% at 100% 0%, rgba(21, 124, 255, .12), transparent 68%); }
.terminal-card:hover { transform: translateY(-4px); border-color: var(--line-strong); box-shadow: 0 24px 64px rgba(0, 0, 0, .4); }
.card-head { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.terminal-id { font-size: 12px; font-weight: 800; letter-spacing: .1em; }
.state-chip { min-height: 27px; padding: 0 10px; display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: rgba(3, 7, 11, .5); font-size: 11px; }
.state-chip i { width: 7px; aspect-ratio: 1; border-radius: 50%; background: var(--red); }
.online .state-chip { color: #9be6c4; border-color: rgba(49, 201, 138, .28); }
.online .state-chip i { background: var(--green); box-shadow: 0 0 10px rgba(49, 201, 138, .6); }
.warning .state-chip { color: #f1ca7d; border-color: rgba(232, 176, 75, .3); }
.warning .state-chip i { background: var(--amber); }
.model { position: relative; min-height: 48px; margin-top: 21px; overflow: hidden; font-size: clamp(19px, 2.5vw, 28px); font-weight: 650; letter-spacing: -.02em; text-overflow: ellipsis; white-space: nowrap; }
.terminal-card dl { position: relative; margin: 4px 0 0; display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.terminal-card dl > div { min-width: 0; padding: 14px 0; }
.terminal-card dl > div:nth-child(even) { padding-left: 18px; border-left: 1px solid var(--line); }
.terminal-card dl > div:nth-child(n+3) { border-top: 1px solid var(--line); }
dt { color: var(--muted); font-size: 11px; letter-spacing: .04em; }
dd { margin: 5px 0 0; overflow: hidden; font-size: 14px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.last-seen { position: relative; min-height: 38px; display: flex; align-items: center; color: var(--muted); font-size: 11px; }
.update-panel { position: relative; margin: 0 0 12px; padding: 13px; border: 1px solid var(--line); border-radius: 13px; background: rgba(3, 8, 13, .48); }
.update-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 11px; }
.update-head > span { color: var(--muted); font-weight: 700; letter-spacing: .04em; }
.update-state { overflow: hidden; color: #b9c9d8; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.updating .update-state { color: #9fc9ff; }
.update-failed .update-state { color: #ff9aa3; }
.update-rolled-back .update-state { color: #f1ca7d; }
.update-progress { height: 3px; margin-top: 10px; overflow: hidden; border-radius: 999px; background: rgba(168, 196, 228, .1); }
.update-progress[hidden] { display: none; }
.update-progress i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #157cff, #52a9ff); box-shadow: 0 0 10px rgba(21, 124, 255, .45); transition: width .35s var(--ease); }
.update-failed .update-progress i { background: var(--red); }
.update-rolled-back .update-progress i { background: var(--amber); }
.update-message { min-height: 30px; padding: 8px 0 6px; overflow: hidden; color: var(--muted); font-size: 10px; line-height: 1.45; text-overflow: ellipsis; white-space: nowrap; }
.update-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(128px, .72fr); gap: 7px; }
.update-actions button,
.update-actions select { min-width: 0; height: 36px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 9px; color: var(--text); background: rgba(255, 255, 255, .035); font: inherit; font-size: 11px; font-weight: 650; }
.update-actions button { cursor: pointer; transition: border-color .2s var(--ease), background .2s var(--ease), opacity .2s var(--ease); }
.update-actions button:hover:not(:disabled) { border-color: rgba(21, 124, 255, .65); background: rgba(21, 124, 255, .13); }
.update-actions button:disabled,
.update-actions select:disabled { cursor: not-allowed; opacity: .38; }
.update-latest { border-color: rgba(21, 124, 255, .4) !important; background: rgba(21, 124, 255, .12) !important; }
.history-toggle { position: relative; color: var(--muted) !important; }
.history-toggle::after { content: "▾"; margin-left: 6px; font-size: 9px; display: inline-block; transition: transform .22s var(--ease); }
.history-toggle[aria-expanded="true"]::after { transform: rotate(180deg); }
/* The history panel is a detour off the one action that matters, so it opens
   deliberately rather than occupying the card by default. */
.update-history { display: grid; grid-template-columns: minmax(0, 1fr) minmax(118px, .62fr); gap: 7px; align-items: center; margin-top: 8px; animation: history-in .24s var(--ease) both; }
.update-history[hidden] { display: none; }
.history-label { grid-column: 1 / -1; color: var(--muted); font-size: 10px; letter-spacing: .04em; }
.update-history select,
.update-history button { min-width: 0; height: 34px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 9px; color: var(--text); background: rgba(255, 255, 255, .035); font: inherit; font-size: 11px; font-weight: 650; }
.update-history button { cursor: pointer; transition: border-color .2s var(--ease), background .2s var(--ease), opacity .2s var(--ease); }
.update-history button:hover:not(:disabled) { border-color: rgba(232, 176, 75, .6); background: rgba(232, 176, 75, .12); }
.update-history select:disabled,
.update-history button:disabled { cursor: not-allowed; opacity: .38; }
@keyframes history-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.release-select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, #7f92a5 50%), linear-gradient(135deg, #7f92a5 50%, transparent 50%); background-position: calc(100% - 13px) 15px, calc(100% - 9px) 15px; background-repeat: no-repeat; background-size: 4px 4px; padding-right: 24px !important; }
.rollback-version { color: #d8caa8 !important; border-color: rgba(232, 176, 75, .22) !important; }
.enter { position: relative; height: 46px; padding: 0 15px; display: flex; align-items: center; justify-content: space-between; border: 1px solid rgba(21, 124, 255, .32); border-radius: 12px; color: #ddecff; background: rgba(21, 124, 255, .1); font-size: 13px; font-weight: 700; text-decoration: none; transition: background .2s var(--ease), border-color .2s var(--ease); }
.enter:hover { border-color: rgba(21, 124, 255, .7); background: rgba(21, 124, 255, .18); }
.enter b { font-size: 20px; font-weight: 400; transition: transform .25s var(--ease); }
.enter:hover b { transform: translateX(4px); }
.offline .model, .offline dd { color: #738393; }
.version-current .current-version { color: #9be6c4; }

.offline-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.offline-card { width: min(560px, 100%); padding: 44px; border: 1px solid var(--line); border-radius: 24px; background: linear-gradient(150deg, rgba(17, 27, 40, .96), rgba(8, 13, 20, .96)); box-shadow: 0 30px 90px rgba(0, 0, 0, .45); text-align: center; }
.offline-mark { width: 68px; aspect-ratio: 1; margin: 0 auto 24px; position: relative; display: grid; place-items: center; border: 1px solid rgba(255, 102, 114, .3); border-radius: 18px; color: #fff; background: rgba(255, 102, 114, .08); font-size: 13px; font-weight: 800; }
.offline-mark i { position: absolute; right: -4px; top: -4px; width: 13px; aspect-ratio: 1; border: 3px solid #101823; border-radius: 50%; background: var(--red); }
.offline-card h1 { margin-top: 12px; font-size: clamp(28px, 6vw, 42px); }
.offline-card p { margin: 18px auto 0; color: #91a3b4; line-height: 1.75; }
.offline-actions { margin-top: 28px; display: flex; justify-content: center; gap: 10px; }
.offline-actions button, .offline-actions a { min-height: 42px; padding: 0 17px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line-strong); border-radius: 11px; color: var(--text); background: rgba(255, 255, 255, .04); font: inherit; font-size: 13px; text-decoration: none; cursor: pointer; }
.offline-actions button { border-color: rgba(21, 124, 255, .5); background: rgba(21, 124, 255, .16); }
@media (max-width: 720px) {
  .portal-shell { width: min(100% - 24px, 1180px); padding-top: 18px; }
  .hero { padding: 54px 0 28px; }
  .terminal-grid { grid-template-columns: 1fr; }
  .terminal-card { padding: 18px; border-radius: 17px; }
  .update-actions { grid-template-columns: minmax(0, 1fr) minmax(118px, .8fr); }
  .offline-card { padding: 30px 20px; }
  .offline-actions { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .001ms !important; animation-duration: .001ms !important; }
}
