* { box-sizing: border-box; }
body {
  margin: 0; background: #f4f6f9; color: #1e293b;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #eef1f6; padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }

.topbar {
  display: flex; align-items: center; gap: 24px;
  background: #0f172a; color: #e2e8f0; padding: 0 20px; height: 52px;
}
.topbar .brand { color: #fff; font-weight: 700; font-size: 16px; }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a { color: #94a3b8; padding: 6px 12px; border-radius: 6px; }
.topbar nav a.active, .topbar nav a:hover { color: #fff; background: #1e293b; text-decoration: none; }
.logout { margin: 0; }

main { max-width: 1200px; margin: 0 auto; padding: 24px 20px 60px; }
.foot { text-align: center; color: #94a3b8; font-size: 12px; padding: 20px; }

.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.page-head h1 { font-size: 20px; margin: 0; }
.page-head-inline { display: flex; align-items: center; justify-content: space-between; }
.count { color: #64748b; font-size: 14px; font-weight: 400; margin-left: 8px; }
.head-actions { display: flex; gap: 8px; align-items: center; }
.head-actions form { margin: 0; display: flex; gap: 6px; }

.card { background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; padding: 18px 20px; margin-bottom: 18px; }
.card h2 { font-size: 15px; margin: 0 0 12px; }
.card h3 { font-size: 13px; margin: 12px 0 6px; color: #475569; }
.card.narrow { max-width: 720px; }
.card.empty { text-align: center; color: #64748b; }
.danger-zone { border-color: #fecaca; }

.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; color: #64748b; padding: 6px 10px; border-bottom: 2px solid #e2e8f0; }
.tbl td { padding: 8px 10px; border-bottom: 1px solid #eef1f6; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.srv-link { font-weight: 600; }
.dim { color: #64748b; font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.row-actions { display: flex; gap: 6px; }
.row-actions form { margin: 0; }

.chip {
  display: inline-block; padding: 1px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px;
}
.chip-ok { background: #dcfce7; color: #15803d; }
.chip-warning { background: #fef3c7; color: #b45309; }
.chip-critical { background: #fee2e2; color: #b91c1c; }
.chip-stale { background: #ede9fe; color: #6d28d9; }
.chip-pending, .chip-muted, .chip-disabled { background: #e2e8f0; color: #475569; }
.chip-tag { background: #e0e7ff; color: #4338ca; text-transform: none; font-weight: 500; margin-left: 4px; }
a.chip-tag:hover { background: #c7d2fe; text-decoration: none; }

.tag-bar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.tag-link {
  padding: 3px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  background: #fff; border: 1px solid #cbd5e1; color: #475569;
}
.tag-link:hover { background: #f1f5f9; text-decoration: none; }
.tag-link.active { background: #2563eb; border-color: #2563eb; color: #fff; }
.txt-critical { color: #b91c1c; font-weight: 700; }
.txt-warning { color: #b45309; font-weight: 600; }

.bar { background: #eef1f6; border-radius: 4px; height: 8px; width: 110px; display: inline-block; vertical-align: middle; overflow: hidden; }
.bar.wide { width: 100%; height: 10px; display: block; margin: 6px 0; }
.bar-fill { height: 100%; border-radius: 4px; }
.fill-ok { background: #22c55e; }
.fill-warning { background: #f59e0b; }
.fill-critical { background: #ef4444; }
.bar-label { margin-left: 8px; font-size: 12.5px; }

.alert-line { padding: 8px 0; border-bottom: 1px solid #eef1f6; }
.alert-line:last-of-type { border-bottom: none; }
.alert-msg { color: #475569; font-size: 13px; white-space: pre-line; margin: 4px 0 0 4px; }
.alert-msg-cell { max-width: 420px; font-size: 12.5px; color: #475569; }
.alert-count { background: #fee2e2; color: #b91c1c; font-weight: 700; padding: 2px 9px; border-radius: 999px; }

.meta-row { display: flex; gap: 22px; flex-wrap: wrap; color: #475569; margin-bottom: 16px; font-size: 13px; }

.btn {
  display: inline-block; border: 1px solid #cbd5e1; background: #fff; color: #1e293b;
  padding: 6px 14px; border-radius: 7px; font-size: 13.5px; cursor: pointer; font-family: inherit;
}
.btn:hover { background: #f1f5f9; text-decoration: none; }
.btn-primary { background: #2563eb; border-color: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-danger { border-color: #fca5a5; color: #b91c1c; }
.btn-danger:hover { background: #fef2f2; }
.btn-ghost { background: transparent; border-color: #334155; color: #94a3b8; }
.btn-ghost:hover { background: #1e293b; color: #fff; }
.btn-sm { padding: 3px 10px; font-size: 12.5px; }
.range-btn.active { background: #2563eb; border-color: #2563eb; color: #fff; }

form label { display: block; margin: 10px 0; font-weight: 600; font-size: 13px; }
form label input, form label select {
  display: block; width: 100%; margin-top: 4px; padding: 7px 10px;
  border: 1px solid #cbd5e1; border-radius: 7px; font: inherit; font-weight: 400;
}
label.inline { display: inline-flex; align-items: center; gap: 6px; margin: 4px 14px 4px 0; font-weight: 500; }
label.inline input { width: auto; margin: 0; }
.inline-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.inline-form input, .inline-form select { width: auto; padding: 5px 8px; border: 1px solid #cbd5e1; border-radius: 6px; font: inherit; }
fieldset { border: 1px solid #e2e8f0; border-radius: 8px; margin: 14px 0; padding: 10px 14px; }
legend { font-size: 12.5px; font-weight: 700; color: #475569; padding: 0 6px; }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 4px 14px; }
.grid-4 label { margin: 4px 0; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .split, .charts { grid-template-columns: 1fr; } }

.sub { margin-top: 12px; }
.sub summary { cursor: pointer; color: #475569; font-size: 13px; }

.token-box, .code-box {
  background: #0f172a; color: #a5f3fc; padding: 12px 14px; border-radius: 8px;
  overflow-x: auto; font-size: 13px; user-select: all; white-space: pre-wrap; word-break: break-all;
}

/* ---- Print / save-as-PDF ---- */
@media print {
  .topbar, .foot, .no-print, .head-actions, .range-picker, .tag-bar,
  .inline-form, .cfg-form, .danger-zone, .sub, .row-actions,
  button, select, input[type="checkbox"] { display: none !important; }
  body { background: #fff; font-size: 11px; }
  main { max-width: none; padding: 0; }
  .card { border: 1px solid #ddd; box-shadow: none; break-inside: avoid; margin-bottom: 10px; }
  .charts { grid-template-columns: 1fr 1fr; }
  a { color: inherit; text-decoration: none; }
  .chip, .bar-fill { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-title { display: block !important; font-size: 15px; font-weight: 700; margin-bottom: 10px; }
}
.print-title { display: none; }

.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: #0f172a; }
.login-card { background: #fff; padding: 32px 36px; border-radius: 12px; width: 340px; }
.login-card h1 { font-size: 20px; text-align: center; margin: 0 0 18px; }
.login-error { background: #fee2e2; color: #b91c1c; padding: 8px 12px; border-radius: 7px; font-size: 13px; }
.login-card .btn { width: 100%; margin-top: 12px; padding: 9px; }
