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

:root {
  --teal: #2DD4BF;
  --teal-dark: #14b8a4;
  --red: #EF4444;
  --red-dark: #dc2626;
  --text: #1a1a1a;
  --label: #888;
  --muted: #666;
  --radius: 12px;
  --sidebar-w: 240px;
  --topbar-h: 64px;
}

html { height: 100%; }

body {
  height: 100%;
  font-family: 'DM Sans', sans-serif;
  background: #f4f1ea;
  color: var(--text);
  margin: 0;
}

/* ── Sidebar (identical to Resident side) ── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: #15296b;
  display: flex;
  flex-direction: column;
  z-index: 200;
  overflow: hidden;
  transition: transform .3s cubic-bezier(.4,0,.2,1);
}

.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 28px 24px 24px;
  border-bottom: 1px solid rgba(255,255,255,.14);
  flex-shrink: 0;
}
.sidebar-logo .logo-icon {
  width: 40px; height: 40px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.sidebar-logo .logo-icon img { width: 100%; height: 100%; object-fit: contain; }
.sidebar-logo span {
  font-family: 'Poppins', serif; font-size: 18px; color: #fff; font-weight: 700;
}

.sidebar-close {
  display: none;
  margin-left: auto;
  background: rgba(255,255,255,.10);
  border: none; border-radius: 8px;
  width: 32px; height: 32px;
  align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  transition: background .15s;
}
.sidebar-close:hover { background: rgba(255,255,255,.20); }
.sidebar-close svg { width: 16px; height: 16px; color: rgba(255,255,255,.9); }

.sidebar-nav {
  flex: 1; padding: 16px 12px;
  display: flex; flex-direction: column; gap: 2px;
  overflow-y: auto;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 10px; font-size: 13.5px;
  color: rgba(255,255,255,.88); font-weight: 500; cursor: pointer; text-decoration: none;
  transition: background .15s, color .15s; white-space: nowrap;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; color: #f4b62a; transition: color .15s; }
.nav-item:hover  { background: rgba(255,255,255,.12); color: #fff; }
.nav-item.active { background: #f4b62a; color: #15296b; font-weight: 700; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.nav-item.active svg { color: #15296b; }

.nav-badge {
  margin-left: auto; background: var(--red); color: #fff;
  font-size: 10px; font-weight: 700; border-radius: 999px;
  padding: 1px 7px; line-height: 1.5;
}

.sidebar-footer {
  padding: 12px 12px 20px;
  border-top: 1px solid rgba(255,255,255,.14);
  flex-shrink: 0;
}
.nav-item.logout { color: #ff9a9a; }
.nav-item.logout:hover { background: rgba(239,68,68,.18); color: #ffc2c2; }
.nav-item.logout svg { color: inherit; }

.drawer-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 199;
  opacity: 0;
  transition: opacity .3s;
}
.drawer-overlay.open { opacity: 1; }

/* ── Page shell ── */
.page-shell {
  margin-left: var(--sidebar-w);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Topbar ── */
.topbar {
  flex-shrink: 0;
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid #d4cfc5;
  padding: 0 32px;
  display: flex; align-items: center; justify-content: space-between;
  z-index: 50; gap: 12px;
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-left h1 {
  font-family: 'Poppins', serif; font-size: 20px; font-weight: 700;
  color: var(--text); white-space: nowrap;
}
.topbar-left p { font-size: 12px; color: var(--muted); margin-top: 1px; white-space: nowrap; }
.topbar-right  { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }

.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px; height: 36px;
  border: none; background: transparent;
  cursor: pointer; padding: 6px; border-radius: 8px;
  flex-shrink: 0; transition: background .15s;
}
.hamburger:hover { background: #f0ece3; }
.hamburger span {
  display: block; width: 100%; height: 2px;
  background: var(--text); border-radius: 2px;
  transition: transform .25s, opacity .25s;
}
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.user-chip {
  display: flex; align-items: center; gap: 8px;
  background: #f4f1ea; border-radius: 999px;
  padding: 6px 14px 6px 6px; font-size: 13px; color: var(--text); font-weight: 500;
}
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--teal);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #0d2e29; flex-shrink: 0;
}

/* ── To-Do panel ── */
.todo-wrap { position: relative; }
.todo-btn {
  position: relative;
  display: flex; align-items: center; gap: 7px;
  background: #f4f1ea; border: none; border-radius: 999px;
  padding: 8px 14px; font-size: 13px; font-weight: 600; color: var(--text);
  cursor: pointer; transition: background .15s;
  font-family: 'DM Sans', sans-serif;
}
.todo-btn:hover { background: #ece7db; }
.todo-btn svg { width: 17px; height: 17px; color: var(--teal-dark); flex-shrink: 0; }
.todo-btn-count {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--red); color: #fff; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.todo-panel {
  display: none;
  position: absolute; top: calc(100% + 10px); right: 0;
  width: 320px; max-width: calc(100vw - 32px);
  background: #fff; border: 1px solid #d4cfc5; border-radius: 14px;
  box-shadow: 0 12px 32px rgba(0,0,0,.14);
  z-index: 60; overflow: hidden;
}
.todo-panel.open { display: block; }
.todo-panel-header {
  padding: 14px 16px 12px; border-bottom: 1px solid #f0ece3;
  display: flex; align-items: baseline; justify-content: space-between;
}
.todo-panel-header h4 {
  font-family: 'Poppins', serif; font-size: 15px; font-weight: 700; color: var(--text);
}
.todo-panel-header span { font-size: 11px; color: var(--muted); }
.todo-list { list-style: none; max-height: 360px; overflow-y: auto; }
.todo-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px; text-decoration: none; color: var(--text);
  border-bottom: 1px solid #f6f3ec; transition: background .12s;
}
.todo-item:last-child { border-bottom: none; }
.todo-item:hover { background: #faf8f3; }
.todo-item-icon {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  background: rgba(45,212,191,.15); display: flex; align-items: center; justify-content: center;
}
.todo-item-icon svg { width: 15px; height: 15px; color: var(--teal-dark); }
.todo-item.danger .todo-item-icon { background: rgba(239,68,68,.13); }
.todo-item.danger .todo-item-icon svg { color: var(--red-dark); }
.todo-item-body { min-width: 0; flex: 1; }
.todo-item-title { font-size: 13px; font-weight: 600; line-height: 1.35; }
.todo-item-desc { font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.4; }
.todo-item-count {
  flex-shrink: 0; margin-top: 1px;
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--teal); color: #0d2e29; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.todo-empty { padding: 28px 16px; text-align: center; color: var(--muted); font-size: 13px; }
@media (max-width: 480px) {
  .todo-panel { position: fixed; top: var(--topbar-h); left: 12px; right: 12px; width: auto; }
  .todo-btn span.todo-btn-label { display: none; }
}

/* ── Content ── */
.content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 28px 32px 60px;
}

/* Utility: a row of header actions (e.g. next to an sc-header title)
   that wraps gracefully instead of overflowing narrow viewports, and
   stacks to full-width buttons on small mobile for easier tapping. */
.sc-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.content::-webkit-scrollbar { width: 5px; }
.content::-webkit-scrollbar-track { background: transparent; }
.content::-webkit-scrollbar-thumb { background: #d4cfc5; border-radius: 10px; }

.page-head { margin-bottom: 22px; }
.page-head h2 {
  font-family: 'Poppins', serif; font-size: 22px; font-weight: 700; color: var(--text);
  margin-bottom: 4px;
}
.page-head p { font-size: 13px; color: var(--muted); }

/* ── Flash messages ── */
.flash {
  border-radius: 10px; padding: 12px 16px; font-size: 13px;
  margin-bottom: 20px; border: 1px solid transparent;
}
.flash-success { background: #d1fae5; border-color: #99e6da; color: #0d5c50; }
.flash-error   { background: #fee2e2; border-color: #fca5a5; color: #7f1d1d; }

/* ── Stat cards ── */
.stat-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px;
  margin-bottom: 28px;
}
.stat-card {
  background: #fff; border: 1px solid #d4cfc5; border-radius: 16px;
  padding: 20px 22px;
}
.stat-card .stat-icon {
  width: 34px; height: 34px; border-radius: 9px; background: #f0faf8;
  display: flex; align-items: center; justify-content: center; margin-bottom: 14px;
}
.stat-card .stat-icon svg { width: 17px; height: 17px; color: var(--teal-dark); }
.stat-card.warn .stat-icon { background: #fffbeb; }
.stat-card.warn .stat-icon svg { color: #d97706; }
.stat-value {
  font-family: 'Poppins', serif; font-size: 28px; font-weight: 700; color: var(--text);
  line-height: 1.1; margin-bottom: 4px;
}
.stat-label { font-size: 12.5px; color: var(--muted); }

/* ── Record card (Payments, and any other list-of-records page) ──
   Same visual language as the Rentals mobile stacked-card view
   (label/value rows + full-width action buttons), but used at every
   screen size rather than only kicking in on mobile — this data
   doesn't fit a table (variable extra notes per row), so one clean
   card design end-to-end reads better than a table-on-desktop /
   card-on-mobile split. */
.record-list { display: flex; flex-direction: column; gap: 12px; }
.record-card { border: 1px solid #e5e0d5; border-radius: 10px; padding: 4px 16px; }
.record-top { display: flex; gap: 8px; flex-wrap: wrap; padding: 14px 0 10px; }
.record-fields { display: flex; flex-direction: column; }
.record-field {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 14px; padding: 8px 0; border-bottom: 1px solid #f0ece3; font-size: 13.5px;
}
.record-fields .record-field:last-child { border-bottom: none; }
.rf-label {
  font-weight: 600; font-size: 11px; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted); flex-shrink: 0; padding-top: 1px;
}
.rf-value { color: var(--text); text-align: right; }
.record-note {
  font-size: 13px; color: #444; background: #fff8ee; border: 1px solid #f0e0bf;
  border-radius: 6px; padding: 8px 10px; margin: 2px 0 12px;
}
.record-actions { display: flex; flex-direction: column; gap: 8px; padding: 14px 0 16px; }
.record-actions .btn { width: 100%; justify-content: center; }
@media screen and (max-width: 900px) {
  .record-actions .btn { padding-top: 11px; padding-bottom: 11px; } /* bigger tap target */
}

/* ── Section card ── */
.section-card {
  background: #fff; border-radius: 16px; border: 1px solid #d4cfc5;
  padding: 22px 24px 26px; margin-bottom: 20px;
}
.sc-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid #f0ece3; flex-wrap: wrap;
}
.sc-header h3 {
  font-family: 'Poppins', serif; font-size: 15px; font-weight: 700; color: var(--text);
}

/* ── Toolbar (search + filters) ── */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toolbar input[type="text"],
.toolbar select {
  font-family: 'DM Sans', sans-serif; font-size: 13px; color: var(--text);
  background: #faf8f3; border: 1.5px solid #ddd8cc; border-radius: 10px;
  padding: 9px 13px; outline: none; transition: border-color .2s;
}
.toolbar input[type="text"]:focus,
.toolbar select:focus { border-color: var(--teal-dark); }

/* ── Table ── */
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
  text-align: left; font-size: 11px; font-weight: 600; color: var(--label);
  text-transform: uppercase; letter-spacing: .06em;
  padding: 10px 14px; border-bottom: 1.5px solid #f0ece3; white-space: nowrap;
}
.data-table td {
  padding: 13px 14px; border-bottom: 1px solid #f4f1ea; color: var(--text); vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #faf8f3; }

.mini-user { display: flex; align-items: center; gap: 10px; }
.mini-avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--teal);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #0d2e29; flex-shrink: 0;
}
.mini-user .name { font-weight: 500; }
.mini-user .sub { font-size: 11.5px; color: var(--muted); }

/* ── Badges ── */
.badge {
  display: inline-block; border-radius: 999px; padding: 3px 11px;
  font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  border: 1px solid transparent; white-space: nowrap;
}
.badge-pending  { background: #fef3c7; border-color: #fcd34d; color: #b45309; }
.badge-verified { background: #d1fae5; border-color: #99e6da; color: #0d5c50; }
.badge-active   { background: #d1fae5; border-color: #99e6da; color: #0d5c50; }
.badge-disabled { background: #fee2e2; border-color: #fca5a5; color: #7f1d1d; }
.badge-role     { background: #f0ece3; border-color: #e0dbd0; color: #555; }

/* ── Status banner (unverified-account notices, etc.) ──
   Defined here in the shared stylesheet — not just dashboard.css —
   so it renders correctly on Officials/Admin pages too, which don't
   load Residents/dashboard.css. */
.status-banner {
  display: flex; align-items: center; gap: 12px;
  background: #fffbeb; border: 1px solid #fcd34d;
  border-radius: 12px; padding: 13px 18px; margin-bottom: 24px;
  font-size: 13px; color: #92400e;
}
.status-banner svg { width: 17px; height: 17px; flex-shrink: 0; color: #d97706; }
.status-banner strong { font-weight: 600; }
.status-badge {
  margin-left: auto; background: #fef3c7; border: 1px solid #fcd34d;
  border-radius: 999px; padding: 3px 12px; font-size: 11px;
  font-weight: 600; color: #b45309; text-transform: uppercase;
  letter-spacing: .06em; white-space: nowrap;
}
@media screen and (max-width: 900px) {
  .status-banner { flex-wrap: wrap; gap: 8px; }
}

/* ── Resident search/autocomplete (walk-in rentals, staff-filed
   blotter reports, staff-filed document requests) ── */
.autocomplete-results {
  position: absolute; z-index: 20; top: 100%; left: 0; right: 0;
  background: #fff; border: 1px solid #e0dbd0; border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.12); max-height: 220px; overflow-y: auto; margin-top: 4px;
}
.autocomplete-item { padding: 9px 12px; cursor: pointer; font-size: 13px; border-bottom: 1px solid #f3f0e9; }
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover, .autocomplete-item.active { background: #faf7f0; }
.autocomplete-item .ac-name { font-weight: 600; color: #222; }
.autocomplete-item .ac-meta { font-size: 11.5px; color: var(--muted); }
.autocomplete-empty { padding: 9px 12px; font-size: 12.5px; color: var(--muted); }

/* ── Buttons ── */
.btn {
  font-family: 'DM Sans', sans-serif; font-size: 13px; font-weight: 500;
  border-radius: 10px; padding: 9px 18px; cursor: pointer; border: none;
  transition: background .15s, transform .1s; display: inline-flex; align-items: center; gap: 6px;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.btn-disabled {
  opacity: .5; cursor: not-allowed; pointer-events: none;
}
.btn-teal    { background: var(--teal); color: #0d2e29; }
.btn-teal:hover { background: var(--teal-dark); }
.btn-outline { background: #faf8f3; border: 1.5px solid #c9c2b0; color: var(--text); }
.btn-outline:hover { background: #f0ece3; border-color: #b3a993; color: var(--text); }
/* Action-based button colors — kept as soft tints (not solid blocks) so a table full of
   them still reads calmly. Teal/outline above stay the primary/neutral defaults. */
.btn-danger  { background: #fee2e2; color: #7f1d1d; }   /* delete, reject, cancel/deactivate */
.btn-danger:hover { background: #fecaca; }
.btn-success { background: #dcfce7; color: #166534; }   /* approve, accept, confirm paid/refund */
.btn-success:hover { background: #bbf7d0; }
.btn-warning { background: #fef3c7; color: #92400e; }   /* edit, update, process */
.btn-warning:hover { background: #fde68a; }
.btn-info    { background: #dbeafe; color: #1e40af; }   /* view, history, print, filter/search */
.btn-info:hover { background: #bfdbfe; }
.btn-sm { padding: 6px 13px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }

.actions-cell { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions-cell form { display: contents; } /* lets a <form>-wrapped button act as a direct flex item */

/* ── Forms ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 12px; font-weight: 500; color: #444; }
.field input, .field select, .field textarea {
  font-family: 'DM Sans', sans-serif; font-size: 14px; color: var(--text);
  background: #faf8f3; border: 1.5px solid #ddd8cc; border-radius: var(--radius);
  padding: 10px 14px; outline: none; transition: border-color .2s, box-shadow .2s; width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--teal-dark); box-shadow: 0 0 0 3px rgba(45,212,191,.14); background: #fff;
}
.field textarea { resize: vertical; min-height: 90px; line-height: 1.6; }
.hint { font-size: 11.5px; color: var(--muted); margin-top: -8px; margin-bottom: 16px; }

/* ── Document Fees editor (Admin/Officials Payments page) ── */
.fees-card .sc-header { align-items: flex-start; }
.fee-scroll-wrap { position: relative; margin-bottom: 4px; }
.fee-grid {
  display: flex; gap: 14px;
  overflow-x: auto; scroll-behavior: smooth; scroll-snap-type: x proximity;
  padding: 4px 4px 14px; margin: -4px -4px -10px;
  scrollbar-width: thin; scrollbar-color: #d8d2c4 transparent;
}
.fee-grid::-webkit-scrollbar { height: 6px; }
.fee-grid::-webkit-scrollbar-track { background: transparent; }
.fee-grid::-webkit-scrollbar-thumb { background: #d8d2c4; border-radius: 4px; }
.fee-scroll-btn {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid #d4cfc5;
  background: #fff; color: var(--teal-dark); font-size: 20px; line-height: 1; padding: 0;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,.1); z-index: 2; transition: background .15s;
}
.fee-scroll-btn:hover { background: #f0faf8; }
.fee-scroll-prev { left: -14px; }
.fee-scroll-next { right: -14px; }
.fee-card {
  display: flex; flex-direction: column; flex: 0 0 220px; width: 220px;
  scroll-snap-align: start;
  background: #faf8f3; border: 1px solid #d4cfc5; border-radius: 14px;
  padding: 16px; transition: border-color .15s, box-shadow .15s;
}
.fee-card:focus-within { border-color: var(--teal-dark); box-shadow: 0 0 0 3px rgba(45,212,191,.14); }
.fee-card-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 14px; }
.fee-icon { margin-top: 1px; }
.fee-icon {
  width: 32px; height: 32px; border-radius: 9px; background: #f0faf8;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  overflow: hidden;
}
.fee-icon svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--teal-dark); }
.fee-name { font-size: 13px; font-weight: 600; color: var(--text); line-height: 1.3; }
.fee-form { display: flex; flex-direction: column; gap: 10px; margin-top: auto; }
.fee-input-wrap {
  display: flex; align-items: center; background: #fff; border: 1.5px solid #ddd8cc;
  border-radius: 10px; overflow: hidden; transition: border-color .15s;
}
.fee-input-wrap:focus-within { border-color: var(--teal-dark); }
.fee-input-wrap .peso {
  padding: 0 0 0 12px; font-size: 14px; font-weight: 600; color: var(--muted);
}
.fee-input-wrap input[type="number"] {
  flex: 1; min-width: 0; border: none; outline: none; background: transparent;
  font-family: 'DM Sans', sans-serif; font-size: 15px; font-weight: 600; color: var(--text);
  padding: 10px 12px 10px 6px;
}
.fee-input-wrap input[type="number"]:disabled { color: var(--muted); }
.fee-form .btn { width: 100%; justify-content: center; }
.fee-free-tag {
  display: inline-block; margin-top: 8px; font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em; color: var(--teal-dark);
}
.fee-empty {
  font-size: 13px; color: var(--muted); background: #fff8ee; border: 1px solid #f0e0bf;
  border-radius: 10px; padding: 14px 16px; line-height: 1.6;
}
.fee-empty code {
  background: #fff; border: 1px solid #f0e0bf; border-radius: 4px; padding: 1px 5px; font-size: 12px;
}
@media screen and (max-width: 480px) {
  .fee-grid { gap: 10px; }
  .fee-card { flex-basis: 165px; width: 165px; padding: 13px; }
  .fee-scroll-btn { width: 28px; height: 28px; font-size: 16px; }
  .fee-scroll-prev { left: -8px; }
  .fee-scroll-next { right: -8px; }
  .fee-card-head { margin-bottom: 10px; gap: 8px; }
  .fee-icon { width: 28px; height: 28px; }
  .fee-icon svg { width: 14px; height: 14px; }
  .fee-name { font-size: 12.5px; }
}
.req { color: var(--red); }

/* ── Confirmation modal (replaces native confirm()) ── */
.confirm-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15,45,26,.55);
  z-index: 500;
  align-items: center; justify-content: center;
  padding: 20px;
}
.confirm-overlay.open { display: flex; }
.confirm-box {
  background: #fff; border-radius: 16px;
  padding: 26px 26px 22px; max-width: 360px; width: 100%;
  box-shadow: 0 24px 60px rgba(0,0,0,.3);
  animation: confirmPop .18s ease both;
}
@keyframes confirmPop {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.confirm-icon {
  width: 44px; height: 44px; border-radius: 50%;
  background: #f0faf8; display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
}
.confirm-icon svg { width: 22px; height: 22px; color: var(--teal-dark); }
.confirm-box.danger .confirm-icon { background: #fee2e2; }
.confirm-box.danger .confirm-icon svg { color: var(--red-dark); }
.confirm-box h4 {
  font-family: 'Poppins', serif; font-size: 16px; font-weight: 700;
  color: var(--text); margin-bottom: 8px;
}
.confirm-box p { font-size: 13px; color: var(--muted); line-height: 1.6; margin-bottom: 22px; }
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); font-size: 13.5px; }

/* ── Two-column layout ── */
.layout-2col { display: grid; grid-template-columns: 1.3fr .9fr; gap: 20px; align-items: start; }

/* Laptop — smaller windows/lower-res laptops get a bit more room
   without yet dropping into the tablet card layout below. */
@media screen and (max-width: 1200px) {
  :root { --sidebar-w: 220px; }
  .content { padding: 24px 24px 50px; }
  .stat-grid { gap: 14px; }
}

@media screen and (max-width: 960px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .layout-2col { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }

  /* Safety net: a plain (non data-table-responsive) table wider than
     its container scrolls horizontally within itself instead of
     pushing the whole page wide — previously this only kicked in
     below 768px, leaving a gap on tablet-landscape/small-laptop. */
  .data-table:not(.data-table-responsive) { display: block; overflow-x: auto; white-space: nowrap; }
}

/* Tablet & mobile — sidebar becomes a drawer, wide tables become
   stacked cards. Raised from 768 to 900px: below 900 there isn't
   enough room for a fixed desktop sidebar *and* a multi-column table
   side by side, and leaving that gap here previously let table
   content spill outside the section-card on tablet widths. */
@media screen and (max-width: 900px) {
  .sidebar { transform: translateX(-100%); width: 260px; }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,.3); }
  .drawer-overlay { display: block; pointer-events: none; }
  .drawer-overlay.open { pointer-events: auto; }
  .page-shell { margin-left: 0; }
  .hamburger { display: flex; }
  .sidebar-close { display: flex; }
  .topbar { padding: 0 16px; }
  .content { padding: 20px 16px 40px; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .data-table { display: block; overflow-x: auto; white-space: nowrap; }

  /* Opt-in stacked-card layout for tables with lots of columns (e.g. Rentals
     catalog) where horizontal scrolling is awkward. Add the class
     data-table-responsive alongside data-table, and data-label="..." on
     each <td> matching its header, to use this instead of scrolling. */
  table.data-table.data-table-responsive { display: block; overflow-x: visible; white-space: normal; }
  .data-table-responsive thead { display: none; }
  .data-table-responsive tbody { display: block; }
  .data-table-responsive tr {
    display: block; border: 1px solid #e5e0d5; border-radius: 10px;
    padding: 4px 14px; margin-bottom: 12px;
  }
  .data-table-responsive tr:hover td { background: none; }
  .data-table-responsive td {
    display: flex; justify-content: space-between; align-items: center;
    gap: 14px; padding: 8px 0; border-bottom: 1px solid #f0ece3;
  }
  .data-table-responsive td:last-child { border-bottom: none; }
  .data-table-responsive td::before {
    content: attr(data-label); font-weight: 600; font-size: 11px;
    text-transform: uppercase; letter-spacing: .04em; color: var(--muted); flex-shrink: 0;
  }

  /* Cells holding action buttons (Pay Now / Cancel / View, etc.) need
     their own treatment: the label/value row layout above works for
     plain text, but a variable number of differently-sized pill
     buttons squeezed into that same row looks inconsistent from card
     to card. Inside the mobile stacked view, actions-cell buttons
     instead stack full-width and uniform, one per line. */
  .data-table-responsive td.actions-cell {
    display: flex; flex-direction: column; align-items: stretch; gap: 8px;
  }
  .data-table-responsive td.actions-cell::before { content: none; }
  .data-table-responsive td.actions-cell .btn {
    width: 100%; justify-content: center;
    padding-top: 11px; padding-bottom: 11px; /* bigger tap target on touch screens */
  }

  /* Header action groups (e.g. "View Calendar" + "Book" next to a
     section title) stack full-width instead of squeezing two labeled
     buttons into one cramped row. */
  .sc-actions { flex-direction: column; align-items: stretch; width: 100%; }
  .sc-actions .btn { width: 100%; justify-content: center; }

  .modal-close-btn { padding: 8px; }
}

@media screen and (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .user-chip span { display: none; }

  /* Search/filter inputs in .toolbar often carry an inline
     min-width (200-240px) sized for desktop; on very narrow phones
     that can force the row wider than the viewport. */
  .toolbar input[type="text"] { min-width: 0 !important; width: 100%; }

  .modal-box { padding: 20px 18px 22px; border-radius: 14px; }
}

/* ── Print reset ──
   Forces the full desktop layout when printing, regardless of what
   screen size/device the page happened to be viewed on (mobile,
   DevTools device toolbar, etc). The @media (max-width) rules above
   are scoped to "screen" so they never apply here, but we also
   explicitly restore anything a narrow screen might have collapsed. */
@media print {
  .sidebar, .drawer-overlay, .hamburger, .sidebar-close { display: none !important; }
  .page-shell { margin-left: 0 !important; height: auto !important; overflow: visible !important; }
  .content { padding: 0 !important; overflow: visible !important; height: auto !important; flex: none !important; }
  .topbar { display: none !important; }
  .stat-grid { grid-template-columns: repeat(4, 1fr) !important; gap: 12px !important; }
  .layout-2col { grid-template-columns: 1.3fr .9fr !important; }
  .grid-2 { grid-template-columns: 1fr 1fr !important; }
  .grid-3 { grid-template-columns: 1fr 1fr 1fr !important; }
  .data-table {
    display: table !important;
    table-layout: fixed !important;
    overflow-x: visible !important;
    width: 100% !important;
    font-size: 11px !important;
  }
  .data-table th, .data-table td {
    white-space: normal !important;
    word-break: break-word !important;
    padding: 6px 8px !important;
  }
  .data-table thead { display: table-header-group; }
  .data-table tr { page-break-inside: avoid; }
  .user-chip span { display: inline !important; }
  body { background: #fff !important; }
}

/* Printed pages use standard portrait with reasonable margins.
   The .data-table rules above (table-layout: fixed + wrapping)
   are what actually keep wide tables from overflowing — this just
   sets sensible page margins. */
@page {
  margin: 14mm 12mm;
}

/* ── Status-colored left borders for request/case rows ──
   Used on Certificate Requests and Blotter listings so each entry's
   status is visible at a glance, not just from the small badge text. */
.status-row { border-left: 4px solid transparent; padding-left: 14px !important; }
.status-row-pending, .status-row-open { border-left-color: #fbbf24; }
.status-row-processing, .status-row-under_investigation { border-left-color: #60a5fa; }
.status-row-for_printing { border-left-color: #f59e0b; }
.status-row-ready { border-left-color: #a78bfa; }
.status-row-approved { border-left-color: #34d399; }
.status-row-released, .status-row-resolved, .status-row-completed { border-left-color: #34d399; }
.status-row-rejected { border-left-color: #f87171; }
.status-row-dismissed, .status-row-cancelled { border-left-color: #9ca3af; }

/* ── Master-detail row (Blotter / Certifications / Payments / Rentals
   staff queues): free-text content on the left, a fixed action column
   on the right. Stacks with full-width actions on mobile so tap
   targets match the rest of the app instead of staying pinned at a
   cramped fixed width. */
.row-card {
  padding: 16px 14px 16px 0; border-bottom: 1px solid #f0ece3;
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 18px; flex-wrap: wrap;
}
.row-card:last-child { border-bottom: none; }
.row-content { flex: 1 1 260px; min-width: 220px; }
.row-actions { display: flex; flex-direction: column; gap: 8px; width: 150px; flex-shrink: 0; }
.row-actions .btn { width: 100%; justify-content: center; }
@media screen and (max-width: 900px) {
  .row-actions { width: 100%; }
  .row-actions .btn { padding-top: 11px; padding-bottom: 11px; } /* bigger tap target */
}

/* ── Status tabs (Certificate Requests, Blotter, Rentals) ── */
.status-tabs {
  display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap;
}
.status-tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 20px; border: 1px solid #e0dbd0;
  background: #fff; color: var(--muted); font-size: 13px; font-weight: 500;
  text-decoration: none; transition: all .15s ease;
}
.status-tab:hover { border-color: var(--teal); color: var(--teal-dark); }
.status-tab.active { background: var(--teal-dark); border-color: var(--teal-dark); color: #fff; }
.status-tab .tab-count {
  background: rgba(0,0,0,.08); border-radius: 10px; padding: 1px 7px; font-size: 11.5px; font-weight: 600;
}
.status-tab.active .tab-count { background: rgba(255,255,255,.25); }

/* ── Pagination ── */
.pagination {
  display: flex; gap: 6px; justify-content: center; align-items: center;
  margin-top: 20px; padding-top: 18px; border-top: 1px solid #f0ece3; flex-wrap: wrap;
}
.page-link {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 32px; height: 32px; padding: 0 8px; border-radius: 8px;
  border: 1px solid #e0dbd0; background: #fff; color: var(--text);
  font-size: 13px; text-decoration: none; transition: all .15s ease;
}
.page-link:hover { border-color: var(--teal); }
.page-link.active { background: var(--teal-dark); border-color: var(--teal-dark); color: #fff; }
.page-link.disabled { opacity: .4; pointer-events: none; }

/* ── Form modal (Request Document, File a Report, etc.) ──
   Reuses the confirmPop animation already defined for .confirm-box. */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15,45,26,.55);
  z-index: 500;
  align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: #fff; border-radius: 16px;
  padding: 26px 26px 28px; max-width: 540px; width: 100%;
  max-height: 88vh; overflow-y: auto;
  box-shadow: 0 24px 60px rgba(0,0,0,.3);
  animation: confirmPop .18s ease both;
}
.modal-box .modal-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px;
}
.modal-box .modal-header h3 { margin: 0; font-family: 'Poppins', serif; font-size: 18px; }
.modal-close-btn {
  background: none; border: none; cursor: pointer; color: var(--muted);
  padding: 4px; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.modal-close-btn:hover { color: var(--text); }

/* ── Rentals calendar ── */
.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px;
}
.cal-weekday {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); text-align: center; padding-bottom: 6px;
}
.cal-day {
  border-radius: 8px; padding: 8px 6px; min-height: 56px;
  display: flex; flex-direction: column; justify-content: space-between;
  border: 1px solid transparent;
}
.cal-day.cal-empty { visibility: hidden; }
.cal-daynum { font-size: 12.5px; font-weight: 600; }
.cal-avail { font-size: 10.5px; opacity: .85; }
.cal-day.cal-free    { background: #d1fae5; border-color: #99e6da; color: #0d5c50; }
.cal-day.cal-partial { background: #fef3c7; border-color: #fcd34d; color: #b45309; }
.cal-day.cal-full    { background: #fee2e2; border-color: #fca5a5; color: #7f1d1d; }
.cal-day.cal-past     { opacity: .45; }
.cal-dot {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px;
}
.cal-dot.cal-free    { background: #34d399; }
.cal-dot.cal-partial { background: #fbbf24; }
.cal-dot.cal-full    { background: #f87171; }

@media screen and (max-width: 480px) {
  .cal-day { min-height: 44px; padding: 6px 4px; }
  .cal-avail { display: none; }
}

/* ── Segmented nav control (e.g. calendar Prev/Today/Next) ──
   Three buttons joined into one connected group instead of loose
   separate buttons, so it reads as a single navigation control. */
.segmented-nav {
  display: inline-flex; border-radius: 10px; overflow: hidden;
  border: 1.5px solid #ddd8cc;
}
.segmented-nav a {
  font-family: 'DM Sans', sans-serif; font-size: 13px; font-weight: 500;
  padding: 9px 16px; color: var(--muted); text-decoration: none;
  background: #fff; border-right: 1.5px solid #ddd8cc;
  transition: background .15s, color .15s;
}
.segmented-nav a:last-child { border-right: none; }
.segmented-nav a:hover { background: #f0ece3; color: var(--text); }
.segmented-nav a.active { background: var(--teal); color: #0d2e29; font-weight: 600; }

/* ── Status timeline (View Details modal) ── */
.timeline { position: relative; padding-left: 22px; margin-top: 4px; }
.timeline-item { position: relative; padding-bottom: 18px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
  content: ''; position: absolute; left: -22px; top: 3px;
  width: 10px; height: 10px; border-radius: 50%; background: var(--teal-dark);
}
.timeline-item::after {
  content: ''; position: absolute; left: -18px; top: 13px; bottom: -5px;
  width: 2px; background: #e0dbd0;
}
.timeline-item:last-child::after { display: none; }
.timeline-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 3px; }
.timeline-date { font-size: 11px; color: var(--muted); }
.timeline-remarks {
  font-size: 13px; color: #444; line-height: 1.55; margin-top: 4px;
  background: #faf8f3; border-radius: 8px; padding: 8px 10px;
}
.timeline-loading, .timeline-empty { font-size: 13px; color: var(--muted); padding: 8px 0; }

/* ── Settings page: live password-requirements checklist ── */
.pw-checklist {
  list-style: none; margin: -6px 0 14px; padding: 0;
  display: flex; flex-direction: column; gap: 4px;
}
.pw-checklist li {
  font-size: 12.5px; color: var(--muted); padding-left: 20px; position: relative;
}
.pw-checklist li::before {
  content: '○'; position: absolute; left: 0; font-size: 11px; top: 1px;
}
.pw-checklist li.met {
  color: #0d5c50;
}
.pw-checklist li.met::before {
  content: '●'; color: #14b8a6;
}

/* ── Settings page: card header icon badge ──
   Reuses the tinted-square icon language already established by the
   dashboard's .stat-icon, so Settings reads as the same system rather
   than a one-off treatment. .warn reuses the same amber tone as
   .stat-card.warn for the one card (Active Sessions) that's a more
   consequential action than the rest. */
.sc-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sc-icon {
  width: 30px; height: 30px; border-radius: 9px; background: #f0faf8;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.sc-icon svg { width: 15px; height: 15px; color: var(--teal-dark); }
.sc-icon .peso-glyph { font-size: 16px; font-weight: 700; color: var(--teal-dark); line-height: 1; font-family: 'DM Sans', sans-serif; }
.sc-icon.warn { background: #fffbeb; }
.sc-icon.warn svg { color: #d97706; }
.sc-note {
  font-size: 12.5px; color: var(--muted); margin: -4px 0 14px; line-height: 1.5;
  overflow-wrap: anywhere; /* long emails/usernames wrap instead of forcing horizontal scroll */
}

/* ── Settings page: masonry-style card layout ──
   A plain 2-column grid gives every row the height of its tallest
   cell, so a short card (Account Information) next to a tall one
   (Change Password) leaves visible dead space beneath it. CSS
   multi-column layout instead flows each card into whichever column
   has room next — same idea as a newspaper page or Pinterest grid —
   so the two columns end up close to evenly filled with no gaps. */
.settings-masonry { columns: 2; column-gap: 20px; }
.settings-masonry .section-card {
  -webkit-column-break-inside: avoid;
  break-inside: avoid;
  margin-bottom: 20px;
}
@media screen and (max-width: 960px) {
  .settings-masonry { columns: 1; }
}

/* ── Settings page: email-OTP verification actions ── */
.otp-actions {
  display: flex; gap: 16px; margin-top: 10px; flex-wrap: wrap;
}
.otp-inline-form { display: inline; }
.btn-link {
  background: none; border: none; padding: 0; cursor: pointer;
  font-family: 'DM Sans', sans-serif; font-size: 12.5px; font-weight: 600;
  color: var(--teal-dark, #0d5c50); text-decoration: underline;
}
.btn-link:hover { opacity: .75; }

/* ── Long-text safety ──
   User-typed text (purpose, remarks, descriptions, messages) has no
   spaces to break on when someone mashes the keyboard or pastes a long
   link, so it ran straight out of its card and got clipped by
   .content { overflow-x: hidden }. Letting any long run wrap fixes it
   everywhere at once instead of patching each list one by one. */
body { overflow-wrap: break-word; }
.content, .modal-box, .confirm-box { overflow-wrap: anywhere; }
.row-content { min-width: 0; }

/* ── Customer Service (support tickets) ── */
.cat-pill {
  display: inline-block; font-size: 11.5px; font-weight: 600; color: #4b5563;
  background: #f1f5f9; border: 1px solid #e2e8f0; border-radius: 999px;
  padding: 2px 9px; white-space: nowrap;
}
.ticket-needs-reply {
  display: inline-block; margin-top: 4px; font-size: 11px; font-weight: 600;
  color: #b45309; background: #fef3c7; border: 1px solid #fcd34d;
  border-radius: 999px; padding: 1px 8px; white-space: nowrap;
}
.ticket-meta { font-size: 12.5px; color: var(--muted); margin-bottom: 14px; line-height: 1.5; }
.ticket-meta-top {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 10px; margin-bottom: 4px;
}
.ticket-meta-subject {
  font-family: 'Poppins', sans-serif; font-size: 15px; font-weight: 600;
  color: var(--text); min-width: 0;
}
.ticket-thread {
  display: flex; flex-direction: column; gap: 10px;
  max-height: 340px; overflow-y: auto;
  background: #faf8f3; border: 1px solid #f0ece3; border-radius: 12px;
  padding: 12px; margin-bottom: 14px;
}
.ticket-bubble {
  max-width: 84%; border-radius: 12px; padding: 9px 12px;
  font-size: 13px; line-height: 1.5; border: 1px solid transparent;
}
/* Staff view: the resident is on the left, staff on the right. */
.ticket-bubble-resident { align-self: flex-start; background: #fff; border-color: #e4dfd3; }
.ticket-bubble-staff    { align-self: flex-end; background: #e6faf6; border-color: #b7ece3; }
.ticket-bubble-internal { background: #fffbeb; border: 1px dashed #f0c96b; }
/* Resident view: flipped, so "me" is always on the right. */
.ticket-thread-resident-view .ticket-bubble-resident { align-self: flex-end; background: #e6faf6; border: 1px solid #b7ece3; }
.ticket-thread-resident-view .ticket-bubble-staff    { align-self: flex-start; background: #fff; border: 1px solid #e4dfd3; }
.ticket-bubble-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 3px; }
.ticket-bubble-sender { font-size: 11.5px; font-weight: 700; color: var(--text); }
.ticket-bubble-time { font-size: 10.5px; color: var(--label); white-space: nowrap; }
.ticket-bubble-body { white-space: pre-wrap; overflow-wrap: anywhere; color: #333; }
.ticket-reply-box textarea {
  width: 100%; min-height: 78px; resize: vertical; padding: 10px 12px;
  border: 1.5px solid #d4cfc5; border-radius: 10px; background: #fff;
  font-family: 'DM Sans', sans-serif; font-size: 13.5px; color: var(--text); outline: none;
}
.ticket-reply-box textarea:focus { border-color: var(--teal-dark); }
.ticket-reply-toolbar {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 10px; flex-wrap: wrap; margin-top: 10px;
}
.ticket-internal-check {
  display: flex; align-items: center; gap: 6px; margin-right: auto;
  font-size: 12px; color: var(--muted); cursor: pointer;
}
.ticket-status-select {
  padding: 8px 10px; border: 1.5px solid #d4cfc5; border-radius: 8px; background: #fff;
  font-family: 'DM Sans', sans-serif; font-size: 13px; color: var(--text); outline: none;
}
@media (max-width: 600px) {
  .ticket-bubble { max-width: 94%; }
  .ticket-internal-check { width: 100%; margin-right: 0; }
}

/* Mobile: hide the short page description under the page title in the top bar. */
@media screen and (max-width: 600px) {
  .topbar-left p { display: none; }
}

/* Cards stand out from the page background: a firmer border and a soft shadow.
   The .content prefix keeps this winning over Residents/dashboard.css. */
.content .section-card,
.content .ph-card {
  border-color: #c9c2b0;
  box-shadow: 0 2px 10px rgba(40, 30, 10, .09);
}
