:root {
  color-scheme: light;
  --ink: #17211c;
  --muted: #637068;
  --brand: #137a4c;
  --brand-dark: #0f603c;
  --header: #10271d;
  --surface: #fff;
  --background: #f4f7f5;
  --line: #d8e2dc;
  --soft: #edf4f0;
  --radius: 16px;
  --shadow: 0 12px 32px rgba(18, 42, 29, .07);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--background); color: var(--ink); font: 400 16px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif; }
.site-header { min-height: 68px; padding: 14px max(20px, calc((100% - 1120px) / 2)); display: flex; align-items: center; justify-content: space-between; gap: 24px; background: var(--header); }
.brand { color: #fff; font-size: 1.08rem; font-weight: 750; text-decoration: none; white-space: nowrap; }
.brand span { color: #7dd5a5; }
nav { display: flex; align-items: center; gap: 8px; }
nav a, .nav-link { padding: 9px 11px; border: 0; background: transparent; color: #fff; font: inherit; text-decoration: none; }
nav form { margin: 0; }
main { max-width: 1120px; margin: auto; padding: 42px 20px 80px; }
h1, h2 { line-height: 1.15; }
h1 { margin: .15em 0 .3em; font-size: clamp(2rem, 5vw, 2.75rem); letter-spacing: -.035em; }
h2 { margin: 16px 0 6px; font-size: 1.45rem; letter-spacing: -.02em; }
p { margin: 0 0 1em; }
.lead, .muted, .help { color: var(--muted); }
.eyebrow { margin-bottom: 8px; color: var(--brand-dark); font-size: .76rem; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.grid { display: grid; grid-template-columns: 1fr; gap: 18px; }
.instance-card { display: grid; gap: 22px; padding: 24px; }
.instance-summary p { margin-bottom: 0; }
.instance-summary .health-note { margin-top: 9px; color: var(--muted); font-size: .86rem; }
.instance-summary .health-note.healthy { color: var(--brand-dark); }
.instance-summary .health-note.suspect, .instance-summary .health-note.recovering,
.instance-summary .health-note.cooldown, .instance-summary .health-note.stale,
.instance-summary .health-note.restart_failed, .instance-summary .health-note.global_failure { color: #7a4d16; }
.status { display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px; border-radius: 999px; background: var(--soft); color: var(--ink); font-size: .78rem; font-weight: 700; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #7a8980; }
.status.on::before { background: var(--brand); }
form { display: grid; gap: 16px; margin-top: 22px; }
label { display: grid; gap: 7px; font-weight: 650; }
.field-hint { color: var(--muted); font-size: .88rem; font-weight: 400; }
input, textarea { width: 100%; min-width: 0; padding: 12px 13px; border: 1px solid #b9c7bf; border-radius: 10px; outline: 0; background: #fff; color: var(--ink); font: inherit; }
textarea { resize: vertical; overflow-wrap: anywhere; }
input:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(19, 122, 76, .14); }
button, .button, .secondary-button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; padding: 11px 16px; border: 1px solid var(--brand); border-radius: 10px; background: var(--brand); color: #fff; font: inherit; font-weight: 700; text-align: center; text-decoration: none; cursor: pointer; }
button:hover, .button:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
button:focus-visible, .button:focus-visible, .secondary-button:focus-visible, nav a:focus-visible, .nav-link:focus-visible { outline: 3px solid rgba(19, 122, 76, .28); outline-offset: 3px; }
.secondary-button { border-color: #aebdb4; background: #fff; color: var(--ink); }
.secondary-button:hover { border-color: var(--ink); background: var(--soft); }
.instance-action { margin: 0; }
.instance-action button { width: 100%; }
.disconnect-details { width: 100%; }
.disconnect-details summary { list-style: none; }
.disconnect-details summary::-webkit-details-marker { display: none; }
.confirm-panel { width: min(100%, 440px); margin: 18px auto 0; padding: 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--soft); }
.confirm-copy { margin: 0; font-weight: 650; }
.confirm-button { background: var(--header); border-color: var(--header); }
.confirm-button:hover { background: #081a12; border-color: #081a12; }
.auth, .form-card, .qr { max-width: 570px; margin: 24px auto; padding: 28px; }
.link-field { margin-top: 20px; }
.copy-button { margin-top: 16px; }
.alert, .success { margin: 18px 0; padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--soft); color: var(--ink); }
.secret { display: block; margin: 10px 0; padding: 12px; background: #fff; overflow-wrap: anywhere; }
.empty { padding: 28px; }
.qr { margin-top: clamp(28px, 10vh, 90px); text-align: center; }
.qrbox { width: min(320px, 100%); aspect-ratio: 1; margin: 24px auto; padding: 14px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.qrbox img { width: 100%; height: 100%; object-fit: contain; }
.spinner { width: 46px; height: 46px; border: 5px solid #dce9e1; border-top-color: var(--brand); border-radius: 50%; animation: spin 1s linear infinite; }
.check { color: var(--brand); font-size: 5rem; }
@keyframes spin { to { transform: rotate(360deg); } }
.users { padding: 0; list-style: none; }
.users li { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.user-summary { display: grid; gap: 2px; }
.user-summary span { color: var(--muted); font-size: .88rem; }
.user-delete { width: min(100%, 440px); }
.user-delete summary { list-style: none; }
.user-delete summary::-webkit-details-marker { display: none; }
.user-delete .confirm-panel { grid-column: 1 / -1; }
code { overflow-wrap: anywhere; }

@media (min-width: 760px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .instance-card { grid-template-columns: minmax(0, 1fr) 230px; align-items: start; }
  .disconnect-details { grid-column: 1 / -1; }
}

@media (max-width: 759px) {
  .site-header { align-items: flex-start; }
  nav { flex-wrap: wrap; justify-content: flex-end; font-size: .9rem; }
  main { padding: 28px 14px 60px; }
  .heading { align-items: stretch; flex-direction: column; }
  .heading .button { width: 100%; }
  .card { border-radius: 14px; }
  .instance-card, .auth, .form-card, .qr { padding: 20px; }
  .users li { grid-template-columns: 1fr; }
  .user-delete, .user-delete summary { width: 100%; }
}

@media (max-width: 480px) {
  .site-header { display: block; }
  .brand { display: block; margin-bottom: 8px; }
  nav { justify-content: flex-start; }
  nav a, .nav-link { padding: 8px; }
  .qrbox { width: min(260px, 100%); }
}
