:root {
  --red: #e11b2e; --red-dark: #b8121f; --bg: #f4f5f7; --card: #fff;
  --ink: #1c2430; --mut: #6b7686; --line: #e3e7ee; --ok: #1a9e4b; --warn: #d97706;
}
* { box-sizing: border-box; margin: 0; }
body { font: 14px/1.45 -apple-system, "Segoe UI", Roboto, Arial, sans-serif; background: var(--bg); color: var(--ink); }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 7px; padding: 7px 10px; }
input:focus, select:focus, textarea:focus { outline: 2px solid #e11b2e33; border-color: var(--red); }

#layout { display: flex; min-height: 100vh; }
#sidebar { width: 212px; background: #171c26; color: #cfd6e2; padding: 14px 10px; flex-shrink: 0;
  display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; }
#sidebar .logo { color: #fff; font-weight: 800; font-size: 16px; padding: 6px 10px 14px; letter-spacing: .3px; }
#sidebar .logo span { color: var(--red); }
#sidebar a { display: flex; gap: 9px; align-items: center; color: inherit; text-decoration: none;
  padding: 8px 10px; border-radius: 8px; font-weight: 500; }
#sidebar a:hover { background: #232b3a; color: #fff; }
#sidebar a.active { background: var(--red); color: #fff; }
#sidebar .sp { flex: 1; }
#sidebar .whoami { font-size: 12px; color: #8a94a6; padding: 8px 10px; border-top: 1px solid #2a3140; }
#sidebar .whoami b { color: #cfd6e2; display: block; }

#main { flex: 1; min-width: 0; }
#topbar { background: var(--card); border-bottom: 1px solid var(--line); padding: 10px 22px;
  display: flex; align-items: center; gap: 14px; position: sticky; top: 0; z-index: 30; }
#topbar h1 { font-size: 17px; flex: 1; }
#haltbar { display: none; background: #b8121f; color: #fff; padding: 10px 22px; font-weight: 600; white-space: pre-line; }
#haltbar a { color: #ffd; }
#content { padding: 20px 22px 60px; max-width: 1200px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; margin-bottom: 16px; }
.card h2 { font-size: 15px; margin-bottom: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.head { margin-bottom: 12px; }
.grow { flex: 1; }
.mut { color: var(--mut); font-size: 12.5px; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; color: var(--mut); font-size: 12px; text-transform: uppercase; letter-spacing: .4px;
  padding: 7px 9px; border-bottom: 2px solid var(--line); white-space: nowrap; }
td { padding: 8px 9px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.click:hover { background: #f8fafc; cursor: pointer; }
.tablewrap { overflow-x: auto; }

.btn { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 7px 13px; font-weight: 600; }
.btn:hover { border-color: #b9c2cf; background: #f8fafc; }
.btn.red { background: var(--red); border-color: var(--red); color: #fff; }
.btn.red:hover { background: var(--red-dark); }
.btn.ghost { border: none; background: none; color: var(--red); padding: 4px 6px; }
.btn.sm { padding: 4px 9px; font-size: 12.5px; border-radius: 6px; }
.btn:disabled { opacity: .5; cursor: default; }

.chip { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; background: #eef1f5; color: var(--mut); }
.chip.ok { background: #e3f6ea; color: var(--ok); }
.chip.bad { background: #fde8ea; color: var(--red); }
.chip.warn { background: #fef3e2; color: var(--warn); }
.chip.blue { background: #e7effd; color: #2b62c9; }

.score { font-weight: 800; }
.score.low { color: var(--red); } .score.mid { color: var(--warn); } .score.high { color: var(--ok); }

#login { position: fixed; inset: 0; background: #171c26; display: none; align-items: center; justify-content: center; z-index: 100; }
#login .box { background: #fff; border-radius: 14px; padding: 30px 32px; width: 330px; }
#login h1 { font-size: 19px; margin-bottom: 4px; } #login .box .mut { margin-bottom: 16px; }
#login input { width: 100%; margin-bottom: 10px; }
#login button { width: 100%; }
#login .err { color: var(--red); font-size: 13px; margin-top: 8px; min-height: 17px; }

#drawer { position: fixed; top: 0; right: -560px; width: 540px; max-width: 94vw; height: 100vh; background: #fff;
  box-shadow: -12px 0 40px rgba(10,15,25,.18); transition: right .2s; z-index: 60; display: flex; flex-direction: column; }
#drawer.open { right: 0; }
#drawer .dhead { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
#drawer .dbody { padding: 16px 18px; overflow-y: auto; flex: 1; }
#drawer pre { white-space: pre-wrap; background: #f6f8fa; border: 1px solid var(--line); border-radius: 8px;
  padding: 12px; font-size: 12.8px; font-family: inherit; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 5px 12px; font-size: 13.5px; margin-bottom: 14px; }
.kv .k { color: var(--mut); }

.hgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 6px 0 14px; }
.hcell { border: 1px solid var(--line); border-radius: 10px; padding: 12px; text-align: center; }
.hcell .lab { font-size: 12px; color: var(--mut); text-transform: uppercase; letter-spacing: .4px; }
.hcell .val { font-size: 21px; font-weight: 800; margin-top: 3px; }
.hcell.ok .val { color: var(--ok); } .hcell.bad .val { color: var(--red); } .hcell.na .val { color: var(--mut); }

.formgrid { display: grid; grid-template-columns: 160px 1fr; gap: 10px 14px; align-items: center; max-width: 640px; }
.formgrid label { color: var(--mut); font-size: 13px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #1c2430; color: #fff;
  padding: 11px 20px; border-radius: 10px; z-index: 200; display: none; max-width: 80vw; white-space: pre-line; }
.pill-toggle { display: flex; gap: 8px; align-items: center; background: #f6f8fa; border: 1px solid var(--line);
  border-radius: 9px; padding: 9px 12px; }
audio { width: 100%; margin: 8px 0; }
.progress { height: 7px; background: #eef1f5; border-radius: 5px; overflow: hidden; min-width: 110px; }
.progress i { display: block; height: 100%; background: var(--ok); }
