:root {
  --bg-1: #f6efe4;
  --bg-2: #efe6d6;
  --card: #fff9ef;
  --ink: #2f2924;
  --accent: #0e7a62;
  --ok: #0d8f4a;
  --wait: #bd6f00;
  --line: #d8ccb8;
  --shadow: 0 16px 40px rgba(45, 37, 26, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Segoe UI', Tahoma, sans-serif;
  color: var(--ink);
  background: linear-gradient(140deg, var(--bg-1), var(--bg-2));
  min-height: 100vh;
  overflow-y: scroll;
}

.bg-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 15% 20%, rgba(240, 127, 62, 0.16), transparent 35%),
    radial-gradient(circle at 90% 90%, rgba(14, 122, 98, 0.2), transparent 35%);
}

.app-shell {
  width: min(1080px, calc(100% - 2rem));
  margin: 1.5rem auto 3rem;
  position: relative;
  z-index: 1;
  display: grid;
  gap: 1rem;
}

.site-head {
  padding: 1rem 1.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 1rem;
}

.site-head > div {
  min-width: 0;
}

.site-title {
  margin: 0;
}

.site-logo {
  display: block;
  margin-left: auto;
  width: min(260px, 34vw);
  max-height: 92px;
  height: auto;
  object-fit: contain;
  object-position: right center;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.auth-card {
  max-width: 420px;
  margin: 0 auto;
  padding: 2rem;
  width: 100%;
}

.auth-alt-actions {
  margin-top: 0.9rem;
  display: grid;
  justify-items: center;
  gap: 0.45rem;
}

.auth-separator {
  margin: 0;
  font-size: 0.9rem;
  color: #6e6251;
}

.register-cta-wrap {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.register-cta {
  display: block;
  width: min(420px, calc(100% - 1rem));
  margin: 0 auto;
}

h1, h2, h3 {
  margin: 0 0 0.6rem;
}

.hint {
  margin: 0 0 1rem;
  opacity: 0.85;
}

.hint.small {
  margin-top: -0.4rem;
  font-size: 0.9rem;
}

.stack {
  display: grid;
  gap: 0.9rem;
}

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.96rem;
}

input,
textarea {
  width: 100%;
  border: 1px solid #c7baa3;
  border-radius: 10px;
  padding: 0.68rem 0.75rem;
  background: #fffefb;
  font: inherit;
}

input:focus,
textarea:focus {
  outline: 2px solid rgba(14, 122, 98, 0.28);
  border-color: var(--accent);
}

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.62rem 0.95rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
}

.btn.register-primary {
  background: #1f67cf;
  color: #fff;
  border-color: #1854ab;
}

.btn.register-primary:hover {
  background: #1755ae;
}

.btn.ghost {
  background: #fff;
  color: var(--ink);
  border-color: #baa98e;
}

.link-btn {
  margin-top: 1rem;
  border: 0;
  background: none;
  color: #065c9f;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}

.hidden {
  display: none !important;
}

.topbar {
  margin-bottom: 1rem;
  padding: 1rem 1.2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
}

.topbar-actions {
  display: flex;
  gap: 0.6rem;
}

.auth-actions {
  justify-content: space-between;
}

.form-card {
  padding: 1.4rem;
}

.status-line {
  margin: 0;
}

.status-badge {
  margin-bottom: 1rem;
  padding: 0.45rem 0.65rem;
  display: inline-flex;
  border-radius: 999px;
  font-size: 0.82rem;
  letter-spacing: 0.03em;
  font-weight: 700;
}

.status-badge.approved {
  background: rgba(13, 143, 74, 0.16);
  color: var(--ok);
}

.status-badge.pending {
  background: rgba(189, 111, 0, 0.16);
  color: var(--wait);
}

.member-form {
  display: grid;
  gap: 0.85rem;
}

.member-form label.pending-change {
  background: #f4e3c9;
  border: 1px solid #c88629;
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
}

.two-col {
  display: grid;
  gap: 0.85rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.hint.inline {
  margin-top: 0;
  margin-bottom: 0;
}

.recaptcha-wrap {
  display: grid;
  gap: 0.35rem;
  justify-items: start;
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
}

.checkbox-row input[type='checkbox'] {
  width: auto;
  margin-top: 0.1rem;
}

.legal-link {
  margin-top: -0.1rem;
}

.actions-row {
  margin-top: 0.4rem;
  display: flex;
  gap: 0.6rem;
}

.actions-row.wrap {
  flex-wrap: wrap;
}

.admin-card {
  padding: 1.2rem;
}

.table-wrap {
  margin-top: 0.8rem;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  border-bottom: 1px solid var(--line);
  padding: 0.58rem;
  text-align: left;
  white-space: nowrap;
}

.status-chip {
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.2rem 0.5rem;
}

.status-chip.ok {
  color: var(--ok);
  background: rgba(13, 143, 74, 0.12);
}

.status-chip.pending {
  color: var(--wait);
  background: rgba(189, 111, 0, 0.12);
}

.status-chip.new-member {
  color: #b10022;
  background: rgba(177, 0, 34, 0.14);
}

.status-chip.role-admin {
  background: rgba(14, 122, 98, 0.16);
  color: #0d6b56;
}

.status-chip.role-member {
  background: rgba(58, 58, 58, 0.1);
  color: #2f2924;
}

.role-toggle-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.role-toggle-wrap input[type='checkbox'] {
  width: auto;
}

#bulkEmailBody {
  min-height: 180px;
  resize: vertical;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(33, 27, 21, 0.42);
  backdrop-filter: blur(3px);
}

#bulkEmailModal {
  z-index: 40;
}

#acceptanceModal {
  z-index: 45;
}

.modal-card {
  width: min(520px, 100%);
  padding: 1.4rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.modal-card h3 {
  margin-bottom: 0.5rem;
}

.modal-card p {
  margin: 0 0 1rem;
  line-height: 1.5;
}

.modal-autoclose {
  margin-top: 1.1rem;
  color: #6e6251;
}

.modal-card .actions-row {
  justify-content: center;
}

.modal-progress {
  width: 100%;
  height: 10px;
  margin-bottom: 1rem;
  background: rgba(14, 122, 98, 0.12);
  border-radius: 999px;
  overflow: hidden;
}

.modal-progress span {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #1f67cf, #0e7a62);
  transform-origin: left center;
}

#acceptanceModal.state-info .modal-card {
  border-color: #7f96bd;
  background: #f7fbff;
}

#acceptanceModal.state-success .modal-card {
  border-color: #73b98e;
  background: #f4fcf6;
}

#acceptanceModal.state-error .modal-card {
  border-color: #e0a0a0;
  background: #fff6f6;
}

#acceptanceModal.state-success h3 {
  color: #0d8f4a;
}

#acceptanceModal.state-error h3 {
  color: #b3261e;
}

#acceptanceModal.state-info .modal-progress {
  background: rgba(31, 103, 207, 0.15);
}

#acceptanceModal.state-success .modal-progress {
  background: rgba(13, 143, 74, 0.15);
}

#acceptanceModal.state-error .modal-progress {
  background: rgba(179, 38, 30, 0.18);
}

#acceptanceModal.state-info .modal-progress span {
  background: linear-gradient(90deg, #2f6ad9, #1e8fbe);
}

#acceptanceModal.state-success .modal-progress span {
  background: linear-gradient(90deg, #13a658, #0e7a62);
}

#acceptanceModal.state-error .modal-progress span {
  background: linear-gradient(90deg, #d23c34, #b3261e);
}

@media (max-width: 760px) {
  .app-shell {
    width: calc(100% - 1rem);
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-actions {
    width: 100%;
  }

  .topbar-actions .btn {
    flex: 1;
  }

  .site-head {
    align-items: center;
  }

  .site-logo {
    width: min(200px, 42vw);
    max-height: 68px;
  }

  .form-card,
  .admin-card {
    padding: 1rem;
  }

  .two-col {
    grid-template-columns: 1fr;
  }
}

/* Footer */
.app-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem;
  background: linear-gradient(to top, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.85));
  border-top: 1px solid #e0e0e0;
  font-size: 0.9rem;
  color: #666;
  z-index: 10;
  box-sizing: border-box;
}

.app-footer p {
  margin: 0;
  font-weight: 500;
  letter-spacing: 0.3px;
}

body {
  padding-bottom: 4rem;
}
