:root {
  --bg: #ffffff;
  --bg-secondary: #f5f5f5;
  --bg-tertiary: #ededed;
  --text: #111111;
  --text-muted: #666666;
  --border: #e0e0e0;
  --border-strong: #c8c8c8;
  --accent: #111111;
  --accent-text: #ffffff;
  --danger-bg: #fbeaea;
  --danger-text: #7a1414;
  --success-bg: #e7f1ea;
  --success-text: #144a26;
  --warning-bg: #fdf1de;
  --warning-text: #8a5a0b;
  --info-bg: #ececec;
  --info-text: #1a1a1a;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 12px rgba(0,0,0,.04);
}
html.dark {
  --bg: #0f0f0f;
  --bg-secondary: #1a1a1a;
  --bg-tertiary: #232323;
  --text: #f0f0f0;
  --text-muted: #888888;
  --border: #2a2a2a;
  --border-strong: #3a3a3a;
  --accent: #f0f0f0;
  --accent-text: #111111;
  --danger-bg: #2a1414;
  --danger-text: #f4a8a8;
  --success-bg: #142a1c;
  --success-text: #a8e0bb;
  --warning-bg: #2e2310;
  --warning-text: #f0c878;
  --info-bg: #1f1f1f;
  --info-text: #e0e0e0;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 12px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--text); text-decoration: underline; text-underline-offset: 2px; }
a:hover { color: var(--text-muted); }
img { max-width: 100%; height: auto; display: block; }
h1, h2, h3, h4 { font-weight: 600; letter-spacing: -0.01em; line-height: 1.3; }
h1 { font-size: 1.7rem; margin: 0 0 .4em; }
h2 { font-size: 1.25rem; margin: 1.1em 0 .35em; }
h3 { font-size: 1.02rem; margin: .9em 0 .3em; }
h2:first-child, h3:first-child { margin-top: 0; }
p { margin: 0 0 .9em; }
p:last-child { margin-bottom: 0; }

/* Layout */
.container { max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.container-narrow { max-width: 720px; margin: 0 auto; padding: 0 20px; }
.page { padding: 20px 0 60px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 0; }
/* Form rows nested in a flex .row use the row's gap; cancel their own bottom margin. */
.row .form-row { margin-bottom: 0; }
@media (max-width: 600px) {
  .container, .container-narrow { padding: 0 14px; }
  .page { padding: 14px 0 48px; }
}

/* Admin / staff bar (renders only for role=staff|admin via includes/admin-bar.php).
   Sits ABOVE the regular sticky nav; non-sticky so the tenant nav can pin.
   Theme-aware: a dark bar on the light theme, a distinct lighter charcoal on the
   dark theme so it doesn't merge into the near-black page. */
:root {
  --ab-bg: #1a1a1a; --ab-hover: #2c2c2c; --ab-active: #353535;
  --ab-text: #dcdcdc; --ab-strong: #ffffff; --ab-border: #000000;
  --ab-menu-bg: #1f1f1f; --ab-menu-border: #383838;
}
html.dark {
  --ab-bg: #262626; --ab-hover: #3a3a3a; --ab-active: #454545;
  --ab-text: #e6e6e6; --ab-strong: #ffffff; --ab-border: #444444;
  --ab-menu-bg: #2e2e2e; --ab-menu-border: #4a4a4a;
}
.admin-bar {
  background: var(--ab-bg); color: var(--ab-text);
  border-bottom: 1px solid var(--ab-border);
  font-size: .86rem;
}
.admin-bar-inner {
  display: flex; align-items: center; gap: 14px;
  padding: 6px 20px; max-width: 1200px; margin: 0 auto;
  flex-wrap: wrap;
}
.ab-brand {
  font-weight: 700; letter-spacing: .12em;
  font-size: .72rem; color: #ffd54a;
  padding: 2px 7px; border: 1px solid #ffd54a; border-radius: 3px;
  white-space: nowrap;
}
.ab-links {
  display: flex; gap: 2px; flex-wrap: wrap; align-items: center;
}
.ab-links a {
  color: var(--ab-text); text-decoration: none;
  padding: 4px 9px; border-radius: 3px;
  white-space: nowrap;
}
.ab-links a:hover { background: var(--ab-hover); color: var(--ab-strong); }
.ab-links a.ab-active { background: var(--ab-active); color: var(--ab-strong); }

/* Settings dropdown using <details>/<summary> */
.ab-drop { position: relative; }
.ab-drop > summary {
  list-style: none; cursor: pointer;
  color: var(--ab-text); padding: 4px 9px; border-radius: 3px;
  white-space: nowrap; user-select: none;
}
.ab-drop > summary::-webkit-details-marker { display: none; }
.ab-drop[open] > summary, .ab-drop > summary:hover { background: var(--ab-hover); color: var(--ab-strong); }
.ab-drop-menu {
  position: absolute; top: calc(100% + 4px); right: 0;
  background: var(--ab-menu-bg); border: 1px solid var(--ab-menu-border); border-radius: 4px;
  min-width: 240px; padding: 4px; z-index: 70;
  box-shadow: 0 6px 18px rgba(0,0,0,.4);
  display: flex; flex-direction: column;
}
.ab-drop-menu a {
  color: var(--ab-text); text-decoration: none; padding: 6px 10px;
  border-radius: 3px; font-size: .88rem;
}
.ab-drop-menu a:hover { background: var(--ab-hover); color: var(--ab-strong); }

/* Mobile: keep the bar wrapping, but make the dropdown render inline so it
   doesn't escape the viewport. */
@media (max-width: 720px) {
  .admin-bar-inner { padding: 6px 12px; gap: 8px; }
  .ab-drop-menu { position: static; min-width: 0; box-shadow: none; }
}

/* Nav */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 20px;
  max-width: 1200px; margin: 0 auto;
}
.nav-brand {
  font-weight: 700; font-size: 1.05rem; text-decoration: none; color: var(--text);
  white-space: nowrap;
}
.nav-links { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav-links a {
  text-decoration: none; padding: 7px 12px; border-radius: 4px;
  color: var(--text-muted); font-size: .94rem;
}
.nav-links a:hover, .nav-links a.active { color: var(--text); background: var(--bg-secondary); }
.nav-user { display: flex; align-items: center; gap: 10px; }
.nav-user-name { color: var(--text-muted); font-size: .9rem; }
.nav-toggle {
  background: transparent; border: 1px solid var(--border);
  color: var(--text); padding: 6px 10px; border-radius: 4px; cursor: pointer;
  font-size: 1rem; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 36px; min-height: 32px;
  text-decoration: none;
}
.nav-toggle:hover { background: var(--bg-secondary); }

/* Inline SVG icons (assets/icons/*.svg via svg_icon() helper). currentColor
   makes them follow the surrounding text color in both themes. */
.nav-toggle .icon { width: 16px; height: 16px; display: block; }
html:not(.dark) .icon-sun  { display: none; }
html.dark         .icon-moon { display: none; }
.nav-burger { display: none; }

/* Mobile nav */
@media (max-width: 880px) {
  .nav-burger {
    display: inline-flex; align-items: center; justify-content: center;
    background: transparent; border: 1px solid var(--border);
    color: var(--text); padding: 6px 10px; border-radius: 4px; cursor: pointer;
    font-size: 1.1rem;
  }
  .nav-links {
    display: none;
    position: absolute; top: 100%; left: 0; right: 0;
    background: var(--bg); border-bottom: 1px solid var(--border);
    flex-direction: column; padding: 8px 16px 14px; gap: 0;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 10px 8px; border-bottom: 1px solid var(--border); }
  .nav-links a:last-child { border-bottom: 0; }
  .nav-user-name { display: none; }
}
/* Narrow phones: tighten the nav bar's own padding/gaps and let the brand
   shrink so the row (brand + burger + theme/logout) never exceeds the
   viewport. Fixes a ~14px horizontal overflow seen at 360px. */
@media (max-width: 480px) {
  .nav-inner { padding: 10px 12px; gap: 8px; }
  .nav-brand { font-size: .98rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .nav-user { gap: 6px; }
}

/* Cards */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 14px;
}
.card > :first-child { margin-top: 0; }
.card > :last-child  { margin-bottom: 0; }
.card-quiet { background: var(--bg-secondary); border-color: var(--border); }
/* details.card: summary acts like a header strip, opens with a divider under it. */
details.card > summary { cursor: pointer; user-select: none; }
details.card[open] > summary { margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }

/* Forms */
.form-row { margin-bottom: 12px; }
.form-row:last-child { margin-bottom: 0; }
label.field-label {
  display: block; font-weight: 600; margin-bottom: 5px; font-size: .92rem;
}
input[type=text], input[type=email], input[type=password], input[type=url],
input[type=number], input[type=date], input[type=tel], input[type=search],
select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border-strong);
  border-radius: 4px; background: var(--bg); color: var(--text);
  font: inherit; font-size: .96rem;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent);
}
textarea { resize: vertical; min-height: 100px; }
.field-hint { color: var(--text-muted); font-size: .85rem; margin-top: 4px; }
.field-error { color: var(--danger-text); font-size: .88rem; margin-top: 4px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 16px; min-height: 38px; line-height: 1.2;
  border-radius: 4px; cursor: pointer;
  background: var(--accent); color: var(--accent-text);
  border: 1px solid var(--accent);
  font: inherit; font-weight: 600;
  text-decoration: none; text-align: center;
  gap: 6px;
}
.btn + .btn { margin-left: 6px; }
.btn:hover { opacity: .9; color: var(--accent-text); }
.btn:disabled, .btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-secondary {
  background: transparent; color: var(--text); border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--bg-secondary); color: var(--text); }
.btn-danger {
  background: var(--danger-bg); color: var(--danger-text); border-color: var(--danger-text);
}
.btn-sm { padding: 4px 10px; min-height: 30px; font-size: .86rem; }

/* Tables (.table and .data-table both supported — same behavior) */
.table, .data-table { width: 100%; border-collapse: collapse; font-size: .94rem; }
.table th, .table td,
.data-table th, .data-table td {
  padding: 8px 12px; border-bottom: 1px solid var(--border);
  text-align: left; vertical-align: top;
}
.table th, .data-table th { background: var(--bg-secondary); font-weight: 600; font-size: .88rem; }
.table tr:hover td, .data-table tr:hover td { background: var(--bg-secondary); }
.table-wrap { overflow-x: auto; }

/* Badges */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: .76rem; font-weight: 600; letter-spacing: .03em;
  background: var(--bg-tertiary); color: var(--text);
  border: 1px solid var(--border);
}
.badge-dark { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.badge-danger { background: var(--danger-bg); color: var(--danger-text); border-color: var(--danger-text); }
.badge-success { background: var(--success-bg); color: var(--success-text); border-color: var(--success-text); }
.badge-warning { background: var(--warning-bg); color: var(--warning-text); border-color: var(--warning-text); }

/* Flash */
.flash {
  padding: 9px 13px; border-radius: 4px; margin: 0 0 12px;
  border: 1px solid var(--border);
}
.flash:last-child { margin-bottom: 14px; }
.flash-success { background: var(--success-bg); color: var(--success-text); border-color: var(--success-text); }
.flash-error { background: var(--danger-bg); color: var(--danger-text); border-color: var(--danger-text); }
.flash-info { background: var(--info-bg); color: var(--info-text); }

/* Avatar */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--bg-tertiary); color: var(--text);
  font-weight: 600; font-size: .85rem;
  border: 1px solid var(--border);
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 96px; height: 96px; font-size: 1.6rem; }
.avatar-xl { width: 160px; height: 160px; font-size: 2.4rem; }

/* Board post */
.post {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 14px;
}
.post-landlord {
  border-left: 3px solid var(--accent);
}
.post-pinned {
  background: var(--bg-secondary);
}
.post-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 12px;
}
.post-author { font-weight: 600; }
.post-author-landlord { font-weight: 700; }
.post-meta { color: var(--text-muted); font-size: .85rem; }
.post-body { white-space: normal; word-break: break-word; }
.post-body a { word-break: break-all; }
.post-images {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px; margin-top: 12px;
}
.post-images img {
  width: 100%; height: 140px; object-fit: cover; border-radius: 4px;
  cursor: pointer; border: 1px solid var(--border);
}
.post-yt { margin-top: 14px; }
.post-yt-frame {
  position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; border-radius: 4px;
  background: #000;
}
.post-yt-frame iframe {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: 0;
}
.post-footer {
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border);
  display: flex; gap: 14px; align-items: center; flex-wrap: wrap;
  font-size: .9rem; color: var(--text-muted);
}
.post-footer a, .post-footer button { color: var(--text-muted); }

/* Comments */
.comment {
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.comment:last-child { border-bottom: 0; }
.comment-header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 6px;
}
.comment-author { font-weight: 600; font-size: .92rem; }
.comment-meta { color: var(--text-muted); font-size: .82rem; }

/* Directory */
.directory-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 14px;
}
@media (min-width: 680px) {
  .directory-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.tenant-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 12px;
  text-align: center;
  text-decoration: none;
  color: var(--text);
}
.tenant-card:hover { background: var(--bg-secondary); color: var(--text); }
.tenant-card .avatar { margin: 0 auto 8px; }
.tenant-card-name { font-weight: 600; margin-top: 4px; line-height: 1.25; }
.tenant-card-specialty { font-size: .86rem; color: var(--text-muted); margin-top: 2px; }
.tenant-card-suite { font-size: .8rem; color: var(--text-muted); margin-top: 2px; }

/* Lightbox */
.lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,.92);
  display: none; align-items: center; justify-content: center;
  z-index: 9000; cursor: zoom-out;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 92vw; max-height: 92vh; object-fit: contain; }

/* Announcement modal */
.announce-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.78);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999; padding: 20px;
}
.announce-modal {
  background: var(--bg); color: var(--text);
  max-width: 560px; width: 100%;
  border-radius: 6px; border: 1px solid var(--border);
  padding: 26px; max-height: 86vh; overflow: auto;
}
.announce-modal h2 { margin-top: 0; }

/* Utilities */
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 6px; } .mt-2 { margin-top: 12px; } .mt-3 { margin-top: 20px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 6px; } .mb-2 { margin-bottom: 12px; } .mb-3 { margin-bottom: 20px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: .88rem; }
.text-center { text-align: center; }
.flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.hidden { display: none !important; }
.divider { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }
.list-clean { list-style: none; padding: 0; margin: 0; }
.list-clean li + li { margin-top: 4px; }
/* Add `.list-divided` for borders between items (used on long admin link lists). */
.list-divided li { padding: 6px 0; border-bottom: 1px solid var(--border); }
.list-divided li:last-child { border-bottom: 0; }

/* File icon + doc-row (tighter card for dense file lists). */
.file-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 36px; background: var(--bg-tertiary);
  border: 1px solid var(--border); border-radius: 3px;
  font-size: .68rem; font-weight: 700; color: var(--text-muted);
}
.doc-row.card { padding: 10px 14px; }

/* Radio/checkbox option row — used by maintenance priority, social platforms. */
.choice-row {
  display: flex; flex-wrap: wrap; gap: 14px;
  margin-bottom: 4px;
}
.choice-row label {
  display: inline-flex; align-items: center; gap: 6px;
  cursor: pointer; font-size: .94rem;
}

/* FAQ */
.faq-entry { padding: 14px 0; border-bottom: 1px solid var(--border); }
.faq-q { font-weight: 600; margin: 0 0 6px; font-size: 1rem; }
.faq-a { color: var(--text-muted); }
.faq-cat-heading { margin-top: 28px; padding-bottom: 4px; border-bottom: 2px solid var(--border); }

/* Auth pages */
.auth-wrap {
  max-width: 420px; margin: 48px auto; padding: 0 20px;
}
.auth-wrap .card { padding: 22px; }
.auth-title { margin-top: 0; text-align: center; }
.auth-tagline { text-align: center; color: var(--text-muted); margin-bottom: 16px; }

/* Autocomplete (type-to-filter list under an input) */
.ac { position: relative; }
.ac-list {
  position: absolute; top: calc(100% + 2px); left: 0; right: 0; z-index: 60;
  background: var(--bg); border: 1px solid var(--border-strong); border-radius: 4px;
  max-height: 280px; overflow-y: auto;
  box-shadow: var(--shadow);
}
.ac-item { padding: 8px 12px; cursor: pointer; font-size: .94rem; border-bottom: 1px solid var(--border); }
.ac-item:last-child { border-bottom: 0; }
.ac-item:hover, .ac-item.ac-active { background: var(--accent); color: var(--accent-text); }

/* Inline form (reorder, add) */
.inline-form { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0; }
.inline-form input[type=text], .inline-form input[type=email] { width: auto; flex: 1; }
.inline-form + .inline-form { margin-left: 8px; }

/* ============================================================
   Responsive hardening (added 2026-05-20) — verified usable from
   ~320px phones through tablets to desktop. Centralized here so it
   covers every page without per-file markup changes.
   ============================================================ */

/* A long unbreakable string (email, URL, signing token) must never push
   the page wider than the screen. */
body { overflow-wrap: break-word; }
pre { max-width: 100%; overflow: auto; }

/* Any data table stays usable on a phone: it scrolls horizontally inside
   its OWN box rather than forcing the whole page to scroll sideways. This
   applies whether or not the table was wrapped in .table-wrap, so no table
   anywhere can break the layout. */
.table-wrap { -webkit-overflow-scrolling: touch; }
@media (max-width: 640px) {
  .table, .data-table {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  /* Keep columns at a readable width while the table scrolls, instead of
     squishing every cell down to one character. */
  .table th, .table td,
  .data-table th, .data-table td { white-space: nowrap; }
}

/* iOS Safari zoom-jumps the whole page whenever a focused input is smaller
   than 16px. Bump form controls to 16px on phones to stop that. */
@media (max-width: 640px) {
  input[type=text], input[type=email], input[type=password], input[type=url],
  input[type=number], input[type=date], input[type=tel], input[type=search],
  select, textarea { font-size: 16px; }
}

/* Title + action-button header rows ( .flex.between ) and side-by-side
   buttons stay tidy on the smallest screens. */
@media (max-width: 600px) {
  .flex.between { gap: 8px 10px; }
}
@media (max-width: 380px) {
  .btn { padding: 8px 12px; }
  .btn + .btn { margin-left: 4px; }
}
