/* ===== PAGE TRANSITIONS ===== */
/*
  body MUST NOT get a CSS transform at any point.
  A transform on any ancestor of position:fixed children creates a new
  containing block, trapping the fixed topbar relative to body instead of
  the viewport (causing it to scroll with content). Opacity-only on body;
  the slide is applied to .app-content which is a *sibling*, not ancestor,
  of .app-topbar, so it cannot trap fixed descendants.
*/
@keyframes pageEnter {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes pageExit {
  from { opacity: 1; }
  to   { opacity: 0; }
}
@keyframes contentSlideEnter {
  from { transform: translateY(14px); }
  to   { transform: none; }
}
@keyframes contentSlideExit {
  from { transform: translateY(0); }
  to   { transform: translateY(-10px); }
}
body.page-enter { animation: pageEnter 0.42s cubic-bezier(0.22, 1, 0.36, 1) both; }
body.page-exit  { animation: pageExit 0.21s ease-in both; pointer-events: none; }
/* Slide applied only to the content area (sibling of topbar, not ancestor) */
body.page-enter .app-content { animation: contentSlideEnter 0.42s cubic-bezier(0.22, 1, 0.36, 1) both; }
body.page-exit  .app-content { animation: contentSlideExit  0.21s ease-in both; }

/* ===== PORTAL STYLES ===== */

:root {
  --blue: #0078AC;
  --blue-dark: #005a82;
  --blue-subtle: #eff8ff;
  --orange: #E8572A;
  --orange-dark: #c94418;
  --green: #16a34a;
  --green-subtle: #f0fdf4;
  --red: #dc2626;
  --text: #0f172a;
  --text-mid: #374151;
  --text-light: #6b7280;
  --bg: #f6f8fa;
  --bg-card: #ffffff;
  --border: #e5e7eb;
  --border-light: #f3f4f6;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 12px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.04);
  --font: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ===== THEME TRANSITIONS ===== */
body,
.portal-header,
.portal-card,
.wt-section,
.wt-title-card,
.wt-notes-card,
.wt-question-row,
.wt-toggle-btn,
.imu-zone,
.note-zone,
.note-textarea,
.success-box,
.success-meta,
.oa-score-card,
.oa-sub-block,
.oa-item-label,
.penalty-note {
  transition-property: background-color, border-color, color, box-shadow;
  transition-duration: 0.22s;
  transition-timing-function: ease;
}

/* ===== DARK MODE ===== */
html[data-theme="dark"] {
  --bg:           #0f172a;
  --bg-card:      #1e293b;
  --text:         #f1f5f9;
  --text-mid:     #cbd5e1;
  --text-light:   #94a3b8;
  --border:       #334155;
  --border-light: #1e293b;
  --blue-subtle:  #0c2d48;
  --green-subtle: #052e16;
  --shadow-sm:    0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.25);
  --shadow:       0 4px 12px rgba(0,0,0,0.35), 0 1px 3px rgba(0,0,0,0.2);
  --shadow-md:    0 8px 24px rgba(0,0,0,0.4), 0 2px 6px rgba(0,0,0,0.25);
  color-scheme: dark;
}
html[data-theme="dark"] body {
  background: var(--bg);
  color: var(--text);
}
html[data-theme="dark"] .portal-header {
  background: rgba(15,23,42,0.95);
  border-bottom-color: var(--border);
  box-shadow: 0 1px 0 var(--border), 0 2px 10px rgba(0,0,0,0.4);
}
/* Card surfaces */
html[data-theme="dark"] .portal-card,
html[data-theme="dark"] .wt-title-card,
html[data-theme="dark"] .wt-section,
html[data-theme="dark"] .wt-notes-card {
  background: var(--bg-card);
  border-color: var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
}
html[data-theme="dark"] .portal-card:hover {
  box-shadow: 0 6px 20px rgba(0,0,0,0.4), 0 2px 6px rgba(0,0,0,0.25);
}
/* Forms */
html[data-theme="dark"] .wt-form-group input,
html[data-theme="dark"] .wt-form-group select,
html[data-theme="dark"] .wt-form-group textarea,
html[data-theme="dark"] .wt-notes-card textarea {
  background: #0f172a;
  color: var(--text);
  border-color: var(--border);
}
html[data-theme="dark"] .wt-form-group input::placeholder,
html[data-theme="dark"] .wt-form-group textarea::placeholder,
html[data-theme="dark"] .wt-notes-card textarea::placeholder { color: var(--text-light); }
html[data-theme="dark"] .wt-form-group input:focus,
html[data-theme="dark"] .wt-form-group select:focus,
html[data-theme="dark"] .wt-form-group textarea:focus,
html[data-theme="dark"] .wt-notes-card textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0,120,172,0.2);
}
/* Toggle buttons */
html[data-theme="dark"] .wt-toggle-btn {
  background: #243044;
  border-color: var(--border);
  color: var(--text-light);
}
html[data-theme="dark"] .wt-toggle-btn:hover { border-color: var(--text-light); }
html[data-theme="dark"] .wt-toggle-btn.yes-active {
  background: #052e16;
  border-color: #16a34a;
  color: #4ade80;
}
html[data-theme="dark"] .wt-toggle-btn.no-active {
  background: #2d1515;
  border-color: var(--red);
  color: #f87171;
}
/* Question rows */
html[data-theme="dark"] .wt-question-row { border-bottom-color: var(--border); }
html[data-theme="dark"] .wt-question-row.answer-no  { background: #2d1515; }
html[data-theme="dark"] .wt-question-row.unanswered {
  background: #261e00;
  outline-color: #d97706;
}
/* Section structure */
html[data-theme="dark"] .wt-section-header { border-bottom-color: var(--border); }
html[data-theme="dark"] .wt-section-count  { color: var(--text-light); }
/* Upload zones */
html[data-theme="dark"] .imu-zone {
  background: #172033;
  border-top-color: var(--border);
}
html[data-theme="dark"] .imu-zone.imu-zone-encouraged {
  background: #1c1800;
  border-top-color: #78550a;
}
html[data-theme="dark"] .imu-zone.imu-zone-required {
  background: #2d1515;
  border-top-color: #7f1d1d;
}
html[data-theme="dark"] .imu-zone.imu-drag {
  background: #0c1e3d;
  border-top-color: var(--blue);
}
/* Note zones */
html[data-theme="dark"] .note-zone {
  background: #172033;
  border-top-color: var(--border);
}
html[data-theme="dark"] .note-zone.note-zone-open {
  background: #0a1f0f;
  border-top-color: #166534;
}
html[data-theme="dark"] .note-textarea {
  background: #0f172a;
  color: var(--text);
  border-color: var(--border);
}
html[data-theme="dark"] .note-textarea::placeholder { color: var(--text-light); }
html[data-theme="dark"] .note-textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0,120,172,0.15);
}
/* Tables */
html[data-theme="dark"] .portal-table th {
  background: #162032;
  color: var(--text-light);
  border-bottom-color: var(--border);
}
html[data-theme="dark"] .portal-table td {
  color: var(--text-mid);
  border-bottom-color: var(--border-light);
}
html[data-theme="dark"] .portal-table tbody tr:hover { background: #243044; }
/* Success overlay */
html[data-theme="dark"] .success-overlay { background: rgba(0,0,0,0.75); }
html[data-theme="dark"] .success-box {
  background: var(--bg-card);
  color: var(--text);
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
html[data-theme="dark"] .success-icon { background: #052e16; }
html[data-theme="dark"] .success-meta { background: #0f172a; }
html[data-theme="dark"] .success-meta-row { border-bottom-color: var(--border); }
html[data-theme="dark"] .success-meta-row span:first-child { color: var(--text-light); }
html[data-theme="dark"] .success-meta-row span:last-child  { color: var(--text); }
/* Buttons */
html[data-theme="dark"] .btn-logout {
  color: var(--text-light);
  border-color: var(--border);
}
html[data-theme="dark"] .btn-logout:hover {
  background: var(--bg-card);
  color: var(--text);
  border-color: var(--text-light);
}
/* Badges */
html[data-theme="dark"] .badge-store {
  background: var(--blue-subtle);
  border-color: rgba(0,120,172,0.25);
}
/* Explicit text color overrides — ensure legibility on dark surfaces */
html[data-theme="dark"] .wt-question-text   { color: var(--text); }
html[data-theme="dark"] .wt-section-title   { color: var(--text); }
html[data-theme="dark"] .wt-section-count   { color: var(--text-light); }
html[data-theme="dark"] .wt-title-card h2   { color: var(--text); }
html[data-theme="dark"] .wt-notes-card h3   { color: var(--text); }
html[data-theme="dark"] .wt-form-group label { color: var(--text-light); }
html[data-theme="dark"] .portal-page-title  { color: var(--text); }
html[data-theme="dark"] .portal-card-header h2 { color: var(--text); }
html[data-theme="dark"] .wt-notes-card textarea { color: var(--text); }
html[data-theme="dark"] .noteworthy-row label { color: var(--text); }
html[data-theme="dark"] .empty-state { color: var(--text-light); }

/* Grade bar dark accents are already dark so they work in both modes */

/* ===== BUTTON CONTRAST — DARK MODE ===== */

/* btn-start: white bg → var(--text) becomes #f1f5f9 in dark = invisible.
   Force dark text explicitly so white button stays readable on dark CTA card. */
html[data-theme="dark"] .btn-start {
  background: #f1f5f9;
  color: #0f172a;
}
html[data-theme="dark"] .btn-start:hover {
  background: #e2e8f0;
  color: #0f172a;
}

/* btn-export: --green-subtle becomes #052e16 in dark, --green is #16a34a.
   Dark green text on very dark green bg = ~3:1 contrast. Boost text to bright green. */
html[data-theme="dark"] .btn-export {
  background: rgba(22, 163, 74, 0.12);
  color: #4ade80;
  border-color: rgba(74, 222, 128, 0.25);
}
html[data-theme="dark"] .btn-export:hover {
  background: rgba(22, 163, 74, 0.2);
  border-color: rgba(74, 222, 128, 0.45);
}

/* wt-toggle-btn default: increase text contrast from --text-light to --text-mid */
html[data-theme="dark"] .wt-toggle-btn {
  background: #243044;
  border-color: var(--border);
  color: var(--text-mid);
}
html[data-theme="dark"] .wt-toggle-btn:hover {
  border-color: var(--text-mid);
  background: #2d3c56;
}

/* btn-success-new hover: #e8f4fb is a very light blue — wrong for dark mode */
html[data-theme="dark"] .btn-success-new:hover {
  background: rgba(0, 120, 172, 0.18);
}

/* imu-btn required state: #C62828 dark red on dark bg = low contrast.
   Use lighter red so it reads clearly. */
html[data-theme="dark"] .imu-btn.imu-btn-required {
  color: #f87171;
}
html[data-theme="dark"] .imu-btn.imu-btn-encouraged {
  color: #fb923c;
}

/* note-btn has-note: --green (#16a34a) on very dark note zone bg = borderline.
   Use bright green. */
html[data-theme="dark"] .note-btn.note-btn-has-note {
  color: #4ade80;
}
html[data-theme="dark"] .note-btn.note-btn-has-note:hover {
  color: #86efac;
}

/* note-btn default: #bbb is fine on dark, but keep it consistent */
html[data-theme="dark"] .note-btn {
  color: #64748b;
}
html[data-theme="dark"] .note-btn:hover {
  color: #94a3b8;
}

/* Mobile account menu */
html[data-theme="dark"] .mobile-account-menu {
  box-shadow: 0 8px 30px rgba(0,0,0,0.5), 0 2px 8px rgba(0,0,0,0.3);
}
html[data-theme="dark"] .account-menu-item:hover    { background: #243044; }
html[data-theme="dark"] .account-menu-signout       { color: #f87171; }
html[data-theme="dark"] .account-menu-signout svg   { color: #f87171; }
html[data-theme="dark"] .account-menu-signout:hover { background: #2d1515; }

/* ===== OPERATIONS ASSESSMENT — dark overrides for embedded styles ===== */
html[data-theme="dark"] .oa-score-card {
  background: var(--bg-card);
  border-color: var(--border);
}
html[data-theme="dark"] .oa-score-bar-track { background: var(--border); }
html[data-theme="dark"] .oa-score-badge {
  background: #243044;
  color: var(--text-light);
}
html[data-theme="dark"] .oa-score-chip {
  background: #243044;
  color: var(--text-light);
  border-color: var(--border);
}
html[data-theme="dark"] .oa-section-score {
  background: #243044;
  color: var(--text-light);
}
html[data-theme="dark"] .oa-sub-block {
  background: #1a1614;
  border-left-color: #E8572A;
}
html[data-theme="dark"] .oa-sub-block .wt-question-row {
  background: #1a1614;
  border-bottom-color: #2d2620;
}
html[data-theme="dark"] .oa-item-label {
  background: #162032;
  color: var(--text-light);
  border-top-color: var(--border);
}
html[data-theme="dark"] .penalty-section .wt-section-header {
  background: #2d1515;
  border-bottom-color: #7f1d1d;
}
html[data-theme="dark"] .penalty-note {
  background: #2d1515;
  color: #fca5a5;
  border-bottom-color: #7f1d1d;
}
html[data-theme="dark"] .penalty-row { background: var(--bg-card); }
html[data-theme="dark"] .penalty-row.answer-no { background: #0d200f !important; }
html[data-theme="dark"] .penalty-row .wt-toggle-btn.yes-active {
  background: #2d1515 !important;
  border-color: var(--red) !important;
  color: #f87171 !important;
}
html[data-theme="dark"] .penalty-row .wt-toggle-btn.no-active {
  background: #052e16 !important;
  border-color: var(--green) !important;
  color: #4ade80 !important;
}

/* ===== THEME TOGGLE BUTTON ===== */
.btn-dark-toggle {
  background: transparent;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  padding: 7px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s, opacity 0.15s;
  opacity: 0.4;
  flex-shrink: 0;
  min-width: 34px;
  min-height: 34px;
}
.btn-dark-toggle:hover  { opacity: 1; background: rgba(0,0,0,0.07); }
.btn-dark-toggle svg    { width: 15px; height: 15px; display: block; flex-shrink: 0; }
html[data-theme="dark"] .btn-dark-toggle { color: #fbbf24; opacity: 0.55; }
html[data-theme="dark"] .btn-dark-toggle:hover { opacity: 1; background: rgba(255,255,255,0.09); }

/* ===== REPORT MODAL — DARK MODE ===== */
/* Modal surface */
html[data-theme="dark"] .sub-overlay  { background: rgba(0,0,0,0.65); }
html[data-theme="dark"] .sub-modal    { background: var(--bg-card); box-shadow: 0 12px 48px rgba(0,0,0,0.55); }
html[data-theme="dark"] .sub-modal-hdr {
  background: var(--bg-card);
  border-bottom-color: var(--border);
}
/* Header text */
html[data-theme="dark"] .sub-modal-hdr h2 { color: var(--text); }
html[data-theme="dark"] .sub-modal-sub    { color: var(--text-light); }
html[data-theme="dark"] .sub-modal-close  { color: var(--text-light); }
html[data-theme="dark"] .sub-modal-close:hover { color: var(--text); }
/* PDF download button — invert to stay legible on dark card */
html[data-theme="dark"] .sub-pdf-btn {
  background: #e2e8f0;
  color: #0f172a;
}
html[data-theme="dark"] .sub-pdf-btn:hover { background: #f1f5f9; }
/* Score bar */
html[data-theme="dark"] .sub-score-track  { background: var(--border); }
html[data-theme="dark"] .sub-score-pct    { color: var(--text); }
/* Meta grid */
html[data-theme="dark"] .sub-meta-label   { color: var(--text-light); }
html[data-theme="dark"] .sub-meta-item    { color: var(--text); }
/* Section headers & dividers */
html[data-theme="dark"] .sub-section-hdr  { color: var(--text-light); }
html[data-theme="dark"] .sub-q-row {
  border-bottom-color: var(--border);
  color: var(--text);
}
html[data-theme="dark"] .sub-q-text { color: var(--text); }
html[data-theme="dark"] .sub-q-note { color: var(--text-light); background: var(--bg-alt, #1e2330); }
/* Answer pills — keep vivid but softer on dark */
html[data-theme="dark"] .sub-badge.yes { background: #052e16; color: #4ade80; }
html[data-theme="dark"] .sub-badge.no  { background: #2d1515; color: #f87171; }
html[data-theme="dark"] .sub-badge.na  { background: var(--border); color: var(--text-light); }
/* Overall notes section */
html[data-theme="dark"] .sub-notes-section { border-top-color: var(--border); }
html[data-theme="dark"] .sub-notes-label   { color: var(--text-light); }
html[data-theme="dark"] .sub-notes-text    { color: var(--text); }

/* ===== DELETE MODAL & CARD MENU — DARK MODE ===== */
html[data-theme="dark"] .del-modal {
  background: var(--bg-card);
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
html[data-theme="dark"] .del-modal h3     { color: var(--text); }
html[data-theme="dark"] .del-modal-desc   { color: var(--text-light); }
html[data-theme="dark"] .btn-del-cancel {
  border-color: var(--border);
  color: var(--text-mid);
}
html[data-theme="dark"] .btn-del-cancel:hover { background: #243044; }
html[data-theme="dark"] .card-menu-drop {
  background: var(--bg-card);
  border-color: var(--border);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4), 0 2px 6px rgba(0,0,0,0.25);
}
html[data-theme="dark"] .card-menu-item {
  color: var(--text-mid);
}
html[data-theme="dark"] .card-menu-item:hover { background: #243044; }
html[data-theme="dark"] .card-menu-delete { color: #f87171; }
html[data-theme="dark"] .card-menu-delete:hover { background: #2d1515; }
/* Submission cards in dark mode */
html[data-theme="dark"] .sub-card:hover  { background: #243044; }
html[data-theme="dark"] .sub-card-store  { color: var(--text); }
html[data-theme="dark"] .sub-card-meta   { color: var(--text-light); }
html[data-theme="dark"] .sub-list-empty  { color: var(--text-light); }
html[data-theme="dark"] .sub-list-footer a { color: #60a5fa; }
html[data-theme="dark"] .sub-list-title  { color: var(--text); }
html[data-theme="dark"] .btn-export-inline {
  color: var(--text-light);
  border-color: var(--border);
}
html[data-theme="dark"] .btn-export-inline:hover { color: var(--text); border-color: var(--text-light); }
html[data-theme="dark"] .btn-resume {
  color: #60a5fa;
  background: #0c2d48;
  border-color: #1e4976;
}
html[data-theme="dark"] .btn-resume:hover { background: #0e3d60; border-color: #2563eb; }
html[data-theme="dark"] .card-menu-btn { color: var(--text-light); }
html[data-theme="dark"] .card-menu-btn:hover { background: rgba(255,255,255,0.07); color: var(--text); }

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

html { overflow-x: clip; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 16px;
  line-height: 1.5;
  overflow-x: clip;
}

/* ===== PORTAL HEADER ===== */
.portal-header {
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  height: 64px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: 0 1px 0 var(--border), var(--shadow-sm);
}

.portal-header-inner {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.portal-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.portal-brand img { height: 32px; width: auto; object-fit: contain; }

.portal-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.portal-user-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.welcome-text {
  font-size: 0.875rem;
  color: var(--text-light);
  font-weight: 500;
}

.role-badge {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--blue-subtle);
  color: var(--blue);
  border: 1px solid rgba(0,120,172,0.15);
}

.role-badge.admin { background: #fff3ee; color: var(--orange); border-color: rgba(232,87,42,0.2); }
.role-badge.mastermind { background: #1a0533; color: #d4a8ff; border-color: rgba(180,80,255,0.35); letter-spacing: 0.08em; }

.btn-logout {
  background: transparent;
  color: var(--text-light);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  font-family: var(--font);
}
.btn-logout:hover { background: var(--bg); color: var(--text); border-color: #d1d5db; }

/* ===== PORTAL CONTENT ===== */
.portal-content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 24px 80px;
  padding-top: 100px; /* 60px fixed topbar + 40px visual spacing */
}

.portal-page-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 32px;
  letter-spacing: -0.02em;
}

/* ===== ANIMATIONS ===== */
@keyframes cardFadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== PORTAL CARDS ===== */
.portal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 24px;
  transition: box-shadow 0.2s;
  animation: cardFadeUp 0.5s cubic-bezier(0.22,1,0.36,1) both;
}

.portal-card:nth-child(2) { animation-delay: 0.1s; }
.portal-card:nth-child(3) { animation-delay: 0.18s; }

.portal-card:hover {
  box-shadow: var(--shadow-md);
}

.portal-card-header {
  padding: 20px 24px 18px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.portal-card-header h2 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.portal-card-body {
  padding: 24px;
}

/* ===== CTA CARD ===== */
.cta-walkthrough {
  background: #040d18;
  color: #fff;
  border-radius: var(--radius);
  padding: 14px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.16), 0 2px 6px rgba(0,0,0,0.1);
  flex-wrap: wrap;
  position: relative;
  overflow: hidden;
  animation: cardFadeUp 0.5s cubic-bezier(0.22,1,0.36,1) both;
}

/* Subtle glow accent */
.cta-walkthrough::before {
  content: '';
  position: absolute;
  top: -80px; left: -60px;
  width: 400px; height: 300px;
  background: radial-gradient(ellipse, rgba(0,120,172,0.25) 0%, transparent 65%);
  pointer-events: none;
}

.cta-walkthrough-text h2 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 2px;
  letter-spacing: -0.02em;
}

.cta-walkthrough-text p {
  font-size: 0.76rem;
  color: rgba(255,255,255,0.5);
  max-width: 460px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.btn-start {
  background: #fff;
  color: var(--text);
  border: none;
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
  font-family: var(--font);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  position: relative;
  z-index: 1;
}
.btn-start:hover {
  background: #f1f5f9;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  text-decoration: none;
}
.btn-start:active { transform: translateY(0); }

/* ===== VEGAS RALLY COUNTDOWN ===== */
.rally-countdown-card {
  background: linear-gradient(160deg, #07122e 0%, #0a1a40 50%, #0d1e4a 100%);
  border-radius: var(--radius);
  padding: 36px 40px;
  text-align: center;
  margin-bottom: 24px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.22), 0 2px 8px rgba(0,0,0,0.14);
  position: relative;
  overflow: hidden;
  animation: cardFadeUp 0.5s cubic-bezier(0.22,1,0.36,1) 0.1s both;
}
.rally-countdown-card::before {
  content: '';
  position: absolute;
  top: -80px; left: 50%; transform: translateX(-50%);
  width: 600px; height: 300px;
  background: radial-gradient(ellipse, rgba(198,40,40,0.14) 0%, transparent 65%);
  pointer-events: none;
}
.rally-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.45);
  margin-bottom: 24px;
  position: relative;
}
.rally-timer {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 8px;
  position: relative;
}
.rally-unit {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 80px;
}
.rally-num {
  font-size: clamp(2.4rem, 5vw, 3.8rem);
  font-weight: 800;
  color: #fff;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  transition: opacity 0.15s ease;
}
.rally-num.tick { opacity: 0.55; }
.rally-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
  margin-top: 6px;
}
.rally-colon {
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 300;
  color: rgba(198,40,40,0.7);
  line-height: 1;
  padding-top: 2px;
  user-select: none;
}
.rally-begun {
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.04em;
  margin: 0;
}

@media (max-width: 640px) {
  .rally-countdown-card { padding: 28px 20px; }
  .rally-unit { min-width: 56px; }
  .rally-colon { font-size: 1.6rem; padding-top: 4px; }
}

/* ===== TABLES ===== */
.portal-table-wrap {
  overflow-x: auto;
}

.portal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.portal-table th {
  text-align: left;
  padding: 10px 20px;
  background: var(--bg);
  color: var(--text-light);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.portal-table td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-mid);
  vertical-align: middle;
  font-size: 0.875rem;
}

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

.portal-table tbody tr {
  transition: background 0.12s;
}
.portal-table tbody tr:hover { background: #fafbfc; }

.badge-store {
  display: inline-flex;
  align-items: center;
  background: var(--blue-subtle);
  color: var(--blue);
  font-weight: 600;
  font-size: 0.78rem;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid rgba(0,120,172,0.12);
  letter-spacing: 0.02em;
}

.empty-state {
  text-align: center;
  padding: 56px 20px;
  color: var(--text-light);
  font-size: 0.875rem;
}

/* ===== EXPORT BUTTON ===== */
.btn-export {
  background: var(--green-subtle);
  color: var(--green);
  border: 1px solid rgba(22,163,74,0.2);
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s, border-color 0.15s;
  font-family: var(--font);
}
.btn-export:hover { background: #dcfce7; border-color: rgba(22,163,74,0.35); }

/* ===== GRADE BAR ===== */
.grade-bar {
  background: #0c1a3d;
  padding: 11px 24px;
  position: sticky;
  top: 60px;
  z-index: 190;
  box-shadow: 0 2px 14px rgba(0,0,0,0.28);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.grade-bar-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 20px;
}
.grade-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
  min-width: 160px;
}
.grade-eyebrow {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255,255,255,0.35);
}
.grade-status {
  font-size: 0.76rem;
  font-weight: 600;
  color: rgba(255,255,255,0.55);
  white-space: nowrap;
}
.grade-track-outer {
  flex: 1;
  height: 5px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  overflow: hidden;
}
.grade-track-fill {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  transition: width 0.35s ease, background-color 0.35s ease;
  background: rgba(255,255,255,0.2);
}
.grade-track-fill.gf-green  { background: #4ade80; }
.grade-track-fill.gf-yellow { background: #fbbf24; }
.grade-track-fill.gf-red    { background: #f87171; }
.grade-number {
  flex-shrink: 0;
  font-size: 1.45rem;
  font-weight: 800;
  line-height: 1;
  color: rgba(255,255,255,0.28);
  font-variant-numeric: tabular-nums;
  min-width: 72px;
  text-align: right;
  transition: color 0.3s;
}
.grade-number.gn-green  { color: #4ade80; }
.grade-number.gn-yellow { color: #fbbf24; }
.grade-number.gn-red    { color: #f87171; }
@media (max-width: 640px) {
  .grade-bar   { padding: 10px 16px; }
  .grade-meta  { min-width: 100px; }
  .grade-number { font-size: 1.2rem; min-width: 58px; }
  .grade-status { font-size: 0.7rem; }
}

/* ===== WALKTHROUGH FORM ===== */
.walkthrough-content {
  max-width: 900px;
  margin: 0 auto;
  padding: 28px 24px 80px;
}

.wt-title-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 32px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.wt-title-card h2 {
  font-size: 1.2rem;
  font-weight: 800;
  margin-bottom: 20px;
  color: var(--text);
}

.wt-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.wt-form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wt-form-group label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-light);
}

.wt-form-group input,
.wt-form-group select,
.wt-form-group textarea {
  padding: 10px 13px;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-size: 0.95rem;
  font-family: var(--font);
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.wt-form-group input:focus,
.wt-form-group select:focus,
.wt-form-group textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0,120,172,0.12);
}

.wt-form-group.error input,
.wt-form-group.error select {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(198,40,40,0.1);
}

/* ===== SECTION CARDS ===== */
.wt-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.wt-section-header {
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--border);
}

.wt-section-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.wt-section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}

.wt-section-count {
  font-size: 0.8rem;
  color: var(--text-light);
}

/* ===== QUESTION ROWS ===== */
.wt-question-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
  transition: background 0.15s;
}

.wt-question-row:last-child { border-bottom: none; }
.wt-question-row.answer-no  { background: #fff5f5; }
.wt-question-row.unanswered { background: #fff8e1; outline: 2px solid #f59e0b; outline-offset: -2px; }

.wt-question-text {
  width: 100%;
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.5;
}

.wt-toggle-group {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.wt-toggle-btn {
  width: 68px;
  height: 36px;
  border: 2px solid var(--border);
  border-radius: 6px;
  background: #f5f7fa;
  color: var(--text-light);
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.12s;
  font-family: var(--font);
}

.wt-toggle-btn:hover { border-color: #aaa; }

.wt-toggle-btn.yes-active {
  background: #e8f5e9;
  border-color: var(--green);
  color: var(--green);
}

.wt-toggle-btn.no-active {
  background: #ffebee;
  border-color: var(--red);
  color: var(--red);
}

.wt-toggle-btn.na-active {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #2563eb;
}

html[data-theme="dark"] .wt-toggle-btn.na-active {
  background: #1e3a5f;
  border-color: #3b82f6;
  color: #60a5fa;
}

/* Training evaluation: Ready / Not Ready / Not Trained / Not started */
.wt-toggle-btn.ready-active       { background:#e8f5e9; border-color:#4caf50; color:#2e7d32; }
.wt-toggle-btn.not-ready-active   { background:#ffebee; border-color:var(--red); color:var(--red); }
.wt-toggle-btn.not-trained-active { background:#fff8e1; border-color:#f59e0b; color:#b45309; }
.wt-toggle-btn.not-started-active { background:#f1f5f9; border-color:#94a3b8; color:#475569; }
html[data-theme="dark"] .wt-toggle-btn.ready-active       { background:#14532d; border-color:#4ade80; color:#4ade80; }
html[data-theme="dark"] .wt-toggle-btn.not-ready-active   { background:#450a0a; border-color:#f87171; color:#f87171; }
html[data-theme="dark"] .wt-toggle-btn.not-trained-active { background:#451a03; border-color:#fbbf24; color:#fbbf24; }
html[data-theme="dark"] .wt-toggle-btn.not-started-active { background:#1e293b; border-color:#64748b; color:#94a3b8; }
.wt-toggle-btn.certified-active     { background:#e8f5e9; border-color:#4caf50; color:#2e7d32; }
.wt-toggle-btn.not-certified-active { background:#fff3e0; border-color:#f59e0b; color:#b45309; }
html[data-theme="dark"] .wt-toggle-btn.certified-active     { background:#14532d; border-color:#4ade80; color:#4ade80; }
html[data-theme="dark"] .wt-toggle-btn.not-certified-active { background:#451a03; border-color:#fbbf24; color:#fbbf24; }

/* ===== SUBGROUP HEADERS, LONGTEXT, CHECKLIST ===== */
.wt-subgroup-header {
  font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: var(--text-light, #6b7280);
  padding: .5rem 1rem .25rem; margin-top: .5rem;
  border-top: 1px solid var(--border, #e5e7eb);
}
.wt-subgroup-header:first-of-type { border-top: none; margin-top: 0; }

.wt-longtext-input {
  width: 100%; min-height: 60px; padding: .5rem;
  border: 1px solid var(--border, #d1d5db); border-radius: 8px;
  font: inherit; font-size: .82rem; resize: vertical;
  background: var(--bg-card, #fff); color: var(--text, #1f2937);
}

.wt-numeric-input {
  width: 90px; height: 36px;
  border: 2px solid var(--border, #d1d5db); border-radius: 6px;
  background: #f5f7fa; color: var(--text, #1f2937);
  font-size: .875rem; font-weight: 700; text-align: center;
  font-family: var(--font); padding: 0 6px; flex-shrink: 0;
}
.wt-numeric-input:focus { border-color: #93c5fd; outline: none; }
html[data-theme="dark"] .wt-numeric-input {
  background: var(--bg-card, #1e293b); color: var(--text, #e2e8f0);
  border-color: var(--border, #334155);
}

.wt-checklist-group { display: flex; flex-wrap: wrap; gap: .35rem .75rem; padding: .35rem 0; }
.wt-checklist-item { display: flex; align-items: center; gap: .3rem; font-size: .8rem; cursor: pointer; }
.wt-checklist-item input[type="checkbox"] { accent-color: var(--blue, #0078AC); }

.wt-subchecklist { display: flex; flex-direction: column; gap: .25rem; padding: .4rem 0 .15rem .25rem; width: 100%; }
.wt-subchecklist-item { display: flex; align-items: center; gap: .4rem; font-size: .78rem; color: var(--text-light, #6b7280); cursor: pointer; }
.wt-subchecklist-item input[type="checkbox"] { accent-color: var(--blue, #0078AC); width: 14px; height: 14px; flex-shrink: 0; }
.wt-subchecklist-item span { line-height: 1.3; }

html[data-theme="dark"] .wt-subgroup-header { color: var(--text-light); border-top-color: var(--border); }
html[data-theme="dark"] .wt-longtext-input {
  background: var(--bg-card, #1e293b); color: var(--text, #e2e8f0);
  border-color: var(--border, #334155);
}

/* ===== BACK TO INSPECTIONS BUTTON ===== */
.btn-back-insp {
  display: inline-flex;
  align-items: center;
  gap: .38rem;
  font-size: .76rem;
  font-weight: 600;
  letter-spacing: .01em;
  color: var(--text-light, #64748b);
  text-decoration: none;
  background: rgba(10, 22, 40, .045);
  border: 1.5px solid var(--border, #e2e8f0);
  border-radius: 999px;
  padding: .3rem .82rem .3rem .6rem;
  margin-bottom: 1.25rem;
  line-height: 1;
  font-family: var(--font, 'Inter', sans-serif);
  transition: color .14s, background .14s, border-color .14s, box-shadow .14s;
  user-select: none;
}
.btn-back-insp svg { flex-shrink: 0; }
.btn-back-insp:hover {
  color: var(--text, #0f172a);
  background: rgba(10, 22, 40, .08);
  border-color: #94a3b8;
  box-shadow: 0 1px 5px rgba(10, 22, 40, .09);
  text-decoration: none;
}
html[data-theme="dark"] .btn-back-insp {
  background: rgba(255, 255, 255, .04);
  border-color: rgba(255, 255, 255, .1);
  color: #475569;
}
html[data-theme="dark"] .btn-back-insp:hover {
  background: rgba(255, 255, 255, .08);
  border-color: rgba(255, 255, 255, .22);
  color: #94a3b8;
  box-shadow: 0 1px 5px rgba(0, 0, 0, .35);
}

/* ===== NOTES SECTION ===== */
.wt-notes-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 32px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.wt-notes-card h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.wt-notes-card textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-size: 0.95rem;
  font-family: var(--font);
  resize: vertical;
  min-height: 110px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

.wt-notes-card textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,120,172,0.12); }

.noteworthy-row {
  margin-top: 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.noteworthy-row label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

/* ===== SUBMIT AREA ===== */
.wt-submit-area {
  text-align: center;
  padding: 16px 0 8px;
}

.btn-submit-wt {
  background: var(--blue);
  color: #fff;
  border: none;
  padding: 15px 48px;
  border-radius: 8px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.15s, transform 0.1s;
}
.btn-submit-wt:hover { background: var(--blue-dark); }
.btn-submit-wt:active { transform: scale(0.97); }

.submit-error {
  color: var(--red);
  font-size: 0.9rem;
  margin-top: 12px;
  display: none;
}
.submit-error.show { display: block; }

/* ===== SUCCESS OVERLAY ===== */
.success-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.success-overlay.show {
  display: flex;
}

.success-box {
  background: #fff;
  border-radius: 16px;
  padding: 48px 40px;
  max-width: 480px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}

.success-icon {
  width: 72px;
  height: 72px;
  background: #e8f5e9;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
  font-size: 2.2rem;
}

.success-box h2 {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 10px;
  color: var(--text);
}

.success-box .sub {
  color: var(--text-light);
  margin-bottom: 24px;
  font-size: 0.95rem;
  line-height: 1.6;
}

.success-meta {
  background: var(--bg);
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 28px;
  text-align: left;
}

.success-meta-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.875rem;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}
.success-meta-row:last-child { border-bottom: none; }
.success-meta-row span:first-child { color: var(--text-light); }
.success-meta-row span:last-child  { font-weight: 600; }

.success-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-success-dashboard {
  background: var(--blue);
  color: #fff;
  border: none;
  padding: 12px 24px;
  border-radius: 7px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s;
}
.btn-success-dashboard:hover { background: var(--blue-dark); text-decoration: none; }

.btn-success-new {
  background: transparent;
  color: var(--blue);
  border: 2px solid var(--blue);
  padding: 11px 24px;
  border-radius: 7px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.15s;
}
.btn-success-new:hover { background: #e8f4fb; }

/* ===== LOGIN PAGE ===== */
@keyframes loginBlobDrift1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  40%       { transform: translate(50px, -40px) scale(1.1); }
  70%       { transform: translate(-30px, 20px) scale(0.92); }
}
@keyframes loginBlobDrift2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50%       { transform: translate(-45px, 35px) scale(0.9); }
}
@keyframes loginBlobDrift3 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50%       { transform: translate(30px, -50px) scale(1.08); }
}
@keyframes loginCardIn {
  from { opacity: 0; transform: translateY(28px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0a1628;
  padding: 24px;
  position: relative;
  overflow: hidden;
}

/* Dot grid tech texture */
.login-page::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(255,255,255,0.045) 1px, transparent 1px);
  background-size: 36px 36px;
  pointer-events: none;
  z-index: 0;
}

.login-home-logo {
  position: absolute;
  top: 24px;
  left: 28px;
  z-index: 10;
  opacity: 0.85;
  transition: opacity 0.2s;
}
.login-home-logo:hover { opacity: 1; }
.login-home-logo img {
  height: 38px;
  width: auto;
  display: block;
}

.login-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.login-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  will-change: transform;
}

.login-blob-1 {
  width: 600px; height: 600px;
  top: -200px; left: 50%; margin-left: -300px;
  background: radial-gradient(circle, rgba(0,120,172,0.3) 0%, transparent 70%);
  animation: loginBlobDrift1 12s ease-in-out infinite;
}

.login-blob-2 {
  width: 400px; height: 400px;
  bottom: -100px; right: -80px;
  background: radial-gradient(circle, rgba(220,53,69,0.18) 0%, transparent 70%);
  animation: loginBlobDrift2 15s ease-in-out infinite;
}

.login-blob-3 {
  width: 480px; height: 480px;
  bottom: -80px; left: -120px;
  background: radial-gradient(circle, rgba(0,40,110,0.4) 0%, transparent 70%);
  animation: loginBlobDrift3 18s ease-in-out infinite;
}

.login-card {
  position: relative;
  z-index: 1;
  background: rgba(30, 55, 90, 0.55);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 20px;
  padding: 52px 44px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 32px 80px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.06);
  text-align: center;
  animation: loginCardIn 0.8s cubic-bezier(0.22, 1, 0.36, 1) 0.1s both;
}

.login-logo {
  margin: 0 auto 16px;
}

.login-logo img {
  height: 56px;
  width: auto;
  object-fit: contain;
  margin: 0 auto;
}

.login-logo .login-logo-text {
  display: block;
  text-align: center;
  font-size: 2rem;
  font-weight: 900;
  color: #fff;
  letter-spacing: -0.02em;
}

.login-home-logo .nav-logo-text {
  font-size: 1.1rem;
  font-weight: 800;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
}

.login-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}

.login-sub {
  font-size: 0.875rem;
  color: rgba(255,255,255,0.38);
  margin-bottom: 32px;
  font-weight: 400;
}

.login-form .form-group {
  text-align: left;
  margin-bottom: 18px;
}

.login-form .form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  display: block;
  margin-bottom: 8px;
  color: rgba(255,255,255,0.5);
}

.login-form .form-group input {
  width: 100%;
  padding: 12px 14px;
  background: rgba(255,255,255,0.06);
  border: 1.5px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  font-size: 0.97rem;
  font-family: var(--font);
  outline: none;
  color: #fff;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.login-form .form-group input::placeholder {
  color: rgba(255,255,255,0.2);
}

.login-form .form-group input:focus {
  border-color: var(--blue);
  background: rgba(255,255,255,0.09);
  box-shadow: 0 0 0 3px rgba(0,120,172,0.2);
}

.btn-login {
  width: 100%;
  background: var(--blue);
  color: #fff;
  border: none;
  padding: 13px;
  border-radius: 8px;
  font-size: 0.97rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  letter-spacing: 0.02em;
  transition: background 0.15s, transform 0.1s;
  margin-top: 8px;
}
.btn-login:hover { background: var(--blue-dark); }
.btn-login:active { transform: scale(0.98); }

.login-error {
  background: rgba(220,53,69,0.15);
  color: #ff8a8a;
  border: 1px solid rgba(220,53,69,0.3);
  padding: 10px 14px;
  border-radius: 7px;
  font-size: 0.875rem;
  margin-bottom: 16px;
  display: none;
  text-align: left;
}
.login-error.show { display: block; }

.login-back {
  margin-top: 24px;
  font-size: 0.82rem;
  color: rgba(255,255,255,0.28);
}

.login-back a {
  color: rgba(255,255,255,0.45);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s;
}
.login-back a:hover { color: rgba(255,255,255,0.75); text-decoration: none; }

/* ===== MOBILE HEADER ELEMENTS (hidden on desktop) ===== */
.portal-toggle-mobile { display: none; }
.portal-header-row2   { display: none; }

.mobile-welcome {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-light);
}

/* ── Account trigger ── */
.mobile-account-wrap {
  position: relative;
}

.mobile-account-trigger {
  display: flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 5px 0 5px 10px;
  font-family: var(--font);
  border-radius: 6px;
  min-height: 36px;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s;
}
.mobile-account-trigger:active { opacity: 0.6; }

.mobile-account-role {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-light);
  opacity: 0.75;
  letter-spacing: 0.01em;
}

.mobile-chevron {
  width: 13px;
  height: 13px;
  color: var(--text-light);
  opacity: 0.45;
  flex-shrink: 0;
  transition: transform 0.18s ease;
}
.mobile-account-trigger[aria-expanded="true"] .mobile-chevron {
  transform: rotate(180deg);
}

/* ── Account dropdown ── */
.mobile-account-menu {
  position: fixed;
  right: 14px;
  width: 190px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 13px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.07);
  z-index: 500;
  overflow: hidden;
  opacity: 0;
  transform: scale(0.95) translateY(-6px);
  transform-origin: top right;
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
}
.mobile-account-menu.open {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
}

.account-menu-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 16px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-mid);
  cursor: pointer;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  font-family: var(--font);
  transition: background 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.account-menu-item svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  color: var(--text-light);
}
.account-menu-item:hover  { background: var(--bg); }
.account-menu-item:active { opacity: 0.65; }

.account-menu-divider {
  height: 1px;
  background: var(--border-light);
  margin: 2px 0;
}

.account-menu-signout       { color: #e53e3e; }
.account-menu-signout svg   { color: #e53e3e; }
.account-menu-signout:hover { background: #fff5f5; }

/* ===== RESPONSIVE ===== */

/* --- Mobile (≤ 768px) — full mobile redesign --- */
@media (max-width: 768px) {

  /* ── Header: 2-row layout ── */
  .portal-header {
    height: auto;
    flex-direction: column;
    align-items: stretch;
    padding: 0;
  }
  .portal-header-inner {
    height: 52px;
    padding: 0 18px;
    max-width: 100%;
  }
  /* Hide desktop user controls */
  .portal-user          { display: none; }
  /* Show mobile toggle in row 1 */
  .portal-toggle-mobile { display: flex; }
  /* Show mobile info row 2 */
  .portal-header-row2 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 18px 12px;
    border-bottom: 1px solid var(--border);
  }

  /* ── Content layout ── */
  .walkthrough-content { max-width: 100%; }
  .portal-content {
    max-width: 100%;
    padding: 20px 16px 64px;
    padding-top: 80px; /* 60px fixed topbar + 20px visual spacing */
  }
  .portal-page-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 16px;
  }

  /* ── Action cards ── */
  .cta-walkthrough {
    flex-direction: column;
    align-items: flex-start;
    padding: 12px 14px;
    gap: 8px;
    border-radius: 14px;
    margin-bottom: 8px;
  }
  .cta-walkthrough::before { opacity: 0.5; }
  .cta-walkthrough-text    { width: 100%; }
  .cta-walkthrough-text h2 { font-size: 0.86rem; margin-bottom: 1px; }
  .cta-walkthrough-text p  {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.52);
    margin: 0;
    line-height: 1.35;
  }
  .btn-start {
    width: 100%;
    justify-content: center;
    padding: 10px 16px;
    min-height: 42px;
    font-size: 0.82rem;
    border-radius: 10px;
  }

  /* ── Portal card ── */
  .portal-card {
    margin-bottom: 14px;
    border-radius: 14px;
  }
  .portal-card-header {
    padding: 16px 16px 14px;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .portal-card-header h2 { font-size: 0.875rem; }
  .btn-export {
    align-self: stretch;
    justify-content: center;
    text-align: center;
    min-height: 40px;
    font-size: 0.78rem;
    border-radius: 8px;
    padding: 8px 14px;
  }

  /* ── Table → submission cards ── */
  .portal-table-wrap  { overflow-x: visible; padding: 0 14px 16px; }
  .portal-table       { display: block; min-width: 0; }
  .portal-table thead { display: none; }
  .portal-table tbody { display: block; }
  .portal-table tr {
    display: block;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    margin-bottom: 10px;
    padding: 12px 14px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
  }
  .portal-table tr:last-child { margin-bottom: 0; }
  .portal-table td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    padding: 5px 0;
    border: none;
    font-size: 0.83rem;
    text-align: right;
  }
  .portal-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-light);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
    flex-shrink: 0;
    text-align: left;
    padding-top: 1px;
  }
  /* Empty state: polished block, no label */
  .portal-table td.empty-state {
    display: block;
    text-align: center;
    padding: 36px 16px;
    font-size: 0.875rem;
    color: var(--text-light);
    line-height: 1.65;
  }
  .portal-table td.empty-state::before { display: none; }
}

/* --- Mobile (≤ 640px) — small screen refinements --- */
@media (max-width: 640px) {
  .portal-header-inner { height: 48px; padding: 0 16px; }
  .portal-header-row2  { padding: 0 16px 8px; }
  .portal-brand img    { height: 24px; }

  .walkthrough-content { padding: 16px 14px 64px; }

  /* Walkthrough form */
  .wt-title-card { padding: 16px; }
  .wt-form-grid  { grid-template-columns: 1fr; gap: 12px; }
  .wt-title-card h2 { font-size: 1rem; margin-bottom: 14px; }
  /* Prevent iOS auto-zoom on focus (font-size must be ≥ 16px) */
  .wt-form-group input,
  .wt-form-group select,
  .wt-form-group textarea { min-height: 44px; font-size: 1rem; }

  /* Question rows */
  .wt-question-row { padding: 12px 14px; gap: 8px; }
  .wt-question-text  { font-size: 0.875rem; }
  .wt-toggle-btn     { min-height: 44px; min-width: 60px; font-size: 0.82rem; }

  /* Section headers */
  .wt-section-header { padding: 12px 14px; gap: 10px; }
  .wt-section-title  { font-size: 0.9rem; }
  .wt-section-count  { font-size: 0.75rem; }

  /* Notes card */
  .wt-notes-card { padding: 16px; }
  .noteworthy-row { flex-direction: column; align-items: flex-start; gap: 10px; }

  /* Upload & note zones */
  .imu-zone  { padding-left: 14px; padding-right: 14px; }
  .note-zone { padding-left: 14px; padding-right: 14px; }

  /* Success overlay — bottom sheet */
  .success-overlay { align-items: flex-end; padding: 0; }
  .success-box {
    padding: 28px 20px 40px;
    border-radius: 20px 20px 0 0;
    width: 100%;
    max-width: 100%;
    margin: 0;
  }
  .success-actions { flex-direction: column; gap: 10px; }
  .btn-success-dashboard,
  .btn-success-new {
    width: 100%;
    justify-content: center;
    text-align: center;
    min-height: 48px;
  }

  /* Login */
  .login-card { padding: 36px 20px; }
  .login-home-logo { top: 16px; left: 16px; }
  .login-home-logo img { height: 30px; }
  .login-form input { min-height: 44px; font-size: 1rem; }
  .btn-login { min-height: 48px; }
}

/* --- Small phones (≤ 430px) --- */
@media (max-width: 430px) {
  .portal-page-title { font-size: 0.95rem; }
}

/* --- Very small (≤ 380px) --- */
@media (max-width: 380px) {
  .mobile-welcome      { display: none; }
  .portal-header-inner { gap: 8px; }
}

/* ===== SHARED: TOGGLE BUTTON TRANSITION ===== */
.wt-toggle-btn {
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

/* ===== SHARED: IMAGE UPLOAD ZONES ===== */
.imu-zone {
  padding: 5px 20px 7px;
  background: #fafafa;
  border-top: 1px dashed #ebebeb;
  transition: background 0.18s, border-color 0.18s;
}
.imu-zone.imu-zone-encouraged {
  background: #fffcf5;
  border-top-color: #ffe082;
}
.imu-zone.imu-zone-required {
  background: #fff8f8;
  border-top-color: #ffcdd2;
}
.imu-zone.imu-drag {
  background: #f0f4ff;
  border-top-color: #1a3fa0;
}
.oa-sub-block .imu-zone {
  padding-left: 36px;
  background: #fffaf9;
}
.imu-input { display: none; }
.imu-btn-row { display: flex; align-items: center; }
.imu-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #bbb;
  background: none;
  border: none;
  padding: 3px 0;
  cursor: pointer;
  transition: color 0.15s;
}
.imu-btn:hover                    { color: #1a3fa0; }
.imu-btn.imu-btn-encouraged       { color: #E65100; }
.imu-btn.imu-btn-encouraged:hover { color: #bf360c; }
.imu-btn.imu-btn-required         { color: #C62828; font-weight: 700; }
.imu-btn.imu-btn-required:hover   { color: #8b0000; }
.imu-icon { width: 13px; height: 13px; flex-shrink: 0; }
.imu-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 7px;
}
.imu-thumbs:empty { display: none; }
.imu-thumb {
  position: relative;
  width: 62px;
  height: 62px;
  border-radius: 7px;
  overflow: hidden;
  border: 1px solid #e0e0e0;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}
.imu-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.imu-thumb-rm {
  position: absolute;
  top: 3px; right: 3px;
  width: 17px; height: 17px;
  border-radius: 50%;
  background: rgba(0,0,0,0.52);
  color: #fff;
  border: none;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  transition: background 0.15s;
}
.imu-thumb-rm:hover { background: rgba(198,40,40,0.88); }

/* Thumbnail upload status overlay */
.imu-thumb-status {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: opacity 0.2s;
}
.imu-thumb[data-status="uploaded"] .imu-thumb-status {
  background: rgba(0,0,0,0.25);
  opacity: 1;
}
.imu-thumb[data-status="uploading"] .imu-thumb-status {
  background: rgba(0,0,0,0.35);
  opacity: 1;
}
.imu-thumb[data-status="failed"] .imu-thumb-status {
  background: rgba(180,30,30,0.55);
  opacity: 1;
  cursor: pointer;
  pointer-events: auto;
}
.imu-spinner {
  width: 20px; height: 20px;
  border: 2.5px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: imu-spin 0.7s linear infinite;
}
@keyframes imu-spin { to { transform: rotate(360deg); } }
.imu-check {
  width: 22px; height: 22px;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}
.imu-retry-label {
  font-size: 0.55rem;
  color: #fff;
  font-weight: 700;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  line-height: 1.2;
}

.imu-msg {
  display: block;
  font-size: 0.7rem;
  color: #C62828;
  margin-top: 3px;
}
@media (max-width: 640px) {
  .imu-zone { padding-left: 16px; padding-right: 16px; }
}

/* ===== DRAFT SAVE INDICATOR (walkthrough.html) ===== */
.draft-indicator {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 500;
  color: transparent;
  min-width: 80px;
  text-align: center;
  transition: color 0.2s;
}
.draft-indicator[data-state="saving"] { color: var(--text-light); }
.draft-indicator[data-state="saved"]  { color: var(--green); }
.draft-indicator[data-state="error"]  { color: var(--text-light); }

/* ===== QUESTION NOTE ZONES ===== */
.note-zone {
  padding: 5px 20px 7px;
  background: #fafafa;
  border-top: 1px dashed #ebebeb;
  transition: background 0.18s, border-color 0.18s;
}
.note-zone.note-zone-open {
  background: #f9fff9;
  border-top-color: #c8e6c9;
}
.note-btn-row { display: flex; align-items: center; }
.note-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #bbb;
  background: none;
  border: none;
  padding: 3px 0;
  cursor: pointer;
  transition: color 0.15s;
  font-family: var(--font);
}
.note-btn:hover { color: #1a3fa0; }
.note-btn.note-btn-has-note { color: var(--green); }
.note-btn.note-btn-has-note:hover { color: #0d8c36; }
.note-icon { width: 13px; height: 13px; flex-shrink: 0; }
.note-expand { margin-top: 6px; }
.note-textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
  font-family: var(--font);
  resize: vertical;
  min-height: 52px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: #fff;
}
.note-textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0,120,172,0.1);
}
@media (max-width: 640px) {
  .note-zone { padding-left: 16px; padding-right: 16px; }
}

/* ===== APP SHELL & SIDEBAR (v10) ===== */

.app-shell { display: flex; min-height: 100vh; width: 100%; max-width: 100vw; overflow-x: hidden; }

/* --- Sidebar --- */
.sb {
  width: 232px;
  min-height: 100vh;
  background: #0b1120;
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 300;
  border-right: 1px solid rgba(255,255,255,0.06);
  transition: transform .25s cubic-bezier(.4,0,.2,1);
}

.sb-brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1.1rem 1.1rem .9rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  text-decoration: none;
}
.sb-logo { width: 36px; height: 36px; object-fit: contain; flex-shrink: 0; }
.sb-brand-name {
  font-size: .875rem; font-weight: 700;
  color: #fff; letter-spacing: -.01em;
  white-space: nowrap;
}

.sb-nav { flex: 1; padding: .6rem .7rem; overflow-y: auto; }

.sb-section-label {
  font-size: .63rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  color: rgba(255,255,255,0.28);
  padding: .9rem .5rem .25rem;
}

.sb-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .48rem .7rem;
  border-radius: 8px;
  font-size: .85rem;
  font-weight: 500;
  color: rgba(255,255,255,0.52);
  text-decoration: none;
  transition: background .13s, color .13s;
  margin-bottom: 1px;
  white-space: nowrap;
  cursor: pointer;
}

.sb-item:hover {
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.88);
  text-decoration: none;
}
.sb-item.active {
  background: rgba(255,255,255,0.1);
  color: #fff;
}
.sb-icon {
  width: 16px; height: 16px;
  flex-shrink: 0;
  stroke-width: 1.9;
  opacity: .7;
  transition: opacity .13s;
}
.sb-item.active .sb-icon,
.sb-item:hover .sb-icon { opacity: 1; }

/* ── Sidebar group container ── */
.sb-group { margin-bottom: 1px; }
.sb-group > .sb-item { margin-bottom: 0; }

/* Brighten header when a child sub-item is active */
.sb-group:has(.sb-sub-item.active) > .sb-item {
  color: rgba(255,255,255,0.88);
}

/* ── Collapse chevron (JS-injected inside .sb-item) ── */
.sb-chevron {
  width: 13px; height: 13px;
  margin-left: auto;
  flex-shrink: 0;
  stroke-width: 2.2;
  color: rgba(255,255,255,0.22);
  transition: transform .22s cubic-bezier(.4,0,.2,1), color .13s;
}
.sb-item:hover .sb-chevron  { color: rgba(255,255,255,0.5); }
.sb-item.active .sb-chevron { color: rgba(255,255,255,0.4); }
.sb-group.open > .sb-item .sb-chevron {
  transform: rotate(90deg);
  color: rgba(255,255,255,0.45);
}

/* ── Sub-items container with vertical connector ── */
.sb-sub {
  position: relative;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height .24s cubic-bezier(.4,0,.2,1), opacity .18s ease;
}
.sb-sub::before {
  content: '';
  position: absolute;
  left: 1.375rem;
  top: .15rem;
  bottom: .4rem;
  width: 1px;
  background: rgba(255,255,255,0.07);
  border-radius: 1px;
}
.sb-group.open .sb-sub {
  opacity: 1;
  max-height: 600px; /* fallback — also set by sidebar.js */
}

/* ── Sub-section headers inside sub-panels ── */
.sb-sub-hdr {
  display: block;
  padding: .44rem .7rem .44rem 2.45rem;
  font-size: .825rem;
  font-weight: 500;
  letter-spacing: -.008em;
  color: rgba(255,255,255,0.44);
  pointer-events: none;
  user-select: none;
}

/* ── Sub-items — same design language, subordinate ── */
.sb-sub-item {
  display: flex;
  align-items: center;
  padding: .44rem .7rem .44rem 2.45rem;
  border-radius: 7px;
  font-size: .825rem;
  font-weight: 500;
  letter-spacing: -.008em;
  color: rgba(255,255,255,0.44);
  text-decoration: none;
  transition: background .13s, color .13s;
  white-space: nowrap;
  margin-bottom: 1px;
}
.sb-sub-item:hover {
  background: rgba(255,255,255,0.065);
  color: rgba(255,255,255,0.82);
  text-decoration: none;
}
.sb-sub-item.active {
  color: rgba(255,255,255,0.92);
  background: rgba(255,255,255,0.09);
  font-weight: 600;
}

/* ── Collapsed sidebar: hide chevron and sub-panel ── */
@media (min-width: 821px) {
  .app-shell.sb-collapsed .sb-sub     { display: none; }
  .app-shell.sb-collapsed .sb-chevron { display: none !important; }
}

.sb-footer {
  padding: .875rem .875rem;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.sb-user {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-bottom: .6rem;
  padding: .35rem .25rem;
}
.sb-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1a3fa0, #0078AC);
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.sb-user-info { min-width: 0; }
.sb-user-name {
  display: block;
  font-size: .82rem; font-weight: 600;
  color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sb-user-role {
  display: block;
  font-size: .7rem;
  color: rgba(255,255,255,0.38);
  white-space: nowrap;
}
.sb-signout-btn {
  width: 100%;
  padding: .38rem .625rem;
  background: none;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 7px;
  color: rgba(255,255,255,0.42);
  font-size: .775rem; font-weight: 500;
  cursor: pointer;
  font-family: var(--font, 'Inter', sans-serif);
  transition: background .12s, color .12s, border-color .12s;
  text-align: center;
  letter-spacing: .01em;
}
.sb-signout-btn:hover {
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.8);
  border-color: rgba(255,255,255,0.18);
}

/* Sidebar overlay (mobile tap-to-close) */
.sb-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 299;
}
.sb-overlay.open { display: block; }

/* --- App main --- */
.app-main {
  flex: 1;
  min-width: 0;            /* prevent flex child from expanding beyond viewport */
  overflow-x: hidden;      /* hard stop — nothing escapes horizontally */
  margin-left: 232px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg, #f6f8fa);
  padding-top: 60px;
}

/* --- Top bar --- */
.app-topbar {
  height: 60px;
  display: flex;
  align-items: center;
  gap: .875rem;
  padding: 0 1.5rem;
  background: #0a1628;
  border-bottom: none;
  box-shadow: 0 2px 14px rgba(0,0,0,.35);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 9999;
  flex-shrink: 0;
}
.app-topbar-title { display: none; }

/* Back button in top bar — gray pill */
.topbar-back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255,255,255,.12);
  color: rgba(255,255,255,.85);
  text-decoration: none;
  transition: background .14s, color .14s;
  flex-shrink: 0;
}
.topbar-back-btn:hover {
  background: rgba(255,255,255,.2);
  color: #fff;
}

/* Icon tinting for dark bar */
.app-topbar .btn-dark-toggle       { color: rgba(255,255,255,.65); opacity: 1 !important; }
.app-topbar .btn-dark-toggle:hover { background: rgba(255,255,255,.1); color: #fff; }
.app-topbar .tp-profile-btn        { background: rgba(255,255,255,.08); border: 1.5px solid rgba(255,255,255,.22); box-shadow: none; }
.app-topbar .tp-profile-btn:hover  { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.38); box-shadow: none; }
.app-topbar .tp-avatar             { color: rgba(255,255,255,.9); }

/* ── Pin avatar + dark toggle to viewport top-right ── */
.app-topbar .tp-profile-wrap {
  position: fixed;
  top: 15px;
  right: 1.5rem;
  z-index: 250;
}
.app-topbar .btn-dark-toggle {
  position: fixed;
  top: 13px;
  right: calc(1.5rem + 30px + .875rem);
  z-index: 250;
}
/* Reserve space so topbar title doesn't slide under the fixed controls */
.app-topbar {
  padding-right: calc(1.5rem + 30px + .875rem + 34px + .5rem);
}
@media (max-width: 820px) {
  .app-topbar .tp-profile-wrap { right: 1.1rem; }
  .app-topbar .btn-dark-toggle { right: calc(1.1rem + 30px + .875rem); }
  .app-topbar { padding-right: calc(1.1rem + 30px + .875rem + 34px + .5rem); }
}

.sb-toggle {
  display: none;
  background: none; border: none;
  cursor: pointer;
  padding: .3rem;
  border-radius: 6px;
  color: var(--text-light, #6b7280);
}
.sb-toggle:hover { background: rgba(0,0,0,.05); }
.sb-toggle svg { width: 19px; height: 19px; display: block; stroke-width: 1.8; }

/* --- App content --- */
.app-content {
  flex: 1;
  padding: 1.75rem 1.75rem 2.5rem;
  max-width: 1040px;
  width: 100%;
}

body.dark .app-main { background: var(--bg); }

/* ── Topbar logo (visible at all widths) ── */
.mob-topbar-logo { display: flex; flex-shrink: 0; margin-right: auto; text-decoration: none; }
.mob-topbar-logo img { width: 36px; height: 36px; object-fit: contain; display: block; }

/* ── Sidebar trigger (below dark header) ── */
.mob-sb-trigger  { display: none; }

/* ── Legacy safety guard: hide old mob-nav-stack markup if it ever appears ── */
.mob-nav-stack { display: none; }
.mob-nav-logo  { display: none; }

/* ── Sidebar drawer-only mode (pages without app-shell layout) ── */
.sb-drawer-only {
  position: fixed; top: 0; left: 0; height: 100vh;
  transform: translateX(-100%); z-index: 300;
}
.sb-drawer-only.open { transform: translateX(0); }

/* --- Mobile --- */
@media (max-width: 820px) {
  .sb { transform: translateX(-100%); }
  .sb.open { transform: translateX(0); }
  .app-main { margin-left: 0; }
  .app-content { padding: 1.25rem 1.1rem 2rem; }
  .app-topbar  { padding: 0 1.1rem; }

  /* Sidebar trigger */
  .mob-sb-trigger {
    display: flex; align-items: center;
    background: var(--border-light, #f1f3f5); border: none;
    border-radius: 6px; cursor: pointer; font-family: inherit;
    padding: .28rem .42rem; margin: .6rem 0 -.1rem 1.1rem;
    color: var(--text-light, #9ca3af);
    transition: background .13s, color .13s; width: fit-content;
  }
  .mob-sb-trigger svg    { width: 13px; height: 13px; stroke-width: 1.5; display: block; }
  .mob-sb-trigger:hover  { background: var(--border, #e5e7eb); color: var(--text-mid, #374151); }
  .mob-sb-trigger:active { opacity: .6; }
  html[data-theme="dark"] .mob-sb-trigger       { background: rgba(255,255,255,.06); color: rgba(255,255,255,.3); }
  html[data-theme="dark"] .mob-sb-trigger:hover { background: rgba(255,255,255,.1);  color: rgba(255,255,255,.6); }

  /* Hide duplicate text back links on mobile — topbar arrow is sufficient */
  .btn-back-insp, .btn-back-link { display: none; }
}

/* ===== COLLAPSIBLE SIDEBAR ===== */

/* Add width to sidebar transition (transform already there) */
.sb { transition: width .25s cubic-bezier(.4,0,.2,1), transform .25s cubic-bezier(.4,0,.2,1); }

/* Animate text labels out as sidebar narrows */
.sb-item span,
.sb-brand-name {
  overflow: hidden;
  white-space: nowrap;
  max-width: 160px;
  transition: max-width .22s cubic-bezier(.4,0,.2,1), opacity .16s;
}
.sb-user-info {
  overflow: hidden;
  min-width: 0;
  max-width: 160px;
  transition: max-width .22s cubic-bezier(.4,0,.2,1), opacity .16s;
}
.sb-signout-btn {
  max-height: 60px;
  overflow: hidden;
  transition: max-height .22s cubic-bezier(.4,0,.2,1), opacity .16s, margin .22s;
}

/* Smooth main content resize (desktop only) */
@media (min-width: 821px) {
  .app-main { transition: margin-left .25s cubic-bezier(.4,0,.2,1); }
}

/* ---- Collapse toggle button ---- */
.sb-collapse-btn {
  position: absolute;
  /* Keep the existing control below the fixed 60px header. */
  top: 79px;
  right: -11px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 1.5px solid #e2e8f0;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  z-index: 10;
  box-shadow: 0 1px 4px rgba(0,0,0,.1);
  transition: box-shadow .12s, background .12s;
  padding: 0;
  flex-shrink: 0;
}
.sb-collapse-btn:hover { box-shadow: 0 2px 10px rgba(0,0,0,.18); background: #f8fafc; }
.sb-collapse-btn svg {
  width: 11px; height: 11px;
  color: #64748b;
  display: block;
  transition: transform .25s cubic-bezier(.4,0,.2,1);
  stroke-width: 2.5;
}
@media (max-width: 820px) { .sb-collapse-btn { display: none; } }

/* ---- Collapsed state (desktop only) ---- */
@media (min-width: 821px) {

  .app-shell.sb-collapsed .sb         { width: 56px; }
  .app-shell.sb-collapsed .app-main   { margin-left: 56px; }

  .app-shell.sb-collapsed .sb-brand   { justify-content: center; padding-left: .5rem; padding-right: .5rem; }
  .app-shell.sb-collapsed .sb-brand-name { max-width: 0; opacity: 0; pointer-events: none; }

  .app-shell.sb-collapsed .sb-item    { padding: .48rem; justify-content: center; }
  .app-shell.sb-collapsed .sb-item span { max-width: 0; opacity: 0; pointer-events: none; }
  .app-shell.sb-collapsed .sb-icon   { opacity: 1 !important; }

  .app-shell.sb-collapsed .sb-user    { justify-content: center; }
  .app-shell.sb-collapsed .sb-user-info { max-width: 0; opacity: 0; pointer-events: none; }
  .app-shell.sb-collapsed .sb-signout-btn { max-height: 0; opacity: 0; margin: 0; pointer-events: none; }

  .app-shell.sb-collapsed .sb-collapse-btn svg { transform: rotate(180deg); }

  /* ---- Tooltips on collapsed nav items ---- */
  .app-shell.sb-collapsed .sb-nav .sb-item { position: relative; }
  .app-shell.sb-collapsed .sb-nav .sb-item[data-label]::after {
    content: attr(data-label);
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%);
    background: #1e293b;
    color: #f1f5f9;
    font-size: .74rem;
    font-weight: 500;
    padding: .3rem .65rem;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity .1s .06s;
    z-index: 500;
    box-shadow: 0 4px 14px rgba(0,0,0,.18);
  }
  .app-shell.sb-collapsed .sb-nav .sb-item[data-label]:hover::after { opacity: 1; }
}

/* ===== TOPBAR PROFILE BUTTON & DROPDOWN ===== */
.tp-profile-wrap { position: relative; flex-shrink: 0; }

.tp-profile-btn {
  width: 30px; height: 30px; border-radius: 50%; border: none;
  background: var(--border, #e5e7eb); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .13s, box-shadow .13s; padding: 0;
}
.tp-profile-btn:hover {
  background: #d1d5db;
  box-shadow: 0 0 0 3px rgba(0,0,0,.07);
}
.tp-avatar {
  font-size: .72rem; font-weight: 700; color: var(--text, #0f172a);
  line-height: 1; font-family: var(--font, 'Inter', sans-serif); user-select: none;
}

.tp-drop {
  display: none; position: absolute; top: calc(100% + 8px); right: 0;
  width: 190px; background: var(--bg-card, #fff);
  border: 1px solid var(--border, #e5e7eb); border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,.12), 0 1px 4px rgba(0,0,0,.06);
  z-index: 500; overflow: hidden;
}
.tp-drop.open { display: block; }

.tp-drop-info {
  padding: .75rem 1rem .7rem; display: flex; flex-direction: column; gap: .12rem;
}
.tp-drop-name {
  font-size: .845rem; font-weight: 700; color: var(--text, #0f172a);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tp-drop-role { font-size: .72rem; color: var(--text-light, #6b7280); text-transform: capitalize; }

.tp-drop-divider { height: 1px; background: var(--border, #e5e7eb); }

.tp-drop-logout {
  display: flex; align-items: center; gap: .6rem;
  width: 100%; padding: .65rem 1rem; background: none; border: none;
  font-size: .845rem; font-weight: 500; color: #dc2626; cursor: pointer;
  font-family: var(--font, 'Inter', sans-serif); text-align: left; transition: background .1s;
}
.tp-drop-logout:hover { background: #fff5f5; }

/* Dark mode */
html[data-theme="dark"] .tp-profile-btn       { background: #334155; }
html[data-theme="dark"] .tp-profile-btn:hover { background: #3e5068; box-shadow: 0 0 0 3px rgba(255,255,255,.07); }
html[data-theme="dark"] .tp-avatar            { color: #f1f5f9; }
html[data-theme="dark"] .tp-drop             { background: var(--bg-card); border-color: var(--border); box-shadow: 0 4px 24px rgba(0,0,0,.4); }
html[data-theme="dark"] .tp-drop-divider     { background: var(--border); }
html[data-theme="dark"] .tp-drop-logout:hover { background: #2d1515; }

/* Dropdown nav item (e.g. Settings link) */
.tp-drop-item {
  display: flex; align-items: center; gap: .6rem;
  width: 100%; padding: .65rem 1rem; background: none; border: none;
  font-size: .845rem; font-weight: 500; color: var(--text, #0f172a); cursor: pointer;
  font-family: var(--font, 'Inter', sans-serif); text-align: left; transition: background .1s;
  text-decoration: none; box-sizing: border-box;
}
.tp-drop-item:hover { background: var(--border-light, #f3f4f6); color: var(--text, #0f172a); }
html[data-theme="dark"] .tp-drop-item       { color: var(--text); }
html[data-theme="dark"] .tp-drop-item:hover { background: #1e293b; }

/* Avatar profile photo */
.tp-profile-btn { overflow: hidden; }
.tp-avatar img  { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }

/* ===== SETTINGS PAGE ===== */
.set-content {
  padding: 1.5rem 1.5rem 4rem;
  max-width: 620px;
}
.set-hdr {
  margin-bottom: 1.75rem;
}
.set-hdr-title {
  font-size: 1.35rem; font-weight: 800; color: var(--text, #0f172a); letter-spacing: -.02em;
}
.set-hdr-sub {
  font-size: .85rem; color: var(--text-light, #6b7280); margin-top: .25rem;
}
.set-card {
  background: var(--bg-card, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 16px;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}
html[data-theme="dark"] .set-card { background: var(--bg-card); border-color: var(--border); }
.set-card-title {
  font-size: .72rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: .09em; color: var(--text-light, #6b7280); margin-bottom: 1.1rem;
}
.set-profile-row {
  display: flex; align-items: center; gap: 1.25rem; margin-bottom: 1.25rem;
}
.set-avatar-wrap { position: relative; flex-shrink: 0; }
.set-avatar {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--blue, #0078AC);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.75rem; font-weight: 800; color: #fff;
  overflow: hidden; flex-shrink: 0;
}
.set-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.set-avatar-upload {
  position: absolute; bottom: -2px; right: -2px;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--blue, #0078AC); border: 2px solid var(--bg-card, #fff);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .15s;
}
.set-avatar-upload:hover { background: var(--blue-dark, #005a82); }
.set-avatar-upload svg { width: 11px; height: 11px; stroke: #fff; stroke-width: 2.2; }
.set-profile-meta { flex: 1; min-width: 0; }
.set-profile-name {
  font-size: 1.05rem; font-weight: 700; color: var(--text, #0f172a);
  letter-spacing: -.015em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.set-profile-username {
  font-size: .78rem; color: var(--text-light, #6b7280); margin-top: .1rem;
}
.set-role-badge {
  display: inline-block; margin-top: .45rem;
  font-size: .67rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; padding: .22rem .6rem;
  border-radius: 999px; background: rgba(0,120,172,.1); color: #0078AC;
}
.set-field-row { margin-bottom: 1rem; }
.set-field-row:last-child { margin-bottom: 0; }
.set-field-row label {
  display: block; font-size: .78rem; font-weight: 600;
  color: var(--text-light, #6b7280); margin-bottom: .35rem;
}
.set-field-row input {
  width: 100%; padding: .62rem .9rem; box-sizing: border-box;
  border: 1px solid var(--border, #e5e7eb); border-radius: 9px;
  font-size: .9rem; font-family: var(--font, 'Inter', sans-serif);
  background: var(--bg-card, #fff); color: var(--text, #0f172a);
  transition: border-color .15s, box-shadow .15s;
}
.set-field-row input:focus {
  outline: none; border-color: var(--blue, #0078AC);
  box-shadow: 0 0 0 3px rgba(0,120,172,.12);
}
.set-field-row input[readonly] {
  background: var(--border-light, #f3f4f6); color: var(--text-mid, #374151);
  cursor: default;
}
.set-field-row input[readonly]:focus { border-color: var(--border, #e5e7eb); box-shadow: none; }
.set-field-hint { font-size: .73rem; color: var(--text-light, #6b7280); margin-top: .3rem; }
html[data-theme="dark"] .set-field-row input { background: #0f172a; color: var(--text); border-color: var(--border); }
html[data-theme="dark"] .set-field-row input[readonly] { background: #1a2535; color: var(--text-mid); }
html[data-theme="dark"] .set-field-row input:focus { border-color: var(--blue); }
.set-save-row { display: flex; align-items: center; gap: .9rem; margin-top: 1.1rem; }
.set-save-btn {
  padding: .62rem 1.4rem; background: var(--blue, #0078AC); color: #fff;
  border: none; border-radius: 9px; font-size: .875rem; font-weight: 600;
  font-family: var(--font, 'Inter', sans-serif); cursor: pointer;
  transition: background .15s, transform .13s;
}
.set-save-btn:hover   { background: var(--blue-dark, #005a82); }
.set-save-btn:active  { transform: scale(.97); }
.set-save-btn:disabled { opacity: .55; cursor: default; }
.set-feedback {
  font-size: .82rem; font-weight: 600; opacity: 0;
  transition: opacity .2s; pointer-events: none;
}
.set-feedback.show { opacity: 1; }
.set-feedback.ok  { color: var(--green, #16a34a); }
.set-feedback.err { color: var(--red, #dc2626); }
.set-divider { height: 1px; background: var(--border, #e5e7eb); margin: 1rem 0; }
.set-pwd-toggle {
  position: absolute; right: .75rem; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; padding: 0; color: var(--text-light);
  display: flex; align-items: center;
}
.set-pwd-toggle svg { width: 16px; height: 16px; stroke-width: 1.75; }
.set-field-row .set-field-inner { position: relative; }
.set-field-inner input { padding-right: 2.6rem; }

@media (max-width: 640px) {
  .set-content { padding: 1rem 1rem 4rem; }
  .set-card { padding: 1.1rem; }
  .set-profile-row { gap: .9rem; }
  .set-avatar { width: 60px; height: 60px; font-size: 1.4rem; }
  .set-profile-name { font-size: .95rem; }
  .set-field-row input { font-size: 1rem; min-height: 44px; }
  .set-save-btn { min-height: 44px; }
}

/* ===== MAINTENANCE TICKET DETAIL PAGE ===== */

/* In-progress pill (ticket cards in list views) */
.pill-in-progress { background: #eff6ff; color: #1d4ed8; }
html[data-theme="dark"] .pill-in-progress { background: #1e3a5f; color: #93c5fd; }

/* In-progress inline badge (headline in list rows) */
.badge-in-progress {
  font-size: .65rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: .14rem .48rem; border-radius: 99px; white-space: nowrap; flex-shrink: 0;
  background: #dbeafe; color: #1d4ed8; border: 1px solid #bfdbfe;
}
html[data-theme="dark"] .badge-in-progress { background:#1e3a5f; color:#93c5fd; border-color:#2a4f7a; }

/* Clickable ticket row */
.maint-ticket-clickable { cursor: pointer; transition: background .13s; }
.maint-ticket-clickable:hover { background: var(--border-light, #f3f4f6); }
html[data-theme="dark"] .maint-ticket-clickable:hover { background: #1e293b; }

/* Detail page — back link: uses shared .btn-back-insp */

/* Detail page — hero */
.td-hero { background:#0a1628; border-radius:16px; padding:1.75rem 1.75rem 1.5rem;
  margin-bottom:1.5rem; position:relative; overflow:hidden; }
.td-hero::before { content:''; position:absolute; top:-60px; right:-40px;
  width:260px; height:200px;
  background:radial-gradient(ellipse,rgba(0,120,172,.28) 0%,transparent 65%); pointer-events:none; }
.td-hero-eyebrow { font-size:.68rem; font-weight:700; letter-spacing:.1em;
  text-transform:uppercase; color:rgba(255,255,255,.38); margin-bottom:.35rem; }
.td-hero-title { font-size:1.45rem; font-weight:900; color:#fff;
  letter-spacing:-.03em; line-height:1.15; margin-bottom:.55rem; }
.td-hero-meta { display:flex; align-items:center; gap:.5rem; flex-wrap:wrap; }

/* Detail page — sections */
.td-section { margin-bottom:1.25rem; }
.td-card { background:var(--bg-card); border:1px solid var(--border); border-radius:14px; overflow:hidden; }
.td-card-hdr { padding:.75rem 1.25rem; border-bottom:1px solid var(--border);
  font-size:.75rem; font-weight:700; text-transform:uppercase; letter-spacing:.07em; color:var(--text-light); }
.td-card-body { padding:1.25rem; }

/* Meta grid (read-only details) */
.td-meta-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(140px,1fr)); gap:1rem; }
.td-meta-label { font-size:.68rem; font-weight:700; text-transform:uppercase;
  letter-spacing:.07em; color:var(--text-light); margin-bottom:.25rem; }
.td-meta-value { font-size:.9rem; font-weight:600; color:var(--text); }
.td-description { font-size:.9rem; color:var(--text-mid); line-height:1.65;
  white-space:pre-wrap; word-break:break-word; margin-top:.875rem; }

/* Photos */
.td-photo { width:100%; max-height:260px; object-fit:cover; display:block;
  border-radius:10px; border:1px solid var(--border); cursor:pointer; }
.td-photos-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(110px,1fr)); gap:.75rem; }
.td-thumb { width:100%; aspect-ratio:1; object-fit:cover; border-radius:8px;
  border:1px solid var(--border); cursor:pointer; transition:opacity .12s; }
.td-thumb:hover { opacity:.85; }
.td-photo-add-btn { width:100%; aspect-ratio:1; border:2px dashed var(--border); border-radius:8px;
  background:transparent; display:flex; flex-direction:column; align-items:center;
  justify-content:center; gap:.35rem; cursor:pointer;
  font-size:.72rem; font-weight:600; color:var(--text-light);
  font-family:var(--font,'Inter',sans-serif); transition:border-color .13s,color .13s; }
.td-photo-add-btn:hover { border-color:var(--blue,#0078AC); color:var(--blue,#0078AC); }
.td-photo-add-btn svg { width:18px; height:18px; stroke-width:1.8; }

/* Notes timeline */
.td-notes-list { display:flex; flex-direction:column; gap:.875rem; }
.td-note { display:flex; gap:.75rem; }
.td-note-avatar { width:28px; height:28px; border-radius:50%; flex-shrink:0; margin-top:.1rem;
  background:linear-gradient(135deg,#1a3fa0,#0078AC);
  display:flex; align-items:center; justify-content:center;
  font-size:.72rem; font-weight:700; color:#fff; }
.td-note-body { flex:1; min-width:0; }
.td-note-meta { font-size:.72rem; color:var(--text-light); margin-bottom:.3rem; }
.td-note-meta strong { color:var(--text-mid); font-weight:600; }
.td-note-text { font-size:.875rem; color:var(--text); line-height:1.55; white-space:pre-wrap; word-break:break-word; }
.td-notes-empty { text-align:center; padding:1.5rem; font-size:.84rem; color:var(--text-light); }
.td-add-note-wrap { padding:1rem 1.25rem; border-top:1px solid var(--border); }
.td-note-textarea { width:100%; box-sizing:border-box; padding:.7rem 1rem; font-size:.88rem;
  font-family:var(--font,'Inter',sans-serif); border:1.5px solid var(--border); border-radius:10px;
  background:var(--bg,#fafafa); color:var(--text); resize:vertical; min-height:80px;
  line-height:1.55; outline:none; transition:border-color .15s,box-shadow .15s; margin-bottom:.65rem; }
.td-note-textarea:focus { border-color:#0078AC; box-shadow:0 0 0 3px rgba(0,120,172,.1); }
.td-note-submit-btn { font-size:.8rem; font-weight:700; padding:.4rem 1rem; border-radius:8px;
  border:none; cursor:pointer; background:#0a1628; color:#fff;
  font-family:var(--font,'Inter',sans-serif); transition:opacity .12s; }
.td-note-submit-btn:hover { opacity:.82; }

/* Status action buttons */
.td-actions { display:flex; flex-direction:column; gap:.65rem; }
.btn-td-in-progress { width:100%; padding:.8rem 1rem; font-size:.9rem; font-weight:700;
  background:#eff6ff; color:#1d4ed8; border:1.5px solid #bfdbfe; border-radius:12px;
  cursor:pointer; font-family:var(--font,'Inter',sans-serif); transition:background .12s; }
.btn-td-in-progress:hover { background:#dbeafe; }
.btn-td-complete { width:100%; padding:.8rem 1rem; font-size:.9rem; font-weight:700;
  background:#f0fdf4; color:#16a34a; border:1.5px solid #bbf7d0; border-radius:12px;
  cursor:pointer; font-family:var(--font,'Inter',sans-serif); transition:background .12s; }
.btn-td-complete:hover { background:#dcfce7; }
.td-status-done { width:100%; padding:.8rem 1rem; font-size:.88rem; font-weight:600;
  background:var(--bg); color:var(--text-light); border:1.5px solid var(--border);
  border-radius:12px; text-align:center; }

/* Supervisor edit fields */
.td-edit-field { margin-bottom:1rem; }
.td-edit-label { display:block; font-size:.7rem; font-weight:700; text-transform:uppercase;
  letter-spacing:.07em; color:var(--text-light); margin-bottom:.45rem; }
.td-edit-select-wrap { position:relative; }
.td-edit-select-wrap::after { content:''; pointer-events:none; position:absolute;
  right:.85rem; top:50%; transform:translateY(-50%);
  border-left:4px solid transparent; border-right:4px solid transparent;
  border-top:5px solid var(--text-light,#9ca3af); }
.td-edit-select, .td-edit-textarea { width:100%; box-sizing:border-box;
  padding:.68rem 2.2rem .68rem .9rem; font-size:.9rem;
  font-family:var(--font,'Inter',sans-serif); border:1.5px solid var(--border);
  border-radius:10px; background:var(--bg-card); color:var(--text);
  -webkit-appearance:none; appearance:none; outline:none;
  transition:border-color .15s,box-shadow .15s; }
.td-edit-textarea { padding:.68rem .9rem; resize:vertical; min-height:90px; }
.td-edit-select:focus, .td-edit-textarea:focus { border-color:#0078AC; box-shadow:0 0 0 3px rgba(0,120,172,.1); }
.td-save-edits-btn { width:100%; padding:.75rem 1rem; font-size:.9rem; font-weight:700;
  background:#0a1628; color:#fff; border:none; border-radius:12px; cursor:pointer;
  font-family:var(--font,'Inter',sans-serif); transition:opacity .12s; margin-top:.25rem; }
.td-save-edits-btn:hover { opacity:.86; }
.td-save-edits-btn:disabled { opacity:.45; cursor:default; }

/* Photo lightbox */
.td-lightbox { display:none; position:fixed; inset:0; background:rgba(0,0,0,.88);
  z-index:1000; align-items:center; justify-content:center; padding:1rem; }
.td-lightbox.open { display:flex; }
.td-lightbox img { max-width:100%; max-height:90vh; border-radius:10px; object-fit:contain; }
.td-lightbox-close { position:absolute; top:1rem; right:1rem; width:36px; height:36px;
  border-radius:50%; background:rgba(255,255,255,.15); border:none; color:#fff;
  font-size:1.2rem; cursor:pointer; display:flex; align-items:center; justify-content:center; }
.td-lightbox-close:hover { background:rgba(255,255,255,.25); }

/* Toast notification */
.td-toast { position:fixed; bottom:1.5rem; left:50%; transform:translateX(-50%);
  background:#0a1628; color:#fff; padding:.65rem 1.25rem; border-radius:10px;
  font-size:.85rem; font-weight:600; box-shadow:0 4px 20px rgba(0,0,0,.25);
  opacity:0; pointer-events:none; transition:opacity .22s; z-index:999;
  font-family:var(--font,'Inter',sans-serif); white-space:nowrap; }
.td-toast.show { opacity:1; }

/* ===== MAINTENANCE: MOBILE TOUCH IMPROVEMENTS ===== */

/* Remove 300ms tap delay and iOS gray flash on all interactive maintenance elements */
.maint-ticket-clickable,
.maint-cta,
.maint-modal-close,
.maint-upload-area,
.maint-upload-btn,
.btn-approve, .btn-reject, .btn-complete,
.btn-submit-maint,
.btn-td-in-progress, .btn-td-complete,
.td-note-submit-btn, .td-save-edits-btn,
.td-photo-add-btn, .td-lightbox-close {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* Ticket detail page — responsive layout on small screens */
@media (max-width: 820px) {
  .td-hero { padding: 1.4rem 1.25rem 1.2rem; }
  .td-hero-title { font-size: 1.2rem; }
  .td-card-body { padding: 1rem; }
  .td-add-note-wrap { padding: .875rem 1rem; }
  .td-meta-grid { grid-template-columns: 1fr 1fr; }
  .td-edit-select, .td-edit-textarea { font-size: 16px; /* prevents iOS auto-zoom on focus */ }
  .td-note-textarea { font-size: 16px; }
}

/* Metric stat cards moved to metric-card.css */

/* ===== PERIOD SELECTOR (shared) ===== */
.period-bar {
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.period-select {
  padding: .4rem .7rem; font-size: .82rem; font-weight: 600;
  border: 1.5px solid var(--border, #e5e7eb); border-radius: 8px;
  background: var(--bg-card, #fff); color: var(--text, #0f172a);
  font-family: var(--font, 'Inter', sans-serif); cursor: pointer;
  outline: none; transition: border-color .14s;
}
.period-select:focus { border-color: #0078AC; }
.period-label {
  font-size: .76rem; font-weight: 600; color: var(--text-light, #6b7280);
}
html[data-theme="dark"] .period-select {
  background: var(--bg-card); color: var(--text); border-color: var(--border);
}
html[data-theme="dark"] .period-select:focus { border-color: #38bdf8; }

/* ── Store Address ── */
.store-address { font-size:.7rem; color:var(--text-light,#6b7280); display:inline-flex; align-items:center; gap:.3rem; margin-top:.15rem; line-height:1.3; }
.store-address svg { width:12px; height:12px; opacity:.5; flex-shrink:0; }
.store-address--hero { color:rgba(255,255,255,.65); }
.store-address--hero svg { opacity:.45; }
html[data-theme="dark"] .store-address { color:var(--text-light,#9ca3af); }
@media print { .store-address { color:#6b7280 !important; } .store-address svg { opacity:.4; } }




/* Shared dialog geometry: navigation stays behind dialogs, and tall contents scroll.
   Explicit wrappers avoid changing drawers, upload masks, and decorative overlays. */
html body :is(
  .sub-overlay,
  .store-org-overlay,
  .edit-person-overlay,
  .ue-modal-overlay,
  .org-add-overlay,
  .org-move-overlay,
  .action-modal-overlay,
  .pkt-confirm-overlay,
  :where(#tgModalOverlay),
  .info-modal-overlay,
  .tg-drilldown-overlay,
  .cal-modal-overlay,
  .dc-modal-overlay,
  .ac-modal-overlay,
  .fc-overlay,
  .wh-modal-backdrop,
  .del-overlay,
  .ua-confirm-overlay,
  .fg-modal-overlay,
  .gb-detail-overlay,
  .gb-modal-overlay,
  .gb-unsaved-overlay,
  .ddv-overlay,
  .maint-overlay,
  .rv-detail-overlay,
  .fah-detail-overlay,
  .fah-del-overlay,
  .sh-del-overlay,
  .cs-modal-backdrop,
  .fse-modal-backdrop,
  .fav-modal-backdrop,
  .oi-modal-backdrop,
  .ov-modal-backdrop,
  .ann-modal-overlay,
  .ooa-overlay,
  .wr-success-overlay,
  .sh-success-overlay,
  .success-overlay,
  :where(#successModal),
  :where(body > div:has(#count-modal-close)),
  :where(body > div:has(#mi-cancel-btn)),
  :where(body > div:has(#del-cancel-btn))
) {
  --dialog-top: max(1rem, env(safe-area-inset-top, 0px));
  --dialog-bottom: max(1rem, env(safe-area-inset-bottom, 0px));
  --dialog-height: calc(100dvh - var(--dialog-top) - var(--dialog-bottom));
  position: fixed !important;
  inset: 0 !important;
  width: auto !important;
  height: 100dvh !important;
  max-height: none !important;
  padding: var(--dialog-top) max(1rem, env(safe-area-inset-right, 0px)) var(--dialog-bottom) max(1rem, env(safe-area-inset-left, 0px)) !important;
  box-sizing: border-box !important;
  z-index: 10020 !important;
  align-items: flex-start !important;
  justify-content: center !important;
  overflow-y: auto !important;
  overscroll-behavior: contain;
}
html body :is(
  .sub-overlay,
  .store-org-overlay,
  .edit-person-overlay,
  .ue-modal-overlay,
  .org-add-overlay,
  .org-move-overlay,
  .action-modal-overlay,
  .pkt-confirm-overlay,
  :where(#tgModalOverlay),
  .info-modal-overlay,
  .tg-drilldown-overlay,
  .cal-modal-overlay,
  .dc-modal-overlay,
  .ac-modal-overlay,
  .fc-overlay,
  .wh-modal-backdrop,
  .del-overlay,
  .ua-confirm-overlay,
  .fg-modal-overlay,
  .gb-detail-overlay,
  .gb-modal-overlay,
  .gb-unsaved-overlay,
  .ddv-overlay,
  .maint-overlay,
  .rv-detail-overlay,
  .fah-detail-overlay,
  .fah-del-overlay,
  .sh-del-overlay,
  .cs-modal-backdrop,
  .fse-modal-backdrop,
  .fav-modal-backdrop,
  .oi-modal-backdrop,
  .ov-modal-backdrop,
  .ann-modal-overlay,
  .ooa-overlay,
  .wr-success-overlay,
  .sh-success-overlay,
  .success-overlay,
  :where(#successModal),
  :where(body > div:has(#count-modal-close)),
  :where(body > div:has(#mi-cancel-btn)),
  :where(body > div:has(#del-cancel-btn))
) > :is(.sub-modal,.store-org-modal,.edit-person-modal,.ue-modal,.org-add-modal,.org-move-modal,.action-modal,.pkt-confirm-modal,.modal,.info-modal,.tg-drilldown,.cal-modal,.dc-modal,.ac-modal,.fc-modal,.wh-modal,.del-modal,.ua-confirm-box,.fg-modal,.gb-detail-panel,.gb-modal,.gb-unsaved-modal,.ddv-modal,.maint-modal,.rv-detail-modal,.fah-detail-modal,.fah-del-modal,.sh-del-modal,.cs-modal,.fse-modal,.fav-modal,.oi-modal,.ov-modal,.ann-modal,.ooa-modal,.wr-success-card,.sh-success-card,.success-box, div:first-child) {
  box-sizing: border-box !important;
  min-width: 0 !important;
  min-height: 0 !important;
  max-height: var(--dialog-height) !important;
  margin-top: auto !important;
  margin-bottom: auto !important;
  flex-shrink: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
}
/* Keep close buttons and headings outside the scrolling content in split panels. */
html body :is(.sub-modal,.store-org-modal,.cal-modal,.dc-modal,.ddv-modal,.gb-detail-panel) {
  display: flex;
  flex-direction: column;
  overflow: hidden !important;
}
html body :is(.sub-modal-body,.store-org-body,.cal-modal-body,.dc-modal-body,.ddv-body,.gb-detail-scroll) {
  flex: 1 1 auto;
  min-height: 0 !important;
  overflow-y: auto !important;
  overscroll-behavior: contain;
}
html body :is(.sub-modal-hdr,.store-org-hdr,.cal-modal-header,.cal-modal-footer,.dc-modal-header,.ddv-header,.gb-detail-hdr,.gb-detail-ftr) {
  flex-shrink: 0 !important;
}
/* Actions opened from another dialog belong above that dialog. */
html body :is(.edit-person-overlay,.ue-modal-overlay,.org-add-overlay,.org-move-overlay,.action-modal-overlay,.info-modal-overlay,.gb-modal-overlay,.ann-modal-overlay,#tgModalOverlay) { z-index: 10060 !important; }
html body :is(.pkt-confirm-overlay,.del-overlay,.ua-confirm-overlay,.fg-modal-overlay,.wh-modal-backdrop,.gb-unsaved-overlay,.fah-del-overlay,.sh-del-overlay,.fc-overlay,body > div:has(#mi-cancel-btn),body > div:has(#del-cancel-btn)) { z-index: 10080 !important; }
html body .td-lightbox { z-index: 10100; }
/* Native dialogs use the browser's top layer; preserve their open/close behavior. */
html body dialog.ac-modal {
  max-height: calc(100dvh - max(1rem, env(safe-area-inset-top, 0px)) - max(1rem, env(safe-area-inset-bottom, 0px)));
  overflow-y: auto;
  box-sizing: border-box;
}
/* The report PDF viewer already has its own higher layer. */
#pdfViewerOverlay { padding: max(1rem, env(safe-area-inset-top, 0px)) 1rem max(1rem, env(safe-area-inset-bottom, 0px)) !important; box-sizing: border-box; }
#pdfViewerOverlay > div { max-height: calc(100dvh - max(1rem, env(safe-area-inset-top, 0px)) - max(1rem, env(safe-area-inset-bottom, 0px))) !important; min-height: 0; }
#pdfViewerOverlay iframe { min-height: 0; }
