/* VibeStack Host - the panel's whole stylesheet.
 *
 * Calm and clean: few colours, lots of air, one accent. The page follows the
 * system light and dark setting through prefers-color-scheme, so there is no theme
 * switch and nothing to store. It reads well in a desktop browser and on a phone;
 * tables turn into stacked cards on a narrow screen.
 */

:root {
  color-scheme: light dark;

  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-sunken: #f1f1ee;
  --text: #1b1d1f;
  --muted: #6a7075;
  --border: #e3e4e2;
  --border-strong: #cfd1ce;
  --accent: #2f6d5f;
  --accent-soft: #e7f0ed;
  --on-accent: #ffffff;
  --danger: #a4453c;
  --danger-soft: #f7eae8;
  --warning: #8a6a1f;
  --warning-soft: #f6f1e3;
  --success: #2f6d5f;
  --success-soft: #e7f0ed;

  --radius: 10px;
  --radius-small: 6px;
  --gap: 20px;
  --shadow: 0 1px 2px rgba(20, 22, 24, 0.05), 0 8px 24px rgba(20, 22, 24, 0.04);

  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a;
    --surface: #1c1f22;
    --surface-sunken: #23272b;
    --text: #e8eaec;
    --muted: #9aa1a7;
    --border: #2c3135;
    --border-strong: #3a4045;
    --accent: #7cc0ad;
    --accent-soft: #1f2f2b;
    --on-accent: #10201c;
    --danger: #e2928a;
    --danger-soft: #2e2222;
    --warning: #d9b871;
    --warning-soft: #2b2620;
    --success: #7cc0ad;
    --success-soft: #1f2f2b;
    --shadow: none;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

a {
  color: var(--accent);
  text-underline-offset: 2px;
}

a:hover {
  text-decoration: none;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

.skip-link {
  position: absolute;
  left: -9999px;
}

.skip-link:focus {
  left: 12px;
  top: 12px;
  z-index: 10;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-small);
}

/* ---------------------------------------------------------------- top bar -- */

.topbar {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.topbar-inner {
  max-width: 1000px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.brand {
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.brand-mark {
  color: var(--accent);
  font-size: 0.95rem;
}

.nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: var(--radius-small);
}

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

.nav a[aria-current="page"] {
  color: var(--text);
  background: var(--surface-sunken);
  font-weight: 600;
}

.nav form {
  display: inline;
  margin: 0;
}

.nav .link-button {
  background: none;
  border: 0;
  padding: 6px 10px;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
  border-radius: var(--radius-small);
}

.nav .link-button:hover {
  background: var(--surface-sunken);
  color: var(--text);
}

/* ----------------------------------------------------------------- layout -- */

.container {
  flex: 1 0 auto;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  padding: 32px 20px 56px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.page-head h1 {
  margin: 0;
  font-size: 1.6rem;
  letter-spacing: -0.01em;
}

.page-head .actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.lede {
  color: var(--muted);
  margin: 0 0 28px;
  max-width: 62ch;
}

h2 {
  font-size: 1.05rem;
  margin: 0 0 4px;
  letter-spacing: 0.01em;
}

h3 {
  font-size: 0.95rem;
  margin: 0 0 6px;
}

.section {
  margin: 0 0 28px;
}

.section h2 + .hint,
.section h2 + p {
  margin-top: 0;
}

.hint {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 12px;
  max-width: 68ch;
}

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

.card + .card {
  margin-top: 16px;
}

.card.tight {
  padding: 16px 18px;
}

.empty {
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 36px 24px;
  text-align: center;
  color: var(--muted);
}

.empty strong {
  display: block;
  color: var(--text);
  font-size: 1.05rem;
  margin-bottom: 6px;
}

.empty .actions {
  margin-top: 18px;
  justify-content: center;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

@media (max-width: 780px) {
  .split {
    grid-template-columns: 1fr;
  }
}

/* ------------------------------------------------------------------ facts -- */

.facts {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(140px, 180px) minmax(0, 1fr);
  gap: 10px 20px;
}

.facts dt {
  color: var(--muted);
  font-size: 0.9rem;
  padding-top: 1px;
}

.facts dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

@media (max-width: 560px) {
  .facts {
    grid-template-columns: 1fr;
    gap: 2px 0;
  }

  .facts dd {
    margin-bottom: 12px;
  }
}

.mono {
  font-family: var(--mono);
  font-size: 0.86rem;
}

.key {
  display: block;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 0.8rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 12rem;
  overflow: auto;
}

/* ----------------------------------------------------------------- tables -- */

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.table caption {
  text-align: left;
  color: var(--muted);
  font-size: 0.9rem;
  padding-bottom: 10px;
}

.table th,
.table td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.table th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
  background: var(--surface-sunken);
}

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

.table .nowrap {
  white-space: nowrap;
}

@media (max-width: 700px) {
  .table,
  .table tbody,
  .table tr,
  .table td {
    display: block;
    width: 100%;
  }

  .table thead {
    display: none;
  }

  .table tr {
    border-bottom: 1px solid var(--border);
    padding: 6px 0;
  }

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

  .table td {
    border: 0;
    display: flex;
    gap: 14px;
    padding: 6px 16px;
  }

  .table td::before {
    content: attr(data-label);
    flex: 0 0 42%;
    color: var(--muted);
    font-size: 0.85rem;
  }
}

/* ---------------------------------------------------------------- badges --- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  background: var(--surface-sunken);
  color: var(--muted);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.badge.is-up {
  background: var(--success-soft);
  color: var(--success);
  border-color: transparent;
}

.badge.is-down {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: transparent;
}

.badge.is-idle {
  background: var(--surface-sunken);
  color: var(--muted);
}

.badge.is-moving {
  background: var(--warning-soft);
  color: var(--warning);
  border-color: transparent;
}

/* --------------------------------------------------------------- messages -- */

.message {
  border-radius: var(--radius);
  padding: 12px 16px;
  margin: 0 0 20px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.message.ok {
  background: var(--success-soft);
  border-color: transparent;
  color: var(--success);
}

.message.error {
  background: var(--danger-soft);
  border-color: transparent;
  color: var(--danger);
}

.message.warning {
  background: var(--warning-soft);
  border-color: transparent;
  color: var(--warning);
}

.message p {
  margin: 0;
}

.message p + p {
  margin-top: 6px;
}

.note {
  color: var(--muted);
  font-size: 0.9rem;
}

.note strong {
  color: var(--text);
}

.mt-2 {
  margin-top: 14px;
}

.mt-3 {
  margin-top: 20px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --------------------------------------------------------------- buttons --- */

.button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-small);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}

.button:hover {
  background: var(--surface-sunken);
}

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

.button.primary:hover {
  filter: brightness(1.06);
}

.button.small {
  padding: 5px 10px;
  font-size: 0.88rem;
}

.button[disabled],
.button[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}

.button[disabled]:hover {
  background: var(--surface);
}

.button.primary[disabled]:hover {
  background: var(--accent);
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

/* ----------------------------------------------------------------- forms --- */

.form {
  display: grid;
  gap: 16px;
  max-width: 34rem;
}

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

.field label {
  font-weight: 600;
  font-size: 0.92rem;
}

.field .help {
  color: var(--muted);
  font-size: 0.85rem;
}

.field input,
.field select,
.field textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-small);
  padding: 9px 11px;
  width: 100%;
}

.field textarea {
  font-family: var(--mono);
  font-size: 0.86rem;
  min-height: 6rem;
  resize: vertical;
}

.field input:disabled,
.field select:disabled,
.field textarea:disabled {
  background: var(--surface-sunken);
  color: var(--muted);
}

.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 16px;
}

/* A field whose value has a fixed part after it, like the domain of a subdomain:
   the box takes the room and the part that is not typed sits beside it. */
.field-row.subdomain {
  display: flex;
  align-items: center;
  gap: 8px;
}

.field-row.subdomain input {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
}

.field-row.subdomain .suffix {
  font-family: var(--mono);
  font-size: 0.95rem;
  color: var(--muted);
  white-space: nowrap;
}

.form .actions {
  margin-top: 4px;
}

/* ---------------------------------------------------------------- footer --- */

.footer {
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
  padding: 18px 20px;
}

.footer-inner {
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: space-between;
}

/* ---------------------------------------------------------------- narrow --- */

@media (max-width: 560px) {
  .container {
    padding: 22px 16px 44px;
  }

  .topbar-inner {
    padding: 12px 16px;
  }

  .card {
    padding: 18px 16px;
  }

  .page-head h1 {
    font-size: 1.35rem;
  }

  .page-head .actions {
    margin-left: 0;
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
