:root {
  --bg: #0f172a;
  --bg-soft: #f6f7f9;
  --surface: #ffffff;
  --border: #e4e7ec;
  --text: #111827;
  --muted: #667085;
  --brand: #1d4ed8;
  --ok: #067647;
  --ok-bg: #ecfdf3;
  --warn: #b54708;
  --warn-bg: #fffaeb;
  --crit: #b42318;
  --crit-bg: #fef3f2;
  --over: #7a271a;
  --over-bg: #fee4e2;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-soft);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--brand); }
button { font: inherit; }

.hidden { display: none !important; }

/* ------------------------------------------------------------- login ---- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: radial-gradient(1200px 600px at 20% 0%, #1e293b 0%, var(--bg) 55%);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card p { margin: 0 0 20px; color: var(--muted); font-size: 13px; }

label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }

input[type="password"], input[type="text"], input[type="number"], select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  outline: none;
}

input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.12); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.btn:hover { background: #f9fafb; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: #1e40af; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }

.error-text { color: var(--crit); font-size: 13px; margin-top: 10px; min-height: 18px; }

/* -------------------------------------------------------------- shell ---- */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--brand); }
.header-spacer { flex: 1; }

.header-meta { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; }

.container { max-width: 1280px; margin: 0 auto; padding: 20px; }

/* ---------------------------------------------------------------- tabs --- */
.tabs { display: flex; gap: 4px; margin-bottom: 18px; flex-wrap: wrap; }

.tab {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
}

.tab:hover { background: #eef1f6; color: var(--text); }
.tab.active { background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: var(--shadow); }
.tab .count { font-size: 11px; color: var(--muted); margin-left: 4px; }

/* --------------------------------------------------------------- cards --- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 18px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.card-label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em; }
.card-value { font-size: 26px; font-weight: 700; margin-top: 4px; line-height: 1.2; }
.card-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.card.warn { border-left: 4px solid var(--warn); }
.card.crit { border-left: 4px solid var(--crit); }
.card.ok { border-left: 4px solid var(--ok); }

/* --------------------------------------------------------------- panel --- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 18px;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.panel-title { font-weight: 700; font-size: 14px; }
.panel-title small { font-weight: 500; color: var(--muted); margin-left: 8px; }
.panel-body { padding: 16px; }

.search { margin-left: auto; position: relative; }
.search input { width: 240px; padding: 8px 10px; font-size: 13px; }

/* --------------------------------------------------------------- table --- */
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }

th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: #fcfcfd;
  white-space: nowrap;
}

td { padding: 12px 14px; border-bottom: 1px solid #f1f2f4; vertical-align: middle; }
tbody tr:hover { background: #fcfcfd; }
tbody tr:last-child td { border-bottom: 0; }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

.name-cell { font-weight: 600; }
.name-cell .sub { font-weight: 400; color: var(--muted); font-size: 12px; }

/* -------------------------------------------------------------- badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.crit { background: var(--crit-bg); color: var(--crit); }
.badge.over { background: var(--over-bg); color: var(--over); }
.badge.unknown { background: #f2f4f7; color: var(--muted); }
.badge.neutral { background: #f2f4f7; color: #475467; }

/* ------------------------------------------------------------ progress --- */
.bar {
  position: relative;
  height: 8px;
  background: #eef0f3;
  border-radius: 999px;
  overflow: hidden;
  min-width: 120px;
}

.bar span { position: absolute; inset: 0 auto 0 0; border-radius: 999px; background: var(--ok); }
.bar.warn span { background: var(--warn); }
.bar.crit span { background: var(--crit); }
.bar.over span { background: var(--over); }

.bar-meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 4px; }

/* --------------------------------------------------------------- misc ---- */
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--text); margin-bottom: 6px; }

.notice {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--warn-bg);
  border: 1px solid #fec84b;
  color: var(--warn);
  font-size: 13px;
  margin-bottom: 16px;
}

.notice.crit { background: var(--crit-bg); border-color: #fda29b; color: var(--crit); }
.notice.info { background: #eff8ff; border-color: #b2ddff; color: #175cd3; }
.notice strong { font-weight: 700; }

.dot-ok { color: var(--ok); }
.dot-bad { color: var(--crit); }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.form-field label { margin-bottom: 5px; }
.form-field .hint { font-size: 11px; color: var(--muted); margin-top: 4px; }
.form-actions { margin-top: 16px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #101828;
  color: #fff;
  padding: 12px 16px;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  font-size: 13px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
  max-width: 380px;
}

.toast.show { opacity: 1; transform: translateY(0); }
.toast.bad { background: #912018; }

/* --------------------------------------------------------------- modal --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, 0.5);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 50;
}

.modal {
  background: var(--surface);
  border-radius: 14px;
  width: 100%;
  max-width: 460px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

.modal-head { padding: 16px 18px; border-bottom: 1px solid var(--border); font-weight: 700; }
.modal-body { padding: 18px; display: grid; gap: 14px; }
.modal-foot { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

@media (max-width: 720px) {
  .header-inner { padding: 10px 14px; }
  .container { padding: 14px; }
  .search input { width: 100%; }
  .search { width: 100%; margin-left: 0; }
  .hide-sm { display: none; }
  .card-value { font-size: 22px; }
}
