:root {
  --paper: #eef1f4;
  --panel: #ffffff;
  --ink: #18202b;
  --muted: #5b6675;
  --faint: #8a94a2;
  --rule: #d6dce3;
  --rule-soft: #e6eaef;
  --live: #0e7c66;
  --live-bg: #e3f3ee;
  --dead: #b4bcc6;
  --risk: #c2410c;
  --risk-bg: #fdeee6;
  --warn: #a16207;
  --warn-bg: #fbf3dc;
  --wait: #dde2e8;
  --act: #2f5bea;
  --act-ink: #ffffff;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --r: 6px;
}
* { box-sizing: border-box; }
html { background: var(--paper); color: var(--ink); }
body { margin: 0; font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--act); outline-offset: 2px; }
a { color: var(--act); }

.top { display: flex; align-items: baseline; gap: 18px; padding: 18px 32px 0; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 16px; }
.brand svg { color: var(--live); align-self: center; }
.brand b { font-weight: 700; color: var(--live); }
.tagline { color: var(--muted); font-size: 13.5px; }

main { max-width: 1440px; margin: 0 auto; padding: 0 32px 64px; }

/* ---------- search */
.search { padding: 44px 0 26px; }
.query { display: flex; gap: 10px; align-items: stretch; max-width: 860px; }
.query input {
  flex: 1; min-width: 0; font: 500 clamp(24px, 3.4vw, 38px)/1.1 var(--mono); letter-spacing: -0.02em;
  padding: 14px 18px; background: var(--panel); border: 1.5px solid var(--rule); border-radius: var(--r);
}
.query input:focus { border-color: var(--act); outline: none; box-shadow: 0 0 0 3px rgba(47, 91, 234, .15); }
button { cursor: pointer; border: 0; border-radius: var(--r); background: var(--act); color: var(--act-ink); padding: 0 26px; font-weight: 600; }
button:disabled { opacity: .5; cursor: progress; }
button.ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--rule); }
button.ghost:hover { border-color: var(--faint); }
button.small { padding: 5px 12px; font-size: 13px; font-weight: 500; }
.opts { margin-top: 12px; color: var(--muted); font-size: 14px; max-width: 860px; }
.opts summary { cursor: pointer; width: max-content; }
.opts-grid { display: flex; flex-wrap: wrap; gap: 10px 26px; padding: 12px 0 4px; }
.opts-grid label { display: flex; align-items: center; gap: 7px; }
.opts-grid input[type=number] { width: 72px; padding: 3px 6px; border: 1px solid var(--rule); border-radius: 4px; background: var(--panel); }

/* ---------- board / field */
.board { background: var(--panel); border: 1px solid var(--rule); border-radius: 10px; padding: 22px 24px 18px; }
.board-head { display: flex; justify-content: space-between; align-items: baseline; gap: 20px; flex-wrap: wrap; }
.board h1 { margin: 0; font: 600 22px/1.2 var(--mono); letter-spacing: -0.01em; }
.counts { display: flex; gap: 22px; flex-wrap: wrap; font-size: 14px; color: var(--muted); }
.counts b { font: 600 20px/1 var(--mono); color: var(--ink); margin-right: 5px; }
.counts .k-live b { color: var(--live); }
.counts .k-risk b { color: var(--risk); }

.field { display: flex; flex-wrap: wrap; gap: 3px; margin: 18px 0 10px; max-height: 260px; overflow: auto; }
.field i { width: 11px; height: 11px; border-radius: 2px; background: var(--wait); cursor: pointer; }
.field.big i { width: 7px; height: 7px; gap: 2px; border-radius: 1px; }
.field i.live { background: var(--live); }
.field i.dead { background: var(--dead); opacity: .55; }
.field i.risk { background: var(--risk); }
.field i.err { background: var(--warn); }
.field i.probing { background: var(--act); animation: pulse .9s ease-in-out infinite; }
.field i:hover { outline: 2px solid var(--ink); outline-offset: 1px; }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .field i.probing { animation: none; } }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 12.5px; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend .c { display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: var(--wait); }
.legend .c.live { background: var(--live); } .legend .c.dead { background: var(--dead); }
.legend .c.risk { background: var(--risk); } .legend .c.probing { background: var(--act); }
.progress { height: 3px; background: var(--rule-soft); border-radius: 2px; margin: 14px 0 10px; overflow: hidden; }
.progress div { height: 100%; width: 0; background: var(--live); transition: width .3s; }
.log { list-style: none; margin: 0; padding: 0; font: 12.5px/1.55 var(--mono); color: var(--muted); max-height: 92px; overflow: auto; }
.log li.err { color: var(--risk); }
.log li.ok { color: var(--live); }

/* ---------- tabs */
.tabs { display: flex; gap: 4px; align-items: center; margin: 28px 0 0; border-bottom: 1.5px solid var(--rule); flex-wrap: wrap; }
.tabs > button[data-tab] { background: none; color: var(--muted); padding: 10px 16px; border-radius: 0; font-weight: 500; border-bottom: 2.5px solid transparent; margin-bottom: -1.5px; }
.tabs > button[data-tab].on { color: var(--ink); border-bottom-color: var(--ink); font-weight: 600; }
.tabs .spacer { flex: 1; }
.tabs .ghost { margin-left: 4px; }
.tab { padding-top: 18px; }

.toolbar { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar input[type=search] { flex: 1; min-width: 240px; max-width: 460px; padding: 8px 12px; border: 1.5px solid var(--rule); border-radius: var(--r); background: var(--panel); }
.seg { display: inline-flex; border: 1.5px solid var(--rule); border-radius: var(--r); overflow: hidden; background: var(--panel); }
.seg button { background: none; color: var(--muted); border-radius: 0; padding: 6px 13px; font-weight: 500; font-size: 13.5px; }
.seg button + button { border-left: 1px solid var(--rule); }
.seg button.on { background: var(--ink); color: #fff; }
.chk { display: flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--muted); }

/* ---------- table */
.table-wrap { background: var(--panel); border: 1px solid var(--rule); border-radius: 10px; overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th { text-align: left; font-weight: 600; font-size: 12.5px; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--rule); cursor: pointer; white-space: nowrap; user-select: none; position: sticky; top: 0; background: var(--panel); }
th.sorted::after { content: " ↓"; } th.sorted.asc::after { content: " ↑"; }
td { padding: 9px 12px; border-bottom: 1px solid var(--rule-soft); vertical-align: top; }
tr.row { cursor: pointer; }
tr.row:hover td { background: #f6f8fa; }
tr.row.open td { background: #f2f5f8; border-bottom-color: transparent; }
.w-st { width: 22px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--dead); margin-top: 5px; }
.dot.live { background: var(--live); } .dot.risk { background: var(--risk); } .dot.err { background: var(--warn); }
.mono { font-family: var(--mono); font-size: 12.8px; }
.host { font-family: var(--mono); font-weight: 500; word-break: break-all; }
.dim { color: var(--faint); }
.sub { display: block; color: var(--muted); font-size: 12px; }
.chip { display: inline-block; font: 500 11.5px/1 var(--mono); padding: 3px 6px; border-radius: 4px; background: var(--rule-soft); margin: 0 3px 3px 0; white-space: nowrap; }
.chip.hot { background: var(--risk-bg); color: var(--risk); }
.chip.web { background: #e7edfd; color: #2445b8; }
.tag { display: inline-block; font-size: 11.5px; padding: 2px 7px; border-radius: 10px; background: var(--rule-soft); color: var(--muted); margin: 2px 3px 0 0; }
.tag.risk { background: var(--risk-bg); color: var(--risk); font-weight: 600; }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.ok { background: var(--live-bg); color: var(--live); }
.code { font-family: var(--mono); font-size: 11.5px; padding: 1px 6px; border-radius: 4px; color: #fff; background: var(--muted); }
.code.s2 { background: var(--live); } .code.s3 { background: #6b7bb3; } .code.s4 { background: var(--warn); } .code.s5 { background: var(--risk); }
.title { max-width: 300px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.more { text-align: center; padding: 14px; }
.empty { padding: 30px; text-align: center; color: var(--muted); }

/* detail row */
tr.detail td { background: #f2f5f8; padding: 4px 16px 20px 46px; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px 32px; }
.detail-grid h4 { margin: 12px 0 6px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 3px 14px; font-size: 13px; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-family: var(--mono); font-size: 12.5px; word-break: break-all; }
.banner { font: 11.5px/1.45 var(--mono); background: var(--panel); border: 1px solid var(--rule-soft); border-radius: 4px; padding: 5px 8px; margin: 3px 0 6px; white-space: pre-wrap; word-break: break-all; color: var(--muted); }
.alert { border-left: 3px solid var(--risk); background: var(--risk-bg); padding: 9px 12px; border-radius: 0 4px 4px 0; margin: 10px 0 0; font-size: 13.5px; }
.alert.warn { border-color: var(--warn); background: var(--warn-bg); }
.alert.ok { border-color: var(--live); background: var(--live-bg); }

/* ---------- DNS / infra cards */
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 18px; }
.card { background: var(--panel); border: 1px solid var(--rule); border-radius: 10px; padding: 16px 18px 14px; min-width: 0; }
.card h3 { margin: 0 0 10px; font-size: 15px; font-weight: 600; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.card h3 small { font-weight: 400; color: var(--faint); font-size: 12.5px; }
.card.wide { grid-column: 1 / -1; }
.card table td, .card table th { padding: 6px 8px 6px 0; cursor: default; position: static; }
.txt { font: 12px/1.5 var(--mono); padding: 6px 0; border-bottom: 1px solid var(--rule-soft); word-break: break-all; }
.txt:last-child { border-bottom: 0; }
.checks { list-style: none; margin: 0; padding: 0; }
.checks li { display: grid; grid-template-columns: 22px 120px 1fr; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--rule-soft); font-size: 13.5px; align-items: baseline; }
.checks li:last-child { border-bottom: 0; }
.checks .ic { font-weight: 700; } .checks .ic.ok { color: var(--live); } .checks .ic.bad { color: var(--risk); } .checks .ic.meh { color: var(--warn); }
.checks .v { font-family: var(--mono); font-size: 12px; color: var(--muted); word-break: break-all; }
.bars { display: grid; grid-template-columns: minmax(120px, max-content) 1fr 44px; gap: 6px 12px; align-items: center; font-size: 13px; }
.bars .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 280px; }
.bars .bar { height: 10px; background: var(--rule-soft); border-radius: 2px; overflow: hidden; }
.bars .bar div { height: 100%; background: var(--ink); opacity: .78; }
.bars .n { font-family: var(--mono); text-align: right; color: var(--muted); }

.network { height: 680px; background: var(--panel); border: 1px solid var(--rule); border-radius: 10px; }
.hint { color: var(--muted); font-size: 13px; }

/* ---------- history */
.history { margin-top: 48px; }
.history h2 { font-size: 16px; font-weight: 600; margin: 0 0 10px; }
.hist-row { display: grid; grid-template-columns: 1fr auto auto auto; gap: 18px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--rule); font-size: 13.5px; }
.hist-row .host { cursor: pointer; color: var(--ink); }
.hist-row .host:hover { color: var(--act); }
.hist-row button { background: none; color: var(--faint); padding: 2px 6px; font-weight: 400; }
.hist-row button:hover { color: var(--risk); }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: var(--r); font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 720px) {
  main, .top { padding-left: 14px; padding-right: 14px; }
  .query { flex-wrap: wrap; } .query button { padding: 12px 22px; }
  .cols { grid-template-columns: 1fr; }
  .tabs .ghost { display: none; }
  tr.detail td { padding-left: 14px; }
}

/* column sizing */
.tag, .code, td.mono.dim { white-space: nowrap; }
#hostTable td:nth-child(2) { max-width: 320px; }
#hostTable td:nth-child(3) { max-width: 260px; }
#hostTable td:nth-child(3) .sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#hostTable td:nth-child(5) { max-width: 170px; }
.cols { grid-template-columns: repeat(auto-fit, minmax(480px, 1fr)); }
.card .host { word-break: normal; overflow-wrap: anywhere; }
.card table td:first-child.host { min-width: 150px; }
.card .txt { max-height: 7.5em; overflow: auto; }
@media (max-width: 720px) { .cols { grid-template-columns: 1fr; } }

[hidden] { display: none !important; }

/* ---------- header extras */
.logout { margin-left: auto; }
.exports { display: flex; gap: 4px; }
.sortpick { display: none; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); }
.sortpick select { font: inherit; color: var(--ink); padding: 7px 10px; border: 1.5px solid var(--rule); border-radius: var(--r); background: var(--panel); }

/* ---------- login page */
.login-body { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--rule); border-radius: 12px; padding: 32px 28px 28px; }
.login-mark { display: grid; grid-template-columns: repeat(8, 12px); gap: 4px; margin-bottom: 22px; }
.login-mark i { width: 12px; height: 12px; border-radius: 2px; background: var(--wait); }
.login-mark i.live { background: var(--live); }
.login-mark i.dead { background: var(--dead); opacity: .55; }
.login-mark i.risk { background: var(--risk); }
.login h1 { font: 600 22px/1.2 var(--mono); margin: 0; letter-spacing: -0.01em; }
.login h1 b { color: var(--live); }
.login-sub { color: var(--muted); margin: 6px 0 20px; }
.login-form { display: grid; gap: 6px; }
.login-form label { font-size: 13.5px; font-weight: 500; color: var(--muted); margin-top: 8px; }
.login-form input { font: 16px/1.3 var(--sans); padding: 11px 12px; border: 1.5px solid var(--rule); border-radius: var(--r); background: #fff; }
.login-form input:focus { border-color: var(--act); outline: none; box-shadow: 0 0 0 3px rgba(47, 91, 234, .15); }
.login-form button { margin-top: 18px; padding: 13px; font-size: 15px; }
.login-error { background: var(--risk-bg); color: var(--risk); border-left: 3px solid var(--risk); padding: 9px 12px; border-radius: 0 4px 4px 0; font-size: 14px; margin: 0 0 8px; }

/* ---------- phones */
@media (max-width: 760px) {
  body { font-size: 14.5px; }
  .top { padding: 14px 16px 0; gap: 4px 12px; align-items: center; }
  .tagline { order: 3; flex-basis: 100%; font-size: 12.5px; }
  main { padding: 0 12px 48px; }
  input, select, textarea { font-size: 16px !important; }

  .search { padding: 22px 0 16px; }
  .query { flex-wrap: wrap; gap: 8px; }
  .query input { flex: 1 1 100%; font-size: 22px; padding: 12px 14px; }
  .query button { flex: 1; min-height: 48px; }
  .opts-grid { flex-direction: column; gap: 12px; }

  .board { padding: 16px 14px 14px; border-radius: 10px; }
  .board h1 { font-size: 18px; overflow-wrap: anywhere; }
  .counts { gap: 6px 14px; font-size: 13px; }
  .counts b { font-size: 17px; }
  .field { max-height: 180px; }
  .log { max-height: 110px; font-size: 11.5px; }

  .tabs { margin-top: 20px; gap: 0; }
  .tabs > button[data-tab] { flex: 1 1 auto; padding: 11px 8px; font-size: 13.5px; }
  .tabs .spacer { display: none; }
  .tabs .ghost { display: inline-block; }
  .exports { order: 2; flex-basis: 100%; overflow-x: auto; padding: 10px 0; -webkit-overflow-scrolling: touch; }
  .exports button { white-space: nowrap; flex: none; min-height: 36px; }

  .toolbar { gap: 10px; }
  .toolbar input[type=search] { flex: 1 1 100%; max-width: none; min-width: 0; }
  .seg { max-width: 100%; overflow-x: auto; }
  .seg button { white-space: nowrap; min-height: 38px; }
  .sortpick { display: flex; flex: 1 1 100%; }
  .sortpick select { flex: 1; }

  #hostTable thead { display: none; }
  #hostTable, #hostTable tbody { display: block; }
  #hostTable tr.row { display: grid; grid-template-columns: 10px minmax(0, 1fr) minmax(0, 1fr) auto; column-gap: 10px; row-gap: 6px; padding: 12px 14px; border-bottom: 1px solid var(--rule-soft); }
  #hostTable tr.row td { display: block; padding: 0; border: 0; max-width: none; background: none; min-width: 0; }
  #hostTable tr.row td:empty { display: none; }
  #hostTable tr.row td:nth-child(1) { grid-column: 1; grid-row: 1; }
  #hostTable tr.row td:nth-child(2) { grid-column: 2 / 4; grid-row: 1; }
  #hostTable tr.row td.c-date { grid-column: 4 !important; grid-row: 1 !important; font-size: 11px; padding-top: 2px; }
  #hostTable tr.row td.c-wait { grid-column: 2 / 5; grid-row: 2; }
  #hostTable tr.row td:nth-child(3):not(.c-wait) { grid-column: 2; grid-row: 2; }
  #hostTable tr.row td:nth-child(4) { grid-column: 3 / 5; grid-row: 2; }
  #hostTable tr.row td:nth-child(6) { grid-column: 2 / 5; grid-row: 3; }
  #hostTable tr.row td:nth-child(5) { grid-column: 2; grid-row: 4; }
  #hostTable tr.row td:nth-child(7) { grid-column: 3 / 5; grid-row: 4; }
  #hostTable tr.row td:nth-child(3) .sub, #hostTable tr.row td:nth-child(7) .sub { display: none; }
  #hostTable tr.row td:nth-child(3) .mono { font-size: 12px; }
  #hostTable tr.row td:nth-child(3):not(.c-wait) { overflow-wrap: anywhere; }
  #hostTable tr.row td:nth-child(3):has(> span.dim:only-child) { grid-column: 2 / 5; white-space: normal; }
  #hostTable tr.row td:nth-child(4) { font-size: 13px; line-height: 1.35; }
  #hostTable tr.row td:nth-child(2) .sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .legend { font-size: 11.5px; gap: 4px 12px; }
  .exports { scrollbar-width: none; }
  .exports::-webkit-scrollbar { display: none; }
  #hostTable tr.row.open { background: #f2f5f8; }
  #hostTable .title { max-width: 100%; }
  #hostTable tr.detail { display: block; }
  #hostTable tr.detail td { display: block; padding: 2px 14px 18px; border-bottom: 1px solid var(--rule); }
  tr.row:hover td { background: none; }
  .detail-grid { grid-template-columns: 1fr; gap: 4px; }
  .kv { grid-template-columns: minmax(84px, max-content) minmax(0, 1fr); }
  .dot { margin-top: 6px; }

  .cols { gap: 12px; }
  .card { padding: 14px; }
  .card table, .card tbody { display: block; }
  .card tr { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 4px 12px; padding: 10px 0; border-bottom: 1px solid var(--rule-soft); }
  .card tr:last-child { border-bottom: 0; }
  .card table td, .card table th { padding: 0; border: 0; min-width: 0; overflow-wrap: anywhere; }
  .card table td:first-child.host { grid-column: 1 / -1; min-width: 0; }
  .checks li { grid-template-columns: 20px 1fr; }
  .checks .v { grid-column: 2; }
  .bars { grid-template-columns: minmax(0, 1fr) 32% 34px; }
  .bars .lbl { max-width: none; }
  .network { height: 62vh; }

  .history { margin-top: 36px; }
  .hist-row { grid-template-columns: 1fr auto; gap: 2px 12px; }
  .hist-row > span:nth-child(2), .hist-row > span:nth-child(3) { grid-column: 1; font-size: 12.5px; }
  .hist-row button { grid-column: 2; grid-row: 1 / span 3; }
  .login { padding: 26px 20px 22px; }
}
