/* ============================================================
   Geeta Ashram Suite — Design System
   ============================================================ */

:root {
  --brand-900: #431407;
  --brand-800: #5c2410;
  --brand-700: #7c2d12;
  --brand-600: #9a3412;
  --brand-500: #c2410c;
  --brand-400: #ea580c;
  --brand-300: #fb923c;
  --brand-200: #fed7aa;
  --brand-100: #ffedd5;
  --brand-50:  #fff7ed;

  --sidebar-bg:           #431407;
  --sidebar-w:            232px;
  --sidebar-text:         rgba(255, 248, 240, 0.82);
  --sidebar-text-strong:  #fff8f0;
  --sidebar-hover:        rgba(255, 255, 255, 0.07);
  --sidebar-active-bg:    rgba(234, 88, 12, 0.25);
  --sidebar-active-bar:   #ea580c;
  --sidebar-border:       rgba(255, 255, 255, 0.1);

  --topbar-h:   48px;
  --topbar-bg:  #431407;

  --bg:             #faf8f5;
  --surface:        #ffffff;
  --surface-alt:    #fffdf9;
  --text:           #1c1412;
  --text-secondary: #6b5046;
  --text-muted:     #9c7d6e;
  --border:         #e8d5c4;
  --border-strong:  #d4b49e;

  --primary:       #c2410c;
  --primary-hover: #9a3412;
  --danger:        #dc2626;
  --danger-hover:  #b91c1c;

  --shadow-xs: 0 1px 2px rgba(67, 20, 7, 0.06);
  --shadow-sm: 0 1px 4px rgba(67, 20, 7, 0.09), 0 1px 2px rgba(67, 20, 7, 0.06);
  --shadow-md: 0 4px 16px rgba(67, 20, 7, 0.10);
  --shadow-lg: 0 8px 32px rgba(67, 20, 7, 0.13);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
}

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

body {
  margin: 0;
  min-height: 100vh;
}

/* ============================================================
   Layout: Sidebar + Main
   ============================================================ */

.layout {
  display: flex;
  min-height: 100vh;
}

/* ============================================================
   Sidebar
   ============================================================ */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  transition: transform 0.25s ease;
}

.sidebar-brand {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-brand a {
  color: var(--sidebar-text-strong);
  text-decoration: none;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: block;
}

.sidebar-brand a:hover {
  color: var(--brand-200);
}

.sidebar-nav {
  flex: 1;
  padding: 0.65rem 0;
  display: flex;
  flex-direction: column;
}

.sidebar-link {
  display: block;
  padding: 0.6rem 1.25rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: background 0.12s ease, color 0.12s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-link:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-strong);
}

.sidebar-link.active {
  background: var(--sidebar-active-bg);
  border-left-color: var(--sidebar-active-bar);
  color: #fff;
  font-weight: 600;
}

.sidebar-footer {
  padding: 0.85rem 1rem;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  flex: 1;
  min-width: 0;
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.4rem;
  transition: background 0.12s ease;
}

.sidebar-user:hover {
  background: var(--sidebar-hover);
}

.sidebar-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--brand-600);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1.5px solid rgba(255,255,255,0.2);
}

.sidebar-username {
  color: var(--sidebar-text);
  font-size: 0.82rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.sidebar-user:hover .sidebar-username {
  color: var(--sidebar-text-strong);
}

.sidebar-logout-form {
  display: inline;
  margin: 0;
  flex-shrink: 0;
}

.sidebar-logout-btn {
  background: none;
  border: none;
  color: rgba(255,248,240,0.5);
  cursor: pointer;
  padding: 0.3rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s ease, color 0.12s ease;
  font-size: 1rem;
  line-height: 1;
}

.sidebar-logout-btn:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

/* ============================================================
   Sidebar overlay (mobile)
   ============================================================ */

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 99;
  -webkit-backdrop-filter: blur(1px);
  backdrop-filter: blur(1px);
}

.sidebar-overlay.visible {
  display: block;
}

/* ============================================================
   Main wrap + Topbar
   ============================================================ */

.main-wrap {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: none;
  align-items: center;
  gap: 0.75rem;
  height: var(--topbar-h);
  background: var(--topbar-bg);
  padding: 0 1rem;
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 50;
  flex-shrink: 0;
}

.topbar-brand {
  color: #fff8f0;
  text-decoration: none;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.02em;
}

.hamburger {
  background: none;
  border: none;
  padding: 0.4rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: #fff8f0;
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
  transform-origin: center;
}

.hamburger.open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* ============================================================
   Content area
   ============================================================ */

.content {
  flex: 1;
  padding: 1.75rem 2rem 3rem;
  max-width: 1280px;
  width: 100%;
}

/* ============================================================
   Typography
   ============================================================ */

h1 {
  margin-top: 0;
  margin-bottom: 0.35rem;
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--brand-900);
}

h1.inline-title {
  color: var(--brand-900);
}

h2 {
  font-size: 1.1rem;
  font-weight: 650;
  color: var(--brand-800);
  letter-spacing: -0.01em;
  margin-top: 1.75rem;
  margin-bottom: 0.5rem;
}

h2:first-child { margin-top: 0; }

h3 {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--brand-700);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 1.1rem;
  margin-bottom: 0.35rem;
}

code, kbd {
  font-family: ui-monospace, "SF Mono", Menlo, Monaco, "Courier New", monospace;
  font-size: 0.88em;
  background: var(--brand-50);
  padding: 0.12em 0.35em;
  border-radius: 4px;
  border: 1px solid var(--border);
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

/* ============================================================
   Buttons
   ============================================================ */

/* Shared shape for all button variants */
.button,
.danger,
main form button[type="submit"]:not(.danger):not(.button):not(.link) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.5rem 1.1rem;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  border: 1.5px solid transparent;
  line-height: 1.4;
  letter-spacing: 0.01em;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
  -webkit-font-smoothing: antialiased;
}

/* Primary — outlined brand */
.button,
main form button[type="submit"]:not(.danger):not(.button):not(.link) {
  background: var(--surface);
  color: var(--primary);
  border-color: var(--primary);
  box-shadow: none;
}

.button:hover,
main form button[type="submit"]:not(.danger):not(.button):not(.link):hover {
  background: #fff4ee;
  border-color: var(--primary-hover);
  color: var(--primary-hover);
  box-shadow: none;
  text-decoration: none;
}

.button:focus-visible,
main form button[type="submit"]:not(.danger):not(.button):not(.link):focus-visible {
  outline: 2px solid var(--brand-300);
  outline-offset: 2px;
}

/* Secondary — outlined neutral */
.button.secondary {
  background: var(--surface);
  color: var(--text-secondary);
  border-color: var(--border-strong);
  box-shadow: none;
}

.button.secondary:hover {
  background: var(--surface-raised);
  border-color: var(--border-strong);
  color: var(--text-primary);
  box-shadow: none;
  text-decoration: none;
}

/* Disabled state */
.button:disabled,
.button[disabled],
main form button[type="submit"]:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* Danger — outlined red */
.danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
  box-shadow: none;
}

.danger:hover {
  background: var(--danger);
  color: #fff;
  text-decoration: none;
}

.danger:focus-visible {
  outline: 2px solid #f87171;
  outline-offset: 2px;
}

/* Plain text link escape hatch */
button.link {
  background: none;
  border: none;
  box-shadow: none;
  padding: 0;
  color: var(--primary);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  display: inline;
}

/* ============================================================
   Forms
   ============================================================ */

/* Stack label text above input in data-entry forms */
form:not(.search-inline):not(.filters):not(.inline-add-form) label:not(.inline):not(.pub-check-row):not(.bundle-pub-check) {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 1.1rem;
  max-width: 28rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Hide <br> inside form labels — flex-column handles the stack */
form:not(.search-inline):not(.filters) label:not(.inline):not(.pub-check-row):not(.bundle-pub-check) > br {
  display: none;
}

/* Input / select / textarea shared styles */
.filters input,
.filters select,
form input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="color"]),
form select,
form textarea {
  padding: 0.48rem 0.65rem;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font: inherit;
  font-size: 1rem; /* ≥16px prevents iOS Safari zoom-on-focus */
  color: var(--text);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

/* Max-width caps in forms (not filters) */
form input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="color"]),
form select,
form textarea {
  width: 100%;
  max-width: 28rem;
}

form input[type="number"] {
  max-width: 10rem;
}

form input[type="date"] {
  max-width: 13rem;
}

form textarea {
  resize: vertical;
  line-height: 1.55;
}

/* Focus ring */
.filters input:focus-visible,
.filters select:focus-visible,
form input:focus-visible,
form select:focus-visible,
form textarea:focus-visible {
  outline: none;
  border-color: var(--brand-400);
  box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.15);
}

/* Strip native OS select chrome so CSS padding controls height consistently
   across macOS Safari, Chrome, Firefox, and iOS. */
.filters select,
form select,
.search-inline select,
.inline-add-form select {
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 10'%3E%3Cpath d='M1 1.5l7 7 7-7' stroke='%236b5046' stroke-width='1.8' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.55rem center;
  background-size: 0.7rem;
  padding-right: 2rem;
}

/* Search inline filter bar */
.search-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.65rem 1rem;
  margin: 0.75rem 0 1.1rem;
  padding: 1rem 1.15rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.search-inline label {
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 6.5rem;
}

.search-inline input,
.search-inline select {
  max-width: 12rem;
  min-width: 8.5rem;
  width: auto;
}

.search-inline .button {
  align-self: flex-end;
}

.sales-filters .search-inline label {
  min-width: 5.5rem;
}

/* Inline add form — compact horizontal form inside panels */
.inline-add-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
  margin-top: 0.85rem;
}

.inline-add-form label {
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.inline-add-form input,
.inline-add-form select {
  width: auto;
}

/* Field rows (phone / email pair) */
.field-row {
  display: grid;
  grid-template-columns: 1fr 10rem;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
  align-items: center;
  max-width: 28rem;
}

.field-row input {
  width: 100%;
  max-width: none;
  padding: 0.42rem 0.55rem;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font: inherit;
}

/* Two / three column form grids */
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1.5rem;
  max-width: 52rem;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0 1rem;
  max-width: 28rem;
}

/* Danger zone separator (delete forms at bottom of pages) */
.form-danger-section {
  margin-top: 2.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

/* ============================================================
   Inline toolbar (list page headers)
   ============================================================ */

.inline-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.inline-toolbar .inline-title {
  margin: 0;
  font-size: 1.45rem;
}

.inline-toolbar .inline-actions {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

/* ============================================================
   Search panel (Publications / Sales tab wrapper)
   ============================================================ */

.search-panel {
  /* intentional — acts as a logical grouping container */
}

/* ============================================================
   Tables
   ============================================================ */

table.data {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
}

table.data th,
table.data td {
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 0.55rem 0.75rem;
  text-align: left;
  font-size: 0.9rem;
}

table.data tbody tr:last-child td {
  border-bottom: none;
}

table.data thead {
  background: linear-gradient(180deg, #ffedd5 0%, #fed7aa 100%);
}

table.data thead th {
  color: var(--brand-700);
  font-weight: 700;
  border-bottom: 1px solid var(--border-strong);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

table.data tbody tr:nth-child(even) td {
  background: #fffaf5;
}

table.data tbody tr:hover td {
  background: #fff4e6 !important;
}

table.data a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}

table.data a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0.5rem 0 1rem;
  max-width: 100%;
  border-radius: var(--radius-md);
}

.table-scroll table.data {
  min-width: 42rem;
}

/* Lapsed member rows */
tr.row-lapsed td {
  background: #fffbeb;
}

/* Table action links */
a.table-action,
button.table-action,
button.table-action-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 1.75rem;
  padding: 0 0.6rem;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  box-sizing: border-box;
  box-shadow: none;
  -webkit-appearance: none;
  appearance: none;
}

a.table-action,
button.table-action {
  background: var(--surface);
  color: var(--text-secondary);
  border: 1.5px solid var(--border-strong);
}

a.table-action:hover,
button.table-action:hover {
  background: var(--surface-raised);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

button.table-action-delete {
  background: transparent;
  color: var(--danger);
  border: 1.5px solid var(--danger);
}

button.table-action-delete:hover {
  background: #fef2f2;
}

/* ============================================================
   Dashboard
   ============================================================ */

.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1.25rem;
}

.dash-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.2rem 1.35rem 1.4rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.dash-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.dash-card h2 {
  margin: 0 0 0.15rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.dash-card h2 a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.12s ease;
}

.dash-card h2 a:hover {
  color: var(--primary);
}

.dash-count {
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--brand-400);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.dash-card .hint {
  font-size: 0.82rem;
}

.dash-card .button {
  align-self: flex-start;
  margin-top: auto;
  font-size: 0.82rem;
  padding: 0.35rem 0.75rem;
}

/* ============================================================
   Badges
   ============================================================ */

.badge {
  display: inline-block;
  padding: 0.2em 0.65em;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.025em;
  white-space: nowrap;
}

.badge-active     { background: #d1fae5; color: #065f46; }
.badge-lapsed     { background: #fef3c7; color: #92400e; }
.badge-historical { background: #f3f4f6; color: #4b5563; }
.badge-devotee    { background: #dbeafe; color: #1e40af; }
.badge-family     { background: #ede9fe; color: #5b21b6; }
.badge-non-member { background: #f9fafb; color: #6b7280; border: 1px solid #e5e7eb; }
.badge-duplicate  { background: #ffedd5; color: #9a3412; }
.badge-pruned     { background: #1f2937; color: #d1d5db; }

/* Status banners */
.status-banner {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  font-size: .9rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
}
.status-banner-pruned {
  background: #fef2f2;
  border: 1.5px solid #fca5a5;
  color: #7f1d1d;
}
.status-banner-duplicate {
  background: #fffbeb;
  border: 1.5px solid #fcd34d;
  color: #78350f;
}

/* ============================================================
   Text utilities
   ============================================================ */

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

.error {
  color: #b91c1c;
  font-weight: 500;
}

.lapsed-alert {
  color: #92400e;
  font-weight: 500;
}

.row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

label.inline {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-right: 1rem;
}

/* ============================================================
   Member detail — section sub-headings and helpers
   ============================================================ */

/* Family-of indicator banner */
.family-of-indicator {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.65rem;
  margin-bottom: 0.75rem;
  padding: 0.45rem 0.8rem;
  background: #f5f3ff;
  border-left: 3px solid #7c3aed;
  border-radius: var(--radius-sm);
  max-width: 52rem;
  font-size: 0.875rem;
}

.family-of-label {
  color: #5b21b6;
  font-weight: 700;
}

.family-of-indicator a {
  color: #6d28d9;
  text-decoration: none;
  font-weight: 500;
}

.family-of-indicator a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Address section label */
.address-label {
  margin: 0.35rem 0 0.2rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
}

/* ============================================================
   HTMX loading indicator
   ============================================================ */

.htmx-indicator {
  visibility: hidden;
  opacity: 0.75;
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.htmx-indicator.htmx-request {
  visibility: visible;
}

/* ============================================================
   Export row
   ============================================================ */

.export-row-inline {
  margin: 0.75rem 0 0.5rem;
}

/* ============================================================
   Link lists (Reports page)
   ============================================================ */

.links {
  line-height: 2;
  padding-left: 0;
  list-style: none;
}

.links li {
  padding: 0.1rem 0;
  border-bottom: 1px solid var(--border);
}

.links li:last-child {
  border-bottom: none;
}

.links a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}

.links a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
  text-underline-offset: 2px;
}

fieldset {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem 1rem;
}

legend {
  color: var(--brand-700);
  font-weight: 600;
  padding: 0 0.35rem;
  font-size: 0.9rem;
}

/* ============================================================
   Tabbed navigation (Imports)
   ============================================================ */

.tab-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.25rem;
}

.tab-nav a {
  padding: 0.5rem 1.1rem 0.5rem 0;
  margin-right: 1.1rem;
  text-decoration: none;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.9rem;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  background: none;
  transition: color 0.12s ease;
}

.tab-nav a:hover {
  color: var(--primary);
}

.tab-nav a.active {
  color: var(--primary);
  font-weight: 700;
  border-bottom-color: var(--primary);
}

/* ============================================================
   Member multi-select
   ============================================================ */

.member-multiselect {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  background: var(--surface);
}

.member-multiselect label.inline {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.1rem 0;
}

/* ============================================================
   Member section (detail page fieldset cards)
   ============================================================ */

.member-section {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 1.15rem 1.4rem 1.5rem;
  margin-bottom: 1.5rem;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.member-section legend {
  color: var(--brand-700);
  font-weight: 650;
  font-size: 1rem;
  padding: 0 0.35rem;
}

/* ============================================================
   Summary tables
   ============================================================ */

.summary-table {
  margin: 0.5rem 0 1rem;
}

/* ============================================================
   Sale publication checklist
   ============================================================ */

.sale-pub-fieldset {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem 1rem;
  margin: 0 0 1.15rem;
}

.sale-pub-hint {
  margin-top: 0;
}

.pub-checklist {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.pub-check-row {
  display: grid;
  grid-template-columns: 1.1rem 1fr;
  column-gap: 0.45rem;
  row-gap: 0.15rem;
  align-items: start;
  margin: 0.2rem 0;
  cursor: pointer;
}

.pub-check-row input[type="checkbox"] {
  margin: 0.2rem 0 0;
  flex-shrink: 0;
}

.pub-check-label {
  line-height: 1.35;
}

.sale-selection-total {
  font-weight: 650;
  color: var(--brand-700);
  margin: 0.35rem 0 0.5rem;
  font-size: 0.95rem;
}

/* ============================================================
   New member bundle
   ============================================================ */

.bundle-main-form {
  flex-direction: column;
  align-items: flex-start;
  max-width: 42rem;
}

.bundle-pub-fieldset {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem 1rem;
  margin: 0 0 1.15rem;
  width: 100%;
}

.bundle-pub-hint {
  margin-top: 0;
}

.bundle-pub-table {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0.5rem 0 0;
}

.bundle-pub-row {
  display: grid;
  grid-template-columns: 1.25rem 1fr auto;
  gap: 0.4rem 0.65rem;
  align-items: center;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}

.bundle-pub-row.missing {
  background: #fff8f4;
  border-color: #fcd34d;
}

.bundle-pub-check input[type="checkbox"] {
  margin: 0;
}

.bundle-pub-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.bundle-pub-title {
  font-weight: 600;
  color: var(--brand-900);
  word-break: break-word;
}

.bundle-pub-stock {
  font-size: 0.88em;
  color: var(--text-muted);
}

.bundle-pub-missing {
  font-size: 0.88em;
  color: var(--danger);
}

.bundle-pub-actions {
  align-self: start;
}

.bundle-remove-btn {
  padding: 0.28rem 0.55rem;
  font-size: 0.82rem;
  white-space: nowrap;
}

.inline-delete-form {
  margin: 0;
  display: inline-flex;
  align-items: center;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: nowrap;
}

/* ============================================================
   Welcome add block (new member bundle)
   ============================================================ */

.welcome-add-block {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px dashed var(--border-strong);
}

.welcome-add-label {
  margin: 0 0 0.4rem;
  font-weight: 600;
  color: var(--brand-700);
  font-size: 0.95rem;
}

.welcome-add-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
}

.welcome-add-form input[type="text"] {
  flex: 1 1 12rem;
  min-width: 0;
  padding: 0.48rem 0.6rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
}

.welcome-add-note {
  margin: 0.45rem 0 0;
  font-size: 0.88em;
  color: var(--text-muted);
}

/* ============================================================
   Centered layout (login / setup pages)
   ============================================================ */

.centered {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  background: var(--brand-900);
  background-image:
    radial-gradient(ellipse 80% 60% at 50% -10%, #7c2d12 0%, transparent 60%),
    linear-gradient(180deg, #431407 0%, #2d0c04 100%);
  padding: max(1rem, env(safe-area-inset-top, 0px))
           max(1rem, env(safe-area-inset-right, 0px))
           max(1rem, env(safe-area-inset-bottom, 0px))
           max(1rem, env(safe-area-inset-left, 0px));
}

.card {
  background: var(--surface);
  padding: 2.25rem 2.5rem 2.5rem;
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.05);
  width: min(440px, 94vw);
}

.card-brand {
  text-align: center;
  margin-bottom: 2rem;
}

.card-brand-name {
  display: block;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--brand-900);
  letter-spacing: -0.03em;
  margin-bottom: 0.25rem;
}

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

.centered .card form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 1.15rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.centered .card input[type="password"],
.centered .card input[type="email"],
.centered .card input[type="text"] {
  display: block;
  width: 100%;
  padding: 0.65rem 0.8rem;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.95rem;
  background: #fffefb;
  color: var(--text);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.centered .card input:focus-visible {
  outline: none;
  border-color: var(--brand-400);
  box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.18);
}

.card-submit {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.75rem 1rem;
  background: var(--brand-500);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(194, 65, 12, 0.35);
  transition: background 0.12s ease, box-shadow 0.12s ease;
}

.card-submit:hover {
  background: var(--brand-600);
  box-shadow: 0 4px 18px rgba(154, 52, 18, 0.45);
}

.card-submit:focus-visible {
  outline: 2px solid var(--brand-300);
  outline-offset: 2px;
}

.card-footer {
  margin-top: 1.1rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.card-footer a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}

.card-footer a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ============================================================
   Touch / mobile targets
   ============================================================ */

@media (hover: none) and (pointer: coarse) {
  .button,
  .danger,
  main form button[type="submit"]:not(.danger):not(.button):not(.link) {
    min-height: 44px;
  }

  /* Hamburger: expand hit area to 44×44 without making the icon bigger */
  .hamburger {
    min-width: 44px;
    min-height: 44px;
    justify-content: center;
    align-items: center;
    padding: 0;
  }

  /* Table row action buttons */
  a.table-action,
  button.table-action,
  button.table-action-delete {
    min-height: 44px;
    padding: 0 0.85rem;
  }

  /* Sidebar logout */
  .sidebar-logout-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  label.inline {
    min-height: 44px;
    padding: 0.2rem 0;
  }

  .pub-check-row input[type="checkbox"],
  .bundle-pub-check input[type="checkbox"] {
    width: 1.15rem;
    height: 1.15rem;
  }
}

/* ============================================================
   Responsive: tablet / mobile
   ============================================================ */

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(calc(-1 * var(--sidebar-w)));
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .topbar {
    display: flex;
  }

  .main-wrap {
    margin-left: 0;
  }

  .content {
    padding: 1.1rem 1rem 2rem;
  }

  .inline-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
  }

  .inline-toolbar .inline-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
  }

  table.data th,
  table.data td {
    padding: 0.55rem 0.6rem;
    font-size: 0.85rem;
  }

  /* iOS notch / home-bar safe area */
  .content {
    padding-bottom: max(2rem, env(safe-area-inset-bottom));
  }
}

@media (max-width: 600px) {
  form input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="color"]),
  form select,
  form textarea {
    max-width: none;
  }

  form input[type="number"] {
    max-width: none;
  }

  form input[type="date"] {
    max-width: none;
  }

  .search-inline {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
    padding: 0.85rem;
  }

  .search-inline label {
    min-width: 0;
    width: 100%;
  }

  .search-inline input,
  .search-inline select {
    max-width: none;
    width: 100%;
  }

  .dash-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }

  .form-grid-2,
  .form-grid-3 {
    grid-template-columns: 1fr;
  }

  .detail-list {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }

  .detail-list dt {
    margin-top: 0.6rem;
  }

  .row-actions {
    flex-wrap: wrap;
  }
}

/* ---- Detail list (dl key/value pairs) ---- */
.detail-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: .35rem 1.25rem;
  margin: 0 0 1.5rem;
  max-width: 52rem;
  font-size: .9rem;
}
.detail-list dt {
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}
.detail-list dd {
  margin: 0;
  color: var(--text-primary);
}

/* ---- Report summary cards ---- */
.report-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  text-align: center;
}
.report-card-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}
.report-card-label {
  font-size: .8rem;
  color: var(--text-secondary);
  margin-top: .35rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* ---- Attendee add form ---- */
.attendee-add-form h3 {
  font-size: .95rem;
  font-weight: 700;
  color: var(--brand-700);
  margin: 1rem 0 .6rem;
}
.opt-subscriber {
  font-weight: 600;
}

/* ---- Visitor / member ID badge ---- */
.visitor-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}
