:root {
  color-scheme: light dark;
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-soft: #fbfbfd;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --border: #e3e3e8;
  --border-strong: #d2d2d7;
  --accent: #1d6f5c;
  --accent-hover: #175a4a;
  --accent-contrast: #ffffff;
  --danger: #b42318;
  --danger-soft: #fdf1f0;
  --success: #1a7f5a;
  --success-soft: #eef8f3;
  --warning: #8a6100;
  --warning-soft: #fdf7e8;
  --code-bg: #f2f2f4;
  --code-text: #2c2c2e;
  --radius: 14px;
  --radius-small: 9px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 10px 30px rgba(0, 0, 0, 0.05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0b0c;
    --surface: #161617;
    --surface-soft: #1c1c1e;
    --text: #f5f5f7;
    --muted: #a1a1a6;
    --border: #2c2c2e;
    --border-strong: #3a3a3c;
    --accent: #59b79f;
    --accent-hover: #76c8b3;
    --accent-contrast: #06231d;
    --danger: #ff7a70;
    --danger-soft: #2a1514;
    --success: #5cc59a;
    --success-soft: #10241c;
    --warning: #e3b65b;
    --warning-soft: #2a2111;
    --code-bg: #101012;
    --code-text: #d7d7dc;
    --shadow: none;
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-weight: 650;
}

h2 {
  font-size: 19px;
  letter-spacing: -0.01em;
}

.muted {
  color: var(--muted);
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 28px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 24px;
}

.brand {
  color: var(--text);
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.brand:hover {
  text-decoration: none;
}

.nav {
  display: flex;
  gap: 4px;
  flex: 1;
}

.nav a {
  padding: 7px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}

.nav a:hover {
  background: var(--surface-soft);
  color: var(--text);
  text-decoration: none;
}

.nav a.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.account {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.account-name {
  color: var(--text);
  font-weight: 550;
}

.account-role {
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 0.02em;
}

.inline {
  display: inline-flex;
  margin: 0;
}

.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.link-button:hover {
  color: var(--text);
  text-decoration: underline;
}

.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 24px 64px;
}

.container-centered {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding-top: 24px;
  padding-bottom: 24px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 26px;
}

.page-head .muted {
  margin-top: 6px;
}

.page-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.banner {
  margin: 0 0 20px;
  padding: 12px 16px;
  border-radius: var(--radius-small);
  font-size: 14px;
}

.banner p + p {
  margin-top: 4px;
}

.banner-success {
  background: var(--success-soft);
  color: var(--success);
}

.banner-error {
  background: var(--danger-soft);
  color: var(--danger);
}

.banner-warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-small);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 550;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
}

.button:hover {
  border-color: var(--muted);
  text-decoration: none;
}

.button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.button-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-contrast);
}

.button-primary:hover {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}

.button-danger {
  border-color: color-mix(in srgb, var(--danger) 35%, var(--border));
  color: var(--danger);
}

.button-danger:hover {
  border-color: var(--danger);
}

.button-small {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 13px;
}

.button-block {
  width: 100%;
}

.table-wrap {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

table.sites {
  width: 100%;
  border-collapse: collapse;
}

table.sites th {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-align: left;
  text-transform: uppercase;
}

table.sites td {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

table.sites tbody tr:last-child td {
  border-bottom: 0;
}

.actions-heading {
  width: 1%;
  white-space: nowrap;
}

.site-name {
  display: block;
  font-weight: 600;
}

.site-domain {
  display: block;
  margin-top: 2px;
  font-size: 13px;
}

.site-domain a {
  color: var(--muted);
}

.site-domain a:hover {
  color: var(--accent);
}

.site-error {
  display: block;
  max-width: 520px;
  margin-top: 6px;
  color: var(--danger);
  font-size: 12px;
  line-height: 1.4;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 550;
  white-space: nowrap;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
}

.status-online {
  color: var(--success);
}

.status-online .dot {
  background: var(--success);
}

.status-stopped {
  color: var(--muted);
}

.status-stopped .dot {
  background: var(--muted);
}

.status-error {
  color: var(--danger);
}

.status-error .dot {
  background: var(--danger);
}

.status-deploying {
  color: var(--warning);
}

.status-deploying .dot {
  background: var(--warning);
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 1;
  }
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.empty {
  padding: 56px 32px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-soft);
  text-align: center;
}

.empty h2 {
  margin-bottom: 8px;
}

.empty p {
  max-width: 470px;
  margin: 0 auto 22px;
  color: var(--muted);
}

.card {
  padding: 26px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.form {
  display: grid;
  gap: 20px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.field {
  display: grid;
  gap: 7px;
}

.field-label {
  font-size: 13px;
  font-weight: 600;
}

.field-help {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="url"],
textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-small);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
}

textarea {
  resize: vertical;
  font-family: var(--mono);
  font-size: 13px;
}

input:focus,
textarea:focus,
.button:focus-visible,
.link-button:focus-visible,
.nav a:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 2px;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
}

.check-list {
  display: grid;
  gap: 8px;
}

.check-item {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  cursor: pointer;
}

.check-item:hover {
  border-color: var(--border-strong);
  background: var(--surface-soft);
}

.check-item input {
  margin: 4px 0 0;
  accent-color: var(--accent);
}

.check-title {
  display: block;
  font-weight: 550;
}

.check-sub {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.login {
  width: 100%;
  max-width: 380px;
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-brand {
  font-size: 26px;
  font-weight: 650;
  letter-spacing: -0.03em;
  text-align: center;
}

.login-sub {
  margin: 6px 0 26px;
  color: var(--muted);
  text-align: center;
}

.login .form {
  gap: 16px;
}

.error-page {
  max-width: 520px;
  padding: 40px 0;
}

.error-code {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.error-page h1 {
  margin: 6px 0 10px;
}

.error-page .button {
  margin-top: 24px;
}

.logs {
  max-height: 62vh;
  margin: 0;
  padding: 18px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--code-bg);
  color: var(--code-text);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.danger-zone {
  border-color: color-mix(in srgb, var(--danger) 30%, var(--border));
}

.danger-title {
  margin-bottom: 6px;
  color: var(--danger);
  font-weight: 600;
}

.danger-zone > p {
  margin-bottom: 18px;
}

.footer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px 32px;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 760px) {
  .topbar-inner {
    flex-wrap: wrap;
    gap: 10px 18px;
    padding: 12px 18px;
  }

  .nav {
    order: 3;
    flex-basis: 100%;
  }

  .account {
    margin-left: auto;
  }

  .account-role {
    display: none;
  }

  .container {
    padding: 26px 16px 48px;
  }

  .page-head {
    flex-direction: column;
    align-items: stretch;
  }

  .page-head > .button,
  .page-head > .page-actions {
    align-self: flex-start;
  }

  h1 {
    font-size: 24px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .card,
  .login {
    padding: 20px;
  }

  .table-wrap {
    border: 0;
    background: none;
    box-shadow: none;
    overflow: visible;
  }

  table.sites,
  table.sites tbody,
  table.sites tr,
  table.sites td {
    display: block;
    width: 100%;
  }

  table.sites thead {
    display: none;
  }

  table.sites tr {
    margin-bottom: 12px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
  }

  table.sites td {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    padding: 6px 0;
    border: 0;
    text-align: right;
  }

  table.sites td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-align: left;
    text-transform: uppercase;
  }

  table.sites td[data-label="Site"] {
    display: block;
    padding-bottom: 10px;
    text-align: left;
  }

  table.sites td[data-label="Site"]::before {
    display: none;
  }

  table.sites td[data-label="Actions"] {
    display: block;
    padding-top: 12px;
  }

  table.sites td[data-label="Actions"]::before {
    display: none;
  }

  .actions {
    justify-content: flex-start;
  }

  .site-error {
    text-align: left;
  }

  .form-actions {
    flex-direction: column-reverse;
  }

  .form-actions .button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
