:root {
  --bg: #e7eef0;
  --sidebar: #12343b;
  --sidebar-soft: #1b4650;
  --ink: #173038;
  --muted: #5d727a;
  --line: #d5e1e5;
  --card: #ffffff;
  --teal: #0f6f78;
  --teal-dark: #0b555c;
  --ok: #0d7a4f;
  --ok-bg: #e6f6ee;
  --late: #8a5a00;
  --late-bg: #fff4d8;
  --bad: #b42318;
  --bad-bg: #fdeceb;
  --run: #0b5cab;
  --run-bg: #e7f1fb;
  --wait: #5c4d8a;
  --wait-bg: #f1edf8;
  --shadow: 0 10px 30px rgba(18, 52, 59, 0.08);
  color-scheme: light;
  font-family: "Segoe UI", "Malgun Gothic", sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: 0.55; }

.shell {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  height: 100%;
}
.shell[hidden] { display: none; }

.login {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login[hidden] { display: none; }
.login-card {
  width: min(400px, 100%);
  background: white;
  border-radius: 18px;
  padding: 28px 24px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
}
.login-card h1 { margin: 0; font-size: 24px; }
.login-card p { margin: 0; color: var(--muted); }
.login-card .mark { width: 48px; height: 48px; }

aside {
  background: linear-gradient(180deg, var(--sidebar) 0%, #0d282e 100%);
  color: #e7f2f4;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
}

.brand { display: flex; gap: 12px; align-items: center; }
.mark {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center;
  background: #1f8a84; color: white; font-weight: 700;
}
.brand h1 { margin: 0; font-size: 18px; font-weight: 700; }
.brand p { margin: 2px 0 0; color: #b7c9ce; font-size: 12px; }

.side-card {
  background: var(--sidebar-soft);
  border-radius: 14px;
  padding: 14px;
  display: grid;
  gap: 8px;
}
.side-card h2 { margin: 0; font-size: 13px; font-weight: 650; color: #d5e7ea; }
.side-card strong { font-size: 16px; }
.side-card span, .path { color: #b7c9ce; font-size: 12px; line-height: 1.45; }
.path { word-break: break-all; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  width: fit-content; border-radius: 999px; padding: 3px 8px;
  background: rgba(255,255,255,0.08); font-size: 12px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: #8aa; display: inline-block; }
.dot.on { background: #3dbe7a; }
.dot.off { background: #e36b64; }
.dot.unknown { background: #d2b15a; }

.side-actions { margin-top: auto; display: grid; gap: 8px; }
.side-actions button, .btn {
  border: 1px solid var(--line);
  background: white;
  border-radius: 10px;
  padding: 8px 12px;
}
.side-actions button {
  background: transparent;
  border-color: rgba(255,255,255,0.18);
  color: #e7f2f4;
}
.side-actions button.primary, .btn.primary {
  background: var(--teal);
  border-color: transparent;
  color: white;
}
.btn.primary:hover { background: var(--teal-dark); }
.btn.ghost { background: #f6fafa; }
.btn.danger { background: white; color: var(--bad); border-color: #f3c7c3; }
.btn.small { padding: 5px 8px; border-radius: 8px; font-size: 12px; }

main {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 18px 20px 16px;
  gap: 12px;
}

.topbar { display: flex; justify-content: space-between; gap: 16px; align-items: flex-end; }
.topbar h2 { margin: 0; font-size: 26px; letter-spacing: -0.03em; }
.topbar p { margin: 4px 0 0; color: var(--muted); }
.top-actions { display: flex; gap: 8px; }

.banner {
  background: #fff7e8;
  border: 1px solid #f0ddb0;
  color: #6d4e09;
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}
.banner.run {
  background: var(--run-bg);
  border-color: #c9dff6;
  color: #0b3f73;
}
.banner[hidden] { display: none; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.stat {
  background: var(--card);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.stat span { color: var(--muted); font-size: 12px; }
.stat strong { display: block; margin-top: 4px; font-size: 22px; font-variant-numeric: tabular-nums; }
.stat em { font-style: normal; color: var(--muted); font-size: 12px; }
.stat.warn strong { color: var(--late); }
.stat.bad strong { color: var(--bad); }

.panel {
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow);
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.toolbar {
  display: flex; gap: 10px; align-items: center;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}
.search {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: #f8fbfb;
}
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line);
  background: white;
  border-radius: 999px;
  padding: 5px 10px;
  color: var(--muted);
}
.chip.on { background: #e7f4f5; color: var(--teal-dark); border-color: #b7dfe2; }

.table-wrap { overflow: auto; min-height: 0; }
table { width: 100%; border-collapse: collapse; min-width: 1040px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid #edf3f4; vertical-align: middle; white-space: nowrap; }
th { position: sticky; top: 0; background: #f8fbfb; font-size: 12px; color: var(--muted); font-weight: 650; z-index: 1; }
tr.group td { background: #f3f7f8; color: var(--muted); font-size: 12px; font-weight: 650; }
.name { font-weight: 700; }
.sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.num { font-variant-numeric: tabular-nums; }
.host-stripe { box-shadow: inset 3px 0 0 var(--stripe, var(--teal)); }
.actions { display: flex; gap: 6px; justify-content: flex-end; white-space: nowrap; }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }

.badge { display: inline-flex; border-radius: 999px; padding: 3px 8px; font-size: 12px; font-weight: 650; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.late { background: var(--late-bg); color: var(--late); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.run { background: var(--run-bg); color: var(--run); }
.badge.wait { background: var(--wait-bg); color: var(--wait); }

.jobdock {
  background: #10262c;
  color: #d7e6ea;
  border-radius: 14px;
  padding: 10px 12px;
  display: grid;
  gap: 8px;
}
.jobdock header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.jobdock pre {
  margin: 0; max-height: 140px; overflow: auto;
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 12px; line-height: 1.45; white-space: pre-wrap;
}
.jobdock .btn { background: transparent; color: white; border-color: rgba(255,255,255,0.2); }

.backdrop { position: fixed; inset: 0; background: rgba(12, 28, 33, 0.48); display: grid; place-items: center; padding: 24px; z-index: 20; }
.backdrop[hidden] { display: none; }
.dialog.wide { width: min(920px, 100%); }
.dialog {
  width: min(640px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  overflow: auto;
  background: white;
  border-radius: 18px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.24);
  padding: 18px;
}
.dialog h3 { margin: 0 0 4px; font-size: 20px; }
.dialog .hint { margin: 0 0 14px; color: var(--muted); }
.form { display: grid; grid-template-columns: 1fr 140px; gap: 10px 12px; }
.field { display: grid; gap: 6px; }
.field.wide { grid-column: 1 / -1; }
.field span { font-size: 12px; color: var(--muted); }
.field input {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 10px;
  background: #fbfefe;
}
.dialog-actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 14px; }
.dialog-actions .right { display: flex; gap: 8px; }
.test-result { min-height: 20px; font-size: 13px; }
.test-result.ok { color: var(--ok); }
.test-result.bad { color: var(--bad); }
.clean-grid { display: grid; grid-template-columns: 240px 1fr; gap: 14px; }
.clean-label { display: block; margin-bottom: 6px; font-size: 12px; color: var(--muted); }
.clean-list {
  display: grid; gap: 6px; max-height: 280px; overflow: auto;
  border: 1px solid var(--line); border-radius: 12px; padding: 8px;
}
.clean-list label { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; }
.clean-list input { margin-top: 3px; }
.clean-meta { color: var(--muted); font-size: 12px; }
.clean-group { font-size: 12px; font-weight: 700; color: var(--teal-dark); margin-top: 4px; }
.clean-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-top: 14px; }
.clean-controls .field { min-width: 180px; }
.preview-box {
  margin-top: 12px; min-height: 48px; max-height: 160px; overflow: auto;
  white-space: pre-wrap; font-size: 12px; color: var(--ink);
  background: #f8fbfb; border-radius: 10px; padding: 8px 10px;
}
.history { display: grid; gap: 8px; margin-top: 8px; }
.history-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

#toast {
  position: fixed; right: 18px; bottom: 18px; z-index: 40;
  background: #173038; color: white; border-radius: 12px;
  padding: 12px 14px; max-width: 360px;
  box-shadow: var(--shadow);
}
#toast[hidden] { display: none; }

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
