:root {
  --bg: #f3f5f9; --panel: #ffffff; --line: #e1e5ec; --text: #1f2933; --muted: #6b7684;
  --brand: #1f4e78; --brand-2: #2b6cb0; --accent: #3182ce;
  --ok-bg: #e6f6ec; --ok-fg: #1e7b3a; --warn-bg: #fff4d6; --warn-fg: #9a6400; --bad-bg: #fde8e8; --bad-fg: #b42318; --unk-bg: #eef0f3; --unk-fg: #5a6470; --info-bg: #e8f1fb; --info-fg: #1d5fa3;
  --radius: 10px; --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: "Segoe UI", "Leelawadee UI", Tahoma, sans-serif; font-size: 14px; color: var(--text); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
.app { display: flex; min-height: 100vh; }
.sidebar { width: 250px; background: var(--brand); color: #fff; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; gap: 10px; align-items: center; padding: 18px 16px 12px; border-bottom: 1px solid rgba(255,255,255,.15); }
.logo { font-size: 28px; }
.brand-name { font-weight: 700; font-size: 17px; }
.brand-sub { font-size: 11px; opacity: .8; }
nav { display: flex; flex-direction: column; padding: 10px 8px; gap: 2px; }
nav a { color: #e6eef8; padding: 10px 12px; border-radius: 8px; display: block; }
nav a:hover { background: rgba(255,255,255,.1); }
nav a.active { background: #fff; color: var(--brand); font-weight: 600; }
.sidebar-foot { margin-top: auto; padding: 12px 10px 16px; display: flex; flex-direction: column; gap: 8px; border-top: 1px solid rgba(255,255,255,.15); }
main { flex: 1; padding: 22px 26px 40px; min-width: 0; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 22px 0 10px; }
h3 { font-size: 14px; margin: 0 0 8px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.loading { padding: 40px; text-align: center; color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.card .label { color: var(--muted); font-size: 12px; }
.card .value { font-size: 28px; font-weight: 700; margin-top: 4px; line-height: 1.1; }
.card .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.card.bad .value { color: var(--bad-fg); } .card.warn .value { color: var(--warn-fg); } .card.ok .value { color: var(--ok-fg); } .card.info .value { color: var(--info-fg); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); margin-bottom: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #f7f9fc; color: #3c4858; font-weight: 600; position: sticky; top: 0; z-index: 1; white-space: nowrap; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: #f4f8fd; }
td.num, th.num { text-align: right; white-space: nowrap; }
.table-wrap { overflow: auto; max-height: 70vh; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.lv2 { background: var(--bad-bg); color: var(--bad-fg); } .lv1 { background: var(--warn-bg); color: var(--warn-fg); } .lv0 { background: var(--ok-bg); color: var(--ok-fg); } .lvu { background: var(--unk-bg); color: var(--unk-fg); } .lvi { background: var(--info-bg); color: var(--info-fg); }
.pill { display: inline-block; padding: 1px 7px; border-radius: 6px; background: #eef0f3; font-size: 12px; margin-right: 4px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.toolbar input[type=text], .toolbar select, .form input[type=text], .form input[type=number], .form select, .form textarea, .inline-input { padding: 7px 9px; border: 1px solid #cfd6df; border-radius: 7px; font: inherit; background: #fff; }
.toolbar input[type=text] { min-width: 240px; }
.form { display: grid; grid-template-columns: 160px 1fr; gap: 8px 12px; align-items: center; max-width: 720px; }
.form textarea { min-height: 70px; resize: vertical; }
.btn { display: inline-block; padding: 7px 13px; border-radius: 7px; border: 1px solid transparent; background: var(--accent); color: #fff; font: inherit; cursor: pointer; text-align: center; }
.btn:hover { filter: brightness(.95); }
.btn-ghost { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.25); }
.btn-light { background: #fff; color: var(--text); border-color: #cfd6df; }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn-danger { background: var(--bad-fg); }
.inline-input { width: 90px; }
.inline-text { width: 100%; min-width: 160px; }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 4px 10px; font-size: 13px; }
.kv .k { color: var(--muted); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 14px 0 10px; }
.tabs button { background: none; border: none; padding: 9px 14px; font: inherit; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.note { white-space: pre-wrap; word-break: break-word; }
.ellipsis { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
details summary { cursor: pointer; color: var(--accent); }
.toast { position: fixed; right: 20px; bottom: 20px; background: #1f2933; color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow); z-index: 50; }
.toast.err { background: var(--bad-fg); }
.stale { color: var(--bad-fg); font-weight: 600; }
.checkbox-cell { text-align: center; }
code { background: #eef0f3; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
pre.code { background: #1f2933; color: #e6eef8; padding: 12px; border-radius: 8px; overflow: auto; font-size: 12px; }
.legend span { margin-right: 10px; }
.bar { height: 8px; background: #eef0f3; border-radius: 4px; overflow: hidden; display: flex; }
.bar i { display: block; height: 100%; }
.bar .b2 { background: #e05252; } .bar .b1 { background: #f0b429; } .bar .b0 { background: #3f9d5a; }
.login-wrap { position: fixed; inset: 0; background: linear-gradient(135deg, #1f4e78 0%, #2b6cb0 100%); display: flex; align-items: center; justify-content: center; z-index: 100; }
.login-wrap[hidden], .toast[hidden], [hidden] { display: none !important; }
.login-card { background: #fff; padding: 28px 32px 24px; border-radius: 14px; width: 380px; max-width: 92vw; box-shadow: 0 10px 40px rgba(0,0,0,.25); display: flex; flex-direction: column; gap: 12px; }
.login-brand { display: flex; gap: 10px; align-items: center; color: var(--brand); }
.login-card h2 { margin: 6px 0 2px; font-size: 18px; }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.login-card input { padding: 9px 10px; border: 1px solid #cfd6df; border-radius: 7px; font: inherit; font-size: 14px; color: var(--text); }
.login-card .btn { padding: 10px; font-size: 15px; margin-top: 4px; }
.login-err { color: var(--bad-fg); font-size: 13px; background: var(--bad-bg); padding: 6px 10px; border-radius: 6px; }
#userBox { color: #e6eef8; }
#userBox a { color: #fff; text-decoration: underline; }
@media (max-width: 900px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-foot { flex-direction: row; flex-wrap: wrap; }
  main { padding: 14px; }
  .form { grid-template-columns: 1fr; }
}
