/* MazKal — base styles. RTL-first. */

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

body {
  font-family: system-ui, -apple-system, sans-serif;
  margin: 0;
  background: #f8f8f8;
  color: #222;
}

header nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.75rem 1.5rem;
  background: #1a3a5c;
  color: #fff;
}

header nav a {
  color: inherit;
  text-decoration: none;
}

header nav .site-title {
  font-weight: bold;
  font-size: 1.1rem;
  margin-inline-end: auto;
}

.user-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.92rem;
}

.user-display-name {
  opacity: 0.85;
  font-weight: 500;
}

header nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 0;
  align-items: stretch;
}

/* Top-level nav items */
header nav ul > li {
  position: relative;
}

header nav ul > li > a,
header nav ul > li > details > summary {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.5rem 0.85rem;
  color: #fff;
  text-decoration: none;
  font-size: 0.9rem;
  white-space: nowrap;
  border-radius: 5px;
  cursor: pointer;
  list-style: none;
  transition: background 0.12s;
  height: 100%;
}

header nav ul > li > a:hover,
header nav ul > li > details > summary:hover,
header nav ul > li > details[open] > summary {
  background: rgba(255,255,255,0.15);
}

header nav ul > li > details > summary::marker,
header nav ul > li > details > summary::-webkit-details-marker {
  display: none;
}

/* Dropdown menus */
.nav-group {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: #fff;
  border: 1px solid #d0dae4;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.14);
  min-width: 170px;
  z-index: 500;
  overflow: hidden;
  padding: 0.3rem 0;
}

.nav-group a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  color: #1a3a5c;
  font-size: 0.875rem;
  white-space: nowrap;
  transition: background 0.1s;
}

.nav-group a:hover {
  background: #f0f6ff;
  text-decoration: none;
}

.nav-group-divider {
  height: 1px;
  background: #e8edf5;
  margin: 0.3rem 0;
}

/* Close dropdown when clicking outside — handled by JS */

main {
  max-width: 1100px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

h1 { margin-top: 0; }

.flash {
  padding: 0.75rem 1.5rem;
  margin-bottom: 1rem;
  border-radius: 4px;
}

.flash-success { background: #d4edda; color: #155724; }
.flash-error   { background: #f8d7da; color: #721c24; }
.flash-info    { background: #d1ecf1; color: #0c5460; }

.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin-top: 2rem;
}

.stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 1.5rem 1rem;
  background: #fff;
  border: 1px solid #d0dae4;
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  transition: box-shadow 0.15s, border-color 0.15s, transform 0.1s;
}

.stat-card:hover {
  border-color: #4a8ac4;
  box-shadow: 0 4px 14px rgba(26,58,92,0.13);
  transform: translateY(-2px);
}

.stat-card--plain {
  cursor: default;
}

.stat-number {
  font-size: 2.25rem;
  font-weight: 700;
  color: #1a3a5c;
  line-height: 1;
}

.stat-label {
  font-size: 0.875rem;
  color: #6080a0;
}

/* Page header */
.page-header {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-header h1 { margin: 0; }

.back-link {
  color: #1a3a5c;
  text-decoration: none;
  font-size: 0.9rem;
  white-space: nowrap;
}

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

/* Data tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
}

.data-table th,
.data-table td {
  text-align: start;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid #e0e0e0;
}

.data-table th {
  background: #f0f4f8;
  font-weight: 600;
  color: #333;
}

/* Sortable column headers */
.data-table th.col-sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.data-table th.col-sortable:hover {
  background: #e4eaf2;
}
.data-table th.col-sortable.sorted {
  background: #d8e5f5;
  color: #1a3a5c;
}
.sort-indicator {
  font-size: 0.75em;
  opacity: 0.8;
}

.data-table tbody tr:hover { background: #f8fafc; }

.data-table a { color: #1a3a5c; }

.row-current { background: #f0f8f0; }

/* Detail layout */
.detail-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  margin-bottom: 2rem;
}

.detail-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4rem 1.5rem;
  margin: 0;
}

.detail-list dt {
  font-weight: 600;
  color: #555;
}

.detail-list dd { margin: 0; }

section { margin-top: 2rem; }
section h2 { margin-bottom: 1rem; font-size: 1.15rem; }

/* Search */
.search-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1.5rem;
}

.search-form input[type="search"] {
  padding: 0.5rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 1rem;
  width: 320px;
  background: #fff;
}

.search-form button {
  padding: 0.5rem 1rem;
  background: #1a3a5c;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 1rem;
  cursor: pointer;
}

.search-form button:hover { background: #2a5a8c; }

.search-form a {
  color: #666;
  font-size: 0.9rem;
  text-decoration: none;
}

.search-form a:hover { text-decoration: underline; }

.empty-state {
  color: #666;
  font-style: italic;
  margin-top: 1rem;
}

.result-count {
  color: #666;
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

/* Import pages */
.import-instructions {
  background: #f0f4f8;
  border: 1px solid #d0d8e4;
  border-radius: 6px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}

.import-instructions p { margin: 0.5rem 0; }

.import-sample {
  margin: 0.75rem 0;
  font-size: 0.88rem;
}

.import-note {
  color: #555;
  font-size: 0.88rem;
  font-style: italic;
}

.import-textarea {
  width: 100%;
  font-family: monospace;
  font-size: 0.92rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  resize: vertical;
  background: #fff;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.form-group label { font-weight: 500; }

.form-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
}

.btn {
  padding: 0.55rem 1.25rem;
  border: none;
  border-radius: 4px;
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

.btn-primary { background: #1a3a5c; color: #fff; }
.btn-primary:hover:not(:disabled) { background: #2a5a8c; }
.btn-primary:disabled { opacity: 0.35; cursor: default; }
.btn-success { background: #1a6b3a; color: #fff; }
.btn-success:hover { background: #2a8c50; }

.preview-section { margin-top: 2rem; }
.preview-section h2 { margin-bottom: 1rem; font-size: 1.1rem; }

.import-errors {
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 4px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.92rem;
}

.import-errors ul { margin: 0.4rem 0 0; padding-inline-start: 1.5rem; }

.import-result p { margin: 0.3rem 0; font-size: 1rem; }
.result-inserted { color: #155724; }
.result-skipped  { color: #856404; }

.row-num { color: #999; font-size: 0.85rem; }

/* Login form */
.login-wrap {
  max-width: 380px;
  margin: 4rem auto;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-weight: 500;
}

.login-form input {
  padding: 0.5rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 1rem;
  background: #fff;
}

.login-form button {
  padding: 0.6rem 1.5rem;
  background: #1a3a5c;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 1rem;
  cursor: pointer;
}

.login-form button:hover {
  background: #2a5a8c;
}

/* -------------------------------------------------------------------------
   Buttons — secondary, small, icon, danger
------------------------------------------------------------------------- */

.btn-secondary {
  background: #e8edf2;
  color: #1a3a5c;
  border: 1px solid #c0ccd8;
}
.btn-secondary:hover { background: #d0dae4; }

.btn-secondary.disabled,
.btn-secondary[disabled] {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}

.btn-sm {
  padding: 0.3rem 0.75rem;
  font-size: 0.88rem;
}

.btn-icon {
  background: none;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 0.2rem 0.5rem;
  font-size: 1rem;
  cursor: pointer;
  color: #333;
  line-height: 1;
}
.btn-icon:hover { background: #f0f4f8; }
.btn-icon:disabled { opacity: 0.3; cursor: default; }

.btn-danger { background: #c0392b; color: #fff; border: none; }
.btn-danger:hover { background: #a93226; }
.btn-icon.btn-danger { background: none; color: #c0392b; border-color: #e5a8a3; }
.btn-icon.btn-danger:hover { background: #fdf2f2; }

/* -------------------------------------------------------------------------
   Inline forms (rename, tenancy, owner-add)
------------------------------------------------------------------------- */

.inline-form {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.inline-input {
  padding: 0.3rem 0.6rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.95rem;
  background: #fff;
  min-width: 160px;
}
.inline-input:focus { outline: 2px solid #4a8ac4; border-color: #4a8ac4; }

.inline-select {
  padding: 0.3rem 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.95rem;
  background: #fff;
  transition: border-color 0.15s, background 0.15s;
}

.inline-select.is-dirty {
  border-color: #e8a020;
  background: #fffbf0;
  outline: 2px solid #f0c060;
}

.btn-icon.tenancy-save.is-dirty {
  background: #1a6b3a;
  color: #fff;
  border-color: #1a6b3a;
  font-weight: bold;
}

.inline-create-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1.5rem;
}

.inline-create-form input[type="text"] {
  padding: 0.45rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 1rem;
  background: #fff;
  min-width: 240px;
}

.inline-create-form button {
  padding: 0.45rem 1rem;
  background: #1a3a5c;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 1rem;
  cursor: pointer;
}
.inline-create-form button:hover { background: #2a5a8c; }

.form-error {
  color: #721c24;
  background: #f8d7da;
  border: 1px solid #f5c6cb;
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
  font-size: 0.92rem;
  margin-bottom: 1rem;
}

/* -------------------------------------------------------------------------
   Yard detail — navigation, name, header
------------------------------------------------------------------------- */

.yard-nav {
  display: flex;
  gap: 0.5rem;
  margin-inline-start: auto;
  align-items: center;
}

.yard-display-name {
  font-size: 1rem;
  font-weight: 500;
  color: #1a3a5c;
  margin: 0 0 0.4rem;
}

#yard-name-section {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* -------------------------------------------------------------------------
   Household cards
------------------------------------------------------------------------- */

.household-card {
  border: 1px solid #d0dae4;
  border-radius: 6px;
  margin-bottom: 1rem;
  background: #fff;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  overflow: hidden;
}

.household-card-body {
  flex: 1;
  min-width: 0;
  padding: 0.85rem 1.1rem;
}

.household-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #eef0f3;
}

.members-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.member-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0;
  border-bottom: 1px solid #f2f4f6;
}
.member-row:last-child { border-bottom: none; }

.member-index {
  color: #999;
  font-size: 0.85rem;
  width: 1.5rem;
  text-align: start;
  flex-shrink: 0;
}

.member-actions {
  margin-inline-start: auto;
  display: flex;
  gap: 0.2rem;
}

.member-add-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid #f2f4f6;
}

.member-meta {
  color: #777;
  font-size: 0.85rem;
}

/* -------------------------------------------------------------------------
   Yard owners section
------------------------------------------------------------------------- */

#yard-owners {
  background: #f8fafc;
  border: 1px solid #d0dae4;
  border-radius: 6px;
  padding: 0.85rem 1.1rem;
}

.owners-list {
  list-style: none;
  margin: 0 0 0.75rem;
  padding: 0;
}

.owner-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid #e8ecf0;
}
.owner-row:last-child { border-bottom: none; }
.owner-row a { color: #1a3a5c; text-decoration: none; flex: 1; }
.owner-row a:hover { text-decoration: underline; }

/* -------------------------------------------------------------------------
   Edit-mode toggle — sliding switch
------------------------------------------------------------------------- */

.edit-mode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
  user-select: none;
  margin-inline-start: auto; /* push to far end of the page-header flex row */
}

.toggle-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: #555;
}

/* The visible track */
.toggle-track {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  background: #c8d0da;
  border-radius: 12px;
  transition: background 0.22s ease;
  flex-shrink: 0;
}

/* Hide the real checkbox visually but keep it accessible */
.toggle-track input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

/* Sliding bubble */
.toggle-bubble {
  position: absolute;
  top: 3px;
  inset-inline-start: 3px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
  transition: transform 0.22s ease;
  pointer-events: none;
}

/* ON state: track turns blue, bubble slides across */
.toggle-track:has(input:checked) {
  background: #3b7dd8;
}
.toggle-track input:checked ~ .toggle-bubble {
  transform: translateX(20px);
}

/* RTL: flip the slide direction */
[dir="rtl"] .toggle-track input:checked ~ .toggle-bubble,
:root[lang="he"] .toggle-track input:checked ~ .toggle-bubble {
  transform: translateX(-20px);
}

/* Keyboard focus ring on the track */
.toggle-track:focus-within {
  outline: 2px solid #3b7dd8;
  outline-offset: 2px;
}

/* -------------------------------------------------------------------------
   Edit-mode content gating
   .edit-ctrl  — visible in edit mode, hidden in view mode
   .view-only  — visible in view mode, hidden in edit mode
------------------------------------------------------------------------- */

.view-only { display: none; }

.edit-container.view-mode .edit-ctrl { display: none !important; }
.edit-container.view-mode .view-only { display: block; }

.hh-view-info {
  padding: 0.25rem 0;
  font-size: 0.95rem;
}

/* Yards list — name cell keeps a minimum width so the rename input has room */
.yard-name-cell {
  min-width: 140px;
}

.yard-name-cell .inline-form {
  margin: 0;
}

/* -------------------------------------------------------------------------
   Building add form (inline, below buildings table)
------------------------------------------------------------------------- */

.building-add-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid #e8ecf0;
}

.inline-input--notes {
  flex: 1;
  min-width: 160px;
}

.household-add-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px dashed #d0d7de;
}

/* -------------------------------------------------------------------------
   Persons list — filters bar (search + subset dropdown)
------------------------------------------------------------------------- */

.persons-filters {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

/* Let the search form grow, subset form stay compact */
.persons-filters .search-form {
  flex: 1;
  margin-bottom: 0;   /* override any default bottom margin */
}

.subset-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.subset-select {
  padding: 0.4rem 0.6rem;
  border: 1px solid #ccd0d6;
  border-radius: 4px;
  font-size: 0.9rem;
  background: #fff;
  min-width: 220px;
  cursor: pointer;
}

.subset-select:focus {
  outline: 2px solid #3b7dd8;
  border-color: #3b7dd8;
}

.subset-clear {
  font-size: 0.8rem;
  color: #888;
  text-decoration: none;
  white-space: nowrap;
}

.subset-clear:hover { color: #c00; }

.active-filter-badge {
  font-size: 0.85rem;
  color: #555;
  background: #eef3fb;
  border: 1px solid #c5d8f5;
  border-radius: 4px;
  padding: 0.3rem 0.75rem;
  margin-bottom: 0.75rem;
  display: inline-block;
}

.active-filter-badge .filter-group {
  color: #888;
  font-weight: 400;
}

/* -------------------------------------------------------------------------
   Person create / edit form
------------------------------------------------------------------------- */

.person-form {
  max-width: 680px;
}

.form-section {
  border: 1px solid #e2e6ea;
  border-radius: 6px;
  padding: 1rem 1.25rem 1.25rem;
  margin-bottom: 1.5rem;
}

.form-section legend {
  font-weight: 600;
  font-size: 0.9rem;
  color: #444;
  padding: 0 0.4rem;
}

.form-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 0.85rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1;
  min-width: 160px;
}

.form-field label {
  font-size: 0.85rem;
  font-weight: 500;
  color: #333;
}

.form-field input,
.form-field select,
.form-field textarea {
  padding: 0.4rem 0.6rem;
  border: 1px solid #ccd0d6;
  border-radius: 4px;
  font-size: 0.95rem;
  background: #fff;
  width: 100%;
  box-sizing: border-box;
}

.form-field input:focus,
.form-field select:focus {
  outline: 2px solid #3b7dd8;
  outline-offset: 1px;
  border-color: #3b7dd8;
}

.form-field--required label::after {
  content: " *";
  color: #c0392b;
}

.field-hint {
  font-size: 0.75rem;
  font-weight: 400;
  color: #777;
}

.form-error--banner {
  background: #fdf0f0;
  border: 1px solid #e8a0a0;
  border-radius: 5px;
  padding: 0.7rem 1rem;
  color: #b00;
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-top: 0.5rem;
}

/* -------------------------------------------------------------------------
   Import — info box, raw data display
------------------------------------------------------------------------- */

.import-info {
  background: #d1ecf1;
  border: 1px solid #bee5eb;
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 0.92rem;
  color: #0c5460;
}

pre.ocr-text {
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  background: #f8f8f8;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  padding: 1rem 1.25rem;
  max-height: 500px;
  overflow-y: auto;
  direction: rtl;
  text-align: right;
}

code.import-raw-data {
  display: block;
  font-size: 0.82em;
  color: #555;
  background: #f4f4f4;
  border-radius: 3px;
  padding: 0.15rem 0.4rem;
  margin-top: 3px;
  direction: ltr;
  text-align: left;
  white-space: pre;
  overflow-x: auto;
}

/* -------------------------------------------------------------------------
   Import index list
------------------------------------------------------------------------- */

.import-index {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.import-index li {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: #fff;
  border: 1px solid #d0dae4;
  border-radius: 6px;
}

.import-index li p {
  margin: 0;
  color: #555;
  font-size: 0.92rem;
}

/* -------------------------------------------------------------------------
   Map page
------------------------------------------------------------------------- */

#map-wrap {
  display: flex;
  gap: 0.75rem;
  height: calc(100vh - 9rem);
  min-height: 400px;
}

/* ── Left panel: yard list ── */
#map-panel {
  width: 220px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid #d0dae4;
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

#yard-search {
  border: none;
  border-bottom: 1px solid #d0dae4;
  padding: 0.55rem 0.75rem;
  font-size: 0.9rem;
  outline: none;
  background: #f8fafc;
}

#yard-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
}

.yard-list-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.75rem;
  cursor: pointer;
  border-bottom: 1px solid #f0f3f7;
  font-size: 0.88rem;
}
.yard-list-item:hover { background: #f0f6ff; }
.yard-list-item.active { background: #ddeeff; font-weight: 600; }
.yard-list-item.has-pin .yard-list-code { color: #1a3a5c; }

.yard-list-code { font-weight: 600; flex-shrink: 0; }
.yard-list-name { color: #666; font-size: 0.82rem; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pin-dot { font-size: 0.75rem; flex-shrink: 0; }

/* ── Map + toolbar ── */
#map-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 0;
}

#map-toolbar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.75rem;
  background: #f4f7fa;
  border: 1px solid #d0dae4;
  border-radius: 6px;
  font-size: 0.88rem;
  min-height: 2.2rem;
}
#toolbar-label { flex: 1; font-weight: 500; color: #444; }

.toolbar-badge--active {
  background: #1a3a5c;
  color: #fff;
  border-radius: 4px;
  padding: 0.15rem 0.6rem;
  font-size: 0.8rem;
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.65; }
}

#main-map {
  flex: 1;
  border-radius: 8px;
  border: 1px solid #d0dae4;
  z-index: 0;
}

/* Custom yard marker */
.yard-marker {
  width: 26px;
  height: 26px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
}

/* -------------------------------------------------------------------------
   Person detail — sections, inline editing
------------------------------------------------------------------------- */

.person-section {
  margin-bottom: 2rem;
}

.person-section h2 {
  font-size: 1rem;
  font-weight: 600;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 0.6rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid #e0e6ed;
}

/* Detail list used inside person sections */
.person-detail-list {
  display: grid;
  grid-template-columns: 8rem 1fr;
  gap: 0.4rem 1rem;
  align-items: baseline;
  margin: 0;
}

.person-detail-list dt {
  color: #777;
  font-size: 0.875rem;
  font-weight: 500;
}

.person-detail-list dd {
  margin: 0;
  font-size: 0.95rem;
}

/* Inline inputs that sit inside detail-list cells in edit mode */
.person-detail-list .inline-input,
.person-detail-list .inline-select {
  width: 100%;
  max-width: 22rem;
  padding: 0.25rem 0.45rem;
  font-size: 0.9rem;
  border: 1px solid #c0c8d0;
  border-radius: 4px;
  background: #fff;
}

.membership-status-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.membership-status-form .inline-input {
  flex: 1 1 10rem;
}

.date-cell {
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 0.2rem;
}
.date-cell .date-input {
  width: 7rem;
}
.date-clear-btn {
  flex-shrink: 0;
  padding: 0.1rem 0.35rem;
  font-size: 0.8rem;
  color: #999;
  border-color: #ddd;
}
.date-clear-btn:hover { color: #c0392b; border-color: #e5a8a3; background: #fdf2f2; }

/* Deceased persons — diagonal slash after the name */
/* Deceased persons — black mourning ribbon after the name */
.is-deceased::after {
  content: '\1F397';
  display: inline-block;
  vertical-align: middle;
  margin-inline-start: 0.3em;
  font-size: 0.95em;
  filter: grayscale(1) brightness(0);
}

/* Deceased badge (shown next to the page <h1>) */
.deceased-badge {
  display: inline-block;
  font-size: 1.1rem;
  vertical-align: middle;
  margin-inline-start: 0.4rem;
  filter: grayscale(1) brightness(0);
  cursor: default;
}

/* Checkbox labels inside a detail form */
.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
}

/* Missing-data badges in the persons list */
.missing-badge {
  display: inline-block;
  background: #fff3cd;
  border: 1px solid #ffc107;
  color: #6b4700;
  border-radius: 3px;
  padding: 0.1rem 0.4rem;
  font-size: 0.78rem;
  font-weight: 500;
  margin-inline-end: 0.25rem;
  white-space: nowrap;
}

/* -------------------------------------------------------------------------
   Building cards (yard detail — replaces the flat table)
------------------------------------------------------------------------- */

.building-card {
  border: 1px solid #d0dae4;
  border-radius: 6px;
  margin-bottom: 0.75rem;
  overflow: hidden;
  display: flex;
  flex-direction: row;
  align-items: stretch;
}

.building-card-body {
  flex: 1;
  min-width: 0;
}

.building-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.75rem;
  background: #f4f7fa;
  border-bottom: 1px solid #d0dae4;
  gap: 0.5rem;
}

.building-label {
  font-weight: 600;
  font-size: 0.95rem;
}

.building-card-actions {
  flex-shrink: 0;
}

/* The persons list inside a building card shares the same members-list style */
.building-card .members-list {
  padding: 0.35rem 0.5rem;
  margin: 0;
  list-style: none;
}

/* -------------------------------------------------------------------------
   Drag & Drop — persons within yard detail
------------------------------------------------------------------------- */

/* Drag handle — braille six-dot glyph; only visible in edit mode */
.drag-handle {
  cursor: grab;
  color: #aaa;
  font-size: 1rem;
  padding: 0 0.25rem;
  user-select: none;
  flex-shrink: 0;
}
.drag-handle:active { cursor: grabbing; }

/* Member / owner rows must be flex so the handle sits at the start */
.member-row,
.owner-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* The element being dragged */
.is-dragging {
  opacity: 0.4;
}

/* Drop-target highlight on the receiving <ul> */
.drop-target {
  outline: 2px dashed #3b7dd8;
  outline-offset: 2px;
  border-radius: 4px;
  background: #f0f6ff;
}

/* Empty-list drop zones — give them enough height to be a visible target */
.members-list--empty,
.owners-list--empty {
  min-height: 2.5rem;
  padding: 0.25rem 0;
}

/* Card-level drag handle — vertical strip on the inline-start edge */
.card-drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 1.5rem;
  cursor: grab;
  color: #bbb;
  font-size: 0.95rem;
  user-select: none;
  background: #f0f3f7;
  border-inline-end: 1px solid #d0dae4;
}
.card-drag-handle:hover { color: #777; background: #e6ebf2; }
.card-drag-handle:active { cursor: grabbing; }

/* In view mode: suppress drag cursor on rows and card handles */
.edit-container.view-mode [data-person-id] {
  cursor: default;
}

/* Placeholder text shown inside an empty droppable list */
.empty-drop-hint {
  list-style: none;
  padding: 0.4rem 0.75rem;
  color: #aaa;
  font-size: 0.85rem;
  font-style: italic;
  pointer-events: none;   /* don't interfere with drag events */
}

/* ── History table: editable rows with drag-to-reorder ──────────────────── */
.history-drag-col  { width: 2rem; }
.history-drag-cell { text-align: center; cursor: grab; color: #aaa; user-select: none; }
.history-drag-cell:active { cursor: grabbing; }

.history-edit-table .inline-input  { width: 100%; box-sizing: border-box; }
.history-edit-table .inline-select { width: 100%; box-sizing: border-box; }

.history-edit-row.is-dragging         { opacity: 0.35; }
.history-edit-row.history-drag-over-top    { box-shadow: inset 0 2px 0 #1a3a5c; }
.history-edit-row.history-drag-over-bottom { box-shadow: inset 0 -2px 0 #1a3a5c; }

/* =========================================================================
   Archive Browser — two-panel dashboard layout
   RTL: sidebar (start/right) + document pane (end/left)
========================================================================= */

main.archive-browser-main {
  max-width: none;
  margin: 0;
  padding: 0;
  height: calc(100vh - 3rem);  /* full height minus header */
  overflow: hidden;
}

.ab-layout {
  display: flex;
  flex-direction: row; /* RTL: first child (sidebar) renders on the right */
  height: 100%;
  overflow: hidden;
}

/* ── Sidebar ── */
.ab-sidebar {
  width: 300px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: #1e2d3d;
  color: #c8d8e8;
  overflow: hidden;
  border-inline-start: 1px solid #162330;
}

.ab-sidebar-header-row {
  display: flex;
  align-items: stretch;
  flex-shrink: 0;
  background: #162330;
}

.ab-sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.9rem 1rem 0.7rem;
  font-weight: 700;
  font-size: 0.95rem;
  color: #e8f0f8;
  letter-spacing: 0.01em;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.ab-sidebar-header:hover { background: #1e2d3d; }

.ab-sidebar-icon { font-size: 1.2rem; flex-shrink: 0; }
.ab-sidebar-title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.ab-sidebar-toggle {
  flex-shrink: 0;
  width: 2rem;
  background: none;
  border: none;
  border-inline-start: 1px solid #243548;
  color: #a0b8d0;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.ab-sidebar-toggle:hover { background: #1e2d3d; color: #e8f0f8; }
[dir="rtl"] .ab-sidebar-toggle { transform: scaleX(-1); }

/* ── Resize handle ── */
.ab-resize-handle {
  width: 5px;
  flex-shrink: 0;
  background: #1a2b3c;
  cursor: col-resize;
  transition: background 0.15s;
  position: relative;
}
.ab-resize-handle:hover,
.ab-resizing .ab-resize-handle { background: #3b82f6; }
.ab-resize-handle--hidden { display: none; }
body.ab-resizing { cursor: col-resize; user-select: none; }

/* ── Collapsed sidebar ── */
.ab-sidebar--collapsed {
  width: 2rem !important;
  min-width: 2rem !important;
  overflow: hidden;
}
.ab-sidebar--collapsed .ab-sidebar-header,
.ab-sidebar--collapsed .ab-search-wrap,
.ab-sidebar--collapsed .ab-tree { display: none; }
.ab-sidebar--collapsed .ab-sidebar-toggle { border-inline-start: none; }

.ab-search-wrap {
  padding: 0.6rem 0.75rem;
  background: #162330;
  border-bottom: 1px solid #243548;
  flex-shrink: 0;
}

.ab-search {
  width: 100%;
  padding: 0.4rem 0.65rem;
  background: #243548;
  border: 1px solid #2e4560;
  border-radius: 6px;
  color: #c8d8e8;
  font-size: 0.88rem;
  outline: none;
}
.ab-search::placeholder { color: #6888a8; }
.ab-search:focus { border-color: #4a8ac4; background: #1e3550; }

/* ── Tree ── */
.ab-tree {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.4rem 0;
  scrollbar-width: thin;
  scrollbar-color: #2e4560 transparent;
}

.ab-node { user-select: none; }

.ab-node-row {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.28rem 0.5rem 0.28rem 0.75rem;
  cursor: pointer;
  border-radius: 4px;
  margin: 0 0.25rem;
  transition: background 0.12s;
}
.ab-node-row:hover { background: #243548; }

.ab-node-row--file { padding-inline-start: 1rem; }

.ab-children {
  padding-inline-start: 1.1rem;
  border-inline-start: 1px solid #243548;
  margin-inline-start: 1.25rem;
}

.ab-toggle {
  background: none;
  border: none;
  color: #6888a8;
  font-size: 0.95rem;
  width: 1.25rem;
  height: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  border-radius: 3px;
  padding: 0;
  transition: color 0.12s, background 0.12s;
}
.ab-toggle:hover { color: #c8d8e8; background: #2e4560; }
.ab-toggle--leaf { pointer-events: none; opacity: 0; }

.ab-toggle-icon {
  display: inline-block;
  font-style: normal;
  font-size: 0.7rem;
  line-height: 1;
  transition: opacity 0.12s;
}
[dir="rtl"] .ab-node:not([aria-expanded="true"]) .ab-toggle-icon {
  transform: scaleX(-1);
}

.ab-node-icon { font-size: 0.95rem; flex-shrink: 0; }

.ab-node-label {
  flex: 1;
  font-size: 0.875rem;
  color: #b8cce0;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  padding: 0.05rem 0;
  transition: color 0.12s;
}
.ab-node-label:hover { color: #e8f4ff; }

.ab-node-row.active {
  background: #1a3a5a;
}
.ab-node-row.active .ab-node-label {
  color: #5bb8ff;
  font-weight: 600;
}

.ab-node-code {
  color: #6888a8;
  font-size: 0.78rem;
  font-weight: 400;
}

.ab-node-path {
  display: block;
  color: #5a7a98;
  font-size: 0.72rem;
  font-weight: 400;
  opacity: 0.8;
  margin-bottom: 0.1rem;
}

.ab-badge {
  flex-shrink: 0;
  background: #1a4a70;
  color: #80b8e8;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.1rem 0.45rem;
  border-radius: 10px;
  min-width: 1.6rem;
  text-align: center;
}
.ab-badge--file { background: #1a3a50; color: #6898c0; }

.ab-loading {
  color: #6888a8;
  font-size: 0.82rem;
  padding: 0.4rem 0.75rem;
  font-style: italic;
}

.ab-empty { color: #6888a8; font-size: 0.88rem; padding: 1rem; }
.ab-empty-children {
  color: #4a6a88;
  font-size: 0.8rem;
  padding: 0.3rem 0.5rem;
  font-style: italic;
}

/* ── Document Pane ── */
.ab-pane-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.ab-toolbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  background: #fff;
  border-bottom: 1px solid #d0d8e4;
}

.ab-global-search {
  display: flex;
  flex-direction: column;
  flex: 1;
  max-width: 560px;
  gap: 0.35rem;
}
.ab-global-search-row {
  display: flex;
  gap: 0;
}
.ab-global-search-dates {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding: 0 0.1rem;
  margin-top: 0.35rem;
}
.ab-date-filter {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.ab-date-label {
  font-size: 0.8rem;
  color: #6b7a8d;
  white-space: nowrap;
}
.ab-date-input {
  font-size: 0.8rem;
  padding: 0.25rem 0.4rem;
  border: 1px solid #c0cad6;
  border-radius: 5px;
  background: #f8fafc;
  color: #1a3050;
  direction: ltr;
}
.ab-date-input:focus {
  border-color: #3b82f6;
  background: #fff;
  outline: none;
}

.ab-global-search-input {
  flex: 1;
  padding: 0.45rem 0.75rem;
  border: 1px solid #c0cad6;
  border-inline-end: none;
  border-start-start-radius: 6px;
  border-end-start-radius: 6px;
  font-size: 0.9rem;
  outline: none;
  background: #f8fafc;
  direction: rtl;
}
.ab-global-search-input:focus {
  border-color: #3b82f6;
  background: #fff;
}

.ab-global-search-btn {
  padding: 0.45rem 0.75rem;
  border: 1px solid #c0cad6;
  border-inline-start: none;
  border-start-end-radius: 6px;
  border-end-end-radius: 6px;
  background: #3b82f6;
  color: #fff;
  cursor: pointer;
  font-size: 0.95rem;
  transition: background 0.15s;
}
.ab-global-search-btn:hover { background: #2563eb; }

.ab-pane {
  flex: 1;
  overflow-y: auto;
  background: #f4f6f9;
  min-width: 0;
}

.ab-pane-inner {
  padding: 1.5rem 2rem;
  max-width: 900px;
}

/* Welcome state */
.ab-pane-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 5rem 2rem;
  text-align: center;
  color: #6080a0;
}
.ab-welcome-icon { font-size: 4rem; margin-bottom: 1rem; opacity: 0.5; }
.ab-pane-welcome h2 { color: #3a5070; margin: 0 0 0.5rem; font-size: 1.4rem; }
.ab-pane-welcome p  { margin: 0 0 2rem; font-size: 1rem; }

.ab-stats-row {
  display: flex;
  gap: 2rem;
  justify-content: center;
}
.ab-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}
.ab-stat-n { font-size: 2rem; font-weight: 700; color: #1a3a5c; }
.ab-stat-l { font-size: 0.85rem; color: #6080a0; }

/* Breadcrumb */
.ab-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: #6080a0;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.ab-breadcrumb a, .ab-breadcrumb [role="button"] {
  color: #3a7abf;
  cursor: pointer;
  text-decoration: none;
}
.ab-breadcrumb a:hover, .ab-breadcrumb [role="button"]:hover { text-decoration: underline; }
.ab-bc-sep { color: #b0bcc8; }

/* Pane header */
.ab-pane-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 2px solid #e0e8f0;
}
.ab-pane-icon { font-size: 2.5rem; flex-shrink: 0; line-height: 1; }
.ab-pane-title-block { flex: 1; min-width: 0; }
.ab-pane-title { margin: 0 0 0.5rem; font-size: 1.5rem; color: #1a2d42; line-height: 1.2; }

.ab-pane-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}
.ab-level-badge {
  background: #1a3a5c;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  letter-spacing: 0.02em;
}
.ab-meta-chip {
  background: #e4edf7;
  color: #3a5a80;
  font-size: 0.8rem;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  border: 1px solid #c8d8ec;
}

.ab-pane-desc {
  color: #4a6070;
  font-size: 0.95rem;
  margin: 0 0 1.5rem;
  line-height: 1.6;
  background: #edf4fc;
  border-inline-start: 3px solid #4a8ac4;
  padding: 0.6rem 0.9rem;
  border-radius: 0 4px 4px 0;
}

/* Section titles */
.ab-section-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6080a0;
  margin: 0 0 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.ab-section-count {
  background: #dce8f5;
  color: #3a6090;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.1rem 0.5rem;
  border-radius: 8px;
  text-transform: none;
  letter-spacing: 0;
}

/* Cards grid (sub-fonds / files) */
.ab-cards-section { margin-bottom: 2rem; }

.ab-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
}

.ab-card {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.75rem 0.9rem;
  background: #fff;
  border: 1px solid #d4e0ec;
  border-radius: 8px;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s, transform 0.1s;
  text-align: start;
}
.ab-card:hover {
  border-color: #4a8ac4;
  box-shadow: 0 4px 12px rgba(26,58,92,0.12);
  transform: translateY(-1px);
}
.ab-card:active { transform: translateY(0); }

.ab-card--file { border-color: #d0dce8; }
.ab-card--file:hover { border-color: #7aacdc; }

.ab-card-icon { font-size: 1.5rem; flex-shrink: 0; }
.ab-card-body { flex: 1; min-width: 0; }
.ab-card-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: #1a3050;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ab-card-code { font-size: 0.76rem; color: #7090b0; margin-top: 0.15rem; }

/* Document list */
.ab-docs-section { margin-top: 0.5rem; }

/* ── Document detail pane ── */
.ab-pane-subtitle { margin: 0.1rem 0 0; color: #6b7a8d; font-size: 0.9rem; }

/* ── Full-pane viewer ── */
#ab-pane.ab-pane--viewer {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 0;
}
.ab-viewer {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: 100%;
}
.ab-viewer-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: #1e2d3d;
  color: #e8f0f8;
  flex-shrink: 0;
}
.ab-viewer-close {
  background: none;
  border: none;
  color: #e8f0f8;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  line-height: 1;
  flex-shrink: 0;
  transition: background 0.15s;
}
.ab-viewer-close:hover { background: rgba(255,255,255,.15); }
.ab-viewer-title {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ab-viewer-download { flex-shrink: 0; font-size: 0.85rem; }
.ab-viewer-body--image {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111;
}
.ab-viewer-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.ab-viewer-iframe {
  flex: 1;
  min-height: 0;
  width: 100%;
  border: none;
}

.ab-doc-pdf-wrap {
  margin: 1rem 0 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.ab-doc-pdf {
  width: 100%;
  height: 70vh;
  border: 1px solid #d0d8e4;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,.1);
}

.ab-doc-image-wrap {
  margin: 1rem 0 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75rem;
}
.ab-doc-image {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 6px;
  border: 1px solid #d0d8e4;
  box-shadow: 0 2px 8px rgba(0,0,0,.1);
  object-fit: contain;
}
.ab-doc-image-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.ab-doc-file-row {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
  margin: 1rem 0 1.25rem;
}
.ab-doc-preview img {
  max-width: 160px;
  max-height: 200px;
  border-radius: 6px;
  border: 1px solid #d0d8e4;
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
}
.ab-doc-file-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  justify-content: flex-start;
}

.ab-doc-meta-sections { margin-top: 1rem; display: flex; flex-direction: column; gap: 0.75rem; }

.ab-doc-section { background: #fff; border-radius: 8px; border: 1px solid #e2e8f0; padding: 0.75rem 1rem; }

.ab-section-title--sm {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #8896a7;
  margin: 0 0 0.5rem;
}

.ab-doc-dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.25rem 1rem;
  margin: 0;
  font-size: 0.88rem;
}
.ab-doc-dl dt { color: #6b7a8d; white-space: nowrap; }
.ab-doc-dl dd { margin: 0; color: #1e293b; word-break: break-word; }

.ab-doc-ocr-bar {
  margin-top: 0.75rem;
  padding: 0.5rem 1rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.ab-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1rem 0 0.5rem;
}
.ab-page-btn {
  padding: 0.35rem 0.9rem;
  border: 1px solid #c0cad6;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 0.9rem;
  color: #1e293b;
  transition: background 0.15s, border-color 0.15s;
}
.ab-page-btn:hover:not(:disabled) { background: #f0f4f8; border-color: #3b82f6; }
.ab-page-btn:disabled { opacity: 0.4; cursor: default; }
.ab-page-info { font-size: 0.85rem; color: #6b7a8d; }

.ab-doc-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.ab-doc-row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.65rem 0.9rem;
  background: #fff;
  border: 1px solid #dce8f0;
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.12s, border-color 0.12s;
}
.ab-doc-row:hover {
  border-color: #4a8ac4;
  box-shadow: 0 2px 8px rgba(26,58,92,0.09);
}

.ab-doc-thumb {
  width: 48px;
  height: 60px;
  flex-shrink: 0;
  border-radius: 4px;
  overflow: hidden;
  background: #edf2f7;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #d0dce8;
}
.ab-doc-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ab-doc-thumb-placeholder { font-size: 1.6rem; opacity: 0.4; }

.ab-doc-body { flex: 1; min-width: 0; }
.ab-doc-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #1a3050;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.25rem;
}
.ab-doc-num {
  flex-shrink: 0;
  min-width: 2em;
  font-size: 0.75rem;
  font-weight: 400;
  color: #8a9bb0;
  text-align: center;
  align-self: center;
}
.ab-doc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: #6a88a8;
  align-items: center;
}
.ab-doc-desc {
  color: #5a7898;
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 300px;
}
.ab-format-badge {
  background: #e8f0f8;
  color: #3a6090;
  border: 1px solid #c0d4ec;
  border-radius: 3px;
  padding: 0.05rem 0.4rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
}

.ab-doc-arrow {
  color: #b0c8e0;
  font-size: 1.1rem;
  flex-shrink: 0;
}

/* ── Search result: row wrapper + view button ─────────────────────────── */
.ab-doc-row-wrap {
  display: flex;
  align-items: stretch;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #dce8f0;
  transition: box-shadow 0.12s, border-color 0.12s;
}
.ab-doc-row-wrap:hover { border-color: #4a8ac4; box-shadow: 0 2px 8px rgba(26,58,92,0.09); }
.ab-doc-row-wrap .ab-doc-row {
  flex: 1;
  border: none;
  border-radius: 0;
  box-shadow: none;
}
.ab-doc-row-wrap .ab-doc-row:hover { border-color: transparent; box-shadow: none; }
.ab-doc-view-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.85rem;
  background: #f4f8fc;
  border: none;
  border-inline-start: 1px solid #dce8f0;
  color: #4a8ac4;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  gap: 0.3rem;
}
.ab-doc-view-btn:hover { background: #dbeafe; color: #1d4ed8; }

/* ── Viewer: search navigation bar ───────────────────────────────────── */
.ab-viewer-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  background: #1a3050;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
}
.ab-viewer-nav-btn {
  padding: 0.2rem 0.6rem;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 4px;
  color: #e2e8f0;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s;
}
.ab-viewer-nav-btn:hover:not(:disabled) { background: rgba(255,255,255,0.22); }
.ab-viewer-nav-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.ab-viewer-pos {
  flex: 1;
  text-align: center;
  font-size: 0.8rem;
  color: #94a3b8;
}
.ab-viewer-nofile {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  color: #8090a8;
  font-style: italic;
}

.ab-empty-pane {
  color: #8090a8;
  font-style: italic;
  margin-top: 2rem;
  text-align: center;
}

/* ── Archive search: ZIP download panel ──────────────────────────────────── */
.ab-download-panel {
  margin-top: 1.2rem;
  border: 1px solid #dce8f0;
  border-radius: 8px;
  overflow: hidden;
}
.ab-download-summary {
  padding: .55rem 1rem;
  background: #f4f8fc;
  cursor: pointer;
  font-weight: 500;
  font-size: .88rem;
  list-style: none;
  user-select: none;
  color: #334155;
}
.ab-download-summary::-webkit-details-marker { display: none; }
.ab-download-summary:hover { background: #e8f0f8; }
details[open] .ab-download-summary { border-bottom: 1px solid #dce8f0; }
.ab-download-form {
  padding: .85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.ab-download-options {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
}
.ab-download-group {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  font-size: .85rem;
}
.ab-download-group strong {
  font-size: .75rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: .1rem;
}
.ab-download-group label {
  display: flex;
  align-items: center;
  gap: .4rem;
  cursor: pointer;
  color: #334155;
}
.ab-download-btn { align-self: flex-start; font-size: .88rem; }
.ab-download-note { font-size: .78rem; color: #94a3b8; }
.ab-download-limit-note { font-size: .85rem; color: #b45309; margin: 0; }

/* ── Committees & Facilities ─────────────────────────────────────────────── */

/* Collapsible add panel */
.inline-form-panel { margin-bottom: 1.25rem; padding: 1rem 1.25rem; background: #f0f6ff; border: 1px solid #c7d9f0; border-radius: 8px; }
.inline-form-panel .form-row { display: flex; gap: .75rem; align-items: flex-end; flex-wrap: wrap; }
.inline-form-panel .form-group { display: flex; flex-direction: column; gap: .3rem; flex: 1; min-width: 160px; }
.inline-form-panel .form-group label { font-size: .85rem; font-weight: 600; color: #444; }
.inline-form-panel .form-group input, .inline-form-panel .form-group select { padding: .45rem .65rem; border: 1px solid #c0cfe0; border-radius: 6px; font-size: .9rem; }
.form-group-btn { flex: 0 !important; min-width: auto !important; }

/* Inactive rows */
.row-inactive td { opacity: .6; }

/* Status badges */
.badge { display: inline-block; padding: .15rem .5rem; border-radius: 9999px; font-size: .75rem; font-weight: 700; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-muted   { background: #f3f4f6; color: #6b7280; }
.badge-warning { background: #fef9c3; color: #854d0e; }
.badge-info    { background: #dbeafe; color: #1e40af; }

/* Section actions row */
.section-actions { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }

/* Detail card */
.detail-card { background: #fff; border: 1px solid #dde6f0; border-radius: 10px; padding: 1.25rem; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.detail-grid { display: grid; grid-template-columns: auto 1fr; gap: .4rem 1.25rem; }
.detail-grid dt { font-size: .8rem; font-weight: 700; color: #6b7280; text-transform: uppercase; letter-spacing: .04em; padding-top: .1rem; }
.detail-grid dd { color: #222; }

/* Schedule editor grid */
.schedule-editor {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: .5rem;
  margin-bottom: 1rem;
}
.schedule-day {
  background: #f8fafc;
  border: 1px solid #dde6f0;
  border-radius: 8px;
  padding: .65rem .5rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.schedule-day-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .25rem;
  font-size: .8rem;
  flex-wrap: wrap;
}
.toggle-label { display: flex; align-items: center; gap: .25rem; font-size: .78rem; cursor: pointer; color: #555; }
.schedule-day-times .time-row { display: flex; flex-direction: column; gap: .15rem; margin-bottom: .35rem; }
.schedule-day-times .time-row label { font-size: .72rem; color: #888; }
.schedule-day-times input[type=time] { width: 100%; padding: .25rem .35rem; border: 1px solid #c0cfe0; border-radius: 4px; font-size: .8rem; }

/* Schedule table in detail view */
.schedule-table { border-collapse: collapse; font-size: .82rem; }
.schedule-table th, .schedule-table td { padding: .4rem .6rem; text-align: center; border: 1px solid #e5e7eb; }
.schedule-table th { background: #f0f6ff; color: #1a3a5c; font-weight: 700; }

@media (max-width: 700px) {
  .schedule-editor { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 420px) {
  .schedule-editor { grid-template-columns: repeat(2, 1fr); }
}

/* ── Portal Management Hub ─────────────────────────────────────────────────── */

.manage-tabs {
  display: flex;
  gap: .25rem;
  border-bottom: 2px solid #d0dae4;
  margin-bottom: 1.25rem;
}
.manage-tab {
  padding: .55rem 1.2rem;
  border: none;
  background: none;
  cursor: pointer;
  font-size: .93rem;
  font-weight: 600;
  color: #4a6080;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  border-radius: 5px 5px 0 0;
  transition: color .15s, border-color .15s;
}
.manage-tab:hover { color: #1a3a5c; background: #f0f6ff; }
.manage-tab.active { color: #1a6aaa; border-bottom-color: #1a6aaa; background: #f0f6ff; }

.sync-badge { font-size: .72rem; padding: .15rem .45rem; vertical-align: middle; }

.manage-panel { margin-top: .25rem; }
.hidden { display: none !important; }
.manage-panel.hidden { display: none; }

.panel-toolbar {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

/* ── Edit form page helpers ────────────────────────────────────────────────── */
.form-control {
  width: 100%;
  padding: .45rem .65rem;
  border: 1px solid #c0cfe0;
  border-radius: 6px;
  font-size: .93rem;
  background: #fff;
  color: #1a2a3a;
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus {
  outline: none;
  border-color: #1a6aaa;
  box-shadow: 0 0 0 3px rgba(26,106,170,.12);
}
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { appearance: auto; }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .93rem;
  cursor: pointer;
}
.checkbox-label input[type=checkbox] { width: 1rem; height: 1rem; cursor: pointer; }

.form-actions {
  display: flex;
  gap: .75rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid #e5eaf0;
}

/* ── Person picker ─────────────────────────────────────────────────────────── */
.person-picker-list {
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid #c0cfe0;
  border-radius: 0 0 8px 8px;
  margin-top: -1px;          /* merge with the filter input border */
  background: #fff;
}
.person-picker-list + .person-picker-empty { margin-top: 0; }

#person-filter {
  border-radius: 8px 8px 0 0;
  position: relative;
  z-index: 1;
}
#person-filter:focus {
  border-radius: 8px 8px 0 0;
}

.person-picker-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: .75rem;
  padding: .55rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid #eef2f7;
  transition: background .1s;
}
.person-picker-item:last-child { border-bottom: none; }
.person-picker-item:hover { background: #f0f6ff; }
.person-picker-item.selected {
  background: #dbeafe;
  font-weight: 600;
}
.person-picker-item.selected .person-picker-name { color: #1a3a5c; }

.person-picker-name { font-size: .93rem; }
.person-picker-email {
  font-size: .8rem;
  color: #6b8099;
  flex-shrink: 0;
}

.person-picker-empty {
  padding: .75rem 1rem;
  font-size: .88rem;
  color: #888;
  border: 1px solid #c0cfe0;
  border-top: none;
  border-radius: 0 0 8px 8px;
  background: #fafbfc;
}

/* ── Page header — multi-button action area ────────────────────────────────── */
.page-header-actions {
  display: flex;
  gap: .5rem;
  align-items: center;
  flex-wrap: wrap;
}

/* ── Column picker panel ───────────────────────────────────────────────────── */
.col-picker-panel {
  background: #f8f9fa;
  border: 1px solid #d0dae4;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}

.col-picker-grid {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.5rem;
  margin-bottom: .9rem;
}

.col-picker-grid .checkbox-label {
  font-size: .9rem;
  min-width: 120px;
}

.col-picker-actions {
  display: flex;
  gap: .5rem;
  align-items: center;
}

.save-view-form {
  display: flex;
  gap: .5rem;
  align-items: center;
  margin-top: .85rem;
  padding-top: .85rem;
  border-top: 1px solid #dee2e6;
  flex-wrap: wrap;
}

.save-view-form .form-control {
  width: auto;
  flex: 1;
  min-width: 140px;
  max-width: 220px;
}

/* ── Saved views bar ───────────────────────────────────────────────────────── */
.saved-views-bar {
  display: flex;
  gap: .5rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: .75rem;
  padding-top: .75rem;
  border-top: 1px solid #dee2e6;
  font-size: .875rem;
}

.saved-view-link {
  color: var(--primary, #1a6aaa);
  text-decoration: none;
  padding: .2rem .55rem;
  border: 1px solid var(--primary, #1a6aaa);
  border-radius: 4px;
  font-size: .8rem;
  transition: background .12s, color .12s;
}

.saved-view-link:hover {
  background: var(--primary, #1a6aaa);
  color: #fff;
}


/* ── Report photo thumbnail (portal/reports.html) ── */
.report-thumb {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid #dde6f0;
  cursor: zoom-in;
  transition: transform .15s ease;
}
.report-thumb:hover { transform: scale(1.08); }

/* ── Force 24-hour display in time inputs (Chrome/Edge/Safari on en-US) ──── */
input[type="time"]::-webkit-datetime-edit-ampm-field,
input[type="datetime-local"]::-webkit-datetime-edit-ampm-field {
  display: none;
}
