:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #172033;
  --muted: #667085;
  --line: #e4e9f2;
  --line-strong: #d4dae5;
  --accent: #3568f0;
  --accent-dark: #254fc6;
  --accent-soft: #edf3ff;
  --success: #168365;
  --shadow: 0 18px 50px rgba(30, 48, 80, 0.08);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  padding-right: env(safe-area-inset-right, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  color: var(--text);
  background:
    radial-gradient(circle at 88% -10%, rgba(78, 124, 246, 0.14), transparent 31rem),
    linear-gradient(180deg, #fbfcff 0%, var(--bg) 48%, #f0f3f8 100%);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.page-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(120deg, rgba(255,255,255,.8), transparent 40%);
}

.page-shell {
  position: relative;
  width: min(1120px, calc(100% - 40px));
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.brandbar {
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid rgba(212, 218, 229, 0.72);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: white;
  background: linear-gradient(145deg, #4778f6, #2854cf);
  box-shadow: 0 10px 24px rgba(53, 104, 240, 0.23);
  font-size: 20px;
  font-weight: 750;
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 17px; letter-spacing: -0.02em; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }

.account { display: flex; align-items: center; gap: 12px; }
.account-name { color: var(--muted); font-size: 14px; }
.text-button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  background: rgba(255,255,255,.72);
  cursor: pointer;
}
.text-button:hover { border-color: var(--line-strong); background: white; }

.login-layout {
  flex: 1;
  min-height: calc(100vh - 168px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 420px);
  gap: clamp(44px, 8vw, 104px);
  align-items: center;
  padding: 64px 0 76px;
}

.intro-panel { max-width: 600px; }
.login-card { width: 100%; justify-self: end; }
.eyebrow {
  margin: 0 0 14px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: .14em;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 18px; font-size: clamp(42px, 6vw, 70px); line-height: .98; letter-spacing: -.055em; }
h2 { margin-bottom: 10px; font-size: 28px; letter-spacing: -.035em; }
.lead { color: var(--muted); font-size: clamp(17px, 2vw, 20px); line-height: 1.65; }
.muted { color: var(--muted); line-height: 1.6; }

.login-card {
  display: grid;
  gap: 20px;
  padding: clamp(28px, 4vw, 38px);
  border: 1px solid rgba(222, 227, 236, .95);
  border-radius: 24px;
  background: rgba(255,255,255,.88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.login-card label { display: grid; gap: 8px; color: #455064; font-size: 13px; font-weight: 650; }
.login-card input {
  width: 100%;
  min-height: 50px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  color: var(--text);
  background: white;
  outline: none;
  transition: border-color .16s, box-shadow .16s;
}
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(53,104,240,.1); }
.form-error { min-height: 20px; margin: -4px 0 -6px; color: #c33f4a; font-size: 13px; }
.primary-button {
  min-height: 52px;
  border: 0;
  border-radius: 13px;
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  box-shadow: 0 12px 28px rgba(53,104,240,.2);
  font-weight: 700;
  cursor: pointer;
}
.primary-button:hover { filter: brightness(1.03); transform: translateY(-1px); }
.primary-button:disabled { opacity: .58; cursor: wait; transform: none; }
.privacy-note { margin: -4px 0 0; color: #8a93a3; text-align: center; font-size: 12px; }

.versions-view { flex: 1; padding: 40px 0 80px; }
.versions-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 34px; }
.versions-heading h1 { margin-bottom: 14px; font-size: clamp(38px, 5vw, 58px); }
.versions-heading .lead { max-width: 730px; margin-bottom: 0; font-size: 16px; }
.status-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; }
.version-count { padding: 10px 14px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: rgba(255,255,255,.7); font-size: 13px; white-space: nowrap; }
.refresh-button { min-height: 38px; padding: 0 13px; border: 1px solid var(--line); border-radius: 999px; color: var(--text); background: white; cursor: pointer; font-size: 13px; }
.refresh-button:hover { border-color: #c7d3e8; background: var(--accent-soft); }
.refresh-button span { display: inline-block; margin-right: 3px; }
.refresh-button.refreshing span { animation: spin .75s linear infinite; }
.refresh-button:disabled { opacity: .65; cursor: wait; }
@keyframes spin { to { transform: rotate(360deg); } }
.notice { margin-bottom: 18px; padding: 13px 16px; border: 1px solid #cfe0ff; border-radius: 13px; color: #315894; background: #f1f6ff; font-size: 13px; }
.version-list { display: grid; gap: 14px; }
.version-card { overflow: hidden; border: 1px solid var(--line); border-radius: 20px; background: rgba(255,255,255,.91); box-shadow: 0 10px 35px rgba(30,48,80,.045); transition: border-color .2s, box-shadow .2s; }
.version-card:hover, .version-card.expanded { border-color: #ccd6e8; box-shadow: 0 16px 42px rgba(30,48,80,.075); }
.version-row { display: grid; grid-template-columns: 1fr 72px; }
.version-link { min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 30px; padding: 24px 28px; color: inherit; text-decoration: none; }
.version-main { min-width: 0; }
.version-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 9px; }
.version-number { color: var(--accent); font-size: 13px; font-weight: 760; letter-spacing: .04em; }
.latest-badge, .status-badge, .health-badge { padding: 4px 8px; border-radius: 999px; font-size: 10px; font-weight: 700; }
.latest-badge { color: white; background: var(--accent); }
.status-badge { color: #566174; background: #eef1f6; }
.health-badge { display: inline-flex; align-items: center; gap: 5px; color: var(--success); background: #eaf8f3; }
.health-badge > span:first-child { width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px rgba(22,131,101,.11); }
.health-badge.offline { color: #b54752; background: #fff0f1; }
.health-badge.offline > span:first-child { box-shadow: 0 0 0 3px rgba(181,71,82,.1); }
.version-name { margin: 0 0 8px; font-size: clamp(20px, 2.4vw, 26px); }
.version-summary { max-width: 760px; margin: 0; color: var(--muted); font-size: 14px; line-height: 1.65; }
.enter-label { flex: 0 0 auto; color: var(--accent); font-size: 13px; font-weight: 700; white-space: nowrap; }
.expand-button { position: relative; border: 0; border-left: 1px solid var(--line); background: transparent; cursor: pointer; }
.expand-button:hover { background: var(--surface-soft); }
.expand-button span::before, .expand-button span::after { content: ""; position: absolute; left: 50%; top: 50%; width: 18px; height: 2px; margin: -1px 0 0 -9px; border-radius: 2px; background: var(--text); transition: transform .2s ease; }
.expand-button span::after { transform: rotate(90deg); }
.expand-button[aria-expanded="true"] span::after { transform: rotate(0); }
.version-details { border-top: 1px solid var(--line); background: linear-gradient(180deg, #fbfcfe, #f7f9fc); }
.details-inner { padding: 22px 28px 26px; }
.details-title { margin-bottom: 14px; color: #39465c; font-size: 13px; font-weight: 750; }
.change-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.change-list li { position: relative; padding-left: 20px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.change-list li::before { content: ""; position: absolute; left: 1px; top: .68em; width: 7px; height: 7px; border-radius: 50%; background: #83a3f8; box-shadow: 0 0 0 4px var(--accent-soft); }

footer { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-top: 1px solid rgba(212,218,229,.72); color: #8790a1; font-size: 12px; }

@media (max-width: 800px) {
  .page-shell { width: min(100% - 28px, 680px); }
  .brandbar { min-height: 76px; }
  .login-layout { min-height: auto; grid-template-columns: 1fr; gap: 30px; padding: 44px 0 60px; }
  .intro-panel { max-width: 560px; }
  .login-card { width: min(100%, 520px); justify-self: center; }
  .versions-view { padding: 44px 0 60px; }
  .versions-heading { align-items: flex-start; flex-direction: column; }
  .status-actions { width: 100%; justify-content: space-between; }
  .version-row { grid-template-columns: 1fr 58px; }
  .version-link { align-items: flex-start; flex-direction: column; gap: 15px; padding: 21px 20px; }
  .enter-label { display: none; }
  .details-inner { padding: 20px; }
}

@media (max-width: 480px) {
  .brand small, footer span:last-child { display: none; }
  .page-shell { width: min(100% - 22px, 680px); }
  .brandbar { min-height: 68px; }
  h1 { font-size: 40px; }
  .lead { font-size: 16px; }
  .login-layout { gap: 24px; padding: 32px 0 44px; }
  .login-card { padding: 24px 20px; border-radius: 20px; }
  .versions-heading h1 { font-size: 38px; }
  .version-summary { font-size: 13px; }
  footer { justify-content: center; }
}

/* Tall 20:9 / 21:9 phones in portrait: keep the login above the fold. */
@media (max-width: 480px) and (max-aspect-ratio: 10/19) {
  .brandbar { min-height: 58px; }
  .brand-mark { width: 36px; height: 36px; border-radius: 11px; font-size: 17px; }
  .login-layout { gap: 16px; padding: 20px 0 calc(28px + env(safe-area-inset-bottom, 0px)); }
  .intro-panel .eyebrow { margin-bottom: 8px; }
  .intro-panel h1 { margin-bottom: 10px; font-size: 34px; }
  .intro-panel .lead { margin-bottom: 0; font-size: 14px; line-height: 1.45; }
  .login-card { gap: 14px; padding: 19px 18px; }
  .login-card .eyebrow { margin-bottom: 7px; }
  .login-card h2 { margin-bottom: 5px; font-size: 24px; }
  .login-card .muted { margin-bottom: 0; font-size: 13px; }
  .login-card input { min-height: 45px; }
  .primary-button { min-height: 47px; }
  footer { min-height: calc(50px + env(safe-area-inset-bottom, 0px)); }
  .versions-view { padding: 28px 0 calc(44px + env(safe-area-inset-bottom, 0px)); }
  .versions-heading { gap: 16px; margin-bottom: 22px; }
  .versions-heading h1 { margin-bottom: 10px; font-size: 34px; }
  .version-link { gap: 11px; padding: 17px 16px; }
  .details-inner { padding: 17px 16px 20px; }
}

/* 21:9 phones in landscape have little vertical space despite desktop width. */
@media (max-height: 520px) and (min-aspect-ratio: 16/9) {
  .page-shell { width: min(100% - 32px, 1080px); }
  .brandbar { min-height: 52px; }
  .brand-mark { width: 34px; height: 34px; border-radius: 10px; font-size: 16px; }
  .brand small { display: none; }
  .login-layout { min-height: auto; grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); gap: 32px; padding: 16px 0 calc(22px + env(safe-area-inset-bottom, 0px)); }
  .intro-panel .eyebrow { margin-bottom: 6px; }
  .intro-panel h1 { margin-bottom: 8px; font-size: 34px; }
  .intro-panel .lead { margin-bottom: 0; font-size: 14px; line-height: 1.4; }
  .login-card { gap: 10px; padding: 15px 18px; border-radius: 18px; }
  .login-card .eyebrow { margin-bottom: 4px; }
  .login-card h2 { margin-bottom: 3px; font-size: 22px; }
  .login-card .muted, .privacy-note { display: none; }
  .login-card label { gap: 5px; }
  .login-card input { min-height: 40px; }
  .form-error { min-height: 16px; margin: -2px 0 -4px; }
  .primary-button { min-height: 42px; }
  .versions-view { padding: 20px 0 calc(28px + env(safe-area-inset-bottom, 0px)); }
  .versions-heading { margin-bottom: 18px; }
  .versions-heading h1 { margin-bottom: 7px; font-size: 32px; }
  .versions-heading .lead { font-size: 13px; line-height: 1.45; }
  .version-link { padding: 14px 18px; }
  .version-summary { line-height: 1.45; }
  .details-inner { padding: 15px 18px 18px; }
  footer { min-height: 42px; }
}

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