@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@500;600&display=swap');

:root {
  --ink: #0E1420;
  --panel: #141C2B;
  --panel-raised: #1A2436;
  --line: #263149;
  --text: #E8ECF3;
  --text-dim: #8B96AC;
  --teal: #4FB6AA;
  --amber: #E8A33D;
  --red: #E2574C;
  --blue: #6C93E8;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-card: 0 1px 2px rgba(0,0,0,.35), 0 12px 28px -16px rgba(0,0,0,.55);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

body {
  background:
    radial-gradient(1200px 600px at 12% -10%, rgba(108,147,232,0.10), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(79,182,170,0.08), transparent 55%),
    var(--ink);
  background-attachment: fixed;
}

.mono { font-family: 'IBM Plex Mono', ui-monospace, monospace; }

a { color: var(--blue); }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 36px 32px;
}
.brand-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: linear-gradient(135deg, var(--teal), var(--blue));
  margin-right: 9px;
  vertical-align: 1px;
}
.login-card h1 {
  font-size: 19px;
  font-weight: 600;
  margin: 0 0 4px;
}
.login-card p {
  color: var(--text-dim);
  font-size: 13px;
  margin: 0 0 24px;
}
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  background: var(--ink);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  border-radius: var(--radius-sm);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(108,147,232,0.18);
}
.btn {
  width: 100%;
  background: var(--blue);
  color: #0E1420;
  border: none;
  padding: 11px;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-top: 6px;
  transition: filter .15s ease, transform .05s ease, opacity .15s ease;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .7; cursor: default; filter: none; }
.error-msg {
  color: var(--red);
  background: rgba(226,87,76,0.10);
  border-radius: var(--radius-sm);
  font-size: 13px;
  padding: 8px 10px;
  margin: -8px 0 16px;
}

/* ---------- Dashboard shell ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 20px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(14,20,32,0.85);
  backdrop-filter: saturate(1.2) blur(8px);
  -webkit-backdrop-filter: saturate(1.2) blur(8px);
}
.topbar h1 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}
.topbar .host {
  color: var(--text-dim);
  font-size: 13px;
  margin-left: 10px;
}
.topbar a.logout {
  color: var(--text-dim);
  font-size: 13px;
  text-decoration: none;
  border: 1px solid var(--line);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: color .15s ease, border-color .15s ease, background-color .15s ease;
}
.topbar a.logout:hover { color: var(--text); border-color: var(--text-dim); background: rgba(255,255,255,0.03); }

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 22px 24px 24px;
}
section > h2 {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 0 0 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

/* ---------- Vitals gauges ---------- */
.vitals-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 24px;
}
.gauge-block { text-align: center; }
.gauge-block .gauge-label {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 6px;
}
.gauge-block .gauge-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}
.gauge-value {
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-weight: 600;
  font-size: 22px;
  font-variant-numeric: tabular-nums;
}

.net-uptime-row {
  display: flex;
  gap: 32px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.stat-inline .stat-inline-label { font-size: 12px; color: var(--text-dim); }
.stat-inline .stat-inline-value {
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: 16px;
  font-weight: 600;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

/* ---------- History chart ---------- */
#history-chart { width: 100%; height: 120px; display: block; }

/* ---------- Tables / lists ---------- */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th {
  text-align: left;
  font-weight: 500;
  color: var(--text-dim);
  font-size: 12px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
}
tr:last-child td { border-bottom: none; }
tbody tr { transition: background-color .15s ease; }
tbody tr:hover { background: rgba(255,255,255,0.025); }

.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  transition: background-color .2s ease, color .2s ease;
}
.pill-ok { background: rgba(79,182,170,0.15); color: var(--teal); }
.pill-warn { background: rgba(232,163,61,0.15); color: var(--amber); }
.pill-bad { background: rgba(226,87,76,0.15); color: var(--red); }

.empty-note { color: var(--text-dim); background: rgba(139,150,172,0.07); font-size: 13px; padding: 7px 10px; border-radius: var(--radius-sm); }
.error-note { color: var(--red); background: rgba(226,87,76,0.10); font-size: 13px; padding: 7px 10px; border-radius: var(--radius-sm); }

.subsection {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
@media (max-width: 720px) {
  main { padding: 18px; gap: 16px; }
  .topbar { padding: 16px 18px; flex-wrap: wrap; gap: 8px; }
  section { padding: 18px 18px 20px; }

  /* Tables collapse into stacked label/value cards instead of a cramped,
     horizontally-scrolling grid — each <tr> becomes one card, each <td>
     shows a small caption (from its data-label attribute) above its value.
     Rows with no data-label (full-width empty/skeleton messages) are left
     alone, since there's nothing to label. */
  table.responsive-stack thead { display: none; }
  table.responsive-stack, table.responsive-stack tbody,
  table.responsive-stack tr, table.responsive-stack td {
    display: block;
    width: 100%;
  }
  table.responsive-stack tr {
    margin-bottom: 10px;
    padding: 10px 12px;
    background: var(--panel-raised);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
  }
  table.responsive-stack tr:last-child { margin-bottom: 0; }
  table.responsive-stack td {
    padding: 4px 0;
    border-bottom: none;
  }
  table.responsive-stack td[data-label]::before {
    content: attr(data-label);
    display: block;
    color: var(--text-dim);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: 2px;
  }
}

.status-counts {
  display: flex;
  gap: 20px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.status-counts .sc-item { font-size: 13px; }
.status-counts .sc-value {
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-weight: 600;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.mail-totals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 18px;
}
.mail-totals .mt-value {
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-weight: 600;
  font-size: 24px;
  font-variant-numeric: tabular-nums;
}
.mail-totals .mt-label { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

.service-row {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.service-row:last-child { border-bottom: none; }
.service-row-head {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.service-name { font-weight: 600; font-size: 14px; }
.service-meta { font-size: 12px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.service-row summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 8px;
  list-style: none;
  transition: color .15s ease;
}
.service-row summary:hover { color: var(--text); }
.service-row summary::-webkit-details-marker { display: none; }
.service-row summary:before { content: '▸ '; }
.service-row details[open] summary:before { content: '▾ '; }
.service-log-line {
  font-size: 11px;
  color: var(--text-dim);
  padding: 3px 0;
  border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere;
}

.vhost-errors {
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}
.vhost-errors:last-child { border-bottom: none; }
.vhost-errors summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--text-dim);
  padding: 2px 0;
  list-style: none;
  transition: color .15s ease;
}
.vhost-errors summary:hover { color: var(--text); }
.vhost-errors summary::-webkit-details-marker { display: none; }
.vhost-errors summary:before { content: '▸ '; }
.vhost-errors[open] summary:before { content: '▾ '; }

.vhost-ok {
  font-size: 13px;
  color: var(--text-dim);
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.vhost-ok:last-child { border-bottom: none; }
.vhost-ok:before { content: '✓ '; color: var(--teal); }

.updated-note {
  color: var(--text-dim);
  font-size: 12px;
}

/* ---------- Loading skeletons (first-load placeholder, replaced once
   dashboard.js's refresh() overwrites the container's innerHTML) ---------- */
.skeleton {
  background: linear-gradient(90deg, var(--panel-raised) 25%, rgba(255,255,255,0.06) 37%, var(--panel-raised) 63%);
  background-size: 400% 100%;
  border-radius: var(--radius-sm);
  animation: skeleton-pulse 1.4s ease infinite;
}
@keyframes skeleton-pulse {
  0% { background-position: 100% 0; }
  100% { background-position: 0 0; }
}
@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
}
.skeleton-line { height: 13px; margin: 7px 0; }
.skeleton-block { height: 72px; }
