:root {
  --bg: #f3efe6;
  --bg-accent: #e7efea;
  --ink: #1c2a24;
  --muted: #5a6b63;
  --line: #c9d2cc;
  --brand: #0f5c4c;
  --brand-ink: #f7faf8;
  --danger: #8b2e2e;
  --card: rgba(255, 255, 255, 0.55);
  --shadow: 0 12px 40px rgba(28, 42, 36, 0.08);
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --font-body: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-body);
  background:
    radial-gradient(circle at 10% 0%, #dfece4 0%, transparent 45%),
    radial-gradient(circle at 90% 10%, #efe4d4 0%, transparent 40%),
    linear-gradient(180deg, var(--bg), var(--bg-accent));
  min-height: 100vh;
}

a { color: var(--brand); }

.site-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.75rem;
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
  background: rgba(243, 239, 230, 0.7);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.brand a {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--ink);
  letter-spacing: 0.01em;
}

.brand-sub {
  color: var(--muted);
  font-size: 0.85rem;
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  align-items: center;
}

nav a {
  text-decoration: none;
  color: var(--ink);
  font-size: 0.95rem;
}

nav a:hover { color: var(--brand); }

.container {
  width: min(1100px, calc(100% - 2rem));
  margin: 1.5rem auto 3rem;
}

.hero-panel, .institution, .stack-form, .filters {
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 18px;
  padding: 1.4rem 1.5rem;
}

.hero-panel h1, h1, h2 {
  font-family: var(--font-display);
  font-weight: 600;
  margin: 0 0 0.5rem;
}

.hero-panel p, .note { color: var(--muted); }

.actions, .page-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  margin: 1rem 0;
}

.page-head { margin-top: 0; }

button, .button {
  appearance: none;
  border: none;
  background: var(--brand);
  color: var(--brand-ink);
  padding: 0.65rem 1rem;
  border-radius: 999px;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

button.secondary, .button.secondary {
  background: transparent;
  color: var(--brand);
  border: 1px solid var(--brand);
}

button.danger { background: var(--danger); }
button.linkish {
  background: transparent;
  color: var(--brand);
  padding: 0;
  border-radius: 0;
  text-decoration: underline;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.stat {
  padding: 1rem 1.1rem;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.45);
}

.stat-value {
  font-family: var(--font-display);
  font-size: 2rem;
}

.stat-label, .muted, .small { color: var(--muted); }
.small { font-size: 0.85rem; }

.plain-list { padding-left: 1.1rem; }

table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75rem 0 1rem;
}

th, td {
  text-align: left;
  padding: 0.65rem 0.4rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.filters, .stack-form, .inline-edit {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
}

.stack-form { flex-direction: column; align-items: stretch; max-width: 480px; }
.stack-form label, .filters label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.9rem; }
.checkbox { flex-direction: row !important; align-items: center; gap: 0.4rem !important; }

input[type="text"], input[type="date"], input[type="file"], select {
  font: inherit;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
}

.bulk-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
  margin: 1rem 0;
  padding: 0.9rem 1rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.55);
}
.bulk-bar label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.9rem;
}
.bulk-bar .checkbox {
  flex-direction: row !important;
  align-items: center;
}
.txn-table-clean td {
  vertical-align: middle;
}
.txn-table-clean .check-col {
  width: 2rem;
}
.txn-table-clean .actions-col {
  width: 4.5rem;
  text-align: right;
}
.txn-name {
  max-width: 28rem;
}
.nowrap { white-space: nowrap; }
.cat-chip {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: #e5f3ec;
  color: #1d4a38;
  font-size: 0.85rem;
}
.bulk-bar {
  position: sticky;
  top: 4.25rem;
  z-index: 5;
}
.bulk-advanced {
  width: 100%;
  font-size: 0.9rem;
}
.bulk-advanced summary {
  cursor: pointer;
  color: var(--muted);
}
.bulk-advanced-body {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-top: 0.65rem;
}
.txn-edit-row td {
  padding: 0 0.4rem 1rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.35);
}
.txn-edit-panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}
.txn-edit-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem 1rem;
}
.txn-edit-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
}
.txn-edit-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.1rem;
  align-items: center;
  margin-top: 0.9rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
}
@media (max-width: 900px) {
  .txn-edit-grid {
    grid-template-columns: 1fr;
  }
}

.account-picker {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.9rem 1rem 1rem;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.login-panel {
  max-width: 420px;
  margin: 2rem auto;
  padding: 1.5rem;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.55);
  box-shadow: var(--shadow);
}
.error { color: var(--danger); }

.flash {
  background: #e5f3ec;
  border: 1px solid #b7d7c6;
  color: #1d4a38;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  margin-bottom: 1rem;
}

.badge {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: #e8eee9;
  color: var(--muted);
}

.status-active { background: #d9efe4; color: #1d5a42; }
.status-error { background: #f3dcdc; color: var(--danger); }

.institution { margin-bottom: 1.25rem; }
.institution header { display: flex; gap: 0.75rem; align-items: center; }

tr.excluded { opacity: 0.55; }

@media (max-width: 720px) {
  .site-header { padding: 1rem; }
  .txn-table { display: block; overflow-x: auto; }
}
