:root {
  --bg: #101513;
  --bg-alt: #151d1a;
  --panel: #1a2420;
  --surface: #1e2a25;
  --surface-soft: #19231f;
  --surface-elev: rgba(26, 36, 32, 0.92);
  --input-bg: #111915;
  --line: #2e3d37;
  --ink: #e8f0ec;
  --muted: #9db0a8;
  --brand: #3f9777;
  --danger: #bd5a5a;
  --ok: #45b889;
  --radius: 14px;
}

[data-theme="light"] {
  --bg: #e8ece8;
  --bg-alt: #dde4df;
  --panel: #eef2ef;
  --surface: #edf2ee;
  --surface-soft: #e6ece8;
  --surface-elev: rgba(237, 242, 238, 0.95);
  --input-bg: #f1f4f2;
  --line: #c6d1ca;
  --ink: #172922;
  --muted: #5d7067;
  --brand: #2c5a4a;
  --danger: #9c4040;
  --ok: #226e54;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Space Grotesk", sans-serif;
  background:
    radial-gradient(circle at 10% 10%, rgba(63, 151, 119, 0.12), transparent 22%),
    radial-gradient(circle at 90% 10%, rgba(69, 184, 137, 0.1), transparent 24%),
    linear-gradient(130deg, var(--bg) 0%, var(--bg-alt) 100%);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.62rem 0.7rem;
  background: var(--input-bg);
  color: var(--ink);
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(36, 77, 64, 0.2);
  outline-offset: 1px;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.9rem;
}

.muted {
  color: var(--muted);
}

.mono {
  font-family: "Courier New", monospace;
}

.eyebrow {
  margin: 0;
  font-size: 0.73rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

.btn {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.55rem 0.95rem;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}

.btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
}

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

.btn-ghost {
  background: var(--surface-soft);
  border-color: var(--line);
  color: var(--ink);
}

.icon-btn {
  width: 38px;
  height: 38px;
  padding: 0;
  display: grid;
  place-items: center;
}

.splash {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.splash-card,
.login-card {
  width: min(460px, 100%);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  padding: 1.1rem;
  display: grid;
  gap: 0.8rem;
}

.splash-card h1,
.login-card h1 {
  margin: 0;
  font-size: clamp(1.7rem, 5vw, 2.4rem);
}

.text-danger {
  color: var(--danger);
}

.text-ok {
  color: var(--ok);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 8;
  border-bottom: 1px solid var(--line);
  background: rgba(16, 21, 19, 0.9);
  backdrop-filter: blur(2px);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
}

[data-theme="light"] .topbar {
  background: rgba(244, 247, 245, 0.95);
}

.topbar h1 {
  margin: 0;
  font-size: 1.15rem;
}

.topbar-left,
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.topbar-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.topbar-actions .btn {
  padding: 0.42rem 0.72rem;
  font-size: 0.84rem;
  white-space: nowrap;
}

.app-body {
  display: grid;
  grid-template-columns: 230px 1fr;
  min-height: 0;
}

.app-body.collapsed {
  grid-template-columns: 78px 1fr;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: rgba(26, 36, 32, 0.72);
  padding: 0.8rem;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 0.8rem;
}

[data-theme="light"] .sidebar {
  background: rgba(255, 255, 255, 0.72);
}

.sidebar.collapsed {
  grid-template-columns: 1fr;
  width: 78px;
}

.sidebar-nav {
  display: grid;
  gap: 0.45rem;
}

.nav-btn {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  padding: 0.55rem 0.7rem;
  text-align: left;
}

.nav-btn.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.sidebar-summary {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem;
  background: var(--surface);
  align-self: end;
}

.sidebar-summary p,
.sidebar-summary span,
.sidebar-summary strong {
  margin: 0;
  display: block;
}

.sidebar-summary strong {
  font-size: 1.45rem;
}

.content {
  padding: 1rem;
  display: grid;
  align-content: start;
  gap: 0.85rem;
  max-width: 1320px;
  width: 100%;
  margin: 0 auto;
}

.notice {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  background: var(--surface);
}

.notice.success {
  border-color: rgba(31, 124, 95, 0.4);
  background: rgba(31, 124, 95, 0.08);
}

.notice.error {
  border-color: rgba(160, 51, 51, 0.35);
  background: rgba(160, 51, 51, 0.08);
}

.loading-line {
  height: 3px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(63, 151, 119, 0.18);
  position: relative;
}

.loading-line::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 35%;
  background: linear-gradient(90deg, rgba(36, 77, 64, 0), var(--brand), rgba(31, 124, 95, 0));
  animation: scan 1s linear infinite;
}

@keyframes scan {
  from {
    transform: translateX(-120%);
  }
  to {
    transform: translateX(260%);
  }
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.7rem;
}

.stat-card,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-elev);
}

.stat-card {
  padding: 0.8rem;
}

.stat-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.stat-card strong {
  display: block;
  margin-top: 0.35rem;
  font-size: 1.6rem;
}

.panel {
  padding: 0.9rem;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.7rem;
}

.panel h2 {
  margin: 0;
  font-size: 1.02rem;
}

.filter-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 0.7rem;
}

.list {
  display: grid;
  gap: 0.55rem;
}

.category-section {
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-soft);
  padding: 0.6rem;
  display: grid;
  gap: 0.6rem;
}

.category-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.category-head h3 {
  margin: 0;
  font-size: 0.94rem;
}

.category-count {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  font-size: 0.78rem;
  color: var(--muted);
  background: var(--surface);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 320px));
  justify-content: start;
  gap: 0.55rem;
}

.list-card {
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 0.72rem;
  background: var(--surface);
  display: grid;
  gap: 0.45rem;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.list-card:hover {
  transform: translateY(-2px);
  border-color: rgba(63, 151, 119, 0.55);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
}

.list-card p {
  margin: 0;
}

.list-head {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
}

.list-head strong {
  display: block;
}

.pill {
  align-self: start;
  padding: 0.2rem 0.58rem;
  border-radius: 999px;
  font-size: 0.76rem;
  border: 1px solid var(--line);
  background: var(--surface-soft);
}

.pill-healthy,
.pill-active {
  border-color: rgba(31, 124, 95, 0.45);
  color: #0f5b44;
  background: rgba(31, 124, 95, 0.08);
}

.pill-unhealthy,
.pill-stale {
  border-color: rgba(160, 51, 51, 0.45);
  color: #7d1f1f;
  background: rgba(160, 51, 51, 0.08);
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: opacity 140ms ease, max-height 140ms ease;
}

.card-actions .btn {
  border-radius: 10px;
  padding: 0.34rem 0.58rem;
  font-size: 0.78rem;
}

.list-card:hover .card-actions,
.list-card:focus-within .card-actions {
  opacity: 1;
  max-height: 120px;
}

.form-stack {
  display: grid;
  gap: 0.68rem;
}

.grid-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 11px;
  padding: 0.85rem;
  color: var(--muted);
  background: var(--surface);
}

.activity .list-card strong {
  font-size: 0.95rem;
}

.ops-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: grid;
  place-items: center;
  padding: 1rem;
  z-index: 40;
}

.modal-card {
  width: min(760px, 100%);
  max-height: calc(100vh - 2rem);
  overflow: auto;
}

.form-compact label {
  justify-items: start;
}

.form-compact input,
.form-compact select,
.form-compact textarea {
  width: 76%;
}

.snapshot {
  margin: 0;
  padding-left: 1.1rem;
  display: grid;
  gap: 0.35rem;
}

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

  .ops-grid {
    grid-template-columns: 1fr;
  }

  .filter-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 760px) {
  .topbar {
    position: static;
    padding: 0.65rem;
  }

  .app-body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    grid-template-rows: auto;
    grid-template-columns: 1fr;
  }

  .sidebar.collapsed {
    width: auto;
  }

  .sidebar-summary {
    display: none;
  }

  .filter-grid,
  .grid-two {
    grid-template-columns: 1fr;
  }

  .form-compact input,
  .form-compact select,
  .form-compact textarea {
    width: 100%;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .card-actions {
    opacity: 1;
    max-height: 200px;
  }
}
