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

/* ── MEMBERSHIP REGISTRATION — BLUE THEME ── */
:root {
  --blue-950:      #0a1628;
  --blue-900:      #0f2744;
  --blue-800:      #1e4d8c;
  --blue-700:      #2563eb;
  --blue-600:      #3b82f6;
  --blue-500:      #60a5fa;
  --blue-200:      #bfdbfe;
  --blue-100:      #dbeafe;
  --blue-50:       #eff6ff;
  --surface:       #f4f8fc;
  --paper:         #ffffff;
  --white:         #ffffff;
  --ink:           #0f172a;
  --ink-muted:     #64748b;
  --line:          #e2e8f0;
  --line-strong:   #cbd5e1;
  --accent:        #0284c7;
  --success:       #15803d;
  --danger:        #dc2626;
  --warn:          #b45309;
  --sidebar-w:     260px;
  --font-display:  'Sora', system-ui, sans-serif;
  --font-ui:       'Plus Jakarta Sans', system-ui, sans-serif;
  --radius:        8px;
  --radius-lg:     12px;
}

html { font-size: 15px; height: 100%; }

body {
  font-family: var(--font-ui);
  background: var(--surface);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

body.page-table {
  height: 100vh;
  overflow: hidden;
}

body.modal-open { overflow: hidden; }

/* ── APP SHELL (sidebar layout) ── */
.app-shell--sidebar {
  display: flex;
  min-height: 100vh;
  height: 100vh;
}

.app-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.app-main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--blue-900) 0%, var(--blue-950) 100%);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  z-index: 1200;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: #fff;
  padding: 8px 10px 20px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-brand-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: rgba(96, 165, 250, 0.2);
  border-radius: var(--radius);
  color: var(--blue-200);
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.sidebar-brand-text strong {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
}

.sidebar-brand-text small {
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--blue-500);
  margin-top: 3px;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.sidebar-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: rgba(255, 255, 255, 0.4);
  padding: 14px 10px 6px;
}

.sidebar-link {
  display: block;
  font-size: 0.84rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.78);
  text-decoration: none;
  padding: 10px 12px;
  border-radius: var(--radius);
  margin-bottom: 2px;
  border-left: 3px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.sidebar-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-link.is-active {
  color: #fff;
  background: rgba(37, 99, 235, 0.35);
  border-left-color: var(--blue-500);
  font-weight: 600;
}

.sidebar-archives {
  margin-top: 4px;
}

.sidebar-archives-trigger {
  list-style: none;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.65);
  padding: 8px 12px;
  border-radius: var(--radius);
  user-select: none;
}

.sidebar-archives-trigger::-webkit-details-marker { display: none; }
.sidebar-archives-trigger::marker { content: ''; }

.sidebar-archives[open] .sidebar-archives-trigger,
.sidebar-archives-trigger:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.sidebar-archives-menu {
  padding: 4px 0 4px 8px;
}

.sidebar-archives-link {
  font-size: 0.8rem;
  padding: 8px 12px 8px 16px;
}

.sidebar-footer {
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin-top: auto;
}

.sidebar-user {
  padding: 0 10px 12px;
}

.sidebar-user-name {
  display: block;
  font-size: 0.86rem;
  font-weight: 600;
  color: #fff;
}

.sidebar-user-role {
  display: block;
  font-size: 0.72rem;
  color: var(--blue-500);
  margin-top: 2px;
}

.sidebar-logout {
  display: block;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--blue-900);
  background: #fff;
  text-decoration: none;
  padding: 10px 14px;
  border-radius: var(--radius);
  transition: background 0.15s;
}

.sidebar-logout:hover {
  background: var(--blue-100);
}

/* ── PAGE SHELL ── */
.page-shell {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 20px 24px 24px;
}

.container {
  max-width: 100%;
  height: 100%;
  margin: 0 auto;
}

/* ── CARD ── */
.card {
  background: var(--paper);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  box-shadow: 0 4px 24px rgba(15, 39, 68, 0.06);
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

/* ── PAGE HEADER ── */
.page-header {
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 26px;
  background: linear-gradient(135deg, var(--blue-800) 0%, var(--blue-700) 100%);
  color: #fff;
}

.page-header-archive {
  background: linear-gradient(135deg, var(--blue-950) 0%, var(--blue-900) 100%);
}

.page-header-text {
  min-width: 0;
}

.page-eyebrow {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--blue-200);
  margin-bottom: 6px;
}

.page-header-archive .page-eyebrow {
  color: #fde68a;
}

.page-title {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.25;
  margin: 0;
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
  padding-top: 4px;
}

.result-count {
  display: inline-block;
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--blue-100);
  margin-left: 10px;
  vertical-align: middle;
  padding: 3px 11px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 999px;
}

/* ── TOOLBAR ── */
.table-toolbar {
  flex-shrink: 0;
  padding: 16px 26px;
  background: var(--blue-50);
  border-bottom: 1px solid var(--line);
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  width: 100%;
}

.search-box {
  display: flex;
  align-items: center;
  flex: 1 1 280px;
  min-width: 200px;
  max-width: 520px;
  position: relative;
}

.search-icon {
  position: absolute;
  left: 14px;
  color: var(--ink-muted);
  pointer-events: none;
}

.search-box input {
  font-family: var(--font-ui);
  font-size: 0.88rem;
  padding: 11px 14px 11px 42px;
  width: 100%;
  background: var(--white);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-box input::placeholder { color: var(--ink-muted); opacity: 0.75; }

.search-box input:focus {
  border-color: var(--blue-600);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.clear-btn {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 10px 16px;
  background: var(--white);
  color: var(--blue-800);
  text-decoration: none;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  transition: all 0.15s;
  flex-shrink: 0;
  white-space: nowrap;
}

.clear-btn:hover {
  background: var(--blue-100);
  border-color: var(--blue-600);
}

/* ── FILTER ── */
.filter-wrap { position: relative; flex-shrink: 0; }

.btn-filter {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--blue-800);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn-filter:hover,
.btn-filter[aria-expanded="true"] {
  background: var(--blue-100);
  border-color: var(--blue-600);
  color: var(--blue-900);
}

.filter-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 300px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 40px rgba(10, 22, 40, 0.12);
  padding: 16px;
  z-index: 200;
}

.filter-dropdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--blue-900);
}

.filter-clear {
  background: none;
  border: none;
  color: var(--blue-700);
  font-size: 0.76rem;
  cursor: pointer;
  text-decoration: underline;
}

.filter-group { margin-bottom: 12px; }

.filter-group label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 5px;
}

.filter-group select,
.filter-group input[type="date"] {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: var(--font-ui);
  font-size: 0.84rem;
  background: var(--surface);
}

.date-range { display: flex; gap: 8px; }
.date-range input { flex: 1; }

.btn-sm { padding: 7px 14px; font-size: 0.8rem; }

/* ── TABLE ── */
.table-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 18px 26px 22px;
  background: var(--white);
}

.table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.table-scroll.is-loading {
  opacity: 0.55;
  pointer-events: none;
}

.table-error {
  margin: 0 26px 10px;
  padding: 11px 14px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-left: 4px solid var(--danger);
  border-radius: var(--radius);
  color: var(--blue-900);
  font-size: 0.86rem;
}

.table-error[hidden] { display: none; }

#data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

#data-table thead {
  position: sticky;
  top: 0;
  z-index: 20;
}

#data-table th {
  padding: 12px 16px;
  text-align: left;
  color: var(--blue-900);
  font-weight: 700;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
  background: var(--blue-50);
  border-bottom: 2px solid var(--blue-600);
}

.th-actions { width: 96px; text-align: center; }

#data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  vertical-align: middle;
  background: var(--white);
}

#data-table tbody tr:last-child td { border-bottom: none; }
#data-table tbody tr:nth-child(even) td { background: #f8fafc; }
#data-table tbody tr:hover td { background: var(--blue-50); }

/* ── BADGES ── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.badge-admin    { background: #ede9fe; color: #5b21b6; }
.badge-member   { background: var(--blue-100); color: var(--blue-800); }
.badge-active   { background: #dcfce7; color: var(--success); }
.badge-inactive { background: #fee2e2; color: var(--danger); }
.badge-pending  { background: #fef3c7; color: var(--warn); }
.badge-yes      { background: #dcfce7; color: var(--success); }
.badge-no       { background: #fee2e2; color: var(--danger); }

.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--ink-muted);
  font-size: 0.9rem;
}

/* ── LOGIN (split panel) ── */
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.login-panel-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  background: linear-gradient(160deg, var(--blue-800) 0%, var(--blue-950) 100%);
  color: #fff;
}

.login-brand-inner {
  max-width: 380px;
}

.login-brand-icon {
  width: 72px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  margin-bottom: 28px;
  color: var(--blue-200);
}

.login-brand-inner h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 14px;
}

.login-brand-inner p {
  font-size: 0.95rem;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.75);
}

.login-panel-form {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 32px;
  background: var(--surface);
}

.login-container {
  width: 100%;
  max-width: 400px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(15, 39, 68, 0.08);
  overflow: hidden;
}

.login-header {
  padding: 28px 28px 0;
}

.login-header h2 {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--blue-900);
  margin-bottom: 6px;
}

.login-header p {
  font-size: 0.88rem;
  color: var(--ink-muted);
}

.login-body { padding: 24px 28px 28px; }

.form-group { margin-bottom: 18px; }

.form-group label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font-family: var(--font-ui);
  font-size: 0.92rem;
  color: var(--ink);
  background: var(--surface);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.form-group input:focus {
  border-color: var(--blue-600);
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.login-body button {
  width: 100%;
  padding: 13px;
  background: var(--blue-700);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 0.92rem;
  transition: background 0.2s;
  margin-top: 6px;
}

.login-body button:hover { background: var(--blue-800); }

.login-hint {
  text-align: center;
  color: var(--ink-muted);
  font-size: 0.76rem;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.login-hint code {
  background: var(--blue-50);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 0.74rem;
  color: var(--blue-800);
}

.error {
  color: var(--danger);
  margin-bottom: 16px;
  padding: 11px 12px;
  background: #fef2f2;
  border-radius: var(--radius);
  border-left: 3px solid var(--danger);
  font-size: 0.85rem;
}

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.page-header .btn-primary {
  background: #fff;
  color: var(--blue-800);
}

.page-header .btn-primary:hover {
  background: var(--blue-50);
}

.page-header .btn-secondary {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.45);
}

.page-header .btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: #fff;
}

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

.btn-primary:hover { background: var(--blue-800); }

.btn-secondary {
  background: var(--white);
  color: var(--blue-800);
  border: 1px solid var(--line-strong);
}

.btn-secondary:hover {
  background: var(--blue-50);
  border-color: var(--blue-600);
}

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

.btn-danger:hover { background: #b91c1c; }

.actions-cell {
  white-space: nowrap;
  text-align: center;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
  margin: 0 1px;
  transition: background 0.15s, color 0.15s;
}

.btn-edit:hover { background: var(--blue-100); color: var(--blue-800); }
.btn-delete:hover { background: #fee2e2; color: var(--danger); }
.btn-restore:hover { background: #dcfce7; color: var(--success); }

/* ── MODALS ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 22, 40, 0.55);
  z-index: 2000;
  align-items: flex-start;
  justify-content: center;
  padding: 32px 20px;
  overflow-y: auto;
  pointer-events: none;
  visibility: hidden;
}

.modal-overlay:not([hidden]) {
  display: flex;
  pointer-events: auto;
  visibility: visible;
}

.modal-overlay[hidden] {
  display: none !important;
  pointer-events: none !important;
  visibility: hidden !important;
}

.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 64px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 56px rgba(10, 22, 40, 0.2);
  margin: auto;
  border: 1px solid var(--line);
}

#record-form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.modal-sm { max-width: 400px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  background: linear-gradient(135deg, var(--blue-800) 0%, var(--blue-700) 100%);
  color: #fff;
}

.modal-header h3 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  color: var(--blue-200);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

.modal-close:hover { color: #fff; }

.modal-body {
  padding: 22px;
  overflow-y: auto;
  flex: 1;
  min-height: 120px;
  max-height: calc(100vh - 220px);
  -webkit-overflow-scrolling: touch;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  background: var(--blue-50);
  flex-shrink: 0;
}

.modal-body .form-group { margin-bottom: 14px; }

.modal-body .form-group label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 5px;
}

.modal-body input,
.modal-body select,
.modal-body textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: var(--font-ui);
  font-size: 0.88rem;
  color: var(--ink);
  background: var(--surface);
}

.modal-body input:focus,
.modal-body select:focus,
.modal-body textarea:focus {
  border-color: var(--blue-600);
  background: var(--white);
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.modal-body input.invalid,
.modal-body select.invalid,
.modal-body textarea.invalid {
  border-color: var(--danger);
}

.field-error {
  display: block;
  color: var(--danger);
  font-size: 0.76rem;
  margin-top: 4px;
}

.restore-error {
  margin-top: 14px;
  padding: 11px 12px;
  background: #fef2f2;
  border-radius: var(--radius);
  border-left: 3px solid var(--danger);
  color: var(--danger);
  font-size: 0.85rem;
  line-height: 1.45;
}

.restore-error[hidden] { display: none; }

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .login-page {
    grid-template-columns: 1fr;
  }

  .login-panel-brand {
    padding: 36px 28px;
    min-height: auto;
  }

  .login-brand-inner h1 {
    font-size: 1.5rem;
  }
}

@media (max-width: 768px) {
  .app-shell--sidebar {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
  }

  .sidebar {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 12px;
    align-items: center;
  }

  .sidebar-brand {
    flex: 1;
    padding: 4px 8px 12px;
    margin-bottom: 0;
    border-bottom: none;
  }

  .sidebar-nav {
    order: 3;
    flex-basis: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding-top: 8px;
  }

  .sidebar-section-label { display: none; }

  .sidebar-link {
    font-size: 0.78rem;
    padding: 8px 10px;
  }

  .sidebar-archives { width: 100%; }

  .sidebar-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    border-top: none;
    padding-top: 0;
  }

  .sidebar-user { padding: 0 8px; }

  body.page-table {
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }

  .app-shell--sidebar { height: auto; }
}

@media (max-width: 640px) {
  .page-header {
    flex-direction: column;
    gap: 14px;
  }

  .page-header-actions {
    justify-content: flex-start;
    width: 100%;
  }

  .page-title { font-size: 1.3rem; }

  .table-toolbar,
  .table-scroll,
  .page-shell { padding-left: 14px; padding-right: 14px; }
}
