/* ─── Reset & Base ──────────────────────────────────────────────────────────── */

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

:root {
  --bg:          #0d1117;
  --bg-surface:  #161b22;
  --bg-raised:   #1c2128;
  --border:      #30363d;
  --border-muted:#21262d;
  --text:        #e6edf3;
  --text-muted:  #8b949e;
  --text-subtle: #6e7681;
  --accent:      #2f81f7;
  --accent-hover:#388bfd;
  --accent-muted:#1f3f6e;
  --green:       #3fb950;
  --red:         #f85149;
  --yellow:      #d29922;
  --radius:      6px;
  --font-mono:   "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --font-sans:   -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

html { font-size: 14px; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

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

/* ─── Layout ────────────────────────────────────────────────────────────────── */

.page-wrap {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

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

/* ─── Topnav ────────────────────────────────────────────────────────────────── */

.topnav {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  height: 52px;
  display: flex;
  align-items: center;
}

.topnav .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topnav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  text-decoration: none;
}

.topnav-brand:hover { color: var(--text); text-decoration: none; }

.brand-icon {
  width: 22px;
  height: 22px;
  background: var(--accent);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.topnav-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: var(--text-muted);
}

/* ─── Main content ──────────────────────────────────────────────────────────── */

.main-content {
  flex: 1;
  padding: 32px 0;
}

/* ─── Flash messages ────────────────────────────────────────────────────────── */

.flash-bar {
  padding: 10px 0;
  font-size: 13px;
}

.flash {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid;
  margin-bottom: 8px;
}

.flash.notice {
  background: rgba(63, 185, 80, 0.1);
  border-color: rgba(63, 185, 80, 0.3);
  color: var(--green);
}

.flash.alert {
  background: rgba(248, 81, 73, 0.1);
  border-color: rgba(248, 81, 73, 0.3);
  color: var(--red);
}

/* ─── Cards ─────────────────────────────────────────────────────────────────── */

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.card-body {
  padding: 20px;
}

/* ─── Buttons ────────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
  text-decoration: none;
  white-space: nowrap;
  font-family: var(--font-sans);
}

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

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }

.btn-secondary {
  background: var(--bg-raised);
  border-color: var(--border);
  color: var(--text);
}
.btn-secondary:hover { background: #2d333b; border-color: #8b949e; color: var(--text); }

.btn-danger {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}
.btn-danger:hover { background: rgba(248,81,73,0.1); border-color: var(--red); color: var(--red); }

.btn-sm { padding: 3px 10px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }

/* ─── Forms ──────────────────────────────────────────────────────────────────── */

.field { margin-bottom: 16px; }

label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

input[type="email"],
input[type="password"],
input[type="text"] {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  padding: 7px 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: var(--font-sans);
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47,129,247,0.15);
}

input::placeholder { color: var(--text-subtle); }

/* ─── Login page ─────────────────────────────────────────────────────────────── */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 360px;
}

.login-header {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo {
  width: 44px;
  height: 44px;
  background: var(--accent);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  margin: 0 auto 16px;
}

.login-header h1 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.login-header p {
  font-size: 13px;
  color: var(--text-muted);
}

/* ─── Dashboard ──────────────────────────────────────────────────────────────── */

.page-header {
  margin-bottom: 24px;
}

.page-header h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}

.page-header p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

/* ─── Stat widget ────────────────────────────────────────────────────────────── */

.stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.stat-value {
  font-size: 28px;
  font-weight: 600;
  color: var(--text);
  font-family: var(--font-mono);
}

.stat-sub {
  font-size: 12px;
  color: var(--text-subtle);
  margin-top: 4px;
}

/* ─── Badge ──────────────────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-green  { background: rgba(63,185,80,0.15);  color: var(--green); }
.badge-red    { background: rgba(248,81,73,0.15);  color: var(--red); }
.badge-yellow { background: rgba(210,153,34,0.15); color: var(--yellow); }
.badge-muted  { background: var(--bg-raised);      color: var(--text-muted); }

/* ─── Table ──────────────────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  text-align: left;
  padding: 8px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

tbody tr {
  border-bottom: 1px solid var(--border-muted);
  transition: background 0.1s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,0.02); }

tbody td {
  padding: 11px 16px;
  color: var(--text);
  vertical-align: middle;
}

td.muted { color: var(--text-muted); font-family: var(--font-mono); font-size: 12px; }

/* ─── Runbook ────────────────────────────────────────────────────────────────── */

.runbook-step {
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--bg-surface);
  margin-bottom: 16px;
  overflow: hidden;
}

.step-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-muted);
  background: var(--bg-raised);
}

.step-number {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  white-space: nowrap;
}

.step-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.step-desc {
  font-size: 13px;
  color: var(--text-muted);
  padding: 12px 18px 0;
  line-height: 1.6;
}

.code-block {
  margin: 12px 18px 16px;
  background: var(--bg);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius);
  overflow: hidden;
}

.code-block pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
}

.code-block code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--text);
  white-space: pre;
}

/* ─── Server meta dl ─────────────────────────────────────────────────────────── */

.server-meta {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 24px;
  font-size: 13px;
}

.server-meta dt {
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
  padding-top: 2px;
}

.server-meta dd { color: var(--text); }
.server-meta .mono { font-family: var(--font-mono); font-size: 12px; }

code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-raised);
  border: 1px solid var(--border-muted);
  border-radius: 3px;
  padding: 1px 5px;
  color: var(--text);
}

/* ─── Runbook article (screen) ───────────────────────────────────────────────── */

.runbook-article {
  max-width: 820px;
}

.runbook-chrome {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.back-link {
  font-size: 13px;
  color: var(--text-muted);
}

.runbook-header {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.runbook-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.runbook-title-row h1 {
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
}

.runbook-badges { display: flex; gap: 6px; }

.runbook-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

.runbook-meta-section {
  margin-bottom: 28px;
}

.runbook-meta-section h2 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

/* ─── Footer ─────────────────────────────────────────────────────────────────── */

.topfooter {
  border-top: 1px solid var(--border-muted);
  padding: 16px 0;
  font-size: 12px;
  color: var(--text-subtle);
}

.topfooter .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ─── Print ───────────────────────────────────────────────────────────────────── */

@media print {
  @page {
    size: A4;
    margin: 2cm 2.2cm;
  }

  /* Hide all screen chrome */
  .no-print { display: none !important; }

  /* Reset colours to white/black for ink efficiency */
  :root {
    --bg:          #fff;
    --bg-surface:  #fff;
    --bg-raised:   #f5f5f5;
    --border:      #ccc;
    --border-muted:#ddd;
    --text:        #111;
    --text-muted:  #444;
    --text-subtle: #666;
    --accent:      #1a56c4;
    --green:       #1a7a2e;
    --red:         #b91c1c;
    --yellow:      #92620a;
  }

  body {
    background: #fff;
    color: #111;
    font-size: 11pt;
    line-height: 1.5;
  }

  /* Remove container padding constraints so content fills the page */
  .main-content { padding: 0; }
  .container     { max-width: 100%; padding: 0; }
  .runbook-article { max-width: 100%; }

  /* Article header */
  .runbook-header {
    border-bottom: 2px solid #111;
    margin-bottom: 18pt;
    padding-bottom: 10pt;
  }

  .runbook-title-row h1 {
    font-size: 22pt;
    font-weight: 700;
    color: #111;
  }

  .runbook-subtitle {
    font-size: 10pt;
    color: #444;
  }

  /* Service info section */
  .runbook-meta-section {
    margin-bottom: 18pt;
    padding-bottom: 12pt;
    border-bottom: 1px solid #ccc;
  }

  .runbook-meta-section h2 {
    font-size: 8pt;
    color: #444;
    margin-bottom: 8pt;
  }

  .server-meta { font-size: 10pt; gap: 4pt 20pt; }
  .server-meta dt { color: #444; }
  .server-meta dd, .server-meta .mono { color: #111; }

  /* Keep each step together; allow page breaks only between steps */
  .runbook-step {
    break-inside: avoid;
    page-break-inside: avoid;
    border: 1px solid #ccc;
    border-left: 3pt solid #1a56c4;
    border-radius: 0;
    margin-bottom: 14pt;
    background: #fff;
  }

  .step-header {
    background: #f5f5f5;
    border-bottom: 1px solid #ddd;
    padding: 7pt 12pt;
    display: flex;
    align-items: baseline;
    gap: 10pt;
  }

  .step-number {
    font-size: 8pt;
    font-weight: 700;
    color: #1a56c4;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
  }

  .step-title {
    font-size: 11pt;
    font-weight: 600;
    color: #111;
  }

  .step-desc {
    font-size: 10pt;
    color: #444;
    padding: 8pt 12pt 0;
  }

  /* Code blocks — keep monospace, light background, full width */
  .code-block {
    margin: 8pt 12pt 10pt;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 0;
    overflow: visible;
  }

  .code-block pre {
    padding: 8pt 10pt;
    white-space: pre-wrap;
    word-break: break-all;
  }

  .code-block code {
    font-family: "Courier New", Courier, monospace;
    font-size: 8.5pt;
    line-height: 1.55;
    color: #111;
    background: none;
    border: none;
    padding: 0;
  }

  /* Inline code */
  code {
    font-family: "Courier New", Courier, monospace;
    font-size: 9pt;
    background: #f0f0f0;
    border: 1px solid #ddd;
    padding: 0 3pt;
    color: #111;
  }

  /* Links — show URL after domain links */
  a[href^="https://"]::after {
    content: " (" attr(href) ")";
    font-size: 8pt;
    color: #666;
  }

  /* But not for button-style or nav links */
  .btn::after,
  .back-link::after { content: none; }
}
