:root {
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f4f6f9;
  --card: #ffffff;
  --brand: #0f766e;
  --brand-dark: #115e59;
  --side: #0b1220;
  --side-ink: #cbd5e1;
  --ok: #166534;
  --ok-bg: #dcfce7;
  --warn: #92400e;
  --warn-bg: #fef3c7;
  --bad: #991b1b;
  --bad-bg: #fee2e2;
  --radius: 10px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

h1, h2 { margin: 0; line-height: 1.25; }
h1 { font-size: 20px; font-weight: 650; }
h2 { font-size: 15px; font-weight: 650; }

small { display: block; color: var(--muted); font-size: 12px; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---- shell ---- */

.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }

.side {
  background: var(--side);
  color: var(--side-ink);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand { display: flex; align-items: center; gap: 10px; color: inherit; }
.brand:hover { text-decoration: none; }
.brand .mark {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: var(--brand);
  color: #fff;
  font-weight: 700; font-size: 17px;
}
.brand strong { display: block; color: #fff; font-size: 15px; line-height: 1.2; }
.brand small { color: #94a3b8; }

.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a {
  color: var(--side-ink);
  padding: 9px 12px;
  border-radius: 8px;
  font-weight: 500;
}
.side nav a:hover { background: #162033; text-decoration: none; }
.side nav a.on { background: #1b2a44; color: #fff; }

.side-foot { margin: auto 0 0; padding: 0 12px; font-size: 12px; color: #64748b; }

.main { min-width: 0; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 28px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.who { display: flex; align-items: center; gap: 14px; margin: 0; }
.who .user { font-weight: 600; }
.who .role { padding: 2px 9px; border-radius: 999px; background: #eef2f7; color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; }
.linkish {
  border: 0; background: none; padding: 0;
  color: var(--brand); font: inherit; cursor: pointer;
}
.linkish:hover { text-decoration: underline; }

main { padding: 24px 28px 48px; }

.crumbs { margin: 0 0 16px; color: var(--muted); }

/* ---- tiles and cards ---- */

.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.tiles.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.tile, .card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.tile { padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tile .k { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.tile strong { font-size: 21px; font-weight: 650; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tile .s { color: var(--muted); font-size: 12px; }

.cols { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 20px; margin-bottom: 20px; }

.card { overflow: hidden; margin-bottom: 20px; }
.cols .card { margin-bottom: 0; }
.card > header form { margin: 0; }
.card > header h2 .muted { font-weight: 400; }
.card > header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin: 0; padding: 12px 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.pager span:first-child { margin-right: auto; }
.pager + .scroll { border-top: 0; }
.card > .pager:first-of-type { border-top: 0; border-bottom: 1px solid var(--line); }
.pager .jump { display: flex; align-items: center; gap: 8px; margin: 0; }
.pager .jump input { width: 76px; padding: 4px 8px; border: 1px solid #cbd5e1; border-radius: 6px; font: inherit; color: var(--ink); }
.note { margin: 0; padding: 12px 18px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); }

/* ---- tables and lists ---- */

.scroll { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
th:first-child, td:first-child { padding-left: 18px; }
th:last-child, td:last-child { padding-right: 18px; }
th {
  color: var(--muted);
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  background: #f8fafc;
  white-space: nowrap;
}
th.num, td.num { text-align: right; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8fafc; }
td form { margin: 0; }
.under { margin-top: 2px; }

.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
}
.list li:last-child { border-bottom: 0; }
.list strong { font-weight: 600; }

meter { width: 120px; height: 8px; display: block; }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge.ok { color: var(--ok); background: var(--ok-bg); }
.badge.warn { color: var(--warn); background: var(--warn-bg); }

.secret { background: var(--warn-bg); padding: 2px 6px; border-radius: 5px; user-select: all; }

/* ---- buttons and forms ---- */

.btn {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid var(--brand);
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font: inherit; font-weight: 600;
  cursor: pointer;
}
.btn:hover { background: var(--brand-dark); border-color: var(--brand-dark); text-decoration: none; }
.btn.ghost { background: #fff; color: var(--brand); border-color: var(--line); }
.btn.ghost:hover { background: #f8fafc; border-color: #cbd5e1; }
.btn.small { padding: 5px 11px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.wide { width: 100%; padding: 10px 14px; }

/* ---- sign-in and error pages ---- */

.auth { display: grid; place-items: center; min-height: 100vh; padding: 24px; }

.signin {
  width: 100%; max-width: 380px;
  padding: 32px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .06);
}
.signin .brand { margin-bottom: 24px; }
.signin .brand strong { color: var(--ink); }
.signin .brand small { color: var(--muted); }
.signin h1 { font-size: 22px; margin-bottom: 4px; }
.signin form { margin: 20px 0 18px; display: grid; gap: 14px; }
.signin label { display: grid; gap: 6px; font-weight: 600; font-size: 13px; }
.signin input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font: inherit; color: inherit;
  background: #fff;
}
.signin input:focus { outline: 2px solid #99f6e4; border-color: var(--brand); }
.alert {
  margin: 16px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--bad); background: var(--bad-bg);
  font-weight: 500;
}
.fine { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.code { margin: 0 0 4px; color: var(--brand); font-size: 44px; font-weight: 700; line-height: 1; }

/* ---- narrow screens ---- */

@media (max-width: 1100px) {
  .tiles, .tiles.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 12px; padding: 12px 14px; }
  .side nav { flex-direction: row; flex-wrap: wrap; }
  .side-foot { display: none; }
  .top, main { padding-left: 16px; padding-right: 16px; }
  .tiles, .tiles.three { grid-template-columns: minmax(0, 1fr); }
}

.loading, .failed { margin: 0; padding: 18px; color: var(--muted); }
.failed { color: var(--bad); }
