/* ============================================================
   RB Health Check — design system
   Mobile-first, self-contained (Inter self-hosted, SVG icons).
   ============================================================ */
@import url("/static/fonts.css");

:root {
  --navy-900: #0e2233;
  --navy-800: #14314a;
  --navy-700: #1d4260;
  --steel: #28536b;
  --accent: #2fa4e7;
  --accent-soft: #d9effc;
  --ink: #1a2b3c;
  --muted: #5d7286;
  --faint: #8fa1b3;
  --ok: #15803d;      --ok-bg: #e3f6ea;
  --warn: #b45309;    --warn-bg: #fdf0d3;
  --crit: #b91c1c;    --crit-bg: #fde5e5;
  --bg: #edf1f6;
  --card: #ffffff;
  --line: #e1e8ef;
  --shadow: 0 1px 2px rgba(14, 34, 51, .05), 0 6px 20px -6px rgba(14, 34, 51, .08);
  --shadow-lg: 0 4px 8px rgba(14, 34, 51, .06), 0 16px 36px -8px rgba(14, 34, 51, .14);
  --r: 14px;
  --r-sm: 10px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15.5px/1.5 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-feature-settings: "cv05", "tnum";
  padding-bottom: 84px;
}
a { color: var(--steel); text-decoration: none; }
p a, td a, .muted a { text-decoration: underline; text-decoration-color: rgba(40,83,107,.3); text-underline-offset: 2px; }
a:hover { text-decoration-color: currentColor; }

.ic { width: 18px; height: 18px; vertical-align: -3.5px; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic.lg { width: 22px; height: 22px; }

/* ================= top bar ================= */
.topbar {
  background: linear-gradient(120deg, var(--navy-900), var(--navy-700));
  color: #fff; display: flex; align-items: center; gap: 14px;
  padding: 12px 18px; position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 12px rgba(14, 34, 51, .25);
}
.brandmark { width: 34px; height: 34px; border-radius: 9px; flex: none;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.18);
  display: grid; place-items: center; }
.brandmark svg { width: 20px; height: 20px; stroke: #6fd3ff; }
.topbar .brand { font-weight: 800; font-size: 16.5px; letter-spacing: -.01em;
  color: #fff; line-height: 1.15; }
.topbar .brand small { display: block; opacity: .62; font-weight: 500; font-size: 11.5px;
  letter-spacing: .02em; }
.topbar .spacer { flex: 1; }

.usermenu { position: relative; }
.usermenu > summary { list-style: none; cursor: pointer; display: flex; align-items: center;
  gap: 10px; padding: 4px 6px 4px 12px; border-radius: 999px;
  border: 1px solid rgba(255,255,255,.16); background: rgba(255,255,255,.06);
  transition: background .15s; }
.usermenu > summary::-webkit-details-marker { display: none; }
.usermenu > summary:hover { background: rgba(255,255,255,.13); }
.usermenu .uname { font-size: 13.5px; font-weight: 600; color: #e8eef4; white-space: nowrap; }
.usermenu .uname small { display: block; font-weight: 500; font-size: 10.5px; opacity: .6; }
.avatar { width: 32px; height: 32px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, var(--accent), #7fd4a8);
  color: #06202f; font-weight: 800; font-size: 14.5px;
  display: grid; place-items: center; }
.usermenu .menu { position: absolute; right: 0; top: calc(100% + 10px); min-width: 230px;
  background: #fff; color: var(--ink); border-radius: var(--r-sm);
  box-shadow: var(--shadow-lg); border: 1px solid var(--line); padding: 6px; z-index: 200; }
.usermenu .menu a, .usermenu .menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: none; border: 0; padding: 10px 12px; border-radius: 8px;
  font: inherit; font-size: 14px; font-weight: 600; color: var(--ink); cursor: pointer; }
.usermenu .menu a:hover, .usermenu .menu button:hover { background: var(--bg); text-decoration: none; }
.usermenu .menu .mhead { padding: 8px 12px 6px; font-size: 12px; color: var(--muted);
  border-bottom: 1px solid var(--line); margin-bottom: 4px; }

.viewas { background: linear-gradient(90deg, #8a3410, #b45309); color: #fff; text-align: center;
  font-size: 13.5px; font-weight: 600; padding: 8px 12px; }
.viewas form { display: inline; }
.viewas button { background: #fff; color: #8a3410; border: 0; border-radius: 999px;
  padding: 4px 14px; font: inherit; font-size: 13px; font-weight: 700; margin-left: 10px; cursor: pointer; }

/* ================= navigation ================= */
.nav { display: flex; gap: 4px; background: var(--navy-900); padding: 6px 12px;
  overflow-x: auto; scrollbar-width: none; position: sticky; top: 58px; z-index: 90; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: #b6c6d4; padding: 8px 15px; font-size: 13.5px; font-weight: 600;
  white-space: nowrap; border-radius: 999px; display: flex; align-items: center; gap: 7px;
  transition: background .15s, color .15s; }
.nav a .ic { width: 16px; height: 16px; }
.nav a:hover { color: #fff; background: rgba(255,255,255,.08); text-decoration: none; }
.nav a.active { color: #fff; background: rgba(111, 211, 255, .16); box-shadow: inset 0 0 0 1px rgba(111,211,255,.25); }

.bottomnav { display: none; }
@media (max-width: 760px) {
  .topbar { padding: 10px 14px; top: 0; }
  .topbar .brand { font-size: 15px; }
  .usermenu .uname { display: none; }
  .usermenu > summary { padding: 3px; border-radius: 50%; }
  .nav { display: none; }
  .bottomnav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
    background: rgba(14, 34, 51, .97); backdrop-filter: blur(10px);
    justify-content: space-around;
    padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid rgba(255,255,255,.08);
    box-shadow: 0 -4px 20px rgba(14,34,51,.25);
  }
  .bottomnav a { color: #93a8b8; font-size: 10.5px; font-weight: 600; text-align: center;
    flex: 1; padding: 3px 0; display: flex; flex-direction: column; align-items: center;
    gap: 3px; border-radius: 10px; transition: color .15s; }
  .bottomnav a .ic { width: 22px; height: 22px; }
  .bottomnav a.active { color: #6fd3ff; }
  .bottomnav a:active { transform: scale(.94); }
}

/* ================= layout ================= */
.wrap { max-width: 1120px; margin: 0 auto; padding: 22px 18px; }
@media (max-width: 760px) { .wrap { padding: 16px 14px; } }
h1 { font-size: 23px; font-weight: 800; letter-spacing: -.02em; margin: 4px 0 16px; }
h2 { font-size: 16.5px; font-weight: 700; letter-spacing: -.01em; margin: 26px 0 12px;
  color: var(--navy-800); display: flex; align-items: center; gap: 8px; }
h2 .ic { color: var(--faint); }
.pagehead { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.pagehead h1 { margin: 0; flex: 1; min-width: 200px; }

.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.cards2 { grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 18px 20px; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 10px; font-size: 14.5px; font-weight: 700; color: var(--navy-800);
  display: flex; align-items: center; gap: 8px; }
.card h3 .ic { color: var(--faint); }
a.card { display: block; transition: transform .16s, box-shadow .16s; }
a.card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-lg); }

/* ================= KPI tiles ================= */
.kpi { display: flex; align-items: center; gap: 13px; padding: 15px 16px;
  transition: transform .16s, box-shadow .16s; }
a.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); text-decoration: none; }
.kpi .bubble { width: 42px; height: 42px; border-radius: 12px; flex: none;
  display: grid; place-items: center; background: var(--accent-soft); color: var(--steel); }
.kpi .bubble .ic { width: 21px; height: 21px; }
.kpi .num { font-size: 25px; font-weight: 800; letter-spacing: -.03em; line-height: 1.05; }
.kpi .lbl { font-size: 12px; color: var(--muted); font-weight: 500; line-height: 1.3; margin-top: 1px; }
.kpi.ok .bubble { background: var(--ok-bg); color: var(--ok); }
.kpi.warn .bubble { background: var(--warn-bg); color: var(--warn); }
.kpi.warn .num { color: var(--warn); }
.kpi.crit .bubble { background: var(--crit-bg); color: var(--crit); }
.kpi.crit .num { color: var(--crit); }

/* ================= badges & bars ================= */
.badge { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px;
  padding: 3px 11px; font-size: 12px; font-weight: 700; line-height: 1.5; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.nodot::before { display: none; }
.b-ok { background: var(--ok-bg); color: var(--ok); }
.b-warn { background: var(--warn-bg); color: var(--warn); }
.b-crit { background: var(--crit-bg); color: var(--crit); }
.b-muted { background: #e8edf3; color: var(--muted); }
.b-steel { background: var(--accent-soft); color: var(--steel); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 7px;
  box-shadow: 0 0 0 3px rgba(0,0,0,.045); }
.d-ok { background: var(--ok); } .d-warn { background: var(--warn); } .d-crit { background: var(--crit); }

.healthbar { display: flex; height: 8px; border-radius: 999px; overflow: hidden;
  background: #e8edf3; margin: 12px 0 8px; }
.healthbar span { display: block; height: 100%; min-width: 0; transition: width .4s ease; }
.healthbar .h-ok { background: #22a55b; }
.healthbar .h-warn { background: #e9a23b; }
.healthbar .h-crit { background: #dc4a4a; }

/* ================= tables ================= */
.tablewrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); }
th { background: #f6f8fb; color: var(--muted); font-size: 11.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; white-space: nowrap;
  position: sticky; top: 0; z-index: 1; }
tbody tr, table tr { transition: background .12s; }
.tablewrap tr:hover td { background: #f6fafd; }
tr:last-child td { border-bottom: 0; }
tr.r-crit td { background: #fdf3f3; } tr.r-crit:hover td { background: #fbecec; }
tr.r-warn td { background: #fdf8ec; } tr.r-warn:hover td { background: #fbf3dd; }
.card table td, .card table tr:hover td { background: none; }
.card th, .card td { padding: 6px 10px 6px 0; border-bottom: 1px solid #eef2f6; }

/* ================= forms ================= */
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin: 12px 0 5px; }
input, select, textarea {
  width: 100%; padding: 10px 13px; border: 1.5px solid #cfd9e3; border-radius: var(--r-sm);
  font: inherit; font-size: 16px; background: #fff; color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 164, 231, .18); }
input[type=file] { padding: 9px; background: #f6f8fb; border-style: dashed; cursor: pointer; }
input[type=file]::file-selector-button {
  background: var(--navy-800); color: #fff; border: 0; border-radius: 8px;
  padding: 7px 14px; font: inherit; font-size: 13px; font-weight: 600; margin-right: 12px; cursor: pointer; }
select { appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%235d7286' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center; padding-right: 34px; }

/* ================= buttons ================= */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(180deg, var(--navy-700), var(--navy-800));
  color: #fff; border: 0; padding: 10px 18px; border-radius: var(--r-sm);
  font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; text-align: center;
  box-shadow: 0 1px 2px rgba(14,34,51,.2), inset 0 1px 0 rgba(255,255,255,.08);
  transition: transform .12s, box-shadow .15s, filter .15s; }
.btn:hover { filter: brightness(1.12); text-decoration: none; box-shadow: 0 3px 10px rgba(14,34,51,.25); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn:focus-visible { outline: 3px solid rgba(47,164,231,.4); outline-offset: 1px; }
.btn .ic { width: 16px; height: 16px; }
.btn.secondary { background: #fff; color: var(--navy-800); border: 1.5px solid #cfd9e3;
  box-shadow: 0 1px 2px rgba(14,34,51,.06); }
.btn.secondary:hover { background: #f6f8fb; filter: none; border-color: var(--faint); }
.btn.danger { background: linear-gradient(180deg, #d24343, #b91c1c); }
.btn.ok { background: linear-gradient(180deg, #1f9d50, #15803d); }
.btn.small { padding: 6px 13px; font-size: 12.5px; border-radius: 8px; }
.btn.small .ic { width: 14px; height: 14px; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
form.inline { display: inline; }

.row { display: flex; gap: 14px; flex-wrap: wrap; align-items: end; }
.row > div { flex: 1; min-width: 150px; }

/* ================= alerts & toasts ================= */
.alert { border-radius: var(--r-sm); padding: 11px 15px; margin: 10px 0; font-size: 14px;
  font-weight: 500; display: flex; gap: 9px; align-items: flex-start; }
.alert .ic { margin-top: 2px; }
.alert.info { background: var(--accent-soft); color: #14536f; }
.alert.err { background: var(--crit-bg); color: var(--crit); }
.alert.ok { background: var(--ok-bg); color: var(--ok); }

#toasts { position: fixed; top: 14px; right: 14px; left: 14px; z-index: 500;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast { pointer-events: auto; max-width: 420px; background: var(--navy-900); color: #fff;
  border-radius: 12px; padding: 12px 18px; font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow-lg); display: flex; gap: 10px; align-items: center;
  animation: toastin .25s ease; }
.toast.err { background: #7f1d1d; }
.toast.ok { background: #14532d; }
@keyframes toastin { from { opacity: 0; transform: translateY(-8px); } }
.toast.out { opacity: 0; transform: translateY(-8px); transition: all .3s; }

.muted { color: var(--muted); font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }

/* ================= dashboard section strip ================= */
.secstrip { display: flex; gap: 8px; }
.secstrip a { flex: 1; text-align: center; padding: 12px 4px 10px; border-radius: 12px;
  font-weight: 800; color: #fff; font-size: 15.5px; position: relative; overflow: hidden;
  box-shadow: var(--shadow); transition: transform .16s, box-shadow .16s; }
.secstrip a:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.secstrip a small { display: block; font-weight: 600; font-size: 10px; opacity: .85; margin-top: 2px;
  letter-spacing: .01em; }
.sec-ok { background: linear-gradient(160deg, #22a55b, #15803d); }
.sec-warning { background: linear-gradient(160deg, #e9a23b, #b45309); }
.sec-critical { background: linear-gradient(160deg, #dc4a4a, #b91c1c); }

/* ================= login ================= */
body.authpage { background: radial-gradient(1100px 500px at 20% -10%, #1d4260 0%, var(--navy-900) 55%) fixed; padding-bottom: 0; }
.loginbox { max-width: 400px; margin: 9vh auto 40px; padding: 0 16px; }
.loginbox .authbrand { display: flex; align-items: center; gap: 13px; color: #fff; margin-bottom: 22px; }
.loginbox .authbrand .brandmark { width: 46px; height: 46px; border-radius: 13px; }
.loginbox .authbrand .brandmark svg { width: 26px; height: 26px; }
.loginbox .authbrand b { font-size: 21px; letter-spacing: -.02em; display: block; }
.loginbox .authbrand small { opacity: .65; font-size: 13px; }
.loginbox .card { padding: 26px; border: 0; box-shadow: var(--shadow-lg); }
.loginbox .foot { color: rgba(255,255,255,.55); text-align: center; font-size: 13px; margin-top: 18px; }

/* ================= task workflow ================= */
.steps { display: flex; gap: 0; margin: 6px 0 2px; }
.step { flex: 1; text-align: center; font-size: 11.5px; font-weight: 700; color: var(--faint);
  position: relative; padding-top: 26px; }
.step::before { content: ""; position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 2.5px solid #cfd9e3; z-index: 1; }
.step::after { content: ""; position: absolute; top: 16px; left: -50%; width: 100%; height: 2.5px;
  background: #cfd9e3; }
.step:first-child::after { display: none; }
.step.done { color: var(--ok); }
.step.done::before { background: var(--ok); border-color: var(--ok);
  box-shadow: inset 0 0 0 3px #fff; }
.step.done::after { background: var(--ok); }
.step.now { color: var(--navy-800); }
.step.now::before { border-color: var(--accent); background: var(--accent-soft); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 10px 0 12px 26px; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 17px; width: 9px; height: 9px;
  border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.timeline li:not(:last-child)::after { content: ""; position: absolute; left: 9px; top: 30px;
  bottom: -8px; width: 1.5px; background: var(--line); }
.timeline li .when { font-size: 12px; color: var(--faint); font-weight: 500; }
.timeline img { max-width: 250px; width: 100%; border-radius: var(--r-sm); margin-top: 8px;
  box-shadow: var(--shadow); }

/* ================= misc ================= */
#map { width: 100%; height: calc(100vh - 240px); min-height: 400px; border-radius: var(--r);
  box-shadow: var(--shadow); }
@media (max-width: 760px) { #map { height: calc(100vh - 230px); } }

.filters { display: flex; gap: 9px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filters select, .filters input { width: auto; min-width: 130px; font-size: 14px; padding: 8px 12px; }
.filters input[type=text], .filters input:not([type]) { min-width: 200px; }
@media (max-width: 760px) {
  .filters select, .filters input { flex: 1; min-width: 46%; }
}

.chartbox { position: relative; height: 250px; }
.chartbox.tall { height: 440px; }
@media (max-width: 760px) { .chartbox.tall { height: 380px; } }

.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty .ic { width: 38px; height: 38px; color: #c3cfda; margin-bottom: 8px; stroke-width: 1.5; }

.qrimg { background: #fff; border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 10px; box-shadow: var(--shadow); }

/* ---- multi-select dropdown ---- */
.msel { position: relative; }
.msel > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center;
  gap: 7px; padding: 8px 13px; border: 1.5px solid #cfd9e3; border-radius: var(--r-sm);
  background: #fff; font-size: 14px; font-weight: 600; color: var(--ink);
  white-space: nowrap; user-select: none; transition: border-color .15s; }
.msel > summary::-webkit-details-marker { display: none; }
.msel > summary::after { content: ""; width: 8px; height: 8px; flex: none;
  border-right: 2px solid var(--faint); border-bottom: 2px solid var(--faint);
  transform: rotate(45deg) translateY(-2px); }
.msel[open] > summary { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,164,231,.18); }
.msel .count { background: var(--navy-800); color: #fff; border-radius: 999px;
  font-size: 11px; padding: 1px 8px; display: none; }
.msel .count.on { display: inline-block; }
.msel .opts { position: absolute; top: calc(100% + 6px); left: 0; z-index: 300;
  min-width: 230px; max-height: 300px; overflow-y: auto; background: #fff;
  border: 1px solid var(--line); border-radius: var(--r-sm); box-shadow: var(--shadow-lg);
  padding: 6px; }
.msel .opts label { display: flex; align-items: center; gap: 9px; margin: 0;
  padding: 8px 10px; border-radius: 7px; font-size: 13.5px; font-weight: 500;
  color: var(--ink); text-transform: none; letter-spacing: 0; cursor: pointer; }
.msel .opts label:hover { background: var(--bg); }
.msel .opts input[type=checkbox] { width: 17px; height: 17px; flex: none; }
.msel .opts .clearall { border-top: 1px solid var(--line); margin-top: 4px;
  color: var(--steel); font-weight: 600; justify-content: center; }
@media (max-width: 760px) { .msel .opts { position: fixed; left: 12px; right: 12px; min-width: 0; } }

/* ---- manual (rendered markdown) ---- */
.mdbody h1 { font-size: 26px; margin: 8px 0 4px; color: var(--navy-800); }
.mdbody h2 { font-size: 19px; margin: 28px 0 10px; padding-bottom: 6px;
  border-bottom: 1px solid var(--line); display: block; }
.mdbody h3 { font-size: 15.5px; margin: 18px 0 8px; color: var(--navy-800); }
.mdbody p, .mdbody li { line-height: 1.65; }
.mdbody ul { padding-left: 22px; }
.mdbody li { margin: 4px 0; }
.mdbody hr { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }
.mdbody table { font-size: 14px; margin: 12px 0; }
.mdbody th, .mdbody td { border: 1px solid var(--line); padding: 8px 12px; }
.mdbody th { background: #f6f8fb; position: static; }
.mdbody code { background: #eef2f6; border-radius: 5px; padding: 1px 6px;
  font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
.mdbody blockquote { border-left: 3px solid var(--accent); margin: 10px 0;
  padding: 4px 14px; color: var(--muted); }

@media print {
  .topbar, .nav, .bottomnav, .viewas, .btn, form, #toasts { display: none !important; }
  body { background: #fff; padding: 0; }
  .card, .tablewrap { box-shadow: none; }
}
