/* KCCS Sentinel - Catppuccin Mocha dark UI. No external fonts/CDNs. */
:root {
  --base: #1e1e2e;
  --mantle: #181825;
  --surface: #313244;
  --surface1: #45475a;
  --text: #cdd6f4;
  --subtext: #a6adc8;
  --red: #f38ba8;
  --yellow: #f9e2af;
  --green: #a6e3a1;
  --blue: #89b4fa;
  --mauve: #cba6f7;
  --overlay: #6c7086;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--base);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- header ---- */
header.topbar {
  background: var(--mantle);
  border-bottom: 1px solid var(--surface);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
}

.brand .shield {
  color: var(--mauve);
  font-size: 1.3rem;
  line-height: 1;
}

nav.mainnav {
  display: flex;
  gap: 4px;
  margin-left: 12px;
  flex-wrap: wrap;
}

nav.mainnav a {
  color: var(--subtext);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.92rem;
}

nav.mainnav a:hover, nav.mainnav a.active {
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}

.spacer { flex: 1; }

.status-pill {
  padding: 4px 12px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.status-pill.ok { background: rgba(166,227,161,0.15); color: var(--green); border: 1px solid var(--green); }
.status-pill.issues { background: rgba(249,226,175,0.15); color: var(--yellow); border: 1px solid var(--yellow); }
.status-pill.critical { background: rgba(243,139,168,0.15); color: var(--red); border: 1px solid var(--red); }

.killbanner {
  background: var(--red);
  color: var(--mantle);
  text-align: center;
  font-weight: 700;
  padding: 8px;
  letter-spacing: 0.04em;
}

.logout-btn {
  color: var(--subtext);
  border: 1px solid var(--surface1);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 0.85rem;
  background: transparent;
}
.logout-btn:hover { color: var(--text); border-color: var(--overlay); }

/* ---- main content ---- */
main.content {
  flex: 1;
  padding: 20px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

h1, h2, h3 { color: var(--text); font-weight: 700; }
h1 { font-size: 1.4rem; margin: 0 0 16px; }
h2 { font-size: 1.1rem; margin: 24px 0 10px; }

.card {
  background: var(--surface);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}

/* ---- stat tiles ---- */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.tile {
  background: var(--surface);
  border-radius: 10px;
  padding: 14px 16px;
  border-left: 4px solid var(--overlay);
}
.tile .label { color: var(--subtext); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
.tile .value { font-size: 1.8rem; font-weight: 700; margin-top: 4px; }
.tile.crit { border-left-color: var(--red); }
.tile.crit .value { color: var(--red); }
.tile.warn { border-left-color: var(--yellow); }
.tile.warn .value { color: var(--yellow); }
.tile.info { border-left-color: var(--blue); }
.tile.info .value { color: var(--blue); }
.tile.ok { border-left-color: var(--green); }
.tile.ok .value { color: var(--green); }

/* ---- host grid ---- */
.hostgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.hostcard {
  background: var(--surface);
  border-radius: 10px;
  padding: 14px;
  display: block;
  color: var(--text);
}
.hostcard:hover { background: var(--surface1); text-decoration: none; }
.hostcard .row1 { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot.up { background: var(--green); }
.dot.down { background: var(--red); }
.hostcard .meta { color: var(--subtext); font-size: 0.82rem; margin-top: 8px; line-height: 1.6; }
.hostcard .issuecount { color: var(--yellow); font-weight: 700; }
.hostcard .issuecount.zero { color: var(--green); }

/* ---- tables ---- */
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--surface1); }
th { color: var(--subtext); text-transform: uppercase; font-size: 0.74rem; letter-spacing: 0.03em; }
tr:hover td { background: rgba(255,255,255,0.02); }

.chip {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
}
.chip.CRIT { background: rgba(243,139,168,0.18); color: var(--red); }
.chip.WARN { background: rgba(249,226,175,0.18); color: var(--yellow); }
.chip.INFO { background: rgba(137,180,250,0.18); color: var(--blue); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
}
.badge.dry { background: rgba(137,180,250,0.18); color: var(--blue); }
.badge.live { background: rgba(243,139,168,0.18); color: var(--red); }
.badge.ok { background: rgba(166,227,161,0.18); color: var(--green); }
.badge.fail { background: rgba(243,139,168,0.18); color: var(--red); }

/* ---- forms / filters ---- */
form.filterbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 14px;
}
select, input[type=text], input[type=password] {
  background: var(--mantle);
  color: var(--text);
  border: 1px solid var(--surface1);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 0.88rem;
}
select:focus, input:focus { outline: 1px solid var(--blue); }

button, .btn {
  background: var(--blue);
  color: var(--mantle);
  border: none;
  border-radius: 6px;
  padding: 7px 14px;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
}
button:hover, .btn:hover { filter: brightness(1.1); }
button.danger, .btn.danger { background: var(--red); }
button.ghost { background: transparent; border: 1px solid var(--surface1); color: var(--text); }

/* ---- toggle switches ---- */
.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  vertical-align: middle;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--surface1);
  border-radius: 999px;
  transition: 0.15s;
}
.slider:before {
  position: absolute;
  content: "";
  height: 16px; width: 16px;
  left: 3px; bottom: 3px;
  background: var(--text);
  border-radius: 50%;
  transition: 0.15s;
}
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider:before { transform: translateX(18px); }

.killswitch-box {
  border: 1px solid var(--red);
  background: rgba(243,139,168,0.08);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.rule-item, .pb-item {
  border-bottom: 1px solid var(--surface1);
  padding: 10px 0;
}
.rule-item:last-child, .pb-item:last-child { border-bottom: none; }
.rule-item code, .pb-item code { color: var(--mauve); background: var(--mantle); padding: 1px 6px; border-radius: 4px; }
.pb-item .allow-list { color: var(--subtext); font-size: 0.82rem; margin-top: 4px; }

.actions-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.action-pill {
  flex-shrink: 0;
  background: var(--mantle);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.82rem;
  min-width: 180px;
}

.empty { color: var(--subtext); font-style: italic; padding: 12px 0; }

/* ---- login page ---- */
.login-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: var(--surface);
  border-radius: 12px;
  padding: 32px;
  width: 320px;
}
.login-card h1 { text-align: center; margin-bottom: 20px; }
.login-card label { display: block; font-size: 0.82rem; color: var(--subtext); margin: 10px 0 4px; }
.login-card input { width: 100%; }
.login-card button { width: 100%; margin-top: 18px; }
.login-error {
  background: rgba(243,139,168,0.15);
  color: var(--red);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 0.85rem;
  margin-top: 12px;
}

/* ---- footer ---- */
footer.sentinel-footer {
  text-align: center;
  color: var(--overlay);
  font-size: 0.78rem;
  padding: 14px;
  border-top: 1px solid var(--surface);
}

@media (max-width: 640px) {
  main.content { padding: 12px; }
  nav.mainnav { width: 100%; order: 3; }
  header.topbar { gap: 8px; }
}
