:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f9fbff;
  --line: #d8e0ec;
  --text: #172033;
  --muted: #687386;
  --accent: #155eef;
  --accent-soft: #eaf1ff;
  --danger: #b42318;
  --danger-soft: #fff0ed;
  --ok: #147a4a;
  --warn: #9a6700;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button, input, textarea, select { font: inherit; }

button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: white;
  border-radius: 6px;
  padding: 9px 14px;
  cursor: pointer;
  white-space: nowrap;
}

button.secondary { background: white; color: var(--accent); }
button.danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: white;
  color: var(--text);
}

textarea { resize: vertical; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
h1, h2, p { margin: 0; }
h1 { font-size: 30px; }
h2 { font-size: 18px; }

table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { border-bottom: 1px solid var(--line); padding: 12px 10px; text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 260px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px;
  background: #101828;
  color: white;
}

.brand { display: flex; gap: 12px; align-items: center; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--accent);
  font-weight: 900;
}
.brand div { display: grid; gap: 2px; }
.brand span:last-child, .session-box small { color: #a9b4c8; }

.nav { display: grid; gap: 8px; }
.nav-item {
  width: 100%;
  text-align: left;
  border-color: transparent;
  background: transparent;
  color: #d8e0ec;
}
.nav-item.active, .nav-item:hover { background: #1d2939; color: white; }

.session-box {
  margin-top: auto;
  display: grid;
  gap: 8px;
  padding-top: 18px;
  border-top: 1px solid #293548;
}

.main {
  margin-left: 260px;
  padding: 28px 32px 44px;
  display: grid;
  gap: 20px;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
  margin-bottom: 5px;
}

.view { display: none; gap: 18px; }
.view.active { display: grid; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.metric, .panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric { display: grid; gap: 8px; padding: 18px; }
.metric span, .panel-head p, .muted { color: var(--muted); }
.metric strong { font-size: 32px; }

.panel { padding: 18px; }
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.two-col, .split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.form-grid, .edit-form {
  display: grid;
  grid-template-columns: 1fr 240px;
  gap: 14px;
  align-items: end;
}

.wide { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
.check input { width: auto; }
.inline-form { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.compact-input { max-width: 260px; }
.table-wrap { overflow-x: auto; }

.status {
  display: inline-flex;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 800;
}
.status.active { background: #eaf8f0; color: var(--ok); }
.status.revoked { background: var(--danger-soft); color: var(--danger); }
.status.expired { background: #fff7e6; color: var(--warn); }

.key-name { display: grid; gap: 4px; }
.row-actions { display: flex; justify-content: flex-end; gap: 8px; }
.request-list, .diagnostics, .bars { display: grid; gap: 10px; }

.request-item, .diagnostic-item, .bar-row {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  padding: 10px;
}

.request-main, .bar-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.bar-track {
  height: 8px;
  border-radius: 99px;
  overflow: hidden;
  background: #e7edf6;
  margin-top: 8px;
}
.bar-fill { height: 100%; background: var(--accent); }

.secret {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent-soft);
  word-break: break-all;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 40px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #172033;
  color: white;
  box-shadow: 0 18px 40px rgba(24, 32, 47, 0.18);
}

.login-page {
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-shell {
  width: min(980px, 100%);
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 20px;
  align-items: stretch;
}
.login-hero, .login-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 28px;
}
.login-hero {
  display: grid;
  align-content: center;
  gap: 14px;
  background: #101828;
  color: white;
}
.login-hero p:last-child { color: #c6d0e1; max-width: 520px; }
.login-form { display: grid; gap: 14px; margin-top: 18px; }
.form-error { color: var(--danger); margin-top: 12px; }
.hidden { display: none !important; }

.text-link {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.home-page {
  display: grid;
  place-items: center;
  padding: 28px;
  background: #101828;
}

.home-shell {
  width: min(1080px, 100%);
  display: grid;
  gap: 24px;
}

.home-head {
  color: white;
  display: grid;
  gap: 10px;
}

.home-head p:last-child {
  color: #c6d0e1;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.home-card {
  min-height: 220px;
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 22px;
  border: 1px solid #293548;
  border-radius: 8px;
  background: #182235;
  color: white;
  text-decoration: none;
}

.home-card:hover {
  border-color: var(--accent);
}

.home-card span {
  color: #8fb3ff;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.home-card strong {
  font-size: 22px;
}

.home-card p {
  color: #c6d0e1;
}

.public-check-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(420px, 0.9fr);
  gap: 18px;
  align-items: end;
  padding: 22px;
  border: 1px solid #293548;
  border-radius: 8px;
  background: white;
}

.public-check-card span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.public-check-card strong {
  display: block;
  margin: 8px 0;
  font-size: 24px;
}

.public-check-card p {
  color: var(--muted);
}

.public-check-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
}

.public-result {
  grid-column: 1 / -1;
  border-radius: 6px;
  padding: 10px 12px;
  font-weight: 800;
}

.public-result.ok {
  background: #eaf8f0;
  color: var(--ok);
}

.public-result.bad {
  background: var(--danger-soft);
  color: var(--danger);
}

@media (max-width: 980px) {
  .sidebar {
    position: static;
    width: auto;
    border-radius: 0;
  }
  .main { margin-left: 0; padding: 20px 16px 34px; }
  .stats-grid, .two-col, .split, .form-grid, .edit-form, .login-shell { grid-template-columns: 1fr; }
  .home-grid, .public-check-card, .public-check-form { grid-template-columns: 1fr; }
  .page-head, .panel-head, .request-main, .bar-head { flex-direction: column; align-items: stretch; }
  .inline-form { grid-template-columns: 1fr; }
}
