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

:root {
  --menu-width-expanded: 246px;
  --menu-width-collapsed: 72px;
  --menu-width: var(--menu-width-expanded);
  --clr-bg: #f4f6f9;
  --clr-surface: #ffffff;
  --clr-surface-alt: #eef2f7;
  --clr-elevated: #ffffff;
  --clr-primary: #2563eb;
  --clr-primary-hover: #1d4ed8;
  --clr-text: #1e293b;
  --clr-muted: #64748b;
  --clr-text-muted: #64748b;
  --clr-border: #e2e8f0;
  --clr-active: #eff6ff;
  --clr-hover-soft: #f3f4f6;
  --clr-input-bg: #ffffff;
  --clr-success-bg: #f0fdf4;
  --clr-success-border: #86efac;
  --clr-success-text: #166534;
  --clr-error-bg: #fef2f2;
  --clr-error-border: #fca5a5;
  --clr-error-text: #991b1b;
  --clr-warning-bg: #fffbeb;
  --clr-warning-border: #f59e0b;
  --clr-warning-border-strong: #d97706;
  --clr-warning-text: #b45309;
  --clr-info-bg: #dbeafe;
  --clr-info-text: #1e40af;
  --clr-shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
  --radius: 8px;
}

:root[data-theme="dark"] {
  --clr-bg: #0f172a;
  --clr-surface: #111827;
  --clr-surface-alt: #1f2937;
  --clr-elevated: #172033;
  --clr-primary: #60a5fa;
  --clr-primary-hover: #93c5fd;
  --clr-text: #e5eefb;
  --clr-muted: #94a3b8;
  --clr-text-muted: #94a3b8;
  --clr-border: #334155;
  --clr-active: rgba(96, 165, 250, 0.15);
  --clr-hover-soft: #223047;
  --clr-input-bg: #0f172a;
  --clr-success-bg: rgba(22, 101, 52, 0.24);
  --clr-success-border: #4ade80;
  --clr-success-text: #bbf7d0;
  --clr-error-bg: rgba(153, 27, 27, 0.28);
  --clr-error-border: #f87171;
  --clr-error-text: #fecaca;
  --clr-warning-bg: rgba(180, 83, 9, 0.22);
  --clr-warning-border: #f59e0b;
  --clr-warning-border-strong: #fbbf24;
  --clr-warning-text: #fde68a;
  --clr-info-bg: rgba(30, 64, 175, 0.28);
  --clr-info-text: #bfdbfe;
  --clr-shadow: 0 20px 48px rgba(2, 6, 23, 0.45);
}

html {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--clr-bg);
  color: var(--clr-text);
  line-height: 1.6;
  padding: 2rem;
  width: 100%;
  max-width: none;
  margin: 0 auto;
}

body.auth-authenticated {
  min-height: 100vh;
  padding: 1rem 1rem 1rem calc(var(--menu-width) + 1rem);
}

body.auth-authenticated.menu-collapsed {
  --menu-width: var(--menu-width-collapsed);
}

body.auth-guest {
  min-height: 100vh;
}

a {
  color: inherit;
}

header {
  margin-bottom: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 1rem;
}

body.auth-authenticated header {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--menu-width);
  border-right: 1px solid var(--clr-border);
  background: var(--clr-surface);
  box-shadow: 12px 0 28px color-mix(in srgb, var(--clr-shadow), transparent 65%);
  z-index: 120;
  padding: 0.75rem 0.5rem;
}

#header-divider {
  margin: 0 0 0.85rem;
  border: none;
  border-top: 1px solid var(--clr-border);
}

body.auth-authenticated #header-divider {
  display: none;
}

#header-actions {
  display: flex;
  align-items: stretch;
  justify-content: flex-start;
  gap: 0.5rem;
  flex-wrap: nowrap;
  flex-direction: column;
  width: 100%;
  height: 100%;
}

#menu-brand-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.45rem;
  width: 100%;
}

#app-logo-placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  min-height: 30px;
  padding: 0 0.5rem;
  border: 1px dashed var(--clr-border);
  border-radius: 8px;
  background: color-mix(in srgb, var(--clr-primary), transparent 92%);
  color: var(--clr-primary);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.app-page-title {
  margin: 0 0 0.85rem;
  font-size: clamp(1.25rem, 1.8vw, 1.6rem);
  line-height: 1.15;
  font-weight: 700;
  color: var(--clr-text);
}

#app-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 0 0.85rem;
}

#app-top-row .app-page-title {
  margin: 0;
  margin-right: auto;
}

#btn-menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  min-width: 30px;
  min-height: 30px;
  height: 30px;
  padding: 0;
}

.menu-arrow-icon {
  display: inline-flex;
  width: 14px;
  height: 14px;
}

.menu-arrow-icon svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

body.auth-authenticated.menu-collapsed .menu-arrow-icon svg {
  transform: rotate(180deg);
}

#theme-toggle {
  display: inline-flex;
  position: relative;
  align-items: center;
  justify-content: flex-start;
  gap: 0.5rem;
  min-height: 38px;
  height: 38px;
  padding: 0.35rem 0.55rem;
  background: transparent;
  color: var(--clr-text);
  border: none;
  border-radius: 0;
  box-shadow: none;
  font-size: 0.84rem;
  font-weight: 600;
  font-family: inherit;
  line-height: 1;
  white-space: nowrap;
  width: 100%;
}

#theme-toggle:hover,
#theme-toggle:focus-visible {
  background: var(--clr-primary);
  color: #fff;
  border-color: var(--clr-primary);
}

#theme-toggle .theme-toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

#theme-toggle .theme-toggle-icon::before {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, #fbbf24, #f97316);
  box-shadow: inset -0.13rem -0.13rem 0 0 rgba(255, 255, 255, 0.5);
}

:root[data-theme="dark"] #theme-toggle .theme-toggle-icon::before {
  background: linear-gradient(135deg, #bfdbfe, #60a5fa);
  box-shadow: inset -0.13rem -0.13rem 0 0 rgba(15, 23, 42, 0.42);
}

/* ---------- Navigation Menu ---------- */
#main-nav {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  flex-direction: column;
  flex-wrap: nowrap;
}

#auth-controls {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

#header-auth-slot {
  display: flex;
  align-items: stretch;
  margin-top: 0.2rem;
  width: 100%;
}

#auth-center-slot {
  width: 100%;
}

#auth-user {
  font-size: 0.85rem;
  font-weight: 600;
  margin-right: 0.2rem;
}

#auth-controls input {
  height: 38px;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  background: var(--clr-input-bg);
  color: var(--clr-text);
  font-size: 0.88rem;
}

.auth-input-label {
  width: 100%;
  margin-bottom: -0.35rem;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--clr-muted);
}

#auth-inline-error {
  width: 100%;
  font-size: 0.84rem;
  color: var(--clr-error-text);
  border: 1px solid var(--clr-error-border);
  background: var(--clr-error-bg);
  border-radius: var(--radius);
  padding: 0.45rem 0.6rem;
  line-height: 1.35;
}

#auth-first-name.auth-input-error,
#auth-surname.auth-input-error,
#auth-email.auth-input-error,
#auth-password.auth-input-error {
  border-color: var(--clr-error-border);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--clr-error-border), transparent 65%);
}

#auth-email {
  width: 180px;
}

#auth-password {
  width: 150px;
}

#btn-auth-submit,
#btn-auth-logout {
  min-height: 38px;
  padding: 0.45rem 0.9rem;
  font-size: 0.88rem;
}

#auth-gate {
  min-height: calc(100vh - 8rem);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 0;
}

#auth-gate-card {
  width: min(100%, 460px);
  padding: 2.25rem;
  border: 1px solid var(--clr-border);
  border-radius: 20px;
  background:
    radial-gradient(circle at top right, color-mix(in srgb, var(--clr-primary), transparent 86%), transparent 45%),
    var(--clr-surface);
  box-shadow: var(--clr-shadow);
}

#auth-gate-eyebrow {
  margin-bottom: 0.65rem;
  color: var(--clr-primary);
  font-size: clamp(1.9rem, 3vw, 2.4rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: 0;
  text-transform: none;
}

#auth-gate-title {
  margin-bottom: 0.45rem;
  font-size: clamp(1.9rem, 3vw, 2.4rem);
  line-height: 1.1;
}

#auth-gate-copy {
  margin-bottom: 1.5rem;
  color: var(--clr-muted);
}

body.auth-guest #main-nav,
body.auth-guest #header-divider,
body.auth-guest #btn-menu-toggle,
body.auth-guest #menu-brand-row,
body.auth-guest #app-shell,
body.auth-guest #auth-user,
body.auth-guest #btn-auth-logout,
body.auth-guest #header-auth-slot,
body.auth-guest #top-profile-wrap {
  display: none !important;
}

body.auth-authenticated #header-auth-slot #auth-controls {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
}

body.auth-authenticated #header-auth-slot .auth-input-label {
  display: none;
}

body.auth-authenticated.menu-collapsed #app-logo-placeholder {
  flex: 0 0 34px;
  width: 34px;
  min-width: 34px;
  padding: 0;
  font-size: 0.65rem;
}

body.auth-authenticated.menu-collapsed #theme-toggle {
  width: 44px;
  min-width: 44px;
  padding: 0;
  justify-content: center;
  margin: 0 auto;
}

body.auth-authenticated.menu-collapsed #theme-toggle-label,
body.auth-authenticated.menu-collapsed .auth-btn-label {
  display: none;
}

body.auth-authenticated.menu-collapsed #btn-auth-logout {
  width: 44px;
  min-width: 44px;
  padding: 0;
  justify-content: center;
  margin: 0 auto;
}

body.auth-authenticated.menu-collapsed #btn-auth-logout .auth-btn-icon {
  margin-right: 0;
}

#btn-auth-logout {
  display: inline-flex;
  position: relative;
  align-items: center;
  justify-content: flex-start;
  gap: 0.55rem;
  background: transparent;
  border: none;
  border-radius: 0;
  width: 100%;
  min-height: 44px;
  height: 44px;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
}

#btn-auth-logout:hover,
#btn-auth-logout:focus-visible {
  background: var(--clr-primary);
  color: #fff;
  border-color: var(--clr-primary);
}

.auth-btn-icon {
  display: inline-flex;
  width: 16px;
  height: 16px;
}

.auth-btn-icon svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

#top-profile-wrap {
  position: relative;
  margin-left: 0;
  z-index: 220;
}

#project-switcher-wrap {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 0;
  margin-left: 0;
}

#project-switcher-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  padding: 0.3rem;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius, 0.6rem);
  background: var(--clr-surface);
  box-shadow: var(--clr-shadow);
}

.project-switcher-field {
  position: relative;
  min-width: 0;
}

.project-switcher-field-label {
  position: absolute;
  top: -0.45rem;
  left: 0.5rem;
  font-size: 0.66rem;
  line-height: 1;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #fff;
  background: var(--clr-primary);
  border-radius: 999px;
  padding: 0.2rem 0.42rem;
  pointer-events: none;
  z-index: 3;
}

#project-switcher-client-select,
#project-switcher-project-select {
  min-width: 170px;
  max-width: 240px;
  min-height: 34px;
  height: 34px;
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  background: var(--clr-input-bg);
  color: var(--clr-text);
  font-size: 0.86rem;
  position: relative;
  z-index: 1;
}

#project-switcher-hint {
  display: none;
}

#project-switcher-wrap.no-access #project-switcher-fields {
  border-color: var(--clr-warning, #f59e0b);
  background: color-mix(in srgb, var(--clr-warning, #f59e0b), transparent 94%);
}

#project-switcher-wrap.no-access #project-switcher-client-select,
#project-switcher-wrap.no-access #project-switcher-project-select {
  border-color: var(--clr-warning, #f59e0b);
  background: color-mix(in srgb, var(--clr-warning, #f59e0b), transparent 90%);
}

#project-switcher-wrap.no-access #project-switcher-hint {
  color: var(--clr-warning, #b45309);
}

#btn-profile-menu {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid var(--clr-border);
  background: var(--clr-surface);
  color: var(--clr-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  box-shadow: var(--clr-shadow);
  padding: 0;
}

#profile-menu {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  min-width: 220px;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  background: var(--clr-surface);
  box-shadow: var(--clr-shadow);
  padding: 0.45rem 0.6rem;
}

#profile-name,
#profile-email,
#profile-role {
  font-size: 0.85rem;
  color: var(--clr-text);
  white-space: nowrap;
  line-height: 1.35;
}

#profile-name {
  font-weight: 700;
}

#profile-email {
  color: var(--clr-muted);
  margin-top: 0.1rem;
}

#profile-role {
  margin-top: 0.35rem;
}

#btn-profile-edit {
  margin-top: 0.5rem;
  width: 100%;
  min-height: 34px;
  padding: 0.35rem 0.55rem;
  font-size: 0.84rem;
}

#btn-profile-logout {
  margin-top: 0.35rem;
  width: 100%;
  min-height: 34px;
  padding: 0.35rem 0.55rem;
  font-size: 0.84rem;
}

.profile-menu-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.profile-action-icon {
  display: inline-flex;
  width: 16px;
  height: 16px;
}

.profile-action-icon svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

#profile-edit-modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: grid;
  place-items: center;
}

#profile-edit-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}

#profile-edit-card {
  position: relative;
  width: min(92vw, 420px);
  border: 1px solid var(--clr-border);
  border-radius: 14px;
  background: var(--clr-surface);
  box-shadow: var(--clr-shadow);
  padding: 1rem;
  display: grid;
  gap: 0.45rem;
}

#profile-edit-title {
  margin: 0 0 0.2rem;
  font-size: 1.1rem;
}

#profile-edit-card label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--clr-muted);
}

#profile-edit-card input {
  width: 100%;
  min-height: 38px;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  background: var(--clr-input-bg);
  color: var(--clr-text);
}

#profile-edit-error {
  font-size: 0.84rem;
  color: var(--clr-error-text);
  border: 1px solid var(--clr-error-border);
  background: var(--clr-error-bg);
  border-radius: var(--radius);
  padding: 0.4rem 0.55rem;
}

#profile-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.3rem;
}

/* Invalid Parents Modal */
#invalid-parents-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(15, 23, 42, 0.45);
}

#invalid-parents-modal {
  position: fixed;
  inset: 0;
  z-index: 501;
  display: grid;
  place-items: center;
  pointer-events: none;
}

#invalid-parents-modal.hidden {
  display: none;
}

#invalid-parents-modal-backdrop.hidden {
  display: none;
}

#invalid-parents-modal .modal-content {
  pointer-events: auto;
  width: min(94vw, 760px);
  max-height: 75vh;
  border: 1px solid var(--clr-border);
  border-radius: 12px;
  background: var(--clr-surface);
  box-shadow: var(--clr-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#invalid-parents-modal .modal-header {
  padding: 1rem;
  border-bottom: 1px solid var(--clr-border);
  flex-shrink: 0;
}

#invalid-parents-modal-title {
  margin: 0;
  font-size: 1.1rem;
}

#invalid-parents-modal .modal-body {
  padding: 1rem;
  overflow-y: auto;
  flex: 1;
  word-break: break-word;
}

#invalid-parents-count-message {
  margin: 0 0 0.65rem;
  font-weight: 600;
}

.invalid-parents-help-list {
  margin: 1em 0;
}

.invalid-parents-list-title {
  font-weight: 700;
  margin-top: 1em;
  margin-bottom: 0.5em;
}

#invalid-parents-list-wrap {
  border: 1px solid var(--clr-border);
  border-radius: 8px;
  background: var(--clr-input-bg);
  max-height: 320px;
  overflow-y: auto;
  padding: 0.35rem 0.65rem;
}

#invalid-parents-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

#invalid-parents-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--clr-border);
  white-space: normal;
  overflow-wrap: anywhere;
}

#invalid-parents-list li:last-child {
  border-bottom: 0;
}

#invalid-parents-modal .modal-footer {
  padding: 1rem;
  border-top: 1px solid var(--clr-border);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-shrink: 0;
}

body.auth-guest header {
  justify-content: space-between;
  align-items: flex-start;
}

body.auth-guest #header-actions {
  align-items: flex-start;
  justify-content: space-between;
}

body.auth-guest #theme-toggle {
  width: auto;
  min-width: 0;
  min-height: 34px;
  height: 34px;
  padding: 0.25rem 0.45rem;
  font-size: 0.8rem;
  gap: 0.4rem;
}

body.auth-guest #auth-center-slot #auth-controls {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.8rem;
}

body.auth-guest #auth-center-slot #auth-controls input,
body.auth-guest #auth-center-slot #auth-controls button {
  width: 100%;
}

body.auth-guest #auth-center-slot #auth-email,
body.auth-guest #auth-center-slot #auth-password {
  width: 100%;
  height: 46px;
  padding: 0.7rem 0.85rem;
  font-size: 0.95rem;
}

body.auth-guest #auth-center-slot #btn-auth-submit {
  min-height: 46px;
  background: var(--clr-primary);
  color: #fff;
}

body.auth-guest #auth-center-slot #btn-auth-submit:hover {
  background: var(--clr-primary-hover);
}

body.auth-authenticated #auth-gate {
  display: none;
}

body.auth-initializing #auth-gate,
body.auth-initializing #app-shell {
  display: none !important;
}

#page-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--clr-bg);
  z-index: 9999;
  opacity: 1;
  transition: opacity 0.3s ease;
}

body.auth-initializing #page-loader {
  opacity: 1;
}

body:not(.auth-initializing) #page-loader {
  opacity: 0;
  pointer-events: none;
}

.loader-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--clr-border);
  border-top-color: var(--clr-primary);
  border-radius: 50%;
  animation: loader-spin 0.8s linear infinite;
}

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

.nav-item {
  position: relative;
  display: flex;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.65rem;
  background: transparent;
  color: var(--clr-text);
  border: none;
  padding: 0.55rem 0.65rem;
  width: 100%;
  min-height: 44px;
  height: 44px;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  line-height: 1;
  border-radius: 0;
  text-decoration: none;
  white-space: nowrap;
}

.nav-item.has-submenu > .nav-btn::after {
  content: "";
  margin-left: auto;
  width: 7px;
  height: 7px;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.15s ease;
  flex: 0 0 auto;
}

.nav-item.open > .nav-btn::after {
  transform: rotate(135deg);
}

.nav-btn:hover,
.nav-btn.active {
  background: var(--clr-primary);
  color: #fff;
  border-color: var(--clr-primary);
}

.nav-icon {
  display: inline-flex;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

.nav-icon svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.nav-label {
  display: inline-flex;
  align-items: center;
}

body.auth-authenticated.menu-collapsed #main-nav {
  align-items: center;
  width: 44px;
  min-width: 44px;
  margin: 0 auto;
}

body.auth-authenticated.menu-collapsed .nav-btn {
  justify-content: center;
  width: 44px;
  min-width: 44px;
  padding: 0;
  margin: 0 auto;
}

body.auth-authenticated.menu-collapsed .nav-item.has-submenu > .nav-btn::after {
  content: none;
}

body.auth-authenticated.menu-collapsed #header-auth-slot {
  width: 44px;
  min-width: 44px;
  margin: 0 auto;
}

body.auth-authenticated.menu-collapsed #header-auth-slot #auth-controls {
  width: 44px;
  align-items: center;
}

body.auth-authenticated.menu-collapsed .nav-label {
  display: none;
}

body.auth-authenticated #btn-menu-toggle {
  position: relative;
}

body.auth-authenticated:not(.menu-collapsed) #btn-menu-toggle:hover::before,
body.auth-authenticated:not(.menu-collapsed) #btn-menu-toggle:focus-visible::before {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--clr-text);
  color: var(--clr-surface);
  border-radius: 6px;
  padding: 0.3rem 0.5rem;
  font-size: 0.78rem;
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
  z-index: 220;
}

body.auth-authenticated.menu-collapsed .nav-btn,
body.auth-authenticated.menu-collapsed #theme-toggle,
body.auth-authenticated.menu-collapsed #btn-auth-logout,
body.auth-authenticated.menu-collapsed #btn-menu-toggle {
  position: relative;
}

body.auth-authenticated.menu-collapsed .nav-btn:hover::before,
body.auth-authenticated.menu-collapsed .nav-btn:focus-visible::before,
body.auth-authenticated.menu-collapsed #theme-toggle:hover::before,
body.auth-authenticated.menu-collapsed #theme-toggle:focus-visible::before,
body.auth-authenticated.menu-collapsed #btn-auth-logout:hover::before,
body.auth-authenticated.menu-collapsed #btn-auth-logout:focus-visible::before,
body.auth-authenticated.menu-collapsed #btn-menu-toggle:hover::before,
body.auth-authenticated.menu-collapsed #btn-menu-toggle:focus-visible::before {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--clr-text);
  color: var(--clr-surface);
  border-radius: 6px;
  padding: 0.3rem 0.5rem;
  font-size: 0.78rem;
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
  z-index: 220;
}

.submenu {
  display: block;
  position: static;
  list-style: none;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  width: 100%;
  min-width: 0;
  z-index: 10;
  padding: 0;
  margin-top: 0.35rem;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transform: none;
  transform-origin: top;
  pointer-events: none;
  will-change: max-height, opacity;
  transition: max-height 0.24s ease, opacity 0.2s ease;
}

.nav-item.open .submenu {
  max-height: var(--submenu-open-height, 260px);
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

body.auth-authenticated:not(.menu-collapsed) .nav-item.has-submenu {
  flex-direction: column;
  width: 100%;
}

body.auth-authenticated:not(.menu-collapsed) .nav-item.has-submenu .submenu {
  position: static;
  top: auto;
  left: auto;
  width: 100%;
  min-width: 0;
  margin-top: 0.35rem;
}

body.auth-authenticated.menu-collapsed .submenu {
  display: none;
  position: absolute;
  top: 50%;
  left: calc(100% + 8px);
  transform: translateY(-50%);
  width: max-content;
  min-width: 160px;
  margin-top: 0;
  margin: 0;
  max-height: none !important;
  opacity: 0;
  overflow: visible;
  pointer-events: none;
  transition: opacity 0.15s ease;
  background: var(--clr-surface);
  border-radius: var(--radius);
  box-shadow: var(--clr-shadow);
  border: 1px solid var(--clr-border);
  z-index: 1000;
  padding: 0;
  list-style: none;
}

body.auth-authenticated.menu-collapsed .submenu li {
  margin: 0;
  padding: 0;
  display: block;
}

body.auth-authenticated.menu-collapsed .submenu li a {
  padding: 0.6rem 1rem;
}

body.auth-authenticated.menu-collapsed .nav-item.open .submenu {
  display: block;
  opacity: 1;
  pointer-events: auto;
  overflow: visible;
}

.submenu li a {
  display: block;
  padding: 0.5rem 1rem;
  text-decoration: none;
  color: var(--clr-text);
  font-size: 0.9rem;
  transition: background 0.1s;
  border-radius: 0;
  white-space: nowrap;
}

.submenu li a:hover,
.submenu li a.active {
  background: var(--clr-active);
  color: var(--clr-primary);
}

h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.subtitle {
  color: var(--clr-muted);
  margin-top: 0.25rem;
}

.muted {
  color: var(--clr-muted);
  font-size: 0.875rem;
}

.hidden {
  display: none !important;
}

/* ---------- App View Panels ---------- */
#view-import-folder,
#view-import-log,
#view-data-viewer,
#view-settings {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  width: 100%;
}

/* ---------- Folder Picker ---------- */
#folder-picker {
  background: var(--clr-surface);
  border: 2px dashed var(--clr-border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
}

button {
  cursor: pointer;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  padding: 0.625rem 1.5rem;
  font-weight: 600;
  transition: background 0.15s;
}

#btn-pick-folder {
  background: var(--clr-primary);
  color: #fff;
}

#btn-pick-folder:hover {
  background: var(--clr-primary-hover);
}

#folder-path {
  margin-top: 0.75rem;
}

/* ---------- File List ---------- */
#file-list-section {
  margin-top: 2rem;
  background: var(--clr-surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  border: 1px solid var(--clr-border);
}

#file-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

#file-list li {
  padding: 0.375rem 0.875rem;
  border-radius: var(--radius);
  border: 1px solid var(--clr-border);
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.15s;
  user-select: none;
}

#file-list li:hover {
  border-color: var(--clr-primary);
  color: var(--clr-primary);
}

#file-list li.active {
  background: var(--clr-active);
  border-color: var(--clr-primary);
  color: var(--clr-primary);
  font-weight: 600;
}

/* ---------- Schema Table ---------- */
#schema-section {
  margin-top: 2rem;
  background: var(--clr-surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  border: 1px solid var(--clr-border);
  overflow-x: auto;
}

#schema-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

#schema-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
}

#schema-table th,
#schema-table td {
  text-align: left;
  padding: 0.7rem 0.65rem;
  line-height: 1.4;
  border-bottom: 1px solid var(--clr-border);
}

#schema-table th {
  background: var(--clr-surface-alt);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--clr-muted);
}

#schema-table td:first-child {
  width: 3rem;
  color: var(--clr-muted);
}

#schema-table td:nth-child(3) {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.85rem;
  color: var(--clr-muted);
}

#schema-table th:nth-child(4),
#schema-table td:nth-child(4) {
  width: 180px;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#schema-table select {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--clr-border);
  border-radius: 4px;
  font-size: 0.9rem;
  background: var(--clr-input-bg);
  color: var(--clr-text);
}

.date-fmt-select {
  margin-top: 0.35rem;
  display: block;
}

.pg-col-input {
  width: 100%;
  min-width: 160px;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--clr-border);
  border-radius: 4px;
  font-size: 0.85rem;
  font-family: "Cascadia Code", "Consolas", monospace;
  background: var(--clr-input-bg);
  color: var(--clr-text);
}

.type-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--clr-surface-alt);
  color: var(--clr-muted);
}

#import-project-status {
  margin-bottom: 1rem;
  font-size: 0.84rem;
}

/* ---------- Table Name Row ---------- */
#table-name-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

#table-name-row label {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
}

#table-name-input {
  flex: 1;
  max-width: 360px;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--clr-border);
  border-radius: 4px;
  font-size: 0.9rem;
  font-family: "Cascadia Code", "Consolas", monospace;
  background: var(--clr-input-bg);
  color: var(--clr-text);
}

/* ---------- Table Categories Row ---------- */
#table-categories-row {
  display: block;
  margin-bottom: 1rem;
}

#table-categories-row label {
  font-weight: 600;
  font-size: 0.9rem;
  display: block;
  margin-bottom: 0.5rem;
}

.categories-multiselect {
  border: 1px solid var(--clr-border);
  border-radius: 4px;
  padding: 0.75rem;
  background: var(--clr-input-bg);
  max-width: 600px;
}

.categories-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  max-height: 200px;
  overflow-y: auto;
}

.categories-list label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.5rem;
  border-radius: 3px;
  cursor: pointer;
  user-select: none;
  font-weight: normal;
  margin-bottom: 0;
}

.categories-list label:hover {
  background: var(--clr-surface-alt);
}

.categories-list input[type="checkbox"] {
  cursor: pointer;
  margin: 0;
}

.categories-help {
  font-size: 0.8rem;
  margin: 0;
}

/* ---------- Schema Actions ---------- */
#schema-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ---------- Buttons ---------- */
.secondary {
  background: var(--clr-bg);
  color: var(--clr-text);
  border: 1px solid var(--clr-border);
}

.secondary:hover {
  background: var(--clr-surface-alt);
}

#btn-import {
  background: #16a34a;
  color: #fff;
}

#btn-import:hover {
  background: #15803d;
}

#btn-validate {
  background: var(--clr-primary);
  color: #fff;
}

#btn-validate:hover {
  background: var(--clr-primary-hover);
}

/* ---------- Import Status ---------- */
#import-status {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
}

.status-success {
  background: var(--clr-success-bg);
  border: 1px solid var(--clr-success-border);
  color: var(--clr-success-text);
}

.status-error {
  background: var(--clr-error-bg);
  border: 1px solid var(--clr-error-border);
  color: var(--clr-error-text);
}

/* ==========================================================================
   Import Folder – Responsive
   ========================================================================== */

@media (max-width: 1024px) {
  #schema-table th,
  #schema-table td {
    padding: 0.55rem 0.45rem;
  }

  #table-name-input {
    max-width: 280px;
  }
}

@media (max-width: 768px) {
  #folder-picker {
    padding: 1.25rem;
  }

  #file-list-section {
    padding: 1rem;
  }

  #schema-section {
    padding: 1rem;
  }

  #table-name-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
  }

  #table-name-input {
    max-width: 100%;
    width: 100%;
  }

  #schema-table {
    font-size: 0.8rem;
  }

  #schema-table th,
  #schema-table td {
    padding: 0.5rem 0.35rem;
  }

  #schema-table th:nth-child(4),
  #schema-table td:nth-child(4) {
    width: 140px;
    max-width: 140px;
  }

  #schema-actions {
    flex-direction: column;
  }

  #schema-actions button {
    width: 100%;
  }
}

