:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #16181d;
  --muted: #6b7280;
  --line: #e4e6eb;
  --accent: #2f5bea;
  --ok: #157f3b;
  --ok-bg: #e5f5ea;
  --warn: #9a5b00;
  --warn-bg: #fff2d9;
  --bad: #b42318;
  --bad-bg: #fde8e6;
  --mute-bg: #eef0f3;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --panel: #171a20;
    --text: #e8eaee;
    --muted: #9198a4;
    --line: #2a2f38;
    --accent: #7b9cff;
    --ok: #5fd08a;
    --ok-bg: #173022;
    --warn: #f2b84b;
    --warn-bg: #352812;
    --bad: #ff7b6e;
    --bad-bg: #3a1a17;
    --mute-bg: #232832;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
code { font-size: 12px; background: var(--mute-bg); padding: 2px 5px; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.pos { color: var(--ok); }
.neg, .bad { color: var(--bad); }
.warn { color: var(--warn); }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; gap: 16px; align-items: center;
  padding: 12px 24px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; white-space: nowrap; }
.brand .muted { font-weight: 400; font-size: 12px; }
#search {
  flex: 1; max-width: 520px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
}
.top a { margin-left: auto; }

main { padding: 20px 24px 60px; max-width: 1400px; margin: 0 auto; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.tile {
  display: flex; flex-direction: column; gap: 2px; text-align: left; cursor: pointer;
  padding: 14px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
}
.tile:hover { border-color: var(--accent); }
.tile-label { font-size: 12px; color: var(--muted); }
.tile-value { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile-sub { font-size: 12px; color: var(--muted); }
.tile.bad .tile-value { color: var(--bad); }

.servers { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; margin: 16px 0; }
.server { padding: 14px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.server-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.server-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 8px; }
.server-stats div { display: flex; flex-direction: column; }
.server-stats b { font-size: 16px; font-variant-numeric: tabular-nums; }
.cost { width: 100%; padding: 3px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); font-weight: 600; }

.filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip {
  padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); cursor: pointer; font-size: 13px;
}
.chip span { color: var(--muted); margin-left: 2px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.on span { color: rgba(255, 255, 255, .8); }

.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; cursor: pointer; user-select: none; }
th.sorted { color: var(--text); }
#sites tbody tr { cursor: pointer; }
#sites tbody tr:hover { background: var(--bg); }
#sites tbody tr.dim { opacity: .55; }
td { font-variant-numeric: tabular-nums; }

.badge { display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: 12px; font-weight: 600; }
.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.mute { background: var(--mute-bg); color: var(--muted); }

.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .25); z-index: 9; }
.detail {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 10; width: min(640px, 100%);
  overflow-y: auto; padding: 20px 24px 40px; background: var(--panel); border-left: 1px solid var(--line);
}
.detail-head { display: flex; justify-content: space-between; align-items: start; }
.detail h2 { margin: 0 0 2px; font-size: 20px; }
.detail h3 { margin: 22px 0 8px; font-size: 14px; }
.close { border: 0; background: none; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); }
.issues { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-direction: column; gap: 6px; }
.issues li { padding: 7px 10px; border-radius: 8px; font-weight: 500; }
.issues li.bad { background: var(--bad-bg); color: var(--bad); }
.issues li.warn { background: var(--warn-bg); color: var(--warn); }
.issues li.info { background: var(--mute-bg); color: var(--text); }
.ok-line { margin: 14px 0 0; padding: 7px 10px; border-radius: 8px; background: var(--ok-bg); color: var(--ok); font-weight: 500; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.fact { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
table.mini th, table.mini td { padding: 6px 8px; font-size: 13px; }
table.mini th { cursor: default; }
table.mini tr.upd td { background: var(--warn-bg); }

.meta-form { display: flex; flex-direction: column; gap: 10px; }
.meta-form label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.meta-form label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }
.meta-form .row { display: flex; gap: 10px; }
.meta-form .row label { flex: 1; }
.meta-form input:not([type=checkbox]), .meta-form select, .meta-form textarea, .login-card input {
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); font-size: 14px;
}
.meta-form button, .login-card button {
  align-self: flex-start; padding: 8px 18px; border: 0; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer;
}

.login-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card {
  display: flex; flex-direction: column; gap: 12px; width: min(360px, 100%);
  padding: 28px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
.login-card h1 { margin: 0; font-size: 22px; }
.login-card p { margin: 0; }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.login-card button { align-self: stretch; }
.login-card label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.team { max-width: 900px; }
.team table { width: 100%; }
.team form.inline { display: inline; }
.team .add { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin: 12px 0 24px; }
.team .add label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.team .add input, .team .add select, .team .link input { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.team .link { padding: 12px; margin: 12px 0; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.team .link input { width: 100%; margin-top: 6px; }
.error { color: var(--bad); }

@media (max-width: 720px) {
  .top { flex-wrap: wrap; padding: 10px 16px; }
  #search { order: 3; flex-basis: 100%; max-width: none; }
  main { padding: 16px; }
  .server-stats { grid-template-columns: 1fr 1fr; }
  .facts { grid-template-columns: 1fr; }
  .detail { padding: 16px; }
}

.history { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.history li { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }

.otp-link { display: block; padding: 9px 12px; border: 1px dashed var(--accent); border-radius: 8px; text-align: center; font-weight: 600; text-decoration: none; }
.otp-key { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .05em; }

.btn { padding: 6px 12px; border: 1px solid var(--accent); border-radius: 8px; background: var(--panel); color: var(--accent); font-weight: 600; cursor: pointer; }
.btn:hover { background: var(--accent); color: #fff; }
.btn.small { padding: 2px 8px; font-size: 12px; }
.bulk { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.nowrap { white-space: nowrap; }
.flash {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 20;
  padding: 10px 16px; border-radius: 10px; background: var(--text); color: var(--bg); font-weight: 500; box-shadow: 0 4px 16px rgba(0, 0, 0, .2);
}

.activity { margin: 0 0 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.activity summary { padding: 12px 16px; font-weight: 600; cursor: pointer; }
.activity-list { max-height: 340px; overflow: auto; border-top: 1px solid var(--line); }
.activity td { padding: 7px 12px; font-size: 13px; }
.activity tbody tr { cursor: pointer; }
.activity tbody tr:hover { background: var(--bg); }
@media (max-width: 720px) { .activity td:last-child { display: none; } }

.btn.danger { border-color: var(--bad); color: var(--bad); }
.btn.danger:hover { background: var(--bad); color: #fff; }

.shots { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.shots a { display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: var(--muted); font-size: 12px; }
.shots img { width: 100%; aspect-ratio: 1366 / 900; object-fit: cover; object-position: top; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); }

.patches summary { color: var(--bad); }
.patches summary .muted { color: var(--muted); }
.panel-actions { margin: 0; padding: 0 16px 12px; }
.panel-actions:empty { display: none; }

.refresh { margin-left: 10px; }

/* Changes to approve (cards, phone-friendly) */
.approve-list { border-top: 1px solid var(--line); padding: 8px 12px 12px; display: grid; gap: 10px; max-height: 70vh; overflow: auto; }
.change { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--bg); }
.change.open { border-color: var(--warn); }
.change header { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: baseline; }
.change p { margin: 8px 0; overflow-wrap: anywhere; }
.change .diff { margin: 8px 0; display: grid; gap: 4px; }
.change .was, .change .now { padding: 6px 8px; border-radius: 6px; font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 180px; overflow: auto; }
.change .was { background: var(--bad-bg); }
.change .was mark { background: none; color: var(--bad); text-decoration: line-through; font-weight: 600; }
.change .now { background: var(--ok-bg); }
.change .now mark { background: none; color: var(--ok); font-weight: 600; }
.change pre.reply { white-space: pre-wrap; font: inherit; margin: 6px 0; padding: 8px; background: var(--panel); border-radius: 6px; }
.change .actions { display: flex; gap: 10px; margin-top: 10px; }
.change .actions .btn { padding: 10px 18px; font-size: 15px; }
@media (max-width: 720px) { .change .actions .btn { flex: 1; } }
