:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --text: #20293a;
  --muted: #667085;
  --border: #d8deea;
  --ok: #1f8f54;
  --warn: #b26a00;
  --err: #b42318;
  --brand: #0f3460;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", "Noto Sans", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top right, #e9efff, var(--bg));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 22px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
}

.brand { font-weight: 700; letter-spacing: .4px; }
nav { display: flex; gap: 10px; }
nav a { color: var(--brand); text-decoration: none; font-weight: 600; }

.container { max-width: 1200px; margin: 20px auto; padding: 0 14px; }
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.stat p { font-size: 1.3rem; font-weight: 700; margin: 0; }

h1 { margin-top: 0; }
h2 { margin-top: 0; font-size: 1.05rem; }

.grid-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.grid-form.two-col {
  grid-template-columns: 1fr 1fr;
}
.grid-form .full { grid-column: 1 / -1; }
label { display: block; font-size: .94rem; color: var(--muted); }
input, textarea, button {
  width: 100%;
  margin-top: 6px;
  padding: 10px 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font: inherit;
}
button {
  background: var(--brand);
  color: #fff;
  border: none;
  cursor: pointer;
  font-weight: 600;
}

.ghost-btn {
  background: #eff2fa;
  color: #27364b;
}

.danger-btn {
  background: var(--err);
}

.btn {
  display: inline-block;
  text-decoration: none;
  background: #eff2fa;
  color: #27364b;
  border-radius: 8px;
  padding: 8px 10px;
  font-weight: 600;
}

table {
  width: 100%;
  border-collapse: collapse;
  overflow-x: auto;
}
th, td {
  text-align: left;
  border-bottom: 1px solid var(--border);
  padding: 9px 8px;
  vertical-align: top;
  font-size: .92rem;
}

.actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.actions form { margin: 0; }
.actions button, .actions .btn { width: auto; margin: 0; }

.badge {
  border-radius: 999px;
  padding: 2px 8px;
  font-size: .8rem;
  font-weight: 700;
}
.badge-ok { background: #dcfce7; color: #166534; }
.badge-partial { background: #fef3c7; color: #92400e; }
.badge-error { background: #fee2e2; color: #991b1b; }
.badge-running { background: #dbeafe; color: #1e40af; }

.checkline {
  display: flex;
  align-items: center;
  gap: 8px;
}
.checkline input[type="checkbox"] {
  width: auto;
  margin: 0;
}

.flash {
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
  border: 1px solid transparent;
}
.flash-success { background: #ecfdf3; border-color: #b7f3cf; color: #0f5132; }
.flash-error { background: #fef2f2; border-color: #fecaca; color: #7f1d1d; }
.flash-info { background: #eff6ff; border-color: #bfdbfe; color: #1e3a8a; }

.digest {
  background: #0f172a;
  color: #e2e8f0;
  padding: 12px;
  border-radius: 8px;
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .85rem;
}

.login-card {
  max-width: 460px;
  margin: 40px auto;
}

.logout-form { margin: 0; }
.logout-form button { margin: 0; width: auto; }

.action-row { display: flex; gap: 10px; flex-wrap: wrap; }
.action-row form { margin: 0; }
.action-row button { width: auto; }

@media (max-width: 900px) {
  .grid-form.two-col { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; }
}
