:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --ink: #1a1d1f;
  --muted: #6f767e;
  --muted-2: #9aa0a6;
  --line: #e8eaed;
  --line-strong: #dfe3e8;
  --accent: #2e5bff;
  --accent-hover: #1f4aef;
  --accent-soft: #eef2ff;
  --accent-ink: #2e5bff;
  --danger: #e5484d;
  --danger-soft: #fff1f1;
  --danger-ink: #c5342f;
  --warn: #d97706;
  --warn-soft: #fff7ed;
  --warn-ink: #b45309;
  --ok: #16a34a;
  --ok-soft: #ecfdf3;
  --ok-ink: #15803d;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.06);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05), 0 4px 12px rgba(16, 24, 40, 0.04);
  --radius: 16px;
  --radius-sm: 12px;
  --radius-pill: 999px;
  --sans: "Plus Jakarta Sans", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", "Consolas", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover { color: var(--accent-hover); }

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 1.25rem 3rem;
}

/* —— Top bar —— */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.wrap > .topbar {
  width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
}

.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink);
  letter-spacing: -0.03em;
  flex-shrink: 0;
}
.brand:hover { color: var(--ink); text-decoration: none; }

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(145deg, #4d7aff 0%, #2e5bff 100%);
  color: #fff;
  display: inline-grid;
  place-items: center;
  font-size: 0.85rem;
  font-weight: 800;
  box-shadow: 0 6px 14px rgba(46, 91, 255, 0.28);
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.2rem;
  flex: 1;
  min-width: 0;
}

.nav-links a {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-pill);
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-links a:hover {
  color: var(--ink);
  background: rgba(0, 0, 0, 0.04);
  text-decoration: none;
}
.nav-links a.active {
  color: var(--ink);
  background: #eceef2;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  margin-left: auto;
  flex-shrink: 0;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(145deg, #93a8ff, #2e5bff);
  color: #fff;
  display: inline-grid;
  place-items: center;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.avatar.sm {
  width: 24px;
  height: 24px;
  font-size: 0.65rem;
}

.user-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.user-meta .name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink);
}
.user-meta .role {
  font-size: 0.72rem;
  color: var(--muted);
}

/* —— Page —— */
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin: 1.5rem 0 1.25rem;
}

.page-head h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.15;
}

.page-head .subtitle {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

h2 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 0.85rem;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0 0 0.85rem;
}
.section-head h2 { margin: 0; }

/* —— Cards & panels —— */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.15rem 1.25rem;
}

.card + .card { margin-top: 1rem; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.panel-body { padding: 1.15rem 1.25rem; }

.panel-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  padding: 0.9rem 1.15rem;
  border-bottom: 1px solid var(--line);
}

/* —— Stats —— */
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.1rem 1.15rem;
  position: relative;
  min-height: 96px;
}

.stat .label {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
}

.stat .value {
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-top: 0.45rem;
  color: var(--ink);
}

.stat .stat-icon {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
}

.stat.danger .value { color: var(--danger-ink); }
.stat.danger .stat-icon { background: var(--danger-soft); color: var(--danger); }
.stat.debt .value { color: var(--accent); }

/* —— Filters / pills —— */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 1rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-pill);
  background: #eceef2;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 600;
  border: none;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}
.pill:hover {
  background: #e2e5eb;
  color: var(--ink);
  text-decoration: none;
}
.pill.active {
  background: var(--ink);
  color: #fff;
}
.pill .count {
  color: inherit;
  opacity: 0.7;
  font-weight: 700;
}

/* —— Tables —— */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  text-align: left;
  padding: 0.85rem 1.15rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #fafbfc;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafbfd; }

td .person {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

/* —— Badges —— */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.28rem 0.65rem;
  border-radius: var(--radius-pill);
  border: none;
  letter-spacing: 0.01em;
  background: #eef0f3;
  color: var(--muted);
}

.badge.success, .badge.ok {
  background: var(--ok-soft);
  color: var(--ok-ink);
}
.badge.failed, .badge.danger {
  background: var(--danger-soft);
  color: var(--danger-ink);
}
.badge.running, .badge.pending, .badge.success_partial {
  background: var(--warn-soft);
  color: var(--warn-ink);
}

/* —— Forms —— */
.form {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem 1.35rem;
  max-width: 480px;
}

.form.wide { max-width: 640px; }

.form label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin: 0.85rem 0 0.35rem;
}
.form label:first-child { margin-top: 0; }

.form input,
.form textarea,
.form select,
.input {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  font: inherit;
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form input:focus,
.form textarea:focus,
.form select:focus,
.input:focus {
  outline: none;
  border-color: #93a8ff;
  box-shadow: 0 0 0 3px rgba(46, 91, 255, 0.15);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 1.15rem;
  align-items: center;
}

/* —— Buttons —— */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  padding: 0.6rem 1.05rem;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  border-radius: var(--radius-sm);
  box-shadow: 0 6px 14px rgba(46, 91, 255, 0.22);
  transition: filter 0.15s ease, transform 0.15s ease, background 0.15s ease;
}
button:hover, .btn:hover {
  filter: brightness(1.03);
  text-decoration: none;
  color: #fff;
}
button:active, .btn:active { transform: translateY(1px); }

button.secondary, .btn.secondary {
  background: #fff;
  color: var(--ink);
  border-color: var(--line-strong);
  box-shadow: none;
}
button.secondary:hover, .btn.secondary:hover {
  background: #f7f8fa;
  color: var(--ink);
}

button.ghost, .btn.ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
  box-shadow: none;
  padding-inline: 0.7rem;
}
button.ghost:hover, .btn.ghost:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--ink);
}

button.danger, .btn.danger {
  background: var(--danger);
  border-color: var(--danger);
  box-shadow: 0 6px 14px rgba(229, 72, 77, 0.22);
}

button.sm, .btn.sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  border-radius: 10px;
  box-shadow: none;
}

/* —— Notices —— */
.notice {
  background: var(--accent-soft);
  border: 1px solid #d9e2ff;
  color: var(--ink);
  padding: 0.95rem 1.1rem;
  margin-bottom: 1rem;
  border-radius: var(--radius-sm);
  word-break: break-all;
  font-size: 0.92rem;
}
.notice code {
  font-family: var(--mono);
  font-size: 0.82rem;
  background: rgba(255, 255, 255, 0.7);
  padding: 0.1rem 0.35rem;
  border-radius: 6px;
}
.notice.warn {
  background: var(--warn-soft);
  border-color: #fde68a;
}

/* —— Log —— */
.log-box {
  background: #0f172a;
  color: #e2e8f0;
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.5;
  padding: 1.1rem 1.2rem;
  border-radius: var(--radius);
  border: 1px solid #1e293b;
  max-height: 70vh;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: var(--shadow);
}

.muted { color: var(--muted); font-size: 0.9rem; }
.debt { font-weight: 700; color: var(--accent); }
.mono { font-family: var(--mono); font-size: 0.85rem; }

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  margin-bottom: 1rem;
  color: var(--muted);
  font-size: 0.92rem;
}
.meta-row strong { color: var(--ink); font-weight: 700; }

.split {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1rem;
  align-items: start;
}

.stack { display: flex; flex-direction: column; gap: 1rem; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 2rem 1rem;
  font-size: 0.92rem;
}

/* —— Landing —— */
.hero-card {
  margin-top: 2.5rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 2.5rem 2rem;
  max-width: 560px;
}
.hero-card h1 {
  margin: 0 0 0.65rem;
  font-size: 1.85rem;
  letter-spacing: -0.035em;
}
.hero-card p { margin: 0; }

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; }
  .user-meta { display: none; }
  .nav-links { gap: 0.1rem; }
  .nav-links a { padding: 0.4rem 0.65rem; font-size: 0.82rem; }
}

@media (max-width: 600px) {
  .wrap { padding: 0 0.85rem 2.5rem; }
  .topbar-inner { padding: 0.75rem 0.85rem; gap: 0.75rem; flex-wrap: wrap; }
  .page-head h1 { font-size: 1.45rem; }
  .stats { grid-template-columns: 1fr 1fr; gap: 0.65rem; }
  th, td { padding: 0.7rem 0.85rem; font-size: 0.85rem; }
  .brand { width: 100%; }
  .nav-links { width: 100%; order: 3; }
  .user-chip { margin-left: 0; }
}
