html, body {
  height: 100%;
  overflow: hidden;
  width: 100%;
  max-width: 100%;
}

#app {
  height: 100%;
  min-height: 100%;
  width: 100%;
  max-width: 100vw;
  overflow: hidden;
}

.input {
  width: 100%;
  border-radius: 0.5rem;
  border: 1px solid #334155;
  background: #1c2330;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: #f1f5f9;
}
.input:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 1px #6366f1;
}

.login-password-field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.login-password-field-footer {
  display: flex;
  justify-content: flex-end;
  padding-right: 0.125rem;
}

.login-forgot-link {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.75rem;
  line-height: 1.2;
  color: #818cf8;
  cursor: pointer;
  transition: color 0.15s ease;
}

.login-forgot-link:hover {
  color: #c7d2fe;
  text-decoration: underline;
}

.btn-primary {
  border-radius: 0.5rem;
  background: #6366f1;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: white;
}
.btn-primary:hover { background: #818cf8; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-outline {
  border-radius: 0.5rem;
  border: 1px solid #475569;
  background: transparent;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  color: #e2e8f0;
}
.btn-outline:hover { border-color: #6366f1; color: white; }
.nav-btn {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  border-radius: 0.5rem;
  padding: 0.5rem 0.625rem;
  font-size: 0.875rem;
  color: #cbd5e1;
  background: transparent;
  text-align: left;
}
.nav-btn.hidden {
  display: none !important;
}
.nav-btn-icon {
  width: 1.25rem;
  flex-shrink: 0;
  text-align: center;
  opacity: 0.85;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.nav-btn-icon svg {
  width: 1rem;
  height: 1rem;
  display: block;
}
.nav-btn:hover { background: #1c2330; }
.nav-btn.active {
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.4);
}
.nav-btn--membership-locked {
  opacity: 0.55;
}
.academy-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.academy-tab-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.85;
}
.academy-tab-icon svg {
  width: 1rem;
  height: 1rem;
  display: block;
}
.tab-btn.active-tab {
  border-bottom: 2px solid #6366f1;
  color: #a5b4fc;
}
.billing-toggle-group {
  display: inline-flex;
  align-items: center;
  gap: 0.125rem;
  border-radius: 0.5rem;
  border: 1px solid #334155;
  padding: 0.125rem;
  background: #0f1117;
}
.billing-toggle-btn {
  border: none;
  border-radius: 0.375rem;
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #94a3b8;
  background: transparent;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.billing-toggle-btn:hover:not(.active) { color: #e2e8f0; }
.billing-toggle-btn.active {
  background: #6366f1;
  color: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}
.app-toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  z-index: 80;
  transform: translateX(-50%);
  border-radius: 0.75rem;
  border: 1px solid rgba(99, 102, 241, 0.45);
  background: rgba(22, 27, 34, 0.96);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: #e2e8f0;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
.phrase-card {
  border-radius: 0.75rem;
  border: 1px solid #334155;
  background: #161b22;
  padding: 1rem;
}
.phrase-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 9999px;
  padding: 0.15rem 0.55rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.35);
}
.knowledge-filter-btn.active {
  border-color: rgba(99, 102, 241, 0.5);
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
}
.card {
  border-radius: 0.75rem;
  border: 1px solid #334155;
  background: #161b22;
  padding: 1.25rem;
}
.prose-lesson p { margin-bottom: 0.75rem; line-height: 1.6; color: #cbd5e1; }
.prose-lesson strong { font-weight: 600; color: white; }
.prose-lesson em {
  font-style: italic;
  color: #c7d2fe;
  font-weight: 500;
}

/* --- App shell layout --- */
.app-layout {
  display: flex;
  flex: 1 1 auto;
  width: 100%;
  max-width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  position: relative;
  --sidebar-width: 288px;
}
.app-layout.hidden {
  display: none !important;
}

.main-column {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
  max-width: 100%;
  min-height: 0;
  overflow: hidden;
}

.main-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid #1e293b;
  padding: 1rem 1.25rem;
  flex-shrink: 0;
}
@media (min-width: 640px) {
  .main-header { padding: 1.5rem 2rem; }
}

.status-banner {
  margin: 1rem 1.25rem 0;
  border-radius: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  flex-shrink: 0;
}
@media (min-width: 640px) {
  .status-banner { margin-left: 2rem; margin-right: 2rem; }
}

.view-root {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 1.25rem;
}
@media (min-width: 640px) {
  .view-root { padding: 1.5rem 2rem; }
}

/* --- Sidebar --- */
.sidebar {
  position: relative;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  width: var(--sidebar-width);
  min-width: 220px;
  max-width: min(480px, 85vw);
  height: 100%;
  border-right: 1px solid #1e293b;
  background: #161b22;
  transition: transform 0.22s ease, margin 0.22s ease;
  z-index: 40;
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  padding: 1rem 0.875rem;
}

.sidebar-account {
  padding: 0 0.125rem;
}

.sidebar-logout {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.sidebar-chat-launcher {
  flex-shrink: 0;
  margin-top: auto;
}

.sidebar-chat-card {
  display: flex;
  width: 100%;
  gap: 0.75rem;
  border: 1px solid #334155;
  border-radius: 0.75rem;
  background: linear-gradient(145deg, #1a2030 0%, #161b22 100%);
  padding: 0.75rem;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.sidebar-chat-card:hover {
  border-color: #6366f1;
  background: linear-gradient(145deg, #1e2540 0%, #1a2030 100%);
  box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.25);
}
.sidebar-chat-card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  flex-shrink: 0;
  border-radius: 0.5rem;
  background: rgba(99, 102, 241, 0.18);
  border: 1px solid rgba(99, 102, 241, 0.35);
  color: #a5b4fc;
}
.sidebar-chat-card-icon svg {
  width: 1.125rem;
  height: 1.125rem;
}
.sidebar-chat-card-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 0.125rem;
}
.sidebar-chat-card-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #f1f5f9;
  line-height: 1.3;
}
.sidebar-chat-card-desc {
  font-size: 0.6875rem;
  line-height: 1.35;
  color: #94a3b8;
}
.sidebar-chat-card-action {
  margin-top: 0.25rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #818cf8;
}
.sidebar-chat-card:hover .sidebar-chat-card-action {
  color: #a5b4fc;
}

.chat-expanded-form {
  border-top: 1px solid #334155;
  padding-top: 0.75rem;
}

@media (min-width: 1024px) {
  .app-layout { --sidebar-width: 260px; }
}

/* Home */
.home-greeting {
  font-size: 1.5rem;
  font-weight: 700;
  color: #f8fafc;
}
.home-action-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(1, minmax(0, 1fr));
}
@media (min-width: 640px) {
  .home-action-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1024px) {
  .home-action-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.home-action-card {
  position: relative;
  border: 1px solid #334155;
  border-radius: 0.75rem;
  background: #161b22;
  padding: 1rem 1.125rem 1rem 1.625rem;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.home-action-card::before {
  content: '→';
  position: absolute;
  top: 0.75rem;
  left: 0.625rem;
  font-size: 0.8125rem;
  line-height: 1;
  color: #64748b;
  transition: color 0.15s, transform 0.15s;
}
.home-action-card:hover {
  border-color: #6366f1;
  background: #1c2330;
}
.home-action-card:hover::before {
  color: #a5b4fc;
  transform: translateX(2px);
}
.home-action-card h3 {
  font-weight: 600;
  color: #f8fafc;
}
.home-action-card p {
  margin-top: 0.375rem;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: #94a3b8;
}
.home-continue-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border: 1px solid #334155;
  border-radius: 0.625rem;
  background: #161b22;
  padding: 0.75rem 1rem;
}
.home-continue-item + .home-continue-item {
  margin-top: 0.5rem;
}

/* Skeleton loaders (tab navigation) */
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton {
  background: linear-gradient(90deg, #1c2330 25%, #283040 50%, #1c2330 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.25s ease-in-out infinite;
  border-radius: 0.375rem;
}
.skeleton-line {
  height: 0.875rem;
}
.skeleton-line-lg {
  height: 1.375rem;
  border-radius: 0.5rem;
}
.skeleton-line-xl {
  height: 2rem;
  border-radius: 0.5rem;
}
.skeleton-home-card {
  height: 5.5rem;
  border-radius: 0.75rem;
  border: 1px solid #2a3344;
}
.skeleton-stat-card {
  height: 5.5rem;
  border-radius: 0.75rem;
  border: 1px solid #2a3344;
}
.skeleton-continue-row {
  height: 3.75rem;
  border-radius: 0.625rem;
  border: 1px solid #2a3344;
}
.skeleton-academy-header {
  height: 7rem;
  border-radius: 0.75rem;
  border: 1px solid #2a3344;
}
.skeleton-course-card {
  height: 11rem;
  border-radius: 0.75rem;
  border: 1px solid #2a3344;
}
.skeleton-manager-table {
  height: 14rem;
  border-radius: 0.75rem;
  border: 1px solid #2a3344;
}
.skeleton-tabs {
  display: flex;
  gap: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #334155;
}
.skeleton-tab {
  width: 5.5rem;
  height: 1.25rem;
}
.skeleton-glossary-line {
  height: 2.5rem;
  margin-bottom: 0.5rem;
}
.skeleton-frasbank-filters {
  height: 11rem;
  border-radius: 0.75rem;
  border: 1px solid #2a3344;
}
.skeleton-action-btn {
  width: 6.5rem;
  height: 2.25rem;
  border-radius: 0.5rem;
}
.skeleton-admin-detail {
  height: 5.5rem;
  border-radius: 0.625rem;
  border: 1px solid #2a3344;
}
.skeleton-planering-day {
  height: 8.5rem;
  border-radius: 0.75rem;
  border: 1px solid #2a3344;
}

.chat-messages {
  font-size: 0.875rem;
  line-height: 1.7;
}
.chat-bubble-text {
  font-size: 0.875rem;
  line-height: 1.7;
}
.chat-bubble-text p {
  margin-bottom: 0.5rem;
}
.chat-bubble-text p:last-child {
  margin-bottom: 0;
}
.chat-msg {
  margin-bottom: 0.75rem;
  width: 100%;
}
.chat-msg-user { text-align: right; }
.chat-bubble {
  display: block;
  width: 100%;
  border-radius: 0.75rem;
  padding: 0.75rem 0.875rem;
  text-align: left;
  word-break: break-word;
}
.chat-bubble-user {
  display: inline-block;
  width: auto;
  max-width: 100%;
  background: rgba(99, 102, 241, 0.22);
  border: 1px solid rgba(99, 102, 241, 0.35);
}
.chat-bubble-assistant {
  background: #1c2330;
  border: 1px solid #334155;
}
.chat-expand-btn {
  border: 1px solid #475569;
  background: #1c2330;
  color: #cbd5e1;
  border-radius: 0.375rem;
  padding: 0.125rem 0.5rem;
  font-size: 0.875rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.chat-expand-btn:hover { border-color: #6366f1; color: #fff; }
.chat-expand-btn svg {
  width: 1rem;
  height: 1rem;
  display: block;
}

.chat-audit-context-option {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid #334155;
  border-radius: 0.5rem;
  background: #1c2330;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: #cbd5e1;
  cursor: pointer;
}
.chat-audit-context-option input {
  width: 1rem;
  height: 1rem;
  margin: 0.125rem 0 0;
  flex-shrink: 0;
}
.chat-audit-context-option--disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.chat-audit-context-option--disabled input {
  cursor: not-allowed;
}

.chat-expanded-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 55;
}
.chat-expanded-panel {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  top: auto;
  width: var(--chat-panel-width, min(400px, calc(100vw - 2rem)));
  height: var(--chat-panel-height, min(62vh, 640px));
  max-height: calc(100dvh - 2rem);
  z-index: 56;
  display: flex;
  flex-direction: column;
  background: #161b22;
  border: 1px solid #334155;
  border-radius: 0.875rem;
  padding: 1rem;
  box-shadow:
    0 16px 48px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.04);
}
.chat-panel-resizer {
  position: absolute;
  top: 0;
  left: 0;
  width: 1.25rem;
  height: 1.25rem;
  cursor: nwse-resize;
  z-index: 3;
  touch-action: none;
  border-radius: 0.875rem 0 0 0;
}
.chat-panel-resizer::after {
  content: '';
  position: absolute;
  top: 0.35rem;
  left: 0.35rem;
  width: 0.55rem;
  height: 0.55rem;
  border-top: 2px solid rgba(129, 140, 248, 0.45);
  border-left: 2px solid rgba(129, 140, 248, 0.45);
  border-radius: 2px 0 0 0;
  pointer-events: none;
}
.chat-panel-resizer:hover::after,
.chat-panel-resizer.active::after {
  border-color: rgba(129, 140, 248, 0.95);
}
@media (max-width: 767px) {
  .chat-expanded-panel {
    right: 0;
    bottom: 0;
    left: 0;
    width: 100% !important;
    height: min(78vh, 100dvh) !important;
    max-height: 90dvh;
    border-radius: 1rem 1rem 0 0;
    border-bottom: none;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.4);
  }
  .chat-panel-resizer { display: none; }
}
.chat-expanded-panel.hidden,
.chat-expanded-backdrop.hidden { display: none !important; }
.chat-expanded-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  flex-shrink: 0;
}
.chat-pdf-panel details summary { cursor: pointer; color: #94a3b8; }
.chat-pdf-panel details:not([open]) .chat-pdf-details-body { display: none; }

.app-loading {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 17, 23, 0.88);
}
.app-loading.hidden { display: none !important; }
.app-loading-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-radius: 0.75rem;
  border: 1px solid #334155;
  background: #161b22;
  color: #e2e8f0;
  font-size: 0.9375rem;
}

.prose-lesson p { margin-bottom: 0.75rem; line-height: 1.7; color: #cbd5e1; }
.prose-lesson strong { font-weight: 600; color: white; }
.prose-lesson em {
  font-style: italic;
  color: #c7d2fe;
  font-weight: 500;
}
.prose-lesson .lesson-list {
  margin: 0.5rem 0 0.75rem 1.25rem;
  list-style: disc;
  color: #cbd5e1;
}
.prose-lesson .lesson-list li { margin-bottom: 0.35rem; line-height: 1.6; }
.prose-lesson .lesson-math {
  font-weight: 600;
  color: #e0e7ff;
  font-size: 1.02em;
}
.prose-lesson .lesson-formula {
  margin: 0.75rem 0;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  background: #121820;
  border: 1px solid #334155;
  overflow-x: auto;
  text-align: center;
}
.prose-lesson .katex {
  color: #e0e7ff;
  font-size: 1.05em;
}
.prose-lesson .katex-display {
  margin: 0.5rem 0;
}

.lesson-page {
  width: 100%;
}
.lesson-xp-bar {
  margin-bottom: 1rem;
  padding: 0.625rem 0.875rem;
  border-radius: 0.625rem;
  border: 1px solid #334155;
  background: rgba(22, 27, 34, 0.85);
}
.lesson-xp-bar-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.75rem;
  color: #94a3b8;
}
.lesson-xp-bar-track {
  margin-top: 0.5rem;
  height: 0.375rem;
  border-radius: 9999px;
  background: #1e293b;
  overflow: hidden;
}
.lesson-xp-bar-fill {
  height: 100%;
  border-radius: 9999px;
  background: linear-gradient(90deg, #6366f1, #818cf8);
  transition: width 0.35s ease;
}
.lesson-prose {
  padding: 1.25rem 1.5rem;
  font-size: 1.0625rem;
}
.lesson-prose p {
  margin-bottom: 1rem;
  line-height: 1.8;
}
.lesson-scenario-body {
  font-size: 1rem;
  line-height: 1.75;
}
.lesson-scenario-body p {
  margin-bottom: 0.75rem;
}
.lesson-quiz-option {
  padding: 0.875rem 1rem;
  border-radius: 0.625rem;
  border: 1px solid #334155;
  background: #161b22;
  font-size: 0.9375rem;
  line-height: 1.65;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.lesson-quiz-option:hover {
  border-color: #6366f1;
  background: #1a2030;
}
.practice-quiz-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 9999px;
  padding: 0.2rem 0.65rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.practice-quiz-badge-category {
  background: #1e293b;
  color: #cbd5e1;
  border: 1px solid #334155;
}
.practice-quiz-badge-easy {
  background: rgba(16, 185, 129, 0.12);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.35);
}
.practice-quiz-badge-medium {
  background: rgba(245, 158, 11, 0.12);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.35);
}
.practice-quiz-badge-hard {
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.35);
}
.lesson-schematic-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
}
.lesson-schematic-step {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.875rem;
  border-radius: 0.625rem;
  border: 1px solid #334155;
  background: #121820;
  font-size: 0.875rem;
}
.lesson-schematic-step strong {
  color: #f1f5f9;
  font-size: 0.9375rem;
}
.lesson-schematic-step span {
  color: #94a3b8;
  line-height: 1.5;
}
.lesson-kfactor .lesson-formula-plain {
  font-size: 1.125rem;
}

.audit-history-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: min(28rem, 55vh);
  overflow-y: auto;
}
.audit-history-item {
  padding: 0.875rem 1rem;
  border-radius: 0.625rem;
  border: 1px solid #334155;
  background: #121820;
  transition: border-color 0.15s, background 0.15s;
}
.audit-history-item:hover {
  border-color: #6366f1;
  background: #1a2030;
}
.audit-history-badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.audit-history-badge--pass {
  color: #6ee7b7;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.35);
}
.audit-history-badge--fail {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.audit-brist-group-title,
.audit-brist-group-summary {
  font-size: 0.95rem;
  font-weight: 600;
}

.audit-brist-group-summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0;
  user-select: none;
}

.audit-brist-group-summary::-webkit-details-marker {
  display: none;
}

.audit-brist-group-summary::before {
  content: '▸';
  display: inline-block;
  width: 0.75rem;
  color: #94a3b8;
  transition: transform 0.15s ease;
}

.audit-brist-group[open] > .audit-brist-group-summary::before {
  transform: rotate(90deg);
}

.audit-brist-group-body {
  margin-top: 0.5rem;
  padding-left: 0.25rem;
}

.audit-brist-group--technical .audit-brist-group-summary {
  color: #fca5a5;
}

.audit-brist-group--administration .audit-brist-group-summary {
  color: #fcd34d;
}

.audit-brist-group--classification .audit-brist-group-summary {
  color: #c4b5fd;
}

.audit-brist-note--admin {
  border-color: rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.08);
  color: #fde68a;
}

.audit-brist-note--technical {
  border-color: rgba(248, 113, 113, 0.35);
  background: rgba(248, 113, 113, 0.08);
  color: #fecaca;
}

.audit-brist-note--classification {
  border-color: rgba(167, 139, 250, 0.35);
  background: rgba(167, 139, 250, 0.1);
  color: #ddd6fe;
}

.audit-upload-form--compact {
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.audit-verdict {
  border-radius: 0.75rem;
  border: 1px solid;
  padding: 0.9rem 1.1rem;
}

.audit-verdict--fail {
  border-color: rgba(248, 113, 113, 0.45);
  background: rgba(127, 29, 29, 0.28);
}

.audit-verdict--pass {
  border-color: rgba(52, 211, 153, 0.4);
  background: rgba(6, 78, 59, 0.28);
}

.audit-verdict-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.audit-verdict--fail .audit-verdict-title {
  color: #fca5a5;
}

.audit-verdict--pass .audit-verdict-title {
  color: #6ee7b7;
}

.audit-verdict-sub {
  margin: 0.35rem 0 0;
  font-size: 0.875rem;
  color: #94a3b8;
}

.audit-verdict-hint {
  margin: 0.55rem 0 0;
  padding-top: 0.55rem;
  border-top: 1px solid rgba(148, 163, 184, 0.18);
  font-size: 0.8125rem;
  line-height: 1.45;
  color: #94a3b8;
  font-weight: 400;
}

.audit-count-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.audit-count-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border-radius: 0.5rem;
  border: 1px solid #334155;
  background: #161b22;
  padding: 0.35rem 0.7rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #cbd5e1;
}

button.audit-count-chip {
  cursor: default;
}

button.audit-count-chip:disabled {
  cursor: default;
  opacity: 1;
}

button.audit-count-chip--jump {
  cursor: pointer;
  transition: border-color 0.15s ease, filter 0.15s ease;
}

button.audit-count-chip--jump:hover {
  filter: brightness(1.12);
}

.audit-count-chip strong {
  font-weight: 700;
  color: inherit;
}

.audit-count-chip--total {
  border-color: #475569;
  color: #e2e8f0;
}

.audit-count-chip--total strong {
  color: #f8fafc;
}

.audit-count-chip--technical {
  border-color: rgba(248, 113, 113, 0.35);
  background: rgba(248, 113, 113, 0.08);
  color: #fca5a5;
}

.audit-count-chip--administration {
  border-color: rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.08);
  color: #fcd34d;
}

.audit-count-chip--classification {
  border-color: rgba(167, 139, 250, 0.35);
  background: rgba(167, 139, 250, 0.1);
  color: #c4b5fd;
}

.audit-brist-card {
  margin-top: 0.75rem;
  border-radius: 0.75rem;
  border: 1px solid #334155;
  background: #161b22;
  padding: 0.9rem 1rem;
}

.audit-brist-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.audit-brist-card-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: #f8fafc;
  line-height: 1.35;
}

.audit-brist-card-idx {
  flex-shrink: 0;
  min-width: 1.5rem;
  text-align: center;
  border-radius: 0.4rem;
  background: #1e293b;
  color: #94a3b8;
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1.5rem;
  padding: 0 0.4rem;
}

.audit-brist-error {
  margin: 0.55rem 0 0;
  font-size: 0.875rem;
  line-height: 1.45;
  color: #cbd5e1;
}

.audit-brist-fix {
  margin: 0.65rem 0 0;
  padding-top: 0.65rem;
  border-top: 1px solid #1e293b;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: #94a3b8;
}

.audit-empty {
  padding: 1.25rem 1.35rem;
}

.audit-empty-header {
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
}

.audit-empty-icon {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.65rem;
  border: 1px solid rgba(99, 102, 241, 0.35);
  background: rgba(99, 102, 241, 0.12);
  color: #a5b4fc;
}

.audit-empty-icon svg {
  width: 1.25rem;
  height: 1.25rem;
}

.audit-empty-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.audit-empty-tag {
  display: inline-flex;
  align-items: center;
  border-radius: 0.5rem;
  padding: 0.3rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid transparent;
}

.audit-empty-tag--technical {
  border-color: rgba(248, 113, 113, 0.35);
  background: rgba(248, 113, 113, 0.08);
  color: #fca5a5;
}

.audit-empty-tag--administration {
  border-color: rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.08);
  color: #fcd34d;
}

.audit-empty-tag--classification {
  border-color: rgba(167, 139, 250, 0.35);
  background: rgba(167, 139, 250, 0.1);
  color: #c4b5fd;
}

.audit-empty-hint {
  margin-top: 0.9rem;
  padding-top: 0.85rem;
  border-top: 1px solid #1e293b;
  font-size: 0.75rem;
  line-height: 1.45;
  color: #64748b;
}

.audit-protocol-guide > summary {
  list-style: none;
}

.audit-protocol-guide > summary::-webkit-details-marker {
  display: none;
}

.audit-protocol-guide > summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 0.4rem;
  color: #94a3b8;
  transition: transform 0.15s ease;
}

.audit-protocol-guide[open] > summary::before {
  transform: rotate(90deg);
}

.sidebar-resizer {
  position: absolute;
  top: 0;
  right: -3px;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  z-index: 2;
  touch-action: none;
}
.sidebar-resizer:hover,
.sidebar-resizer.active {
  background: rgba(99, 102, 241, 0.35);
}

.sidebar-collapse-btn,
.sidebar-expand-btn,
.sidebar-mobile-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #475569;
  background: #1c2330;
  color: #cbd5e1;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.sidebar-collapse-btn:hover,
.sidebar-expand-btn:hover,
.sidebar-mobile-btn:hover {
  border-color: #6366f1;
  color: #fff;
}
.sidebar-collapse-btn svg,
.sidebar-expand-btn svg,
.sidebar-mobile-btn svg {
  width: 1rem;
  height: 1rem;
}

.sidebar-collapse-btn {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 1.75rem;
  height: 1.75rem;
  z-index: 3;
}

.sidebar-expand-btn {
  position: fixed;
  top: 0.75rem;
  left: 0;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 0 0.5rem 0.5rem 0;
  border-left: none;
  z-index: 35;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.sidebar-mobile-btn {
  width: 2.25rem;
  height: 2.25rem;
  flex-shrink: 0;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 30;
}

/* Collapsed state */
.app-layout.sidebar-collapsed .sidebar {
  transform: translateX(-100%);
  width: 0 !important;
  min-width: 0 !important;
  overflow: hidden;
  border-right: none;
  pointer-events: none;
}
.app-layout.sidebar-collapsed .sidebar-resizer {
  display: none;
}
.app-layout.sidebar-collapsed .sidebar-expand-btn {
  opacity: 1;
  pointer-events: auto;
}

/* Mobile: overlay sidebar */
@media (max-width: 767px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    max-width: min(320px, 88vw);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.45);
  }
  .sidebar-resizer { display: none; }
  .sidebar-mobile-btn { display: inline-flex; }

  /* Desktop collapse tab — hamburger in header is enough on mobile */
  .sidebar-expand-btn {
    display: none !important;
  }

  .main-header {
    padding: 0.75rem 1rem;
    gap: 0.75rem;
  }

  .view-root {
    padding: 1rem;
  }

  .app-layout:not(.sidebar-collapsed) .sidebar-backdrop {
    display: block;
  }
  .app-layout.sidebar-collapsed .sidebar-backdrop {
    display: none;
  }
}

@media (min-width: 768px) {
  .sidebar-mobile-btn { display: none; }
  .sidebar-backdrop { display: none !important; }
}

/* Loading & file picker */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  display: inline-block;
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid #475569;
  border-top-color: #6366f1;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
.spinner-sm { width: 1rem; height: 1rem; border-width: 2px; }
.loading-inline,
.loading-panel {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  border-radius: 0.75rem;
  border: 1px solid #334155;
  background: #161b22;
  color: #cbd5e1;
  font-size: 0.875rem;
}
.loading-panel { margin-top: 1rem; }

.audit-progress {
  padding: 1.15rem 1.25rem;
}

.audit-progress-track {
  position: relative;
  height: 0.35rem;
  overflow: hidden;
  border-radius: 999px;
  background: #1e293b;
}

.audit-progress-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 40%;
  border-radius: 999px;
  background: linear-gradient(90deg, #6366f1, #818cf8);
  animation: audit-progress-slide 1.4s ease-in-out infinite;
}

@keyframes audit-progress-slide {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}

.audit-progress-stage {
  margin: 0.9rem 0 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: #e2e8f0;
}

.audit-progress-meta {
  margin: 0.35rem 0 0;
  font-size: 0.8125rem;
  color: #94a3b8;
}

.audit-progress-hint {
  margin: 0.65rem 0 0;
  padding-top: 0.65rem;
  border-top: 1px solid #1e293b;
  font-size: 0.75rem;
  color: #64748b;
}

.chat-loading {
  padding: 0;
  border: none;
  background: transparent;
}
.chat-loading.hidden { display: none; }

.chat-progress {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.8rem;
  border-radius: 0.65rem;
  border: 1px solid rgba(99, 102, 241, 0.3);
  background: rgba(99, 102, 241, 0.1);
}

.chat-progress-track {
  position: relative;
  flex: 1 1 auto;
  min-width: 4rem;
  height: 0.28rem;
  overflow: hidden;
  border-radius: 0.5rem;
  background: rgba(30, 41, 59, 0.9);
}

.chat-progress-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 42%;
  border-radius: 0.5rem;
  background: linear-gradient(90deg, #6366f1, #a5b4fc);
  animation: audit-progress-slide 1.4s ease-in-out infinite;
}

.chat-progress-copy {
  flex: 0 1 auto;
  min-width: 0;
  text-align: right;
}

.chat-progress-stage {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: #c7d2fe;
  white-space: nowrap;
}

.chat-progress-meta {
  margin: 0.15rem 0 0;
  font-size: 0.6875rem;
  color: #94a3b8;
  white-space: nowrap;
}

.file-picker {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-radius: 0.75rem;
  border: 1px dashed #475569;
  background: #1c2330;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.file-picker:hover { border-color: #6366f1; background: #1e2433; }
.file-picker.file-picker--selected { border-style: solid; border-color: #6366f1; }
.file-picker.file-picker--dragover {
  border-style: solid;
  border-color: #818cf8;
  background: #232b45;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}
.file-picker.file-picker--invalid {
  border-style: solid;
  border-color: #ef4444;
  background: #2a1a1c;
}
.file-picker.file-picker--invalid .file-picker-name { color: #fca5a5; }
.file-picker-icon { flex-shrink: 0; width: 2.25rem; height: 2.25rem; }
.file-picker-icon svg { width: 100%; height: 100%; }
.file-picker-body { min-width: 0; flex: 1; }
.file-picker-name {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-picker-hint { display: block; font-size: 0.75rem; color: #64748b; margin-top: 0.125rem; }

.field-grid {
  display: grid;
  gap: 0.75rem;
}
.field-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 767px) {
  .field-grid.cols-2,
  .field-grid.cols-3 { grid-template-columns: 1fr; }
}
.field-label { display: block; font-size: 0.75rem; color: #94a3b8; margin-bottom: 0.25rem; }
.form-section-title { font-size: 1rem; font-weight: 600; margin-top: 1.25rem; margin-bottom: 0.5rem; }
.form-section-caption { font-size: 0.75rem; color: #64748b; margin-bottom: 0.75rem; }
.agg-card {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 0.75rem;
  border: 1px solid #334155;
  background: #121820;
}

/* --- Protocol simulation sheet (Aggregatsblad) --- */
.protocol-sheet-scroll {
  overflow-x: auto;
}
.protocol-cell .protocol-input,
.protocol-field-wrap .protocol-input {
  border-radius: 0;
}
.protocol-field-wrap textarea.protocol-input {
  min-height: 2.5rem;
}
.agg-card summary { cursor: pointer; font-weight: 600; list-style: none; }
.agg-card summary::-webkit-details-marker { display: none; }

/* --- Injustering --- */
.inj-table input.input,
.inj-table select.input {
  min-width: 6rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.8125rem;
}

.inj-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  padding: 0.15rem 0.55rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.inj-status--ok {
  background: rgba(6, 78, 59, 0.35);
  color: #6ee7b7;
  box-shadow: inset 0 0 0 1px rgba(16, 185, 129, 0.35);
}
.inj-status--fail {
  background: rgba(127, 29, 29, 0.35);
  color: #fca5a5;
  box-shadow: inset 0 0 0 1px rgba(239, 68, 68, 0.35);
}
.inj-status--na {
  color: #94a3b8;
}

.inj-summary-row td {
  font-variant-numeric: tabular-nums;
}

/* --- Spårgasmätning --- */
.spar-panel--fran {
  box-shadow: inset 0 0 0 1px rgba(16, 185, 129, 0.28);
}
.spar-panel--till {
  box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.28);
}
.spar-result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin-top: 0.25rem;
}
.spar-result-grid .label,
.spar-n .label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #94a3b8;
}
.spar-result-grid .value,
.spar-n .value {
  margin-top: 0.15rem;
  font-size: 0.95rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: #f8fafc;
}
.spar-n {
  border-radius: 0.6rem;
  padding: 0.85rem 1rem;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(15, 23, 42, 0.45);
}
.spar-n--fran {
  border-color: rgba(16, 185, 129, 0.35);
  background: rgba(6, 78, 59, 0.22);
}
.spar-n--till {
  border-color: rgba(56, 189, 248, 0.35);
  background: rgba(12, 74, 110, 0.28);
}

/* Fastigheter */
.fastigheter-clickable {
  border: 1px solid #334155;
  border-radius: 0.75rem;
  background: #161b22;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.fastigheter-clickable:hover {
  border-color: #6366f1;
  background: #1c2330;
  box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.15);
}
.fastigheter-event {
  border: 1px solid #334155;
  border-radius: 0.75rem;
  background: #161b22;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.fastigheter-event:hover,
.fastigheter-event.is-open {
  border-color: #6366f1;
  background: #1c2330;
}
.fastigheter-event-preview {
  margin-top: 0.35rem;
  font-size: 0.75rem;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fastigheter-doc-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  border: 1px solid #1e293b;
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: #0f1419;
}
.fastigheter-upload-box {
  margin-top: 0.25rem;
  padding: 0.85rem;
  border-radius: 0.65rem;
  border: 1px solid #334155;
  background: #0f1419;
}
.fastigheter-event-body .fastigheter-upload-box {
  margin-top: 0.5rem;
}
.portal-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.portal-tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
  color: #c7d2fe;
  background: rgba(99, 102, 241, 0.22);
  border: 1px solid rgba(129, 140, 248, 0.35);
}
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
