:root {
  --bg: #f3f8f4;
  --surface: #ffffff;
  --border: #e2ece5;
  --border-strong: #cadad0;
  --text: #14261c;
  --text-muted: #5b6f63;
  --accent: #17864a;
  --accent-hover: #10693a;
  --accent-soft: #e4f4ea;
  --danger: #b42318;
  --danger-soft: #fdeeec;
  --success: #0f7a3d;
  --success-soft: #e4f4ea;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 40, 30, 0.05), 0 10px 28px rgba(20, 40, 30, 0.08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 3rem 1rem;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.card {
  width: 100%;
  max-width: 620px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card__header {
  padding: 1.5rem 1.5rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.card__header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

/* Grouped nav actions on the right of the header (e.g. Districts + Log out). */
.card__header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Compact brand used as the "home" link in the tables header. */
.nav__brand--sm {
  font-size: 1rem;
  gap: 0.5rem;
}

.card__header-title {
  margin-top: 0.9rem;
}

.btn--sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.82rem;
  flex-shrink: 0;
}

h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.subtitle {
  margin: 0.35rem 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.toolbar {
  padding: 1rem 1.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.search {
  position: relative;
  display: flex;
  align-items: center;
}

.search__icon {
  position: absolute;
  left: 0.75rem;
  width: 1.05rem;
  height: 1.05rem;
  color: var(--text-muted);
  pointer-events: none;
}

#filter {
  width: 100%;
  padding: 0.6rem 0.75rem 0.6rem 2.35rem;
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

#filter:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.toolbar__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.selectall {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.count {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--accent);
}

.list {
  max-height: 340px;
  overflow-y: auto;
  padding: 0.25rem 0.75rem;
  margin: 0 0.5rem;
}

.row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.92rem;
  transition: background 0.12s;
}

.row:hover {
  background: var(--bg);
}

.row.is-selected {
  background: var(--accent-soft);
}

.row__name {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86rem;
}

/* --- Source groups (accordion) --- */
.toolbar__left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.linkbtn {
  font: inherit;
  font-size: 0.82rem;
  color: var(--accent);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.linkbtn:hover {
  text-decoration: underline;
}

.group {
  border-bottom: 1px solid var(--border);
}

.group:last-child {
  border-bottom: none;
}

.group__header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.5rem;
  border-radius: 8px;
}

.group__header:hover {
  background: var(--bg);
}

.group__toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
}

.chevron {
  width: 1rem;
  height: 1rem;
  transition: transform 0.15s ease;
}

.group.is-open .chevron {
  transform: rotate(90deg);
}

.group__check {
  flex-shrink: 0;
}

.group__name {
  flex: 1;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  user-select: none;
}

.group__count {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
  flex-shrink: 0;
}

.group__tables {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.1rem 0 0.6rem 1.6rem;
}

.group:not(.is-open) .group__tables {
  display: none;
}

/* --- Tables page: fill the window --- */
body.app-page {
  padding: 1.5rem;
  align-items: stretch;
}

#app {
  max-width: 1100px;
  margin: 0 auto;
  max-height: calc(100vh - 3rem);
  display: flex;
  flex-direction: column;
}

/* Header, banner and footer keep their height; the workspace fills the rest. */
#app .card__header,
#app .banner,
#app .actions {
  flex-shrink: 0;
}

/* Two columns: the selectable list on the left, the schema detail on the right. */
.workspace {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
}

.panel {
  min-width: 0;
  min-height: 0;
}

.panel--list {
  flex: 1 1 56%;
  display: flex;
  flex-direction: column;
}

.panel--detail {
  flex: 1 1 44%;
  overflow-y: auto;
  border-left: 1px solid var(--border);
}

#app .toolbar {
  flex-shrink: 0;
}

#app .list {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
}

@media (max-width: 720px) {
  .workspace {
    flex-direction: column;
  }
  .panel--detail {
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: 45%;
  }
}

/* --- Table row (select + inspect) --- */
.titem {
  display: flex;
  align-items: center;
  border-radius: 8px;
  transition: background 0.12s, box-shadow 0.12s;
}

.titem:hover {
  background: var(--bg);
}

.titem.is-selected {
  background: var(--accent-soft);
}

.titem.is-active {
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

.titem .row {
  flex: 1;
  min-width: 0;
}

.titem .row:hover {
  background: none;
}

.titem__info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  margin-right: 0.35rem;
  padding: 0;
  border: none;
  background: none;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.12s, color 0.12s, background 0.12s;
  flex-shrink: 0;
}

.titem:hover .titem__info,
.titem.is-active .titem__info {
  opacity: 1;
}

.titem__info:hover {
  color: var(--accent);
  background: var(--surface);
}

.titem.is-active .titem__info {
  color: var(--accent);
}

.titem__info svg {
  width: 1.05rem;
  height: 1.05rem;
}

/* --- Schema detail panel --- */
.detail {
  padding: 1.25rem 1.35rem;
}

.detail__empty {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.detail__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.detail__title {
  margin: 0 0 0.15rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.98rem;
  font-weight: 600;
  word-break: break-all;
}

.btn-copy {
  flex-shrink: 0;
  font: inherit;
  font-size: 0.76rem;
  font-weight: 500;
  padding: 0.3rem 0.7rem;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.btn-copy:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.btn-copy:disabled {
  color: var(--accent);
  border-color: var(--accent);
  cursor: default;
}

.detail__desc {
  margin: 0 0 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.detail__section {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 1.1rem 0 0.5rem;
}

.schema-cols {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.schema-cols td {
  padding: 0.35rem 0.5rem 0.35rem 0;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.schema-cols .cname {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.schema-cols .ctype {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text-muted);
  white-space: nowrap;
}

.col-desc {
  color: var(--text-muted);
  font-size: 0.76rem;
  margin-top: 0.15rem;
}

.tag {
  display: inline-block;
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  white-space: nowrap;
}

.tag--key {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent);
}

.schema-keys {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.8rem;
}

.schema-keys__row {
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
  flex-wrap: wrap;
}

.klabel {
  color: var(--text-muted);
  min-width: 8.5rem;
}

.chip {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.74rem;
  padding: 0.1rem 0.45rem;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  margin: 0 0.25rem 0.25rem 0;
}

input[type="checkbox"] {
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.state {
  padding: 2.5rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.banner {
  margin: 0.5rem 1.5rem;
  padding: 0.7rem 0.9rem;
  border-radius: 8px;
  font-size: 0.85rem;
}

.banner--info {
  background: var(--accent-soft);
  color: var(--accent);
}

.banner--error {
  background: var(--danger-soft);
  color: var(--danger);
}

.banner--success {
  background: var(--success-soft);
  color: var(--success);
}

.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.actions__buttons {
  display: flex;
  gap: 0.6rem;
}

.hint {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.btn {
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.6rem 1.1rem;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

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

.btn--primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--block {
  width: 100%;
  margin-top: 0.25rem;
}

/* --- Login page --- */
body.centered {
  align-items: center;
}

/* Sign-in page: share the landing chrome (nav + footer) but center the card
   between them. Uses the combined selector so it wins over `body.landing`. */
body.landing.auth-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* As flex items the nav/footer would shrink to content width (their `margin:
   0 auto` collapses in a flex column), breaking their space-between layout.
   Force them full-width so their internal max-width + centering still work. */
.auth-page .nav,
.auth-page .footer {
  width: 100%;
}

.auth-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
}

.card--login {
  max-width: 380px;
}

.login__header {
  padding: 2.25rem 1.75rem 1.25rem;
  text-align: center;
}

.brand {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.login__form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 0.75rem 1.75rem 2rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field__label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
}

.field input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: var(--text);
}

/* --- Landing page --- */
body.landing {
  display: block;
  align-items: initial;
  justify-content: initial;
  padding: 0;
  background: radial-gradient(
      60% 45% at 50% 0%,
      var(--accent-soft) 0%,
      transparent 70%
    ),
    var(--bg);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem;
}

.nav__brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}

.logo {
  display: block;
  flex-shrink: 0;
}

.btn--ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-strong);
  text-decoration: none;
}

.btn--ghost:hover {
  background: var(--surface);
}

.btn--lg {
  padding: 0.8rem 1.5rem;
  font-size: 0.98rem;
}

a.btn {
  display: inline-block;
  text-decoration: none;
}

.hero {
  max-width: 760px;
  margin: 0 auto;
  padding: 5rem 1.5rem 3.5rem;
  text-align: center;
}

.hero__eyebrow {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  margin-bottom: 1.25rem;
}

.hero__title {
  font-size: clamp(2rem, 5vw, 3.25rem);
  line-height: 1.08;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0 0 1.1rem;
}

.hero__subtitle {
  font-size: 1.1rem;
  color: var(--text-muted);
  max-width: 560px;
  margin: 0 auto 2rem;
}

.hero__cta {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

.features {
  max-width: 1000px;
  margin: 0 auto;
  padding: 1rem 1.5rem 4rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
}

.feature {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
}

.feature__mark {
  display: block;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent-soft);
  margin-bottom: 0.9rem;
}

.feature h3 {
  margin: 0 0 0.4rem;
  font-size: 1rem;
  font-weight: 600;
}

.feature p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.footer {
  max-width: 1080px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
}

.footer a {
  color: var(--text-muted);
  text-decoration: none;
}

.footer a:hover {
  color: var(--text);
}

/* --- Nav links + content pages --- */
.nav__links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav__links a:not(.btn) {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.95rem;
}

.nav__links a:not(.btn):hover {
  color: var(--text);
}

.footer__links {
  display: flex;
  gap: 1.25rem;
}

.page {
  max-width: 760px;
  margin: 0 auto;
  padding: 3.5rem 1.5rem 4rem;
}

.page-title {
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 1.5rem;
}

.section-heading {
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 2.5rem 0 0.75rem;
}

.prose p {
  color: var(--text-muted);
  font-size: 1.02rem;
  line-height: 1.75;
  margin: 0 0 1rem;
}

.link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.link:hover {
  text-decoration: underline;
}

/* --- Leadership --- */
.leaders {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.75rem;
  margin-top: 1.25rem;
}

.leader {
  text-align: center;
}

.avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 0.9rem;
  overflow: hidden;
}

.avatar__icon {
  width: 54px;
  height: 54px;
  color: var(--accent);
  opacity: 0.5;
}

.avatar__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.leader__role {
  font-weight: 600;
  font-size: 1rem;
  margin: 0;
}

.leader__name {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0.25rem 0 0;
  min-height: 1em;
}

.leader__bio {
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.6;
  margin: 0.5rem 0 0;
}

.form-error {
  color: var(--danger);
  font-size: 0.85rem;
  text-align: center;
  margin: 0.25rem 0 0;
}
