:root {
  --bg: #f3f2ef;
  --surface: #fff;
  --ink: #1a1a1a;
  --muted: #5c5c5c;
  --faint: #8a8a8a;
  --line: #e4e2dc;
  --sidebar: #161616;
  --sidebar-text: #c8c8c8;
  --sidebar-active: #fff;
  --accent: #1f6f78;
  --accent-hover: #18585f;
  --ok: #2f6b3a;
  --ok-bg: #e8f3ea;
  --warn: #8a5a12;
  --warn-bg: #f7eedc;
  --bad: #9b2c2c;
  --bad-bg: #f8e8e8;
  --info: #2c5282;
  --info-bg: #e8eef6;
  --shadow: 0 1px 2px rgba(26, 26, 26, 0.06);
  --radius: 6px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Mono", "Segoe UI Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.hidden { display: none !important; }

/* Login */
.login-wrap {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 32px 16px;
  background: var(--sidebar);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid #2a2a2a;
  padding: 32px 28px;
}
.login-brand {
  font-size: 13px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 6px;
}
.login-card h1 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.02em;
}
.login-card p {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 13px;
}

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--ink);
}
.field { margin-bottom: 14px; }
input, select, textarea {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(31, 111, 120, 0.28);
  border-color: var(--accent);
}
.hint { color: var(--faint); font-weight: 400; font-size: 11px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  font-size: 13px;
}
.btn:hover { background: #f7f6f3; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-block { width: 100%; height: 40px; }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-danger:hover { background: #7f2222; }
.btn-sm { height: 28px; padding: 0 8px; font-size: 12px; }

.alert {
  display: none;
  padding: 10px 12px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  font-size: 13px;
  border: 1px solid transparent;
}
.alert.show { display: block; }
.alert-error { background: var(--bad-bg); color: var(--bad); border-color: #ecc8c8; }
.alert-success { background: var(--ok-bg); color: var(--ok); border-color: #c9e2ce; }

/* App shell */
.app {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100%;
}
.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-text);
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
}
.sidebar-logo {
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.04em;
  font-size: 15px;
  padding: 0 8px 20px;
}
.sidebar-logo span {
  display: block;
  margin-top: 3px;
  font-weight: 400;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8d8d8d;
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button {
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--sidebar-text);
  border: 0;
  border-radius: 4px;
  padding: 9px 10px;
  font-weight: 500;
}
.nav button:hover { background: #242424; color: #fff; }
.nav button.active { background: #2b2b2b; color: var(--sidebar-active); }
.sidebar-foot {
  margin-top: auto;
  padding: 12px 8px 0;
  border-top: 1px solid #2a2a2a;
  font-size: 12px;
}
.sidebar-foot .who { color: #fff; margin-bottom: 10px; }

.main { padding: 28px 32px 48px; min-width: 0; }
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 20px;
}
.page-head h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.02em;
}
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.metric .k {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--faint);
  font-weight: 600;
}
.metric .v {
  margin-top: 6px;
  font-size: 26px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.panel-head {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.search {
  min-width: 220px;
  flex: 1;
  max-width: 360px;
}
.filter { width: 160px; height: 34px; }

table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--faint);
  font-weight: 650;
  background: #fafaf8;
}
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafaf8; }
.empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--muted);
}
code.key {
  font-family: var(--mono);
  font-size: 12px;
  background: #f4f3ef;
  padding: 3px 6px;
  border-radius: 4px;
}
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 650;
}
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-muted { background: #eee; color: var(--muted); }

.num { font-variant-numeric: tabular-nums; }

.credentials {
  margin-top: 16px;
  background: #f7f6f3;
  border: 1px solid var(--line);
  padding: 14px;
}
.credentials h3 { margin: 0 0 8px; font-size: 14px; }
.cred-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 13px;
}
.cred-row:last-child { border-bottom: 0; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(22, 22, 22, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 20;
}
.modal.open { display: flex; }
.modal-card {
  width: 100%;
  max-width: 460px;
  background: #fff;
  border: 1px solid var(--line);
  padding: 22px;
  max-height: 90vh;
  overflow: auto;
}
.modal-card h3 {
  margin: 0 0 16px;
  font-size: 18px;
  font-weight: 650;
}
.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.modal-actions .btn { flex: 1; }

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}
.check input { width: auto; height: auto; }

@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; align-items: center; gap: 12px; padding: 12px; }
  .sidebar-logo { padding: 0 8px 0 0; }
  .sidebar-logo span { display: none; }
  .nav { flex-direction: row; flex: 1; }
  .nav button { width: auto; }
  .sidebar-foot { margin: 0 0 0 auto; border: 0; padding: 0; display: flex; gap: 8px; align-items: center; }
  .sidebar-foot .who { margin: 0; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .main { padding: 18px 14px 40px; }
  table, thead, tbody, th, td, tr { display: block; }
  thead { display: none; }
  tbody tr { padding: 12px 14px; border-bottom: 1px solid var(--line); }
  td { padding: 4px 0; border: 0; }
  td::before {
    content: attr(data-label);
    display: inline-block;
    min-width: 92px;
    color: var(--faint);
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 650;
  }
}
