:root {
  --bg: #e8efe8;
  --bg-2: #f4f7f3;
  --ink: #1c2a22;
  --muted: #5c6b61;
  --line: #c5d2c6;
  --panel: rgba(255, 255, 255, 0.72);
  --panel-solid: #f7faf6;
  --accent: #1f6b4f;
  --accent-2: #c46b2f;
  --pos: #1a6b45;
  --neg: #9b2f2f;
  --warn: #8a6a1f;
  --shadow: 0 18px 50px rgba(28, 42, 34, 0.08);
  --radius: 18px;
  --font: "DM Sans", system-ui, sans-serif;
  --display: "Fraunces", Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 10% -10%, #d7e8d8 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #f0e0cf 0%, transparent 50%),
    linear-gradient(180deg, var(--bg), var(--bg-2));
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 3rem;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding: 0.85rem 1rem;
  background: var(--panel);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
}

.brand {
  font-family: var(--display);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
}
.brand span { color: var(--accent); }

.nav {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.nav a {
  color: var(--muted);
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 500;
}
.nav a:hover, .nav a.active {
  color: var(--ink);
  background: #fff;
}

.entity-filter {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.entity-filter select,
.filters select,
.filters input,
.stack-form input,
.stack-form select,
.inline-form input,
.mini-form select {
  font: inherit;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 0.45rem 0.65rem;
  color: var(--ink);
}

.main { min-height: 60vh; }

.footer {
  margin-top: 2.5rem;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  color: var(--muted);
  margin: 0 0 0.35rem;
}

h1, h2 {
  font-family: var(--display);
  font-weight: 600;
  margin: 0 0 0.75rem;
}
h1 { font-size: clamp(1.8rem, 3vw, 2.4rem); }
h2 { font-size: 1.25rem; }

.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }

.hero-panel,
.alert-panel,
.stat,
.narrow,
.grid-2 > div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero-panel {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1.25rem;
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.hero-balance {
  font-family: var(--display);
  font-size: clamp(2rem, 5vw, 3rem);
  margin: 0.2rem 0 0.4rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-start;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 0.55rem 1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--bg-2); text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { filter: brightness(1.05); background: var(--accent); }
.btn-small { padding: 0.35rem 0.7rem; font-size: 0.85rem; }

.alert-panel {
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  border-color: #e2d3a2;
  background: #fff8e8;
}
.alert-panel h2 { margin-bottom: 0.4rem; }
.alert-panel ul { margin: 0.4rem 0 0.8rem; padding-left: 1.1rem; }

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.85rem;
  margin-bottom: 1rem;
}
.stat {
  padding: 1rem 1.1rem;
}
.stat span {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
}
.stat strong {
  font-family: var(--display);
  font-size: 1.45rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 1rem;
}
.grid-2 > div { padding: 1.1rem; }

.section-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.table th,
.table td {
  text-align: left;
  padding: 0.65rem 0.4rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.table tr.warn td { background: #fff8e8; }
.table tr.muted-row td { opacity: 0.7; }
.table-scroll { overflow-x: auto; }

.tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: #e4efe7;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
}
.tag-ok { background: #dcefe3; color: var(--pos); }
.tag-error { background: #f5e0e0; color: var(--neg); }
.tag-running { background: #efe8d8; color: var(--warn); }

.tx-list, .bar-list, .steps {
  list-style: none;
  margin: 0;
  padding: 0;
}
.tx-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--line);
}
.bar-list li { margin-bottom: 0.85rem; }
.bar-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  margin-bottom: 0.3rem;
}
.bar-track {
  height: 8px;
  background: #e4ebe4;
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #3d9a72);
}

.steps {
  list-style: decimal;
  padding-left: 1.2rem;
  margin: 1rem 0 1.25rem;
  color: var(--muted);
}
.steps li { margin-bottom: 0.4rem; }

.filters, .inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: end;
  margin-bottom: 1rem;
  padding: 1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.filters label, .inline-form label, .stack-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.narrow {
  max-width: 520px;
  padding: 1.4rem;
}

.stack-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.empty {
  color: var(--muted);
  padding: 1rem 0;
}

.flash-wrap { margin-bottom: 1rem; }
.flash {
  padding: 0.75rem 1rem;
  border-radius: 12px;
  margin-bottom: 0.4rem;
  border: 1px solid var(--line);
  background: #fff;
}
.flash-ok { border-color: #b7d9c4; background: #eef8f1; }
.flash-error { border-color: #e2b6b6; background: #fbf0f0; }

.inline-edit summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 0.85rem;
}
.mini-form {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.4rem;
  min-width: 180px;
}
.check {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
}

@media (max-width: 860px) {
  .topbar { border-radius: 18px; }
  .stats-row, .grid-2 { grid-template-columns: 1fr; }
  .nav { width: 100%; order: 3; }
}
