:root {
  --bg: #f2f2f7;
  --bg-elev: #ffffff;
  --bg-sidebar: #f2f2f7;
  --bg-grouped: #ffffff;
  --line: rgba(60, 60, 67, 0.12);
  --line-strong: rgba(60, 60, 67, 0.18);
  --text: #1d1d1f;
  --muted: #6e6e73;
  --blue: #007aff;
  --blue-press: #0066d6;
  --green: #34c759;
  --orange: #ff9f0a;
  --red: #ff3b30;
  --fill: rgba(120, 120, 128, 0.12);
  --fill-2: rgba(120, 120, 128, 0.08);
  --radius: 12px;
  --sidebar: 220px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font-family: inherit; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(400px, 100%);
  background: var(--bg-elev);
  border-radius: 18px;
  padding: 32px 28px;
  border: 1px solid var(--line);
}
.login-card h1 { margin: 0 0 4px; font-size: 28px; font-weight: 700; letter-spacing: -0.03em; }
.login-card p { margin: 0 0 22px; color: var(--muted); }
.login-card label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 6px; }
.login-card input {
  width: 100%;
  background: var(--fill-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 12px;
  margin-bottom: 12px;
  font-size: 16px;
  color: var(--text);
}
.login-card input:focus { outline: none; border-color: var(--blue); background: #fff; }
.err { color: var(--red); font-size: 13px; min-height: 1.2em; margin-top: 8px; }

.layout {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
}
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--line);
  padding: 18px 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100dvh;
}
.wordmark {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.02em;
  padding: 4px 10px 14px;
}
.nav-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}
.nav-btn:hover { background: var(--fill-2); }
.nav-btn.active { background: var(--fill); }
.nav-btn .dot-mini {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted); flex-shrink: 0;
}
.sidebar-foot {
  margin-top: auto;
  padding: 10px 10px 0;
  border-top: 1px solid var(--line);
}
.sidebar-foot .who { font-size: 12px; color: var(--muted); margin-bottom: 8px; word-break: break-all; }

.main {
  min-width: 0;
  padding: 28px 32px 64px;
  max-width: 860px;
}

.page-title {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.035em;
  margin: 0 0 6px;
}
.page-sub { margin: 0 0 22px; color: var(--muted); font-size: 14px; }

.toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.search {
  flex: 1;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 15px;
}
.search:focus { outline: none; border-color: var(--blue); }

.group {
  background: var(--bg-grouped);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  overflow: hidden;
  margin-bottom: 16px;
}
.group-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0 4px 6px;
}
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 0;
  background: transparent;
  width: 100%;
  text-align: left;
  color: inherit;
  cursor: pointer;
  font-size: 15px;
}
.row + .row, .kv-row + .kv-row { border-top: 1px solid var(--line); }
.row:hover { background: var(--fill-2); }
.row .grow { flex: 1; min-width: 0; }
.row h3 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -0.02em; }
.row .meta { color: var(--muted); font-size: 13px; margin-top: 2px; }
.chev { color: var(--muted); font-size: 18px; line-height: 1; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}
.status .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}
.status.paused .dot, .status.degraded .dot { background: var(--orange); }
.status.down .dot { background: var(--red); }
.status.live .dot { background: var(--green); }

.btn {
  border: 0;
  background: var(--fill);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}
.btn:hover { filter: brightness(0.97); }
.btn.primary { background: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-press); }
.btn.danger { background: var(--red); color: #fff; }
.btn.ghost { background: transparent; color: var(--blue); padding-left: 8px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 18px; }

.hero { margin-bottom: 8px; }
.hero .back {
  border: 0; background: transparent; color: var(--blue);
  padding: 0 0 10px; cursor: pointer; font-size: 15px;
}
.kv-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 8px;
  padding: 11px 14px;
  font-size: 14px;
}
.kv-row span { color: var(--muted); }
.note { color: var(--muted); font-size: 14px; padding: 12px 14px; margin: 0; }

textarea.notes {
  width: 100%;
  min-height: 72px;
  border: 0;
  padding: 12px 14px;
  resize: vertical;
  font-size: 14px;
  background: transparent;
  color: var(--text);
}
textarea.notes:focus { outline: none; }

.check-ok { color: var(--green); font-size: 13px; }
.check-bad { color: var(--red); font-size: 13px; }
.check-skip { color: var(--muted); font-size: 13px; }

.sheet-bg {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.36);
  z-index: 40;
  display: grid;
  place-items: end center;
}
.sheet {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 16px 16px 0 0;
  padding: 20px 20px calc(20px + var(--safe-b));
}
@media (min-width: 641px) {
  .sheet-bg { place-items: center; }
  .sheet { border-radius: 16px; }
}
.sheet h2 { margin: 0 0 8px; font-size: 20px; letter-spacing: -0.02em; }
.sheet p { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
.sheet-actions { display: flex; gap: 8px; justify-content: flex-end; }

.log-time { color: var(--muted); font-size: 12px; min-width: 108px; }
.stat-line { display: flex; gap: 16px; color: var(--muted); font-size: 13px; margin: -12px 0 18px; }

.bottom-nav {
  display: none;
}

@media (max-width: 768px) {
  .layout { grid-template-columns: 1fr; padding-bottom: calc(56px + var(--safe-b)); }
  .sidebar {
    display: none;
  }
  .bottom-nav {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    background: rgba(242, 242, 247, 0.92);
    backdrop-filter: saturate(180%) blur(16px);
    border-top: 1px solid var(--line);
    z-index: 30;
    padding: 6px 4px calc(6px + var(--safe-b));
    justify-content: space-around;
  }
  .bottom-nav button {
    flex: 1;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 10px;
    font-weight: 500;
    padding: 4px 0;
    cursor: pointer;
  }
  .bottom-nav button.active { color: var(--blue); }
  .main { padding: 16px 16px 32px; }
  .page-title { font-size: 28px; }
  .kv-row { grid-template-columns: 1fr; gap: 2px; }
}
