:root {
  --bg:            #ffffff;
  --panel:         #ffffff;
  --canvas:        #F3F5F5;
  --border:        #E3E5E5;
  --fg:            #1F2629;
  --muted:         #9DA1A2;
  --primary:       #155666;
  --primary-hover: #0F424E;
  --primary-tint:  #E6EEED;
  --accent:        #f0512c;
  --on-accent:     #ffffff;
  --success:       #4F7874;
  --success-tint:  #E6EFEE;
  --error:         #C0431F;
  --error-tint:    #FCEAE3;
  --shadow:        0 8px 24px rgba(20, 30, 30, 0.10);
  --popup-anim-speed: 0.2s;
}

* {
  box-sizing: border-box;
}

/* ── Sleek Custom Scrollbars Globally ─────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary-hover);
}

::-webkit-scrollbar-button {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

/* For Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--primary) transparent;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Calibri', 'Segoe UI', 'Helvetica Neue', system-ui, sans-serif;
  background: var(--bg);
  color: var(--fg);
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Disable body scroll when modal is active */
body:has(.modal-overlay) {
  overflow: hidden;
}

button {
  padding: 0.6rem 1.2rem;
  font-size: 0.95rem;
  font-family: inherit;
  border: none;
  border-radius: 8px;
  background: var(--primary);
  color: var(--on-accent);
  cursor: pointer;
  letter-spacing: 0.02em;
}

:where(button):hover:not(:disabled) {
  background-color: var(--primary-hover);
}

button:disabled {
  opacity: 0.5;
  cursor: wait;
}

input,
select,
textarea {
  padding: 0.5rem 0.75rem;
  font-size: 0.95rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--fg);
}

select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239DA1A2' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 0.9rem;
  padding-right: 2.25rem;
}

select::-ms-expand {
  display: none;
}

/* Custom Select Dropdown Styles */
.custom-select-wrapper {
  position: relative;
  display: inline-block;
  width: 100%;
}

button.custom-select-trigger {
  width: 100%;
  display: block;
  padding: 0.5rem 2.25rem 0.5rem 0.75rem;
  font-size: 0.95rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--fg);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239DA1A2' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 0.9rem;
}

button.custom-select-trigger:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(21, 86, 102, 0.15);
}

button.custom-select-trigger:hover:not(:disabled) {
  background-color: var(--bg);
  color: var(--fg);
}

button.custom-select-trigger:hover:not(:disabled):not(:focus) {
  border-color: var(--muted);
}

.custom-select-popup {
  position: absolute;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 999999;
  max-height: 200px;
  overflow-y: auto;
  display: none;
  transform-origin: center;
}

.custom-select-popup.open {
  display: block;
  animation: popup-fade-in var(--popup-anim-speed) ease-out forwards;
}

.custom-select-item {
  padding: 0.5rem 0.75rem;
  font-size: 0.95rem;
  color: var(--fg);
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.custom-select-item:hover {
  background-color: var(--primary-tint);
  color: var(--primary);
}

.custom-select-item.selected {
  background-color: var(--primary-tint);
  color: var(--primary);
  font-weight: 600;
}


input:hover:not(:disabled):not(:focus),
select:hover:not(:disabled):not(:focus),
textarea:hover:not(:disabled):not(:focus) {
  border-color: var(--muted);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(21, 86, 102, 0.15);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

input,
select,
textarea {
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}


.boot-status {
  margin: 0;
  padding: 3rem;
  text-align: center;
  color: var(--muted);
}

/* ── Login ─────────────────────────────────────────────────────────── */
.login-bg {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg);
  overflow: hidden;
}

.login-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url('../assets/geometric_brain_top.png') center/cover no-repeat;
  filter: opacity(0.2);
  mix-blend-mode: multiply;
  z-index: 0;
}

.login-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, transparent 0%, var(--bg) 90%);
  z-index: 1;
}

.login-bg-overlay {
  display: none;
}



.login-page {
  position: relative;
  z-index: 10;
  width: 90%;
  max-width: 420px;
  padding: 3rem 2.5rem 2.5rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow), 0 20px 40px rgba(21, 86, 102, 0.08);
  text-align: center;
}

.login-logo-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.login-logo {
  height: 44px;
  width: auto;
  transition: transform 0.3s ease;
}

.login-logo:hover {
  transform: scale(1.05);
}

.login-subtitle {
  margin: 1rem 0 0.25rem;
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.login-hint {
  margin: 0 0 1.75rem;
  font-size: 0.9rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  text-align: left;
}

.login-form label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--fg);
  letter-spacing: 0.04em;
  margin-top: 0.25rem;
}

.login-form input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--fg);
  border-radius: 8px;
  padding: 0.8rem 1rem;
  font-size: 1rem;
  transition: all 0.3s ease;
}

.login-form input::placeholder {
  color: var(--muted);
}

.login-form input:focus {
  background: var(--bg);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(21, 86, 102, 0.15);
  outline: none;
}

.login-form .password-toggle {
  color: var(--muted);
}

.login-form .password-toggle:hover {
  color: var(--fg);
}

.login-form button[type="submit"] {
  width: 100%;
  margin-top: 1rem;
  padding: 0.85rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--primary);
  color: var(--on-accent);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.login-form button[type="submit"]:hover:not(:disabled) {
  background: var(--primary-hover);
}

.login-form button[type="submit"]:active {
  transform: translateY(1px);
}

.login-form button[type="submit"]:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.muted {
  color: var(--muted);
}

/* ── Layout ────────────────────────────────────────────────────────── */
.layout {
  display: flex;
  height: 100dvh;
  overflow: hidden;
  background: var(--canvas);
}

/* ── Navbar ────────────────────────────────────────────────────────── */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  width: 260px;
  height: calc(100vh - 170px);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 1.5rem 1.25rem 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  z-index: 100;
  box-sizing: border-box;
}

.navbar-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.5rem;
  margin-right: 0;
  flex-shrink: 0;
}

.navbar-logo {
  height: 32px;
  width: auto;
  display: block;
}

/* legacy text title — hidden when logo is present */
.navbar-title {
  display: none;
}

.navbar-links {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  flex: 1;
  justify-content: flex-start;
  overflow-y: auto;
  gap: 0.5rem;
  scrollbar-width: thin;
}

.navbar-links::-webkit-scrollbar {
  width: 4px;
}

.navbar-links::-webkit-scrollbar-track {
  background: transparent;
}

.navbar-links::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.navbar-end {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 1rem 0 0 0;
  border-top: 1px solid var(--border);
  gap: 0.75rem;
  margin-top: auto;
}

.navbar-org {
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-transform: uppercase;
  white-space: nowrap;
  text-align: center;
  margin-bottom: 0.25rem;
}

.nav-link {
  display: flex;
  align-items: center;
  padding: 0.7rem 1rem;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  font-size: 0.825rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-radius: 8px;
  border-left: 3px solid transparent;
  transition: all 0.2s ease;
}

.nav-link:hover {
  color: var(--primary);
  background: var(--primary-tint);
}

.nav-link.active {
  color: var(--primary);
  background: var(--primary-tint);
  border-left-color: var(--primary);
}

.logout-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: transparent;
  border: 1px solid var(--error);
  color: var(--error);
  font-size: 0.775rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.65rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.logout-icon {
  display: inline-flex;
}

.logout-icon svg {
  width: 16px;
  height: 16px;
}

.logout-button:hover {
  background: var(--error-tint);
  border-color: var(--error);
}

/* ── User menu (avatar + popup) ────────────────────────────────────── */
.user-menu {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
}

.user-identity {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
  cursor: pointer;
  user-select: none;
  transition: opacity 0.2s ease;
}

.user-menu-trigger:hover .user-identity {
  opacity: 0.8;
}

.user-identity-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-identity-role {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid transparent;
  background-image: linear-gradient(var(--primary-tint), var(--primary-tint)), linear-gradient(135deg, var(--primary), var(--accent));
  background-origin: border-box;
  background-clip: padding-box, border-box;
  color: var(--primary);
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.user-menu-trigger:hover .user-avatar,
.user-menu.open .user-avatar {
  transform: scale(1.08) translateY(-1px);
  box-shadow: 0 8px 20px rgba(21, 86, 102, 0.25);
}

.user-avatar.has-logo {
  padding: 0;
  overflow: hidden;
  background-image: linear-gradient(#fff, #fff), linear-gradient(135deg, var(--primary), var(--accent));
}

.user-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.user-popup {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  display: none;
  flex-direction: column;
  gap: 0.65rem;
  padding: 0.85rem;
  min-width: 180px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  z-index: 200;
  transform-origin: bottom center;
}

.user-menu.open .user-popup {
  display: flex;
  animation: popup-fade-in var(--popup-anim-speed) ease-out forwards;
}

.user-popup-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--fg);
  text-align: center;
  word-break: break-word;
}

.user-popup-row {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.user-popup-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.user-popup-value {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--fg);
  word-break: break-word;
}

.user-popup .logout-button,
.user-popup .change-password-button {
  width: 100%;
}

/* Change-password button: same shape as the logout button. */
.change-password-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--primary);
  font-size: 0.775rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.65rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.change-password-button:hover:not(:disabled) {
  background: var(--primary-tint);
  border-color: var(--primary);
}

/* ── Footer ────────────────────────────────────────────────────────── */
.footer {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 260px;
  height: 170px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  z-index: 101;
  gap: 8px;
  box-sizing: border-box;
}

.footer-user {
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 1rem 0;
  margin-bottom: 0.25rem;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.footer-user::before {
  content: "";
  position: absolute;
  top: 0;
  left: 1.25rem;
  right: 1.25rem;
  border-top: 1px solid var(--border);
}

.footer-meta {
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
  padding: 0 0.5rem;
}

.footer-badges {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 0 0.5rem 0.75rem;
}

.footer-badge {
  height: 50px;
  width: auto;
  max-width: 46%;
  display: block;
}

.footer-badge-rounded {
  border-radius: 4px;
}

/* ── Content ───────────────────────────────────────────────────────── */
.content {
  margin-left: 260px;
  padding: 1.75rem 2.5rem;
  height: 100vh;
  overflow: hidden;
  flex: 1;
  background: var(--canvas);
  box-sizing: border-box;
}

/* ── Pages ─────────────────────────────────────────────────────────── */
.page {
  background: transparent;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.page-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
}

.page-title {
  margin: 0;
  font-size: 1.75rem;
  line-height: 1.2;
  color: var(--primary);
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.status {
  color: var(--muted);
  font-size: 0.88rem;
}

/* ── Add / primary action button ───────────────────────────────────── */
.add-btn {
  padding: 0.55rem 1.25rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: var(--primary);
  color: var(--on-accent);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s ease;
}

.add-btn:hover:not(:disabled) {
  background: var(--primary-hover);
}

.add-btn:active {
  transform: translateY(1px);
}

.status-error {
  color: var(--error);
}

.status-success {
  color: var(--success);
}

/* ── Password input with show/hide eye toggle ──────────────────────── */
.password-input {
  position: relative;
  width: 100%;
}

.password-input input {
  width: 100%;
  padding-right: 2.5rem; /* leave room for the eye toggle */
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 0.4rem;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.3rem;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
}

.password-toggle:hover {
  background: transparent;
  color: var(--fg);
}

.password-toggle svg {
  width: 18px;
  height: 18px;
}

/* Per-field feedback line under the change-password inputs. */
.password-feedback {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.password-feedback:empty {
  display: none;
}

.password-feedback-ok {
  color: var(--success);
}

.password-feedback-error {
  color: var(--error);
}

/* ── Password strength panel (new-password field) ──────────────────── */
.pw-strength-panel {
  margin-top: 0.5rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.pw-strength-panel[hidden] {
  display: none;
}

.pw-strength-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--fg);
}

.pw-strength-label-error {
  color: var(--error);
}

.pw-strength-meter {
  display: flex;
  gap: 6px;
}

.pw-strength-seg {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  transition: background 0.2s ease;
}

.pw-strength-seg-s0,
.pw-strength-seg-s1 { background: var(--error); }
.pw-strength-seg-s2 { background: #E0A100; }
.pw-strength-seg-s3 { background: #6FA84F; }
.pw-strength-seg-s4 { background: var(--success); }

.pw-strength-warning {
  margin: 0;
  font-size: 0.8rem;
  color: var(--fg);
}

.pw-strength-warning:empty {
  display: none;
}

.pw-strength-suggestions-title {
  margin: 0;
  font-size: 0.8rem;
  color: var(--fg);
}

.pw-strength-suggestions-title[hidden] {
  display: none;
}

.pw-strength-suggestions {
  margin: 0;
  padding-left: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.pw-strength-suggestions li {
  font-size: 0.78rem;
  color: var(--muted);
}

/* ── Pagination bar ───────────────────────────────────────────────── */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0;
}

.pagination-bar:empty {
  display: none;
}

.pagination-limit-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pagination-limit-label {
  font-size: 0.8rem;
  color: var(--muted);
}

.pagination-limit-select .custom-select-trigger {
  height: 32px;
  padding: 0.25rem 1.75rem 0.25rem 0.5rem;
  font-size: 0.8rem;
  background-size: 0.75rem;
  background-position: right 0.5rem center;
}

.pagination-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.pagination-info {
  font-size: 0.8rem;
  color: var(--muted);
}

.pagination-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pagination-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 1.1rem;
  line-height: 1;
  font-weight: 600;
  background: var(--panel);
  color: var(--primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.pagination-btn:hover:not(:disabled) {
  background: var(--primary-tint);
}

.pagination-btn:disabled {
  color: var(--muted);
  cursor: default;
  opacity: 0.6;
}

/* ── Scrollable Table Wrapper Container ───────────────────────────── */
.page-content:has(> .data-table):not(:has(.card-grid)),
.page-content > div:has(> .data-table) {
  width: 100%;
  box-sizing: border-box;
  max-height: calc(100dvh - 180px);
  overflow-y: auto;
  overflow-x: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin: 12px 0;
  /* Don't stretch to fill page height — only grow as tall as the table content */
  align-self: flex-start;
  /* Allow the wrapper to shrink (and scroll internally) so a pagination bar
     appended below it stays visible inside the overflow:hidden page-content. */
  min-height: 0;
}


/* The pagination bar's host div must keep its height when the table is tall. */
.page-content > div:has(> .pagination-bar) {
  flex-shrink: 0;
}

/* Strip card styling from the table when it is inside the scrollable container */
.page-content:has(> .data-table):not(:has(.card-grid)) .data-table,
.page-content > div:has(> .data-table) .data-table {
  border: none;
  box-shadow: none;
  border-radius: 0;
  margin: 0;
  background: transparent;
}

.page-content:has(> .data-table):not(:has(.card-grid)) .data-table th,
.page-content:has(> .data-table):not(:has(.card-grid)) .data-table td,
.page-content > div:has(> .data-table) .data-table th,
.page-content > div:has(> .data-table) .data-table td {
  border-radius: 0;
}

/* ── Data table ─────────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.92rem;
  margin: 0.75rem 0 0rem;
  background: var(--panel);
  border-radius: 12px;
  border: 1px solid var(--border);
}

/* Round first header cells to match container border radius */
.data-table th:first-child {
  border-top-left-radius: 11px;
}
.data-table th:last-child {
  border-top-right-radius: 11px;
}

/* Round last row cells to match container border radius */
.data-table tbody tr:last-child td:first-child {
  border-bottom-left-radius: 11px;
}
.data-table tbody tr:last-child td:last-child {
  border-bottom-right-radius: 11px;
}

.data-table th,
.data-table td {
  padding: 14px 18px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 10;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  background: #FAFBFB;
}

.data-table tbody tr {
  transition: background 0.2s ease;
  cursor: pointer;
}

.data-table tbody tr:hover {
  background: var(--primary-tint);
}

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

.data-table td.no-rows {
  text-align: center;
  color: var(--muted);
  font-style: italic;
  padding: 2rem 18px !important;
}

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

.data-table a:hover {
  text-decoration: underline;
}

/* ── Identity cell (name + monogram + ref id) ──────────────────────── */
.identity-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.monogram {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--primary-tint);
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  letter-spacing: 0;
  user-select: none;
}

.identity-name {
  display: block;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--fg);
  line-height: 1.25;
}

.identity-ref {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
}

/* ── Session cell states ─────────────────────────────────────────────── */
span[data-active-start],
.session-active-wrap {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

span[data-active-start]::before,
.session-active-dot {
  content: "";
  display: inline-block;
  flex-shrink: 0;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse-dot 2s infinite ease-in-out;
}

@keyframes pulse-dot {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(79, 120, 116, 0.7); /* Using --success color */
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 6px rgba(79, 120, 116, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(79, 120, 116, 0);
  }
}

span[data-active-start],
.session-active-time {
  color: var(--success);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.session-mono {
  font-variant-numeric: tabular-nums;
}

/* ── Search input ──────────────────────────────────────────────────── */
input[type="search"] {
  background: #FAFBFB;
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: all 0.2s ease;
}

input[type="search"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-tint);
}

/* ── Detail pane ────────────────────────────────────────────────────── */
.detail-pane {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  max-height: 360px;
  overflow: auto;
  font-size: 0.8rem;
}

/* ── Dashboard stat cards ───────────────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1.25rem;
  margin: 1rem 0 1.5rem;
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1.25rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 12px;
  text-decoration: none;
  transition: all 0.2s ease;
}

.stat-card:hover {
  border-color: var(--primary);
  border-left-color: var(--accent);
  background: var(--primary-tint);
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  transition: color 0.2s ease;
}

.stat-card:hover .stat-value {
  color: var(--primary-hover);
}

.stat-label {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Entity form ────────────────────────────────────────────────────── */
.entity-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.5rem;
  max-width: 900px;
}

/* ── Sortable / filterable table headers ────────────────────────────── */
.sortable-th {
  position: relative;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.th-container {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 100%;
}

.th-inner {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.th-label {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.th-sort-icon {
  font-size: 0.7rem;
  color: var(--muted);
  line-height: 1;
}

.th-sort-active {
  color: var(--primary);
}

.th-filter-icon {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1;
  padding: 0 3px;
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
}

.th-filter-icon svg {
  width: 11px;
  height: 11px;
  display: block;
  transition: fill 0.15s ease, color 0.15s ease;
}

.th-filter-icon:hover {
  color: var(--fg);
}

.th-filter-active {
  color: var(--primary);
}

.th-filter-active svg {
  fill: currentColor;
}

/* ── Filter popover ─────────────────────────────────────────────────── */
.th-popover {
  position: fixed;
  z-index: 1000;
  min-width: 160px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  box-shadow: var(--shadow);
  transform-origin: top center;
  animation: popup-fade-in var(--popup-anim-speed) ease-out forwards;
}

.th-popover-option {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.2rem 0;
  font-size: 0.875rem;
  color: var(--fg);
}

.th-popover-option label {
  cursor: pointer;
}

.th-popover-option input[type="checkbox"],
.th-popover-option input[type="radio"] {
  accent-color: var(--primary);
  cursor: pointer;
  padding: 0;
  border: none;
  background: transparent;
}

.th-popover-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.6rem;
}

.th-popover-apply {
  flex: 1;
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
  background: var(--primary);
  color: var(--on-accent);
  border: none;
  border-radius: 6px;
}

button.th-popover-apply:hover:not(:disabled) {
  background: var(--primary-hover);
}

.th-popover-clear {
  flex: 1;
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
}

button.th-popover-clear:hover:not(:disabled) {
  color: var(--primary);
  border-color: var(--primary);
  background: var(--primary-tint);
}

/* ── No-rows placeholder ────────────────────────────────────────────── */
.no-rows {
  text-align: center;
  color: var(--muted);
  font-style: italic;
  padding: 1.5rem 0;
}

/* ── Reports badge + popover ────────────────────────────────────────── */
.report-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.report-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.2rem;
  height: 1.2rem;
  cursor: pointer;
  color: var(--primary);
  transition: color 0.15s ease, transform 0.15s ease;
}

.report-icon svg {
  width: 100%;
  height: 100%;
}

.report-icon:hover {
  color: var(--primary-hover);
  transform: scale(1.15);
}

.report-icon.disabled {
  color: var(--muted);
  cursor: default;
  opacity: 0.45;
}

.report-badge {
  position: absolute;
  top: -0.4rem;
  right: -0.5rem;
  min-width: 0.95rem;
  box-sizing: border-box;
  text-align: center;
  font-size: 0.65rem;
  font-weight: 700;
  background: var(--primary);
  color: var(--on-accent);
  border-radius: 999px;
  padding: 0 4px;
  line-height: 1.45;
  cursor: pointer;
}

.report-popover {
  /* Positioned via JS (position: fixed) so it escapes the scrolling tbody's
     overflow clipping and can be clamped to stay within the table bounds. */
  position: fixed;
  z-index: 1000;
  min-width: 280px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  box-shadow: var(--shadow);
  animation: popup-fade-in var(--popup-anim-speed) ease-out forwards;
}

@keyframes popup-fade-in {
  from {
    opacity: 0;
    scale: 0.9;
  }
  to {
    opacity: 1;
    scale: 1;
  }
}

.report-mobile-close {
  display: none;
  position: absolute;
  top: 8px;
  right: 12px;
  background: transparent;
  border: none;
  font-size: 24px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  z-index: 10;
}

.report-mobile-close:hover {
  background: transparent;
  color: var(--fg);
}

/* Header + rows are one shared grid so Name / Created / actions columns align
   across every line (the rows use display:contents to hand their cells up). */
.report-popover-list {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  column-gap: 0.5rem;
  row-gap: 0.3rem;
  font-size: 0.85rem;
  /* Cap tall lists (patient reports aggregate every session) and scroll the
     rows; the "Download All as ZIP" button below stays visible. */
  max-height: 50vh;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.report-popover-header,
.report-popover-item {
  display: contents;
}

.report-popover-header > span {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

/* One continuous underline under the header row, spanning every column. */
.report-popover-divider {
  grid-column: 1 / -1;
  border-bottom: 1px solid var(--border);
  margin: 0.35rem 0 0.15rem;
}

/* Per-session date label separating each block of reports in the patient /
   caregiver Reports popover (reports aggregated across all sessions). */
.report-group-divider {
  grid-column: 1 / -1;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding-top: 0.4rem;
  margin-top: 0.25rem;
  border-top: 1px solid var(--border);
}

/* First group divider sits right under the header underline — drop the extra
   top border/spacing so it doesn't double up. (The first group divider always
   directly follows the header row in grouped mode.) */
.report-popover-header + .report-group-divider {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

.report-col-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.report-col-time {
  color: var(--muted);
  white-space: nowrap;
  font-size: 0.72rem;
  text-align: left;
  justify-self: start;
}

.report-col-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.report-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  color: var(--primary);
  border-radius: 6px;
  background: transparent;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  flex-shrink: 0;
  cursor: pointer;
}

.report-action-btn:hover {
  background: var(--primary-tint);
  border-color: var(--primary);
  color: var(--primary-hover);
}

.report-action-btn.disabled {
  color: var(--muted);
  cursor: default;
  opacity: 0.45;
}

.report-action-btn.disabled:hover {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.report-action-btn svg {
  width: 14px;
  height: 14px;
  display: block;
}

.report-popover-zip {
  margin-top: 0.5rem;
  width: 100%;
  font-size: 0.8rem;
}

.report-popover-zip:disabled {
  opacity: 0.6;
  cursor: default;
}

/* ── Searchable filter ──────────────────────────────────────────────── */
.filter-search-input {
  width: 100%;
  padding: 0.25rem 0.4rem;
  margin-bottom: 0.4rem;
  font-size: 0.8rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--fg);
}

.th-popover-options {
  max-height: 180px;
  overflow-y: auto;
}

.filter-select-input {
  width: 100%;
  padding: 0.25rem 0.4rem;
  margin-bottom: 0.2rem;
  font-size: 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--fg);
}

/* ── Date filter popover ─────────────────────────────────────────────── */
.th-popover .date-filter-custom:not([hidden]) {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin: 0.4rem 0 0.2rem;
  padding-top: 0.4rem;
  border-top: 1px solid var(--border);
}

.date-filter-label {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.date-filter-input {
  width: 100%;
  padding: 0.25rem 0.4rem;
  font-size: 0.8rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--fg);
  color-scheme: light;
}

/* ── Modal ─────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(31, 38, 41, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: modal-fade-in 0.2s ease-out forwards;
}

.modal-dialog {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 0;
  min-width: 360px;
  max-width: 520px;
  width: 90%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  animation: modal-slide-in 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  position: relative;
}

.modal-dialog:has(.modal-form) .modal-body {
  margin-bottom: 5.4rem;
  padding-bottom: 1.5rem;
}

.modal-dialog:has(.modal-form)::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 5.4rem;
  background: var(--panel);
  border-top: 1px solid var(--border);
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 16px;
  pointer-events: none;
  z-index: 9;
}

@keyframes modal-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modal-slide-in {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-overlay.closing {
  animation: modal-fade-out 0.15s ease-in forwards;
}

.modal-overlay.closing .modal-dialog {
  animation: modal-slide-out 0.2s cubic-bezier(0.4, 0, 1, 1) forwards;
}

@keyframes modal-fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes modal-slide-out {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(20px);
    opacity: 0;
  }
}

.modal-header {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: 1.25rem 1.75rem;
  margin-bottom: 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

/* Top row of the header: Neurosteer logo (left), clinic logo + name (right). */
.modal-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  /* Leave room for the absolutely-positioned close button in the corner. */
  padding-right: 2rem;
}

.modal-header-logo {
  height: 32px;
  width: auto;
  object-fit: contain;
}

.modal-header-clinic {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.modal-header-clinic-logo {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 8px;
  background: var(--border);
}

.modal-header-clinic-logo-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
}

.modal-header-clinic-logo-empty svg {
  width: 20px;
  height: 20px;
}

/* IMAGE-type table cell thumbnail (e.g. organization logo). */
.table-thumb {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--border);
  display: block;
}

.modal-header-clinic-name {
  font-weight: 600;
  color: var(--fg);
  letter-spacing: 0.01em;
}

.modal-title {
  margin: 0;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.modal-close {
  position: absolute;
  top: 0.9rem;
  right: 1.1rem;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.5rem;
  padding: 0 0.4rem;
  line-height: 1;
  cursor: pointer;
}

.modal-close:hover {
  color: var(--fg);
  background: transparent;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  scrollbar-gutter: stable;
  padding: 1.25rem 1.75rem 1.5rem;
}

/* Single column modal form (each input on its own row) */
.modal-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.modal-form .status {
  margin: 0 0 0.75rem;
}

.modal-form .status:empty {
  display: none;
}

.modal-form input,
.modal-form select,
.modal-form textarea {
  width: 100%;
}

.modal-form button[type="submit"] {
  position: absolute;
  bottom: 1.5rem;
  left: 1.75rem;
  right: calc(1.75rem + 9px);
  z-index: 10;
  margin: 0;
}

.modal-form button[type="submit"]:disabled {
  cursor: not-allowed;
}

/* ── Form Fields inside Modals ────────────────────────────────────── */
.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.25rem;
}

.form-field-label {
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--fg);
  letter-spacing: 0.01em;
}

.form-field-row {
  display: flex;
  gap: 0.75rem;
}

.form-field-row > * {
  flex: 1;
  min-width: 0;
}

.modal-checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  cursor: pointer;
  user-select: none;
  margin: 0.25rem 0;
}

.modal-checkbox input[type="checkbox"] {
  width: auto !important;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ── Tabbed modal ───────────────────────────────────────────────────── */
.modal-dialog-wide {
  max-width: 860px;
  width: 95%;
}

.modal-dialog-tabbed {
  padding: 0;
  display: flex;
  flex-direction: column;
  height: 85%;
  width: 65%;
  max-width: none;
}

.modal-dialog-tabbed .modal-header {
  padding: 1.25rem 1.5rem;
  margin-bottom: 0;
  border-bottom: none;
}

.modal-tabs {
  display: flex;
  align-items: stretch;
  height: 44px;
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  flex-shrink: 0;
}

.modal-tab-strip {
  display: flex;
  align-items: stretch;
  flex: 1;
  overflow-x: hidden;
  scroll-behavior: smooth;
}

.modal-tab-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 1.75rem;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  margin-bottom: 4px;
}

.modal-tab-arrow:hover {
  color: var(--primary);
  background: transparent;
}

.modal-tab-arrow.hidden {
  display: none;
}

.modal-tab {
  display: flex;
  align-items: center;
  padding: 0 0.85rem;
  height: 100%;
  color: var(--muted);
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  border-top: none;
  border-left: none;
  border-right: none;
  border-radius: 0;
  background: transparent;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  cursor: pointer;
  flex-shrink: 0;
}

.modal-tab:hover {
  color: var(--primary);
  background: transparent;
}

.modal-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.modal-tab-panel {
  padding: 0 1.5rem 1.25rem;
  overflow-y: auto;
  scrollbar-gutter: stable;
  flex: 1;
}

.modal-tab-panel > :first-child {
  margin-top: 1.25rem;
}

/* Placeholder tab states ("No Data" / "Loading…") fill the panel and center both axes. */
.modal-tab-panel:has(.tab-empty) {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-tab-panel:has(.tab-empty) > :first-child {
  margin-top: 0;
}

.tab-empty {
  margin: 0;
  text-align: center;
}

/* ── Patient detail grid ────────────────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.1rem 2rem;
}

.detail-field label {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.2rem;
}

.detail-field span {
  font-size: 0.95rem;
  color: var(--fg);
}

.session-visualizer {
  width: 100%;
  height: calc(85vh - 180px);
  border: none;
  border-radius: 4px;
}

.modal-section-label {
  margin: 0.5rem 0 0;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

/* ── Load-more row ──────────────────────────────────────────────────── */
.load-more-row {
  display: flex;
  justify-content: center;
  margin: 0.25rem 0 1.5rem;
}

.load-more-btn {
  background: transparent;
  border: 1px solid #BBD0CD;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.5rem 1.2rem;
  border-radius: 7px;
}

.load-more-btn:hover:not(:disabled) {
  background: var(--primary-tint);
  border-color: var(--primary);
}

/* ── Mobile nav toggle (hidden on desktop) ─────────────────────────── */
.navbar-toggle {
  display: none;
}

.navbar-overlay {
  display: none;
}

/* ── Mobile responsive ≤ 768px ─────────────────────────────────────── */
@media (max-width: 768px) {
  .report-popover:not([hidden]) {
    display: flex !important;
    flex-direction: column;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: 90vw;
    max-width: 400px;
    padding: 2.5rem 1rem 1rem 1rem;
    max-height: 85vh;
    animation: popup-fade-in var(--popup-anim-speed) ease-out forwards !important;
  }
  
  .report-mobile-close {
    display: block;
  }
  
  .report-popover-list {
    flex: 1;
    min-height: 0;
    max-height: none;
    margin-bottom: 1rem;
  }

  .report-popover-zip {
    margin-top: auto;
  }

  /* Hamburger button — transparent, aligned with content top-left */
  .navbar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 1.25rem;
    left: 1rem;
    z-index: 201;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
    transition: background 0.15s ease;
  }

  button.navbar-toggle svg {
    width: 24px;
    height: 24px;
    color: var(--primary);
  }

  button.navbar-toggle:hover:not(:disabled) {
    background: var(--primary-tint);
  }

  /* Overlay backdrop */
  .navbar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 99;
    background: rgba(0, 0, 0, 0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }

  .navbar-overlay.visible {
    opacity: 1;
    pointer-events: auto;
  }

  /* Navbar becomes a slide-out drawer */
  .navbar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 200;
  }

  .navbar.open {
    transform: translateX(0);
  }

  /* Footer follows the drawer */
  .footer {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 200;
  }

  .navbar.open ~ .footer {
    transform: translateX(0);
  }

  /* Content takes full width */
  .content {
    margin-left: 0;
    padding: 3.5rem 1.25rem 1.25rem;
  }

  /* Login page — narrower card for small screens */
  .login-page {
    width: calc(100vw - 2rem);
    max-width: 400px;
  }
}

/* ── Table Skeleton Loader ─────────────────────────────────────────── */
.page-content {
  position: relative;
}

.skeleton-loader {
  display: flex;
  flex-direction: column;
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin: 0.75rem 0 0rem;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.skeleton-row {
  display: flex;
  gap: 20px;
  padding: 18px 18px; /* Taller row heights to match td padding: 14px 18px + text height */
  border-bottom: 1px solid var(--border);
  align-items: center;
}

.skeleton-row:last-child {
  border-bottom: none;
}

.skeleton-header-row {
  background: #FAFBFB;
  border-bottom: 2px solid var(--border);
  padding: 16px 18px;
}

.skeleton-cell {
  height: 14px;
  background: linear-gradient(90deg, var(--canvas) 25%, var(--border) 50%, var(--canvas) 75%);
  background-size: 1000px 100%;
  animation: skeleton-loading 2s infinite linear;
  border-radius: 6px;
}

.skeleton-cell.header-cell {
  height: 10px;
  background: linear-gradient(90deg, var(--border) 25%, var(--canvas) 50%, var(--border) 75%);
  background-size: 1000px 100%;
  opacity: 0.85;
}

@keyframes skeleton-loading {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

/* ── Subsequent Load Overlay Spinner ───────────────────────────────── */
.table-loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  border-radius: 12px;
  backdrop-filter: blur(1.5px);
  animation: fadeIn 0.15s ease-out;
}

.table-loading-overlay .spinner {
  width: 42px;
  height: 42px;
  border: 4px solid var(--primary-tint);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s infinite linear;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.05);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ── Custom Date & Time Picker ────────────────────────────────────────── */

.custom-dp-wrapper {
  position: relative;
  display: inline-block;
  width: 100%;
}

button.custom-dp-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  font-size: 0.95rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--fg);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

button.custom-dp-trigger:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(21, 86, 102, 0.15);
}

button.custom-dp-trigger:hover:not(:disabled) {
  background-color: var(--bg);
  color: var(--fg);
}

button.custom-dp-trigger:hover:not(:disabled):not(:focus) {
  border-color: var(--muted);
}

button.custom-dp-trigger:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button.custom-dp-trigger.placeholder-text {
  color: var(--muted);
}

.custom-dp-trigger svg {
  color: var(--muted);
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-left: 0.5rem;
}

.custom-dp-popup {
  position: absolute;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 9999;
  padding: 14px 14px 10px;
  display: none;
  flex-direction: column;
  user-select: none;
  font-family: inherit;
}

.custom-dp-popup.open {
  display: flex;
  transform-origin: center;
  animation: popup-fade-in var(--popup-anim-speed) ease-out forwards;
}

.dp-content {
  display: flex;
  flex-direction: row;
  gap: 12px;
}

/* ── Calendar Section ── */
.dp-calendar {
  width: 250px;
  min-width: 0;
}

.dp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.dp-title {
  display: flex;
  align-items: center;
  gap: 4px;
}

.dp-month-year {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
}

.dp-arrows {
  display: flex;
  gap: 2px;
}

.dp-arrow-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent !important;
  border: none;
  cursor: pointer;
  color: var(--primary) !important;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  transition: background 0.15s ease;
}

.dp-arrow-btn svg {
  fill: var(--primary);
  flex-shrink: 0;
}

.dp-arrow-btn:hover {
  background: var(--primary-tint) !important;
}

.dp-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  margin-bottom: 4px;
}

.dp-weekdays span {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  padding: 4px 0;
}

.dp-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.dp-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  cursor: pointer;
}

.dp-cell--empty {
  pointer-events: none;
}

.dp-cell-inner {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 13px;
  color: var(--fg);
  transition: background 0.12s;
}

.dp-cell:hover:not(.dp-cell--empty) .dp-cell-inner:not(.dp-cell-inner--selected) {
  background: var(--primary-tint);
}

.dp-cell-inner--selected {
  background: var(--primary);
  color: var(--on-accent);
  font-weight: 600;
}

.dp-cell-inner--today:not(.dp-cell-inner--selected) {
  border: 1.5px solid var(--primary);
  color: var(--primary);
  font-weight: 600;
}

/* ── Clock Section ── */
.dp-clock {
  width: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.dp-clock-hidden {
  display: none !important;
}

.tp-date-feedback {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary);
  text-align: center;
  margin-bottom: 0.75rem;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  background: var(--primary-tint);
  cursor: pointer;
  transition: all 0.2s ease;
  display: none;
  align-self: center;
}

.tp-date-feedback:hover {
  background: var(--panel);
  border-color: var(--primary);
}

.dp-mobile-close {
  display: none;
  position: absolute;
  top: 12px;
  right: 16px;
  background: transparent;
  border: none;
  font-size: 28px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  z-index: 10;
}

.dp-mobile-close:hover {
  background: transparent;
  color: var(--fg);
}

.tp-time-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 10px;
}

.tp-time-seg {
  font-size: 22px;
  font-weight: 300;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 3px 8px;
  border-radius: 6px;
  min-width: 44px;
  text-align: center;
  transition: background 0.15s, color 0.15s;
  user-select: none;
}

.tp-time-seg--active {
  background: var(--primary);
  color: var(--on-accent);
}

.tp-time-seg:not(.tp-time-seg--active):hover {
  background: var(--canvas);
  color: var(--fg);
}

.tp-time-colon {
  font-size: 22px;
  font-weight: 300;
  color: var(--muted);
  line-height: 1;
  padding: 0 2px;
  margin-bottom: 2px;
  user-select: none;
}

.tp-clock-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

.tp-clock-svg {
  width: 160px;
  height: 160px;
  display: block;
}

.tp-ampm {
  display: inline-flex;
  flex-direction: row;
  justify-content: center;
  margin-top: 12px;
  gap: 0;
  background: var(--canvas);
  border-radius: 8px;
  padding: 3px;
}

.tp-ampm-btn {
  padding: 0 !important;
  background: transparent !important;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted) !important;
  width: 44px;
  height: 30px;
  border-radius: 6px;
  letter-spacing: 0.04em;
  transition: background 0.15s, color 0.15s;
}

.tp-ampm-btn--active {
  background: var(--primary) !important;
  color: var(--on-accent) !important;
  box-shadow: 0 1px 4px rgba(21, 86, 102, 0.25);
}

.tp-ampm-btn:not(.tp-ampm-btn--active):hover {
  background: var(--border) !important;
  color: var(--fg) !important;
}

/* ── Footer ── */
.dp-footer {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
  width: 100%;
}

.dp-footer-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.04em;
  padding: 5px 8px;
  border-radius: 4px;
  transition: background 0.15s;
}

.dp-footer-btn:hover {
  background: var(--primary-tint);
}

.dp-footer-btn--set {
  background: var(--primary);
  color: var(--on-accent);
  padding: 5px 14px;
}

.dp-footer-btn--set:hover {
  background: var(--primary-hover);
}

.dp-footer-btn-back {
  display: none;
}

@media (max-width: 768px), (max-height: 550px) {
  .tp-date-feedback {
    display: inline-block;
  }

  .custom-dp-popup {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100dvh !important;
    max-width: none !important;
    max-height: none !important;
    transform: none !important;
    border-radius: 0;
    padding: 16px 20px 16px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: var(--bg);
    z-index: 100000;
    overflow-y: auto;
  }

  .dp-content {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 0 1 auto;
    gap: 0;
  }

  .dp-mobile-close {
    display: block;
  }

  .dp-calendar {
    width: 100%;
    max-width: 380px;
    transform: none;
    margin: auto;
  }

  .dp-clock:not(.dp-clock-hidden) {
    width: 100%;
    max-width: 380px;
    border-top: none;
    margin-top: 0;
    padding-top: 0;
    transform: none;
  }

  .dp-footer {
    flex-wrap: wrap;
    border-top: none;
    padding-top: 16px;
    justify-content: space-between;
  }
  
  .dp-footer-btn {
    font-size: 13px;
    padding: 10px 16px;
  }

  .custom-dp-popup.dp-phase-time .dp-calendar {
    display: none !important;
  }
  
  .custom-dp-popup.dp-phase-calendar .dp-clock {
    display: none !important;
  }
  
  .custom-dp-popup.dp-phase-time .dp-footer-btn-cancel {
    display: none;
  }
  
  .custom-dp-popup.dp-phase-time .dp-footer-btn-back {
    display: block;
  }
}

/* ── Month/Year Picker Button ── */
.dp-month-year-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
  font-family: inherit;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.15s;
}

.dp-month-year-btn:hover {
  background: var(--primary-tint);
  color: var(--primary);
}

/* ── Month/Year Grid ── */
.dp-month-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 8px 0;
}

.dp-month-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  color: var(--fg);
  border-radius: 8px;
  transition: background 0.12s;
}

.dp-month-cell:hover:not(.dp-month-cell--selected) {
  background: var(--primary-tint);
}

.dp-month-cell--selected {
  background: var(--primary);
  color: var(--on-accent);
  font-weight: 600;
}

.dp-month-cell--today:not(.dp-month-cell--selected) {
  border: 1.5px solid var(--primary);
  color: var(--primary);
  font-weight: 600;
}

.dp-month-cell--outside {
  color: var(--muted);
}
