:root {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: #1f2937;
  background: #f6f8fb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at top right, #edf3ff 0%, #f6f8fb 45%, #f6f8fb 100%);
  color: #1f2937;
}

.topbar {
  display: flex;
  justify-content: center;
  align-items: center;
  background: #ffffff;
  color: #111827;
  padding: 0.75rem 2rem 1rem;
  border-bottom: 1px solid #dbe4f0;
  position: sticky;
  top: var(--topbar-top, 0px);
  z-index: 1090;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
}

.brand-logo {
  height: 235px;
  width: auto;
  display: block;
  margin: 0 auto;
}

.topbar h1 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: 0.2px;
  font-weight: 600;
}

.profile-menu {
  position: relative;
}

.profile-toggle {
  background: #0891b2;
  color: #ffffff;
  border: 1px solid #0891b2;
  border-radius: 0.5rem;
  padding: 0.45rem 0.7rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  transition: all 0.2s ease;
}

.profile-toggle.logged-in {
  background: #0891b2;
  border-color: #0891b2;
}

.profile-toggle:hover {
  background: #0e7490;
  border-color: #0e7490;
}

.profile-toggle.logged-in:hover {
  background: #0e7490;
  border-color: #0e7490;
}

.profile-icon {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1;
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
  text-transform: uppercase;
  flex-shrink: 0;
}

.profile-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 0.4rem);
  min-width: 280px;
  background: #fff;
  color: #1f2937;
  border-radius: 0.75rem;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.16);
  border: 1px solid #dbe4f0;
  padding: 0.85rem;
  z-index: 1000;
}

.profile-summary {
  margin: 0 0 0.75rem;
  color: #425466;
  line-height: 1.35;
}

.profile-actions {
  display: grid;
  gap: 0.5rem;
}

.main-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 1100;
  padding: 0.65rem 2rem;
  background: #ffffff;
  border-bottom: 1px solid #dbe4f0;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
}

.nav-left,
.nav-right {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.nav-right .profile-toggle {
  padding: 0.42rem 0.7rem;
}

.rent-metrics {
  display: flex;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  background: #f0f5ff;
  border-radius: 0.5rem;
  border: 1px solid #d1dced;
  font-size: 0.85rem;
  align-items: center;
}

.rent-metrics.hidden {
  display: none;
}

.metric {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
}

.metric-label {
  font-size: 0.75rem;
  color: #6b7280;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.metric-value {
  font-size: 1rem;
  font-weight: 700;
  color: #1f2937;
}

.inactivity-banner {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  background: #991b1b;
  color: #ffffff;
  border: 1px solid #7f1d1d;
  border-radius: 999px;
  padding: 0.55rem 1rem;
  font-weight: 700;
  z-index: 2500;
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.22);
}

.inactivity-banner.hidden {
  display: none;
}

/* ── Toast notifications ───────────────────────────────────────── */
.toast-notification {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9000;
  padding: 0.7rem 1.1rem;
  border-radius: 0.6rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
  opacity: 1;
  transition: opacity 0.4s ease;
  pointer-events: none;
}
.toast-notification.success { background: #16a34a; }
.toast-notification.error   { background: #dc2626; }
.toast-notification.info    { background: #0891b2; }
.toast-notification.fade-out { opacity: 0; }

.nav-btn {
  background: #000000;
  color: #ffffff;
  border: 1px solid #000000;
  border-radius: 999px;
  padding: 0.42rem 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.nav-btn:hover {
  border-color: #000000;
  color: #ffffff;
  background: #000000;
}

.nav-btn.active {
  background: #005fb8;
  border-color: #005fb8;
  color: #ffffff;
}

.nav-alert {
  border: 1px solid #d97706;
  background: #fff7ed;
  color: #9a3412;
  border-radius: 999px;
  padding: 0.42rem 0.85rem;
  font-weight: 700;
  white-space: nowrap;
}

.nav-alert:hover {
  background: #ffedd5;
}

.container {
  max-width: 1240px;
  margin: 1.6rem auto 2.25rem;
  padding: 0 1.25rem;
}

/* Sticky gap — maintains the whitespace between the logo and the
   tab/toolbar bars as content scrolls underneath them. */
.sticky-gap {
  position: sticky;
  top: var(--sticky-gap-top, 0px);
  z-index: 1045;
  height: 1.6rem;
  /* Extend past the container's horizontal padding so it fills edge-to-edge */
  margin-left: -1.25rem;
  margin-right: -1.25rem;
  background: #f6f8fb;
  pointer-events: none;
}

.card {
  background: #fff;
  border-radius: 1rem;
  padding: 1.15rem;
  border: 1px solid #e3eaf4;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.05);
}

#authView.card {
  background: #e6f7fb;
  border-color: #b7e7f2;
}

.pw-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.pw-wrap input {
  flex: 1;
  padding-right: 3.6rem !important;
}
.pw-toggle {
  position: absolute;
  right: 0.5rem;
  background: none;
  border: none;
  padding: 0.2rem 0.45rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: #6b7280;
  cursor: pointer;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 4px;
  line-height: 1;
  flex-shrink: 0;
}
.pw-toggle:hover {
  color: #1f2937;
  background: rgba(0, 0, 0, 0.07);
}

.tenant-rent-status-title {
  color: #ffffff;
  border-radius: 0.7rem;
  padding: 0.6rem 0.85rem;
  margin: 0 0 0.95rem;
}

.tenant-rent-status-title.is-current {
  background: #15803d;
}

.tenant-rent-status-title.is-behind {
  background: #b91c1c;
}

.tenant-late-fee-panel {
  margin-top: 1rem;
  border: 1px solid #b91c1c;
  border-radius: 0.85rem;
  padding: 0.85rem;
  background: #ef4444;
  color: #ffffff;
}

.tenant-late-fee-panel h3 {
  margin: 0 0 0.65rem;
}

.tenant-late-fee-panel p {
  margin: 0.3rem 0;
}

.tenant-late-fee-panel strong {
  color: #ffe4e6;
}

.hint {
  color: #52667d;
  margin-top: 0;
}

.form-grid {
  display: grid;
  gap: 0.8rem;
}

#loginForm {
  width: 36ch;
  max-width: 100%;
  margin: 0 auto;
}

#authView h2,
#authView .hint {
  text-align: center;
}

#loginForm label,
#loginForm input {
  width: 100%;
}

label {
  display: grid;
  gap: 0.4rem;
  font-weight: 600;
  color: #334155;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  border: 1px solid #cfd8e6;
  border-radius: 0.6rem;
  padding: 0.62rem;
  background: #fbfcfe;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
  outline: none;
}

button {
  border: 0;
  background: linear-gradient(180deg, #0f6cbd 0%, #005fb8 100%);
  color: #fff;
  border-radius: 0.55rem;
  padding: 0.6rem 0.9rem;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.06s ease, filter 0.2s ease;
}

button:hover {
  filter: brightness(1.02);
}

button:active {
  transform: translateY(1px);
}

button.secondary {
  background: #334155;
}

button.danger {
  background: #dc2626;
}

.hidden {
  display: none;
}

.demo-users {
  margin-top: 1rem;
  background: #f3f8ff;
  border: 1px solid #d4e4fb;
  border-radius: 0.7rem;
  padding: 0.75rem;
}

.auth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

#loginForm button,
.auth-actions button,
.auth-subform button {
  width: auto;
  justify-self: start;
}

#loginForm button {
  justify-self: center;
}

.auth-actions {
  justify-content: center;
}

.auth-subform {
  margin-top: 0.75rem;
  padding: 0.75rem;
  border: 1px solid #dbe4f0;
  border-radius: 0.7rem;
  background: #f8fbff;
}

.auth-subform h3 {
  margin: 0;
  font-size: 1rem;
  color: #334155;
}

.tabs {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  align-items: center;
  background: #0f2744;
  padding: 0.55rem 0.85rem;
  border-radius: 0.65rem;
  margin-bottom: 0.75rem;
  position: sticky;
  top: var(--tabs-top, 57px);
  z-index: 1040;
}

/* ── Admin-only toolbar ────────────────────────────────────────── */
.admin-toolbar {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  align-items: center;
  background: #1e293b;
  padding: 0.55rem 0.85rem;
  border-radius: 0.65rem;
  margin-bottom: 0.75rem;
  position: sticky;
  top: var(--admin-toolbar-top, 57px);
  z-index: 1050;
}

.admin-toolbar.hidden {
  display: none;
}

.admin-toolbar::after {
  content: "⚙ Admin";
  color: #94a3b8;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-left: auto;
  white-space: nowrap;
}

.admin-tab-btn {
  background: transparent;
  color: #cbd5e1;
  border: 1px solid #334155;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.3rem 0.9rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.admin-tab-btn:hover {
  background: #334155;
  color: #f1f5f9;
  border-color: #475569;
}

.admin-tab-btn.active {
  background: #f59e0b;
  border-color: #f59e0b;
  color: #1e293b;
}

.tab-btn {
  background: transparent;
  color: #93c5fd;
  border: 1px solid #1e3a5f;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.3rem 0.9rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.tab-btn:hover {
  background: #1e3a5f;
  color: #e0f2fe;
  border-color: #2d5a8e;
}

.tab-btn.active {
  background: #38bdf8;
  border-color: #38bdf8;
  color: #0f2744;
}

.tab-content {
  display: grid;
  gap: 1rem;
}

@keyframes tab-spin {
  to { transform: rotate(360deg); }
}

.tab-loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  color: #9ca3af;
  font-size: 0.95rem;
}

.tab-spinner {
  display: block;
  width: 2rem;
  height: 2rem;
  border: 3px solid #e3eaf4;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: tab-spin 0.75s linear infinite;
  margin-bottom: 0.9rem;
}

.grid-2 {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid #e1e8f3;
  border-radius: 0.75rem;
  overflow: hidden;
}

th,
td {
  text-align: left;
  padding: 0.68rem;
  border-bottom: 1px solid #ebf0f7;
}

th {
  background: #f7fafe;
  color: #334155;
  font-weight: 700;
}

.badge {
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  color: #fff;
  font-size: 0.8rem;
  display: inline-block;
  white-space: nowrap;
  line-height: 1.1;
}

.status-open {
  background: #d97706;
}

.status-progress {
  background: #2563eb;
}

.status-completed {
  background: #16a34a;
}

.status-denied {
  background: #dc2626;
}

.workorder-comments {
  display: grid;
  gap: 0.55rem;
}

.workorder-comments h4 {
  margin: 0;
  font-size: 0.95rem;
  color: #334155;
}

.comment-list {
  display: grid;
  gap: 0.45rem;
}

.comment-item {
  border: 1px solid #e2e8f0;
  border-radius: 0.55rem;
  background: #f8fbff;
  padding: 0.5rem 0.6rem;
}

.comment-item p {
  margin: 0.15rem 0;
}

.comment-form-row {
  display: grid;
  gap: 0.45rem;
}

.tenant-contacts-section {
  display: grid;
  gap: 0.55rem;
  padding: 0.65rem;
  border: 1px solid #dbe4f0;
  border-radius: 0.65rem;
  background: #f8fbff;
}

.tenant-contacts-section h3 {
  margin: 0;
  font-size: 0.95rem;
  color: #334155;
}

.tenant-contacts-list {
  display: grid;
  gap: 0.5rem;
}

.tenant-contact-row {
  display: grid;
  gap: 0.45rem;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  align-items: center;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  display: grid;
  place-items: center;
  z-index: 2000;
  padding: 1rem;
}

.modal-card {
  width: min(560px, 100%);
  background: #ffffff;
  border: 1px solid #dbe4f0;
  border-radius: 0.85rem;
  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.2);
  padding: 1rem;
  display: grid;
  gap: 0.85rem;
}

.modal-card h3 {
  margin: 0;
  color: #1f2937;
}

.modal-actions {
  display: flex;
  gap: 0.55rem;
  justify-content: flex-end;
}

.actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.account-card-list {
  display: grid;
  gap: 0.8rem;
}

.account-card {
  border: 1px solid #dbe4f0;
  border-radius: 0.8rem;
  background: #f8fbff;
  padding: 0.85rem;
  display: grid;
  gap: 0.65rem;
}

.account-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.65rem;
}

.account-card-summary {
  display: grid;
  gap: 0.15rem;
}

.account-card-head h3 {
  margin: 0;
  font-size: 1rem;
  color: #1f2937;
}

.account-card-summary p {
  margin: 0;
  color: #52667d;
  font-size: 0.9rem;
}

.account-card-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.account-card-body {
  display: grid;
  gap: 0.55rem;
}

.account-card-details {
  display: grid;
  gap: 0.3rem;
}

.account-card-details p {
  margin: 0;
  color: #334155;
}

.account-card-actions {
  padding-top: 0.15rem;
  border-top: 1px solid #e2e8f0;
}

.account-card-permissions {
  padding: 0.65rem 0 0.25rem;
  border-top: 1px solid #e2e8f0;
}

.account-card-permissions-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
  margin-bottom: 0.45rem;
}

.permission-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.permission-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 999px;
  border: 1.5px solid #cbd5e1;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  line-height: 1;
}

.permission-chip:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.permission-chip.active {
  background: #dcfce7;
  border-color: #22c55e;
  color: #15803d;
}

.permission-chip.active:hover {
  background: #fee2e2;
  border-color: #f87171;
  color: #dc2626;
}

.perm-panel-overlay {
  position: fixed;
  inset: 0;
  z-index: 2100;
  background: rgba(15, 23, 42, 0.3);
  display: flex;
  justify-content: flex-end;
  animation: permOverlayIn 0.18s ease;
}

@keyframes permOverlayIn {
  from { background: rgba(15, 23, 42, 0); }
  to   { background: rgba(15, 23, 42, 0.3); }
}

.perm-panel {
  width: min(420px, 100%);
  height: 100%;
  background: #fff;
  box-shadow: -6px 0 32px rgba(15, 23, 42, 0.18);
  display: flex;
  flex-direction: column;
  animation: permPanelIn 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.perm-panel.closing {
  animation: permPanelOut 0.18s cubic-bezier(0.55, 0, 1, 0.45) forwards;
}

.perm-panel-overlay.closing {
  animation: permOverlayOut 0.18s ease forwards;
}

@keyframes permPanelIn {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

@keyframes permPanelOut {
  from { transform: translateX(0); }
  to   { transform: translateX(100%); }
}

@keyframes permOverlayOut {
  from { background: rgba(15, 23, 42, 0.3); }
  to   { background: rgba(15, 23, 42, 0); }
}

.perm-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1.1rem 1.25rem 0.9rem;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
}

.perm-panel-header-info h3 {
  margin: 0 0 0.15rem;
  font-size: 1rem;
  color: #1f2937;
}

.perm-panel-header-info p {
  margin: 0;
  font-size: 0.85rem;
  color: #52667d;
}

.perm-panel-close {
  flex-shrink: 0;
  background: none;
  border: none;
  padding: 0.2rem 0.4rem;
  font-size: 1.15rem;
  color: #94a3b8;
  cursor: pointer;
  border-radius: 0.4rem;
  line-height: 1;
  box-shadow: none;
}

.perm-panel-close:hover {
  background: #f1f5f9;
  color: #475569;
}

.perm-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.perm-panel-section {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.perm-panel-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #94a3b8;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid #f1f5f9;
}

.perm-panel-section-hint {
  margin: 0;
  font-size: 0.82rem;
  color: #64748b;
  line-height: 1.5;
}

.perm-panel-elevated {
  background: #fff8f8;
  border: 1px solid #fecaca;
  border-radius: 0.65rem;
  padding: 0.85rem;
}

.perm-panel-elevated .perm-panel-section-title {
  color: #ef4444;
  border-bottom-color: #fecaca;
}

.perm-panel-grant {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 0.65rem;
  padding: 0.85rem;
}

.perm-panel-grant .perm-panel-section-title {
  color: #0284c7;
  border-bottom-color: #bae6fd;
}

.perm-panel-alt-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.perm-panel-alt-row p {
  margin: 0;
  font-size: 0.85rem;
  color: #374151;
  line-height: 1.4;
}

.permission-form {
  gap: 0.45rem;
}

.permission-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 600;
}

.permission-toggle input[type="checkbox"] {
  width: auto;
  height: auto;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}


.lease-doc-status {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}

.lease-status-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
}

.lease-doc-present {
  background: #dcfce7;
  color: #166534;
}

.lease-doc-missing {
  background: #fee2e2;
  color: #991b1b;
}

@media (max-width: 760px) {
  .topbar,
  .main-nav {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .main-nav {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .nav-right {
    margin-left: auto;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .brand h1 {
    font-size: 1rem;
  }

  .profile-toggle {
    padding: 0.4rem 0.55rem;
  }

  .profile-status-text {
    display: none;
  }
}

/* ── Mobile hamburger nav ─────────────────────────────────────────────── */
/* Shown on screens ≤ 640 px (phones). Replaces the flat pill-button row
   with a compact header bar + slide-down panel. */

.mobile-nav-bar,
.mobile-nav-drawer {
  display: none; /* hidden on desktop; enabled via media query below */
}

@media (max-width: 640px) {
  /* ── Nav bar shell: single tight row, no padding (bar + nav-right handle it) */
  .main-nav {
    flex-wrap: nowrap;
    align-items: center;
    padding: 0;
    gap: 0;
  }

  /* ── Hide desktop-only nav items ── */
  .main-nav .nav-left                  { display: none; }
  .main-nav .nav-right > .nav-btn      { display: none; } /* Login / Dashboard links */
  .main-nav .nav-right > #rentMetrics  { display: none; } /* balance widget */
  .main-nav .nav-right > .nav-alert    { display: none; } /* notification button */

  /* ── Mobile bar: [☰] [brand text flex:1]  ordered first (left side) ── */
  .mobile-nav-bar {
    display: flex;
    order: 1;
    flex: 1;
    min-width: 0;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.75rem 0.5rem 1rem;
  }

  .mobile-nav-brand {
    flex: 1;
    font-weight: 700;
    font-size: 0.95rem;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
  }

  /* ── Hamburger button ── */
  .hamburger-btn {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    flex-shrink: 0;
    background: none;
    border: none;
    padding: 0.4rem;
    cursor: pointer;
    border-radius: 6px;
  }
  .hamburger-btn:hover { background: rgba(0,0,0,0.06); }
  .hamburger-btn span {
    display: block;
    width: 22px;
    height: 2px;
    background: #1f2937;
    border-radius: 2px;
    transition: transform 0.25s, opacity 0.25s;
  }
  /* Animate to × when open */
  .hamburger-btn[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .hamburger-btn[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
  .hamburger-btn[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  /* ── Profile toggle: ordered last (right side) ── */
  .main-nav .nav-right {
    order: 2;
    display: flex;
    flex-shrink: 0;
    flex-wrap: nowrap;
    align-items: center;
    margin-left: 0;
    gap: 0;
    padding-right: 0.75rem;
  }

  /* Ensure profile menu container is a flex row */
  .main-nav .nav-right .profile-menu {
    display: flex;
    align-items: center;
  }

  /* ── Profile toggle: always visible on mobie regardless of saved custom colours ──
     The injected !important rules (from applyProfileDropdownStyles) may set the
     button background to anything — even white (matching the nav bar), making both
     background and text invisible.  The injected stylesheets never touch .profile-icon
     or box-shadow, so these rules will always win. */
  .main-nav .nav-right .profile-toggle {
    /* subtle ring so button bounds are visible on any background */
    box-shadow: 0 0 0 1.5px rgba(15, 23, 42, 0.22), 0 1px 4px rgba(15, 23, 42, 0.1);
    padding: 0.3rem !important;
  }
  .main-nav .nav-right .profile-icon {
    /* force a dark semi-transparent circle — visible against any button colour */
    background: rgba(0, 0, 0, 0.5) !important;
    color: #fff !important;
    width: 2rem !important;
    height: 2rem !important;
    font-size: 0.9rem !important;
  }

  /* Hide the "Not logged in" label; keep just the 👤 icon */
  #profileStatusText { display: none; }

  /* ── Drawer: absolute dropdown below the sticky nav ── */
  .mobile-nav-drawer {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1099;
    background: #fff;
    border-bottom: 1px solid #dbe4f0;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.12);
    display: none;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.6rem 0.75rem 0.75rem;
  }
  .mobile-nav-drawer.open {
    display: flex;
  }

  /* Nav links inside the drawer */
  .mobile-nav-drawer a,
  .mobile-nav-drawer button:not(.profile-toggle) {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.65rem 0.75rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.97rem;
    background: none;
    color: #1f2937;
    border: none;
    cursor: pointer;
    text-decoration: none;
    box-sizing: border-box;
  }
  .mobile-nav-drawer a:hover,
  .mobile-nav-drawer button:not(.profile-toggle):hover {
    background: #f1f5f9;
  }
  .mobile-nav-drawer a.active,
  .mobile-nav-drawer button.active {
    background: #e0f2fe;
    color: #0369a1;
  }

  /* ── Tabs + admin toolbar scroll horizontally ── */
  .tabs,
  .admin-toolbar {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 0.35rem;
    padding: 0.5rem 0.75rem;
  }
  .tabs::-webkit-scrollbar,
  .admin-toolbar::-webkit-scrollbar { display: none; }
  .admin-toolbar::after { flex-shrink: 0; }
}

/* ── Content Management Admin UI ─────────────────────────────────────── */

.cm-panel-list-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  margin-bottom: 1rem;
}

.cm-panel-list-header h2 {
  margin: 0;
  white-space: nowrap;
  flex-shrink: 0;
}

.cm-page-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0;
}

.cm-page-tabs .tab-btn {
  font-size: 0.85rem;
  padding: 0.35rem 0.9rem;
}

.content-mgmt-panel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.75rem;
  border: 1px solid #dbe4f0;
  border-radius: 0.5rem;
  margin-bottom: 0.5rem;
  background: #f9fbfd;
}

.content-mgmt-panel-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.content-mgmt-panel-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.cm-core-badge {
  font-size: 0.75rem;
  font-weight: 600;
  color: #6b7280;
  background: #e5e7eb;
  border: 1px solid #d1d5db;
  border-radius: 0.35rem;
  padding: 0.2rem 0.6rem;
  letter-spacing: 0.03em;
}

.cm-editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.45rem 0.6rem;
  background: #f1f5f9;
  border: 1px solid #dbe4f0;
  border-bottom: none;
  border-radius: 0.45rem 0.45rem 0 0;
}

.cm-editor-toolbar button {
  font-size: 0.8rem;
  padding: 0.25rem 0.65rem;
  min-width: 2rem;
  border-radius: 0.3rem;
  background: #fff;
  border: 1px solid #cbd5e1;
  color: #1f2937;
  cursor: pointer;
  line-height: 1.4;
}

.cm-editor-toolbar button:hover {
  background: #e2e8f0;
}

.cm-content-editor {
  min-height: 180px;
  border: 1px solid #dbe4f0;
  border-radius: 0 0 0.45rem 0.45rem;
  padding: 0.75rem;
  font-size: 0.95rem;
  line-height: 1.6;
  background: #fff;
  outline: none;
  word-break: break-word;
}

.cm-content-editor:focus {
  border-color: #0891b2;
  box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.12);
}

.cm-content-editor img {
  max-width: 100%;
  height: auto;
  border-radius: 0.3rem;
}

.cm-color-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.cm-color-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.35rem;
}

.cm-color-input-wrap input[type="color"] {
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 1px solid #dbe4f0;
  border-radius: 0.35rem;
  cursor: pointer;
  background: none;
  flex-shrink: 0;
  transition: opacity 0.2s;
}

.cm-clear-color {
  font-size: 0.78rem;
  padding: 0.25rem 0.55rem;
}

/* ── Public Content Panels ───────────────────────────────────────────── */

.content-panel {
  margin-top: 0;
}

.content-panel-body {
  line-height: 1.7;
}

.content-panel-body img {
  max-width: 100%;
  height: auto;
  border-radius: 0.4rem;
  margin: 0.5rem 0;
  display: block;
}

/* Responsive 16:9 video wrapper for embedded iframes and native video */
.cm-video-wrapper {
  position: relative;
  width: 100%;
  padding-top: 56.25%; /* 16:9 */
  margin: 1rem 0;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
}
.cm-video-wrapper iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 8px;
}
.cm-video-wrapper.cm-video-native {
  padding-top: 0;
  background: transparent;
}
.cm-video-wrapper.cm-video-native video {
  display: block;
  width: 100%;
  border-radius: 8px;
}

.content-panel-body a {
  color: #0891b2;
  text-decoration: underline;
}

.content-panel-body a:hover {
  color: #0e7490;
}

@media (max-width: 600px) {
  .cm-color-row {
    grid-template-columns: 1fr;
  }
}
