/* ── Self-hosted Roboto (variable font, latin + latin-ext) ──────────────── */

@font-face {
  font-family: 'Roboto';
  font-style: normal;
  font-weight: 400 600;
  font-stretch: 100%;
  font-display: swap;
  src: url('fonts/roboto-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Roboto';
  font-style: normal;
  font-weight: 400 600;
  font-stretch: 100%;
  font-display: swap;
  src: url('fonts/roboto-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

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

/* ── Colour tokens ───────────────────────────────────────────────────────── */

:root {
  --bg:               #f5f5f5;
  --card-bg:          #ffffff;
  --shadow:           rgba(0, 0, 0, 0.1);
  --text:             #333333;
  --text-muted:       #555555;
  --text-hint:        #999999;
  --border:           #d1d5db;
  --border-light:     #e0e0e0;
  --input-bg:         #ffffff;
  --tile-bg:          #f5f5f5;
  --summary-bg:       #f9f9f9;
  --summary-bg-hover: #f0f0f0;
  --accent:           #2c3e50;
  --accent-hover:     #1a252f;
  --error-bg:         #fdf2f2;
  --error-color:      #d9534f;
  --info-bg:          #f0faf0;
  --info-color:       #2c7a2c;
  --admin-tile-bg:    #eef2f7;
  --admin-tile-border:#c5d0de;
  --toggle-bg:        #e0e0e0;
  --toggle-color:     #333;
}

[data-theme="dark"] {
  --bg:               #111827;
  --card-bg:          #1f2937;
  --shadow:           rgba(0, 0, 0, 0.4);
  --text:             #e5e7eb;
  --text-muted:       #9ca3af;
  --text-hint:        #6b7280;
  --border:           #374151;
  --border-light:     #374151;
  --input-bg:         #111827;
  --tile-bg:          #111827;
  --summary-bg:       #111827;
  --summary-bg-hover: #1a2535;
  --accent:           #5b8dee;
  --accent-hover:     #4a7bdc;
  --error-bg:         #2d1515;
  --error-color:      #f87171;
  --info-bg:          #14291a;
  --info-color:       #6ee7a0;
  --admin-tile-bg:    #1a2535;
  --admin-tile-border:#2e3f5c;
  --toggle-bg:        #374151;
  --toggle-color:     #e5e7eb;
}

/* ── Logo theme switching ────────────────────────────────────────────────── */

/* !important needed — .page-header img and .logo img selectors have higher specificity */
.logo-dark                        { display: none !important; }
[data-theme="dark"] .logo-light   { display: none !important; }
[data-theme="dark"] .logo-dark    { display: block !important; }


/* ── Animations ─────────────────────────────────────────────────────────── */

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Base ────────────────────────────────────────────────────────────────── */

body {
  font-family: 'Roboto', 'Helvetica Neue', sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s, color 0.2s;
}

.card {
  background: var(--card-bg);
  border-radius: 8px;
  box-shadow: 0 2px 12px var(--shadow);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
  transition: background 0.2s, box-shadow 0.2s;
  animation: fadeInUp 0.35s ease-out;
}

/* ── Logo / header ───────────────────────────────────────────────────────── */

.logo {
  text-align: center;
  margin-bottom: 2rem;
}

.logo img {
  height: 56px;
  width: auto;
  display: block;
  margin: 0 auto;
}


/* ── Dark mode toggle ────────────────────────────────────────────────────── */

.theme-toggle {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  background: var(--toggle-bg);
  color: var(--toggle-color);
  border: none;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  font-size: 17px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px var(--shadow);
  transition: background 0.2s;
  z-index: 1000;
}

.theme-toggle:hover {
  background: var(--border-light);
}

body.portal-body.sidebar-hidden .theme-toggle {
  display: none;
}

/* ── Form fields ─────────────────────────────────────────────────────────── */

.field {
  margin-bottom: 1.25rem;
}

.field label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.4rem;
  color: var(--text);
}

.field input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--input-bg);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(44, 62, 80, 0.12);
}

[data-theme="dark"] .field input:focus {
  box-shadow: 0 0 0 3px rgba(91, 141, 238, 0.2);
}

.remember {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  color: var(--text-muted);
}

.remember input[type="checkbox"] {
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.remember label {
  cursor: pointer;
  user-select: none;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.btn-login {
  width: 100%;
  padding: 0.75rem;
  background: var(--accent);
  color: #ffffff;
  border: none;
  border-radius: 5px;
  font-size: 15px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 2px 4px var(--shadow);
  transition: background 0.2s, box-shadow 0.2s, transform 0.1s;
}

.btn-login:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 8px var(--shadow);
}

.btn-login:active {
  transform: scale(0.98);
  box-shadow: 0 1px 2px var(--shadow);
}

.btn-login:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(44, 62, 80, 0.2);
}

[data-theme="dark"] .btn-login:focus-visible {
  box-shadow: 0 0 0 3px rgba(91, 141, 238, 0.3);
}

.btn-save {
  margin-top: 0.75rem;
  padding: 0.5rem 1.25rem;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 5px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.btn-save:hover {
  background: var(--accent);
  color: #fff;
}

.btn-delete {
  padding: 0.5rem 1.25rem;
  background: transparent;
  color: #c0392b;
  border: 1px solid #c0392b;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.btn-delete:hover {
  background: #c0392b;
  color: #fff;
}

/* ── Top bar (select page) ──────────────────────────────────────────────── */

body.has-topbar {
  display: block;
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-light);
  box-shadow: 0 1px 4px var(--shadow);
}

.topbar-inner {
  padding: 0.6rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar-logo img {
  height: 40px;
  width: auto;
  display: block;
}

.topbar-actions {
  display: flex;
  align-items: center;
  font-size: 13px;
}

.topbar-user {
  color: var(--text-muted);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-sep {
  color: var(--border);
  margin: 0 0.5rem;
  user-select: none;
}

.topbar-link {
  color: var(--text-hint);
  text-decoration: none;
  font-weight: 500;
}

.topbar-link:hover {
  color: var(--accent);
}

.topbar-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

.inline-form {
  display: inline;
  margin: 0;
  padding: 0;
}

button.topbar-link,
button.sidebar-action {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
  margin: 0;
}

button.sidebar-action {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
}

.topbar-title {
  flex: 1;
  text-align: center;
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 0.75rem;
}

/* ── Portal layout (sidebar + main) ─────────────────────────────────────── */

:root {
  --sidebar-width: 280px;
  --sidebar-collapsed-width: 0px;
  --sidebar-transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

html.portal-html,
html.portal-html body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

body.portal-body {
  display: flex;
  height: 100%;
  align-items: stretch;
  justify-content: stretch;
  min-height: 0;
}

/* Spacer pushes main content — animated width avoids layout thrash */
.sidebar-spacer {
  width: var(--sidebar-width);
  flex-shrink: 0;
  transition: width var(--sidebar-transition);
  will-change: width;
}

.sidebar-spacer.collapsed {
  width: var(--sidebar-collapsed-width);
}

/* ── Sidebar ────────────────────────────────────────────────────────────── */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--card-bg);
  border-right: none;
  display: flex;
  flex-direction: column;
  z-index: 200;
  transform: translateX(0);
  transition: width var(--sidebar-transition), background 0.2s;
  overflow: hidden;
  will-change: width, transform;
  contain: layout style;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
  border-right: none;
}

.sidebar-header {
  position: relative;
  padding: 0 0.75rem 0 2.25rem;
  border-bottom: none;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 48px;
}

.sidebar-logo {
  display: block;
  overflow: hidden;
  flex-shrink: 0;
}

.sidebar-logo img {
  height: 36px;
  width: auto;
  display: block;
}

.sidebar-collapse-btn {
  position: absolute;
  right: 8px;
  background: #6b7280;
  border: none;
  border-radius: 6px;
  font-family: inherit;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity 0.15s, transform var(--sidebar-transition);
}

.sidebar-collapse-btn:hover {
  opacity: 1;
}

.sidebar.collapsed .sidebar-collapse-btn {
  transform: rotate(180deg);
}

.sidebar.collapsed .sidebar-logo {
  display: none;
}

/* ── Nav list ───────────────────────────────────────────────────────────── */

.sidebar-nav-list {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 8px 6px;
  scrollbar-width: thin;
}

.sidebar-nav-list::-webkit-scrollbar {
  width: 4px;
}

.sidebar-nav-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.sidebar-nav-list ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 6px 10px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  transition: background 150ms ease, color 150ms ease;
}

.sidebar-item:hover {
  background: var(--sidebar-hover-bg, var(--tile-bg));
  color: var(--text);
}

.sidebar-item.active {
  background: var(--sidebar-active-bg, var(--tile-bg));
  color: var(--accent);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--accent);
}

.sidebar-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  border-radius: 6px;
}

.sidebar-badge {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--text-hint);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 150ms ease, color 150ms ease;
}

.sidebar-item.active .sidebar-badge {
  background: var(--accent);
  color: #fff;
}

.sidebar-item:hover .sidebar-badge {
  background: var(--accent);
  color: #fff;
}

.sidebar-label {
  opacity: 1;
  transition: opacity 150ms ease 50ms;
}

.sidebar.collapsed .sidebar-label {
  opacity: 0;
  transition: opacity 100ms ease;
}

.sidebar.collapsed .sidebar-item {
  justify-content: center;
  padding: 0;
}

/* ── Sidebar footer ─────────────────────────────────────────────────────── */

.sidebar-footer {
  margin-top: auto;
  padding: 10px;
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  overflow: hidden;
}

.sidebar-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-footer-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  white-space: nowrap;
  transition: opacity 150ms ease 50ms;
}

.sidebar-action {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 11px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
}

.sidebar-action:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--tile-bg);
}

.sidebar-action:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

.sidebar-logout {
  color: #c0392b;
  border-color: #c0392b;
}

.sidebar-logout:hover {
  color: #fff;
  background: #c0392b;
  border-color: #c0392b;
}

.topbar-logout {
  color: #c0392b;
}

.topbar-logout:hover {
  color: #a93226;
}

/* Collapsed footer: just the avatar centered */
.sidebar.collapsed .sidebar-footer {
  justify-content: center;
  padding: 10px 0;
}

.sidebar.collapsed .sidebar-footer-actions {
  opacity: 0;
  width: 0;
  overflow: hidden;
  transition: opacity 100ms ease;
}

/* ── Main content ───────────────────────────────────────────────────────── */

.portal-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.portal-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-height: 48px;
  padding: 0 16px;
  border-bottom: none;
  background: var(--card-bg);
  flex-shrink: 0;
}

.btn-export {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-muted);
  background: none;
  border: 1px solid var(--border);
  border-radius: 5px;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
}

.btn-export:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--tile-bg);
}

.btn-export:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-cancel {
  color: var(--error-color);
  border-color: var(--error-color);
}

.btn-cancel:hover {
  color: #fff;
  background: var(--error-color);
  border-color: var(--error-color);
}

.portal-main #reportContainer {
  flex: 1;
  width: 100%;
  height: 100%;
  border: none;
  content-visibility: auto;
  contain-intrinsic-size: 0 500px;
  scrollbar-gutter: stable;
}

.portal-main .loading-spinner {
  flex: 1;
}

.portal-main .embed-message {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  color: var(--text-muted);
}

.portal-main .embed-message p {
  font-size: 1rem;
}

/* ── Sidebar expand button (visible when sidebar hidden) ────────────────── */

.sidebar-expand-btn {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 100;
  width: 32px;
  height: 32px;
  background: #6b7280;
  border: none;
  border-radius: 6px;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  opacity: 0.7;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
  transition: opacity 0.15s;
}

.sidebar-expand-btn:hover {
  opacity: 1;
}

/* ── Mobile topbar & sidebar toggle ─────────────────────────────────────── */

.mobile-topbar {
  display: none;
}

.sidebar-toggle {
  background: none;
  border: none;
  font-family: inherit;
  font-size: 1.25rem;
  color: var(--text);
  cursor: pointer;
  padding: 0.25rem;
}

.sidebar-overlay {
  display: none;
}

/* ── Reduced motion ─────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .sidebar,
  .sidebar-spacer,
  .sidebar-collapse-btn,
  .sidebar-item,
  .sidebar-badge,
  .sidebar-label,
  .sidebar-user,
  .sidebar-actions-row {
    transition: none;
  }
  .skeleton-bar,
  .skeleton-chart { animation: none; opacity: 1; }
  .report-reveal { animation: none; opacity: 1; }
  .report-switching { transition: none; }
  .visual-progress { display: none; }
}

/* ── Admin content ───────────────────────────────────────────────────────── */

.admin-content {
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
  padding: 5rem 1.25rem 2rem;
  animation: fadeInUp 0.35s ease-out;
}

/* ── Admin nav ───────────────────────────────────────────────────────────── */

.admin-tile {
  background: var(--admin-tile-bg);
  border-color: var(--admin-tile-border);
  color: var(--accent);
  font-weight: 500;
}

.admin-tile:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.admin-heading {
  font-size: 18px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 1.25rem;
}

.admin-form {
  margin-bottom: 2rem;
}

.admin-nav {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--border-light);
}

.admin-nav a {
  padding: 0.5rem 1rem;
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 14px;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}

.admin-nav a:hover {
  color: var(--accent);
}

.admin-nav a.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.sub-nav {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-light);
}

.sub-nav a {
  padding: 0.4rem 0.85rem;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.sub-nav a:hover {
  color: var(--accent);
}

.sub-nav a.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── Inputs ──────────────────────────────────────────────────────────────── */

.search-input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--input-bg);
  outline: none;
  margin-bottom: 0.75rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(44, 62, 80, 0.12);
}

[data-theme="dark"] .search-input:focus {
  box-shadow: 0 0 0 3px rgba(91, 141, 238, 0.2);
}

.multi-select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--input-bg);
  padding: 0.25rem;
  min-height: 120px;
  outline: none;
}

.multi-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(44, 62, 80, 0.12);
}

[data-theme="dark"] .multi-select:focus {
  box-shadow: 0 0 0 3px rgba(91, 141, 238, 0.2);
}

.multi-select option {
  padding: 0.35rem 0.5rem;
  border-radius: 3px;
}

.multi-select option:checked {
  background: var(--accent);
  color: #fff;
}

/* ── Pagination ──────────────────────────────────────────────────────────── */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1rem;
}

.page-btn {
  padding: 0.4rem 0.9rem;
  background: var(--card-bg);
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.page-btn:hover:not(:disabled) {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.page-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.page-info {
  font-size: 13px;
  color: var(--text-muted);
  min-width: 100px;
  text-align: center;
}

/* ── Group / user rows ───────────────────────────────────────────────────── */

.group-details {
  border: 1px solid var(--border-light);
  border-radius: 6px;
  margin-bottom: 0.6rem;
  overflow: hidden;
}

.group-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 0.65rem 0.75rem;
  cursor: pointer;
  font-weight: 500;
  color: var(--text);
  background: var(--summary-bg);
  user-select: none;
}

.group-summary:hover {
  background: var(--summary-bg-hover);
}

.group-dash-count {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-hint);
}

.user-last-login {
  width: 100%;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-hint);
  margin-top: 0.2rem;
}

.group-edit-form {
  padding: 0.75rem;
  border-top: 1px solid var(--border-light);
}

/* ── Misc ────────────────────────────────────────────────────────────────── */

.form-hint {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 1.25rem;
}

.back-link {
  display: block;
  text-align: center;
  margin-top: 1rem;
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
}

.back-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

.field-hint {
  font-size: 12px;
  color: var(--text-hint);
  margin-top: 0.3rem;
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.4rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
}

.users-list-heading {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.75rem;
}

.users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-bottom: 1.5rem;
}

.users-table th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  background: var(--tile-bg);
  color: var(--text-muted);
  font-weight: 500;
  border-bottom: 1px solid var(--border-light);
}

.users-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
}

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

.strength-wrapper {
  margin-top: 0.4rem;
}

.strength-bar {
  height: 4px;
  background: var(--border-light);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 0.3rem;
}

.strength-fill {
  height: 100%;
  width: 0;
  border-radius: 2px;
  transition: width 0.25s, background 0.25s;
}

.strength-label {
  font-size: 12px;
  font-weight: 500;
  display: block;
  margin-bottom: 0.4rem;
  min-height: 1em;
}

.strength-checklist {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.75rem;
}

.strength-checklist li {
  font-size: 11px;
  color: var(--text-hint);
  padding-left: 1.1em;
  position: relative;
}

.strength-checklist li::before {
  content: '✕';
  position: absolute;
  left: 0;
  color: var(--error-color);
}

.strength-checklist li.met {
  color: var(--info-color);
}

.strength-checklist li.met::before {
  content: '✓';
  color: var(--info-color);
}

.error {
  color: var(--error-color);
  font-size: 13px;
  margin-bottom: 1rem;
  padding: 0.5rem 0.75rem;
  background: var(--error-bg);
  border-radius: 4px;
  border-left: 3px solid var(--error-color);
}

.info {
  color: var(--info-color);
  font-size: 13px;
  padding: 0.5rem 0.75rem;
  background: var(--info-bg);
  border-radius: 4px;
  border-left: 3px solid var(--info-color);
}

/* ── Greeting overlay ───────────────────────────────────────────────────── */

.greeting-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  animation: greetFade 2.2s ease-in-out forwards;
}

.greeting-overlay .greeting-text {
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--text);
  text-align: center;
  animation: greetSlide 2.2s ease-in-out forwards;
}

@keyframes greetFade {
  0%   { opacity: 1; }
  70%  { opacity: 1; }
  100% { opacity: 0; pointer-events: none; }
}

@keyframes greetSlide {
  0%   { opacity: 0; transform: translateY(8px); }
  15%  { opacity: 1; transform: translateY(0); }
  70%  { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-8px); }
}

/* ── Empty state ────────────────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  opacity: 0.5;
}

.empty-state p {
  font-size: 14px;
  margin-bottom: 0.5rem;
}

.empty-state .empty-state-hint {
  font-size: 12px;
  color: var(--text-hint);
}

/* ── Loading spinner ────────────────────────────────────────────────────── */

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

.loading-spinner {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-spinner::after {
  content: '';
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-light);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ── Dashboard skeleton loader ──────────────────────────────────────────── */

@keyframes shimmer {
  0%   { background-position: -600px 0; }
  100% { background-position: 600px 0; }
}

.skeleton-loader {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1.5rem;
  gap: 1rem;
  overflow: hidden;
}

@keyframes skeletonCascade {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.skeleton-bar {
  border-radius: 4px;
  background: var(--border-light);
  background-image: linear-gradient(90deg, var(--border-light) 0%, var(--skeleton-shine) 40%, var(--border-light) 80%);
  background-size: 600px 100%;
  animation: skeletonCascade 0.35s ease-out both, shimmer 1.6s ease-in-out 0.35s infinite;
}

:root { --skeleton-shine: #ebebeb; }
[data-theme="dark"] { --skeleton-shine: #2d3748; }

.skeleton-title   { width: 35%; height: 18px; animation-delay: 0s, 0.35s; }
.skeleton-filter  { width: 100%; height: 36px; border-radius: 6px; animation-delay: 0.08s, 0.43s; }
.skeleton-charts {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 1rem;
}
.skeleton-chart {
  border-radius: 8px;
  background: var(--border-light);
  background-image: linear-gradient(90deg, var(--border-light) 0%, var(--skeleton-shine) 40%, var(--border-light) 80%);
  background-size: 600px 100%;
  animation: skeletonCascade 0.35s ease-out both, shimmer 1.6s ease-in-out 0.35s infinite;
}
.skeleton-chart:nth-child(1) { animation-delay: 0.16s, 0.51s; }
.skeleton-chart:nth-child(2) { animation-delay: 0.24s, 0.59s; }
.skeleton-chart:nth-child(3) { animation-delay: 0.32s, 0.67s; }
.skeleton-chart:nth-child(4) { animation-delay: 0.40s, 0.75s; }

@media (max-width: 600px) {
  .skeleton-charts { grid-template-columns: 1fr; }
}

/* ── Report fade-in ─────────────────────────────────────────────────────── */

.report-reveal {
  animation: reportFadeIn 0.3s ease-out both;
}
@keyframes reportFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.report-switching {
  opacity: 0.45;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

/* ── Visual progress indicator ──────────────────────────────────────────── */

.visual-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--border-light);
  z-index: 10;
  opacity: 1;
  transition: opacity 0.4s ease;
}

.visual-progress.done { opacity: 0; }

.visual-progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.3s ease-out;
}

/* ── Mobile responsive ──────────────────────────────────────────────────── */

@media (max-width: 600px) {

  /* Let the card fill the screen instead of floating centred */
  body {
    align-items: flex-start;
    padding: 1rem 0.75rem;
  }

  .card {
    padding: 1.5rem 1.25rem;
    max-width: 100%;
    border-radius: 10px;
  }

  .select-content,
  .admin-content {
    padding-top: 4.5rem;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  /* Sidebar slides off-screen on mobile */
  .sidebar-spacer {
    display: none;
  }

  .sidebar {
    width: 260px;
    transform: translateX(-100%);
    transition: transform var(--sidebar-transition);
    box-shadow: none;
  }

  .sidebar.collapsed {
    width: 260px;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px var(--shadow);
  }

  .sidebar .sidebar-collapse-btn {
    display: none;
  }

  .sidebar.collapsed .sidebar-logo {
    display: block;
  }

  .sidebar.collapsed .sidebar-label,
  .sidebar.collapsed .sidebar-user,
  .sidebar.collapsed .sidebar-actions-row {
    opacity: 1;
  }

  .sidebar.collapsed .sidebar-item {
    justify-content: flex-start;
    padding: 0 10px;
  }

  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 150;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
  }

  .sidebar-overlay.open {
    opacity: 1;
    pointer-events: auto;
  }

  .mobile-topbar {
    display: block;
    position: static;
    flex-shrink: 0;
  }

  body.portal-body {
    flex-direction: column;
  }

  .topbar-logo img {
    height: 32px;
  }

  .topbar-actions {
    font-size: 12px;
  }

  .topbar-user {
    max-width: 90px;
  }

  .topbar-title {
    font-size: 0.8rem;
  }

  /* Wrap admin nav tabs */
  .admin-nav {
    flex-wrap: wrap;
    gap: 0;
  }

  .admin-nav a {
    flex: 1 1 auto;
    text-align: center;
    padding: 0.6rem 0.5rem;
    font-size: 13px;
  }

  .sub-nav {
    flex-wrap: wrap;
    gap: 0;
  }

  .sub-nav a {
    flex: 1 1 auto;
    text-align: center;
    padding: 0.5rem 0.5rem;
  }

  /* Bigger touch targets */
  .btn-login,
  .btn-save,
  .btn-delete,
  .page-btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .btn-login {
    font-size: 16px;
  }

  .back-link {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Multi-select shorter on mobile */
  .multi-select {
    min-height: 90px;
  }

  /* Pagination */
  .pagination {
    gap: 0.5rem;
  }

  .page-info {
    min-width: auto;
    font-size: 12px;
  }

  /* Prevent iOS zoom on input focus (font-size >= 16px) */
  .field input,
  .search-input,
  .multi-select {
    font-size: 16px;
  }
}
