:root {
  --pine: #1b4332;
  --pine-light: #2d6a4f;
  --pine-pale: #d8f3dc;
  --stone: #f5f0e8;
  --stone-dark: #e8e0d2;
  --bark: #5c4033;
  --lake: #2563eb;
  --lake-light: #dbeafe;
  --slate: #374151;
  --slate-light: #6b7280;
  --white: #ffffff;
  --red: #dc2626;
  --red-light: #fef2f2;
  --amber: #d97706;
  --amber-light: #fffbeb;
  --green: #16a34a;
  --green-light: #f0fdf4;
  --font-body: 'DM Sans', system-ui, sans-serif;
  --font-display: 'Fraunces', Georgia, serif;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  background: var(--stone);
  color: var(--slate);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- Nav --- */
.topnav {
  background: var(--pine);
  color: var(--white);
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
}
.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  height: 56px;
}
.nav-brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--white);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0;
}
.nav-links {
  display: flex;
  gap: .25rem;
  flex: 1;
}
.nav-links a {
  color: rgba(255,255,255,.8);
  text-decoration: none;
  padding: .35rem .75rem;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-links a:hover { background: rgba(255,255,255,.12); color: var(--white); }
.nav-user {
  display: flex;
  align-items: center;
  gap: .75rem;
  font-size: .85rem;
  flex-shrink: 0;
}
.nav-name { color: rgba(255,255,255,.75); }

/* --- Layout --- */
.container {
  width: 100%;
  max-width: 950px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  flex: 1;
}
.page-header {
  margin-bottom: 2rem;
}
.page-header h1 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  color: var(--pine);
  font-weight: 700;
}
.page-header p {
  color: var(--slate-light);
  margin-top: .25rem;
}

/* --- Cards --- */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  min-width: 640px;
  box-sizing: border-box;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}
.card-header h2 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--pine);
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

/* --- Stats --- */
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  text-align: center;
}
.stat-value {
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--pine);
  font-weight: 700;
}
.stat-label {
  font-size: .8rem;
  color: var(--slate-light);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-top: .25rem;
}

/* --- Table --- */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
th {
  text-align: left;
  padding: .65rem .75rem;
  font-weight: 600;
  color: var(--slate-light);
  text-transform: uppercase;
  font-size: .75rem;
  letter-spacing: .04em;
  border-bottom: 2px solid var(--stone-dark);
  cursor: pointer;
  user-select: none;
}
th:hover { color: var(--pine); }
th .sort-arrow { font-size: .6rem; margin-left: .25rem; }
td {
  padding: .6rem .75rem;
  border-bottom: 1px solid var(--stone);
  vertical-align: middle;
}
tr:hover td { background: var(--stone); }

/* --- Badges --- */
.badge {
  display: inline-block;
  padding: .15rem .55rem;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.badge-board { background: rgba(255,255,255,.2); color: var(--white); }
.badge-verified { background: var(--green-light); color: var(--green); }
.badge-pending { background: var(--amber-light); color: var(--amber); }
.badge-rejected { background: var(--red-light); color: var(--red); }
.badge-review { background: var(--lake-light); color: var(--lake); }
.badge-paid { background: var(--green-light); color: var(--green); }
.badge-unpaid { background: var(--red-light); color: var(--red); }
.badge-waived { background: var(--stone); color: var(--slate-light); }
.badge-draft { background: var(--amber-light); color: var(--amber); }
.badge-approved { background: var(--green-light); color: var(--green); }
.badge-archived { background: var(--stone); color: var(--slate-light); }
.badge-abutter { background: var(--pine-pale); color: var(--pine); }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .5rem 1rem;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: .85rem;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: background .15s, box-shadow .15s;
}
.btn-primary { background: var(--pine); color: var(--white); }
.btn-primary:hover { background: var(--pine-light); }
.btn-danger { background: var(--red); color: var(--white); }
.btn-danger:hover { opacity: .9; }
.btn-outline {
  background: transparent;
  border: 1.5px solid rgba(255,255,255,.3);
  color: var(--white);
}
.btn-outline:hover { border-color: rgba(255,255,255,.6); }
.btn-ghost {
  background: transparent;
  color: var(--pine);
  padding: .35rem .5rem;
}
.btn-ghost:hover { background: var(--stone); }
.btn-sm { padding: .3rem .65rem; font-size: .78rem; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; }

/* --- Forms --- */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--slate);
  margin-bottom: .3rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], select, textarea {
  width: 100%;
  padding: .55rem .75rem;
  border: 1.5px solid var(--stone-dark);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: .9rem;
  background: var(--white);
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--pine-light);
  box-shadow: 0 0 0 3px var(--pine-pale);
}
textarea { min-height: 200px; resize: vertical; }
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.form-hint {
  font-size: .78rem;
  color: var(--slate-light);
  margin-top: .2rem;
}

/* --- Auth pages --- */
.auth-container {
  max-width: 440px;
  margin: 3rem auto;
}
.auth-header {
  text-align: center;
  margin-bottom: 2rem;
}
.auth-header h1 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  color: var(--pine);
}
.auth-header p { color: var(--slate-light); margin-top: .25rem; }
.auth-link {
  text-align: center;
  margin-top: 1.25rem;
  font-size: .875rem;
}
.auth-link a { color: var(--lake); text-decoration: none; font-weight: 600; }
.auth-link a:hover { text-decoration: underline; }

/* --- Alerts --- */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .875rem;
}
.alert-error { background: var(--red-light); color: var(--red); border: 1px solid #fecaca; }
.alert-success { background: var(--green-light); color: var(--green); border: 1px solid #bbf7d0; }
.alert-info { background: var(--lake-light); color: var(--lake); border: 1px solid #bfdbfe; }

/* --- Inline form --- */
.inline-form {
  display: inline-flex;
  gap: .35rem;
  align-items: center;
}

/* --- Footer --- */
.site-footer {
  text-align: center;
  padding: 1.5rem;
  font-size: .78rem;
  color: var(--slate-light);
  border-top: 1px solid var(--stone-dark);
  margin-top: 2rem;
}

/* --- Toast UI Editor --- */
.toastui-editor-defaultUI { width: 100% !important; box-sizing: border-box; }
.toastui-editor-md-container, .toastui-editor-ww-container { width: 100% !important; }
.toastui-editor-main { min-width: 0 !important; }

/* --- Markdown content --- */
.md-content h1, .md-content h2, .md-content h3 { color: var(--pine); margin: 1rem 0 .5rem; }
.md-content h1 { font-size: 1.4rem; }
.md-content h2 { font-size: 1.2rem; }
.md-content h3 { font-size: 1.05rem; }
.md-content p { margin-bottom: .75rem; }
.md-content ul, .md-content ol { margin: .5rem 0 .75rem 1.5rem; }
.md-content li { margin-bottom: .25rem; }
.md-content table { margin: .75rem 0; }
.md-content blockquote { border-left: 3px solid var(--stone-dark); padding-left: .75rem; color: var(--slate-light); margin: .75rem 0; }
.md-content code { background: var(--stone); padding: .1rem .35rem; border-radius: 3px; font-size: .85em; }
.md-content pre code { display: block; padding: .75rem; overflow-x: auto; }
.md-content hr { border: none; border-top: 1px solid var(--stone-dark); margin: 1rem 0; }

/* --- Responsive --- */
@media (max-width: 768px) {
  .nav-inner { flex-wrap: wrap; height: auto; padding: .75rem 0; }
  .nav-links { order: 3; width: 100%; overflow-x: auto; }
  .form-row { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: 1fr; }
}
