    :root {
      --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
      --text-body-size: 14px;
      --text-label-size: 13px;
      /* Smooth, non-abrupt motion (ease-out feel) */
      --motion-smooth: 0.48s cubic-bezier(0.33, 1, 0.68, 1);
      --motion-smooth-medium: 0.4s cubic-bezier(0.33, 1, 0.68, 1);
      --motion-overlay: 0.42s cubic-bezier(0.4, 0, 0.2, 1);
      /* Viewer chrome: sidebar + Document browser + Selection panel shells */
      --ui-chrome-surface: rgba(255, 255, 255, 0.85);
      --ui-chrome-border: 1px solid rgba(0, 0, 0, 0.08);
      --ui-chrome-radius: 12px;
      /* Refined to a softer, layered drop (keeps the crisp inset ring) for a more premium depth. */
      --ui-chrome-shadow: 0 0 0 1px rgba(16, 24, 40, 0.04) inset, 0 6px 16px -4px rgba(16, 24, 40, 0.10), 0 2px 6px -2px rgba(16, 24, 40, 0.06);
      --ui-backdrop-filter: saturate(180%) blur(40px);
      --ui-text-primary: #1d1d1f;
      --ui-accent: #2563eb;
      --ui-accent-soft-bg: rgba(37, 99, 235, 0.15);
      --ui-accent-soft-border: 1px solid rgba(37, 99, 235, 0.12);
      --ui-accent-muted-bg: rgba(37, 99, 235, 0.08);
      /* Sidebar-only: slightly more opaque glass over busy background (panels keep --ui-chrome-surface) */
      --ui-sidebar-surface: rgba(255, 255, 255, 0.96);
      --ui-sidebar-surface-image: linear-gradient(165deg, rgba(255, 255, 255, 0.98) 0%, rgba(241, 245, 249, 0.94) 100%);
      --ui-sidebar-border: 1px solid rgba(15, 23, 42, 0.10);
      --ui-sidebar-shadow:
        0 0 0 1px rgba(15, 23, 42, 0.04) inset,
        0 10px 28px -8px rgba(15, 23, 42, 0.18),
        0 4px 10px -4px rgba(15, 23, 42, 0.10);
      --ui-sidebar-text: #0f172a;
      --ui-sidebar-text-muted: #64748b;
      --ui-sidebar-icon: #475569;
      --ui-sidebar-active-bg: linear-gradient(90deg, rgba(37, 99, 235, 0.18), rgba(37, 99, 235, 0.08));
      --ui-sidebar-active-border: 1px solid rgba(37, 99, 235, 0.28);
      --ui-sidebar-active-rail: #2563eb;
      --ui-sidebar-footer-bg: rgba(15, 23, 42, 0.03);
      --ui-nav-item-padding: 8px 10px;
      --ui-nav-item-radius: 8px;
      --ui-nav-item-padding-collapsed: 10px;
      --ui-nav-hover-bg: rgba(15, 23, 42, 0.06);
      --ui-sidebar-toggle-hover-bg: rgba(15, 23, 42, 0.08);
      --ui-hover-border-color: rgba(15, 23, 42, 0.06);
      --ui-avatar-border: 1px solid rgba(0, 0, 0, 0.1);
      --ui-focus-ring-color: rgba(37, 99, 235, 0.45);
      --ui-sidebar-nav-press: rgba(15, 23, 42, 0.09);
      --ui-sidebar-toggle-press: rgba(15, 23, 42, 0.12);
      --ui-sidebar-viewport-inset: 10px;
      --ui-sidebar-width-expanded: min(220px, calc(100vw - 20px));
      --ui-sidebar-width-collapsed: 64px;
      --ui-sidebar-content-gap: 10px;
      --ui-content-inset-left-expanded: calc(var(--ui-sidebar-viewport-inset) + var(--ui-sidebar-width-expanded) + var(--ui-sidebar-content-gap));
      --ui-content-inset-left-collapsed: calc(var(--ui-sidebar-viewport-inset) + var(--ui-sidebar-width-collapsed) + var(--ui-sidebar-content-gap));
      --ui-panel-muted-surface: rgba(0, 0, 0, 0.03);
      --ui-panel-muted-surface-hover: rgba(0, 0, 0, 0.05);
      --ui-panel-muted-border: rgba(0, 0, 0, 0.08);
      --ui-panel-muted-shadow: 0 0 0 1px rgba(0, 0, 0, 0.02) inset;
      /* Dynamic viewport height (falls back to 100vh; upgraded below when dvh is supported) */
      --app-vh: 100vh;

      /* ============================================================
         PREMIUM FOUNDATION TOKENS — additive; components adopt gradually.
         (See .claude/design-system.md.) Light theme values.
         ============================================================ */
      /* Spacing — 4px grid */
      --space-1: 4px;  --space-2: 8px;   --space-3: 12px;  --space-4: 16px;  --space-5: 20px;
      --space-6: 24px; --space-8: 32px;  --space-10: 40px; --space-12: 48px;
      /* Radius scale */
      --radius-sm: 6px; --radius-md: 8px; --radius-lg: 12px; --radius-xl: 16px; --radius-pill: 999px;
      /* Type scale + weights + tracking */
      --text-caption: 12px; --text-label: 13px; --text-body: 14px;
      --text-subtitle: 16px; --text-title: 20px; --text-display: 26px;
      --weight-regular: 400; --weight-medium: 500; --weight-semibold: 600; --weight-bold: 700;
      --tracking-tight: -0.01em;
      /* Neutral text ramp (extends --ui-text-primary) */
      --ui-text-secondary: #5b6470;
      --ui-text-muted: #9ca3af;
      /* Elevation — soft, layered */
      --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
      --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.10), 0 1px 2px rgba(16, 24, 40, 0.06);
      --shadow-md: 0 4px 8px -2px rgba(16, 24, 40, 0.10), 0 2px 4px -2px rgba(16, 24, 40, 0.06);
      --shadow-lg: 0 12px 20px -6px rgba(16, 24, 40, 0.12), 0 6px 8px -4px rgba(16, 24, 40, 0.05);
      /* Semantic colors (solid + soft background) */
      --color-success: #1a8f4c; --color-success-soft: rgba(26, 143, 76, 0.12);
      --color-warning: #b26a00; --color-warning-soft: rgba(230, 160, 30, 0.12);
      --color-danger: #c0392b;  --color-danger-soft: rgba(192, 57, 43, 0.10);
      --color-info: var(--ui-accent); --color-info-soft: var(--ui-accent-soft-bg);
    }

    body.dark-theme {
      --ui-chrome-surface: #212736;
      --ui-chrome-border: 1px solid #363d4d;
      --ui-chrome-shadow: 0 0 0 1px rgba(0, 0, 0, 0.10) inset, 0 6px 16px -4px rgba(0, 0, 0, 0.40), 0 2px 6px -2px rgba(0, 0, 0, 0.28);
      --ui-text-primary: #e0e0e0;
      --ui-accent: #6aa1ff;
      --ui-accent-soft-bg: rgba(106, 161, 255, 0.2);
      --ui-accent-soft-border: 1px solid rgba(106, 161, 255, 0.12);
      --ui-accent-muted-bg: rgba(106, 161, 255, 0.12);
      --ui-sidebar-surface: #151a24;
      --ui-sidebar-surface-image:
        radial-gradient(120% 70% at 0% 0%, rgba(56, 120, 240, 0.14), transparent 55%),
        linear-gradient(180deg, #1a2130 0%, #121722 58%, #0f141d 100%);
      --ui-sidebar-border: 1px solid rgba(148, 163, 184, 0.16);
      --ui-sidebar-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.04) inset,
        0 14px 36px -10px rgba(0, 0, 0, 0.55),
        0 6px 14px -6px rgba(0, 0, 0, 0.4);
      --ui-sidebar-text: #f1f5f9;
      --ui-sidebar-text-muted: #94a3b8;
      --ui-sidebar-icon: #a8b4c7;
      --ui-sidebar-active-bg: linear-gradient(90deg, rgba(56, 120, 240, 0.42), rgba(37, 99, 235, 0.18));
      --ui-sidebar-active-border: 1px solid rgba(147, 197, 253, 0.32);
      --ui-sidebar-active-rail: #60a5fa;
      --ui-sidebar-footer-bg: rgba(255, 255, 255, 0.035);
      --ui-nav-hover-bg: rgba(255, 255, 255, 0.07);
      --ui-sidebar-toggle-hover-bg: rgba(255, 255, 255, 0.09);
      --ui-hover-border-color: rgba(255, 255, 255, 0.08);
      --ui-avatar-border: 1px solid rgba(148, 163, 184, 0.28);
      --ui-focus-ring-color: rgba(106, 161, 255, 0.55);
      --ui-sidebar-nav-press: rgba(255, 255, 255, 0.12);
      --ui-sidebar-toggle-press: rgba(255, 255, 255, 0.16);
      --ui-panel-muted-surface: rgba(255, 255, 255, 0.06);
      --ui-panel-muted-surface-hover: rgba(255, 255, 255, 0.09);
      --ui-panel-muted-border: rgba(255, 255, 255, 0.08);
      --ui-panel-muted-shadow: 0 0 0 1px rgba(255, 255, 255, 0.03) inset;

      /* Premium foundation — dark overrides (scales/type/radius/spacing inherit from :root) */
      --ui-text-secondary: #a0a6b0;
      --ui-text-muted: #6b7280;
      --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.30);
      --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.40), 0 1px 2px rgba(0, 0, 0, 0.30);
      --shadow-md: 0 4px 8px -2px rgba(0, 0, 0, 0.45), 0 2px 4px -2px rgba(0, 0, 0, 0.30);
      --shadow-lg: 0 12px 20px -6px rgba(0, 0, 0, 0.50), 0 6px 8px -4px rgba(0, 0, 0, 0.30);
      --color-success: #34c77b; --color-success-soft: rgba(52, 199, 123, 0.16);
      --color-warning: #e0a032; --color-warning-soft: rgba(230, 160, 30, 0.18);
      --color-danger: #e57368;  --color-danger-soft: rgba(231, 76, 60, 0.18);
    }

    html,
    body {
      margin: 0;
      padding: 0;
      width: 100%;
      height: 100%;
      height: var(--app-vh);
      overflow: hidden;
      font-family: var(--font-ui);
      font-size: var(--text-body-size);
    }

    @supports (height: 100dvh) {
      :root {
        --app-vh: 100dvh;
      }
    }

    /* ==========================
           PREMIUM MOTION — accessibility + content entrance
           ========================== */
    /* Respect prefers-reduced-motion: drop decorative transitions/animations,
       but keep loading indicators moving (that motion is functional feedback). */
    @media (prefers-reduced-motion: reduce) {
      *, *::before, *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
      }
      .login-btn-spinner, .construction-stats-loading__spinner, .toast-spinner,
      .auth-overlay-spinner, .custom-loader-bar, .pg-loader-bar,
      .props-header-busy-spinner, .forge-spinner, .lmv-spinner,
      .pg-loader-bar::before, .auth-overlay-spinner::before, .custom-loader-bar::before {
        animation-duration: 0.8s !important;
        animation-iteration-count: infinite !important;
      }
    }

    /* Content fades + rises in gently instead of popping. */
    @keyframes motion-enter {
      from { opacity: 0; transform: translateY(6px); }
      to   { opacity: 1; transform: translateY(0); }
    }
    /* Scoped to the Auto de medição preview (renders on "Generate", not on chip changes)
       so it never replays on Financial/Execução filter switches. */
    #measurementPreviewHost .kpi-row,
    #measurementPreviewHost .measurement-warnings {
      animation: motion-enter 0.30s cubic-bezier(0.33, 1, 0.68, 1) both;
    }
    #measurementPreviewHost .ui-content-frame {
      animation: motion-enter 0.34s cubic-bezier(0.33, 1, 0.68, 1) 0.04s both;
    }

    /* ==========================
           TABS SYSTEM
           ========================== */
    .tabs-container {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      display: flex;
      flex-direction: column;
      z-index: 1;
      transition: opacity var(--motion-smooth-medium);
    }

    body.user-authenticated .tabs-container {
      flex-direction: row;
      background-color: #1a1a1a;
      background-image:
        radial-gradient(1000px circle at 18% 22%, var(--ui-accent-soft-bg), transparent 58%),
        radial-gradient(800px circle at 82% 28%, rgba(255, 255, 255, 0.06), transparent 55%),
        linear-gradient(135deg, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0.88));
      background-size: cover;
      background-position: center;
      background-repeat: no-repeat;
      opacity: 0;
      transition: opacity var(--motion-smooth);
    }

    body.user-authenticated .tabs-container.app-loaded {
      opacity: 1;
    }

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

    /* Sidebar – floating card; tokens shared with Document browser + Selection shells */
    .app-sidebar {
      display: none;
      width: var(--ui-sidebar-width-expanded);
      flex-shrink: 0;
      flex-direction: column;
      padding: 10px 12px;
      gap: 0.5rem;
      background-color: var(--ui-sidebar-surface);
      background-image: var(--ui-sidebar-surface-image);
      color: var(--ui-sidebar-text);
      backdrop-filter: var(--ui-backdrop-filter);
      -webkit-backdrop-filter: var(--ui-backdrop-filter);
      border: var(--ui-sidebar-border);
      border-radius: var(--ui-chrome-radius);
      font-family: var(--font-ui);
      font-size: var(--text-label-size);
      transition: width var(--motion-smooth-medium), padding var(--motion-smooth-medium), transform var(--motion-smooth-medium);
      overflow: hidden auto;
      isolation: isolate;
      box-shadow: var(--ui-sidebar-shadow);
      max-height: calc(var(--app-vh) - 20px);
      scrollbar-width: none;
      -ms-overflow-style: none;
      box-sizing: border-box;
    }

    body.user-authenticated .app-sidebar {
      display: flex;
      position: fixed;
      left: var(--ui-sidebar-viewport-inset);
      top: var(--ui-sidebar-viewport-inset);
      bottom: var(--ui-sidebar-viewport-inset);
      z-index: 12000;
      box-shadow: var(--ui-sidebar-shadow);
    }

    .app-sidebar::-webkit-scrollbar {
      display: none;
    }

    .app-sidebar .sidebar-toggle {
      display: flex;
      align-items: center;
      justify-content: flex-start;
      width: 100%;
      padding: var(--ui-nav-item-padding);
      margin-bottom: 0.25rem;
      background: transparent;
      border: 1px solid transparent;
      border-radius: var(--ui-nav-item-radius);
      cursor: pointer;
      color: var(--ui-sidebar-icon);
      font-weight: 500;
      font-size: var(--text-label-size);
      transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
      flex: none;
      box-sizing: border-box;
    }

    .app-sidebar .sidebar-toggle:hover {
      background: var(--ui-sidebar-toggle-hover-bg);
      border-color: var(--ui-hover-border-color);
      color: var(--ui-sidebar-text);
    }

    .app-sidebar .sidebar-toggle:active {
      background: var(--ui-sidebar-toggle-press);
    }

    .app-sidebar .sidebar-toggle:focus {
      outline: none;
    }

    .app-sidebar .sidebar-toggle:focus-visible {
      outline: 2px solid var(--ui-focus-ring-color);
      outline-offset: 2px;
    }

    .app-sidebar .sidebar-toggle svg,
    .app-sidebar .sidebar-toggle i {
      width: 18px;
      height: 18px;
      flex-shrink: 0;
      display: block;
    }
    .app-sidebar .sidebar-toggle i svg {
      width: 100%;
      height: 100%;
      display: block;
    }

    .sidebar-model-loading {
      position: relative;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 8px;
      margin-top: auto;
      margin-bottom: 4px;
      padding: 12px 10px 10px;
      border-radius: 12px;
      border: 1px solid rgba(96, 165, 250, 0.45);
      background:
        linear-gradient(180deg, rgba(59, 130, 246, 0.22), rgba(59, 130, 246, 0.07)),
        rgba(12, 16, 24, 0.65);
      box-shadow:
        0 0 0 1px rgba(147, 197, 253, 0.14) inset,
        0 8px 20px rgba(0, 0, 0, 0.28);
      overflow: hidden;
      isolation: isolate;
      text-align: center;
    }

    .sidebar-model-loading-cancel {
      position: absolute;
      top: 6px;
      right: 6px;
      z-index: 2;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 26px;
      height: 26px;
      padding: 0;
      border: 1px solid rgba(191, 219, 254, 0.35);
      border-radius: 8px;
      background: rgba(15, 23, 42, 0.55);
      color: #e2e8f0;
      cursor: pointer;
      transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    }

    .sidebar-model-loading-cancel:hover,
    .sidebar-model-loading-cancel:focus-visible {
      background: rgba(239, 68, 68, 0.28);
      border-color: rgba(248, 113, 113, 0.55);
      color: #fecaca;
      outline: none;
    }

    .sidebar-model-loading-cancel i,
    .sidebar-model-loading-cancel svg {
      width: 14px;
      height: 14px;
      display: block;
      pointer-events: none;
    }

    body.sidebar-collapsed .sidebar-model-loading-cancel {
      top: 4px;
      right: 4px;
      width: 22px;
      height: 22px;
      border-radius: 6px;
    }

    .sidebar-model-loading-glow {
      position: absolute;
      inset: -30% -20%;
      background: radial-gradient(circle at 50% 40%, rgba(96, 165, 250, 0.32), transparent 62%);
      animation: sidebar-model-loading-pulse 1.6s ease-in-out infinite;
      pointer-events: none;
      z-index: 0;
    }

    .sidebar-model-loading-spinner {
      position: relative;
      z-index: 1;
      width: 22px;
      height: 22px;
      border-radius: 50%;
      border: 2.5px solid rgba(147, 197, 253, 0.28);
      border-top-color: #93c5fd;
      border-right-color: #60a5fa;
      animation: sidebar-model-loading-spin 0.85s linear infinite;
      box-shadow: 0 0 12px rgba(96, 165, 250, 0.45);
    }

    .sidebar-model-loading-title,
    .sidebar-model-loading-label {
      position: relative;
      z-index: 1;
      margin: 0;
      color: #bfdbfe !important;
      font-size: 13px;
      font-weight: 800;
      line-height: 1.25;
      letter-spacing: 0.02em;
      text-align: center;
      text-shadow: 0 0 14px rgba(96, 165, 250, 0.35);
    }

    .sidebar-model-loading-info {
      position: relative;
      z-index: 1;
      margin: 0;
      max-width: 100%;
      color: rgba(191, 219, 254, 0.85);
      font-size: 11px;
      font-weight: 600;
      line-height: 1.3;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .sidebar-model-loading-info:empty {
      display: none;
    }

    .sidebar-model-progress-track {
      position: relative;
      z-index: 1;
      display: none;
      width: 100%;
      height: 8px;
      border-radius: 999px;
      background: rgba(15, 23, 42, 0.55);
      border: 1px solid rgba(147, 197, 253, 0.22);
      overflow: hidden;
    }

    .sidebar-model-progress-fill {
      position: relative;
      height: 100%;
      min-width: 0;
      border-radius: inherit;
      background: linear-gradient(90deg, #2563eb, #60a5fa 55%, #93c5fd);
      box-shadow: 0 0 10px rgba(96, 165, 250, 0.45);
      transition: width 0.35s ease;
    }

    .sidebar-model-progress-pct {
      position: absolute;
      inset: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 9px;
      font-weight: 800;
      letter-spacing: 0.02em;
      color: #eff6ff;
      text-shadow: 0 1px 2px rgba(15, 23, 42, 0.55);
      white-space: nowrap;
    }

    .sidebar-model-loading-indeterminate {
      position: relative;
      z-index: 1;
      display: none;
      width: 100%;
      max-width: 140px;
      height: 3px;
      background: rgba(96, 165, 250, 0.2);
      box-shadow: none;
    }

    .sidebar-model-loading-indeterminate::before {
      background: linear-gradient(
        90deg,
        transparent,
        #60a5fa 18%,
        #dbeafe 50%,
        #60a5fa 82%,
        transparent
      );
    }

    /* Translation / upload: determinate % bar */
    .sidebar-model-loading.active .sidebar-model-progress-track {
      display: block;
    }

    .sidebar-model-loading.active .sidebar-model-loading-indeterminate {
      display: none;
    }

    /* Viewer geometry load: indeterminate bar */
    .sidebar-model-loading:not(.active):not([hidden]) .sidebar-model-loading-indeterminate {
      display: block;
    }

    .sidebar-model-loading:not(.active) .sidebar-model-progress-track,
    .sidebar-model-loading:not(.active) .sidebar-model-loading-info {
      display: none;
    }

    .sidebar-model-loading[hidden] {
      display: none !important;
    }

    body.sidebar-collapsed .sidebar-model-loading {
      padding: 10px 6px;
      gap: 6px;
    }

    body.sidebar-collapsed .sidebar-model-loading-title,
    body.sidebar-collapsed .sidebar-model-loading-label {
      font-size: 9px;
      line-height: 1.15;
    }

    body.sidebar-collapsed .sidebar-model-loading-info {
      display: none;
    }

    body.sidebar-collapsed .sidebar-model-loading-spinner {
      width: 16px;
      height: 16px;
    }

    body.sidebar-collapsed .sidebar-model-progress-pct {
      font-size: 8px;
    }

    .sidebar-model-missing {
      position: relative;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 6px;
      margin-top: auto;
      margin-bottom: 4px;
      padding: 12px 10px 10px;
      border-radius: 12px;
      border: 1px solid rgba(255, 59, 59, 0.4);
      background:
        linear-gradient(180deg, rgba(255, 59, 59, 0.18), rgba(255, 59, 59, 0.06)),
        rgba(12, 16, 24, 0.65);
      box-shadow:
        0 0 0 1px rgba(255, 59, 59, 0.12) inset,
        0 8px 20px rgba(0, 0, 0, 0.28);
      overflow: hidden;
      isolation: isolate;
      text-align: center;
    }

    .sidebar-model-missing-glow {
      position: absolute;
      inset: -30% -20%;
      background: radial-gradient(circle at 50% 40%, rgba(255, 59, 59, 0.22), transparent 62%);
      pointer-events: none;
      z-index: 0;
    }

    .sidebar-model-missing-title,
    .sidebar-model-missing-text {
      position: relative;
      z-index: 1;
      margin: 0;
      color: #ff3b3b !important;
      text-shadow: 0 0 14px rgba(255, 59, 59, 0.35);
    }

    .sidebar-model-missing-title {
      font-size: 12px;
      font-weight: 800;
      line-height: 1.25;
    }

    .sidebar-model-missing-text {
      font-size: 11px;
      font-weight: 600;
      line-height: 1.35;
      opacity: 0.95;
    }

    .sidebar-model-missing[hidden] {
      display: none !important;
    }

    body.sidebar-collapsed .sidebar-model-missing {
      padding: 10px 6px;
      gap: 4px;
    }

    body.sidebar-collapsed .sidebar-model-missing-title {
      font-size: 9px;
    }

    body.sidebar-collapsed .sidebar-model-missing-text {
      display: none;
    }

    /* Light theme: sidebar alerts — dark text on soft surfaces */
    body:not(.dark-theme) .sidebar-model-missing,
    body:not(.dark-theme) .sidebar-teams-missing {
      border-color: rgba(185, 28, 28, 0.35);
      background:
        linear-gradient(180deg, rgba(254, 226, 226, 0.95), rgba(254, 242, 242, 0.98)),
        #fff;
      box-shadow:
        0 0 0 1px rgba(185, 28, 28, 0.08) inset,
        0 4px 14px rgba(15, 23, 42, 0.08);
    }
    body:not(.dark-theme) .sidebar-model-missing-glow {
      background: radial-gradient(circle at 50% 40%, rgba(248, 113, 113, 0.18), transparent 62%);
    }
    body:not(.dark-theme) .sidebar-model-missing-title,
    body:not(.dark-theme) .sidebar-model-missing-text {
      color: #0f172a !important;
      text-shadow: none;
    }

    body:not(.dark-theme) .sidebar-model-loading {
      border-color: rgba(37, 99, 235, 0.35);
      background:
        linear-gradient(180deg, rgba(219, 234, 254, 0.95), rgba(239, 246, 255, 0.98)),
        #fff;
      box-shadow:
        0 0 0 1px rgba(37, 99, 235, 0.08) inset,
        0 4px 14px rgba(15, 23, 42, 0.08);
    }
    body:not(.dark-theme) .sidebar-model-loading-glow {
      background: radial-gradient(circle at 50% 40%, rgba(96, 165, 250, 0.2), transparent 62%);
    }
    body:not(.dark-theme) .sidebar-model-loading-title,
    body:not(.dark-theme) .sidebar-model-loading-label,
    body:not(.dark-theme) .sidebar-model-loading-info {
      color: #0f172a !important;
      text-shadow: none;
    }
    body:not(.dark-theme) .sidebar-model-loading-cancel {
      background: rgba(255, 255, 255, 0.85);
      border-color: rgba(15, 23, 42, 0.16);
      color: #0f172a;
    }
    body:not(.dark-theme) .sidebar-model-loading-cancel:hover,
    body:not(.dark-theme) .sidebar-model-loading-cancel:focus-visible {
      background: rgba(254, 226, 226, 0.95);
      border-color: rgba(185, 28, 28, 0.4);
      color: #991b1b;
    }
    body:not(.dark-theme) .sidebar-model-progress-track {
      background: rgba(15, 23, 42, 0.08);
      border-color: rgba(37, 99, 235, 0.2);
    }

    /* Stack sidebar alerts: first visible owns margin-top auto; siblings sit below */
    .sidebar-model-missing:not([hidden]) ~ .sidebar-model-loading,
    .sidebar-model-missing:not([hidden]) ~ .sidebar-model-missing,
    .sidebar-model-loading:not([hidden]) ~ .sidebar-model-missing {
      margin-top: 8px;
    }

    @keyframes sidebar-model-loading-spin {
      to { transform: rotate(360deg); }
    }

    @keyframes sidebar-model-loading-pulse {
      0%, 100% { opacity: 0.55; transform: scale(0.96); }
      50% { opacity: 1; transform: scale(1.04); }
    }


    .home-tab-alert-dot {
      position: absolute;
      right: 6px;
      bottom: 5px;
      width: 8px;
      height: 8px;
      border-radius: 50%;
      background: #ff3b3b;
      box-shadow:
        0 0 0 2px rgba(16, 23, 34, 0.95),
        0 0 10px rgba(255, 59, 59, 0.65);
      pointer-events: none;
    }
    .home-tab-alert-dot[hidden] {
      display: none !important;
    }
    .home-inner-panel {
      flex: 1 1 auto;
      min-height: 0;
      overflow-x: hidden;
      overflow-y: auto;
      overscroll-behavior: contain;
      scrollbar-width: thin;
      scrollbar-color: #2563eb #f1f1f1;
    }

    #homePanelProject .home-project-alert-row {
      display: block;
      width: min(100%, 980px);
      margin: 0 0 16px;
      box-sizing: border-box;
    }
    #homePanelProject .home-project-alert-row > .home-orcamento {
      width: 100%;
      max-width: none;
    }
    #homePanelProject .home-project-alert-row > .home-orcamento[hidden] {
      display: none !important;
    }
    #homePanelProject .home-hub {
      max-width: none;
      width: min(100%, 980px);
      margin: 0 0 16px;
    }

    #tab1 .select-model-btn .select-model-btn-dot,
    .select-model-btn-dot {
      right: 7px;
      bottom: 7px;
    }

    #tab1 .select-model-btn .btn-icon,
    #tab1 .select-model-btn svg {
      width: 18px;
      height: 18px;
      flex-shrink: 0;
    }

    #tab1 .file-upload-btn {
      background: var(--ui-accent-soft-bg);
      color: var(--ui-accent);
      border: var(--ui-accent-soft-border);
    }

    .app-sidebar-nav {
      display: flex;
      flex-direction: column;
      gap: 0.375rem;
      flex: 1;
      min-height: 0;
    }

    .app-sidebar .tab-button {
      display: flex;
      align-items: center;
      justify-content: flex-start;
      gap: 0.75rem;
      width: 100%;
      padding: var(--ui-nav-item-padding);
      border: 1px solid transparent;
      border-radius: var(--ui-nav-item-radius);
      background: transparent;
      cursor: pointer;
      font-size: var(--text-label-size);
      font-weight: 500;
      color: var(--ui-text-primary);
      transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
      text-align: left;
      flex: none;
    }

    .app-sidebar .tab-button:hover {
      background: var(--ui-nav-hover-bg);
      border-color: var(--ui-hover-border-color);
      color: #fff;
    }

    body:not(.dark-theme) .app-sidebar .tab-button:hover {
      color: var(--ui-sidebar-text);
    }

    .app-sidebar .tab-button:active {
      background: var(--ui-sidebar-nav-press);
    }

    .app-sidebar .tab-button.tab-model-locked,
    .app-sidebar .tab-button.tab-model-locked:hover,
    .app-sidebar .tab-button.tab-model-locked:active,
    .app-sidebar .tab-button.tab-model-locked.active {
      opacity: 0.42;
      cursor: not-allowed;
      background: transparent;
      border-color: transparent;
      color: var(--ui-text-muted, rgba(255, 255, 255, 0.45));
    }

    body:not(.dark-theme) .app-sidebar .tab-button.tab-model-locked,
    body:not(.dark-theme) .app-sidebar .tab-button.tab-model-locked:hover {
      color: var(--ui-text-muted, #9ca3af);
    }

    .app-sidebar .tab-button.active {
      background: var(--ui-accent-soft-bg);
      border: 1px solid transparent;
      color: var(--ui-accent);
      font-weight: 600;
    }

    .app-sidebar .tab-button:focus {
      outline: none;
    }

    .app-sidebar .tab-button:focus-visible {
      outline: 2px solid var(--ui-focus-ring-color);
      outline-offset: 2px;
    }

    .app-sidebar .tab-button svg,
    .app-sidebar .tab-button i {
      width: 18px;
      height: 18px;
      flex-shrink: 0;
      display: block;
    }
    .app-sidebar .tab-button i svg {
      width: 100%;
      height: 100%;
      display: block;
    }

    .app-sidebar .tab-button .sidebar-nav-label {
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    /* Sidebar collapsed: compact floating card, icons only */
    .app-sidebar.collapsed {
      width: var(--ui-sidebar-width-collapsed);
      padding: 8px;
      gap: 0.375rem;
    }

    .app-sidebar.collapsed .sidebar-toggle {
      margin-bottom: 0.25rem;
      justify-content: center;
      padding: var(--ui-nav-item-padding-collapsed);
      min-width: 0;
    }

    .app-sidebar.collapsed .sidebar-toggle i,
    .app-sidebar.collapsed .sidebar-toggle svg {
      display: block;
      margin: 0;
    }

    .app-sidebar.collapsed .sidebar-toggle svg {
      width: 18px;
      height: 18px;
    }

    .app-sidebar.collapsed .tab-button .sidebar-nav-label,
    .app-sidebar.collapsed .sidebar-user-name,
    .app-sidebar.collapsed .sidebar-action-label {
      width: 0;
      overflow: hidden;
      opacity: 0;
      visibility: hidden;
      white-space: nowrap;
    }

    .app-sidebar.collapsed .tab-button {
      justify-content: center;
      padding: var(--ui-nav-item-padding-collapsed);
    }

    .app-sidebar.collapsed .tab-button.active {
      padding: var(--ui-nav-item-padding-collapsed);
      border: 1px solid transparent;
      background: var(--ui-accent-soft-bg);
    }

    .app-sidebar.collapsed .sidebar-user-row {
      justify-content: center;
    }

    .app-sidebar.collapsed .sidebar-actions {
      flex-direction: column;
      align-items: center;
      gap: 0.375rem;
    }

    .app-sidebar.collapsed .sidebar-actions button {
      justify-content: center;
      padding: var(--ui-nav-item-padding-collapsed);
    }

    /* Sidebar footer */
    .app-sidebar-footer {
      margin-top: auto;
      padding-top: 0.75rem;
      border-top: var(--ui-chrome-border);
      display: flex;
      flex-direction: column;
      gap: 0.5rem;
      flex-shrink: 0;
    }

    .sidebar-user-row {
      display: flex;
      align-items: center;
      gap: 0.75rem;
      min-width: 0;
    }

    .sidebar-user-avatar {
      width: 32px;
      height: 32px;
      border-radius: 50%;
      object-fit: cover;
      flex-shrink: 0;
      border: var(--ui-avatar-border);
    }

    .sidebar-user-name {
      font-size: var(--text-label-size);
      font-weight: 500;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      min-width: 0;
      color: inherit;
    }

    .sidebar-actions {
      display: flex;
      flex-direction: column;
      gap: 0.375rem;
    }

    .sidebar-actions button {
      display: flex;
      align-items: center;
      justify-content: flex-start;
      gap: 0.75rem;
      padding: var(--ui-nav-item-padding);
      border: 1px solid transparent;
      border-radius: var(--ui-nav-item-radius);
      background: transparent;
      cursor: pointer;
      font-size: var(--text-label-size);
      font-weight: 500;
      color: var(--ui-text-primary);
      transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
      width: 100%;
      text-align: left;
    }

    .sidebar-actions button:hover {
      background: var(--ui-nav-hover-bg);
      border-color: var(--ui-hover-border-color);
    }

    .sidebar-actions button:active {
      background: var(--ui-sidebar-nav-press);
    }

    .sidebar-actions button:focus {
      outline: none;
    }

    .sidebar-actions button:focus-visible {
      outline: 2px solid var(--ui-focus-ring-color);
      outline-offset: 2px;
    }

    .sidebar-actions button svg,
    .sidebar-actions button i {
      width: 18px;
      height: 18px;
      flex-shrink: 0;
      display: block;
    }
    .sidebar-actions button i svg {
      width: 100%;
      height: 100%;
      display: block;
    }

    .tabs-header {
      display: none;
      gap: 8px;
      padding: 10px 16px;
      background: rgba(255, 255, 255, 0.2);
      backdrop-filter: saturate(180%) blur(40px);
      -webkit-backdrop-filter: saturate(180%) blur(40px);
      border-bottom: 1px solid rgba(255, 255, 255, 0.25);
      z-index: 100;
      font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
    }

    .tab-button {
      flex: 1;
      padding: 8px 12px;
      background: rgba(0, 0, 0, 0.08);
      border: 1px solid rgba(0, 0, 0, 0.1);
      border-radius: 10px;
      cursor: pointer;
      font-size: 13px;
      font-weight: 500;
      color: #1d1d1f;
      transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    }

    .tab-button:hover {
      background: rgba(0, 0, 0, 0.06);
      border-color: rgba(0, 0, 0, 0.12);
    }

    .tab-button.active {
      background: rgba(0, 0, 0, 0.08);
      border-color: rgba(0, 0, 0, 0.12);
      color: #1d1d1f;
      box-shadow: 0 0 0 2px rgba(10, 132, 255, 0.4);
    }

    .tab-content {
      flex: 1;
      min-height: 0;
      position: absolute;
      top: 0;
      bottom: 0;
      left: 0;
      right: 0;
      visibility: hidden;
      opacity: 0;
      pointer-events: none;
      display: flex;
      flex-direction: column;
      transition: opacity 0.22s ease, visibility 0.22s ease;
    }

    .tab-content.active {
      visibility: visible;
      opacity: 1;
      pointer-events: auto;
      position: relative;
      overflow: hidden;
      flex: 1;
      min-height: 0;
      display: flex;
      flex-direction: column;
    }
    
    #tab3.tab-content.active {
      overflow: hidden;
      display: flex;
      flex-direction: column;
      min-height: 0;
    }

    /* ==========================
           TAB 1 (Home) – macOS login style
           ========================== */
    #tab1 {
      display: flex;
      justify-content: center;
      align-items: center;
      background-color: #1a1a1a;
      background-image:
        radial-gradient(900px circle at 25% 18%, var(--ui-accent-soft-bg), transparent 60%),
        radial-gradient(700px circle at 78% 34%, rgba(255, 255, 255, 0.05), transparent 55%),
        linear-gradient(135deg, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0.9));
      background-size: cover;
      background-position: center;
      background-repeat: no-repeat;
      font-family: var(--font-ui);
    }

    body.user-authenticated #tab1 {
      background: transparent;
      background-image: none;
    }

    /* Settings: wallpaper instead of radial/linear gradient shell */
    body.app-bg-wallpaper {
      --app-shell-wallpaper-image: url('/assets/wallpapper/ScopeLoginWallpaper.png?v=5');
      background-color: #050c1c;
      background-image:
        linear-gradient(135deg, rgba(5, 12, 28, 0.28), rgba(5, 12, 28, 0.48)),
        var(--app-shell-wallpaper-image);
      background-size: cover, cover;
      background-position: center, center;
      background-repeat: no-repeat, no-repeat;
      background-attachment: fixed;
    }

    /* Guest login uses the selected wallpaper (default Scope image, or a custom upload). */
    body:not(.user-authenticated) #tab1,
    body:not(.user-authenticated).app-bg-wallpaper #tab1 {
      background-color: #050c1c;
      background-image:
        linear-gradient(90deg, rgba(4, 10, 22, 0.35) 0%, rgba(4, 10, 22, 0.28) 42%, rgba(4, 10, 22, 0.18) 72%, rgba(4, 10, 22, 0.22) 100%),
        var(--app-shell-wallpaper-image);
      background-size: cover, cover;
      background-position: center, center;
      background-repeat: no-repeat, no-repeat;
    }

    body.app-bg-wallpaper #tab1 {
      background-color: #050c1c;
      background-image:
        linear-gradient(180deg, rgba(5, 12, 28, 0.28) 0%, rgba(5, 12, 28, 0.42) 42%, rgba(5, 12, 28, 0.72) 100%),
        var(--app-shell-wallpaper-image);
      background-size: cover, cover;
      background-position: center, center;
      background-repeat: no-repeat, no-repeat;
    }

    body.user-authenticated.app-bg-wallpaper #tab1,
    body.user-authenticated.app-bg-wallpaper .app-main {
      background: transparent;
      background-image: none;
    }

    body.user-authenticated.app-bg-wallpaper .tabs-container {
      background-color: #050c1c;
      background-image:
        linear-gradient(135deg, rgba(5, 12, 28, 0.28), rgba(5, 12, 28, 0.48)),
        var(--app-shell-wallpaper-image);
      background-size: cover, cover;
      background-position: center, center;
      background-repeat: no-repeat, no-repeat;
      background-attachment: fixed;
    }

    body.user-authenticated .tab1-content {
      margin-top: 0;
      margin-bottom: 0;
      position: fixed;
      left: var(--ui-content-inset-left-expanded);
      right: var(--ui-sidebar-viewport-inset);
      top: var(--ui-sidebar-viewport-inset);
      bottom: var(--ui-sidebar-viewport-inset);
      max-height: calc(var(--app-vh) - (2 * var(--ui-sidebar-viewport-inset)));
      transform: none;
      z-index: 5;
      width: auto;
      height: auto;
      min-height: 0;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      padding: 0;
      background:
        linear-gradient(180deg, rgba(22, 32, 48, 0.98) 0%, #101722 40%, #0d131c 100%);
      backdrop-filter: none;
      -webkit-backdrop-filter: none;
      box-shadow: var(--ui-chrome-shadow);
      border: 1px solid rgba(255, 255, 255, 0.08);
      border-radius: var(--radius-xl);
      box-sizing: border-box;
    }
    body.user-authenticated.sidebar-collapsed .tab1-content {
      left: var(--ui-content-inset-left-collapsed);
    }

    .tab1-content {
      width: min(400px, calc(100vw - 32px));
      min-width: 280px;
      flex-shrink: 0;
      padding: 28px 26px 24px;
      margin-bottom: 56vh;
      overflow-y: auto;
      position: relative;
      font-size: var(--text-label-size);
      font-family: var(--font-ui);
      background: rgba(255, 255, 255, 0.92);
      backdrop-filter: saturate(160%) blur(28px);
      -webkit-backdrop-filter: saturate(160%) blur(28px);
      border-radius: var(--radius-xl);
      border: 1px solid rgba(255, 255, 255, 0.55);
      box-shadow:
        0 0 0 1px rgba(16, 24, 40, 0.04) inset,
        0 18px 40px -12px rgba(0, 8, 24, 0.45),
        0 8px 16px -8px rgba(0, 8, 24, 0.28);
      color: var(--ui-text-primary);
    }

    /* Guest login card — centered premium glass modal */
    body:not(.user-authenticated) .tab1-content.login-panel {
      width: min(420px, calc(100vw - 40px));
      margin: 0;
      padding: 32px 30px 28px;
      background: linear-gradient(165deg, rgba(18, 28, 44, 0.88) 0%, rgba(10, 16, 28, 0.92) 100%);
      backdrop-filter: saturate(140%) blur(28px);
      -webkit-backdrop-filter: saturate(140%) blur(28px);
      border: 1px solid rgba(148, 183, 255, 0.18);
      border-radius: 20px;
      box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.04) inset,
        0 24px 56px -16px rgba(0, 0, 0, 0.65),
        0 0 80px -24px rgba(37, 99, 235, 0.35);
      color: #f3f6fb;
    }

    .login-panel .login-panel-header {
      display: flex;
      flex-direction: column;
      align-items: center;
      margin-bottom: 22px;
      text-align: center;
    }

    .login-brand {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 10px;
      margin-bottom: 18px;
    }

    .scope-mark {
      display: block;
      flex-shrink: 0;
      object-fit: contain;
      user-select: none;
      pointer-events: none;
      background: transparent !important;
      border: 0 !important;
      border-radius: 0 !important;
      box-shadow: none !important;
      -webkit-mask-image: none;
      mask-image: none;
    }

    .scope-mark--login {
      width: 36px;
      height: 36px;
      background: transparent !important;
    }

    .login-brand .scope-mark--login {
      background: transparent !important;
      padding: 0;
    }

    .login-brand-name {
      font-size: 14px;
      font-weight: 700;
      letter-spacing: 0.22em;
      text-transform: uppercase;
      color: #e8eef8;
    }

    .login-panel .login-panel-header h3 {
      margin: 0;
      font-size: clamp(1.35rem, 1.2rem + 0.5vw, 1.6rem);
      font-weight: 650;
      letter-spacing: var(--tracking-tight);
      color: #f8fafc;
    }

    .login-panel-subtitle {
      margin: 8px 0 0;
      font-size: var(--text-body);
      color: rgba(203, 213, 225, 0.78);
      line-height: 1.45;
      max-width: 28ch;
    }

    body:not(.user-authenticated) .tab1-content {
      margin-top: 0;
      margin-bottom: 0;
    }

    /* Guest login: panel centered on screen */
    body:not(.user-authenticated) #tab1 {
      opacity: 0;
      transform: translateY(10px);
      transition: opacity var(--motion-smooth), transform var(--motion-smooth);
      align-items: center;
      justify-content: center;
      padding: 24px 16px;
      box-sizing: border-box;
    }

    body:not(.user-authenticated) #tab1.login-tab--entrance-ready {
      opacity: 1;
      transform: translateY(0);
    }

    @media (prefers-reduced-motion: reduce) {
      body:not(.user-authenticated) #tab1 {
        opacity: 1;
        transform: none;
        transition: none;
      }
    }

    body:not(.user-authenticated) .login-panel .input-with-icon .input-icon,
    body:not(.user-authenticated) .login-panel .input-with-icon svg {
      color: rgba(186, 206, 240, 0.7);
    }

    body:not(.user-authenticated) .login-panel .user-name-input,
    body:not(.user-authenticated) .login-panel .user-password-input {
      background: rgba(255, 255, 255, 0.06);
      border: 1px solid rgba(255, 255, 255, 0.12);
      box-shadow: none;
      color: #f8fafc;
      border-radius: 12px;
      padding: 12px 14px 12px 40px;
      min-height: 46px;
    }

    body:not(.user-authenticated) .login-panel .user-name-input::placeholder,
    body:not(.user-authenticated) .login-panel .user-password-input::placeholder {
      color: rgba(203, 213, 225, 0.45);
    }

    body:not(.user-authenticated) .login-panel .user-name-input:focus,
    body:not(.user-authenticated) .login-panel .user-password-input:focus {
      background: rgba(255, 255, 255, 0.09);
      border-color: rgba(106, 161, 255, 0.55);
      box-shadow: 0 0 0 3px rgba(106, 161, 255, 0.22);
      outline: none;
    }

    body:not(.user-authenticated) .login-panel .login-btn {
      margin-top: 18px;
      min-height: 48px;
      border-radius: 12px;
      background: linear-gradient(180deg, #3b82f6, #1d4ed8);
      box-shadow: 0 10px 24px -10px rgba(37, 99, 235, 0.7), 0 1px 0 rgba(255, 255, 255, 0.18) inset;
    }

    body:not(.user-authenticated) .login-panel .input-with-icon {
      margin-bottom: 12px;
    }

    body:not(.user-authenticated) .login-panel .user-profile {
      margin-bottom: 0;
    }

    .login-panel .user-profile {
      display: flex;
      flex-direction: column;
      align-items: stretch;
      gap: 0;
      margin-bottom: 20px;
      padding: 0;
      background: transparent;
      position: relative;
    }

    .user-photo-container {
      position: relative;
      flex-shrink: 0;
      margin-bottom: 18px;
    }

    .user-photo {
      width: 72px;
      height: 72px;
      border-radius: 50%;
      object-fit: cover;
      border: 2px solid rgba(255, 255, 255, 0.5);
      cursor: pointer;
      transition: border-color 0.2s ease, transform 0.2s ease;
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }

    .user-photo:hover {
      border-color: rgba(255, 255, 255, 0.8);
    }

    .user-photo-input {
      display: none;
    }

    .user-info {
      width: 100%;
      min-width: 0;
    }

    .login-panel .input-with-icon {
      position: relative;
      margin-bottom: 8px;
    }

    .login-panel .input-with-icon:last-of-type {
      margin-bottom: 0;
    }

    .login-panel .input-with-icon .input-icon,
    .login-panel .input-with-icon svg {
      position: absolute;
      left: 10px;
      top: 50%;
      transform: translateY(-50%);
      width: 16px;
      height: 16px;
      color: rgba(0, 0, 0, 0.4);
      pointer-events: none;
    }

    .login-panel .user-name-input,
    .login-panel .user-password-input {
      width: 100%;
      padding: 10px 12px 10px 36px;
      font-size: var(--text-body);
      font-weight: 400;
      color: var(--ui-text-primary);
      border: var(--ui-chrome-border);
      border-radius: var(--radius-md);
      margin: 0;
      background: rgba(0, 0, 0, 0.04);
      transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
      box-sizing: border-box;
      box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.02) inset;
    }

    .login-panel .user-password-input {
      margin-bottom: 0;
    }

    .login-panel .user-name-input::placeholder,
    .login-panel .user-password-input::placeholder {
      color: rgba(0, 0, 0, 0.35);
    }

    .login-panel .user-name-input:focus,
    .login-panel .user-password-input:focus {
      outline: none;
      background: rgba(0, 0, 0, 0.06);
      border-color: rgba(37, 99, 235, 0.2);
      box-shadow: 0 0 0 2px var(--ui-focus-ring-color);
    }

    #tab1 .upload-section {
      display: none;
      margin: 20px 0 0;
      padding: 0;
      background: transparent;
    }

    body.user-authenticated #tab1 .upload-section {
      display: block;
      margin-top: 0;
    }

    #tab1 .home-project-context {
      display: none;
      margin: 0 0 16px;
      padding: 16px 18px;
      border-radius: var(--radius-xl);
      border: 1px solid rgba(91, 156, 255, 0.28);
      background:
        linear-gradient(120deg, rgba(91, 156, 255, 0.14), rgba(91, 156, 255, 0.03) 55%),
        rgba(18, 26, 38, 0.88);
      box-shadow: var(--shadow-sm);
      max-width: 980px;
    }

    body.user-authenticated #tab1 .home-project-context {
      display: block;
    }

    #tab1 .home-orcamento {
      margin: 0 0 12px;
      padding: 14px 16px;
      border-radius: var(--ui-nav-item-radius);
      border: 1px solid rgba(91, 156, 255, 0.28);
      background:
        linear-gradient(135deg, rgba(91, 156, 255, 0.12), transparent 58%),
        var(--ui-chrome-surface);
      box-shadow: var(--ui-chrome-shadow);
      max-width: 980px;
      width: 100%;
      box-sizing: border-box;
    }

    .home-orcamento-head {
      display: flex;
      align-items: baseline;
      justify-content: space-between;
      gap: 10px;
    }

    .home-orcamento-head-actions {
      display: inline-flex;
      align-items: center;
      gap: 10px;
      flex-shrink: 0;
    }

    .home-orcamento-title {
      font-size: 13px;
      font-weight: 700;
      color: #bfdbfe;
    }

    .home-project-label {
      display: block;
      font-size: 14px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.04em;
      color: #93c5fd;
      opacity: 1;
      margin-bottom: 8px;
    }

    .home-orcamento-status {
      font-size: 11px;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.04em;
    }

    .home-orcamento-status.is-ready { color: #2e7d32; }
    .home-orcamento-status.is-missing { color: #c62828; }
    body.dark-theme .home-orcamento-status.is-ready { color: #81c784; }
    body.dark-theme .home-orcamento-status.is-missing { color: #ff8a80; }

    .home-orcamento-meta {
      margin: 8px 0 0;
      font-size: 12px;
      line-height: 1.4;
      color: var(--ui-text-muted);
    }

    .home-orcamento-file-link {
      color: var(--ui-accent, #4ea1ff);
      text-decoration: underline;
      text-underline-offset: 2px;
      cursor: pointer;
      font-weight: 600;
    }

    .home-orcamento-file-link:hover,
    .home-orcamento-file-link:focus-visible {
      color: var(--ui-accent-hover, #7cbcff);
      outline: none;
    }

    .home-orcamento-meta:not(.has-openable-file) .home-orcamento-file-link {
      color: var(--ui-text-muted);
      font-weight: 500;
    }

    .home-orcamento-meta.is-missing,
    .home-orcamento:has(.home-orcamento-status.is-missing) .home-orcamento-meta {
      color: #ff3b3b !important;
      font-weight: 700;
      opacity: 1;
    }

    #homePanelProject .home-orcamento-meta.is-missing {
      color: #ff3b3b !important;
      font-weight: 700;
      opacity: 1;
    }

    .home-orcamento-actions {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      margin-top: 12px;
      align-items: center;
    }

    .home-orcamento-import-row {
      display: inline-flex;
      align-items: center;
      gap: 10px;
      flex: 1 1 220px;
      min-width: 0;
    }

    .home-orcamento-import-row .home-orcamento-btn {
      flex: 1 1 auto;
    }

    .home-orcamento-btn {
      flex: 1 1 160px;
    }

    .home-orcamento-file-row {
      display: grid;
      gap: 8px;
      margin-top: 12px;
    }

    .home-orcamento-file-row .home-inline-actions {
      flex-wrap: wrap;
    }

    .home-orcamento-file-row .home-field-label {
      word-break: break-all;
      margin-top: 4px;
      text-transform: none;
      letter-spacing: normal;
    }

    .home-orcamento-sheet-block {
      margin: 10px 0 4px;
      max-width: 420px;
    }

    .construction-obra-views .chip.is-locked {
      opacity: 0.55;
    }

    .home-project-select {
      width: 100%;
      max-width: 100%;
      padding: 10px 12px;
      border-radius: 8px;
      border: 1px solid rgba(0, 0, 0, 0.1);
      background: rgba(255, 255, 255, 0.9);
      font-family: var(--font-ui);
      font-size: 14px;
      color: var(--ui-text-primary);
    }

    body.dark-theme .home-project-select {
      background: rgba(15, 23, 42, 0.45);
      border-color: rgba(91, 156, 255, 0.28);
      color: var(--ui-text-primary);
    }

    .home-project-hint {
      display: none;
      margin: 10px 0 0;
      font-size: 12px;
      opacity: 0.75;
      line-height: 1.4;
    }

    .home-project-hint--error {
      color: #c62828;
    }

    body.dark-theme .home-project-hint--error {
      color: #ff8a80;
    }

    .home-project-row {
      display: flex;
      gap: 6px;
      align-items: center;
    }
    .home-project-row .home-project-select { flex: 1; min-width: 0; }

    .home-project-icon-btn {
      flex-shrink: 0;
      width: 36px; height: 36px;
      display: flex; align-items: center; justify-content: center;
      border: 1px solid rgba(0,0,0,0.1);
      border-radius: 8px;
      background: rgba(255,255,255,0.9);
      cursor: pointer;
      color: var(--ui-text-primary);
      font-size: 18px; line-height: 1;
      transition: background .15s, border-color .15s;
    }
    .home-project-icon-btn:hover { background: rgba(0,0,0,0.05); }
    .home-project-icon-btn.danger { color: #c62828; }
    .home-project-icon-btn.danger:hover { background: rgba(198,40,40,0.08); }
    body.dark-theme .home-project-icon-btn {
      background: rgba(255,255,255,0.06);
      border-color: rgba(255,255,255,0.1);
    }
    body.dark-theme .home-project-icon-btn:hover { background: rgba(255,255,255,0.12); }
    body.dark-theme .home-project-icon-btn.danger { color: #ff8a80; }

    .home-project-create-row {
      display: none;
      gap: 6px;
      align-items: center;
      margin-top: 8px;
    }
    .home-project-create-row.show { display: flex; }
    .home-project-create-input {
      flex: 1; min-width: 0;
      padding: 8px 10px;
      border-radius: 8px;
      border: 1px solid rgba(0,0,0,0.1);
      background: rgba(255,255,255,0.9);
      font-family: var(--font-ui);
      font-size: 13px;
      color: var(--ui-text-primary);
    }
    body.dark-theme .home-project-create-input {
      background: rgba(255,255,255,0.06);
      border-color: rgba(255,255,255,0.1);
      color: var(--ui-text-primary);
    }
    .home-project-create-confirm {
      flex-shrink: 0;
      padding: 8px 14px;
      border: none;
      border-radius: 8px;
      background: var(--ui-accent);
      color: #fff;
      font-size: 13px;
      font-weight: 600;
      cursor: pointer;
    }
    .home-project-create-confirm:hover { filter: brightness(1.1); }

    .home-replace-model-btn { margin-top: 0; }

    .home-replace-modal-content {
      max-width: 480px;
    }

    .home-replace-hint {
      margin: 0 0 14px;
      font-size: 0.9rem;
      color: var(--ui-muted-text, #666);
      line-height: 1.45;
    }

    body.dark-theme .home-replace-hint {
      color: rgba(255, 255, 255, 0.72);
    }

    .home-replace-fields {
      display: flex;
      flex-direction: column;
      gap: 12px;
      margin-bottom: 12px;
    }

    .home-replace-field {
      display: flex;
      flex-direction: column;
      gap: 6px;
      font-size: 0.9rem;
      font-weight: 600;
    }

    .home-replace-summary {
      min-height: 1.2em;
      margin: 0 0 12px;
      font-size: 0.88rem;
      color: var(--ui-muted-text, #363d4d);
    }

    .home-replace-confirm-btn {
      font-weight: 600;
    }

    /* --- Home Hub (project details after login) --- */
    .home-hub {
      display: none;
      margin-top: 2px;
    }
    body.user-authenticated .home-hub { display: block; }

    .home-hub-stats {
      display: flex;
      gap: 0;
      margin-bottom: 16px;
      border-radius: var(--radius-lg);
      overflow: hidden;
      border: 1px solid rgba(91, 156, 255, 0.28);
      box-shadow: var(--shadow-xs);
      background:
        linear-gradient(180deg, rgba(91, 156, 255, 0.1), transparent 70%),
        rgba(0, 0, 0, 0.18);
    }
    .home-hub-stat {
      flex: 1;
      display: flex;
      flex-direction: column;
      align-items: center;
      padding: 18px 10px 16px;
      background: transparent;
      border-right: 1px solid rgba(91, 156, 255, 0.16);
    }
    .home-hub-stat:last-child { border-right: none; }
    .home-hub-stat-value {
      font-size: 26px;
      font-weight: 700;
      line-height: 1.15;
      letter-spacing: -0.02em;
      font-variant-numeric: tabular-nums;
      color: #9ec5ff;
    }
    .home-hub-stat-label {
      font-size: 11px;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      color: #93c5fd;
      margin-top: 5px;
      opacity: 0.9;
    }

    body.dark-theme .home-hub-stats {
      border-color: rgba(91, 156, 255, 0.28);
    }
    body.dark-theme .home-hub-stat {
      background: transparent;
      border-right-color: rgba(91, 156, 255, 0.16);
    }

    .home-hub-models-title {
      font-size: 11px;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.04em;
      color: #93c5fd;
      opacity: 1;
      margin-bottom: 8px;
    }

    .home-hub-models-list {
      display: flex;
      flex-direction: column;
      gap: 6px;
      margin-bottom: 14px;
      max-height: 220px;
      overflow-y: auto;
      color-scheme: dark;
      scrollbar-width: thin;
      scrollbar-color: rgba(180, 180, 190, 0.85) rgba(255, 255, 255, 0.08);
    }
    .home-hub-models-list::-webkit-scrollbar {
      width: 8px;
    }
    .home-hub-models-list::-webkit-scrollbar-track {
      background: rgba(255, 255, 255, 0.06);
      border-radius: 8px;
    }
    .home-hub-models-list::-webkit-scrollbar-thumb {
      background: rgba(180, 180, 190, 0.75);
      border-radius: 8px;
    }
    .home-hub-models-list::-webkit-scrollbar-thumb:hover {
      background: rgba(210, 210, 220, 0.9);
    }

    .home-hub-model-card {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 9px 12px;
      border-radius: 8px;
      border: 1px solid rgba(91, 156, 255, 0.2);
      background: rgba(91, 156, 255, 0.06);
      transition: background .12s, border-color .12s;
    }
    .home-hub-model-card:hover {
      background: rgba(91, 156, 255, 0.12);
      border-color: rgba(91, 156, 255, 0.4);
    }

    body.dark-theme .home-hub-model-card {
      border-color: rgba(91, 156, 255, 0.2);
      background: rgba(91, 156, 255, 0.06);
    }
    body.dark-theme .home-hub-model-card:hover {
      background: rgba(91, 156, 255, 0.12);
      border-color: rgba(91, 156, 255, 0.4);
    }

    .home-hub-model-icon {
      flex-shrink: 0;
      width: 32px; height: 32px;
      display: flex; align-items: center; justify-content: center;
      border-radius: 8px;
      background: var(--ui-accent-muted-bg);
      color: var(--ui-accent);
    }
    .home-hub-model-icon svg {
      width: 16px; height: 16px;
    }
    .home-hub-model-delete {
      flex-shrink: 0;
      border: 1px solid rgba(255, 90, 90, 0.45);
      background: transparent;
      color: #ff8d8d;
      border-radius: 6px;
      padding: 4px 8px;
      font-size: 12px;
      cursor: pointer;
    }
    .home-hub-model-delete:hover {
      background: rgba(255, 90, 90, 0.12);
    }

    .home-hub-model-info {
      flex: 1; min-width: 0;
    }
    .home-hub-model-name {
      font-size: 13px;
      font-weight: 500;
      line-height: 1.3;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .home-hub-model-meta {
      font-size: 11px;
      opacity: 0.55;
      margin-top: 1px;
    }

    .home-hub-model-badge {
      flex-shrink: 0;
      font-size: 10px;
      font-weight: 600;
      padding: 3px 8px;
      border-radius: 999px;
      text-transform: uppercase;
      letter-spacing: 0.03em;
    }
    .home-hub-model-badge.success {
      background: rgba(52,199,89,0.12);
      color: #1b8a3e;
    }
    .home-hub-model-badge.inprogress {
      background: rgba(37, 99, 235,0.12);
      color: #1d4ed8;
    }
    .home-hub-model-badge.failed {
      background: rgba(255,59,48,0.12);
      color: #c62828;
    }
    body.dark-theme .home-hub-model-badge.success {
      background: rgba(52,199,89,0.18);
      color: #6ee7a0;
    }
    body.dark-theme .home-hub-model-badge.inprogress {
      background: rgba(106, 161, 255,0.18);
      color: #7dc4ff;
    }
    body.dark-theme .home-hub-model-badge.failed {
      background: rgba(255,69,58,0.18);
      color: #ff8a80;
    }

    .home-hub-empty {
      text-align: center;
      padding: 18px 10px;
      font-size: 12px;
      opacity: 0.5;
    }

    body.user-authenticated #tab1 .user-profile,
    body.user-authenticated .login-panel .login-panel-header {
      display: none;
    }
    body.user-authenticated #tab1 .login-panel {
      display: flex;
      flex-direction: column;
      height: 100%;
      min-height: 0;
    }

    /* Home workspace (Empresa / Equipas / Projeto) */
    #homeWorkspace {
      display: none;
      width: 100%;
      flex: 1 1 auto;
      min-height: 0;
      margin: 0;
      text-align: left;
      overflow: hidden;
      flex-direction: row;
      align-items: stretch;
      gap: 12px;
      padding: 22px 26px 20px;
      box-sizing: border-box;
    }
    body.user-authenticated #homeWorkspace {
      display: flex;
    }
    .home-workspace-main {
      flex: 1 1 auto;
      min-width: 0;
      min-height: 0;
      display: flex;
      flex-direction: column;
      overflow: hidden;
    }
    .home-workspace-header {
      flex: 0 0 auto;
      margin: 0 0 18px;
      padding: 16px 18px;
      border-radius: var(--radius-xl);
      border: 1px solid rgba(91, 156, 255, 0.3);
      background:
        linear-gradient(120deg, rgba(91, 156, 255, 0.18), rgba(91, 156, 255, 0.04) 55%),
        rgba(18, 26, 38, 0.88);
      box-shadow: var(--shadow-sm);
    }
    .home-workspace-brand {
      position: relative;
      display: inline-flex;
      align-items: center;
      justify-content: flex-start;
      gap: 14px;
      margin: 0;
      min-height: 56px;
    }
    .scope-mark--home {
      width: 56px;
      height: 56px;
      filter: none;
    }
    .home-workspace-brand-name {
      position: relative;
      z-index: 1;
      margin: 0;
      font-size: clamp(1.85rem, 1.4rem + 1.1vw, 2.35rem);
      font-weight: 700;
      letter-spacing: 0.18em;
      text-transform: uppercase;
      color: #f8fafc;
      line-height: 1;
      text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
    }
    .home-workspace-subtitle {
      margin: 10px 0 0;
      font-size: var(--text-body);
      color: #93c5fd;
      line-height: 1.45;
      max-width: 42rem;
    }
    .home-inner-tabs {
      display: inline-flex;
      gap: 4px;
      margin: 0 auto 18px;
      flex-wrap: wrap;
      flex: 0 0 auto;
      padding: 4px;
      border-radius: var(--radius-lg);
      background: rgba(91, 156, 255, 0.08);
      border: 1px solid rgba(91, 156, 255, 0.28);
      width: fit-content;
      max-width: 100%;
      align-self: center;
    }
    .home-inner-tab {
      position: relative;
      border: 1px solid transparent;
      background: transparent;
      color: rgba(226, 232, 240, 0.72);
      border-radius: var(--radius-md);
      padding: 9px 16px;
      cursor: pointer;
      font-size: var(--text-body);
      font-weight: 560;
      transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    }
    .home-inner-tab:hover {
      color: #f8fafc;
      background: rgba(255, 255, 255, 0.05);
    }
    .home-inner-tab:focus-visible {
      outline: none;
      box-shadow: 0 0 0 2px var(--ui-focus-ring-color);
    }
    .home-inner-tab.active {
      background: linear-gradient(180deg, rgba(56, 120, 240, 0.42), rgba(37, 99, 235, 0.28));
      border-color: rgba(147, 197, 253, 0.35);
      color: #fff;
      box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08) inset;
    }
    .home-inner-tabs-split {
      width: 1px;
      align-self: stretch;
      margin: 4px 6px;
      background: rgba(255, 255, 255, 0.14);
    }
    .home-inner-tab--secondary {
      color: rgba(226, 232, 240, 0.58);
    }
    .home-inner-tab--secondary.active {
      color: #fff;
    }
    #homeProjectAfterSelect[hidden] {
      display: none !important;
    }
    #homeProjectAfterSelect {
      display: flex;
      flex-direction: column;
      width: 100%;
    }
    .home-project-need-select,
    .home-project-current-banner {
      margin: 0 0 16px;
      padding: 14px 16px;
      border-radius: var(--radius-lg);
      border: 1px solid rgba(255, 255, 255, 0.08);
      background: rgba(18, 26, 38, 0.72);
      color: rgba(226, 232, 240, 0.9);
      font-size: var(--text-body);
      line-height: 1.45;
    }
    .home-project-need-select[hidden],
    .home-project-current-banner[hidden] {
      display: none !important;
    }
    .home-equipas-summary {
      margin: 0 0 12px;
      padding: 14px 16px;
      border-radius: var(--radius-xl);
      border: 1px solid rgba(255, 255, 255, 0.08);
      background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.02)),
        rgba(18, 26, 38, 0.88);
      box-sizing: border-box;
    }
    .home-equipas-summary .home-card-title {
      margin: 0 0 6px;
      font-size: 0.95rem;
    }
    .home-equipas-summary-row {
      display: flex;
      align-items: flex-end;
      justify-content: space-between;
      gap: 16px;
      flex-wrap: wrap;
    }
    .home-equipas-summary-copy {
      min-width: 0;
      flex: 1 1 240px;
    }
    .home-equipas-summary-line {
      margin: 0;
      font-size: var(--text-body);
      line-height: 1.4;
      color: rgba(226, 232, 240, 0.88);
    }
    .home-equipas-summary-line + .home-equipas-summary-line {
      margin-top: 4px;
    }
    .home-equipas-summary-chips {
      list-style: none;
      margin: 8px 0 0;
      padding: 0;
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
    }
    .home-equipas-summary-chips[hidden] {
      display: none !important;
    }
    .home-equipas-summary-chips li {
      margin: 0;
      padding: 4px 10px;
      border-radius: 999px;
      border: 1px solid rgba(147, 197, 253, 0.28);
      background: rgba(37, 99, 235, 0.18);
      color: #dbeafe;
      font-size: 0.82rem;
      font-weight: 600;
    }
    #homeGoToProjetosBtn {
      margin-top: 0;
      flex: 0 0 auto;
    }
    #homeGoToProjetosBtn:disabled {
      opacity: 0.55;
      cursor: not-allowed;
    }
    .home-collapse-btn {
      width: 28px;
      height: 28px;
      border: 0;
      border-radius: 6px;
      font-size: 16px;
      line-height: 1;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
      padding: 0;
      background: rgba(255, 255, 255, 0.08);
      color: inherit;
    }
    .home-collapse-btn:hover {
      background: rgba(255, 255, 255, 0.14);
    }
    .home-collapsible.is-collapsed {
      padding-bottom: 14px;
    }
    .home-collapsible.is-collapsed .home-collapse-body {
      display: none;
    }
    .home-collapsible.is-collapsed .home-card-header-row {
      margin-bottom: 0;
    }
    .home-team-card.is-collapsed .home-team-card-body {
      display: none;
    }
    .home-team-card.is-collapsed .home-team-card-head {
      margin-bottom: 0;
      padding-bottom: 0;
      border-bottom: none;
    }
    .home-team-card-head {
      cursor: pointer;
    }
    .home-ready-list {
      list-style: none;
      margin: 0 0 16px;
      padding: 0;
    }
    .home-ready-item {
      display: flex;
      gap: 10px;
      align-items: flex-start;
      padding: 8px 0;
      border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    }
    .home-ready-item:last-child {
      border-bottom: none;
    }
    .home-ready-mark {
      width: 8px;
      height: 8px;
      border-radius: 50%;
      margin-top: 6px;
      flex-shrink: 0;
      background: rgba(255, 255, 255, 0.35);
    }
    .home-ready-item.is-ready .home-ready-mark {
      background: #81c784;
    }
    .home-ready-item.is-missing .home-ready-mark {
      background: #ff8a80;
    }
    .home-ready-text {
      font-size: var(--text-body);
      line-height: 1.45;
      color: rgba(226, 232, 240, 0.88);
    }
    #homePanelProject .home-readiness,
    #homePanelProject .home-models-block {
      max-width: none;
      width: min(100%, 980px);
      margin: 0 0 16px;
      min-height: 0;
      box-sizing: border-box;
    }
    #homePanelProject .home-models-block .home-hub,
    #homePanelProject .home-models-block .upload-section {
      width: 100%;
      max-width: none;
      margin: 0;
    }
    #homePanelProject .home-models-block .upload-section {
      margin-top: 12px;
    }
    .home-inner-panel {
      flex: 1 1 auto;
      min-height: 0;
      overflow-x: hidden;
      overflow-y: auto;
      overscroll-behavior: contain;
      scrollbar-width: thin;
      scrollbar-color: #2563eb #f1f1f1;
    }
    /* Same scrollbar as Auditoria / Controlo (.tab3-content) */
    .home-inner-panel::-webkit-scrollbar {
      width: 10px;
    }
    .home-inner-panel::-webkit-scrollbar-track {
      background: #f1f1f1;
      border-radius: 10px;
    }
    .home-inner-panel::-webkit-scrollbar-thumb {
      background: linear-gradient(to bottom, #2563eb, #1d4ed8);
      border-radius: 10px;
    }
    .home-inner-panel::-webkit-scrollbar-thumb:hover {
      background: linear-gradient(to bottom, #1d4ed8, #1565C0);
    }
    .home-inner-panel[hidden] { display: none !important; }
    .home-card {
      border: 1px solid rgba(91, 156, 255, 0.26);
      background:
        linear-gradient(160deg, rgba(91, 156, 255, 0.12), transparent 55%),
        rgba(18, 26, 38, 0.88);
      box-shadow: var(--shadow-sm);
      border-radius: var(--radius-xl);
      padding: 22px 22px 20px;
      margin-top: 0;
      min-height: 0;
      box-sizing: border-box;
    }
    .home-card-title {
      margin: 0 0 14px;
      font-size: var(--text-subtitle);
      font-weight: 650;
      letter-spacing: var(--tracking-tight);
      color: #bfdbfe;
    }
    .home-card-title .home-card-title-alert-dot,
    .home-field-label .home-card-title-alert-dot {
      display: inline-block;
      width: 8px;
      height: 8px;
      margin-left: 8px;
      vertical-align: middle;
      border-radius: 50%;
      background: #ff3b3b;
      box-shadow:
        0 0 0 2px rgba(16, 23, 34, 0.95),
        0 0 10px rgba(255, 59, 59, 0.65);
    }
    .home-card-title .home-card-title-alert-dot[hidden],
    .home-field-label .home-card-title-alert-dot[hidden] {
      display: none !important;
    }
    .home-card-header-row {
      display: flex;
      justify-content: space-between;
      gap: 12px;
      align-items: center;
      flex-wrap: wrap;
      margin-bottom: 10px;
    }
    .home-card-header-row .home-card-title {
      margin: 0;
    }
    .home-company-grid {
      display: grid;
      grid-template-columns: 240px minmax(320px, 1fr);
      gap: 28px;
      align-items: start;
    }
    @media (max-width: 640px) {
      .home-company-grid { grid-template-columns: 1fr; }
    }
    .home-company-photo-preview {
      width: 220px;
      height: 220px;
      border-radius: var(--radius-xl);
      border: 1px dashed rgba(91, 156, 255, 0.4);
      background: rgba(91, 156, 255, 0.06) center/cover no-repeat;
      box-shadow: inset 0 0 0 1px rgba(91, 156, 255, 0.08);
    }
    .home-company-photo-preview.has-photo {
      border-style: solid;
    }
    .home-company-photo-actions {
      display: flex;
      flex-direction: column;
      gap: 10px;
      margin-top: 14px;
      max-width: 220px;
    }
    #homePanelCompany .home-card-title {
      font-size: 1.35rem;
      margin-bottom: 22px;
    }
    #homePanelCompany .home-field-label {
      font-size: 12px;
      margin-bottom: 8px;
    }
    #homePanelCompany .home-primary-btn,
    #homePanelCompany .home-secondary-btn {
      padding: 12px 16px;
      font-size: 1rem;
    }
    #homePanelCompany {
      padding: 8px 16px 24px;
      box-sizing: border-box;
      display: flex;
      flex-direction: column;
      align-items: center;
    }
    #homePanelCompany > .home-card {
      width: min(100%, 980px);
      margin: 0 auto;
      min-height: 0;
      box-sizing: border-box;
    }
    #homePanelCompany .home-company-grid {
      justify-content: center;
      margin: 0 auto;
      max-width: 920px;
      width: 100%;
    }
    #homePanelCompany .home-company-fields {
      min-width: 0;
      width: 100%;
    }
    #homePanelCompany .home-text-input {
      padding: 14px 16px;
      font-size: 1.05rem;
      min-height: 48px;
      width: 100%;
      max-width: none;
      box-sizing: border-box;
    }
    #homePanelCompany .home-card-title {
      text-align: center;
    }
    #homeCompanyNameMeta {
      margin-top: 6px;
      font-size: 0.85rem;
      opacity: 0.7;
    }
    .home-field-label {
      display: block;
      font-size: 11px;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.04em;
      opacity: 0.75;
      margin-bottom: 6px;
    }
    .home-text-input {
      width: 100%;
      padding: 10px 12px;
      border-radius: 8px;
      border: 1px solid rgba(91, 156, 255, 0.28);
      background: rgba(15, 23, 42, 0.35);
      color: inherit;
      box-sizing: border-box;
    }
    .home-text-input:focus {
      outline: none;
      border-color: rgba(91, 156, 255, 0.55);
      box-shadow: 0 0 0 2px rgba(91, 156, 255, 0.2);
    }
    .home-text-input--sm { max-width: 160px; }
    .home-primary-btn,
    .home-secondary-btn {
      border-radius: var(--radius-md);
      padding: 10px 14px;
      cursor: pointer;
      border: 1px solid transparent;
      font-weight: 600;
      transition: background 0.15s ease, border-color 0.15s ease, filter 0.15s ease, transform 0.12s ease;
    }
    .home-primary-btn {
      background: linear-gradient(180deg, #3b7cff, #1d4ed8);
      color: #fff;
      box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18), 0 1px 3px rgba(37, 99, 235, 0.28);
    }
    .home-primary-btn:hover {
      filter: brightness(1.05);
    }
    .home-secondary-btn {
      background: rgba(91, 156, 255, 0.1);
      border-color: rgba(91, 156, 255, 0.3);
      color: #dbeafe;
    }
    .home-secondary-btn:hover {
      background: rgba(91, 156, 255, 0.18);
      border-color: rgba(91, 156, 255, 0.5);
    }
    .home-secondary-btn.danger { color: #ff8a80; }
    .home-inline-hint {
      margin: 8px 0 0;
      font-size: 0.86rem;
      opacity: 0.8;
    }
    .home-inline-hint.is-error {
      color: #ff3b3b !important;
      opacity: 1;
      font-weight: 600;
    }
    body.dark-theme .home-inline-hint.is-error {
      color: #ff5252 !important;
    }
    /* Viewer: never show selection filter panel */
    body.pg-role-viewer .pg-sel-filter,
    body.pg-role-viewer #pgSelectionFilter {
      display: none !important;
    }
    /* Viewer: no Execução tab in selection props panel */
    body.pg-role-viewer #propsPanel .props-panel-tab[data-props-tab="execucao"],
    body.pg-role-viewer #propsPanel #propsPaneExecucao {
      display: none !important;
    }
    /* Viewer: no orçamento alert row on Início → Projetos */
    body.pg-role-viewer #homePanelProject .home-project-alert-row {
      display: none !important;
    }
    /* Viewer legend: Em Obra + Concluído only */
    body.pg-role-viewer .viewer-state-legend [data-legend-group="fin"],
    body.pg-role-viewer .viewer-state-legend [data-legend="initial"],
    body.pg-role-viewer .viewer-state-legend--viewer [data-legend-group="fin"],
    body.pg-role-viewer .viewer-state-legend--viewer [data-legend="initial"] {
      display: none !important;
    }
    #homeDocFolderPath.is-path-invalid,
    .doc-folder-config input.is-path-invalid {
      border-color: #ff3b3b !important;
      box-shadow: 0 0 0 1px rgba(255, 59, 59, 0.35);
    }
    .home-teams-toolbar { display: flex; gap: 8px; flex-wrap: wrap; }
    .home-teams-list {
      display: grid;
      gap: 10px;
      margin-top: 12px;
    }
    .home-obra-access-card { margin-top: 16px; }
    .home-obra-access-card .home-project-select { width: 100%; max-width: 420px; margin: 8px 0 12px; }
    .home-obra-access-people {
      display: grid;
      gap: 8px;
      margin: 4px 0 12px;
    }
    .home-obra-access-person {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 8px 10px;
      border: 1px solid rgba(91, 156, 255, 0.24);
      border-radius: var(--radius-lg);
    }
    .home-obra-access-person.is-inactive { opacity: 0.65; }
    .home-obra-access-person-copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
    .home-obra-access-person-meta { font-size: 12px; opacity: 0.75; }
    .home-obra-access-actions { margin-bottom: 8px; }
    .home-team-card {
      border: 1px solid rgba(91, 156, 255, 0.24);
      border-radius: var(--radius-lg);
      padding: 16px 18px;
      background:
        linear-gradient(160deg, rgba(91, 156, 255, 0.12), transparent 55%),
        rgba(0, 0, 0, 0.18);
      box-shadow: 0 1px 0 rgba(255,255,255,0.04) inset;
      transition: border-color 0.15s ease, background 0.15s ease;
    }
    .home-team-card:hover {
      border-color: rgba(91, 156, 255, 0.45);
      background:
        linear-gradient(160deg, rgba(91, 156, 255, 0.16), transparent 55%),
        rgba(0, 0, 0, 0.16);
    }
    .home-team-card-head {
      display: flex;
      justify-content: flex-start;
      align-items: center;
      gap: 12px;
      margin-bottom: 12px;
      padding-bottom: 10px;
      border-bottom: 1px solid rgba(91, 156, 255, 0.2);
    }
    .home-team-card-head strong {
      flex: 1 1 auto;
      min-width: 0;
      font-size: 1.15rem;
      font-weight: 700;
      letter-spacing: 0.01em;
      color: #bfdbfe;
    }
    .home-team-count {
      flex: 0 0 auto;
      margin-left: auto;
      font-size: 0.82rem;
      font-weight: 600;
      opacity: 0.85;
      padding: 3px 8px;
      border-radius: 999px;
      border: 1px solid rgba(96, 165, 250, 0.35);
      background: rgba(37, 99, 235, 0.18);
      color: #bfdbfe;
    }
    .home-team-preview {
      margin: 0;
      font-size: 0.9rem;
      opacity: 0.8;
      line-height: 1.4;
      word-break: break-word;
    }
    .home-team-preview-list {
      list-style: none;
      margin: 0;
      padding: 0;
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      font-size: 0.88rem;
    }
    .home-team-preview-list li {
      margin: 0;
      padding: 5px 10px;
      max-width: 100%;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      border: 1px solid rgba(255,255,255,0.22);
      border-radius: 8px;
      background: rgba(255,255,255,0.04);
      color: rgba(255,255,255,0.92);
      box-sizing: border-box;
    }
    .home-team-actions {
      display: flex;
      gap: 8px;
      margin-top: 14px;
      padding-top: 10px;
      border-top: 1px solid rgba(255,255,255,0.08);
      flex-wrap: wrap;
    }
    .home-doc-path-box {
      display: flex;
      gap: 12px;
      align-items: end;
      flex-wrap: wrap;
      margin-top: 14px;
      padding: 12px;
      border-radius: 10px;
      border: 1px solid rgba(255,255,255,0.12);
      background: rgba(0,0,0,0.2);
      width: 100%;
      max-width: 100%;
      box-sizing: border-box;
      min-width: 0;
    }
    .home-doc-path-box[hidden] {
      display: none !important;
    }
    .home-field-block {
      min-width: 0;
      max-width: 100%;
      box-sizing: border-box;
    }
    .home-field-grow {
      flex: 1 1 240px;
      min-width: 0;
      max-width: 100%;
    }
    .home-inline-actions {
      display: flex;
      gap: 10px;
      align-items: center;
      flex-wrap: wrap;
    }
    .home-project-docs-stack {
      display: grid;
      gap: 14px;
    }
    .home-doc-action-btn {
      padding: 6px 12px;
      font-size: 0.85rem;
    }
    .home-secondary-btn:disabled,
    #homePanelProject .home-secondary-btn:disabled {
      opacity: 0.45;
      cursor: not-allowed;
      pointer-events: none;
    }
    .home-file-label { opacity: 0.85; font-size: 0.9rem; }
    .home-subheading { margin: 16px 0 6px; font-size: 0.95rem; }
    .home-project-teams-assign-list {
      display: grid;
      gap: 8px;
      margin-top: 8px;
    }
    .home-check-row {
      display: flex;
      gap: 8px;
      align-items: center;
    }
    .home-empty { opacity: 0.75; margin: 0; }
    .home-teams-required-warn {
      margin: 8px 0 0;
      color: #ff3b3b;
      font-size: 0.92rem;
      font-weight: 700;
      line-height: 1.35;
      opacity: 1;
    }
    .home-teams-required-warn[hidden] {
      display: none !important;
    }
    .visually-hidden-file {
      position: absolute !important;
      width: 1px; height: 1px;
      padding: 0; margin: -1px;
      overflow: hidden; clip: rect(0,0,0,0);
      border: 0;
    }

    .home-team-modal.analise-global-modal {
      background: rgba(8, 12, 18, 0.92);
    }
    .home-team-modal .home-team-modal-content {
      width: min(960px, calc(100vw - 48px));
      height: min(88vh, 900px);
      max-height: min(88vh, 900px);
      overflow: auto;
      background: #121820;
      border: 1px solid rgba(255,255,255,0.12);
      border-radius: 16px;
      padding: 28px 32px 22px;
      box-shadow: 0 18px 48px rgba(0,0,0,0.45);
      color: var(--ui-text-primary);
      display: flex;
      flex-direction: column;
    }
    .home-team-modal-close {
      position: absolute;
      top: 10px;
      right: 14px;
      border: 0;
      background: transparent;
      color: inherit;
      font-size: 1.6rem;
      cursor: pointer;
      line-height: 1;
      opacity: 0.75;
    }
    .home-team-modal-content { position: relative; }
    .home-team-modal-title {
      margin: 0 28px 6px 0;
      font-size: 1.25rem;
    }
    .home-team-modal-hint {
      margin: 0 0 16px;
      opacity: 0.75;
      font-size: 0.92rem;
    }
    .home-team-modal-members-head {
      display: flex;
      justify-content: space-between;
      align-items: baseline;
      margin-top: 16px;
    }
    .home-team-modal-count {
      font-size: 0.9rem;
      opacity: 0.75;
    }
    .home-team-modal-input {
      width: min(100%, 320px);
      padding: 6px 10px;
      font-size: 0.92rem;
      border-radius: 6px;
    }
    #homeTeamModalName.home-team-modal-input {
      width: min(100%, 280px);
    }
    .home-team-modal-add-row {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 8px;
      margin: 8px 0 12px;
    }
    .home-team-modal-add-row .home-team-modal-input {
      width: min(100%, 200px);
      flex: 0 1 200px;
    }
    .home-team-modal-add-row .home-secondary-btn {
      padding: 6px 10px;
      font-size: 0.9rem;
    }
    .home-team-modal-members {
      list-style: none;
      margin: 0;
      padding: 10px;
      display: flex;
      flex-direction: column;
      align-content: flex-start;
      justify-content: flex-start;
      gap: 6px;
      flex: 1 1 auto;
      min-height: 120px;
      max-height: none;
      overflow: auto;
      border: 1px solid rgba(255,255,255,0.1);
      border-radius: 10px;
      background: rgba(0,0,0,0.22);
    }
    .home-team-modal-member {
      display: flex;
      justify-content: space-between;
      gap: 10px;
      align-items: center;
      flex: 0 0 auto;
      height: 44px;
      min-height: 44px;
      max-height: 44px;
      padding: 0 10px;
      border-radius: 8px;
      background: rgba(255,255,255,0.04);
      border: 1px solid rgba(255,255,255,0.08);
      box-sizing: border-box;
    }
    .home-team-modal-member-meta {
      display: flex;
      flex-direction: column;
      justify-content: center;
      gap: 0;
      min-width: 0;
      line-height: 1.2;
    }
    .home-team-modal-member-meta strong {
      font-size: 0.9rem;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .home-team-modal-member-meta span {
      font-size: 0.78rem;
      opacity: 0.7;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .home-team-modal-member-actions {
      display: flex;
      gap: 6px;
      flex: 0 0 auto;
      align-items: center;
    }
    .home-team-modal-member.is-editing {
      height: auto;
      min-height: 44px;
      max-height: none;
      padding: 6px 10px;
      gap: 8px;
    }
    .home-team-modal-member-edit-input {
      flex: 1 1 auto;
      width: auto !important;
      max-width: none;
      min-width: 120px;
    }
    .home-team-modal-member .home-secondary-btn {
      flex: 0 0 auto;
      padding: 4px 8px;
      font-size: 0.82rem;
    }
    .home-team-modal .home-team-modal-error,
    #homeTeamModalError.home-team-modal-error {
      min-height: 1.2em;
      margin: 8px 0 0;
      color: #ff3b30 !important;
      font-size: 0.9rem;
      font-weight: 600;
    }
    #homeTeamModalError.home-team-modal-error.is-visible {
      color: #ff3b30 !important;
    }
    .home-team-modal-actions {
      display: flex;
      justify-content: flex-end;
      gap: 10px;
      margin-top: 16px;
      flex-wrap: wrap;
    }
    .home-team-modal-empty {
      margin: 0;
      opacity: 0.65;
      font-size: 0.9rem;
      padding: 18px 8px;
      text-align: center;
    }

    body.user-authenticated #tab1 .upload-section {
      display: block;
    }

    /* Projeto tab: centered column, wider blocks */
    #homePanelProject {
      padding: 8px 16px 32px;
      box-sizing: border-box;
      display: flex;
      flex-direction: column;
      align-items: center;
      /* Grow with content so the panel scroll reveals Orçamento e documentação */
      justify-content: flex-start;
    }
    #homePanelProject > * {
      width: min(100%, 980px);
      margin-left: auto;
      margin-right: auto;
      box-sizing: border-box;
      flex: 0 0 auto;
      min-height: auto;
    }
    #homePanelTeams {
      padding: 8px 16px 32px;
      box-sizing: border-box;
    }
    #homePanelTeams > * {
      width: min(100%, 980px);
      margin-left: auto;
      margin-right: auto;
      box-sizing: border-box;
    }
    body.user-authenticated #tab1 #homePanelProject .home-project-context {
      display: block;
      max-width: none;
      width: min(100%, 980px);
      margin: 0 0 16px;
      box-sizing: border-box;
    }
    #homePanelProject .home-orcamento {
      max-width: none;
      width: min(100%, 980px);
      margin: 0 0 16px;
      padding: 16px 18px;
      border-radius: var(--radius-xl);
      border: 1px solid rgba(91, 156, 255, 0.28);
      background:
        linear-gradient(135deg, rgba(91, 156, 255, 0.12), transparent 58%),
        rgba(18, 26, 38, 0.88);
      box-shadow: var(--shadow-sm);
      box-sizing: border-box;
    }
    #homePanelProject .home-hub {
      max-width: none;
      width: min(100%, 980px);
      margin: 0 0 16px;
    }
    #homePanelProject .home-hub-stats {
      max-width: none;
      width: 100%;
    }
    #homePanelProject .upload-section {
      max-width: none;
      width: min(100%, 980px);
      margin: 0 0 16px;
      display: flex;
      flex-wrap: wrap;
      gap: 10px;
      align-items: flex-start;
      justify-content: flex-start;
    }
    #tab1 #homePanelProject .select-model-btn,
    #tab1 #homePanelProject .file-upload-btn {
      width: auto;
      min-width: 0;
      max-width: 100%;
      flex: 0 1 auto;
      margin: 0;
    }
    #homePanelProject .model-progress-container {
      flex: 1 1 100%;
      max-width: none;
      width: 100%;
      margin-top: 8px;
      box-sizing: border-box;
    }
    #homePanelProject .home-project-extras,
    #homePanelProject .home-card.home-project-extras {
      max-width: none;
      width: min(100%, 980px);
      flex: 0 0 auto;
      min-height: auto;
      height: auto;
      margin: 0 0 8px;
      padding: 18px 22px 22px;
      box-sizing: border-box;
      overflow: visible;
    }
    #homePanelProject .home-doc-path-box {
      max-width: 100%;
      width: 100%;
      gap: 12px;
      margin-top: 12px;
      padding: 14px 16px;
      align-items: end;
      justify-content: flex-start;
      box-sizing: border-box;
      min-width: 0;
      flex-wrap: nowrap;
    }
    #homePanelProject .home-doc-path-box .home-field-grow {
      flex: 1 1 auto;
      min-width: 220px;
      max-width: none;
    }
    #homePanelProject .home-doc-path-box .home-field-block:not(.home-field-grow) {
      flex: 0 0 auto;
      min-width: 0;
    }
    #homePanelProject .home-doc-path-box .home-primary-btn {
      flex: 0 0 auto;
    }
    #homePanelProject .home-doc-path-box .home-text-input {
      max-width: 100%;
      width: 100%;
      box-sizing: border-box;
      min-width: 0;
    }
    #homePanelProject #homeDocFolderPath {
      max-width: none;
      width: 100%;
    }
    #homePanelProject #homeDocFolderPrefix {
      width: 160px;
      max-width: 180px;
      box-sizing: border-box;
    }
    @media (max-width: 720px) {
      #homePanelProject .home-doc-path-box {
        flex-wrap: wrap;
      }
      #homePanelProject .home-doc-path-box .home-field-grow {
        flex: 1 1 100%;
      }
    }
    #homePanelProject .home-primary-btn,
    #homePanelProject .home-secondary-btn {
      width: auto;
      max-width: 100%;
      white-space: nowrap;
    }
    #homePanelProject #homeMeasurementAttachBtn {
      position: relative;
      padding-right: 22px;
    }
    #homePanelProject #homeMeasurementAttachBtn .home-tab-alert-dot {
      right: 6px;
      bottom: 6px;
    }
    #homePanelProject .home-project-teams-assign {
      margin-top: 0;
      max-width: none;
      width: 100%;
      text-align: center;
    }
    #homePanelProject .home-project-teams-card {
      margin: 0 0 16px;
      width: min(100%, 980px);
    }
    #homePanelProject > .home-project-context {
      margin: 0 0 16px;
      width: min(100%, 980px);
    }
    #homePanelProject .home-readiness {
      margin: 0 0 16px;
      width: min(100%, 980px);
    }
    #homePanelProject .home-project-teams-assign .home-subheading,
    #homePanelProject .home-project-teams-assign .home-inline-hint {
      text-align: center;
    }
    #homePanelProject .home-project-teams-assign .home-teams-required-warn,
    #homePanelProject #homeProjectTeamsRequiredWarn {
      color: #ff3b3b !important;
      opacity: 1 !important;
      font-weight: 700;
      text-align: center;
      margin: 10px auto 0;
    }
    #homePanelProject .home-project-teams-assign-list {
      max-width: 640px;
      width: 100%;
      margin: 12px auto 0;
      padding: 16px 18px;
      border: 1px solid rgba(255,255,255,0.1);
      border-radius: 10px;
      background: rgba(0,0,0,0.18);
      box-sizing: border-box;
      display: flex;
      flex-direction: column;
      align-items: stretch;
      gap: 10px;
      justify-content: center;
    }
    #homePanelProject .home-check-row {
      padding: 8px 14px;
      gap: 10px;
      width: 100%;
      max-width: none;
      min-width: 0;
      justify-content: flex-start;
      font-size: 1rem;
      border: 1px solid rgba(255,255,255,0.12);
      border-radius: 8px;
      background: rgba(255,255,255,0.03);
      box-sizing: border-box;
    }
    #homePanelProject .home-check-row input[type="checkbox"] {
      width: 1.1rem;
      height: 1.1rem;
      flex-shrink: 0;
      accent-color: #3b82f6;
    }
    #homePanelProject .home-check-row span {
      font-size: 1rem;
      line-height: 1.35;
    }
    #homePanelProject .home-check-row span em {
      font-style: normal;
      opacity: 0.7;
      font-size: 0.9em;
    }
    #homePanelProject .home-inline-hint,
    #homePanelProject .home-project-hint {
      max-width: none;
      width: min(100%, 980px);
    }

    .login-panel .login-btn {
      width: 100%;
      padding: 11px 14px;
      margin-top: 14px;
      font-size: var(--text-body);
      font-weight: 600;
      letter-spacing: 0.01em;
      border: 1px solid transparent;
      border-radius: var(--radius-md);
      cursor: pointer;
      background: linear-gradient(180deg, #2f6fed, #1d4ed8);
      color: #ffffff;
      box-shadow: 0 1px 2px rgba(16, 24, 40, 0.12), 0 1px 3px rgba(37, 99, 235, 0.30);
      transition: transform 0.14s ease, box-shadow 0.14s ease, filter 0.14s ease;
      font-family: var(--font-ui);
    }

    .login-panel .login-btn:hover {
      filter: brightness(1.05);
      transform: translateY(-1px);
      box-shadow: 0 6px 14px -3px rgba(37, 99, 235, 0.42), 0 2px 5px rgba(16, 24, 40, 0.10);
    }

    .login-panel .login-btn:active {
      transform: translateY(0);
      filter: brightness(0.97);
    }

    .login-panel .login-btn:focus-visible {
      outline: none;
      box-shadow: 0 0 0 3px var(--ui-focus-ring-color), 0 1px 3px rgba(37, 99, 235, 0.30);
    }

    .login-btn .login-btn-loading {
      display: none;
      align-items: center;
      justify-content: center;
      gap: 8px;
    }

    .login-btn.loading .login-btn-text {
      display: none;
    }

    .login-btn.loading .login-btn-loading {
      display: inline-flex;
    }

    .login-btn.loading {
      cursor: not-allowed;
      opacity: 0.85;
      pointer-events: none;
    }

    .login-btn-spinner {
      width: 16px;
      height: 16px;
      border: 2px solid rgba(255, 255, 255, 0.35);
      border-top-color: #fff;
      border-radius: 50%;
      animation: login-spin 0.7s linear infinite;
    }

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

    /* Overlays: login success and logout (shared base + theme-aware)
       Must sit above .app-sidebar (z-index 12000) so the user never sees dashboard chrome underneath. */
    .auth-overlay {
      position: fixed;
      inset: 0;
      z-index: 13000;
      display: flex;
      align-items: center;
      justify-content: center;
      background: #16181f;
      opacity: 0;
      visibility: hidden;
      pointer-events: none;
      transition: opacity var(--motion-overlay), visibility var(--motion-overlay);
    }

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

    /* After session ready: hide overlay in one frame so the dashboard never shows through a fading scrim */
    .auth-overlay.auth-overlay-dismiss-snap {
      transition: none !important;
    }

    /* No box — the loader + text sit directly on the dark scrim. */
    .auth-overlay-content {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 22px;
      padding: 0;
      background: none;
      border: none;
      border-radius: 0;
      box-shadow: none;
    }

    /* Gentle scale-in for the login/logout card (the overlay scrim already fades). */
    @keyframes motion-pop {
      from { opacity: 0; transform: scale(0.96) translateY(6px); }
      to   { opacity: 1; transform: scale(1) translateY(0); }
    }
    .auth-overlay.visible .auth-overlay-content {
      animation: motion-pop 0.36s cubic-bezier(0.33, 1, 0.68, 1) both;
    }
    /* Config / column-mapping modals scale-in too (reuses motion-pop). */
    .excel-column-config-modal:not(.hidden) .excel-column-config-content {
      animation: motion-pop 0.26s cubic-bezier(0.33, 1, 0.68, 1) both;
    }

    /* Indeterminate progress line — shared program-wide loader (auth, viewer, Controlo, toast). */
    .pg-loader-bar,
    .auth-overlay-spinner,
    .custom-loader-bar {
      position: relative;
      display: block;
      width: 220px;
      height: 4px;
      border-radius: 999px;
      background: rgba(255, 255, 255, 0.28);
      overflow: hidden;
      flex: 0 0 auto;
      box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.12),
        0 0 14px color-mix(in srgb, var(--ui-accent) 45%, transparent);
    }
    .pg-loader-bar::before,
    .auth-overlay-spinner::before,
    .custom-loader-bar::before {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      height: 100%;
      width: 45%;
      border-radius: inherit;
      background: linear-gradient(
        90deg,
        transparent,
        var(--ui-accent) 18%,
        #ffffff 50%,
        var(--ui-accent) 82%,
        transparent
      );
      animation: auth-bar-slide 1.2s cubic-bezier(0.45, 0, 0.35, 1) infinite;
    }
    .pg-loader-bar--sm {
      width: 88px;
      height: 3px;
    }
    body:not(.dark-theme) .pg-loader-bar,
    body:not(.dark-theme) .auth-overlay-spinner,
    body:not(.dark-theme) .custom-loader-bar {
      background: rgba(15, 23, 42, 0.14);
      box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.06);
    }
    body:not(.dark-theme) .pg-loader-bar::before,
    body:not(.dark-theme) .auth-overlay-spinner::before,
    body:not(.dark-theme) .custom-loader-bar::before {
      background: linear-gradient(
        90deg,
        transparent,
        var(--ui-accent) 22%,
        color-mix(in srgb, var(--ui-accent) 70%, #fff) 50%,
        var(--ui-accent) 78%,
        transparent
      );
    }
    @keyframes auth-bar-slide {
      0% { transform: translateX(-115%); }
      100% { transform: translateX(340%); }
    }

    .auth-overlay-text {
      margin: 0;
      font-size: 15px;
      font-weight: 500;
      letter-spacing: 0.02em;
      color: rgba(255, 255, 255, 0.92);
      font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
    }

    /* Legacy class names: keep .visible rule for backward compatibility */
    .login-success-overlay.visible { opacity: 1; visibility: visible; pointer-events: auto; }

    /* Overlay visible on load (post-login or post-logout) until window.load */
    body.auth-loading #loginSuccessOverlay,
    body.auth-loading .login-success-overlay {
      opacity: 1;
      visibility: visible;
      pointer-events: auto;
    }

    /* Workspace refresh: ensure login-success overlay never flashes light glass when dark theme
       is active (dark-theme is set from localStorage in the first body script). */
    body.auth-loading.dark-theme #loginSuccessOverlay.auth-overlay {
      background: #0d0f14;
    }

    body.auth-loading.dark-theme #loginSuccessOverlay .auth-overlay-content {
      background: none;
      border: none;
      box-shadow: none;
    }

    body.auth-loading.dark-theme #loginSuccessOverlay .auth-overlay-text {
      color: #e8e8ed;
    }

    body.just-logged-out #logoutOverlay,
    body.just-logged-out .logout-overlay {
      opacity: 1;
      visibility: visible;
      pointer-events: auto;
    }

    /* Hide main content behind overlay (same as auth-loading for login) */
    body.just-logged-out .tabs-container {
      opacity: 0;
      transition: opacity var(--motion-smooth-medium);
    }

    /* Fade-out state before hiding overlay */
    .auth-overlay.auth-overlay-fade-out {
      opacity: 0;
      visibility: hidden;
      pointer-events: none;
    }

    /* Dark theme: login and logout overlays */
    body.dark-theme .auth-overlay {
      background: #0d0f14;
    }

    body.dark-theme .auth-overlay-content {
      background: none;
      border: none;
      box-shadow: none;
    }

    body.dark-theme .auth-overlay-text {
      color: #e8e8ed;
    }

    .dropdown-section {
      margin-bottom: 20px;
    }

    .dropdown-section label {
      display: block;
      margin-bottom: 8px;
      font-weight: 600;
      color: #333;
    }

    .dropdown-select {
      width: 100%;
      padding: 10px 12px;
      font-size: 13px;
      border: 1px solid rgba(0, 0, 0, 0.1);
      border-radius: 10px;
      background: rgba(0, 0, 0, 0.06);
      color: #1d1d1f;
      transition: background 0.2s ease, box-shadow 0.2s ease;
    }

    .dropdown-select:focus {
      outline: none;
      background: rgba(0, 0, 0, 0.08);
      box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.12), 0 0 0 4px rgba(10, 132, 255, 0.25);
    }

    #tab1 .file-upload-btn,
    #tab1 .select-model-btn {
      position: relative;
      width: 100%;
      padding: 12px 18px;
      font-size: 15px;
      font-weight: 500;
      border: 1px solid transparent;
      border-radius: 12px;
      cursor: pointer;
      margin-top: 0;
      margin-bottom: 10px;
      transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, opacity 0.2s ease;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
    }

    #tab1 .select-model-btn .btn-icon,
    #tab1 .select-model-btn svg {
      width: 18px;
      height: 18px;
      flex-shrink: 0;
    }

    #tab1 .file-upload-btn {
      background: var(--ui-accent-soft-bg);
      color: var(--ui-accent);
      border: var(--ui-accent-soft-border);
    }

    #tab1 .file-upload-btn:hover {
      background: linear-gradient(rgba(37, 99, 235, 0.06), rgba(37, 99, 235, 0.06)), var(--ui-accent-soft-bg);
      border: 1px solid rgba(37, 99, 235, 0.22);
    }

    #tab1 .select-model-btn {
      background: var(--ui-sidebar-surface);
      color: var(--ui-text-primary);
      border: var(--ui-chrome-border);
      box-shadow: var(--ui-chrome-shadow);
      backdrop-filter: var(--ui-backdrop-filter);
      -webkit-backdrop-filter: var(--ui-backdrop-filter);
      font-family: var(--font-ui);
      font-size: var(--text-label-size);
      font-weight: 500;
    }

    #tab1 .select-model-btn:hover {
      background: linear-gradient(var(--ui-nav-hover-bg), var(--ui-nav-hover-bg)), var(--ui-chrome-surface);
      border: var(--ui-chrome-border);
      box-shadow: var(--ui-chrome-shadow);
    }

    #tab1 .select-model-btn:focus-visible {
      outline: none;
      box-shadow: var(--ui-chrome-shadow), 0 0 0 2px var(--ui-focus-ring-color);
    }

    #tab1 .file-upload-btn:focus-visible {
      outline: none;
      box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.4);
    }

    .file-upload-btn, .select-model-btn {
      width: 100%;
      padding: 10px 14px;
      font-size: 13px;
      font-weight: 500;
      border: 1px solid transparent;
      border-radius: 10px;
      cursor: pointer;
      margin-top: 6px;
      transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    }

    .file-upload-btn {
      background: rgba(37, 99, 235, 0.15);
      border-color: rgba(37, 99, 235, 0.14);
      color: #2563eb;
    }

    .file-upload-btn:hover {
      background: rgba(37, 99, 235, 0.2);
      border-color: rgba(37, 99, 235, 0.18);
    }

    .select-model-btn {
      background: var(--ui-chrome-surface);
      border: var(--ui-chrome-border);
      color: var(--ui-text-primary);
      box-shadow: var(--ui-chrome-shadow);
      backdrop-filter: var(--ui-backdrop-filter);
      -webkit-backdrop-filter: var(--ui-backdrop-filter);
    }

    .select-model-btn:hover {
      background: linear-gradient(var(--ui-nav-hover-bg), var(--ui-nav-hover-bg)), var(--ui-chrome-surface);
      border: var(--ui-chrome-border);
      box-shadow: var(--ui-chrome-shadow);
    }

    .file-input-hidden {
      display: none;
    }

    /* Legacy project-tab progress styles kept inert; live UI is sidebar-model-loading */
    .model-progress-container {
      display: none;
    }

    .model-progress-container.sidebar-model-loading {
      display: flex;
    }

    .model-progress-container.sidebar-model-loading[hidden] {
      display: none !important;
    }

    .model-progress-container.active {
      /* visibility controlled by [hidden] on sidebar card */
    }

    .model-progress-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 12px;
    }

    .model-progress-title {
      font-weight: 600;
      color: #333;
      font-size: 14px;
    }

    .model-progress-status {
      font-size: 12px;
      padding: 4px 8px;
      border-radius: 999px;
      font-weight: 600;
    }

    .model-progress-status.pending {
      background: #fff3cd;
      color: #856404;
    }

    .model-progress-status.inprogress {
      background: #d1ecf1;
      color: #0c5460;
    }

    .model-progress-status.success {
      background: #d4edda;
      color: #155724;
    }

    .model-progress-status.failed {
      background: #f8d7da;
      color: #721c24;
    }

    .model-progress-info {
      font-size: 12px;
      color: #666;
      margin-bottom: 8px;
    }

    .model-progress-bar-wrapper {
      width: 100%;
      height: 24px;
      background: #e9ecef;
      border-radius: 12px;
      overflow: hidden;
      position: relative;
    }

    .model-progress-bar {
      height: 100%;
      background: linear-gradient(90deg, #2563eb 0%, #1d4ed8 100%);
      border-radius: 12px;
      transition: width 0.3s ease;
      position: relative;
      overflow: hidden;
    }

    .model-progress-bar::after {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      bottom: 0;
      right: 0;
      background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
      );
      animation: shimmer 2s infinite;
    }

    @keyframes shimmer {
      0% {
        transform: translateX(-100%);
      }
      100% {
        transform: translateX(100%);
      }
    }

    .model-progress-bar.success {
      background: linear-gradient(90deg, #4CAF50 0%, #45a049 100%);
    }

    .model-progress-bar.failed {
      background: linear-gradient(90deg, #f44336 0%, #d32f2f 100%);
    }

    .model-progress-text {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      font-size: 11px;
      font-weight: 600;
      color: #333;
      z-index: 1;
    }

    .select-model-btn:disabled {
      background: #ccc;
      cursor: not-allowed;
      opacity: 0.6;
    }

    .select-model-btn:disabled:hover {
      background: #ccc;
    }

    #tab1 .select-model-btn:disabled,
    #tab1 .select-model-btn:disabled:hover {
      background: var(--ui-chrome-surface);
      border: var(--ui-chrome-border);
      box-shadow: var(--ui-chrome-shadow);
      color: var(--ui-text-primary);
      opacity: 0.5;
      cursor: not-allowed;
      backdrop-filter: var(--ui-backdrop-filter);
      -webkit-backdrop-filter: var(--ui-backdrop-filter);
    }

    /* Shared glass-panel tokens (Document browser / Selection–aligned) */
    .ui-surface-card,
    .settings-modal-content,
    .admin-user-edit-modal,
    .project-elements-modal-content,
    .analise-global-choice-content,
    .analise-global-content,
    .excel-comparison-content,
    .analise-global-graph-content {
      background: var(--ui-chrome-surface);
      backdrop-filter: var(--ui-backdrop-filter);
      -webkit-backdrop-filter: var(--ui-backdrop-filter);
      border: var(--ui-chrome-border);
      box-shadow: var(--ui-chrome-shadow);
    }

    .ui-close-button,
    .settings-modal-close,
    .project-elements-close,
    .analise-global-close,
    .analise-global-graph-close,
    .admin-user-edit-close {
      border-radius: 8px;
      transition: background 0.15s ease, color 0.15s ease;
    }

    .ui-close-button:hover,
    .settings-modal-close:hover,
    .project-elements-close:hover,
    .analise-global-close:hover,
    .analise-global-graph-close:hover,
    .admin-user-edit-close:hover {
      background: rgba(0, 0, 0, 0.08);
    }

    .ui-panel-card,
    .settings-option,
    .project-elements-form-row,
    .project-elements-details,
    .admin-content-card {
      background: rgba(0, 0, 0, 0.03);
      border: 1px solid rgba(0, 0, 0, 0.08);
      border-radius: 12px;
      box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.02) inset;
    }

    .ui-input-field,
    .dropdown-select,
    .language-select,
    .viewer-setting-input,
    .admin-user-edit-field input,
    .admin-user-edit-field select,
    #tab3 select,
    #projectElementsSelect[multiple],
    #constructionExecType[multiple],
    .projectElementsSelect {
      border: 1px solid rgba(0, 0, 0, 0.08);
      border-radius: 10px;
      background: rgba(0, 0, 0, 0.04);
      color: #1d1d1f;
      transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    }

    .dfs-code-picker {
      position: relative;
      width: 100%;
    }

    .dfs-code-picker__native {
      position: absolute;
      width: 1px;
      height: 1px;
      opacity: 0;
      pointer-events: none;
    }

    .dfs-code-picker__btn {
      position: relative;
      display: block;
      width: 100%;
      box-sizing: border-box;
      text-align: left;
      cursor: pointer;
      border: 1px solid rgba(0, 0, 0, 0.1);
      border-radius: 10px;
      background: rgba(0, 0, 0, 0.06);
      color: #1d1d1f;
      padding: 10px 32px 10px 12px;
      font-family: inherit;
      font-size: 13px;
      font-weight: 500;
      line-height: 1.35;
      height: auto;
      letter-spacing: normal;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      transition: background 0.2s ease, box-shadow 0.2s ease;
    }

    .dfs-code-picker__btn::after {
      content: "";
      position: absolute;
      right: 12px;
      top: 50%;
      width: 7px;
      height: 7px;
      border-right: 1.6px solid currentColor;
      border-bottom: 1.6px solid currentColor;
      opacity: 0.65;
      transform: translateY(-70%) rotate(45deg);
      pointer-events: none;
    }

    .dfs-code-picker__btn[aria-expanded="true"]::after {
      transform: translateY(-20%) rotate(225deg);
    }

    .dfs-code-picker__btn:hover {
      background: rgba(0, 0, 0, 0.08);
    }

    .dfs-code-picker__btn:focus,
    .dfs-code-picker__btn[aria-expanded="true"] {
      outline: none;
      background: rgba(0, 0, 0, 0.08);
      box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.12), 0 0 0 4px rgba(10, 132, 255, 0.25);
    }

    .dfs-code-picker__btn:active {
      transform: none;
    }

    .dfs-code-picker__menu {
      position: absolute;
      z-index: 200;
      left: 0;
      top: calc(100% + 1px);
      width: 100%;
      min-width: 100%;
      max-width: none;
      max-height: 16rem;
      overflow-x: hidden;
      overflow-y: auto;
      margin: 0;
      padding: 2px 0;
      background: #fff;
      color: #1a1a1a;
      border: 1px solid #b4b4b4;
      border-radius: 4px;
      box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
      color-scheme: light;
    }

    .dfs-code-picker__pick {
      display: flex;
      align-items: center;
      gap: 8px;
      width: 100%;
      height: auto;
      box-sizing: border-box;
      text-align: left;
      letter-spacing: normal;
      background: transparent;
      border: 0;
      border-radius: 0;
      padding: 4px 10px;
      margin: 0;
      cursor: pointer;
      color: #1a1a1a;
      font: inherit;
      font-size: 13px;
      font-weight: 400;
      line-height: 1.4;
      transform: none;
    }

    .dfs-code-picker__pick:hover {
      background: #0a6ed1;
      color: #fff;
    }

    .dfs-code-picker__pick:active {
      transform: none;
    }

    .dfs-code-picker__pick.is-selected {
      background: #cce4f7;
      color: #1a1a1a;
    }

    .dfs-code-picker__pick.is-selected:hover {
      background: #0a6ed1;
      color: #fff;
    }

    .dfs-code-picker__label {
      flex: 1;
      min-width: 0;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .dfs-code-toggle {
      display: none;
    }

    body.dark-theme .dfs-code-picker__btn {
      background: #2b3242;
      color: #ffffff;
      border-color: #363d4d;
    }

    body.dark-theme .dfs-code-picker__btn:hover,
    body.dark-theme .dfs-code-picker__btn:focus,
    body.dark-theme .dfs-code-picker__btn[aria-expanded="true"] {
      background: #323a4c;
      color: #ffffff;
      border-color: #363d4d;
    }

    body.dark-theme .dfs-code-picker__menu {
      background: #2b3242;
      border-color: #363d4d;
      color: #ffffff;
      box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
      color-scheme: dark;
    }

    body.dark-theme .dfs-code-picker__pick {
      color: #ffffff;
      background: transparent;
    }

    body.dark-theme .dfs-code-picker__pick.is-selected {
      background: #3a4558;
      color: #ffffff;
    }

    body.dark-theme .dfs-code-picker__pick:hover,
    body.dark-theme .dfs-code-picker__pick.is-selected:hover {
      background: #0a6ed1;
      color: #fff;
    }

    .ui-input-field:hover,
    .dropdown-select:hover,
    .language-select:hover,
    .viewer-setting-input:hover,
    .admin-user-edit-field input:hover,
    .admin-user-edit-field select:hover,
    #tab3 select:hover,
    .projectElementsSelect:hover {
      background: rgba(0, 0, 0, 0.06);
      border-color: rgba(0, 0, 0, 0.1);
    }

    .ui-input-field:focus,
    .dropdown-select:focus,
    .language-select:focus,
    .viewer-setting-input:focus,
    .admin-user-edit-field input:focus,
    .admin-user-edit-field select:focus,
    #tab3 select:focus,
    .projectElementsSelect:focus {
      outline: none;
      background: rgba(0, 0, 0, 0.06);
      border-color: rgba(37, 99, 235, 0.16);
      box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
    }

    /* Base for design-system button utilities (padding/shape/type); colours come
       from the variant rules below. Kept in sync with #modelSelector* buttons. */
    .ui-button-primary,
    .ui-button-secondary,
    .ui-button-danger {
      padding: 10px 16px;
      font-size: 13px;
      font-weight: 500;
      border-radius: 10px;
      cursor: pointer;
    }

    .ui-button-secondary,
    .modal-secondary-btn,
    #modelSelectorCancel,
    .admin-btn-secondary,
    .theme-toggle-btn,
    #tab3 .file-input-label {
      border: 1px solid rgba(0, 0, 0, 0.08);
      background: rgba(0, 0, 0, 0.04);
      color: #1d1d1f;
      transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    }

    .ui-button-secondary:hover,
    .modal-secondary-btn:hover,
    #modelSelectorCancel:hover,
    .admin-btn-secondary:hover,
    .theme-toggle-btn:hover,
    #tab3 .file-input-label:hover {
      background: rgba(0, 0, 0, 0.08);
      border-color: rgba(0, 0, 0, 0.1);
    }

    .ui-button-primary,
    .admin-action-btn,
    .admin-btn-primary,
    #modelSelectorSave,
    .excel-comparison-btn-close,
    .analise-global-choice-btn-primary,
    .analise-global-graph-btn-close {
      border: 1px solid rgba(37, 99, 235, 0.14);
      background: rgba(37, 99, 235, 0.15);
      color: #2563eb;
      transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    }

    .ui-button-primary:hover,
    .admin-action-btn:hover,
    .admin-btn-primary:hover,
    #modelSelectorSave:hover,
    .excel-comparison-btn-close:hover,
    .analise-global-choice-btn-primary:hover,
    .analise-global-graph-btn-close:hover {
      background: rgba(37, 99, 235, 0.2);
      border-color: rgba(37, 99, 235, 0.18);
    }

    .ui-button-danger,
    #modelSelectorDelete,
    .admin-btn-delete {
      border: 1px solid rgba(211, 47, 47, 0.14);
      background: rgba(211, 47, 47, 0.12);
      color: #c62828;
      transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    }

    .ui-button-danger:hover,
    #modelSelectorDelete:hover,
    .admin-btn-delete:hover {
      background: rgba(211, 47, 47, 0.18);
      border-color: rgba(211, 47, 47, 0.18);
    }

    .ui-info-banner,
    .model-selector-info {
      margin-bottom: 12px;
      padding: 10px 12px;
      border-radius: 12px;
      border: 1px solid rgba(37, 99, 235, 0.08);
      background: rgba(37, 99, 235, 0.08);
      color: #1d1d1f;
      font-size: 12px;
      line-height: 1.5;
    }

    .ui-content-frame,
    .model-selector-file-list,
    .admin-content-card {
      border: 1px solid rgba(0, 0, 0, 0.08);
      border-radius: 12px;
      background: rgba(0, 0, 0, 0.02);
      overflow: hidden;
    }

    .ui-loading-message {
      padding: 20px;
      text-align: center;
      color: #666;
      font-size: 13px;
    }

    .skeleton-line {
      height: 14px;
      margin: 8px 0;
      border-radius: 4px;
      background: linear-gradient(90deg, rgba(0,0,0,0.06) 25%, rgba(0,0,0,0.12) 50%, rgba(0,0,0,0.06) 75%);
      background-size: 200% 100%;
      animation: skeleton-shimmer 1s ease-in-out infinite;
    }
    .skeleton-line.short { max-width: 60%; }
    .skeleton-line.medium { max-width: 85%; }
    @keyframes skeleton-shimmer {
      0% { background-position: 200% 0; }
      100% { background-position: -200% 0; }
    }

    .admin-error-message,
    .model-selector-error-message {
      color: #c62828;
    }

    .excel-comparison-cell-match {
      color: #2e7d32;
    }

    .excel-comparison-cell-positive {
      color: #ef6c00;
    }

    .excel-comparison-cell-negative {
      color: #c62828;
    }

    /* Settings Modal */
    /* Admin Panel Styles */
    .admin-tabs {
      display: flex;
      gap: 8px;
      margin-bottom: 20px;
      border-bottom: 1px solid rgba(0, 0, 0, 0.08);
      padding-bottom: 12px;
    }

    .admin-tab-btn {
      padding: 8px 14px;
      border: 1px solid transparent;
      background: rgba(0, 0, 0, 0.02);
      cursor: pointer;
      font-size: 13px;
      font-weight: 500;
      color: #666;
      border-radius: 10px;
      transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    }

    .admin-tab-btn:hover {
      color: #2563eb;
      background: rgba(0, 0, 0, 0.06);
    }

    .admin-tab-btn.active {
      color: #2563eb;
      border-color: rgba(37, 99, 235, 0.12);
      background: rgba(37, 99, 235, 0.15);
    }

    .admin-tab-content {
      display: none;
    }

    .admin-tab-content.active {
      display: block;
    }

    .admin-actions-row {
      margin-bottom: 20px;
    }

    .admin-modal-content {
      max-height: 90vh;
      overflow-y: auto;
    }

    .admin-action-btn {
      padding: 10px 20px;
      border-radius: 10px;
      cursor: pointer;
      font-weight: 500;
    }

    .admin-users-table {
      width: 100%;
      min-width: 720px;
      border-collapse: collapse;
      margin-top: 0;
      border-radius: 12px;
      overflow: hidden;
    }

    /* Users list: allow horizontal scroll when modal is narrow */
    #adminUsersList.admin-content-card {
      overflow-x: auto;
      overflow-y: visible;
      -webkit-overflow-scrolling: touch;
    }

    .admin-users-table th,
    .admin-users-table td {
      padding: 12px;
      text-align: left;
      border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    }

    .admin-users-table th {
      background: rgba(0, 0, 0, 0.04);
      font-weight: 600;
      color: #1d1d1f;
    }

    .admin-users-table tr:hover {
      background: rgba(0, 0, 0, 0.04);
    }

    .admin-user-actions {
      display: flex;
      gap: 8px;
    }

    .admin-btn-small {
      padding: 7px 12px;
      font-size: 12px;
      border: 1px solid transparent;
      border-radius: 8px;
      cursor: pointer;
      font-weight: 500;
      transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    }

    .admin-btn-edit {
      background: rgba(37, 99, 235, 0.15);
      border-color: rgba(37, 99, 235, 0.14);
      color: #2563eb;
    }

    .admin-btn-delete {
      background: rgba(211, 47, 47, 0.12);
      border-color: rgba(211, 47, 47, 0.14);
      color: #c62828;
    }

    .admin-form {
      margin-top: 20px;
      padding: 20px;
      border-radius: 12px;
    }

    .admin-form-group {
      margin-bottom: 16px;
    }

    .admin-form-label {
      display: block;
      margin-bottom: 6px;
      font-weight: 500;
      font-size: 14px;
    }

    .admin-form-input {
      width: 100%;
      padding: 8px 12px;
      border-radius: 10px;
      font-size: 14px;
      box-sizing: border-box;
    }

    .admin-form-select {
      width: 100%;
      padding: 8px 12px;
      border-radius: 10px;
      font-size: 14px;
      box-sizing: border-box;
    }

    /* Admin User Edit Modal — above .settings-modal / admin panel (13000) */
    .admin-user-edit-backdrop {
      position: fixed;
      inset: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      background: rgba(0, 0, 0, 0.55);
      backdrop-filter: blur(8px);
      z-index: 14000;
      padding: 20px;
    }

    .admin-user-edit-backdrop.hidden {
      display: none;
    }

    .admin-user-edit-modal {
      width: 100%;
      max-width: 520px;
      border-radius: var(--ui-chrome-radius);
      padding: 20px 24px 18px;
      box-sizing: border-box;
      font-family: var(--font-ui);
      color: var(--ui-text-primary);
    }

    .admin-user-edit-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 16px;
    }

    .admin-user-edit-header h3 {
      margin: 0;
      font-size: 18px;
      font-weight: 600;
    }

    .admin-user-edit-close {
      border: none;
      background: transparent;
      font-size: 20px;
      cursor: pointer;
      line-height: 1;
      color: var(--ui-text-primary);
      width: 32px;
      height: 32px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      border-radius: var(--ui-nav-item-radius);
      transition: background 0.2s ease;
    }

    .admin-user-edit-close:hover {
      background: var(--ui-nav-hover-bg);
    }

    .admin-user-edit-close:focus-visible {
      outline: none;
      box-shadow: 0 0 0 2px var(--ui-focus-ring-color);
    }

    .admin-user-edit-body {
      display: flex;
      flex-direction: column;
      gap: 12px;
      margin-bottom: 16px;
    }

    .admin-user-edit-field {
      display: flex;
      flex-direction: column;
      gap: 4px;
    }

    .admin-user-edit-field label {
      font-size: 13px;
      font-weight: 500;
    }

    .admin-user-edit-field input,
    .admin-user-edit-field select {
      padding: 8px 10px;
      border-radius: 10px;
      font-size: 14px;
      box-sizing: border-box;
    }

    .admin-user-edit-inline {
      flex-direction: row;
      gap: 12px;
    }

    .admin-user-edit-inline-item {
      flex: 1;
      display: flex;
      flex-direction: column;
      gap: 4px;
    }

    .admin-user-edit-error {
      min-height: 18px;
      font-size: 12px;
      color: #d32f2f;
    }

    .admin-user-edit-footer {
      display: flex;
      justify-content: flex-end;
      gap: 10px;
    }

    .admin-btn-primary,
    .admin-btn-secondary {
      padding: 8px 16px;
      border-radius: 10px;
      font-size: 14px;
      cursor: pointer;
      font-weight: 500;
    }

    @media (max-width: 640px) {
      .admin-user-edit-modal {
        margin: 0;
      }
    }

    body.dark-theme .admin-user-edit-modal {
      background: var(--ui-chrome-surface) !important;
      color: var(--ui-text-primary);
      border: var(--ui-chrome-border) !important;
      box-shadow: var(--ui-chrome-shadow) !important;
      backdrop-filter: var(--ui-backdrop-filter);
      -webkit-backdrop-filter: var(--ui-backdrop-filter);
    }

    body.dark-theme .admin-user-edit-field input,
    body.dark-theme .admin-user-edit-field select {
      background: rgba(0, 0, 0, 0.6);
      border-color: rgba(255, 255, 255, 0.15);
      color: rgba(255, 255, 255, 0.9);
    }

    body.dark-theme .admin-user-edit-error {
      color: #ff453a;
    }

    body.dark-theme .admin-btn-secondary {
      background: rgba(255, 255, 255, 0.08);
      color: rgba(255, 255, 255, 0.9);
    }

    body.dark-theme .admin-tabs {
      border-bottom-color: rgba(255, 255, 255, 0.2);
    }

    body.dark-theme .admin-tab-btn {
      color: rgba(255, 255, 255, 0.7);
    }

    body.dark-theme .admin-tab-btn:hover,
    body.dark-theme .admin-tab-btn.active {
      color: #6aa1ff;
      border-bottom-color: #6aa1ff;
    }

    body.dark-theme .admin-users-table th {
      background: rgba(255, 255, 255, 0.05);
      color: rgba(255, 255, 255, 0.9);
    }

    body.dark-theme .admin-users-table td {
      color: rgba(255, 255, 255, 0.8);
      border-bottom-color: rgba(255, 255, 255, 0.1);
    }

    body.dark-theme .admin-users-table tr:hover {
      background: rgba(255, 255, 255, 0.05);
    }

    body.dark-theme .admin-form {
      background: rgba(255, 255, 255, 0.05);
      border-color: rgba(255, 255, 255, 0.1);
    }

    body.dark-theme .admin-form-label {
      color: rgba(255, 255, 255, 0.9);
    }

    body.dark-theme .admin-form-input,
    body.dark-theme .admin-form-select {
      background: rgba(255, 255, 255, 0.1);
      border-color: rgba(255, 255, 255, 0.2);
      color: rgba(255, 255, 255, 0.9);
    }

    .settings-modal {
      position: fixed;
      inset: 0;
      z-index: 13000;
      background: rgba(0, 0, 0, 0.55);
      display: none;
      align-items: center;
      justify-content: center;
      padding: 20px;
    }

    .settings-modal.show {
      display: flex;
    }

    .settings-modal-content {
      border-radius: var(--ui-chrome-radius);
      padding: 28px;
      max-width: 500px;
      width: 90%;
      max-height: 90vh;
      overflow-y: auto;
      position: relative;
      font-family: var(--font-ui);
      color: var(--ui-text-primary);
    }

    /* Admin panel shares .settings-modal-content but needs more width for the users table */
    .settings-modal-content.admin-modal-content {
      width: min(96vw, 1040px);
      max-width: min(96vw, 1040px);
      box-sizing: border-box;
    }

    body.dark-theme .settings-modal-content {
      background: var(--ui-chrome-surface) !important;
      color: var(--ui-text-primary) !important;
      border: var(--ui-chrome-border) !important;
      box-shadow: var(--ui-chrome-shadow) !important;
      backdrop-filter: var(--ui-backdrop-filter);
      -webkit-backdrop-filter: var(--ui-backdrop-filter);
    }

    .settings-modal-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 24px;
      padding-bottom: 16px;
      border-bottom: var(--ui-chrome-border);
    }

    .settings-modal-header h2 {
      margin: 0;
      font-size: 24px;
      font-weight: 700;
      color: var(--ui-text-primary);
    }

    .settings-modal-close {
      background: none;
      border: none;
      font-size: 24px;
      cursor: pointer;
      color: var(--ui-text-primary);
      width: 32px;
      height: 32px;
      display: flex;
      align-items: center;
      justify-content: center;
      border-radius: var(--ui-nav-item-radius);
      transition: background 0.2s ease, color 0.2s ease;
    }

    .settings-modal-close:hover {
      background: var(--ui-nav-hover-bg);
      color: var(--ui-text-primary);
    }

    .settings-modal-close:focus-visible {
      outline: none;
      box-shadow: 0 0 0 2px var(--ui-focus-ring-color);
    }

    .settings-tab-bar {
      display: flex;
      gap: 8px;
      margin-bottom: 16px;
      border-bottom: 1px solid rgba(0, 0, 0, 0.08);
      padding-bottom: 12px;
    }
    .settings-tab-btn {
      padding: 8px 14px;
      border: 1px solid transparent;
      background: rgba(0, 0, 0, 0.02);
      font-size: 13px;
      font-weight: 500;
      color: #6c757d;
      cursor: pointer;
      border-radius: 10px;
      margin-bottom: 0;
    }
    .settings-tab-btn:hover {
      color: #2c3e50;
      background: rgba(0, 0, 0, 0.06);
    }
    .settings-tab-btn.active {
      color: var(--ui-accent);
      border: var(--ui-accent-soft-border);
      background: var(--ui-accent-soft-bg);
    }
    .settings-tab-pane {
      display: none;
    }
    .settings-tab-pane.active {
      display: block;
    }
    .user-data-content { padding: 0 4px; }
    .user-data-avatar-row { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
    .user-data-avatar { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; border: 2px solid rgba(0,0,0,0.08); }
    .user-data-avatar-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
    .user-data-avatar-actions .user-photo-input { position: absolute; width: 0; height: 0; opacity: 0; }
    .user-data-avatar-btn { padding: 6px 12px; font-size: 13px; border-radius: 8px; border: 1px solid rgba(0,0,0,0.15); background: rgba(0,0,0,0.04); cursor: pointer; }
    .user-data-avatar-btn:hover { background: rgba(0,0,0,0.08); }
    .user-data-library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 8px; max-height: 200px; overflow-y: auto; padding: 12px; background: rgba(0,0,0,0.03); border-radius: 12px; margin-bottom: 16px; }
    .user-data-library-grid img { width: 48px; height: 48px; object-fit: contain; cursor: pointer; border-radius: 8px; border: 2px solid transparent; transition: border-color 0.2s; }
    .user-data-library-grid img:hover, .user-data-library-grid img.selected { border-color: #2563eb; }
    .user-data-fields { display: flex; flex-direction: column; gap: 10px; }
    .user-data-field { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
    .user-data-label { font-weight: 600; font-size: 13px; min-width: 80px; color: rgba(0,0,0,0.7); }
    .user-data-value { font-size: 14px; color: #1d1d1f; }
    .user-data-name-input { max-width: 280px; }
    .user-data-name-actions { margin-top: 8px; }
    .user-data-save-btn { padding: 6px 14px; font-size: 13px; border-radius: 8px; border: none; background: #2563eb; color: #fff; cursor: pointer; }
    .user-data-save-btn:hover { background: #1d4ed8; }
    .settings-option {
      margin-bottom: 16px;
      padding: 16px;
    }

    .settings-option-label {
      display: block;
      font-size: 15px;
      font-weight: 600;
      color: #2c3e50;
      margin-bottom: 12px;
    }

    .settings-option-description {
      font-size: 13px;
      color: #6c757d;
      margin-bottom: 12px;
    }

    .viewer-settings-fields {
      display: flex;
      flex-direction: column;
      gap: 12px;
    }

    .viewer-setting-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      flex-wrap: wrap;
    }

    .viewer-setting-label {
      font-size: 13px;
      color: #2c3e50;
      flex: 1;
      min-width: 180px;
    }

    .viewer-setting-input {
      width: 80px;
      padding: 8px 10px;
      border: 1px solid rgba(0, 0, 0, 0.15);
      border-radius: 8px;
      font-size: 14px;
    }

    .theme-toggle-container {
      display: flex;
      gap: 12px;
    }

    .app-wallpaper-picker {
      position: relative;
      display: flex;
      flex-direction: column;
      gap: 10px;
      margin-top: 14px;
    }

    .app-wallpaper-picker[hidden] {
      display: none !important;
    }

    .app-wallpaper-picker .user-photo-input {
      position: absolute;
      width: 0;
      height: 0;
      opacity: 0;
    }

    .app-wallpaper-picker-label {
      font-size: 13px;
      color: #6c757d;
    }

    .app-wallpaper-gallery {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
      gap: 10px;
    }

    .app-wallpaper-tile {
      position: relative;
      display: flex;
      flex-direction: column;
      border: 2px solid transparent;
      border-radius: 12px;
    }

    .app-wallpaper-tile-select {
      display: flex;
      flex-direction: column;
      gap: 6px;
      width: 100%;
      padding: 0;
      border: none;
      background: transparent;
      cursor: pointer;
      text-align: left;
      color: inherit;
      border-radius: 10px;
    }

    .app-wallpaper-tile:hover,
    .app-wallpaper-tile.selected {
      border-color: var(--ui-accent);
    }

    .app-wallpaper-tile-preview {
      display: block;
      width: 100%;
      aspect-ratio: 16 / 10;
      border-radius: 10px;
      background-color: #1a1a1a;
      background-size: cover;
      background-position: center;
      background-repeat: no-repeat;
    }

    .app-wallpaper-tile-name {
      font-size: 11px;
      line-height: 1.2;
      color: #6c757d;
      padding: 0 2px 4px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .app-wallpaper-tile-remove {
      position: absolute;
      top: 4px;
      right: 4px;
      width: 22px;
      height: 22px;
      border: none;
      border-radius: 50%;
      background: rgba(0, 0, 0, 0.62);
      color: #fff;
      font-size: 14px;
      line-height: 22px;
      cursor: pointer;
      padding: 0;
    }

    .app-wallpaper-tile-remove:hover {
      background: rgba(0, 0, 0, 0.82);
    }

    .theme-toggle-btn {
      flex: 1;
      padding: 10px 12px;
      border-radius: 10px;
      cursor: pointer;
      font-weight: 500;
      font-size: 13px;
      text-align: center;
    }

    .theme-toggle-btn.active {
      background: rgba(37, 99, 235, 0.15);
      border-color: rgba(37, 99, 235, 0.12);
      color: #2563eb;
    }

    .language-select {
      width: 100%;
      padding: 10px 12px;
      font-size: 13px;
      border-radius: 10px;
      cursor: pointer;
    }

    .notification-toggle {
      display: flex;
      align-items: center;
      gap: 12px;
    }

    .toggle-switch {
      position: relative;
      width: 50px;
      height: 26px;
    }

    .toggle-switch input {
      opacity: 0;
      width: 0;
      height: 0;
    }

    .toggle-slider {
      position: absolute;
      cursor: pointer;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background-color: #ccc;
      transition: 0.3s;
      border-radius: 26px;
    }

    .toggle-slider:before {
      position: absolute;
      content: "";
      height: 20px;
      width: 20px;
      left: 3px;
      bottom: 3px;
      background-color: white;
      transition: 0.3s;
      border-radius: 50%;
    }

    .toggle-switch input:checked + .toggle-slider {
      background-color: #2563eb;
    }

    .toggle-switch input:checked + .toggle-slider:before {
      transform: translateX(24px);
    }

    .toggle-label {
      font-size: 14px;
      color: #495057;
      font-weight: 500;
    }

    /* Dark theme styles */
    body.dark-theme {
      background: #1a1a1a;
      color: #e0e0e0;
    }

    body.dark-theme .tab1-content {
      background: var(--ui-sidebar-surface) !important;
      border: var(--ui-chrome-border) !important;
      box-shadow: var(--ui-chrome-shadow) !important;
      color: var(--ui-text-primary);
      backdrop-filter: var(--ui-backdrop-filter);
      -webkit-backdrop-filter: var(--ui-backdrop-filter);
    }

    /* Guest login keeps its own glass treatment even in dark theme */
    body.dark-theme:not(.user-authenticated) .tab1-content.login-panel {
      background: linear-gradient(165deg, rgba(18, 28, 44, 0.88) 0%, rgba(10, 16, 28, 0.92) 100%) !important;
      border: 1px solid rgba(148, 183, 255, 0.18) !important;
      box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.04) inset,
        0 24px 56px -16px rgba(0, 0, 0, 0.65),
        0 0 80px -24px rgba(37, 99, 235, 0.35) !important;
      color: #f3f6fb !important;
    }

    body.dark-theme .login-panel .login-panel-header h3 {
      color: var(--ui-text-primary) !important;
    }

    body.dark-theme:not(.user-authenticated) .login-panel .login-panel-header h3 {
      color: #f8fafc !important;
    }

    body.dark-theme:not(.user-authenticated) .login-brand-name {
      color: #e8eef8;
    }

    body.dark-theme #tab1 .login-btn {
      background: linear-gradient(180deg, #3b82f6, #1d4ed8) !important;
      color: #fff !important;
      border: 1px solid transparent !important;
    }

    body.dark-theme:not(.user-authenticated) #tab1 .login-btn:hover {
      filter: brightness(1.06);
      background: linear-gradient(180deg, #4b8fff, #2563eb) !important;
    }

    body.dark-theme #tab1 .input-with-icon .input-icon,
    body.dark-theme #tab1 .input-with-icon svg {
      color: rgba(255, 255, 255, 0.6);
    }

    body.dark-theme #tab1 .user-name-input,
    body.dark-theme #tab1 .user-password-input {
      background: rgba(255, 255, 255, 0.12);
      border: none;
      box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1);
      color: #f5f5f7;
    }

    body.dark-theme #tab1 .user-name-input::placeholder,
    body.dark-theme #tab1 .user-password-input::placeholder {
      color: rgba(255, 255, 255, 0.4);
    }

    body.dark-theme #tab1 .user-name-input:focus,
    body.dark-theme #tab1 .user-password-input:focus {
      background: rgba(255, 255, 255, 0.18);
      border-color: rgba(106, 161, 255, 0.35);
      box-shadow: 0 0 0 2px var(--ui-focus-ring-color);
    }

    body.dark-theme #tab1 .user-photo {
      border-color: rgba(255, 255, 255, 0.35);
    }

    body.dark-theme #tab1 .select-model-btn {
      background: var(--ui-chrome-surface) !important;
      color: var(--ui-text-primary) !important;
      border: var(--ui-chrome-border) !important;
      box-shadow: var(--ui-chrome-shadow) !important;
      backdrop-filter: var(--ui-backdrop-filter);
      -webkit-backdrop-filter: var(--ui-backdrop-filter);
      font-family: var(--font-ui);
      font-size: var(--text-label-size);
    }

    body.dark-theme #tab1 .select-model-btn:hover {
      background: linear-gradient(var(--ui-nav-hover-bg), var(--ui-nav-hover-bg)), var(--ui-chrome-surface) !important;
      border: var(--ui-chrome-border) !important;
      box-shadow: var(--ui-chrome-shadow) !important;
      color: var(--ui-text-primary) !important;
    }

    body.dark-theme #tab1 .select-model-btn:focus-visible {
      outline: none !important;
      box-shadow: var(--ui-chrome-shadow), 0 0 0 2px var(--ui-focus-ring-color) !important;
    }

    body.dark-theme #tab1 .select-model-btn:disabled,
    body.dark-theme #tab1 .select-model-btn:disabled:hover {
      background: var(--ui-chrome-surface) !important;
      border: var(--ui-chrome-border) !important;
      box-shadow: var(--ui-chrome-shadow) !important;
      color: var(--ui-text-primary) !important;
      opacity: 0.5 !important;
      cursor: not-allowed !important;
    }

    body.dark-theme #tab1 .file-upload-btn {
      background: var(--ui-accent-soft-bg) !important;
      color: var(--ui-accent) !important;
      border: var(--ui-accent-soft-border) !important;
    }

    body.dark-theme #tab1 .file-upload-btn:hover {
      background: linear-gradient(rgba(106, 161, 255, 0.12), rgba(106, 161, 255, 0.12)), var(--ui-accent-soft-bg) !important;
      border: 1px solid rgba(106, 161, 255, 0.28) !important;
    }

    body.dark-theme #tab1 .login-btn {
      background: var(--ui-accent-soft-bg) !important;
      color: var(--ui-accent) !important;
      border: var(--ui-accent-soft-border) !important;
    }

    body.dark-theme #tab1 .login-btn:hover {
      background: linear-gradient(rgba(106, 161, 255, 0.12), rgba(106, 161, 255, 0.12)), var(--ui-accent-soft-bg) !important;
      border: 1px solid rgba(106, 161, 255, 0.28) !important;
    }

    body.dark-theme #tab1 .login-btn:focus-visible {
      box-shadow: 0 0 0 2px var(--ui-focus-ring-color) !important;
    }

    body.dark-theme #tab1 .model-progress-container {
      border-top-color: rgba(255, 255, 255, 0.12);
    }

    body.dark-theme #tab1 .model-progress-title {
      color: #f5f5f7;
    }

    body.dark-theme #tab1 .model-progress-info {
      color: rgba(255, 255, 255, 0.7);
    }

    body.dark-theme .tab3-content {
      background: var(--ui-chrome-surface) !important;
      color: var(--ui-text-primary);
      border: var(--ui-chrome-border) !important;
      box-shadow: var(--ui-chrome-shadow) !important;
    }

    body.dark-theme #tab3 .project-elements-form-row,
    body.dark-theme .project-elements-details,
    body.dark-theme .project-elements-table-wrapper {
      background: var(--ui-chrome-surface) !important;
      color: var(--ui-text-primary);
      border: var(--ui-chrome-border) !important;
      box-shadow: var(--ui-chrome-shadow) !important;
    }

    body.dark-theme .project-elements-details .pe-filter-row input,
    body.dark-theme .project-elements-details .pe-filter-row select {
      background: #212736 !important;
      color: var(--ui-text-primary) !important;
      border-color: #363d4d !important;
    }

    body.dark-theme .project-elements-details .pe-filter-row .pe-filter-apply,
    body.dark-theme .project-elements-details .pe-filter-row .pe-filter-clear {
      background: #2b3242 !important;
      color: #ffffff !important;
      border-color: #363d4d !important;
    }

    body.dark-theme .project-elements-details .pe-filter-row .pe-filter-apply:hover,
    body.dark-theme .project-elements-details .pe-filter-row .pe-filter-clear:hover {
      background: #2563eb !important;
      border-color: #2563eb !important;
      color: #ffffff !important;
    }

    body.dark-theme #noModelMessage3 {
      border-color: rgba(255, 255, 255, 0.2) !important;
      color: var(--ui-text-primary) !important;
    }

    body.dark-theme #tab3 button[type="button"]:not(.btn):not(.dfs-code-picker__btn):not(.dfs-code-picker__pick),
    body.dark-theme .file-input-label,
    body.dark-theme #tab3 .file-input-label {
      background: #2b3242 !important;
      color: #ffffff !important;
      border-color: #363d4d !important;
    }

    body.dark-theme #tab3 button[type="button"]:not(.btn):not(.dfs-code-picker__btn):not(.dfs-code-picker__pick):hover,
    body.dark-theme .file-input-label:hover,
    body.dark-theme #tab3 .file-input-label:hover {
      background: #2563eb !important;
      color: #ffffff !important;
    }

    /* Dark theme - File input label specific */
    body.dark-theme #tab3 .file-input-label,
    body.dark-theme .file-input-label {
      background: #2b3242 !important;
      color: #ffffff !important;
      border-color: #2563eb !important;
    }

    body.dark-theme #tab3 .file-input-label.has-file {
      background: #4CAF50 !important;
      color: #ffffff !important;
      border-color: #4CAF50 !important;
    }

    /* In the new construction-dash toolbar, the "Choose File" button matches the
       neutral .btn look by default; its .has-file (green) state above still wins
       once a file is picked. */
    body.dark-theme #tab3 .construction-dash .file-input-label:not(.has-file) {
      background: rgba(255, 255, 255, 0.06) !important;
      color: #e0e0e0 !important;
      border-color: rgba(255, 255, 255, 0.08) !important;
    }

    body.dark-theme .settings-modal-header {
      border-bottom-color: #363d4d;
    }

    body.dark-theme .settings-modal-header h2 {
      color: var(--ui-text-primary);
    }

    body.dark-theme .settings-modal-close {
      color: var(--ui-text-primary);
    }

    body.dark-theme .settings-modal-close:hover {
      background: var(--ui-nav-hover-bg);
      color: var(--ui-text-primary);
    }

    body.dark-theme .settings-tab-bar {
      border-bottom-color: #2e3444;
    }
    body.dark-theme .settings-tab-btn {
      color: #999;
    }
    body.dark-theme .settings-tab-btn:hover {
      color: #e0e0e0;
    }
    body.dark-theme .settings-tab-btn.active {
      color: var(--ui-accent);
      border: var(--ui-accent-soft-border);
      background: var(--ui-accent-soft-bg);
    }
    body.dark-theme .user-data-label { color: #b0b0b0; }
    body.dark-theme .user-data-value { color: #e0e0e0; }
    body.dark-theme .user-data-avatar { border-color: rgba(255,255,255,0.15); }
    body.dark-theme .user-data-avatar-btn { border-color: #363d4d; background: rgba(255,255,255,0.06); color: #e0e0e0; }
    body.dark-theme .user-data-avatar-btn:hover { background: rgba(255,255,255,0.1); }
    body.dark-theme .user-data-library-grid { background: rgba(255,255,255,0.04); }
    body.dark-theme .user-data-library-grid img.selected { border-color: #6aa1ff; }
    body.dark-theme .app-wallpaper-picker-label,
    body.dark-theme .app-wallpaper-tile-name { color: #b0b0b0; }
    body.dark-theme .app-wallpaper-tile:hover,
    body.dark-theme .app-wallpaper-tile.selected { border-color: #6aa1ff; }

    body.dark-theme .settings-option-label {
      color: #e0e0e0;
    }

    body.dark-theme .theme-toggle-btn {
      background: rgba(255, 255, 255, 0.06);
      color: #e0e0e0;
      border-color: rgba(255, 255, 255, 0.08);
    }

    body.dark-theme .language-select {
      background: rgba(255, 255, 255, 0.06);
      color: #e0e0e0;
      border-color: #363d4d;
    }

    /* Dark theme - All text elements should be light */
    body.dark-theme label,
    body.dark-theme .settings-option-label,
    body.dark-theme .settings-option-description,
    body.dark-theme .viewer-setting-label,
    body.dark-theme .toggle-label {
      color: #ffffff !important;
    }

    body.dark-theme #tab3 .project-elements-form-row label,
    body.dark-theme .project-elements-form-row label,
    body.dark-theme .bg-color-picker-label {
      color: #ffffff !important;
    }

    body.dark-theme input[type="text"],
    body.dark-theme input[type="file"],
    body.dark-theme input[type="password"],
    body.dark-theme input[type="number"],
    body.dark-theme select,
    body.dark-theme .user-name-input,
    body.dark-theme .user-password-input,
    body.dark-theme .viewer-setting-input,
    body.dark-theme .projectElementsSelect,
    body.dark-theme #tab3 select,
    body.dark-theme #tab3 input[type="file"] {
      background: #2b3242 !important;
      color: #ffffff !important;
      border-color: #363d4d !important;
    }

    body.dark-theme input::placeholder,
    body.dark-theme input::-webkit-input-placeholder,
    body.dark-theme input::-moz-placeholder,
    body.dark-theme input:-ms-input-placeholder {
      color: #b0b0b0 !important;
    }

    body.dark-theme select option {
      background: #2b3242 !important;
      color: #ffffff !important;
    }

    body.dark-theme .props-table th,
    body.dark-theme .props-table td {
      color: #ffffff !important;
      background: #2b3242 !important;
    }

    body.dark-theme .props-table th {
      background: #212736 !important;
      border-bottom-color: #363d4d !important;
      color: #ffffff !important;
    }

    body.dark-theme .props-table td {
      background: #2b3242 !important;
      color: #ffffff !important;
    }

    body.dark-theme .props-table tbody tr {
      background: #2b3242 !important;
    }

    body.dark-theme .props-table tbody tr td {
      background: #2b3242 !important;
      color: #ffffff !important;
    }

    body.dark-theme .props-table tbody tr:hover {
      background: #2e3444 !important;
    }

    body.dark-theme .props-table tbody tr:hover td {
      background: #2e3444 !important;
      color: #ffffff !important;
    }

    body.dark-theme .props-table tbody tr.element-row {
      background: #2b3242 !important;
    }

    body.dark-theme .props-table tbody tr.element-row td {
      background: #2b3242 !important;
      color: #ffffff !important;
    }

    body.dark-theme .props-table tbody tr.element-row:hover {
      background: #1e3a5f !important;
    }

    body.dark-theme .props-table tbody tr.element-row:hover td {
      background: #1e3a5f !important;
      color: #ffffff !important;
    }

    body.dark-theme .props-table tfoot tr.total-row td {
      background: #212736 !important;
      color: #ffffff !important;
      box-shadow: 0 -1px 0 #363d4d;
    }

    /* Dark theme - Force all table text to be white */
    body.dark-theme .props-table,
    body.dark-theme .props-table *,
    body.dark-theme .props-table th,
    body.dark-theme .props-table td,
    body.dark-theme .props-table th *,
    body.dark-theme .props-table td *,
    body.dark-theme .props-table span,
    body.dark-theme .props-table div,
    body.dark-theme .props-table strong {
      color: #ffffff !important;
    }

    /* Dark theme - Override inline styles in table cells */
    body.dark-theme .props-table th[style*="color"],
    body.dark-theme .props-table td[style*="color"] {
      color: #ffffff !important;
    }

    body.dark-theme .empty {
      color: #b0b0b0 !important;
    }

    body.dark-theme .no-model-message {
      color: #000000 !important;
    }

    body.dark-theme .model-progress-title,
    body.dark-theme .model-progress-info {
      color: #ffffff !important;
    }

    /* Dark theme - Model Progress Container */
    body.dark-theme .model-progress-container {
      background: #2b3242 !important;
      border-color: #363d4d !important;
    }

    body.dark-theme .model-progress-bar-wrapper {
      background: #212736 !important;
    }

    body.dark-theme .model-progress-text {
      color: #ffffff !important;
    }

    body.dark-theme .model-progress-status.pending {
      background: #363d4d !important;
      color: #ffd700 !important;
    }

    body.dark-theme .model-progress-status.inprogress {
      background: #1e3a5f !important;
      color: #64b5f6 !important;
    }

    body.dark-theme .model-progress-status.success {
      background: #2d5a3d !important;
      color: #81c784 !important;
    }

    body.dark-theme .model-progress-status.failed {
      background: #5a2d2d !important;
      color: #e57373 !important;
    }

    body.dark-theme .column-visibility-btn {
      background: #2b3242 !important;
      color: #ffffff !important;
      border-color: #363d4d !important;
    }

    body.dark-theme .column-visibility-btn:hover {
      background: #363d4d !important;
      color: #ffffff !important;
    }

    body.dark-theme .column-visibility-dropdown {
      background: #2b3242 !important;
      border-color: #363d4d !important;
    }

    body.dark-theme .column-visibility-action-btn {
      background: #363d4d;
      border-color: #4a5163;
      color: #ffffff;
    }

    body.dark-theme .column-visibility-action-btn:hover {
      background: #3f4658;
      border-color: #5b6478;
      color: #ffffff;
    }

    body.dark-theme .column-visibility-actions {
      background: #2b3242;
    }

    body.dark-theme .column-visibility-divider {
      background: rgba(255, 255, 255, 0.12);
    }

    body.dark-theme .column-visibility-item {
      color: #ffffff !important;
    }

    body.dark-theme .column-visibility-item:hover {
      background: #2e3444 !important;
    }

    body.dark-theme .column-visibility-item label {
      color: #ffffff !important;
    }

    /* Dark theme - Filter elements */
    body.dark-theme .pe-filters label,
    body.dark-theme .pe-filters span {
      color: #ffffff !important;
    }

    body.dark-theme .pe-filter-col,
    body.dark-theme .pe-filter-val {
      background: #2b3242 !important;
      color: #ffffff !important;
      border-color: #363d4d !important;
    }

    body.dark-theme .pe-filter-val::placeholder {
      color: #b0b0b0 !important;
    }

    body.dark-theme .pe-filter-col option {
      background: #2b3242 !important;
      color: #ffffff !important;
    }

    body.dark-theme .pe-filter-apply,
    body.dark-theme .pe-filter-clear {
      background: #2b3242 !important;
      color: #ffffff !important;
      border-color: #363d4d !important;
    }

    body.dark-theme .pe-filter-apply:hover,
    body.dark-theme .pe-filter-clear:hover {
      background: #2563eb !important;
      color: #ffffff !important;
    }

    /* Dark theme - Pagination and other text elements */
    body.dark-theme span,
    body.dark-theme div[style*="color:#2e3444"],
    body.dark-theme div[style*="color:#666"] {
      color: #ffffff !important;
    }

    body.dark-theme .user-info label,
    body.dark-theme .user-info input {
      color: #ffffff !important;
    }

    body.dark-theme .user-info input::placeholder {
      color: #b0b0b0 !important;
    }

    /* Dark theme - Override inline styles for text color */
    body.dark-theme [style*="color:#2e3444"],
    body.dark-theme [style*="color:#666"],
    body.dark-theme [style*="color: #2e3444"],
    body.dark-theme [style*="color: #666"],
    body.dark-theme [style*="color:#495057"],
    body.dark-theme [style*="color: #495057"],
    body.dark-theme [style*="color:#333"],
    body.dark-theme [style*="color: #333"] {
      color: #ffffff !important;
    }

    /* Dark theme - Override any background colors in table */
    body.dark-theme .props-table [style*="background:#ffffff"],
    body.dark-theme .props-table [style*="background: #ffffff"] {
      background: #2b3242 !important;
    }

    body.dark-theme h1,
    body.dark-theme h2,
    body.dark-theme h3,
    body.dark-theme h4,
    body.dark-theme h5,
    body.dark-theme h6 {
      color: #ffffff !important;
    }

    body.dark-theme p {
      color: #e0e0e0 !important;
    }

    /* Dark theme - Additional text elements */
    body.dark-theme .bg-color-picker-label,
    body.dark-theme .bg-color-picker-container {
      color: #ffffff !important;
    }

    body.dark-theme .tabs-header {
      background: rgba(30, 30, 32, 0.65) !important;
      border-bottom-color: rgba(255, 255, 255, 0.12) !important;
    }

    body.dark-theme .app-sidebar {
      background-color: var(--ui-sidebar-surface) !important;
      background-image: none !important;
      backdrop-filter: var(--ui-backdrop-filter);
      -webkit-backdrop-filter: var(--ui-backdrop-filter);
      border: var(--ui-chrome-border) !important;
      color: var(--ui-text-primary) !important;
      box-shadow: var(--ui-chrome-shadow) !important;
    }

    body.dark-theme .app-sidebar .tab-button {
      color: var(--ui-text-primary) !important;
      background: transparent !important;
      border: 1px solid transparent !important;
    }

    body.dark-theme .app-sidebar .tab-button:hover {
      background: var(--ui-nav-hover-bg) !important;
      border-color: var(--ui-hover-border-color) !important;
    }

    body.dark-theme .app-sidebar .tab-button.active {
      background: var(--ui-accent-soft-bg) !important;
      border: 1px solid transparent !important;
      color: var(--ui-accent) !important;
      font-weight: 600 !important;
    }

    body.dark-theme .app-sidebar .sidebar-toggle {
      background: transparent !important;
      border: 1px solid transparent !important;
      color: var(--ui-text-primary) !important;
    }

    body.dark-theme .app-sidebar .sidebar-toggle:hover {
      background: var(--ui-sidebar-toggle-hover-bg) !important;
      border-color: var(--ui-hover-border-color) !important;
    }

    body.dark-theme .app-sidebar-footer {
      border-top: var(--ui-chrome-border) !important;
    }

    body.dark-theme .sidebar-user-avatar {
      border: var(--ui-avatar-border) !important;
    }

    body.dark-theme .sidebar-actions button {
      background: transparent !important;
      border: 1px solid transparent !important;
      color: var(--ui-text-primary) !important;
    }

    body.dark-theme .sidebar-actions button:hover {
      background: var(--ui-nav-hover-bg) !important;
      border-color: var(--ui-hover-border-color) !important;
    }

    body.dark-theme .tab-button {
      background: rgba(255, 255, 255, 0.12) !important;
      border: 1px solid rgba(255, 255, 255, 0.2) !important;
      color: rgba(255, 255, 255, 0.9) !important;
    }

    body.dark-theme .tab-button:hover {
      background: rgba(255, 255, 255, 0.2) !important;
      border-color: rgba(255, 255, 255, 0.3) !important;
      color: #f5f5f7 !important;
    }

    body.dark-theme .tab-button.active {
      background: rgba(255, 255, 255, 0.25) !important;
      border-color: rgba(255, 255, 255, 0.35) !important;
      color: #f5f5f7 !important;
      box-shadow: 0 0 0 2px rgba(10, 132, 255, 0.4) !important;
    }

    /* Dark theme - Override any dark text colors */
    body.dark-theme strong {
      color: #ffffff !important;
    }

    /* Dark theme - Pagination and navigation elements */
    body.dark-theme button[style*="background:#ffffff"],
    body.dark-theme button[style*="background: #ffffff"] {
      background: #2b3242 !important;
      color: #ffffff !important;
      border-color: #363d4d !important;
    }

    body.dark-theme input[style*="background:#ffffff"],
    body.dark-theme input[style*="background: #ffffff"] {
      background: #2b3242 !important;
      color: #ffffff !important;
      border-color: #363d4d !important;
    }

    /* ==========================
           TAB 2 (Viewer)
           ========================== */
    #forgeViewer {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background-color: #F0F8FF;
      /* Let APS handle single-finger orbit / pinch; avoid browser scroll stealing gestures. */
      touch-action: none;
    }

    #forgeViewer .adsk-viewing-viewer,
    #forgeViewer .adsk-viewing-viewer canvas,
    #forgeViewer3D,
    #forgeViewer3D .adsk-viewing-viewer,
    #forgeViewer3D .adsk-viewing-viewer canvas {
      touch-action: none;
    }

    .viewer-state-legend {
      position: absolute;
      /* Bottom-left, clear of the sidebar (the viewer runs under it, like .pg-sel-filter): the bottom-right corner
         holds the AI chat button (João, 2026-10-11). */
      left: var(--ui-content-inset-left-expanded);
      right: auto;
      /* Above the viewer toolbar, which on laptop screens reaches this corner. */
      bottom: 72px;
      /* Above #viewerRightPanels (z-index 200) so minimize stays clickable when Seleção overlaps. */
      z-index: 220;
      min-width: 200px;
      max-width: min(280px, calc(100% - 24px));
      padding: 10px 12px;
      border-radius: 10px;
      border: 1px solid rgba(255, 255, 255, 0.14);
      background: rgba(18, 22, 28, 0.82);
      color: #f3f5f7;
      backdrop-filter: blur(8px);
      box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
      pointer-events: auto;
    }

    body.sidebar-collapsed .viewer-state-legend {
      left: var(--ui-content-inset-left-collapsed);
    }

    body:not(.dark-theme) .viewer-state-legend {
      border-color: rgba(15, 23, 42, 0.12);
      background: rgba(255, 255, 255, 0.92);
      color: #0f172a;
      box-shadow: 0 8px 24px rgba(15, 23, 42, 0.14);
    }

    .viewer-state-legend__head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      margin-bottom: 8px;
    }

    .viewer-state-legend.collapsed {
      min-width: 0;
      max-width: none;
      width: auto;
      padding: 6px 8px;
    }

    .viewer-state-legend.collapsed .viewer-state-legend__head {
      margin-bottom: 0;
      gap: 6px;
    }

    .viewer-state-legend__title {
      font-size: 12px;
      font-weight: 650;
      letter-spacing: 0.02em;
      white-space: nowrap;
    }

    .viewer-state-legend__toggle {
      width: 24px;
      height: 24px;
      border: 0;
      border-radius: 6px;
      background: rgba(255, 255, 255, 0.08);
      color: inherit;
      cursor: pointer;
      line-height: 1;
      font-size: 14px;
      flex: 0 0 auto;
    }

    body:not(.dark-theme) .viewer-state-legend__toggle {
      background: rgba(15, 23, 42, 0.06);
    }

    .viewer-state-legend__toggle:hover {
      background: rgba(255, 255, 255, 0.14);
    }

    body:not(.dark-theme) .viewer-state-legend__toggle:hover {
      background: rgba(15, 23, 42, 0.1);
    }

    .viewer-state-legend__list {
      list-style: none;
      margin: 0;
      padding: 0;
      display: grid;
      gap: 6px;
    }

    .viewer-state-legend__group {
      display: grid;
      gap: 6px;
    }

    .viewer-state-legend__group + .viewer-state-legend__group {
      margin-top: 10px;
      padding-top: 8px;
      border-top: 1px solid rgba(255, 255, 255, 0.12);
    }

    body:not(.dark-theme) .viewer-state-legend__group + .viewer-state-legend__group {
      border-top-color: rgba(15, 23, 42, 0.1);
    }

    .viewer-state-legend__group-head {
      display: flex;
      align-items: center;
      gap: 8px;
      margin: 0;
      cursor: pointer;
      user-select: none;
    }

    .viewer-state-legend__group-check {
      width: 14px;
      height: 14px;
      margin: 0;
      flex: 0 0 auto;
      accent-color: var(--ui-accent, #2563eb);
      cursor: pointer;
    }

    .viewer-state-legend__group-title {
      font-size: 11px;
      font-weight: 700;
      letter-spacing: 0.04em;
      text-transform: uppercase;
      opacity: 0.9;
    }

    .viewer-state-legend__list[hidden] {
      display: none !important;
    }

    .viewer-state-legend__list li {
      display: flex;
      align-items: center;
      gap: 8px;
      font-size: 12px;
      line-height: 1.25;
    }

    .viewer-state-legend__list li[hidden] {
      display: none !important;
    }

    .viewer-state-legend__swatch {
      width: 14px;
      height: 14px;
      border-radius: 3px;
      flex: 0 0 auto;
      box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
      background: #64748b;
    }
    .viewer-state-legend__swatch[data-swatch="emObra"],
    .viewer-state-legend__swatch[data-swatch="execution"] {
      background: rgb(255, 217, 0);
    }
    .viewer-state-legend__swatch[data-swatch="awaiting"],
    .viewer-state-legend__swatch[data-swatch="awaitingOrConfirmed"] {
      background: rgb(255, 140, 0);
    }
    .viewer-state-legend__swatch[data-swatch="confirmed"] {
      background: rgb(158, 82, 242);
    }
    .viewer-state-legend__swatch[data-swatch="payable"] {
      background: rgb(38, 115, 250);
    }
    .viewer-state-legend__swatch[data-swatch="paid"] {
      background: rgb(46, 199, 89);
    }
    .viewer-state-legend__swatch[data-swatch="initial"] {
      background: rgb(148, 163, 184);
    }

    .viewer-state-legend__state-meta {
      display: flex;
      flex-direction: column;
      gap: 1px;
      min-width: 0;
    }

    .viewer-state-legend__state-name {
      font-weight: 600;
    }

    .viewer-state-legend__state-desc {
      font-size: 11px;
      opacity: 0.75;
      line-height: 1.3;
    }

    .viewer-state-legend__hint {
      margin: 8px 0 0;
      font-size: 11px;
      line-height: 1.35;
      opacity: 0.72;
    }

    .viewer-state-legend.collapsed .viewer-state-legend__body {
      display: none;
    }

    body.split-2d-3d .viewer-state-legend {
      max-width: min(240px, calc(100% - 24px));
    }

    body.split-2d-3d .viewer-state-legend.collapsed {
      max-width: none;
    }

    .pg-window-select-overlay {
      position: absolute;
      inset: 0;
      pointer-events: none;
      z-index: 8;
      overflow: hidden;
    }

    .pg-window-select-overlay[hidden] {
      display: none;
    }

    .pg-window-select-rect {
      position: absolute;
      box-sizing: border-box;
      border: 1.5px solid #3b82f6;
      background: rgba(59, 130, 246, 0.16);
    }

    .pg-window-select-overlay.is-crossing .pg-window-select-rect {
      border-style: dashed;
      border-color: #22c55e;
      background: rgba(34, 197, 94, 0.14);
    }

    .pg-sel-filter {
      position: fixed;
      top: var(--ui-sidebar-viewport-inset);
      left: var(--ui-content-inset-left-expanded);
      bottom: var(--ui-sidebar-viewport-inset);
      z-index: 11950;
      width: min(320px, calc(100vw - var(--ui-content-inset-left-expanded) - 24px));
      max-height: none;
      height: auto;
      display: flex;
      flex-direction: column;
      border-radius: var(--ui-chrome-radius);
      border: var(--ui-chrome-border);
      background: var(--ui-sidebar-surface);
      color: var(--ui-text-primary);
      backdrop-filter: var(--ui-backdrop-filter);
      -webkit-backdrop-filter: var(--ui-backdrop-filter);
      box-shadow: var(--ui-chrome-shadow);
      pointer-events: auto;
    }

    body.sidebar-collapsed .pg-sel-filter {
      left: var(--ui-content-inset-left-collapsed);
      width: min(320px, calc(100vw - var(--ui-content-inset-left-collapsed) - 24px));
    }

    .tabs-container:not(:has(#tab2.tab-content.active)) .pg-sel-filter {
      display: none;
    }

    .pg-sel-filter.is-dragging {
      bottom: auto;
    }

    body:not(.dark-theme) .pg-sel-filter {
      border: var(--ui-chrome-border);
      background: var(--ui-sidebar-surface);
      color: var(--ui-text-primary);
      box-shadow: var(--ui-chrome-shadow);
    }

    .pg-sel-filter[hidden] {
      display: none;
    }

    .pg-sel-filter__head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      padding: 11px 12px;
      border-bottom: 1px solid rgba(148, 163, 184, 0.16);
      background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent);
      cursor: move;
      user-select: none;
    }

    .pg-sel-filter.is-dragging .pg-sel-filter__head {
      cursor: grabbing;
    }

    .pg-sel-filter__titles {
      min-width: 0;
      flex: 1;
    }

    .pg-sel-filter__titles h3 {
      margin: 0;
      display: flex;
      align-items: center;
      gap: 8px;
      font-size: 13px;
      font-weight: 650;
      letter-spacing: 0.01em;
      line-height: 1.2;
    }

    .pg-sel-filter__badge {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-width: 1.5rem;
      height: 1.35rem;
      padding: 0 6px;
      border-radius: 999px;
      border: 1px solid rgba(96, 165, 250, 0.45);
      background: rgba(59, 130, 246, 0.22);
      color: #dbeafe;
      font-size: 11px;
      font-weight: 700;
      line-height: 1;
    }

    .pg-sel-filter__badge--muted {
      border-color: rgba(148, 163, 184, 0.35);
      background: rgba(148, 163, 184, 0.14);
      color: #cbd5e1;
      font-weight: 600;
    }

    .pg-sel-filter__meta {
      margin: 4px 0 0;
      font-size: 11px;
      opacity: 0.72;
      line-height: 1.35;
    }

    .pg-sel-filter__head-actions {
      display: flex;
      align-items: center;
      gap: 6px;
      flex-shrink: 0;
    }

    .pg-sel-filter__min-btn {
      width: 28px;
      height: 28px;
      border-radius: 8px;
      border: 1px solid rgba(148, 163, 184, 0.28);
      background: rgba(15, 23, 42, 0.35);
      color: inherit;
    }

    .pg-sel-filter__min-btn:hover,
    .pg-sel-filter__min-btn:focus-visible {
      border-color: rgba(96, 165, 250, 0.55);
      background: rgba(59, 130, 246, 0.18);
      outline: none;
    }

    .pg-sel-filter__text-btn,
    .pg-sel-filter__link {
      border: 0;
      background: transparent;
      color: inherit;
      font: inherit;
      cursor: pointer;
      opacity: 0.8;
    }

    .pg-sel-filter__text-btn {
      font-size: 11px;
      text-decoration: underline;
      padding: 2px 4px;
    }

    .pg-sel-filter__link {
      font-size: 11px;
      padding: 0;
    }

    .pg-sel-filter__text-btn:hover,
    .pg-sel-filter__link:hover {
      opacity: 1;
    }

    .pg-sel-filter__body {
      overflow: auto;
      padding: 0 10px 10px;
      min-height: 0;
    }

    .pg-sel-filter__section-banner {
      margin: 8px 0 10px;
      padding: 8px 10px;
      border-radius: 8px;
      border: 1px solid rgba(255, 255, 255, 0.12);
      background: rgba(255, 255, 255, 0.04);
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .pg-sel-filter__section-banner.is-active-section {
      border-color: rgba(59, 130, 246, 0.55);
      background: rgba(37, 99, 235, 0.18);
    }

    .pg-sel-filter__section-banner-label {
      display: block;
      flex: 1 1 auto;
      min-width: 0;
      font-size: 0.78rem;
      font-weight: 700;
      letter-spacing: 0.04em;
      text-transform: uppercase;
      color: rgba(255, 255, 255, 0.88);
      line-height: 1.3;
      word-break: break-word;
    }

    body:not(.dark-theme) .pg-sel-filter__section-banner {
      border-color: rgba(15, 23, 42, 0.12);
      background: rgba(15, 23, 42, 0.04);
    }

    body:not(.dark-theme) .pg-sel-filter__section-banner.is-active-section {
      border-color: rgba(37, 99, 235, 0.45);
      background: rgba(37, 99, 235, 0.1);
    }

    body:not(.dark-theme) .pg-sel-filter__section-banner-label {
      color: rgba(15, 23, 42, 0.88);
    }

    .pg-sel-filter__elements {
      margin-top: 8px;
      padding-bottom: 8px;
      border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    body:not(.dark-theme) .pg-sel-filter__elements {
      border-bottom-color: rgba(15, 23, 42, 0.08);
    }

    .pg-sel-filter__element-card {
      display: flex;
      flex-direction: column;
      gap: 4px;
      padding: 10px 10px;
      border-radius: 10px;
      border: 1px solid rgba(96, 165, 250, 0.28);
      background: rgba(59, 130, 246, 0.12);
    }

    .pg-sel-filter__element-list {
      list-style: none;
      margin: 0;
      padding: 0;
      display: flex;
      flex-direction: column;
      gap: 4px;
      max-height: 180px;
      overflow: auto;
    }

    .pg-sel-filter__element-row {
      display: flex;
      flex-direction: column;
      gap: 2px;
      padding: 7px 8px;
      border-radius: 8px;
      background: rgba(255, 255, 255, 0.04);
    }

    body:not(.dark-theme) .pg-sel-filter__element-row {
      background: rgba(15, 23, 42, 0.04);
    }

    .pg-sel-filter__element-title {
      font-size: 12px;
      font-weight: 600;
      line-height: 1.25;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .pg-sel-filter__element-meta {
      font-size: 10px;
      opacity: 0.7;
      line-height: 1.3;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    /* Collapse to a compact header bar (panel uses top+bottom stretch when expanded). */
    .pg-sel-filter.is-collapsed {
      bottom: auto;
      height: auto;
      max-height: none;
    }

    .pg-sel-filter.is-collapsed .pg-sel-filter__body {
      display: none;
    }

    .pg-sel-filter.is-collapsed .pg-sel-filter__meta,
    .pg-sel-filter.is-collapsed .pg-sel-filter__text-btn {
      display: none;
    }

    .pg-sel-filter.is-collapsed .pg-sel-filter__head {
      align-items: center;
      border-bottom: 0;
      padding: 10px 12px;
    }

    .pg-sel-filter [data-sf-min] {
      min-width: 28px;
      min-height: 28px;
      line-height: 1;
      font-size: 16px;
      font-weight: 600;
    }

    .pg-sel-filter__loading,
    .pg-sel-filter__empty {
      margin: 8px 0;
      font-size: 12px;
      opacity: 0.75;
    }

    .pg-sel-filter__facet + .pg-sel-filter__facet {
      margin-top: 10px;
      padding-top: 8px;
      border-top: 1px solid rgba(255, 255, 255, 0.1);
    }

    body:not(.dark-theme) .pg-sel-filter__facet + .pg-sel-filter__facet {
      border-top-color: rgba(15, 23, 42, 0.08);
    }

    .pg-sel-filter__facet-head {
      display: flex;
      align-items: baseline;
      justify-content: space-between;
      gap: 8px;
      margin-bottom: 4px;
    }

    .pg-sel-filter__facet-head h4 {
      margin: 0;
      font-size: 12px;
      font-weight: 650;
    }

    .pg-sel-filter__facet-actions {
      display: flex;
      gap: 8px;
    }

    .pg-sel-filter__rows {
      display: flex;
      flex-direction: column;
    }

    .pg-sel-filter__row {
      display: grid;
      grid-template-columns: auto minmax(0, 1fr) auto;
      align-items: center;
      gap: 8px;
      padding: 3px 0;
      font-size: 12px;
      cursor: pointer;
    }

    .pg-sel-filter__name {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .pg-sel-filter__count {
      opacity: 0.7;
      font-variant-numeric: tabular-nums;
    }

    .pg-sel-filter__sets {
      margin-top: 10px;
      padding-top: 8px;
      border-top: 1px solid rgba(255, 255, 255, 0.1);
    }

    body:not(.dark-theme) .pg-sel-filter__sets {
      border-top-color: rgba(15, 23, 42, 0.08);
    }

    .pg-sel-filter__save {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      gap: 6px;
      margin: 6px 0 8px;
    }

    .pg-sel-filter__name-input {
      width: 100%;
      min-width: 0;
      box-sizing: border-box;
      padding: 5px 8px;
      border-radius: 6px;
      border: 1px solid rgba(255, 255, 255, 0.18);
      background: rgba(0, 0, 0, 0.2);
      color: inherit;
      font: inherit;
      font-size: 12px;
    }

    body:not(.dark-theme) .pg-sel-filter__name-input {
      border-color: rgba(15, 23, 42, 0.16);
      background: #fff;
    }

    .pg-sel-filter__save-btn {
      padding: 5px 10px;
      border: 0;
      border-radius: 6px;
      background: #2563eb;
      color: #fff;
      font: inherit;
      font-size: 12px;
      cursor: pointer;
    }

    .pg-sel-filter__save-btn:disabled {
      opacity: 0.6;
      cursor: default;
    }

    .pg-sel-filter__set-list {
      list-style: none;
      margin: 0;
      padding: 0;
      display: flex;
      flex-direction: column;
      gap: 2px;
    }

    .pg-sel-filter__set {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto auto;
      align-items: center;
      gap: 4px;
    }

    .pg-sel-filter__set.is-renaming {
      grid-template-columns: minmax(0, 1fr) auto;
    }

    .pg-sel-filter__set.is-active .pg-sel-filter__set-name {
      border-radius: 6px;
      padding: 4px 6px;
      background: rgba(59, 130, 246, 0.2);
      box-shadow: inset 2px 0 0 #60a5fa;
    }

    .pg-sel-filter__set-name {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      gap: 8px;
      align-items: center;
      width: 100%;
      padding: 4px 0;
      border: 0;
      background: transparent;
      color: inherit;
      font: inherit;
      font-size: 12px;
      text-align: left;
      cursor: pointer;
    }

    .pg-sel-filter__set-name span:first-child {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .pg-sel-filter__set-delete {
      border: 0;
      background: transparent;
      color: inherit;
      opacity: 0.55;
      cursor: pointer;
      font-size: 14px;
      line-height: 1;
      padding: 2px 4px;
    }

    .pg-sel-filter__set-rename {
      border: 0;
      background: transparent;
      color: inherit;
      opacity: 0.55;
      cursor: pointer;
      font-size: 13px;
      line-height: 1;
      padding: 2px 4px;
      flex-shrink: 0;
    }

    .pg-sel-filter__rename-form {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      gap: 4px;
      min-width: 0;
    }

    .pg-sel-filter__rename-input {
      width: 100%;
      min-width: 0;
      box-sizing: border-box;
      font: inherit;
      font-size: 12px;
      padding: 4px 6px;
      border-radius: 6px;
      border: 1px solid rgba(91, 156, 255, 0.4);
      background: rgba(255, 255, 255, 0.08);
      color: inherit;
    }

    .pg-sel-filter__rename-ok {
      border: 0;
      border-radius: 6px;
      padding: 4px 8px;
      font-size: 11px;
      font-weight: 650;
      cursor: pointer;
      background: rgba(91, 156, 255, 0.22);
      color: inherit;
    }

    body:not(.dark-theme) .pg-sel-filter__rename-input {
      background: #fff;
      border-color: rgba(15, 23, 42, 0.18);
      color: #0f172a;
    }

    body:not(.dark-theme) .pg-sel-filter__rename-ok {
      background: rgba(37, 99, 235, 0.12);
      color: #0f172a;
    }

    .pg-sel-filter__set-delete:hover,
    .pg-sel-filter__set-rename:hover,
    .pg-sel-filter__set-name:hover {
      opacity: 1;
    }

    #forgeViewer3D {
      position: absolute;
      top: 0;
      left: 50%;
      width: 50%;
      height: 100%;
      margin: 0;
      background-color: #333;
      display: none;
      border-left: 2px solid #666;
    }

    /* Separador arrastável entre 2D e 3D (só visível em split) */
    #splitResizer.split-resizer {
      display: none;
      position: absolute;
      top: 0;
      width: 6px;
      height: 100%;
      cursor: col-resize;
      z-index: 100;
      background: #666;
      left: calc(var(--split-pct, 50) * 1%);
      transform: translateX(-50%);
    }
    body.split-2d-3d #splitResizer.split-resizer {
      display: block;
    }
    body.split-2d-3d #splitResizer.split-resizer:hover,
    body.split-2d-3d #splitResizer.split-resizer.dragging {
      background: #888;
    }

    body.split-2d-3d #forgeViewer {
      width: calc(var(--split-pct, 50) * 1%) !important;
      overflow: hidden;
    }

    body.split-2d-3d #forgeViewer3D {
      display: block !important;
      left: calc(var(--split-pct, 50) * 1%);
      width: calc((100 - var(--split-pct, 50)) * 1%);
      border-left: none;
    }

    #tab2.tab-content.active {
      height: 100%;
    }

    .no-model-message {
      display: flex;
      align-items: center;
      justify-content: center;
      height: 100%;
      font-size: 24px;
      color: #999;
      background: #f9f9f9;
    }

    /* ==========================
           TAB 3 (Analysis)
           ========================== */
    .tab3-content {
      padding: 32px 24px 32px 24px;
      max-width: none;
      margin: 24px;
      flex: 1;
      min-width: 0;
      overflow-y: hidden;
      overflow-x: hidden;
      background: var(--ui-sidebar-surface);
      backdrop-filter: var(--ui-backdrop-filter);
      -webkit-backdrop-filter: var(--ui-backdrop-filter);
      border: var(--ui-chrome-border);
      border-radius: var(--ui-chrome-radius);
      box-shadow: var(--ui-chrome-shadow);
      box-sizing: border-box;
      min-height: 0;
      color: var(--ui-text-primary);
      display: flex;
      flex-direction: row;
      align-items: stretch;
      gap: 12px;
    }

    .page-brand-rail {
      flex: 0 0 120px;
      width: 120px;
      display: flex;
      align-items: center;
      justify-content: center;
      pointer-events: none;
      position: sticky;
      top: 0;
      align-self: stretch;
    }

    .page-brand-rail img {
      display: block;
      width: 108px;
      height: auto;
      max-height: min(78vh, 720px);
      object-fit: contain;
      opacity: 0.92;
    }

    .tab3-content-main {
      flex: 1 1 auto;
      min-width: 0;
      min-height: 0;
      display: flex;
      flex-direction: column;
    }

    /* Analysis content should clear the floating sidebar without affecting Viewer */
    body.user-authenticated #tab3 .tab3-content {
      margin-top: var(--ui-sidebar-viewport-inset);
      margin-right: var(--ui-sidebar-viewport-inset);
      margin-bottom: var(--ui-sidebar-viewport-inset);
      margin-left: var(--ui-content-inset-left-expanded);
      padding-left: 24px;
      transition: margin-top var(--motion-smooth-medium), margin-right var(--motion-smooth-medium), margin-bottom var(--motion-smooth-medium), margin-left var(--motion-smooth-medium), padding-left var(--motion-smooth-medium);
    }

    body.user-authenticated.sidebar-collapsed #tab3 .tab3-content {
      margin-top: var(--ui-sidebar-viewport-inset);
      margin-right: var(--ui-sidebar-viewport-inset);
      margin-bottom: var(--ui-sidebar-viewport-inset);
      margin-left: var(--ui-content-inset-left-collapsed);
      padding-left: 24px;
    }

    /* Construction tabs + measurement report + AI + Auditoria — same layout as tab3 */
    body.user-authenticated #tab4 .tab3-content,
    body.user-authenticated #tab6 .tab3-content,
    body.user-authenticated #tab7 .tab3-content,
    body.user-authenticated #tab8 .tab3-content,
    body.user-authenticated #tab11 .tab3-content {
      margin-top: var(--ui-sidebar-viewport-inset);
      margin-right: var(--ui-sidebar-viewport-inset);
      margin-bottom: var(--ui-sidebar-viewport-inset);
      margin-left: var(--ui-content-inset-left-expanded);
      padding-left: 24px;
      transition: margin-top var(--motion-smooth-medium), margin-right var(--motion-smooth-medium), margin-bottom var(--motion-smooth-medium), margin-left var(--motion-smooth-medium), padding-left var(--motion-smooth-medium);
    }

    body.user-authenticated.sidebar-collapsed #tab4 .tab3-content,
    body.user-authenticated.sidebar-collapsed #tab6 .tab3-content,
    body.user-authenticated.sidebar-collapsed #tab7 .tab3-content,
    body.user-authenticated.sidebar-collapsed #tab8 .tab3-content,
    body.user-authenticated.sidebar-collapsed #tab11 .tab3-content {
      margin-top: var(--ui-sidebar-viewport-inset);
      margin-right: var(--ui-sidebar-viewport-inset);
      margin-bottom: var(--ui-sidebar-viewport-inset);
      margin-left: var(--ui-content-inset-left-collapsed);
      padding-left: 24px;
    }

    #tab4.tab-content.active,
    #tab6.tab-content.active,
    #tab7.tab-content.active,
    #tab8.tab-content.active,
    #tab11.tab-content.active {
      overflow: hidden;
      display: flex;
      flex-direction: column;
      min-height: 0;
    }

    /* Execução / Financeiro / Planeamento / relatórios / Auditoria: scroll no painel inteiro */
    body.user-authenticated #tab4 .tab3-content,
    body.user-authenticated #tab6 .tab3-content,
    body.user-authenticated #tab7 .tab3-content,
    body.user-authenticated #tab8 .tab3-content,
    body.user-authenticated #tab11 .tab3-content,
    body.user-authenticated.sidebar-collapsed #tab4 .tab3-content,
    body.user-authenticated.sidebar-collapsed #tab6 .tab3-content,
    body.user-authenticated.sidebar-collapsed #tab7 .tab3-content,
    body.user-authenticated.sidebar-collapsed #tab8 .tab3-content,
    body.user-authenticated.sidebar-collapsed #tab11 .tab3-content {
      flex: 1 1 0;
      min-height: 0;
      max-height: 100%;
      overflow: hidden;
    }

    body.user-authenticated #tab4 .tab3-content-main,
    body.user-authenticated #tab7 .tab3-content-main,
    body.user-authenticated #tab9 .tab3-content-main,
    body.user-authenticated #tab10 .tab3-content-main,
    body.user-authenticated #tab11 .tab3-content-main {
      overflow-x: hidden;
      overflow-y: auto;
      overscroll-behavior-y: contain;
      -webkit-overflow-scrolling: touch;
      min-height: 0;
    }

    /* ============================================================
       Construction dashboard styles (Execution / Financial / Planning)
       ============================================================ */
    :root {
      --exec-hue: 160;
      --fin-hue: 43;
      --plan-accent: #a78bfa;
      --plan-accent-soft: rgba(167, 139, 250, 0.18);
    }

    .construction-dash {
      max-width: 1200px;
      margin: 0 auto;
      padding: 8px 0 48px;
      --dash-accent: #5b9cff;
      --dash-accent-soft: rgba(91, 156, 255, 0.14);
    }

    #tab3 .construction-dash .toolbar {
      overflow: visible;
    }

    #tab3 .construction-dash,
    #tab3 .tab3-content-main,
    #tab3 #tab3Content {
      overflow: visible;
    }

    #tab3 .field--dfs-code {
      flex: 0 1 200px;
      width: 200px;
      max-width: 220px;
      min-width: 0;
    }

    #tab3 .construction-dash .toolbar-actions {
      margin-left: 0;
      align-self: end;
    }

    #tab3 .construction-dash .toolbar-hint {
      align-self: center;
      max-width: 16rem;
    }

    .construction-dash .toolbar {
      display: flex;
      flex-wrap: wrap;
      align-items: flex-end;
      gap: 12px;
      margin-bottom: 16px;
      padding: 14px 16px;
      background:
        linear-gradient(105deg, var(--dash-accent-soft), transparent 46%),
        var(--ui-chrome-surface);
      border: 1px solid color-mix(in srgb, var(--dash-accent) 28%, transparent);
      border-radius: var(--ui-chrome-radius);
      box-shadow: var(--ui-chrome-shadow);
    }

    /* Controlo de Obra: row1 = model/PE/performer; row2 = dates together + period + actions */
    .construction-dash--obra .construction-obra-toolbar {
      flex-direction: column;
      align-items: stretch;
      flex-wrap: nowrap;
      gap: 12px;
    }

    .construction-dash--obra .toolbar-row {
      display: flex;
      flex-wrap: wrap;
      align-items: flex-end;
      gap: 12px;
    }

    /* Model + DFS FAMÍLIAS + DFS_CODE stay on one row and shrink instead of clipping. */
    .construction-dash--obra .toolbar-row:first-child {
      display: grid;
      grid-template-columns: minmax(140px, 0.7fr) minmax(160px, 1.2fr) minmax(160px, 1.2fr) minmax(140px, 1fr);
      align-items: end;
    }

    .construction-dash--obra .toolbar-row:first-child .field {
      min-width: 0;
      width: 100%;
    }

    .construction-dash .field-group--dates {
      display: flex;
      flex-wrap: nowrap;
      align-items: flex-end;
      gap: 12px;
    }

    .construction-dash .field-group--dates .field {
      min-width: 140px;
    }

    .construction-dash .field {
      display: flex;
      flex-direction: column;
      gap: 4px;
      min-width: 140px;
    }

    .construction-dash .field[hidden] {
      display: none;
    }

    .construction-dash .field.field--wide {
      min-width: 200px;
    }

    .construction-dash .field label {
      font-size: 11px;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.04em;
      opacity: 0.65;
    }

    /* The Budget field header keeps the micro-label look, but the "Choose File"
       button label (which shows the filename once picked) must not inherit the
       uppercase / dimmed micro-label styling. */
    .construction-dash .field .file-input-label {
      text-transform: none;
      letter-spacing: normal;
      opacity: 1;
    }

    .construction-dash .field select,
    .construction-dash .field input[type="date"],
    .construction-dash .field input[type="text"],
    .construction-dash .field input[type="number"] {
      padding: 8px 10px;
      border-radius: 8px;
      border: 1px solid var(--ui-panel-muted-border);
      background: var(--ui-panel-muted-surface);
      color: var(--ui-text-primary);
      font-family: inherit;
      font-size: 13px;
    }

    .construction-dash .field select:focus,
    .construction-dash .field input:focus {
      outline: none;
      border-color: rgba(106, 161, 255, 0.45);
      box-shadow: 0 0 0 2px rgba(106, 161, 255, 0.2);
    }

    .construction-dash .toolbar-actions {
      margin-left: auto;
      display: flex;
      gap: 8px;
    }

    .construction-dash .btn {
      padding: 8px 14px;
      border-radius: 10px;
      font-size: 13px;
      font-weight: 500;
      cursor: pointer;
      border: 1px solid var(--ui-panel-muted-border);
      background: rgba(255, 255, 255, 0.06);
      color: var(--ui-text-primary);
      transition: background 0.15s ease;
    }

    .construction-dash .btn:hover { background: rgba(255, 255, 255, 0.1); }
    .construction-dash .btn-primary {
      background: linear-gradient(180deg, #2f6fed, #1d4ed8);
      border-color: transparent;
      color: #ffffff;
      box-shadow: 0 1px 2px rgba(16, 24, 40, 0.10), 0 1px 3px rgba(37, 99, 235, 0.28);
      transition: transform 0.14s ease, filter 0.14s ease, box-shadow 0.14s ease;
    }
    .construction-dash .btn-primary:hover {
      background: linear-gradient(180deg, #2f6fed, #1d4ed8);
      filter: brightness(1.06);
      transform: translateY(-1px);
      box-shadow: 0 4px 10px -2px rgba(37, 99, 235, 0.40), 0 2px 4px rgba(16, 24, 40, 0.10);
    }
    .construction-dash label.btn { display: inline-flex; align-items: center; }

    /* Auto de medição — file input (self-contained; not tab3-scoped) */
    .construction-dash .visually-hidden-file {
      position: absolute;
      width: 0.1px;
      height: 0.1px;
      opacity: 0;
      overflow: hidden;
      z-index: -1;
    }
    .construction-dash .measurement-file-row {
      display: flex;
      align-items: center;
      gap: 10px;
    }
    .construction-dash .measurement-file-name {
      font-size: 13px;
      opacity: 0.7;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      max-width: 240px;
    }
    .construction-dash .measurement-deltas-block {
      margin-top: 8px;
    }
    .construction-dash .measurement-delta-list {
      display: flex;
      flex-direction: column;
      gap: 6px;
      max-height: 180px;
      overflow: auto;
      padding: 4px 0;
    }
    .construction-dash .measurement-delta-row {
      display: flex;
      align-items: flex-start;
      gap: 8px;
      font-size: 13px;
      cursor: pointer;
    }
    .construction-dash .completion-percent-row {
      display: flex;
      align-items: center;
      gap: 8px;
      flex-wrap: wrap;
      margin-bottom: 8px;
    }
    .completion-percent-badge,
    .construction-dash .completion-percent-badge {
      display: inline-block;
      min-width: 2.75rem;
      padding: 2px 8px;
      border-radius: 4px;
      background: rgba(31, 58, 95, 0.12);
      color: #1f3a5f;
      font-variant-numeric: tabular-nums;
      font-size: 13px;
      text-align: center;
    }
    .completion-percent-fin-row {
      display: flex;
      align-items: center;
      gap: 8px;
      flex-wrap: wrap;
      margin-bottom: 10px;
      padding-bottom: 8px;
      border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    }
    .completion-percent-fin-label {
      font-size: 13px;
      opacity: 0.85;
    }
    .construction-dash .measurement-num {
      text-align: right;
      font-variant-numeric: tabular-nums;
    }
    .construction-dash .measurement-qty { font-weight: 600; }
    .construction-dash .measurement-qty-input {
      width: 7.5rem;
      max-width: 100%;
      box-sizing: border-box;
      text-align: right;
      font: inherit;
      font-variant-numeric: tabular-nums;
      padding: 4px 6px;
      border-radius: 6px;
      border: 1px solid rgba(15, 23, 42, 0.18);
      background: #fff;
      color: inherit;
    }
    body.dark-theme .construction-dash .measurement-qty-input {
      border-color: rgba(255, 255, 255, 0.2);
      background: rgba(0, 0, 0, 0.25);
      color: inherit;
    }
    .construction-dash .measurement-qty-locked {
      cursor: default;
    }
    .construction-dash .measurement-manual-tag {
      font-size: 11px;
      font-weight: 650;
      letter-spacing: 0.02em;
      opacity: 0.8;
    }
    .construction-dash .measurement-row-manual td:first-child {
      white-space: nowrap;
    }
    .construction-dash .measurement-row-warn { opacity: 0.6; }
    .construction-dash .measurement-flag {
      display: inline-block;
      min-width: 14px;
      text-align: center;
      color: #b26a00;
      font-weight: 700;
      margin-right: 4px;
    }
    .construction-dash .measurement-warnings {
      margin: 12px 0;
      padding: 10px 14px;
      border-radius: 10px;
      border: 1px solid rgba(230, 160, 30, 0.35);
      background: rgba(230, 160, 30, 0.10);
      font-size: 13px;
      color: var(--ui-text-primary);
    }
    .construction-dash .measurement-warnings ul { margin: 6px 0 0; padding-left: 18px; }
    .construction-dash .measurement-warnings li { margin: 2px 0; }

    .construction-dash .kpi-row {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
      gap: 12px;
      margin-bottom: 16px;
    }

    .construction-dash .kpi {
      padding: 16px 18px;
      border-radius: var(--ui-chrome-radius);
      border: var(--ui-chrome-border);
      background: var(--ui-chrome-surface);
      box-shadow: var(--shadow-sm);
      cursor: default;
      transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
    }

    .construction-dash .kpi:hover {
      border-color: rgba(37, 99, 235, 0.35);
      transform: translateY(-1px);
      box-shadow: var(--shadow-md);
    }

    .construction-dash .kpi.exec-accent,
    .construction-dash .kpi.fin-accent {
      border-left: 3px solid var(--dash-accent);
      background:
        linear-gradient(135deg, rgba(91, 156, 255, 0.16), transparent 58%),
        var(--ui-chrome-surface);
    }
    .construction-dash .kpi.exec-accent .value,
    .construction-dash .kpi.fin-accent .value {
      color: #9ec5ff;
    }
    .construction-dash .kpi .label {
      font-size: 11px;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      opacity: 0.78;
      margin-bottom: 6px;
    }

    .construction-dash .kpi .value {
      font-size: 1.65rem;
      font-weight: 700;
      letter-spacing: -0.03em;
      line-height: 1.1;
      font-variant-numeric: tabular-nums;
    }

    .construction-dash .kpi .hint {
      margin-top: 6px;
      font-size: 11px;
      opacity: 0.55;
    }

    .construction-dash .kpi .sub {
      font-size: 11px;
      opacity: 0.65;
      margin-top: 4px;
      font-weight: 500;
    }

    .construction-dash .split {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 16px;
      margin-bottom: 16px;
    }

    @media (max-width: 900px) {
      .construction-dash .split { grid-template-columns: 1fr; }
      .construction-dash .toolbar-actions { width: 100%; margin-left: 0; justify-content: flex-end; }

      /* Controlo: avoid clipping date/period filters under overflow-x:hidden shells */
      .construction-dash--obra .toolbar-row,
      .construction-dash--audit .toolbar-row {
        flex-direction: column;
        align-items: stretch;
      }

      .construction-dash--obra .toolbar-row:first-child {
        grid-template-columns: 1fr;
      }

      .construction-dash .field-group--dates {
        flex-wrap: wrap;
        width: 100%;
      }

      .construction-dash .field-group--dates .field {
        flex: 1 1 140px;
        min-width: 0;
      }

      .construction-dash .field,
      .construction-dash .field.field--wide {
        min-width: 0;
        width: 100%;
      }

      .construction-dash--obra .toolbar-actions {
        justify-content: stretch;
      }

      .construction-dash--obra .toolbar-actions .btn {
        flex: 1 1 auto;
      }
    }

    .construction-dash .ui-content-frame {
      border: 1px solid rgba(148, 163, 184, 0.18);
      border-radius: var(--ui-chrome-radius);
      background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 40%),
        rgba(0, 0, 0, 0.18);
      overflow: hidden;
    }

    .construction-dash .frame-head {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 10px 14px;
      font-size: 11px;
      font-weight: 700;
      letter-spacing: 0.04em;
      text-transform: uppercase;
      border-bottom: 1px solid var(--ui-panel-muted-border);
      background: rgba(255, 255, 255, 0.04);
      color: #c7d7f0;
    }

    .construction-dash .frame-head::before {
      content: "";
      width: 8px;
      height: 8px;
      border-radius: 50%;
      flex-shrink: 0;
      background: var(--ui-accent);
      box-shadow: 0 0 0 3px rgba(106, 161, 255, 0.16);
    }

    body:not(.dark-theme) .construction-dash .ui-content-frame {
      background:
        linear-gradient(180deg, rgba(37, 99, 235, 0.04), transparent 40%),
        rgba(255, 255, 255, 0.72);
      border-color: rgba(15, 23, 42, 0.1);
    }

    body:not(.dark-theme) .construction-dash .frame-head {
      color: #334155;
      background: rgba(37, 99, 235, 0.05);
    }

    .construction-stats-loading {
      margin-top: 16px;
      min-height: 220px;
      border: var(--ui-chrome-border);
      border-radius: var(--ui-chrome-radius);
      background: var(--ui-panel-muted-surface);
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 16px;
      color: var(--ui-text-secondary);
      font-size: var(--text-label);
      pointer-events: none;
      animation: motion-enter 0.28s cubic-bezier(0.33, 1, 0.68, 1) both;
    }

    .construction-stats-loading-overlay {
      position: absolute;
      inset: 0;
      z-index: 2;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 14px;
      background: color-mix(in srgb, #ffffff 78%, transparent);
      color: var(--ui-text-primary);
      font-size: var(--text-label);
      font-weight: 500;
      pointer-events: none;
      border-radius: var(--ui-chrome-radius);
    }

    body.dark-theme .construction-stats-loading {
      background: rgba(13, 15, 20, 0.92);
      border-color: rgba(255, 255, 255, 0.12);
      color: #e8e8ed;
    }

    body.dark-theme .construction-stats-loading-overlay {
      background: rgba(13, 15, 20, 0.78);
      color: #e8e8ed;
    }

    .construction-empty-state {
      margin-top: 16px;
      padding: 20px 22px;
      border: var(--ui-chrome-border);
      border-radius: var(--ui-chrome-radius);
      background: var(--ui-panel-muted-surface);
      max-width: 560px;
    }
    .construction-empty-state__title {
      margin: 0 0 12px;
      font-size: var(--text-body);
      font-weight: 600;
      color: var(--ui-text-primary);
    }
    .construction-empty-state__steps {
      margin: 0 0 14px;
      padding: 0;
      list-style: none;
      display: grid;
      gap: 8px;
    }
    .construction-empty-state__steps li {
      display: flex;
      gap: 10px;
      align-items: flex-start;
      color: var(--ui-text-secondary);
      font-size: var(--text-label);
    }
    .construction-empty-step-num {
      flex: 0 0 auto;
      width: 1.4rem;
      height: 1.4rem;
      border-radius: 999px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      background: var(--ui-accent);
      color: #fff;
      font-size: 0.75rem;
      font-weight: 700;
    }
    .construction-empty-state__hint {
      margin: 0 0 12px;
      color: var(--ui-text-secondary);
      font-size: var(--text-label);
    }
    .construction-empty-state__actions {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
    }

    .construction-pe-banner {
      margin-top: 12px;
      padding: 12px 14px;
      border: var(--ui-chrome-border);
      border-radius: var(--ui-chrome-radius);
      background: color-mix(in srgb, var(--ui-accent) 10%, var(--ui-panel-muted-surface));
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
    }
    .construction-jump-wrap {
      display: inline-flex;
      flex-direction: column;
      align-items: flex-start;
      gap: 4px;
    }
    .construction-jump-hint {
      font-size: 0.75rem;
      color: var(--ui-text-secondary);
    }
    .construction-table-toolbar {
      margin: 8px 0;
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 12px;
    }

    .obra-view-tabs {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      margin: 12px 0 4px;
    }
    .construction-obra-views {
      margin-top: 14px;
      margin-bottom: 6px;
      padding-bottom: 10px;
      border-bottom: 1px solid var(--ui-panel-muted-border);
    }
    .obra-view-tabs .chip[aria-selected="true"],
    .obra-view-tabs .chip.active,
    .construction-obra-views .chip.active {
      font-weight: 600;
    }
    .construction-dash--obra .filter-chips[hidden] {
      display: none !important;
    }

    .construction-stats-loading__spinner {
      /* Legacy alias — prefer .pg-loader-bar */
      position: relative;
      display: block;
      width: 220px;
      height: 4px;
      border: 0;
      border-radius: 999px;
      background: rgba(255, 255, 255, 0.28);
      overflow: hidden;
      animation: none;
      box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.12),
        0 0 14px color-mix(in srgb, var(--ui-accent) 45%, transparent);
    }
    .construction-stats-loading__spinner::before {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      height: 100%;
      width: 45%;
      border-radius: inherit;
      background: linear-gradient(
        90deg,
        transparent,
        var(--ui-accent) 18%,
        #ffffff 50%,
        var(--ui-accent) 82%,
        transparent
      );
      animation: auth-bar-slide 1.2s cubic-bezier(0.45, 0, 0.35, 1) infinite;
    }
    body:not(.dark-theme) .construction-stats-loading__spinner {
      background: rgba(15, 23, 42, 0.14);
      box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.06);
    }

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

    .construction-dash .bars {
      padding: 14px 16px 18px;
    }

    .construction-dash .bar-item {
      margin-bottom: 12px;
    }

    .construction-dash .bar-item:last-child { margin-bottom: 0; }

    .construction-dash .bar-top {
      display: flex;
      justify-content: space-between;
      font-size: 12px;
      margin-bottom: 4px;
      opacity: 0.9;
    }

    .construction-dash .bar-track {
      height: 8px;
      border-radius: 999px;
      background: rgba(255, 255, 255, 0.08);
      overflow: hidden;
    }

    .construction-dash .bar-fill {
      height: 100%;
      border-radius: 999px;
      transition: width 0.4s ease;
    }

    .construction-dash .bar-fill.exec { background: linear-gradient(90deg, hsl(160, 40%, 38%), hsl(160, 50%, 48%)); }
    .construction-dash .bar-fill.fin-pay { background: linear-gradient(90deg, hsl(43, 55%, 42%), hsl(43, 65%, 52%)); }
    .construction-dash .bar-fill.fin-paid { background: linear-gradient(90deg, hsl(200, 40%, 45%), hsl(200, 50%, 55%)); }

    .construction-type-chart {
      margin: 16px 0 8px;
      padding: 14px 16px 16px;
      border: var(--ui-chrome-border, 1px solid #363d4d);
      border-radius: var(--ui-chrome-radius, 12px);
      background: rgba(0, 0, 0, 0.12);
    }

    .construction-type-chart--empty {
      padding-bottom: 12px;
    }

    .construction-type-chart__head {
      font-size: 12px;
      font-weight: 600;
      margin-bottom: 12px;
      color: var(--ui-text-primary, #e0e0e0);
      letter-spacing: 0.02em;
    }

    .construction-type-chart__sub {
      font-size: 11px;
      font-weight: 500;
      line-height: 1.4;
      margin: -6px 0 12px;
      opacity: 0.72;
      color: var(--ui-text-secondary, #999);
    }

    .construction-dash--exec .construction-type-chart__head {
      color: hsl(var(--exec-hue), 42%, 72%);
    }

    .construction-dash--fin .construction-type-chart__head {
      color: hsl(var(--fin-hue), 55%, 62%);
    }

    .construction-type-chart__body {
      display: flex;
      flex-wrap: wrap;
      align-items: flex-start;
      gap: 16px 24px;
    }

    .construction-type-chart__svg-wrap {
      flex: 0 0 auto;
      width: min(200px, 42vw);
      max-width: 220px;
    }

    .construction-type-chart__svg {
      width: 100%;
      height: auto;
      display: block;
      filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.35));
    }

    .construction-type-chart__legend {
      flex: 1 1 200px;
      min-width: 0;
      max-height: 220px;
      overflow: auto;
      font-size: 12px;
      line-height: 1.35;
    }

    .construction-type-chart__legend-row {
      display: grid;
      grid-template-columns: 12px 1fr auto;
      gap: 8px 10px;
      align-items: baseline;
      padding: 4px 0;
      border-bottom: 1px solid rgba(255, 255, 255, 0.06);
      color: var(--ui-text-primary, #e0e0e0);
    }

    .construction-type-chart__legend-row:last-child {
      border-bottom: none;
    }

    .construction-type-chart__swatch {
      width: 12px;
      height: 12px;
      border-radius: 3px;
      margin-top: 3px;
      flex-shrink: 0;
      box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
    }

    .construction-type-chart__lbl {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      min-width: 0;
    }

    .construction-type-chart__nums {
      font-variant-numeric: tabular-nums;
      opacity: 0.88;
      white-space: nowrap;
    }

    .construction-binary-donut__body {
      align-items: center;
    }

    .construction-binary-donut__svg-wrap {
      position: relative;
      flex: 0 0 auto;
      width: min(200px, 42vw);
      max-width: 220px;
    }

    .construction-binary-donut__center {
      position: absolute;
      inset: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 1.65rem;
      font-weight: 700;
      font-variant-numeric: tabular-nums;
      color: var(--ui-text-primary, #e8e8e8);
      pointer-events: none;
      text-shadow: 0 1px 6px rgba(0, 0, 0, 0.45);
    }

    .construction-binary-donut__pct {
      font-size: 0.65em;
      font-weight: 600;
      opacity: 0.85;
      margin-left: 1px;
    }

    .construction-dash table.data {
      width: 100%;
      border-collapse: separate;
      border-spacing: 0;
      font-size: 13px;
    }

    .construction-dash--obra .dash-frame--table .data-wrap {
      overflow-x: auto;
    }

    .construction-dash--obra .dash-frame .frame-head-title {
      flex: 1 1 auto;
      min-width: 0;
    }

    .construction-dash--obra .dash-frame .dash-frame-toggle {
      margin-left: auto;
      flex-shrink: 0;
    }

    .construction-dash--obra .dash-frame.is-collapsed > :not(.frame-head) {
      display: none;
    }

    .construction-dash--obra .dash-frame.is-collapsed .frame-head {
      border-bottom-color: transparent;
    }

    .construction-dash--obra table.data.data--fin-wide {
      width: max-content;
      min-width: 2200px;
      table-layout: auto;
    }

    .construction-dash--obra table.data--fin-wide th,
    .construction-dash--obra table.data--fin-wide td {
      white-space: nowrap;
      padding-left: 16px;
      padding-right: 16px;
    }

    .construction-dash--obra table.data--fin-wide td.fin-span-dfs,
    .construction-dash--obra table.data--fin-wide td.fin-span-el {
      vertical-align: middle;
    }

    .construction-dash--obra table.data--fin-wide td.fin-span-dfs {
      font-weight: 600;
      border-right: 1px solid rgba(128, 128, 128, 0.28);
    }

    .construction-dash--obra table.data--fin-wide tr.fin-dfs-start td {
      border-top: 1px solid rgba(128, 128, 128, 0.4);
    }

    .construction-dash--obra .fin-orc-stack {
      display: flex;
      flex-direction: column;
      gap: 2px;
      min-width: 4.5rem;
    }

    .construction-dash--obra .fin-orc-stack > div {
      line-height: 1.35;
      white-space: nowrap;
    }

    .construction-dash--obra .fin-orc-total {
      margin-top: 2px;
      padding-top: 4px;
      border-top: 1px solid rgba(128, 128, 128, 0.35);
      font-weight: 600;
    }

    .construction-dash .data-wrap {
      overflow: auto;
      max-height: clamp(220px, calc(var(--app-vh) - 320px), 70vh);
      background: var(--ui-chrome-surface, rgba(255, 255, 255, 0.04));
      border-radius: var(--ui-chrome-radius, 10px);
      border: var(--ui-chrome-border, 1px solid rgba(255, 255, 255, 0.08));
      box-shadow: var(--ui-chrome-shadow, none);
      padding: 4px 0 0;
    }

    .construction-dash .construction-table-wrap,
    .construction-dash .construction-table-wrap.data-wrap {
      overflow: auto;
      max-height: clamp(220px, calc(var(--app-vh) - 320px), 70vh);
      overscroll-behavior: contain;
      background: var(--ui-chrome-surface, rgba(255, 255, 255, 0.04));
      border-radius: var(--ui-chrome-radius, 10px);
      border: var(--ui-chrome-border, 1px solid rgba(255, 255, 255, 0.08));
      box-shadow: var(--ui-chrome-shadow, none);
      padding: 6px 8px 8px;
      box-sizing: border-box;
    }

    .construction-dash--audit .construction-audit-toolbar {
      flex-direction: column;
      align-items: stretch;
      flex-wrap: nowrap;
      gap: 12px;
    }

    .construction-dash--audit .toolbar-row {
      display: flex;
      flex-wrap: wrap;
      align-items: flex-end;
      gap: 12px;
    }

    .construction-dash--audit #auditEventChips.filter-chips {
      gap: 10px;
      margin-top: 12px;
      margin-bottom: 16px;
      padding-left: 14px;
      padding-right: 14px;
      box-sizing: border-box;
    }

    .construction-dash--audit #auditEventChips .chip {
      padding: 8px 14px;
      font-size: 13px;
      line-height: 1.25;
      gap: 8px;
    }

    .construction-dash--audit #auditEventChips + .construction-table-wrap,
    .construction-dash--audit #auditEventChips + .construction-empty-state {
      margin-top: 4px;
    }

    /* Auditoria — blue chrome (status pills keep semantic color) */
    .construction-dash--audit {
      --audit-events: #5b9cff;
      --audit-deltas: #5b9cff;
      --audit-exports: #5b9cff;
      --audit-history: #5b9cff;
    }

    .construction-dash--audit .kpi-audit {
      position: relative;
      overflow: hidden;
      border-left-width: 3px;
      border-left-style: solid;
      border-left-color: #5b9cff;
      background:
        linear-gradient(135deg, rgba(91, 156, 255, 0.16), transparent 58%),
        var(--ui-chrome-surface);
    }

    .construction-dash--audit .kpi-audit .label {
      opacity: 0.78;
    }

    .construction-dash--audit .kpi-audit .value { color: #9ec5ff; }

    body:not(.dark-theme) .construction-dash--audit .kpi-audit .value { color: #1d4ed8; }

    .construction-dash--audit .audit-frame {
      border-color: rgba(91, 156, 255, 0.28);
      background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 40%),
        rgba(0, 0, 0, 0.18);
    }

    .construction-dash--audit .audit-frame .frame-head {
      display: flex;
      align-items: center;
      gap: 8px;
      font-weight: 700;
      letter-spacing: 0.04em;
      text-transform: uppercase;
      font-size: 11px;
      color: #bfdbfe;
      background: rgba(91, 156, 255, 0.1);
      border-bottom-color: rgba(91, 156, 255, 0.22);
    }

    .construction-dash--audit .audit-frame .frame-head-title {
      flex: 1 1 auto;
      min-width: 0;
    }

    .construction-dash--audit .audit-frame .audit-frame-toggle {
      margin-left: auto;
      flex-shrink: 0;
    }

    .construction-dash--audit .audit-frame.is-collapsed .audit-frame-body {
      display: none;
    }

    .construction-dash--audit .audit-frame.is-collapsed .frame-head {
      border-bottom-color: transparent;
    }

    .construction-dash--audit .audit-login-filters {
      display: flex;
      flex-wrap: wrap;
      gap: 10px 14px;
      align-items: flex-end;
      margin: 12px 14px 6px;
    }

    .construction-dash--audit .audit-login-filters .field {
      min-width: 160px;
      margin: 0;
    }

    .construction-dash--audit .audit-login-filters .btn {
      margin-bottom: 1px;
    }

    .construction-dash--audit .audit-frame .frame-head::before {
      content: "";
      width: 8px;
      height: 8px;
      border-radius: 50%;
      flex-shrink: 0;
      background: #5b9cff;
      box-shadow: 0 0 0 3px rgba(91, 156, 255, 0.18);
    }

    body:not(.dark-theme) .construction-dash--audit .audit-frame .frame-head { color: #1e40af; }

    .construction-dash--audit .audit-empty {
      max-width: none;
      margin: 14px;
      border: 1px dashed rgba(91, 156, 255, 0.4);
      background: rgba(91, 156, 255, 0.08);
    }

    .construction-dash--audit .audit-empty--ok {
      border-color: rgba(91, 156, 255, 0.45);
      background: rgba(91, 156, 255, 0.1);
    }

    .construction-dash--audit .audit-empty--ok .construction-empty-state__title {
      color: #93c5fd;
    }

    body:not(.dark-theme) .construction-dash--audit .audit-empty--ok .construction-empty-state__title {
      color: #1d4ed8;
    }

    .construction-dash--audit .audit-state-pill {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 3px 10px 3px 8px;
      border-radius: 999px;
      font-size: 12px;
      font-weight: 600;
      line-height: 1.2;
      color: #fff;
      background: color-mix(in srgb, var(--audit-state-color, #5b9cff) 28%, transparent);
      border: 1px solid color-mix(in srgb, var(--audit-state-color, #5b9cff) 55%, transparent);
      box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
    }

    .construction-dash--audit .chip-audit {
      border-color: rgba(91, 156, 255, 0.28);
      background: rgba(255, 255, 255, 0.04);
      color: var(--ui-text-secondary, #a0a6b0);
      transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    }

    .construction-dash--audit .chip-audit.active {
      color: #dbeafe;
      border-color: rgba(91, 156, 255, 0.55);
      background: rgba(91, 156, 255, 0.2);
    }

    .construction-dash--audit .construction-table-wrap,
    .construction-dash--audit .data-wrap {
      background:
        linear-gradient(180deg, rgba(91, 156, 255, 0.05), transparent 48px),
        var(--ui-chrome-surface, rgba(255, 255, 255, 0.04));
    }

    .construction-dash--audit .construction-props-table th {
      color: #c7d7f0;
    }

    body:not(.dark-theme) .construction-dash--audit .construction-props-table th {
      color: #334155;
    }

    .construction-dash .construction-props-table {
      width: 100%;
      min-width: 720px;
      max-width: none;
      white-space: nowrap;
      font-size: 13px;
    }

    .construction-dash .construction-props-table th,
    .construction-dash .construction-props-table td {
      padding: 12px 14px;
    }

    .construction-dash .construction-table-toolbar {
      display: flex;
      align-items: center;
      gap: 12px;
      flex-wrap: wrap;
      margin: 8px 0;
      padding: 0 2px;
    }

    .construction-dash .construction-table-pager,
    .pe-pager-like {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 10px;
      margin: 10px 0 0;
      padding: 0 2px;
      color: var(--ui-text-primary);
    }

    .construction-dash .construction-table-pager .pe-pager-meta,
    .pe-pager-like .pe-pager-meta {
      font-size: 12px;
      color: var(--ui-text-secondary, rgba(255, 255, 255, 0.7));
    }

    .construction-dash .data th,
    .construction-dash .data td {
      padding: 12px 14px;
      text-align: left;
      border-bottom: 1px solid var(--ui-panel-muted-border);
    }

    .construction-dash .data th {
      position: sticky;
      top: 0;
      z-index: 2;
      background: var(--ui-chrome-surface, #f8f9fa);
      font-weight: 600;
      font-size: 11px;
      text-transform: uppercase;
      letter-spacing: 0.04em;
      color: var(--ui-text-primary, #2c3e50);
      opacity: 1;
      border-bottom: 2px solid var(--ui-panel-muted-border, #dee2e6);
    }

    body.dark-theme .construction-dash .data th {
      background: var(--ui-chrome-surface, #212736);
      color: #ffffff;
      border-bottom-color: #363d4d;
    }

    .construction-dash .data tr:hover td {
      background: rgba(106, 161, 255, 0.06);
    }

    .construction-dash .badge {
      display: inline-block;
      padding: 2px 8px;
      border-radius: 6px;
      font-size: 11px;
      font-weight: 600;
    }

    .construction-dash .badge.done { background: rgba(46, 125, 50, 0.25); color: #a5d6a7; }
    .construction-dash .badge.conf { background: rgba(106, 161, 255, 0.2); color: var(--ui-accent); }
    .construction-dash .badge.pay { background: rgba(255, 183, 77, 0.2); color: #ffcc80; }
    .construction-dash .badge.paid { background: rgba(129, 199, 132, 0.25); color: #c8e6c9; }

    .construction-dash .filter-chips {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      margin-top: 10px;
    }

    .construction-dash .chip {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 4px 10px;
      border-radius: 999px;
      font-size: 11px;
      border: 1px solid var(--ui-panel-muted-border);
      background: rgba(255, 255, 255, 0.05);
      cursor: pointer;
    }

    .construction-dash .obra-state-dot {
      display: inline-block;
      width: 8px;
      height: 8px;
      border-radius: 50%;
      flex-shrink: 0;
      box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
    }

    .construction-dash .obra-state-cell,
    .props-table .obra-state-cell {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 3px 10px 3px 8px;
      border-radius: 999px;
      font-size: 12px;
      font-weight: 600;
      line-height: 1.2;
      background: rgba(255, 255, 255, 0.06);
      border: 1px solid rgba(148, 163, 184, 0.22);
    }

    .props-table .obra-state-dot {
      display: inline-block;
      width: 8px;
      height: 8px;
      border-radius: 50%;
      flex-shrink: 0;
      box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
    }

    .construction-dash--audit .audit-state-cell {
      display: inline-flex;
      align-items: center;
      gap: 6px;
    }

    .construction-dash--audit .audit-col-center {
      text-align: center;
      font-variant-numeric: tabular-nums;
    }

    .construction-dash .chip.active {
      border-color: color-mix(in srgb, var(--dash-accent, var(--ui-accent)) 55%, transparent);
      background: color-mix(in srgb, var(--dash-accent, var(--ui-accent)) 20%, transparent);
      color: #e2e8f0;
    }

    body:not(.dark-theme) .construction-dash .chip.active {
      color: var(--ui-accent);
    }

    .construction-dash .construction-empty-state {
      border: 1px dashed color-mix(in srgb, var(--dash-accent, #5b9cff) 40%, transparent);
      background: color-mix(in srgb, var(--dash-accent, #5b9cff) 8%, transparent);
      max-width: none;
    }

    /* Shared blue accents across Controlo / Auto / Plan / Análise */
    .construction-dash--obra .construction-obra-views .chip.active,
    .construction-dash--obra .construction-obra-views .chip[data-view="exec"].active,
    .construction-dash--obra .construction-obra-views .chip[data-view="fin"].active {
      color: #dbeafe;
      border-color: rgba(91, 156, 255, 0.55);
      background: rgba(91, 156, 255, 0.2);
    }

    .construction-dash .dash-frame,
    .construction-dash .ui-content-frame {
      border-color: rgba(91, 156, 255, 0.26);
    }

    .construction-dash .dash-frame .frame-head,
    .construction-dash .ui-content-frame .frame-head {
      color: #bfdbfe;
      background: rgba(91, 156, 255, 0.1);
      border-bottom-color: rgba(91, 156, 255, 0.22);
    }

    .construction-dash .dash-frame .frame-head::before,
    .construction-dash .ui-content-frame .frame-head::before {
      background: #5b9cff;
      box-shadow: 0 0 0 3px rgba(91, 156, 255, 0.18);
    }

    .construction-dash .kpi-row .kpi:nth-child(1) .value { color: #bfdbfe; }
    .construction-dash .kpi-row .kpi:nth-child(2) .value { color: #93c5fd; }
    .construction-dash .kpi-row .kpi:nth-child(3) .value { color: #7dd3fc; }
    .construction-dash .kpi-row .kpi:nth-child(4) .value { color: #60a5fa; }

    .construction-dash .kpi-row .kpi {
      border-left: 3px solid #5b9cff;
      background:
        linear-gradient(135deg, rgba(91, 156, 255, 0.14), transparent 58%),
        var(--ui-chrome-surface);
    }

    body:not(.dark-theme) .construction-dash .kpi-row .kpi .value {
      color: #1d4ed8;
    }
    body:not(.dark-theme) .construction-dash .dash-frame .frame-head,
    body:not(.dark-theme) .construction-dash .ui-content-frame .frame-head {
      color: #1e40af;
    }

    .construction-dash--auto .measurement-deltas-block,
    .construction-dash--auto .measurement-delta-list {
      border-radius: var(--ui-chrome-radius);
    }
    .construction-dash--auto .measurement-delta-item {
      border-top-color: rgba(91, 156, 255, 0.2) !important;
    }

    /* Controlo de Obra — larger Execução/Financeiro + status chips only */
    .construction-dash--obra .obra-view-tabs,
    .construction-dash--obra .construction-obra-views {
      gap: 10px;
    }
    .construction-dash--obra .obra-view-tabs .chip,
    .construction-dash--obra .construction-obra-views .chip {
      padding: 10px 18px;
      font-size: 14px;
      line-height: 1.3;
      gap: 8px;
    }
    .construction-dash--obra .filter-chips {
      gap: 10px;
      margin-top: 12px;
    }
    .construction-dash--obra .filter-chips .chip {
      padding: 8px 14px;
      font-size: 13px;
      line-height: 1.3;
      gap: 8px;
    }
    .construction-dash--obra .filter-chips .obra-state-dot {
      width: 10px;
      height: 10px;
    }

    /* Auto de medição — larger status chips only */
    .construction-dash--auto .filter-chips {
      gap: 10px;
      margin-top: 12px;
    }
    .construction-dash--auto .filter-chips .chip {
      padding: 8px 14px;
      font-size: 13px;
      line-height: 1.3;
      gap: 8px;
    }
    .construction-dash--auto .filter-chips .obra-state-dot {
      width: 10px;
      height: 10px;
    }

    .construction-dash--plan .construction-tab-title {
      color: #bfdbfe;
    }
    .construction-dash--plan .construction-plan-send {
      padding: 14px 16px;
      border-radius: var(--ui-chrome-radius);
      border: 1px solid rgba(91, 156, 255, 0.28);
      background:
        linear-gradient(135deg, rgba(91, 156, 255, 0.1), transparent 50%),
        rgba(0, 0, 0, 0.16);
      margin-bottom: 16px;
    }
    .construction-dash--plan .construction-plan-section-label {
      color: #bfdbfe;
      font-weight: 700;
    }

    #tab3 .project-elements-details {
      border-radius: var(--ui-chrome-radius);
      border: 1px solid rgba(91, 156, 255, 0.24);
      background:
        linear-gradient(180deg, rgba(91, 156, 255, 0.08), transparent 48%),
        rgba(0, 0, 0, 0.14);
      padding: 12px;
    }

    .construction-dash .section-title {
      margin: 20px 0 10px;
      font-size: 13px;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.06em;
      opacity: 0.85;
      color: #93c5fd;
    }

    .construction-dash .spec-box {
      margin-bottom: 14px;
      padding: 12px 14px;
      border-radius: var(--ui-chrome-radius);
      border: 1px solid rgba(46, 125, 50, 0.25);
      background: rgba(46, 125, 50, 0.08);
      font-size: 12px;
      line-height: 1.5;
      color: var(--ui-text-primary);
    }

    .construction-dash .spec-box strong {
      display: block;
      margin-bottom: 8px;
      font-size: 12px;
      color: #a5d6a7;
    }

    .construction-dash .spec-box ul {
      margin: 0;
      padding-left: 1.2rem;
      opacity: 0.92;
    }

    .construction-dash .spec-box li { margin-bottom: 4px; }

    .construction-dash .spec-box .spec-foot {
      margin-top: 10px;
      font-size: 11px;
      opacity: 0.65;
    }

    .construction-dash .kpi-row--prod {
      grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    }

    .construction-dash .data .num { font-variant-numeric: tabular-nums; text-align: right; }
    .construction-dash .data th.num { text-align: right; }

    .construction-dash-empty,
    .construction-dash-placeholder {
      text-align: center;
      opacity: 0.55;
      font-size: 12px;
      padding: 12px;
    }

    .construction-calc-line {
      font-size: 11px;
      opacity: 0.55;
      margin-top: 2px;
    }

    .construction-productivity-line {
      margin-top: 12px;
      font-size: 0.9rem;
      color: var(--ui-text-primary, #e0e0e0);
    }

    .construction-tab-msg {
      font-size: 13px;
      opacity: 0.7;
      margin-top: 10px;
    }

    /* Planning tab */
    .construction-plan-banner {
      margin-bottom: 20px;
      padding: 14px 16px;
      border-radius: var(--ui-chrome-radius);
      border: 1px solid rgba(167, 139, 250, 0.35);
      background: linear-gradient(135deg, rgba(167, 139, 250, 0.12), rgba(106, 161, 255, 0.08));
      box-shadow: var(--ui-chrome-shadow);
      font-size: 13px;
    }

    .construction-tab-header {
      margin-bottom: 12px;
    }

    .construction-tab-title {
      margin: 0;
      font-size: 1.1rem;
      font-weight: 600;
    }

    .construction-plan-form {
      display: flex;
      flex-wrap: wrap;
      gap: 12px;
      align-items: flex-end;
      margin-bottom: 16px;
    }

    .construction-plan-form label {
      display: flex;
      flex-direction: column;
      gap: 4px;
      font-size: 12px;
      font-weight: 500;
    }

    .construction-input {
      padding: 8px 10px;
      border-radius: 8px;
      border: 1px solid var(--ui-panel-muted-border);
      background: var(--ui-panel-muted-surface);
      color: var(--ui-text-primary);
      font-family: inherit;
      font-size: 13px;
    }

    .construction-refresh-btn {
      padding: 8px 14px;
      border-radius: 10px;
      font-size: 13px;
      font-weight: 500;
      cursor: pointer;
      border: 1px solid var(--ui-panel-muted-border);
      background: var(--plan-accent-soft);
      color: var(--plan-accent);
    }

    .construction-plan-list {
      list-style: none;
      margin: 0;
      padding: 0;
    }

    .construction-plan-item {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 10px 14px;
      border-radius: 8px;
      border: 1px solid var(--ui-panel-muted-border);
      margin-bottom: 6px;
      background: var(--ui-panel-muted-surface);
    }

    .construction-plan-item-title {
      flex: 1;
      font-weight: 500;
    }

    .construction-plan-item-meta {
      font-size: 12px;
      opacity: 0.65;
    }

    .construction-plan-del {
      background: none;
      border: none;
      color: var(--ui-text-primary);
      font-size: 18px;
      cursor: pointer;
      opacity: 0.5;
      padding: 2px 6px;
      border-radius: 4px;
    }

    .construction-plan-del:hover {
      opacity: 1;
      background: rgba(255, 0, 0, 0.15);
    }

    .construction-plan-empty {
      text-align: center;
      opacity: 0.55;
      font-size: 13px;
      padding: 16px;
    }

    .construction-plan-send {
      margin-bottom: 20px;
    }

    .construction-plan-send-toolbar {
      margin-bottom: 16px;
    }

    .construction-plan-section-label {
      display: block;
      font-size: 12px;
      font-weight: 600;
      margin-bottom: 8px;
      color: var(--ui-text-secondary);
    }

    .construction-plan-attach-row {
      margin-bottom: 16px;
    }

    .construction-plan-attach-actions {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 12px;
    }

    .construction-plan-file-name {
      font-size: 13px;
      color: var(--ui-text-secondary);
    }

    .construction-plan-email-row {
      display: flex;
      flex-wrap: wrap;
      align-items: flex-end;
      gap: 12px;
    }

    .construction-plan-email-field {
      flex: 1 1 280px;
      min-width: 200px;
    }

    .construction-plan-divider {
      border: none;
      border-top: 1px solid var(--ui-panel-muted-border);
      margin: 24px 0;
    }

    .construction-plan-history {
      margin-top: 28px;
    }

    .construction-plan-history .construction-tab-msg {
      margin: 0;
      padding: 8px 14px 0;
    }

    .construction-plan-history .construction-plan-empty {
      margin: 0;
      padding: 16px 14px 18px;
    }

    .construction-tab-msg--error {
      color: var(--ui-danger, #f87171);
    }

    #tab3Content {
      padding-right: 24px;
      box-sizing: border-box;
      margin: 0 auto;
      width: 100%;
      max-width: min(1800px, 100%);
      min-width: 0;
    }

    #tab3 .analysis-top-layout {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 20px;
      align-items: stretch;
      margin-bottom: 28px;
      width: 100%;
      max-width: 100%;
      min-width: 0;
    }

    #tab3 .analysis-top-layout .project-elements-form-row {
      margin-bottom: 0;
      min-width: 0;
      max-width: 100%;
      height: 100%;
      width: 100%;
      box-sizing: border-box;
    }

    #tab3 .analysis-top-layout .project-elements-form-row:hover {
      box-shadow: var(--ui-chrome-shadow);
    }

    #tab3 .analysis-top-layout select {
      width: 100%;
      max-width: 100%;
      min-width: 0;
    }

    #tab3 .analysis-top-layout .tab3-button-group {
      min-width: 0;
      max-width: 100%;
    }

    @media (max-width: 1360px) {
      #tab3 .analysis-top-layout {
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }

      #tab3 .analysis-top-layout .analysis-budget-card {
        grid-column: 1 / -1;
      }
    }

    @media (max-width: 1100px) {
      #tab3 .analysis-top-layout {
        grid-template-columns: 1fr;
      }
    }
    
    /* Custom scrollbar for Tab 3 */
    .tab3-content::-webkit-scrollbar {
      width: 10px;
    }
    
    .tab3-content::-webkit-scrollbar-track {
      background: #f1f1f1;
      border-radius: 10px;
    }
    
    .tab3-content::-webkit-scrollbar-thumb {
      background: linear-gradient(to bottom, #2563eb, #1d4ed8);
      border-radius: 10px;
    }
    
    .tab3-content::-webkit-scrollbar-thumb:hover {
      background: linear-gradient(to bottom, #1d4ed8, #1565C0);
    }
    
    .project-elements-table-wrapper::-webkit-scrollbar {
      width: 10px;
      height: 10px;
    }
    
    .project-elements-table-wrapper::-webkit-scrollbar-track {
      background: #f1f1f1;
      border-radius: 10px;
    }
    
    .project-elements-table-wrapper::-webkit-scrollbar-thumb {
      background: linear-gradient(135deg, #2563eb, #1d4ed8);
      border-radius: 10px;
    }
    
    .project-elements-table-wrapper::-webkit-scrollbar-thumb:hover {
      background: linear-gradient(135deg, #1d4ed8, #1565C0);
    }
    
    /* Analysis cards — same shell as Document browser (#floorplanPanel) */
    #tab3 .project-elements-form-row {
      margin-bottom: 28px;
      padding: 10px 12px;
      background: var(--ui-chrome-surface);
      backdrop-filter: var(--ui-backdrop-filter);
      -webkit-backdrop-filter: var(--ui-backdrop-filter);
      border: var(--ui-chrome-border);
      border-radius: var(--ui-chrome-radius);
      box-shadow: var(--ui-chrome-shadow);
      font-family: var(--font-ui);
      font-size: var(--text-label-size);
      color: var(--ui-text-primary);
      transition: border-color 0.15s ease, box-shadow 0.15s ease;
    }

    #tab3 .project-elements-form-row:hover {
      box-shadow: var(--ui-chrome-shadow);
    }

    #tab3 .project-elements-form-row label {
      margin: 0 0 6px 0;
      font-size: var(--text-label-size);
      font-weight: 600;
      color: var(--ui-text-primary);
      letter-spacing: normal;
      display: block;
    }

    #tab3 .project-elements-form-row label::before {
      display: none;
      content: none;
    }

    #tab3 .toolbar-hint {
      margin: 0;
      font-size: var(--text-label-size);
      font-weight: 500;
      color: var(--ui-text-primary);
      opacity: 0.78;
    }

    .elements-btn {
      padding: 10px 20px;
      font-size: 13px;
      font-weight: 500;
      border: none;
      border-radius: 10px;
      background: #2563eb;
      color: white;
      cursor: pointer;
      margin-bottom: 20px;
      transition: background 0.2s ease;
    }

    .elements-btn:hover {
      background: #409cff;
    }
    
    .elements-btn:active {
      transform: scale(0.98);
    }

    /* ==========================
           VIEWER PANELS
           ========================== */
    #viewerRightPanels {
      position: absolute;
      top: 10px;
      right: 10px;
      z-index: 200;
      display: flex;
      flex-direction: column;
      gap: 10px;
      align-items: stretch;
      width: min(380px, calc(100vw - 28px));
      max-height: calc(var(--app-vh) - 20px);
      min-height: 0;
      overflow: visible;
      /* Empty column space must not steal clicks from legend / viewer canvas. */
      pointer-events: none;
    }

    #viewerRightPanels > * {
      pointer-events: auto;
    }

    #viewerRightPanels #propsPanel {
      flex: 1 1 auto;
      min-height: 0;
      max-height: min(calc(var(--app-vh) - 80px), 720px);
    }

    #viewerRightPanels #propsPanel.minimized {
      flex: 0 0 auto;
      max-height: none;
      min-height: 0;
    }

    #propsPanel.minimized > :not(.props-header) {
      display: none !important;
    }

    #propsPanel.minimized .props-header {
      margin-bottom: 0;
    }

    #propsPanel .props-header-actions {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      flex-shrink: 0;
    }

    #propsPanel .props-minimize-btn,
    #propsPanel .panel-toggle-btn.props-minimize-btn {
      width: 28px;
      height: 28px;
      border: 0;
      border-radius: 6px;
      font-size: 14px;
      line-height: 1;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
      padding: 0;
      background: rgba(0, 0, 0, 0.06);
      color: inherit;
    }

    #propsPanel .props-minimize-btn:hover {
      background: rgba(0, 0, 0, 0.1);
    }

    body.dark-theme #propsPanel .props-minimize-btn {
      background: rgba(255, 255, 255, 0.08);
    }

    body.dark-theme #propsPanel .props-minimize-btn:hover {
      background: rgba(255, 255, 255, 0.14);
    }

    #propsPanel {
      background: var(--ui-chrome-surface);
      backdrop-filter: var(--ui-backdrop-filter);
      -webkit-backdrop-filter: var(--ui-backdrop-filter);
      padding: 10px 14px;
      font-family: var(--font-ui);
      font-size: var(--text-label-size);
      width: 100%;
      max-width: 100%;
      min-height: 0;
      box-sizing: border-box;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      border-radius: var(--ui-chrome-radius);
      border: var(--ui-chrome-border);
      box-shadow: var(--ui-chrome-shadow);
    }

    #propsPanel .props-header,
    #propsPanel .props-multi-state-warning,
    #propsPanel .props-panel-tabs {
      flex-shrink: 0;
    }

    #propsPanel #propsPanePropriedades > .props-panel-meta,
    #propsPanel #propsPanePropriedades > hr,
    #propsPanel #propsPanePropriedades > .props-panel-inline-tools,
    #propsPanel #propsPanePropriedades > .props-panel-footer-actions {
      flex-shrink: 0;
    }

    /* Pane ativo ocupa a altura restante do painel (cadeia flex até .props-content) */
    #propsPanel .props-panel-pane.active {
      flex: 1 1 0%;
      min-height: 0;
      overflow: hidden;
    }

    #propsPanel #propsPanePropriedades.active {
      display: flex;
      flex-direction: column;
      flex: 1 1 0%;
      min-height: 0;
      overflow: hidden;
    }

    /* Multi-seleção: scroll no painel inteiro (meta + acordeões) */
    #propsPanel #propsPanePropriedades.props-pane--multi.active {
      overflow-x: hidden;
      overflow-y: auto;
      overscroll-behavior-y: contain;
      -webkit-overflow-scrolling: touch;
      touch-action: pan-y;
      scrollbar-gutter: stable;
      scrollbar-width: thin;
      scrollbar-color: rgba(120, 120, 128, 0.85) rgba(0, 0, 0, 0.12);
    }

    #propsPanel #propsPanePropriedades.props-pane--multi.active::-webkit-scrollbar {
      width: 10px;
    }

    #propsPanel #propsPanePropriedades.props-pane--multi.active::-webkit-scrollbar-track {
      background: rgba(0, 0, 0, 0.08);
      border-radius: 6px;
    }

    #propsPanel #propsPanePropriedades.props-pane--multi.active::-webkit-scrollbar-thumb {
      background: rgba(100, 100, 108, 0.55);
      border-radius: 6px;
    }

    #propsPanel #propsPanePropriedades .props-content.props-content--multi {
      flex: 0 0 auto;
      min-height: 0;
      height: auto;
      overflow: visible;
      display: block;
    }

    /*
      Seleção única: scroll na lista de propriedades (.props-content).
    */
    #propsPanel #propsPanePropriedades .props-content:not(.props-content--multi),
    #propsPanel #propsPanePropriedades .props-content.props-content-scroll:not(.props-content--multi),
    #propsPanel #propsPanePropriedades .props-content.props-content-virtual {
      flex: 1 1 0%;
      min-height: 140px;
      width: 100%;
      box-sizing: border-box;
      display: flex;
      flex-direction: column;
      gap: 10px;
      overflow-x: hidden;
      overflow-y: auto;
      overscroll-behavior-y: contain;
      padding-right: 4px;
      scrollbar-gutter: stable;
      scrollbar-width: thin;
      scrollbar-color: rgba(120, 120, 128, 0.85) rgba(0, 0, 0, 0.12);
      -webkit-overflow-scrolling: touch;
      touch-action: pan-y;
    }
    #propsPanel .props-content::-webkit-scrollbar,
    #propsPanel .props-content.props-content-scroll::-webkit-scrollbar,
    #propsPanel .props-content.props-content-virtual::-webkit-scrollbar {
      width: 10px;
    }
    #propsPanel .props-content::-webkit-scrollbar-track,
    #propsPanel .props-content.props-content-scroll::-webkit-scrollbar-track,
    #propsPanel .props-content.props-content-virtual::-webkit-scrollbar-track {
      background: rgba(0, 0, 0, 0.08);
      border-radius: 6px;
    }
    #propsPanel .props-content::-webkit-scrollbar-thumb,
    #propsPanel .props-content.props-content-scroll::-webkit-scrollbar-thumb,
    #propsPanel .props-content.props-content-virtual::-webkit-scrollbar-thumb {
      background: rgba(100, 100, 108, 0.55);
      border-radius: 6px;
    }
    #propsPanel .props-content::-webkit-scrollbar-thumb:hover,
    #propsPanel .props-content.props-content-scroll::-webkit-scrollbar-thumb:hover,
    #propsPanel .props-content.props-content-virtual::-webkit-scrollbar-thumb:hover {
      background: rgba(80, 80, 88, 0.75);
    }
    #propsPanel .props-panel-group-children-virtual .pe-vscroll-top,
    #propsPanel .props-panel-group-children-virtual .pe-vscroll-bottom {
      width: 100%;
      pointer-events: none;
    }
    
    .done-checkbox-container {
      margin-top: 8px;
      padding-top: 8px;
      border-top: 1px solid #e0e0e0;
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 6px;
    }
    
    .done-checkbox-container input[type="checkbox"] {
      cursor: pointer;
      width: 16px;
      height: 16px;
      flex-shrink: 0;
    }
    
    .done-checkbox-container input[type="checkbox"]:disabled {
      cursor: not-allowed;
      opacity: 0.55;
    }

    .done-checkbox-container input[type="checkbox"]:disabled + label {
      cursor: not-allowed;
      opacity: 0.65;
    }

    .done-checkbox-container label {
      cursor: pointer;
      font-size: 12px;
      color: #333;
      user-select: none;
      white-space: nowrap;
      flex: 0 1 auto;
    }

    #propsPanel .done-checkbox-container--with-performer {
      align-items: flex-start;
      gap: 8px 10px;
    }

    #propsPanel .done-performed-by {
      display: flex;
      flex-direction: column;
      gap: 3px;
      flex: 1 1 140px;
      min-width: 120px;
      max-width: 100%;
    }

    #propsPanel .done-performed-by > label {
      font-size: 11px;
      font-weight: 600;
      color: inherit;
      white-space: normal;
      cursor: default;
    }

    #propsPanel .done-performed-by-required {
      color: #c62828;
      margin-left: 2px;
    }

    #propsPanel .done-performed-by input[type="text"],
    #propsPanel .done-performed-by select.performed-by-select {
      width: 100%;
      box-sizing: border-box;
      padding: 5px 8px;
      border: 1px solid rgba(0, 0, 0, 0.14);
      border-radius: 6px;
      font: inherit;
      font-size: 12px;
      background: rgba(255, 255, 255, 0.75);
      color: inherit;
    }

    #propsPanel .done-performed-by select.performed-by-select {
      cursor: pointer;
      appearance: auto;
    }

    #propsPanel .done-performed-by input[type="text"]:focus,
    #propsPanel .done-performed-by select.performed-by-select:focus {
      outline: none;
      border-color: rgba(37, 99, 235, 0.55);
      box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
    }

    #propsPanel .done-performed-by input[type="text"]:disabled,
    #propsPanel .done-performed-by select.performed-by-select:disabled {
      opacity: 0.6;
      cursor: not-allowed;
    }

    body.dark-theme #propsPanel .done-performed-by input[type="text"],
    body.dark-theme #propsPanel .done-performed-by select.performed-by-select {
      border-color: rgba(255, 255, 255, 0.16);
      background: rgba(0, 0, 0, 0.22);
      color: inherit;
    }

    body.dark-theme #propsPanel .done-performed-by-required {
      color: #ff8a80;
    }

    #propsPanel .done-meta {
      font-size: 10px;
      color: #666;
      margin-top: 4px;
      margin-left: 22px;
      font-style: italic;
      flex-basis: 100%;
    }
    
    .comment-container {
      margin-top: 8px;
      padding-top: 8px;
      border-top: 1px solid #e0e0e0;
    }
    
    .comment-container label {
      display: block;
      font-size: 12px;
      font-weight: 600;
      color: #333;
      margin-bottom: 4px;
      white-space: nowrap;
    }
    
    .comment-container input[type="text"]:disabled {
      cursor: not-allowed;
      opacity: 0.6;
      background: rgba(0, 0, 0, 0.04);
    }
    
    .comment-container input[type="text"] {
      width: 100%;
      padding: 4px 6px;
      font-size: 12px;
      border: 1px solid #ccc;
      border-radius: 3px;
      box-sizing: border-box;
    }
    
    .comment-container input[type="text"]:focus {
      outline: none;
      border-color: #2563eb;
    }
    
    .comment-char-count {
      font-size: 10px;
      color: #666;
      margin-top: 2px;
      text-align: right;
    }

    #propsPanel .comment-save-btn {
      margin-top: 6px;
      padding: 4px 8px;
      font-size: 11px;
      border-radius: 3px;
      border: 1px solid #999;
      background: #f5f5f5;
      cursor: pointer;
      color: #333;
    }

    #propsPanel .comment-save-btn:hover {
      background: #e8e8e8;
    }

    #propsPanel .comment-save-btn:disabled {
      opacity: 0.5;
      cursor: not-allowed;
      pointer-events: none;
    }

    #propsPanel .comment-history-wrap {
      max-height: 180px;
      overflow-y: auto;
      margin-bottom: 10px;
      padding: 8px;
      background: rgba(0,0,0,0.04);
      border-radius: 8px;
    }

    #propsPanel .comment-history {
      display: flex;
      flex-direction: column;
      gap: 6px;
    }

    #propsPanel .comment-history-empty {
      font-size: 11px;
      color: #888;
      font-style: italic;
      margin: 0;
    }

    #propsPanel .comment-history-item {
      font-size: 12px;
      padding: 6px 8px;
      background: #fff;
      border-radius: 8px;
      border: 1px solid rgba(0,0,0,0.08);
      box-shadow: 0 1px 2px rgba(0,0,0,0.04);
    }

    #propsPanel .comment-history-item-head {
      display: flex;
      align-items: center;
      gap: 6px;
      min-width: 0;
    }

    #propsPanel .comment-history-who {
      font-weight: 600;
      color: #2563eb;
      min-width: 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    #propsPanel .comment-history-when {
      font-size: 10px;
      color: #888;
      flex: 1 1 auto;
      min-width: 0;
    }

    #propsPanel .comment-history-delete {
      flex: 0 0 auto;
      margin-left: auto;
      width: 22px;
      height: 22px;
      padding: 0;
      border: 0;
      border-radius: 6px;
      background: transparent;
      color: #888;
      font-size: 16px;
      line-height: 1;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      justify-content: center;
    }

    #propsPanel .comment-history-delete:hover {
      background: rgba(198, 40, 40, 0.12);
      color: #c62828;
    }

    body.dark-theme #propsPanel .comment-history-delete:hover {
      background: rgba(255, 138, 128, 0.16);
      color: #ff8a80;
    }

    #propsPanel .comment-history-text {
      margin-top: 4px;
      color: #333;
      word-break: break-word;
    }

    /* Custom document browser tree (replaces official Document Browser) */
    #floorplanPanel {
      background: var(--ui-chrome-surface);
      backdrop-filter: var(--ui-backdrop-filter);
      -webkit-backdrop-filter: var(--ui-backdrop-filter);
      padding: 10px 14px;
      font-family: var(--font-ui);
      font-size: var(--text-label-size);
      width: 100%;
      max-width: 100%;
      box-sizing: border-box;
      border-radius: var(--ui-chrome-radius);
      border: var(--ui-chrome-border);
      box-shadow: var(--ui-chrome-shadow);
    }

    #floorplanPanel .panel-header-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      margin-bottom: 6px;
    }

    #floorplanPanel h3 {
      margin: 0;
      font-size: 13px;
    }

    #floorplanPanel .panel-toggle-btn {
      border: 1px solid rgba(0, 0, 0, 0.12);
      background: rgba(255, 255, 255, 0.8);
      color: var(--ui-text-primary);
      width: 22px;
      height: 22px;
      border-radius: 6px;
      font-size: 14px;
      line-height: 1;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
      padding: 0;
    }

    #floorplanPanel .panel-toggle-btn:hover {
      background: rgba(0, 0, 0, 0.08);
    }

    #floorplanPanel.minimized #floorplanTree {
      display: none;
    }

    #floorplanPanel.minimized .panel-header-row {
      margin-bottom: 0;
    }

    /* Document browser tree */
    #floorplanTree {
      width: 100%;
      font-size: 13px;
      list-style: none;
      margin: 0;
      padding: 0;
    }
    #floorplanTree .doc-tree-root {
      display: flex;
      flex-direction: column;
      gap: 2px;
    }
    #floorplanTree .doc-tree-item {
      display: flex;
      align-items: center;
      gap: 6px;
      padding: 6px 8px;
      border-radius: 6px;
      cursor: pointer;
      user-select: none;
      color: var(--ui-text-primary);
      transition: background 0.15s ease;
    }
    #floorplanTree .doc-tree-item:hover {
      background: rgba(0, 0, 0, 0.08);
    }
    #floorplanTree .doc-tree-item.selected {
      background: var(--ui-accent-soft-bg);
      color: var(--ui-accent);
    }
    #floorplanTree .doc-tree-item.section-header {
      font-weight: 600;
    }
    #floorplanTree .doc-tree-item.doc-tree-primary {
      background: var(--ui-accent-muted-bg);
    }
    #floorplanTree .doc-tree-item .doc-tree-chevron {
      width: 16px;
      flex-shrink: 0;
      font-size: 10px;
      color: #666;
      transition: transform 0.15s ease;
    }
    #floorplanTree .doc-tree-item .doc-tree-chevron.expanded {
      transform: rotate(90deg);
    }
    #floorplanTree .doc-tree-item .doc-tree-label {
      flex: 1;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    #floorplanTree .doc-tree-item .doc-tree-count {
      flex-shrink: 0;
      min-width: 20px;
      padding: 1px 6px;
      border-radius: 999px;
      background: rgba(0, 0, 0, 0.08);
      color: #666;
      font-size: 11px;
      text-align: center;
    }
    #floorplanTree .doc-tree-children {
      margin-left: 16px;
      border-left: 1px solid rgba(0, 0, 0, 0.08);
      padding-left: 4px;
    }
    #floorplanTree .doc-tree-children.collapsed {
      display: none;
    }
    #floorplanTree .doc-tree-item.child-item {
      padding-left: 6px;
    }
    #floorplanTree .doc-tree-item.empty-item {
      cursor: default;
      color: #777;
      font-style: italic;
    }
    #floorplanTree .doc-tree-item.empty-item:hover {
      background: transparent;
    }
    #floorplanTree .doc-tree-loading {
      padding: 8px;
      color: #666;
      font-style: italic;
    }

    #propsPanel h3 {
      margin: 0 0 6px 0;
      font-size: 13px;
    }
    
    #propsPanel .props-multi-state-warning {
      display: flex;
      align-items: flex-start;
      gap: 8px;
      margin: 0 0 10px 0;
      padding: 10px 12px;
      border-radius: 8px;
      background: rgba(220, 53, 69, 0.1);
      border: 1px solid rgba(220, 53, 69, 0.35);
      color: #b02a37;
      font-size: 12px;
      line-height: 1.45;
      font-weight: 500;
    }

    #propsPanel .props-multi-state-warning[hidden] {
      display: none;
    }

    #propsPanel .props-multi-state-warning__icon {
      flex-shrink: 0;
      font-size: 16px;
      line-height: 1.2;
    }

    #propsPanel .props-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 6px;
      gap: 10px;
    }
    
    #propsPanel .props-header h3 {
      margin: 0 0 6px 0;
      flex: 1;
      min-width: 0;
    }

    #propsPanel .props-header-busy {
      display: inline-flex;
      align-items: center;
      gap: 7px;
      padding: 5px 9px;
      border-radius: 999px;
      background: rgba(37, 99, 235, 0.1);
      border: 1px solid rgba(37, 99, 235, 0.22);
      color: #2563eb;
      font-size: 12px;
      font-weight: 600;
      white-space: nowrap;
    }

    #propsPanel .props-header-busy[hidden] {
      display: none;
    }

    #propsPanel .props-header-busy-spinner {
      width: 72px;
      height: 3px;
      border: 0;
      border-radius: 999px;
      background: rgba(37, 99, 235, 0.18);
      overflow: hidden;
      position: relative;
      flex-shrink: 0;
      animation: none;
      box-shadow: 0 0 8px color-mix(in srgb, var(--ui-accent) 35%, transparent);
    }
    #propsPanel .props-header-busy-spinner::before {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      height: 100%;
      width: 45%;
      border-radius: inherit;
      background: linear-gradient(
        90deg,
        transparent,
        var(--ui-accent) 18%,
        #ffffff 50%,
        var(--ui-accent) 82%,
        transparent
      );
      animation: auth-bar-slide 1.2s cubic-bezier(0.45, 0, 0.35, 1) infinite;
    }

    #propsPanel.is-busy .props-panel-tabs,
    #propsPanel.is-busy .props-panel-pane {
      pointer-events: none;
      opacity: 0.58;
      user-select: none;
    }

    #propsPanel.is-busy .props-close-btn {
      pointer-events: none;
      opacity: 0.45;
      cursor: not-allowed;
    }
    
    #propsPanel .props-close-btn {
      background: none;
      border: none;
      font-size: 18px;
      cursor: pointer;
      color: #1d1d1f;
      padding: 4px 8px;
      line-height: 1;
      border-radius: 8px;
      transition: background 0.2s ease, color 0.2s ease;
    }
    
    #propsPanel .props-close-btn:hover {
      background: rgba(0, 0, 0, 0.06);
      color: #1d1d1f;
    }
    
    #propsPanel.hidden {
      display: none;
    }

    #propsPanel .empty {
      color: #666;
      font-style: italic;
    }

    #propsPanel .props-too-large-notice {
      margin: 4px 0 0;
      color: #c62828;
      font-size: 13px;
      font-weight: 600;
      line-height: 1.45;
    }

    /* Props panel tabs (Propriedades | Execução | Financeira) */
    #propsPanel .props-panel-tabs {
      display: flex;
      flex-wrap: wrap;
      gap: 4px 8px;
      margin-bottom: 10px;
      border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    }
    #propsPanel .props-panel-tab {
      padding: 6px 12px;
      border: none;
      background: none;
      font-size: 12px;
      font-weight: 500;
      color: #6c757d;
      cursor: pointer;
      border-bottom: 2px solid transparent;
      margin-bottom: -1px;
    }
    #propsPanel .props-panel-tab:hover {
      color: #2c3e50;
    }
    #propsPanel .props-panel-tab.active {
      color: var(--ui-accent);
      border-bottom-color: var(--ui-accent);
    }
    #propsPanel .props-panel-pane {
      display: none;
    }
    #propsPanel .props-panel-pane.active {
      display: flex;
      flex-direction: column;
      flex: 1 1 0%;
      min-height: 0;
      overflow: hidden;
    }
    #propsPanel .props-panel-meta {
      display: flex;
      flex-direction: column;
      gap: 6px;
      margin-bottom: 2px;
    }
    #propsPanel .props-panel-meta-row {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 6px 8px;
      border-radius: 8px;
      background: rgba(0, 0, 0, 0.03);
      border: 1px solid rgba(0, 0, 0, 0.06);
    }
    #propsPanel .props-panel-meta-label {
      font-size: 11px;
      line-height: 1.2;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.04em;
      color: #6b7280;
      min-width: 82px;
      flex-shrink: 0;
    }
    #propsPanel .props-panel-meta-value {
      display: flex;
      align-items: center;
      flex-wrap: wrap;
      gap: 6px;
      font-size: 13px;
      color: #1d1d1f;
      min-width: 0;
      max-width: 100%;
      word-break: break-word;
      overflow-wrap: anywhere;
    }
    #propsPanel .props-state-dot {
      display: inline-block;
      width: 10px;
      height: 10px;
      border-radius: 50%;
      flex-shrink: 0;
      background: rgb(148, 163, 184);
      box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
    }
    #propsPanel .props-state-dot--placeholder {
      opacity: 0.55;
    }

    #propsPanel .props-state-history-wrap {
      flex: 1 1 auto;
      min-height: 0;
      overflow: auto;
      padding: 8px 10px 12px;
    }

    #propsPanel .props-state-history {
      display: flex;
      flex-direction: column;
      gap: 10px;
    }

    #propsPanel .props-state-history-item {
      display: flex;
      align-items: flex-start;
      gap: 10px;
      padding: 8px 10px;
      border-radius: 8px;
      background: rgba(255, 255, 255, 0.04);
      border: 1px solid var(--ui-panel-muted-border, rgba(255, 255, 255, 0.08));
    }

    #propsPanel .props-state-history-dot {
      display: inline-block;
      width: 10px;
      height: 10px;
      border-radius: 50%;
      flex-shrink: 0;
      margin-top: 4px;
      box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
    }

    #propsPanel .props-state-history-body {
      min-width: 0;
      flex: 1;
    }

    #propsPanel .props-state-history-title {
      font-size: 13px;
      font-weight: 600;
      line-height: 1.3;
    }

    #propsPanel .props-state-history-meta {
      font-size: 11px;
      opacity: 0.75;
      margin-top: 2px;
    }

    #propsPanel .props-state-history-detail {
      font-size: 12px;
      margin-top: 4px;
      opacity: 0.9;
    }
    #propsPanel .props-panel-meta-badge {
      display: inline-flex;
      align-items: center;
      padding: 1px 7px;
      border-radius: 999px;
      font-size: 11px;
      font-weight: 600;
      background: rgba(37, 99, 235, 0.1);
      border: 1px solid rgba(37, 99, 235, 0.22);
      color: #2563eb;
      white-space: nowrap;
    }
    #propsPanel .props-panel-inline-tools {
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
      align-items: center;
      gap: 8px;
      margin-bottom: 8px;
      width: 100%;
      box-sizing: border-box;
    }
    #propsPanel .props-panel-inline-meta {
      font-size: 11px;
      font-weight: 600;
      color: #5f6b7a;
      background: rgba(0, 0, 0, 0.05);
      border: 1px solid rgba(0, 0, 0, 0.08);
      border-radius: 999px;
      padding: 2px 8px;
      min-width: 44px;
      text-align: center;
      line-height: 1.3;
    }
    #propsPanel .props-panel-inline-actions {
      display: flex;
      align-items: center;
      gap: 6px;
      flex: 1 1 180px;
      flex-wrap: wrap;
      justify-content: flex-end;
      min-width: 0;
      max-width: 100%;
    }
    #propsPanel .props-panel-inline-tool-btn,
    #propsPanel .props-panel-inline-text-btn {
      border: 1px solid rgba(0, 0, 0, 0.12);
      background: rgba(0, 0, 0, 0.02);
      color: #1d1d1f;
      border-radius: 8px;
      padding: 6px 10px;
      font-size: 12px;
      cursor: pointer;
      max-width: 100%;
      white-space: nowrap;
      transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    }
    #propsPanel .props-panel-inline-tool-btn:hover,
    #propsPanel .props-panel-inline-text-btn:hover,
    #propsPanel .props-panel-inline-tool-btn.active {
      background: rgba(0, 0, 0, 0.06);
      border-color: rgba(0, 0, 0, 0.16);
    }
    #propsPanel .props-panel-inline-save-btn {
      padding: 6px 14px;
      font-size: 12px;
      font-weight: 600;
      border-radius: 8px;
      border: none;
      background: #2563eb;
      color: #fff;
      cursor: pointer;
      transition: background 0.2s ease, opacity 0.2s ease;
    }
    #propsPanel .props-panel-inline-save-btn:hover {
      background: #1d4ed8;
    }
    #propsPanel .props-panel-inline-save-btn:disabled,
    #propsPanel .props-panel-inline-text-btn:disabled {
      opacity: 0.55;
      cursor: not-allowed;
      filter: saturate(0.7);
    }
    #propsPanel .props-panel-group {
      background: rgba(0, 0, 0, 0.02);
      border: 1px solid rgba(0, 0, 0, 0.06);
      border-radius: 6px;
      overflow: visible;
    }
    #propsPanel .props-panel-group-header {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 6px 8px;
      font-weight: 600;
      color: #1d1d1f;
      background: transparent;
    }
    #propsPanel .props-panel-group-label {
      flex: 1;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    #propsPanel .props-panel-group-count {
      flex-shrink: 0;
      min-width: 20px;
      padding: 1px 6px;
      border-radius: 999px;
      background: rgba(0, 0, 0, 0.08);
      color: #666;
      font-size: 11px;
      text-align: center;
    }
    #propsPanel .props-panel-group-children {
      display: flex;
      flex-direction: column;
      gap: 0;
    }

    /* Multi-select Propriedades: group by type, accordion per element */
    #propsPanel .props-multi-type-group,
    #propsPanel .props-multi-element {
      border: 1px solid rgba(0, 0, 0, 0.06);
      border-radius: 6px;
      background: rgba(0, 0, 0, 0.02);
      overflow: visible;
      max-width: 100%;
      box-sizing: border-box;
    }

    #propsPanel .props-multi-element-props,
    #propsPanel .props-multi-element-body {
      max-width: 100%;
      overflow-x: hidden;
    }
    #propsPanel .props-multi-type-group + .props-multi-type-group {
      margin-top: 8px;
    }
    #propsPanel .props-multi-type-header,
    #propsPanel .props-multi-element-header {
      display: flex;
      align-items: center;
      gap: 8px;
      width: 100%;
      padding: 8px 10px;
      border: none;
      background: transparent;
      color: inherit;
      font: inherit;
      text-align: left;
      cursor: pointer;
    }
    #propsPanel .props-multi-element-row {
      display: flex;
      align-items: center;
      gap: 6px;
      min-width: 0;
    }
    #propsPanel .props-multi-element-row .props-multi-element-header {
      flex: 1 1 auto;
      min-width: 0;
      width: auto;
    }
    #propsPanel .props-multi-view-btn {
      flex: 0 0 auto;
      margin: 0 8px 0 0;
      padding: 4px 8px;
      border: 1px solid rgba(0, 0, 0, 0.12);
      border-radius: 6px;
      background: rgba(0, 0, 0, 0.04);
      color: inherit;
      font: inherit;
      font-size: 11px;
      font-weight: 600;
      line-height: 1.2;
      white-space: nowrap;
      cursor: pointer;
    }
    #propsPanel .props-multi-view-btn:hover {
      background: rgba(0, 0, 0, 0.08);
    }
    body.dark-theme #propsPanel .props-multi-view-btn {
      border-color: rgba(255, 255, 255, 0.14);
      background: rgba(255, 255, 255, 0.06);
    }
    body.dark-theme #propsPanel .props-multi-view-btn:hover {
      background: rgba(255, 255, 255, 0.12);
    }
    #propsPanel .props-multi-type-header:hover,
    #propsPanel .props-multi-element-header:hover {
      background: rgba(0, 0, 0, 0.04);
    }
    #propsPanel .props-multi-chevron {
      flex-shrink: 0;
      width: 0;
      height: 0;
      border-top: 5px solid transparent;
      border-bottom: 5px solid transparent;
      border-left: 6px solid #666;
      transition: transform 0.15s ease;
    }
    #propsPanel .props-multi-chevron.expanded {
      transform: rotate(90deg);
    }
    #propsPanel .props-multi-type-label,
    #propsPanel .props-multi-element-name {
      flex: 1;
      min-width: 0;
      display: inline-flex;
      align-items: center;
      gap: 6px;
      font-weight: 600;
      font-size: 12px;
    }
    #propsPanel .props-multi-element-name-text {
      min-width: 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    #propsPanel .props-multi-type-label {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    #propsPanel .props-multi-type-children,
    #propsPanel .props-multi-element-body {
      display: flex;
      flex-direction: column;
      gap: 6px;
      padding: 0 8px 8px;
    }
    #propsPanel .props-multi-type-children.collapsed,
    #propsPanel .props-multi-element-body.collapsed {
      display: none;
    }
    #propsPanel .props-multi-element {
      margin-top: 6px;
    }
    #propsPanel .props-multi-element-header {
      padding: 7px 8px;
      font-weight: 500;
    }
    #propsPanel .props-multi-element-name {
      font-weight: 500;
    }
    #propsPanel .props-panel-meta-nested {
      margin-top: 4px;
    }
    #propsPanel .props-multi-element-props {
      display: flex;
      flex-direction: column;
      gap: 8px;
    }
    #propsPanel .props-multi-element-props .props-panel-group {
      margin-top: 0;
    }
    #propsPanel .props-panel-prop-row {
      display: flex;
      align-items: flex-start;
      gap: 10px;
      padding: 6px 8px;
      border-radius: 6px;
      transition: background 0.15s ease, opacity 0.15s ease;
    }
    #propsPanel .props-panel-prop-row:hover {
      background: rgba(0, 0, 0, 0.08);
    }
    #propsPanel .props-panel-prop-row.is-hidden {
      opacity: 0.5;
    }
    #propsPanel .props-panel-prop-main {
      flex: 1;
      min-width: 0;
    }
    #propsPanel .props-panel-prop-label {
      font-size: 12px;
      font-weight: 600;
      color: var(--ui-text-primary);
      margin-bottom: 2px;
    }
    #propsPanel .props-panel-prop-value {
      font-size: 13px;
      color: var(--ui-text-primary);
      word-break: break-word;
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
      align-items: center;
    }
    #propsPanel .props-panel-prop-badge {
      display: inline-flex;
      align-items: center;
      padding: 2px 8px;
      border-radius: 999px;
      font-size: 11px;
      background: rgba(37, 99, 235, 0.10);
      color: #2563eb;
    }
    #propsPanel .props-panel-prop-toggle {
      position: relative;
      display: inline-flex;
      align-items: center;
      flex-shrink: 0;
      cursor: pointer;
    }
    #propsPanel .props-panel-prop-toggle input {
      position: absolute;
      opacity: 0;
      pointer-events: none;
    }
    #propsPanel .props-panel-prop-switch {
      position: relative;
      width: 34px;
      height: 20px;
      border-radius: 999px;
      background: rgba(0, 0, 0, 0.14);
      transition: background 0.2s ease;
    }
    #propsPanel .props-panel-prop-switch::after {
      content: '';
      position: absolute;
      top: 2px;
      left: 2px;
      width: 16px;
      height: 16px;
      border-radius: 50%;
      background: #fff;
      box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
      transition: transform 0.2s ease;
    }
    #propsPanel .props-panel-prop-toggle input:checked + .props-panel-prop-switch {
      background: rgba(37, 99, 235, 0.75);
    }
    #propsPanel .props-panel-prop-toggle input:checked + .props-panel-prop-switch::after {
      transform: translateX(14px);
    }
    #propsPanel .props-panel-footer-actions {
      display: flex;
      flex-wrap: wrap;
      justify-content: flex-end;
      gap: 8px;
      margin-top: 8px;
      width: 100%;
      box-sizing: border-box;
      flex-shrink: 0;
    }
    #propsPanel .props-panel-secondary-btn {
      padding: 6px 12px;
      font-size: 12px;
      border-radius: 8px;
      border: 1px solid rgba(0, 0, 0, 0.12);
      background: rgba(0, 0, 0, 0.02);
      cursor: pointer;
      color: #1d1d1f;
      max-width: 100%;
      white-space: nowrap;
      transition: background 0.2s ease, border-color 0.2s ease;
    }
    #propsPanel .props-panel-secondary-btn:hover {
      background: rgba(0, 0, 0, 0.06);
      border-color: rgba(0, 0, 0, 0.16);
    }

    /* Dark theme - Props Panel */
    body.dark-theme #propsPanel {
      background: var(--ui-chrome-surface) !important;
      border: var(--ui-chrome-border) !important;
      box-shadow: var(--ui-chrome-shadow) !important;
      color: #ffffff !important;
    }

    body.dark-theme #propsPanel * {
      color: #ffffff !important;
    }

    body.dark-theme #propsPanel .props-too-large-notice {
      color: #ff6b6b !important;
    }

    body.dark-theme #propsPanel h3 {
      color: #ffffff !important;
    }

    body.dark-theme #propsPanel .props-header h3 {
      color: #ffffff !important;
    }

    body.dark-theme #propsPanel .props-header-busy {
      background: rgba(106, 161, 255, 0.14);
      border-color: rgba(106, 161, 255, 0.32);
      color: #7cc4ff !important;
    }

    body.dark-theme #propsPanel .props-header-busy-spinner {
      background: rgba(124, 196, 255, 0.22);
      border: 0;
      box-shadow: 0 0 10px rgba(124, 196, 255, 0.35);
    }

    body.dark-theme #propsPanel .props-close-btn {
      color: #b0b0b0 !important;
    }

    body.dark-theme #propsPanel .props-close-btn:hover {
      color: #ffffff !important;
    }

    body.dark-theme #propsPanel .empty {
      color: #b0b0b0 !important;
    }

    body.dark-theme #propsPanel .props-panel-tab {
      color: #b0b0b0 !important;
    }
    body.dark-theme #propsPanel .props-panel-tab:hover {
      color: #ffffff !important;
    }
    body.dark-theme #propsPanel .props-panel-tab.active {
      color: var(--ui-accent) !important;
      border-bottom-color: var(--ui-accent) !important;
    }
    body.dark-theme #propsPanel .props-panel-tabs {
      border-bottom-color: #363d4d !important;
    }
    body.dark-theme #propsPanel .props-panel-inline-tool-btn,
    body.dark-theme #propsPanel .props-panel-inline-text-btn {
      background: #2b3242 !important;
      border-color: #363d4d !important;
      color: #ffffff !important;
    }
    body.dark-theme #propsPanel .props-panel-meta-row {
      background: rgba(255, 255, 255, 0.04);
      border-color: rgba(255, 255, 255, 0.1);
    }
    body.dark-theme #propsPanel .props-panel-meta-label {
      color: #9aa4b2;
    }
    body.dark-theme #propsPanel .props-panel-meta-value {
      color: #e5e7eb;
    }
    body.dark-theme #propsPanel .props-panel-meta-badge {
      color: #7cc4ff;
      background: rgba(106, 161, 255, 0.14);
      border-color: rgba(106, 161, 255, 0.32);
    }
    body.dark-theme #propsPanel .props-panel-inline-meta {
      color: #cfd7e6;
      background: rgba(255, 255, 255, 0.08);
      border-color: #4b5361;
    }
    body.dark-theme #propsPanel .props-panel-inline-tool-btn:hover,
    body.dark-theme #propsPanel .props-panel-inline-text-btn:hover,
    body.dark-theme #propsPanel .props-panel-inline-tool-btn.active {
      background: rgba(255, 255, 255, 0.08) !important;
      border-color: #666 !important;
    }
    body.dark-theme #propsPanel .props-panel-inline-save-btn {
      background: #6aa1ff !important;
      color: #ffffff !important;
    }
    body.dark-theme #propsPanel .props-panel-inline-save-btn:hover {
      background: #66b3ff !important;
    }
    body.dark-theme #propsPanel .props-panel-group {
      background: rgba(255, 255, 255, 0.03) !important;
      border-color: #363d4d !important;
    }
    body.dark-theme #propsPanel .props-multi-type-group,
    body.dark-theme #propsPanel .props-multi-element {
      background: rgba(255, 255, 255, 0.03) !important;
      border-color: #363d4d !important;
    }
    body.dark-theme #propsPanel .props-multi-type-header:hover,
    body.dark-theme #propsPanel .props-multi-element-header:hover {
      background: rgba(255, 255, 255, 0.06) !important;
    }
    body.dark-theme #propsPanel .props-multi-chevron {
      border-left-color: #b0b0b0;
    }
    body.dark-theme #propsPanel .props-content,
    body.dark-theme #propsPanel .props-content.props-content-scroll,
    body.dark-theme #propsPanel .props-content.props-content-virtual {
      scrollbar-color: rgba(180, 180, 190, 0.9) rgba(255, 255, 255, 0.08);
    }
    body.dark-theme #propsPanel .props-content::-webkit-scrollbar-track,
    body.dark-theme #propsPanel .props-content.props-content-scroll::-webkit-scrollbar-track,
    body.dark-theme #propsPanel .props-content.props-content-virtual::-webkit-scrollbar-track {
      background: rgba(255, 255, 255, 0.08);
    }
    body.dark-theme #propsPanel .props-content::-webkit-scrollbar-thumb,
    body.dark-theme #propsPanel .props-content.props-content-scroll::-webkit-scrollbar-thumb,
    body.dark-theme #propsPanel .props-content.props-content-virtual::-webkit-scrollbar-thumb {
      background: rgba(180, 180, 190, 0.85);
      background-clip: padding-box;
    }
    body.dark-theme #propsPanel .props-content::-webkit-scrollbar-thumb:hover,
    body.dark-theme #propsPanel .props-content.props-content-scroll::-webkit-scrollbar-thumb:hover,
    body.dark-theme #propsPanel .props-content.props-content-virtual::-webkit-scrollbar-thumb:hover {
      background: rgba(210, 210, 220, 0.95);
      background-clip: padding-box;
    }
    body.dark-theme #propsPanel .props-panel-group-header {
      background: rgba(255, 255, 255, 0.04) !important;
    }
    body.dark-theme #propsPanel .props-panel-prop-row:hover {
      background: rgba(255, 255, 255, 0.08) !important;
    }
    body.dark-theme #propsPanel .props-panel-prop-label,
    body.dark-theme #propsPanel .props-panel-prop-value {
      color: #e5e7eb !important;
    }
    body.dark-theme #propsPanel .props-panel-group-count {
      background: rgba(255, 255, 255, 0.08) !important;
      color: #b0b0b0 !important;
    }
    body.dark-theme #propsPanel .props-panel-prop-label {
      color: #b0b0b0 !important;
    }
    body.dark-theme #propsPanel .props-panel-prop-switch {
      background: rgba(255, 255, 255, 0.18) !important;
    }
    body.dark-theme #propsPanel .props-panel-prop-toggle input:checked + .props-panel-prop-switch {
      background: rgba(106, 161, 255, 0.85) !important;
    }
    body.dark-theme #propsPanel .props-panel-secondary-btn {
      background: #2b3242 !important;
      border-color: #363d4d !important;
      color: #ffffff !important;
    }
    body.dark-theme #propsPanel .props-panel-secondary-btn:hover {
      background: rgba(255, 255, 255, 0.08) !important;
      border-color: #666 !important;
    }

    body.dark-theme #propsPanel .done-checkbox-container {
      border-top-color: #363d4d !important;
    }

    body.dark-theme #propsPanel .done-checkbox-container label {
      color: #ffffff !important;
    }

    body.dark-theme #propsPanel .done-meta {
      color: #b0b0b0 !important;
    }

    body.dark-theme #propsPanel .comment-container {
      border-top-color: #363d4d !important;
    }

    body.dark-theme #propsPanel .comment-container label {
      color: #ffffff !important;
    }

    body.dark-theme #propsPanel .comment-container input[type="text"] {
      background: #2b3242 !important;
      color: #ffffff !important;
      border-color: #363d4d !important;
    }

    body.dark-theme #propsPanel .comment-container input[type="text"]:focus {
      border-color: #2563eb !important;
    }

    body.dark-theme #propsPanel .comment-char-count {
      color: #b0b0b0 !important;
    }

    body.dark-theme #propsPanel .comment-save-btn {
      background: #2b3242 !important;
      color: #ffffff !important;
      border-color: #363d4d !important;
    }

    body.dark-theme #propsPanel .comment-save-btn:hover {
      background: #4a4a4a !important;
    }

    body.dark-theme #propsPanel .comment-history-wrap {
      background: rgba(255,255,255,0.06) !important;
    }

    body.dark-theme #propsPanel .comment-history-empty {
      color: #888 !important;
    }

    body.dark-theme #propsPanel .comment-history-item {
      background: #2b3242 !important;
      border-color: #363d4d !important;
    }

    body.dark-theme #propsPanel .comment-history-who {
      color: #6aa1ff !important;
    }

    body.dark-theme #propsPanel .comment-history-when {
      color: #888 !important;
    }

    body.dark-theme #propsPanel .comment-history-text {
      color: #e0e0e0 !important;
    }

    body.dark-theme #propsPanel strong {
      color: #ffffff !important;
    }

    body.dark-theme #propsPanel span {
      color: #ffffff !important;
    }

    body.dark-theme #propsPanel div {
      color: #ffffff !important;
    }

    body.dark-theme #propsPanel p {
      color: #ffffff !important;
    }

    /* Dark theme - Props Panel - All text elements */
    body.dark-theme #propsPanel table,
    body.dark-theme #propsPanel table th,
    body.dark-theme #propsPanel table td,
    body.dark-theme #propsPanel table * {
      color: #ffffff !important;
      background: transparent !important;
    }

    body.dark-theme #propsPanel a {
      color: #4CAF50 !important;
    }

    body.dark-theme #propsPanel a:hover {
      color: #66bb6a !important;
    }

    /* Dark theme - Override any inline styles in propsPanel */
    body.dark-theme #propsPanel [style*="color:#333"],
    body.dark-theme #propsPanel [style*="color: #333"],
    body.dark-theme #propsPanel [style*="color:#666"],
    body.dark-theme #propsPanel [style*="color: #666"],
    body.dark-theme #propsPanel [style*="color:#2e3444"],
    body.dark-theme #propsPanel [style*="color: #2e3444"] {
      color: #ffffff !important;
    }

    body.dark-theme #propsPanel [style*="background:#ffffff"],
    body.dark-theme #propsPanel [style*="background: #ffffff"],
    body.dark-theme #propsPanel [style*="background:#fafafa"],
    body.dark-theme #propsPanel [style*="background: #fafafa"] {
      background: #2b3242 !important;
    }

    /* Dark theme - Export to Excel button */
    body.dark-theme #exportPropsBtn {
      background: #363d4d !important;
      color: #ffffff !important;
      border-color: #777 !important;
      border-width: 1px !important;
    }

    body.dark-theme #exportPropsBtn:hover {
      background: #666 !important;
      border-color: #999 !important;
    }

    /* Dark theme - Floorplan Panel */
    body.dark-theme #floorplanPanel {
      background: var(--ui-chrome-surface) !important;
      border: var(--ui-chrome-border) !important;
      box-shadow: var(--ui-chrome-shadow) !important;
      color: #ffffff !important;
    }

    body.dark-theme #floorplanPanel h3 {
      color: #ffffff !important;
    }

    body.dark-theme #floorplanPanel .panel-toggle-btn {
      border-color: rgba(255, 255, 255, 0.2) !important;
      background: rgba(255, 255, 255, 0.06) !important;
      color: #f5f5f5 !important;
    }

    body.dark-theme #floorplanPanel .panel-toggle-btn:hover {
      background: rgba(255, 255, 255, 0.12) !important;
    }

    body.dark-theme #floorplanTree,
    body.dark-theme #floorplanTree .doc-tree-item {
      color: #e0e0e0 !important;
    }
    body.dark-theme #floorplanTree .doc-tree-item:hover {
      background: rgba(255, 255, 255, 0.1) !important;
    }
    body.dark-theme #floorplanTree .doc-tree-item.selected {
      background: var(--ui-accent-soft-bg) !important;
      color: var(--ui-accent) !important;
    }
    body.dark-theme #floorplanTree .doc-tree-item.doc-tree-primary {
      background: var(--ui-accent-muted-bg) !important;
    }
    body.dark-theme #floorplanTree .doc-tree-chevron {
      color: #b0b0b0 !important;
    }
    body.dark-theme #floorplanTree .doc-tree-count {
      background: rgba(255, 255, 255, 0.12) !important;
      color: #cfcfcf !important;
    }
    body.dark-theme #floorplanTree .doc-tree-children {
      border-left-color: #363d4d !important;
    }
    body.dark-theme #floorplanTree .doc-tree-loading {
      color: #b0b0b0 !important;
    }
    body.dark-theme #floorplanTree .doc-tree-item.empty-item {
      color: #9d9d9d !important;
    }

    /* Dark theme - Model selector modal (Select Models) */
    body.dark-theme #modelSelectorModal .project-elements-modal-content {
      background: var(--ui-chrome-surface) !important;
      color: #e0e0e0 !important;
      border: var(--ui-chrome-border) !important;
    }
    body.dark-theme #modelSelectorModal .project-elements-header h2 {
      color: #e0e0e0 !important;
    }
    body.dark-theme #modelSelectorModal #modelSelectorFileList {
      background: rgba(255, 255, 255, 0.04) !important;
      border-color: #363d4d !important;
    }
    body.dark-theme #modelSelectorModal .model-selector-item-name,
    body.dark-theme #modelSelectorModal .model-selector-item-meta,
    body.dark-theme #modelSelectorModal .model-selector-item-urn,
    body.dark-theme #modelSelectorModal .model-selector-aux-label,
    body.dark-theme #modelSelectorModal .ui-loading-message,
    body.dark-theme #modelSelectorModal .model-selector-info {
      color: #e0e0e0 !important;
    }
    body.dark-theme #modelSelectorModal #modelSelectorCancel,
    body.dark-theme .ui-button-secondary {
      background: rgba(255, 255, 255, 0.06) !important;
      color: #e0e0e0 !important;
      border-color: #363d4d !important;
    }
    body.dark-theme #modelSelectorModal #modelSelectorInfo {
      background: rgba(106, 161, 255, 0.12) !important;
      border-color: rgba(106, 161, 255, 0.12) !important;
    }
    body.dark-theme #modelSelectorModal #modelSelectorFileList .model-selector-item:hover {
      background: rgba(255, 255, 255, 0.08) !important;
    }
    body.dark-theme #modelSelectorModal #modelSelectorFileList .model-selector-item {
      border-bottom-color: #363d4d !important;
    }

    .project-elements-modal.hidden {
      display: none;
    }

    .project-elements-modal {
      position: fixed;
      inset: 0;
      z-index: 2000;
      background: rgba(0, 0, 0, 0.45);
      backdrop-filter: saturate(120%) blur(14px);
      -webkit-backdrop-filter: saturate(120%) blur(14px);
      display: flex;
      align-items: flex-start;
      justify-content: center;
      padding: 40px 20px;
    }

    .project-elements-modal-content {
      width: 60vw;
      max-width: calc(100vw - 40px);
      max-height: calc(var(--app-vh) - 80px);
      min-width: 500px;
      min-height: 260px;
      border-radius: 16px;
      padding: 24px 28px;
      position: fixed;
      top: 80px;
      left: 50%;
      transform: translateX(-50%);
      display: flex;
      flex-direction: column;
      gap: 16px;
      overflow-y: auto;
      overflow-x: hidden;
    }

    body.user-authenticated #modelSelectorModal .project-elements-modal-content,
    body.user-authenticated #replaceModelModal .project-elements-modal-content {
      left: calc(50% + (var(--ui-content-inset-left-expanded) / 2));
      max-width: calc(100vw - var(--ui-content-inset-left-expanded) - 40px);
      transition: left var(--motion-smooth-medium), max-width var(--motion-smooth-medium);
    }

    body.user-authenticated.sidebar-collapsed #modelSelectorModal .project-elements-modal-content,
    body.user-authenticated.sidebar-collapsed #replaceModelModal .project-elements-modal-content {
      left: calc(50% + (var(--ui-content-inset-left-collapsed) / 2));
      max-width: calc(100vw - var(--ui-content-inset-left-collapsed) - 40px);
    }
    
    .project-elements-modal-content::-webkit-scrollbar {
      width: 10px;
    }
    
    .project-elements-modal-content::-webkit-scrollbar-track {
      background: rgba(0, 0, 0, 0.04);
      border-radius: 10px;
    }
    
    .project-elements-modal-content::-webkit-scrollbar-thumb {
      background: rgba(37, 99, 235, 0.35);
      border-radius: 10px;
    }
    
    .project-elements-modal-content::-webkit-scrollbar-thumb:hover {
      background: rgba(37, 99, 235, 0.48);
    }

    .project-elements-modal-content h2 {
      cursor: move;
      user-select: none;
      margin: 0;
      font-size: 24px;
      font-weight: 700;
      color: #2c3e50;
    }

    .project-elements-close {
      position: absolute;
      right: 16px;
      top: 16px;
      border: none;
      background: transparent;
      font-size: 24px;
      cursor: pointer;
      z-index: 5;
      color: #1d1d1f;
      width: 32px;
      height: 32px;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .project-elements-header {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 16px;
      padding-bottom: 16px;
      border-bottom: 1px solid rgba(0, 0, 0, 0.08);
      margin-bottom: 8px;
    }

    .model-selector-modal-content {
      min-width: 600px;
    }

    .model-selector-file-list {
      min-height: 120px;
    }

    /* Modal action buttons – sidebar-style */
    #modelSelectorModal .modal-actions,
    #replaceModelModal .modal-actions {
      display: flex;
      gap: 8px;
      margin-top: 12px;
      justify-content: flex-end;
    }

    #modelSelectorCancel {
      padding: 10px 16px;
      font-size: 13px;
      font-weight: 500;
      border-radius: 10px;
      cursor: pointer;
    }

    #modelSelectorDelete {
      padding: 10px 16px;
      font-size: 13px;
      font-weight: 500;
      border-radius: 10px;
      cursor: pointer;
    }

    #modelSelectorSave {
      padding: 10px 16px;
      font-size: 13px;
      font-weight: 500;
      border-radius: 10px;
      cursor: pointer;
    }

    .analise-global-choice-content {
      position: relative;
      padding: 24px 28px;
      min-width: 260px;
      max-width: 90vw;
      border-radius: 16px;
    }

    .analise-global-choice-title {
      margin: 0 0 8px 0;
      font-size: 24px;
      font-weight: 700;
      color: #2c3e50;
    }

    .analise-global-choice-description {
      margin: 0 0 20px 0;
      font-size: 14px;
      color: #6c757d;
    }

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

    .analise-global-choice-btn {
      padding: 10px 20px;
      font-size: 13px;
      font-weight: 500;
      border-radius: 10px;
      cursor: pointer;
    }

    .analise-global-choice-btn-primary {
      border: 1px solid rgba(37, 99, 235, 0.14);
    }

    .analise-global-choice-btn-secondary {
      border: 1px solid rgba(0, 0, 0, 0.08);
    }

    .analise-global-choice-content .analise-global-close {
      position: absolute;
      top: 8px;
      right: 8px;
      font-size: 22px;
      border: none;
      background: transparent;
      cursor: pointer;
      color: #1d1d1f;
      width: 32px;
      height: 32px;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    body.dark-theme .analise-global-choice-content {
      background: #212736;
      border-color: #363d4d;
    }

    body.dark-theme .analise-global-choice-title {
      color: #e0e0e0;
    }

    body.dark-theme .analise-global-choice-description {
      color: #aaa;
    }

    body.dark-theme .analise-global-choice-btn-secondary {
      border-color: rgba(255, 255, 255, 0.08);
      background: rgba(255, 255, 255, 0.06);
      color: #e0e0e0;
    }

    body.dark-theme .analise-global-choice-btn-secondary:hover {
      background: rgba(255, 255, 255, 0.15);
      border-color: rgba(255, 255, 255, 0.25);
    }

    body.dark-theme .analise-global-choice-content .analise-global-close {
      color: #e0e0e0;
    }

    body.dark-theme .analise-global-choice-content .analise-global-close:hover {
      background: rgba(255, 255, 255, 0.1);
    }

    .modal-secondary-btn {
      padding: 0 16px;
      font-size: 13px;
      font-weight: 500;
      line-height: 40px;
      height: 40px;
      border-radius: 10px;
      cursor: pointer;
      box-sizing: border-box;
    }

    .project-elements-logo {
      max-height: 60px;
      max-width: 180px;
      object-fit: contain;
      margin-right: 26px;
      filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
    }

    .project-elements-form-row {
      display: flex;
      flex-direction: column;
      gap: 8px;
      padding: 16px;
    }

    .project-elements-form-row label {
      font-size: 14px;
      font-weight: 600;
      color: #2c3e50;
    }

    .projectElementsSelect {
      padding: 10px 12px;
      font-size: 13px;
      border-radius: 10px;
      cursor: pointer;
      font-weight: 500;
    }
    
    .file-input-wrapper {
      position: relative;
      display: inline-block;
      vertical-align: middle;
      line-height: 0;
      margin-top: 2px;
    }
    
    #tab3 input[type="file"] {
      position: absolute;
      width: 0.1px;
      height: 0.1px;
      opacity: 0;
      overflow: hidden;
      z-index: -1;
    }
    
    #tab3 .file-input-label {
      display: inline-block;
      padding: 0 16px;
      font-size: 13px;
      font-weight: 500;
      border-radius: 10px;
      cursor: pointer;
      letter-spacing: 0.2px;
      line-height: 40px;
      height: 40px;
      box-sizing: border-box;
      white-space: nowrap;
      margin: 0;
      vertical-align: middle;
      text-align: center;
    }
    
    #tab3 .file-input-label:active {
      transform: scale(0.98);
    }
    
    #tab3 .file-input-label.has-file {
      border-color: rgba(37, 99, 235, 0.16);
      background: rgba(37, 99, 235, 0.15);
      color: #2563eb;
    }
    
    #tab3 .file-input-label.has-file:hover {
      background: rgba(37, 99, 235, 0.2);
      border-color: rgba(37, 99, 235, 0.2);
    }
    
    #tab3 select {
      padding: 10px 12px;
      font-size: 13px;
      border: 1px solid rgba(0, 0, 0, 0.1);
      border-radius: 10px;
      background: rgba(0, 0, 0, 0.06);
      color: #1d1d1f;
      transition: background 0.2s ease, box-shadow 0.2s ease;
      cursor: pointer;
      font-weight: 500;
    }
    
    #tab3 select:hover {
      background: rgba(0, 0, 0, 0.08);
    }
    
    #tab3 select:focus {
      outline: none;
      background: rgba(0, 0, 0, 0.08);
      box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.12), 0 0 0 4px rgba(10, 132, 255, 0.25);
    }
    
    #tab3 button[type="button"]:not(.btn):not(.dfs-code-picker__btn):not(.dfs-code-picker__pick) {
      padding: 0 16px;
      font-size: 13px;
      font-weight: 500;
      border-radius: 10px;
      border: 1px solid rgba(0, 0, 0, 0.1);
      background: rgba(0, 0, 0, 0.08);
      color: #1d1d1f;
      cursor: pointer;
      transition: background 0.2s ease, border-color 0.2s ease;
      letter-spacing: 0.2px;
      line-height: 40px;
      height: 40px;
      box-sizing: border-box;
      white-space: nowrap;
      margin: 0;
      vertical-align: middle;
      text-align: center;
    }
    
    #tab3 button[type="button"]:not(.btn):not(.dfs-code-picker__btn):not(.dfs-code-picker__pick):hover {
      background: rgba(0, 0, 0, 0.12);
      border-color: rgba(0, 0, 0, 0.12);
    }

    #tab3 button[type="button"]:not(.btn):not(.dfs-code-picker__btn):not(.dfs-code-picker__pick):active {
      transform: scale(0.98);
    }
    
    .tab3-button-group {
      display: flex;
      gap: 12px;
      align-items: center;
      flex-wrap: wrap;
    }
    
    #noModelMessage3 {
      display: flex;
      align-items: center;
      justify-content: center;
      min-height: 400px;
      font-size: 18px;
      color: var(--ui-text-primary);
      background: var(--ui-chrome-surface);
      backdrop-filter: var(--ui-backdrop-filter);
      -webkit-backdrop-filter: var(--ui-backdrop-filter);
      border-radius: var(--ui-chrome-radius);
      box-shadow: var(--ui-chrome-shadow);
      border: 2px dashed rgba(0, 0, 0, 0.12);
      margin: 20px 24px 20px 0;
    }
    
    #noModelMessage3::before {
      content: '📊';
      font-size: 48px;
      margin-right: 16px;
      opacity: 0.5;
    }

    .project-elements-details {
      min-height: 300px;
      overflow: visible;
      display: flex;
      flex-direction: column;
      margin-top: 10px;
      background: var(--ui-chrome-surface);
      backdrop-filter: var(--ui-backdrop-filter);
      -webkit-backdrop-filter: var(--ui-backdrop-filter);
      border-radius: var(--ui-chrome-radius);
      box-shadow: var(--ui-chrome-shadow);
      border: var(--ui-chrome-border);
      padding: 10px 12px;
      font-family: var(--font-ui);
      font-size: var(--text-label-size);
    }

    .project-elements-details h3 {
      margin: 0 0 6px 0;
      font-size: 13px;
      font-weight: 600;
      color: var(--ui-text-primary);
    }

    .project-elements-details .empty {
      color: var(--ui-text-primary);
      opacity: 0.72;
      font-style: italic;
      margin-top: 4px;
    }

    .project-elements-details .pe-details-toolbar {
      display: flex;
      align-items: center;
      gap: 10px;
      flex-wrap: wrap;
      margin-bottom: 2px;
      font-size: var(--text-label-size);
      color: var(--ui-text-primary);
      position: relative;
      z-index: 5;
      overflow: visible;
    }

    .project-elements-details .pe-jump-toolbar {
      margin: 8px 0 4px;
    }

    .project-elements-details .pe-select-all-label {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      font-size: var(--text-label-size);
      color: var(--ui-text-primary);
      cursor: pointer;
      user-select: none;
    }

    .project-elements-details .pe-selection-count {
      font-size: 0.75rem;
      color: var(--ui-text-secondary);
    }

    .project-elements-details .props-table th.pe-select-col,
    .project-elements-details .props-table td.pe-select-cell {
      width: 36px;
      min-width: 36px;
      max-width: 40px;
      text-align: center;
      padding-left: 6px;
      padding-right: 6px;
    }

    .project-elements-details .pe-details-name {
      flex: 1 1 auto;
      min-width: 0;
    }

    .project-elements-details .pe-details-name strong {
      font-weight: 600;
      margin-right: 4px;
    }

    .project-elements-details .pe-filters {
      display: flex;
      flex-direction: column;
      gap: 6px;
      margin: 8px 0 0;
    }

    .project-elements-details .pe-filter-row {
      display: flex;
      gap: 8px;
      align-items: center;
      flex-wrap: wrap;
    }

    .project-elements-details .pe-filter-label {
      font-size: 12px;
      color: var(--ui-text-primary);
      opacity: 0.72;
      width: 44px;
      flex-shrink: 0;
    }

    .project-elements-details .pe-filter-row input,
    .project-elements-details .pe-filter-row select {
      padding: 3px 6px;
      font-size: 12px;
      width: 220px;
      max-width: 100%;
      box-sizing: border-box;
      background: #ffffff;
      color: var(--ui-text-primary);
      border: 1px solid rgba(0, 0, 0, 0.15);
      border-radius: 6px;
    }

    .project-elements-details .pe-filter-row .pe-filter-apply,
    .project-elements-details .pe-filter-row .pe-filter-clear {
      padding: 3px 10px;
      font-size: 12px;
      border-radius: 6px;
      cursor: pointer;
      border: 1px solid rgba(0, 0, 0, 0.12);
      background: rgba(0, 0, 0, 0.04);
      color: var(--ui-text-primary);
    }

    .project-elements-details .pe-filter-row .pe-filter-apply:hover,
    .project-elements-details .pe-filter-row .pe-filter-clear:hover {
      background: rgba(0, 0, 0, 0.08);
    }

    .project-elements-details .pe-filter-and {
      font-size: 11px;
      color: var(--ui-text-primary);
      opacity: 0.55;
      margin-left: 2px;
    }

    .project-elements-details .pe-pager {
      flex: 0 0 auto;
      margin-top: auto;
      padding-top: 4px;
      color: var(--ui-text-primary);
    }

    .project-elements-details .pe-pager-meta {
      font-size: 12px;
      color: var(--ui-text-secondary);
    }

    .project-elements-details .pe-pager button {
      color: var(--ui-text-primary);
      background: var(--ui-panel-muted-surface, rgba(0, 0, 0, 0.04));
      border: 1px solid var(--ui-chrome-border, rgba(0, 0, 0, 0.12));
      border-radius: 6px;
      cursor: pointer;
    }

    .project-elements-details .pe-pager button:disabled {
      opacity: 0.45;
      cursor: default;
    }

    .project-elements-details .pe-pager .pe-page-input {
      background: var(--ui-chrome-surface, #fff);
      color: var(--ui-text-primary);
      border: 1px solid var(--ui-chrome-border, rgba(0, 0, 0, 0.12));
      border-radius: 6px;
    }

    .project-elements-table-wrapper {
      width: 100%;
      overflow-x: auto;
      overflow-y: auto;
      max-height: clamp(160px, calc(var(--app-vh) - 300px), 78vh);
      min-height: 0;
      flex: 1 1 auto;
      background: var(--ui-chrome-surface);
      backdrop-filter: var(--ui-backdrop-filter);
      -webkit-backdrop-filter: var(--ui-backdrop-filter);
      border-radius: var(--ui-chrome-radius);
      box-shadow: var(--ui-chrome-shadow);
      border: var(--ui-chrome-border);
      margin-top: 8px;
      padding: 6px 8px 8px 8px;
      box-sizing: border-box;
    }

    .project-elements-table-wrapper.pe-table-virtual {
      overflow-x: auto;
      overflow-y: auto;
    }

    .props-table {
      width: max-content;
      min-width: 100%;
      border-collapse: separate;
      border-spacing: 0;
      white-space: nowrap;
      min-width: 1000px;
      font-size: 13px;
    }

    .props-table th,
    .props-table td {
      border: none;
      border-bottom: 1px solid #e9ecef;
      padding: 14px 16px;
      text-align: left;
      white-space: nowrap;
      transition: background-color 0.2s ease;
    }
    
    .props-table td {
      background: #ffffff;
      color: #495057;
    }

    .props-table tfoot tr.total-row td {
      position: sticky;
      bottom: 0;
      z-index: 4;
      background: #ffffff;
      font-weight: 600;
      box-shadow: 0 -1px 0 #e9ecef;
    }

    /* Keep Total row reachable when body rows are virtualized. */
    .project-elements-table-wrapper.pe-table-virtual .props-table tfoot tr.total-row td {
      z-index: 5;
    }
    
    .props-table tbody tr {
      transition: all 0.2s ease;
    }
    
    .props-table tbody tr:hover {
      background: #f8f9fa;
    }
    
    .props-table tbody tr:hover td {
      background: #f8f9fa;
    }
    
    .props-table tbody tr.element-row {
      cursor: pointer;
    }
    
    .props-table tbody tr.element-row:hover {
      background: #e3f2fd;
    }
    
    .props-table tbody tr.element-row:hover td {
      background: #e3f2fd;
    }

    .props-table th {
      background: linear-gradient(to bottom, #f8f9fa 0%, #e9ecef 100%);
      position: sticky;
      top: 0;
      z-index: 2;
      font-weight: 600;
      color: #2c3e50;
      text-transform: uppercase;
      font-size: 11px;
      letter-spacing: 0.8px;
      border-bottom: 2px solid #dee2e6;
    }

    .props-table th.pe-sortable {
      cursor: pointer;
      user-select: none;
    }

    .props-table th.pe-sortable:hover {
      background: linear-gradient(to bottom, #eef2f7 0%, #e2e8f0 100%);
    }

    .props-table th.pe-sortable .pe-col-label::after {
      content: '';
      display: inline-block;
      margin-left: 6px;
      font-size: 10px;
      opacity: 0.35;
      vertical-align: middle;
    }

    .props-table th.pe-sortable[data-sort-dir="asc"] .pe-col-label::after {
      content: '▲';
      opacity: 0.9;
      color: var(--ui-accent, #2563eb);
    }

    .props-table th.pe-sortable[data-sort-dir="desc"] .pe-col-label::after {
      content: '▼';
      opacity: 0.9;
      color: var(--ui-accent, #2563eb);
    }

    body.dark-theme .props-table th.pe-sortable:hover {
      background: #2b3242 !important;
    }
    
    .props-table th .col-resizer {
      position: absolute;
      top: 0;
      right: 0;
      width: 8px;
      height: 100%;
      cursor: col-resize;
      background: transparent;
      user-select: none;
      z-index: 2;
      transition: background-color 0.2s ease;
      z-index: 3;
    }
    
    .props-table th .col-resizer:hover {
      background: #2563eb;
      width: 10px;
    }
    
    .props-table th .col-resizer:active {
      background: #1d4ed8;
      width: 10px;
    }

    .props-table th.pe-col-draggable {
      cursor: grab;
    }

    .props-table th.pe-col-dragging {
      opacity: 0.55;
      cursor: grabbing;
    }

    .props-table th.pe-col-drop-target {
      box-shadow: inset 3px 0 0 #2563eb;
      background: rgba(37, 99, 235, 0.08);
    }

    body.pe-col-resizing,
    body.pe-col-resizing * {
      cursor: col-resize !important;
      user-select: none !important;
    }
    
    /* Column visibility controls */
    .column-visibility-menu {
      position: relative;
      display: inline-block;
      margin-left: auto;
      flex: 0 0 auto;
      z-index: 30;
    }
    
    .column-visibility-btn {
      padding: 8px 12px;
      font-size: 13px;
      font-weight: 500;
      border-radius: 10px;
      border: 1px solid rgba(0, 0, 0, 0.1);
      background: rgba(0, 0, 0, 0.08);
      color: #1d1d1f;
      cursor: pointer;
      display: flex;
      align-items: center;
      gap: 6px;
      transition: background 0.2s ease, border-color 0.2s ease;
    }
    
    .column-visibility-btn:hover {
      background: rgba(0, 0, 0, 0.12);
      border-color: rgba(0, 0, 0, 0.12);
    }
    
    .column-visibility-dropdown {
      position: absolute;
      top: calc(100% + 8px);
      right: 0;
      left: auto;
      background: rgba(255, 255, 255, 0.98);
      backdrop-filter: saturate(180%) blur(24px);
      -webkit-backdrop-filter: saturate(180%) blur(24px);
      border: 1px solid rgba(0, 0, 0, 0.08);
      border-radius: 12px;
      box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.04) inset;
      z-index: 1000;
      width: min(420px, calc(100vw - 48px));
      min-width: 280px;
      max-height: min(420px, 60vh);
      overflow-x: hidden;
      overflow-y: auto;
      display: none;
      box-sizing: border-box;
    }
    
    .column-visibility-dropdown.show {
      display: block;
    }

    .column-visibility-actions {
      display: flex;
      gap: 8px;
      padding: 10px 10px 6px;
      position: sticky;
      top: 0;
      background: rgba(255, 255, 255, 0.98);
      z-index: 2;
    }

    .column-visibility-action-btn {
      flex: 1 1 0;
      min-width: 0;
      border: 1px solid rgba(0, 0, 0, 0.12);
      background: rgba(0, 0, 0, 0.04);
      color: #1d1d1f;
      border-radius: 8px;
      padding: 8px 10px;
      font-size: 12px;
      font-weight: 600;
      cursor: pointer;
      line-height: 1.2;
      white-space: nowrap;
    }

    .column-visibility-action-btn:hover {
      background: rgba(37, 99, 235, 0.1);
      border-color: rgba(37, 99, 235, 0.35);
      color: #1d4ed8;
    }

    .column-visibility-divider {
      height: 1px;
      margin: 2px 12px 6px;
      background: rgba(0, 0, 0, 0.1);
    }
    
    .column-visibility-item {
      padding: 10px 12px;
      display: flex;
      align-items: flex-start;
      gap: 10px;
      cursor: pointer;
      font-size: 13px;
      transition: background-color 0.2s ease;
      color: #1d1d1f;
      border-radius: 8px;
      margin: 2px 4px;
    }
    
    .column-visibility-item:hover {
      background: rgba(0, 0, 0, 0.06);
    }
    
    .column-visibility-item input[type="checkbox"] {
      cursor: pointer;
      margin: 2px 0 0 0;
      width: 16px;
      height: 16px;
      flex: 0 0 auto;
      accent-color: #2563eb;
    }
    
    .column-visibility-item label {
      cursor: pointer;
      flex: 1 1 auto;
      min-width: 0;
      margin: 0;
      user-select: none;
      font-weight: 500;
      white-space: normal;
      overflow-wrap: anywhere;
      word-break: break-word;
      line-height: 1.35;
    }
    
    .props-table th[data-col].hidden,
    .props-table td[data-col].hidden {
      display: none;
    }

    .analise-global-modal {
      position: fixed;
      inset: 0;
      z-index: 13000;
      background: rgba(0, 0, 0, 0.55);
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 20px;
    }

    body.user-authenticated .analise-global-modal,
    body.user-authenticated .analise-global-graph-modal {
      padding-left: calc(20px + var(--ui-content-inset-left-expanded));
      transition: padding-left var(--motion-smooth-medium);
    }

    body.user-authenticated.sidebar-collapsed .analise-global-modal,
    body.user-authenticated.sidebar-collapsed .analise-global-graph-modal {
      padding-left: calc(20px + var(--ui-content-inset-left-collapsed));
    }

    .analise-global-modal.hidden {
      display: none;
    }

    .analise-global-content {
      position: relative;
      padding: 24px;
      border-radius: 16px;
      max-width: 90vw;
      max-height: 90vh;
    }

    body.dark-theme .analise-global-content {
      background: #212736;
      color: #e0e0e0;
      border-color: #363d4d;
    }

    .excel-comparison-content {
      max-width: 90%;
      max-height: 90%;
      overflow: auto;
    }

    body.dark-theme .excel-comparison-content {
      background: #212736;
      color: #e0e0e0;
      border-color: #363d4d;
    }

    .excel-comparison-inner {
      max-width: 1100px;
      max-height: 85vh;
      overflow: hidden;
      display: flex;
      flex-direction: column;
      padding: 20px;
      color: #1d1d1f;
    }

    .excel-comparison-toolbar {
      display: flex;
      flex-wrap: wrap;
      gap: 12px;
      align-items: center;
      margin: 0 0 12px;
    }

    .excel-comparison-filter {
      flex: 1 1 220px;
      min-width: 160px;
      padding: 8px 10px;
      border-radius: 8px;
      border: 1px solid var(--ui-chrome-border, rgba(0, 0, 0, 0.15));
      background: var(--ui-chrome-surface, #fff);
      color: inherit;
      font-size: 13px;
    }

    .excel-comparison-diff-only {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      font-size: 13px;
      opacity: 0.9;
      white-space: nowrap;
    }

    .excel-comparison-table-wrap {
      overflow: auto;
      max-height: min(52vh, 520px);
      border: 1px solid var(--ui-panel-muted-border, #e9ecef);
      border-radius: 10px;
      background: var(--ui-chrome-surface, #fff);
    }

    .excel-comparison-pager,
    .excel-comparison-pager-meta {
      margin-top: 10px;
      text-align: center;
    }

    .excel-column-config-modal {
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .excel-column-config-content {
      position: relative;
      width: min(480px, 92vw);
      max-height: 90vh;
      overflow: auto;
      padding: 24px 20px 20px;
      border-radius: 14px;
      background: #fff;
      color: #1d1d1f;
      box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
    }

    body.dark-theme .excel-column-config-content {
      background: #212736;
      color: #e0e0e0;
      border: 1px solid #363d4d;
    }

    .excel-column-config-close {
      position: absolute;
      top: 10px;
      right: 12px;
      border: none;
      background: transparent;
      font-size: 24px;
      line-height: 1;
      cursor: pointer;
      color: inherit;
    }

    .excel-column-config-title {
      margin: 0 32px 8px 0;
      font-size: 18px;
      font-weight: 700;
    }

    .excel-column-config-description {
      margin: 0 0 16px;
      font-size: 13px;
      opacity: 0.85;
      line-height: 1.45;
    }

    .excel-column-config-form {
      display: flex;
      flex-direction: column;
      gap: 12px;
    }

    .excel-column-config-field {
      display: flex;
      flex-direction: column;
      gap: 4px;
      font-size: 13px;
      font-weight: 600;
    }

    .excel-column-config-field input {
      font-weight: 400;
      padding: 8px 10px;
      border-radius: 8px;
      border: 1px solid rgba(0, 0, 0, 0.15);
      font-size: 14px;
    }

    .excel-column-config-unit-help {
      margin: -4px 0 8px;
      font-size: 12px;
      font-weight: 400;
      line-height: 1.45;
      opacity: 0.85;
    }

    body.dark-theme .excel-column-config-field input {
      background: #1e1e1e;
      border-color: #363d4d;
      color: #e0e0e0;
    }

    .excel-column-config-actions {
      display: flex;
      gap: 10px;
      justify-content: flex-end;
      margin-top: 18px;
    }

    .excel-column-config-btn-primary,
    .excel-column-config-btn-secondary {
      padding: 8px 18px;
      border-radius: 10px;
      font-size: 14px;
      font-weight: 600;
      cursor: pointer;
      border: 1px solid transparent;
    }

    .excel-column-config-btn-primary {
      background: #2563eb;
      color: #fff;
    }

    .excel-column-config-btn-secondary {
      background: transparent;
      border-color: rgba(0, 0, 0, 0.2);
      color: inherit;
    }

    body.dark-theme .excel-column-config-btn-secondary {
      border-color: #666;
    }

    .excel-comparison-title {
      margin: 0 0 16px 0;
      font-size: 20px;
      font-weight: 700;
      color: #2c3e50;
    }

    .excel-comparison-summary {
      margin-bottom: 15px;
      padding: 10px 14px;
      border-radius: 12px;
      background: rgba(0, 0, 0, 0.03);
      border: 1px solid rgba(0, 0, 0, 0.08);
      color: #1d1d1f;
    }

    .excel-comparison-table {
      width: 100%;
      border-collapse: collapse;
      font-size: 12px;
    }

    .excel-comparison-thead .excel-comparison-th {
      position: sticky;
      top: 0;
      z-index: 2;
      padding: 8px;
      border: 1px solid rgba(0, 0, 0, 0.08);
      background: linear-gradient(to bottom, #f8f9fa 0%, #e9ecef 100%);
      color: #2563eb;
      font-weight: 600;
      text-align: left;
    }

    .excel-comparison-thead .excel-comparison-th:nth-child(2),
    .excel-comparison-thead .excel-comparison-th:nth-child(3),
    .excel-comparison-thead .excel-comparison-th:nth-child(4),
    .excel-comparison-thead .excel-comparison-th:nth-child(5) {
      text-align: right;
    }

    .excel-comparison-thead .excel-comparison-th:nth-child(6) {
      text-align: center;
    }

    .excel-comparison-td {
      padding: 6px 8px;
      border: 1px solid rgba(0, 0, 0, 0.08);
      color: inherit;
    }

    .excel-comparison-btn-close {
      padding: 10px 28px;
      font-size: 14px;
      font-weight: 600;
      border-radius: 10px;
      cursor: pointer;
    }

    body.dark-theme .excel-comparison-inner {
      color: #e0e0e0;
    }

    body.dark-theme .excel-comparison-filter {
      background: #2b3242;
      border-color: #363d4d;
      color: #e0e0e0;
    }

    body.dark-theme .excel-comparison-table-wrap {
      background: #2b3242;
      border-color: #363d4d;
    }

    body.dark-theme .excel-comparison-title {
      color: #e0e0e0;
    }

    body.dark-theme .excel-comparison-summary {
      background: rgba(255, 255, 255, 0.06);
      border-color: rgba(255, 255, 255, 0.08);
      color: #e0e0e0;
    }

    body.dark-theme .excel-comparison-table {
      border-color: rgba(255, 255, 255, 0.15);
    }

    body.dark-theme .excel-comparison-thead .excel-comparison-th {
      background: #212736;
      color: #6aa1ff;
      border-color: rgba(255, 255, 255, 0.08);
    }

    body.dark-theme .excel-comparison-td {
      border-color: rgba(255, 255, 255, 0.15);
      color: #e0e0e0;
    }

    .analise-global-image {
      max-width: 80vw;
      max-height: 80vh;
      object-fit: contain;
    }

    .analise-global-close {
      position: absolute;
      top: 8px;
      right: 8px;
      font-size: 22px;
      border: none;
      background: transparent;
      cursor: pointer;
      color: #1d1d1f;
      width: 32px;
      height: 32px;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    /* Análise global – graph modal (matches app design) */
    .analise-global-graph-modal {
      position: fixed;
      inset: 0;
      z-index: 13000;
      background: rgba(0, 0, 0, 0.6);
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 20px;
    }

    .analise-global-graph-content {
      position: relative;
      padding: 24px 28px;
      width: fit-content;
      min-width: min(95vw, 680px);
      max-width: min(95vw, 880px);
      max-height: 90vh;
      overflow: auto;
    }

    .analise-global-graph-header {
      display: flex;
      justify-content: space-between;
      align-items: flex-start;
      margin-bottom: 24px;
      padding-bottom: 16px;
      border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    }

    .analise-global-graph-header h2 {
      margin: 0;
      font-size: 24px;
      font-weight: 700;
      color: #2c3e50;
    }

    .analise-global-graph-subtitle {
      font-size: 14px;
      color: #6c757d;
      margin-top: 4px;
    }

    .analise-global-graph-close {
      position: absolute;
      top: 8px;
      right: 8px;
      font-size: 22px;
      border: none;
      background: transparent;
      cursor: pointer;
      color: #1d1d1f;
      width: 32px;
      height: 32px;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .ag-graph-body {
      padding: 20px 0;
      display: flex;
      flex-direction: column;
      gap: 20px;
    }

    .ag-graph-summary-row {
      display: flex;
      flex-direction: column;
      gap: 12px;
    }

    .ag-graph-summary-label {
      font-size: 12px;
      color: #6c757d;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.04em;
    }

    .ag-graph-summary-cards {
      display: flex;
      gap: 16px;
      flex-wrap: wrap;
    }

    .ag-graph-summary-cards .ag-graph-card {
      flex: 1;
      min-width: 0;
      overflow: visible;
    }

    .ag-graph-summary-cards .ag-graph-card-value {
      white-space: normal;
      word-break: break-word;
    }

    .ag-graph-list {
      min-width: 0;
      overflow-x: auto;
    }

    .ag-graph-legend-label {
      font-size: 12px;
      color: #6c757d;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.04em;
      margin-bottom: 8px;
    }

    .ag-graph-legend-chips {
      display: flex;
      flex-wrap: nowrap;
      gap: 6px 8px;
    }

    .ag-graph-legend-chip {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 6px 12px;
      border-radius: 20px;
      font-size: 12px;
      font-weight: 500;
      background: rgba(0, 0, 0, 0.06);
      color: #1d1d1f;
    }

    .ag-graph-section-label {
      font-size: 12px;
      color: #6c757d;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.04em;
      margin-bottom: 10px;
    }

    .ag-graph-list-item {
      display: flex;
      flex-direction: column;
      gap: 12px;
      padding: 14px 16px;
      background: rgba(0, 0, 0, 0.04);
      border-radius: 10px;
      border: 1px solid rgba(0, 0, 0, 0.06);
      margin-bottom: 16px;
    }

    .ag-graph-list-item-code {
      font-size: 14px;
      font-weight: 700;
      color: #1d1d1f;
    }

    .ag-graph-row-cards {
      display: flex;
      flex-direction: row;
      flex-wrap: wrap;
      gap: 10px;
    }

    .ag-graph-row-card {
      flex: 1;
      min-width: 90px;
      padding: 8px 12px;
      border-radius: 8px;
      display: flex;
      flex-direction: column;
      gap: 2px;
      box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    }

    .ag-graph-row-card-label {
      font-size: 10px;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.04em;
      opacity: 0.85;
    }

    .ag-graph-row-card-value {
      font-size: 13px;
      font-weight: 600;
      white-space: nowrap;
    }

    .ag-graph-row-card.excel {
      background: rgba(10, 132, 255, 0.12);
      color: #2563eb;
    }

    .ag-graph-row-card.programa {
      background: rgba(0, 0, 0, 0.06);
      color: #374151;
    }

    .ag-graph-row-card.diff-low {
      background: rgba(40, 167, 69, 0.12);
      color: #1e7e34;
    }

    .ag-graph-row-card.diff-mid {
      background: rgba(253, 126, 20, 0.12);
      color: #e65100;
    }

    .ag-graph-row-card.diff-high {
      background: rgba(220, 53, 69, 0.12);
      color: #b71c1c;
    }

    .ag-graph-list-item-bars {
      display: flex;
      flex-direction: column;
      gap: 8px;
    }

    .ag-graph-bar-row {
      display: flex;
      align-items: center;
      gap: 10px;
    }

    .ag-graph-bar-caption {
      font-size: 11px;
      font-weight: 600;
      color: #6c757d;
      text-transform: uppercase;
      letter-spacing: 0.03em;
      flex: 0 0 72px;
    }

    .ag-graph-bar-track {
      flex: 1;
      min-width: 0;
      height: 10px;
      background: rgba(0, 0, 0, 0.08);
      border-radius: 5px;
      overflow: hidden;
    }

    .ag-graph-bar {
      height: 100%;
      border-radius: 5px;
      transition: width 0.5s ease-out;
    }

    .ag-graph-card {
      padding: 14px 18px;
      border-radius: 10px;
      text-align: center;
      font-weight: 600;
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    }

    .ag-graph-card-label {
      font-size: 0.7rem;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      opacity: 0.9;
    }

    .ag-graph-card-value {
      font-size: 1.4rem;
      margin-top: 4px;
    }

    .ag-graph-card.excel,
    .ag-graph-card.programa {
      background: rgba(0, 0, 0, 0.06);
      color: #374151;
    }

    .ag-graph-card.diff-pos {
      background: rgba(220, 53, 69, 0.12);
      color: #b71c1c;
    }

    .ag-graph-card.diff-neg {
      background: rgba(40, 167, 69, 0.12);
      color: #1e7e34;
    }

    .analise-global-graph-footer {
      margin-top: 24px;
      text-align: center;
    }

    .analise-global-graph-btn-close {
      padding: 10px 28px;
      font-size: 14px;
      font-weight: 600;
      border-radius: 10px;
      cursor: pointer;
    }

    body.dark-theme .analise-global-graph-content {
      background: #212736;
      color: #e0e0e0;
      border-color: #363d4d;
    }

    body.dark-theme .analise-global-graph-header {
      border-bottom-color: #2e3444;
    }

    body.dark-theme .analise-global-graph-header h2 {
      color: #e0e0e0;
    }

    body.dark-theme .analise-global-graph-subtitle {
      color: #aaa;
    }

    body.dark-theme .analise-global-graph-close {
      color: #e0e0e0;
    }

    body.dark-theme .ag-graph-legend-label,
    body.dark-theme .ag-graph-section-label,
    body.dark-theme .ag-graph-summary-label {
      color: #aaa;
    }

    body.dark-theme .ag-graph-legend-chip {
      background: rgba(255, 255, 255, 0.1);
      color: #e0e0e0;
    }

    body.dark-theme .ag-graph-list-item {
      background: rgba(255, 255, 255, 0.06);
      border-color: rgba(255, 255, 255, 0.1);
    }

    body.dark-theme .ag-graph-list-item-code {
      color: #e0e0e0;
    }

    body.dark-theme .ag-graph-bar-caption {
      color: #aaa;
    }

    body.dark-theme .ag-graph-row-card.programa {
      background: rgba(255, 255, 255, 0.08);
      color: #e0e0e0;
    }

    body.dark-theme .ag-graph-card.excel,
    body.dark-theme .ag-graph-card.programa {
      background: rgba(255, 255, 255, 0.08);
      color: #e0e0e0;
    }

    .model-selector-list {
      max-height: 400px;
      overflow-y: auto;
    }

    /* Virtual list: stable row height improves scroll sync with JS windowing */
    .model-selector-list--virtual .model-selector-item {
      min-height: 96px;
      box-sizing: border-box;
    }

    .model-selector-virtual-phantom {
      contain: layout style;
    }

    .model-selector-item {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 10px 12px;
      border-bottom: 1px solid rgba(0, 0, 0, 0.08);
      cursor: pointer;
      transition: background 0.15s ease;
    }

    .model-selector-item:last-child {
      border-bottom: none;
    }

    .model-selector-item:hover {
      background: rgba(0, 0, 0, 0.04);
    }

    .model-selector-item input[type="checkbox"] {
      margin: 0;
      width: 18px;
      height: 18px;
      cursor: pointer;
      accent-color: #2563eb;
      flex-shrink: 0;
    }

    .model-selector-item-main {
      flex: 1;
      min-width: 0;
    }

    .model-selector-item-name {
      margin-bottom: 4px;
      font-weight: 600;
      color: #1d1d1f;
      word-break: break-word;
    }

    .model-selector-item-meta {
      margin-bottom: 2px;
      font-size: 11px;
      color: #666;
      word-break: break-word;
    }

    .model-selector-item-urn {
      font-size: 10px;
      color: #999;
      font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
      word-break: break-all;
    }

    .model-selector-item-side {
      display: flex;
      flex-direction: column;
      align-items: flex-end;
      gap: 8px;
      flex-shrink: 0;
      min-width: 168px;
    }

    .model-selector-delete-btn {
      flex: 0 0 auto;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 34px;
      height: 34px;
      margin: 0;
      padding: 0;
      border-radius: 10px;
      border: 1px solid rgba(248, 113, 113, 0.35);
      background: rgba(239, 68, 68, 0.12);
      color: #f87171;
      cursor: pointer;
      transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    }

    .model-selector-delete-btn:hover {
      background: rgba(239, 68, 68, 0.22);
      border-color: rgba(248, 113, 113, 0.55);
      color: #fecaca;
    }

    .model-selector-delete-btn:focus-visible {
      outline: none;
      box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.35);
    }

    .model-selector-delete-btn svg {
      width: 16px;
      height: 16px;
      display: block;
    }

    body:not(.dark-theme) .model-selector-delete-btn {
      background: rgba(239, 68, 68, 0.08);
      border-color: rgba(220, 38, 38, 0.28);
      color: #dc2626;
    }

    body:not(.dark-theme) .model-selector-delete-btn:hover {
      background: rgba(239, 68, 68, 0.14);
      color: #b91c1c;
    }

    .model-selector-side-field {
      display: flex;
      align-items: center;
      gap: 6px;
      white-space: nowrap;
    }

    .model-selector-placement-select {
      font-size: 11px;
      max-width: 160px;
      padding: 2px 4px;
      border-radius: 6px;
      border: 1px solid #d0d0d5;
      background: #fff;
      color: #333;
    }

    .model-selector-aux-label {
      font-size: 11px;
      color: #666;
    }

    .admin-content-card {
      padding: 16px;
    }

    .admin-card-title {
      margin: 0 0 12px 0;
      font-size: 13px;
      font-weight: 600;
      color: #1d1d1f;
    }

    .admin-info-list {
      display: grid;
      gap: 10px;
    }

    .admin-info-row {
      display: flex;
      justify-content: space-between;
      gap: 16px;
      padding: 10px 12px;
      border-radius: 10px;
      background: rgba(0, 0, 0, 0.03);
      border: 1px solid rgba(0, 0, 0, 0.06);
      flex-wrap: wrap;
    }

    .admin-info-label {
      font-size: 12px;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.04em;
      color: #666;
    }

    .admin-info-value {
      font-size: 13px;
      color: #1d1d1f;
      word-break: break-word;
      text-align: right;
    }

    .excel-comparison-actions {
      margin-top: 15px;
      text-align: center;
    }

    .excel-comparison-cell-strong {
      font-weight: 600;
    }

    .excel-comparison-cell-right {
      text-align: right;
    }

    .excel-comparison-cell-center {
      text-align: center;
    }

    .ag-graph-bar-excel {
      background: #2563eb;
    }

    .ag-graph-bar-program-low {
      background: #2e7d32;
    }

    .ag-graph-bar-program-mid {
      background: #ef6c00;
    }

    .ag-graph-bar-program-high {
      background: #c62828;
    }

    .ag-graph-legend-swatch {
      width: 12px;
      height: 12px;
      border-radius: 3px;
      display: inline-block;
      flex-shrink: 0;
    }

    body.dark-theme .model-selector-item {
      border-bottom-color: rgba(255, 255, 255, 0.08);
    }

    body.dark-theme .model-selector-item:hover {
      background: rgba(255, 255, 255, 0.08);
    }

    body.dark-theme .model-selector-item-name,
    body.dark-theme .admin-card-title,
    body.dark-theme .admin-info-value {
      color: #e0e0e0;
    }

    body.dark-theme .model-selector-item-meta,
    body.dark-theme .model-selector-item-urn,
    body.dark-theme .model-selector-aux-label,
    body.dark-theme .admin-info-label {
      color: #b0b0b0;
    }

    body.dark-theme .admin-content-card,
    body.dark-theme .admin-info-row {
      background: rgba(255, 255, 255, 0.04);
      border-color: rgba(255, 255, 255, 0.08);
    }

    body.dark-theme .ui-button-primary,
    body.dark-theme .admin-action-btn,
    body.dark-theme .admin-btn-primary,
    body.dark-theme #modelSelectorSave,
    body.dark-theme .excel-comparison-btn-close,
    body.dark-theme .analise-global-choice-btn-primary,
    body.dark-theme .analise-global-graph-btn-close,
    body.dark-theme .file-upload-btn,
    body.dark-theme .login-btn {
      background: rgba(106, 161, 255, 0.2);
      border-color: rgba(106, 161, 255, 0.12);
      color: #6aa1ff;
    }

    body.dark-theme .ui-button-primary:hover,
    body.dark-theme .admin-action-btn:hover,
    body.dark-theme .admin-btn-primary:hover,
    body.dark-theme #modelSelectorSave:hover,
    body.dark-theme .excel-comparison-btn-close:hover,
    body.dark-theme .analise-global-choice-btn-primary:hover,
    body.dark-theme .analise-global-graph-btn-close:hover,
    body.dark-theme .file-upload-btn:hover,
    body.dark-theme .login-btn:hover {
      background: rgba(106, 161, 255, 0.26);
      border-color: rgba(106, 161, 255, 0.18);
    }

    body.dark-theme .ui-button-secondary,
    body.dark-theme .modal-secondary-btn,
    body.dark-theme #modelSelectorCancel,
    body.dark-theme .admin-btn-secondary,
    body.dark-theme .theme-toggle-btn,
    body.dark-theme #tab3 .file-input-label,
    body.dark-theme .admin-btn-small {
      background: rgba(255, 255, 255, 0.06);
      border-color: rgba(255, 255, 255, 0.08);
      color: #e0e0e0;
    }

    body.dark-theme .ui-button-secondary:hover,
    body.dark-theme .modal-secondary-btn:hover,
    body.dark-theme #modelSelectorCancel:hover,
    body.dark-theme .admin-btn-secondary:hover,
    body.dark-theme .theme-toggle-btn:hover,
    body.dark-theme #tab3 .file-input-label:hover,
    body.dark-theme .admin-btn-small:hover {
      background: rgba(255, 255, 255, 0.1);
      border-color: rgba(255, 255, 255, 0.12);
    }

    body.dark-theme .ui-button-danger,
    body.dark-theme #modelSelectorDelete,
    body.dark-theme .admin-btn-delete {
      background: rgba(255, 107, 107, 0.16);
      border-color: rgba(255, 107, 107, 0.14);
      color: #ff8e8e;
    }

    body.dark-theme .ui-button-danger:hover,
    body.dark-theme #modelSelectorDelete:hover,
    body.dark-theme .admin-btn-delete:hover {
      background: rgba(255, 107, 107, 0.22);
      border-color: rgba(255, 107, 107, 0.18);
    }

    body.dark-theme .ui-input-field,
    body.dark-theme .dropdown-select,
    body.dark-theme .language-select,
    body.dark-theme .viewer-setting-input,
    body.dark-theme .admin-user-edit-field input,
    body.dark-theme .admin-user-edit-field select,
    body.dark-theme #tab3 select,
    body.dark-theme .projectElementsSelect,
    body.dark-theme .admin-form-input,
    body.dark-theme .admin-form-select {
      background: rgba(255, 255, 255, 0.06);
      border-color: rgba(255, 255, 255, 0.08);
      color: #e0e0e0;
    }

    body.dark-theme .ui-input-field:hover,
    body.dark-theme .dropdown-select:hover,
    body.dark-theme .language-select:hover,
    body.dark-theme .viewer-setting-input:hover,
    body.dark-theme .admin-user-edit-field input:hover,
    body.dark-theme .admin-user-edit-field select:hover,
    body.dark-theme #tab3 select:hover,
    body.dark-theme .projectElementsSelect:hover {
      background: rgba(255, 255, 255, 0.1);
    }

    body.dark-theme .ui-input-field:focus,
    body.dark-theme .dropdown-select:focus,
    body.dark-theme .language-select:focus,
    body.dark-theme .viewer-setting-input:focus,
    body.dark-theme .admin-user-edit-field input:focus,
    body.dark-theme .admin-user-edit-field select:focus,
    body.dark-theme #tab3 select:focus,
    body.dark-theme .projectElementsSelect:focus {
      background: rgba(255, 255, 255, 0.1);
      border-color: rgba(106, 161, 255, 0.16);
      box-shadow: 0 0 0 2px rgba(106, 161, 255, 0.14);
    }

    /* Model ready notification popup — alinhado ao chrome Início / confirm-dialog */
    .model-ready-popup-overlay {
      position: fixed;
      inset: 0;
      z-index: 10000;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 16px;
      background: rgba(0, 0, 0, 0.45);
      backdrop-filter: saturate(120%) blur(14px);
      -webkit-backdrop-filter: saturate(120%) blur(14px);
      opacity: 0;
      visibility: hidden;
      pointer-events: none;
      transition: opacity 0.22s ease, visibility 0.22s ease;
    }

    .model-ready-popup-overlay[hidden] {
      display: none !important;
    }

    .model-ready-popup-overlay.show {
      opacity: 1;
      visibility: visible;
      pointer-events: auto;
    }

    .model-ready-popup {
      width: min(440px, calc(100vw - 32px));
      padding: 22px 22px 18px;
      border-radius: var(--radius-xl, 16px);
      border: 1px solid rgba(91, 156, 255, 0.28);
      background:
        linear-gradient(165deg, rgba(91, 156, 255, 0.16), transparent 52%),
        var(--ui-chrome-surface, rgba(255, 255, 255, 0.92));
      box-shadow:
        var(--ui-chrome-shadow, 0 12px 40px rgba(0, 0, 0, 0.18)),
        0 0 0 1px rgba(147, 197, 253, 0.08) inset;
      backdrop-filter: var(--ui-backdrop-filter, saturate(180%) blur(20px));
      -webkit-backdrop-filter: var(--ui-backdrop-filter, saturate(180%) blur(20px));
      transform: translateY(10px) scale(0.98);
      opacity: 0;
      transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.24s ease;
    }

    .model-ready-popup-overlay.show .model-ready-popup {
      transform: translateY(0) scale(1);
      opacity: 1;
    }

    .model-ready-popup-header {
      display: flex;
      align-items: flex-start;
      gap: 14px;
      margin-bottom: 14px;
    }

    .model-ready-popup-icon {
      flex-shrink: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      width: 44px;
      height: 44px;
      border-radius: 12px;
      border: 1px solid rgba(96, 165, 250, 0.45);
      background:
        linear-gradient(180deg, rgba(59, 130, 246, 0.28), rgba(59, 130, 246, 0.08)),
        rgba(15, 23, 42, 0.35);
      box-shadow: 0 0 16px rgba(96, 165, 250, 0.25);
      color: #93c5fd;
    }

    .model-ready-popup-icon svg {
      width: 26px;
      height: 26px;
      stroke-width: 2;
    }

    .model-ready-popup-title {
      margin: 0;
      flex: 1;
      font-size: 17px;
      font-weight: 700;
      line-height: 1.35;
      letter-spacing: var(--tracking-tight, -0.02em);
      color: var(--ui-text-primary, #1d1d1f);
    }

    body.dark-theme .model-ready-popup-title {
      color: #bfdbfe;
    }

    .model-ready-popup-file {
      margin: 0 0 12px;
      padding: 10px 12px;
      border-radius: 10px;
      font-size: 13px;
      font-weight: 600;
      line-height: 1.35;
      color: #dbeafe;
      background: rgba(37, 99, 235, 0.14);
      border: 1px solid rgba(96, 165, 250, 0.22);
      word-break: break-word;
    }

    .model-ready-popup-file[hidden] {
      display: none !important;
    }

    body:not(.dark-theme) .model-ready-popup-file {
      color: #1e3a8a;
      background: rgba(37, 99, 235, 0.08);
    }

    .model-ready-popup-message {
      margin: 0 0 18px;
      font-size: 14px;
      line-height: 1.55;
      color: var(--ui-text-secondary, #4b5563);
    }

    body.dark-theme .model-ready-popup-message {
      color: rgba(226, 232, 240, 0.88);
    }

    body.dark-theme .model-ready-popup {
      border-color: rgba(91, 156, 255, 0.26);
      background:
        linear-gradient(160deg, rgba(91, 156, 255, 0.12), transparent 55%),
        rgba(18, 26, 38, 0.94);
    }

    .model-ready-popup-actions {
      display: flex;
      justify-content: flex-end;
      gap: 8px;
    }

    .model-ready-popup-btn {
      min-width: 88px;
      padding: 10px 18px;
      font-size: 13px;
      font-weight: 600;
      font-family: var(--font-ui, inherit);
      border-radius: 10px;
      border: 1px solid transparent;
      cursor: pointer;
      transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    }

    .model-ready-popup-btn-ok {
      background: linear-gradient(180deg, #3b82f6, #2563eb);
      color: #fff;
      border-color: rgba(147, 197, 253, 0.35);
      box-shadow: 0 1px 0 rgba(255, 255, 255, 0.12) inset, 0 4px 14px rgba(37, 99, 235, 0.35);
    }

    .model-ready-popup-btn-ok:hover {
      background: linear-gradient(180deg, #60a5fa, #3b82f6);
    }

    .model-ready-popup-btn-ok:focus-visible {
      outline: none;
      box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.45);
    }

    /* Toast notification — bottom-right stack (same for login + viewer saves) */
    #toastContainer {
      position: fixed;
      bottom: 24px;
      right: 24px;
      left: auto;
      /* Above every modal/backdrop (settings/admin 13000, edit + confirm dialogs 14000) so toasts are never hidden */
      z-index: 15000;
      display: flex;
      flex-direction: column;
      align-items: flex-end;
      gap: 8px;
      pointer-events: none;
      max-width: min(420px, calc(100vw - 48px));
    }

    #toastContainer .toast {
      max-width: 100%;
    }

    .toast {
      padding: 12px 20px;
      border-radius: 10px;
      font-size: 14px;
      font-weight: 500;
      box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
      opacity: 0;
      transform: translateY(8px);
      transition: opacity var(--motion-smooth-medium), transform var(--motion-smooth-medium);
      pointer-events: auto;
      max-width: min(420px, calc(100vw - 48px));
      display: inline-flex;
      align-items: center;
      gap: 10px;
    }

    .toast.show {
      opacity: 1;
      transform: translateY(0);
    }

    .toast.toast-success {
      background: #22c55e;
      color: #fff;
    }

    .toast.toast-error {
      background: #dc2626;
      color: #fff;
    }

    .toast.toast-loading {
      background: #0d0f14;
      color: #f3f5f7;
      border: 1px solid rgba(255, 255, 255, 0.12);
      gap: 12px;
    }

    .toast.toast-info {
      background: #64748b;
      color: #fff;
    }

    .toast.toast-warning {
      background: #d97706;
      color: #fff;
    }

    .toast-spinner,
    .toast .pg-loader-bar {
      display: inline-block;
      width: 88px;
      height: 3px;
      border: 0;
      border-radius: 999px;
      background: rgba(255, 255, 255, 0.28);
      overflow: hidden;
      vertical-align: middle;
      flex: 0 0 auto;
      position: relative;
      box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.12),
        0 0 10px color-mix(in srgb, var(--ui-accent) 45%, transparent);
      animation: none;
    }
    .toast-spinner::before,
    .toast .pg-loader-bar::before {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      height: 100%;
      width: 45%;
      border-radius: inherit;
      background: linear-gradient(
        90deg,
        transparent,
        var(--ui-accent) 18%,
        #ffffff 50%,
        var(--ui-accent) 82%,
        transparent
      );
      animation: auth-bar-slide 1.2s cubic-bezier(0.45, 0, 0.35, 1) infinite;
    }
    @keyframes toast-spin {
      to { transform: rotate(360deg); }
    }

    body.dark-theme .toast.toast-success {
      background: #16a34a;
      color: #f0fdf4;
    }

    body.dark-theme .toast.toast-error {
      background: #b91c1c;
      color: #fef2f2;
    }

    body.dark-theme .toast.toast-loading {
      background: #0d0f14;
      color: #f3f5f7;
      border-color: rgba(255, 255, 255, 0.14);
    }

    body.dark-theme .toast.toast-info {
      background: #475569;
      color: #f8fafc;
    }

    body.dark-theme .toast.toast-warning {
      background: #b45309;
      color: #fffbeb;
    }

    .confirm-dialog-backdrop {
      position: fixed;
      inset: 0;
      z-index: 14000;
      display: none;
      align-items: center;
      justify-content: center;
      padding: 16px;
      background: rgba(0, 0, 0, 0.5);
      backdrop-filter: saturate(120%) blur(14px);
      -webkit-backdrop-filter: saturate(120%) blur(14px);
      opacity: 0;
      transition: opacity 0.22s ease;
      pointer-events: auto;
    }

    .confirm-dialog-backdrop.show {
      display: flex;
      opacity: 1;
    }

    .confirm-dialog-backdrop[hidden] {
      display: none !important;
    }

    .confirm-dialog {
      position: relative;
      width: min(440px, calc(100vw - 32px));
      padding: 20px 20px 16px;
      border-radius: var(--radius-xl, 16px);
      border: 1px solid rgba(91, 156, 255, 0.28);
      background:
        linear-gradient(165deg, rgba(91, 156, 255, 0.16), transparent 52%),
        var(--ui-chrome-surface, rgba(255, 255, 255, 0.96));
      box-shadow:
        var(--ui-chrome-shadow, 0 12px 40px rgba(0, 0, 0, 0.18)),
        0 0 0 1px rgba(147, 197, 253, 0.08) inset;
      backdrop-filter: var(--ui-backdrop-filter, saturate(180%) blur(20px));
      -webkit-backdrop-filter: var(--ui-backdrop-filter, saturate(180%) blur(20px));
      transform: translateY(10px) scale(0.98);
      opacity: 0;
      transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.24s ease;
      font-family: var(--font-ui, inherit);
      color: var(--ui-text-primary, #1d1d1f);
      box-sizing: border-box;
    }

    .confirm-dialog-backdrop.show .confirm-dialog {
      transform: translateY(0) scale(1);
      opacity: 1;
    }

    .confirm-dialog-top {
      display: flex;
      align-items: flex-start;
      gap: 10px;
      margin: 0 0 16px;
    }

    .confirm-dialog-btn-close {
      flex: 0 0 auto;
      display: flex;
      align-items: center;
      justify-content: center;
      width: 34px;
      height: 34px;
      margin: -4px -4px 0 0;
      padding: 0;
      border: 1px solid transparent;
      border-radius: 10px;
      background: transparent;
      color: #6b7280;
      font-size: 22px;
      line-height: 1;
      cursor: pointer;
      transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    }

    .confirm-dialog-btn-close:hover {
      background: rgba(0, 0, 0, 0.06);
      border-color: rgba(0, 0, 0, 0.08);
      color: #1d1d1f;
    }

    .confirm-dialog-btn-close:focus-visible {
      outline: none;
      box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.35);
    }

    .confirm-dialog-body {
      display: flex;
      flex-direction: row;
      align-items: flex-start;
      gap: 14px;
      flex: 1 1 auto;
      min-width: 0;
    }

    .confirm-dialog-icon {
      flex: 0 0 44px;
      width: 44px;
      height: 44px;
      max-width: 44px;
      max-height: 44px;
      overflow: hidden;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      border-radius: 12px;
      border: 1px solid rgba(96, 165, 250, 0.45);
      background:
        linear-gradient(180deg, rgba(59, 130, 246, 0.28), rgba(59, 130, 246, 0.08)),
        rgba(15, 23, 42, 0.08);
      box-shadow: 0 0 16px rgba(96, 165, 250, 0.2);
      color: #2563eb;
      box-sizing: border-box;
    }

    .confirm-dialog-icon svg {
      width: 22px !important;
      height: 22px !important;
      max-width: 22px;
      max-height: 22px;
      display: block;
      flex-shrink: 0;
    }

    .confirm-dialog-copy {
      min-width: 0;
      flex: 1 1 auto;
      padding-top: 2px;
    }

    .confirm-dialog-title {
      margin: 0 0 6px;
      font-size: 17px;
      font-weight: 700;
      line-height: 1.35;
      letter-spacing: var(--tracking-tight, -0.02em);
      color: var(--ui-text-primary, #1d1d1f);
    }

    .confirm-dialog-title[hidden] {
      display: none !important;
    }

    .confirm-dialog-message {
      margin: 0;
      font-size: 14px;
      line-height: 1.55;
      color: var(--ui-text-secondary, #4b5563);
    }

    .confirm-dialog-actions {
      display: flex;
      justify-content: flex-end;
      gap: 8px;
    }

    .confirm-dialog-btn {
      min-width: 88px;
      padding: 10px 18px;
      border-radius: 10px;
      font-size: 13px;
      font-weight: 600;
      font-family: var(--font-ui, inherit);
      cursor: pointer;
      border: 1px solid transparent;
      transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
    }

    .confirm-dialog-btn-cancel {
      background: rgba(15, 23, 42, 0.06);
      color: var(--ui-text-primary, #1d1d1f);
      border-color: rgba(15, 23, 42, 0.12);
    }

    .confirm-dialog-btn-confirm {
      background: linear-gradient(180deg, #3b82f6, #2563eb);
      color: #fff;
      border-color: rgba(147, 197, 253, 0.35);
      box-shadow: 0 1px 0 rgba(255, 255, 255, 0.12) inset, 0 4px 14px rgba(37, 99, 235, 0.35);
    }

    .confirm-dialog-btn-cancel:hover {
      background: rgba(15, 23, 42, 0.1);
    }

    .confirm-dialog-btn-confirm:hover {
      background: linear-gradient(180deg, #60a5fa, #3b82f6);
    }

    .confirm-dialog-btn:focus-visible {
      outline: none;
      box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.4);
    }

    .confirm-dialog.is-danger {
      border-color: rgba(248, 113, 113, 0.35);
      background:
        linear-gradient(165deg, rgba(248, 113, 113, 0.12), transparent 52%),
        var(--ui-chrome-surface, rgba(255, 255, 255, 0.96));
    }

    .confirm-dialog.is-danger .confirm-dialog-icon {
      border-color: rgba(248, 113, 113, 0.45);
      background:
        linear-gradient(180deg, rgba(239, 68, 68, 0.28), rgba(239, 68, 68, 0.08)),
        rgba(15, 23, 42, 0.08);
      color: #dc2626;
      box-shadow: 0 0 16px rgba(239, 68, 68, 0.2);
    }

    .confirm-dialog.is-danger .confirm-dialog-btn-confirm {
      background: linear-gradient(180deg, #f87171, #dc2626);
      border-color: rgba(252, 165, 165, 0.4);
      box-shadow: 0 1px 0 rgba(255, 255, 255, 0.12) inset, 0 4px 14px rgba(220, 38, 38, 0.35);
    }

    .confirm-dialog.is-danger .confirm-dialog-btn-confirm:hover {
      background: linear-gradient(180deg, #fca5a5, #ef4444);
    }

    body.dark-theme .confirm-dialog {
      border-color: rgba(91, 156, 255, 0.26);
      background:
        linear-gradient(160deg, rgba(91, 156, 255, 0.12), transparent 55%),
        rgba(18, 26, 38, 0.96);
      color: #e2e8f0;
    }

    body.dark-theme .confirm-dialog-btn-close {
      color: #94a3b8;
    }

    body.dark-theme .confirm-dialog-btn-close:hover {
      background: rgba(255, 255, 255, 0.08);
      border-color: rgba(255, 255, 255, 0.1);
      color: #f8fafc;
    }

    body.dark-theme .confirm-dialog-icon {
      background:
        linear-gradient(180deg, rgba(59, 130, 246, 0.28), rgba(59, 130, 246, 0.08)),
        rgba(15, 23, 42, 0.35);
      color: #93c5fd;
      box-shadow: 0 0 16px rgba(96, 165, 250, 0.25);
    }

    body.dark-theme .confirm-dialog-title {
      color: #bfdbfe;
    }

    body.dark-theme .confirm-dialog-message {
      color: rgba(226, 232, 240, 0.88);
    }

    body.dark-theme .confirm-dialog-btn-cancel {
      background: rgba(148, 163, 184, 0.12);
      color: #e2e8f0;
      border-color: rgba(148, 163, 184, 0.22);
    }

    body.dark-theme .confirm-dialog-btn-cancel:hover {
      background: rgba(148, 163, 184, 0.2);
    }

    body.dark-theme .confirm-dialog-btn-confirm {
      background: linear-gradient(180deg, #3b82f6, #2563eb);
      color: #fff;
    }

    body.dark-theme .confirm-dialog-btn-confirm:hover {
      background: linear-gradient(180deg, #60a5fa, #3b82f6);
    }

    body.dark-theme .confirm-dialog.is-danger {
      border-color: rgba(248, 113, 113, 0.32);
      background:
        linear-gradient(160deg, rgba(248, 113, 113, 0.12), transparent 55%),
        rgba(18, 26, 38, 0.96);
    }

    body.dark-theme .confirm-dialog.is-danger .confirm-dialog-icon {
      color: #fca5a5;
      background:
        linear-gradient(180deg, rgba(239, 68, 68, 0.28), rgba(239, 68, 68, 0.08)),
        rgba(15, 23, 42, 0.35);
    }

    body.dark-theme .confirm-dialog.is-danger .confirm-dialog-title {
      color: #fecaca;
    }

    /* Custom loader to replace Autodesk loader */
    .custom-loader {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: #0d0f14;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 22px;
      z-index: 1000;
      transition: opacity 0.3s ease;
    }

    .custom-loader.hidden {
      opacity: 0;
      pointer-events: none;
      display: none;
    }

    .custom-loader-logo {
      max-width: 200px;
      max-height: 200px;
      width: auto;
      height: auto;
      object-fit: contain;
      margin-bottom: 20px;
      animation: pulse 2s ease-in-out infinite;
    }

    @keyframes pulse {
      0%, 100% {
        opacity: 1;
        transform: scale(1);
      }
      50% {
        opacity: 0.7;
        transform: scale(0.95);
      }
    }

    .custom-loader-text {
      font-size: 15px;
      font-weight: 500;
      letter-spacing: 0.02em;
      color: rgba(255, 255, 255, 0.92);
      margin-top: 0;
    }

    /* Dark theme: black loading label on a light overlay (readable on viewer canvas). */
    body.dark-theme .custom-loader {
      background: #f5f5f7;
    }

    body.dark-theme .custom-loader-text {
      color: #000000;
    }

    body.dark-theme .custom-loader-bar,
    body.dark-theme .custom-loader .pg-loader-bar {
      background: rgba(15, 23, 42, 0.14);
      box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.06);
    }

    body.dark-theme .custom-loader-bar::before,
    body.dark-theme .custom-loader .pg-loader-bar::before {
      background: linear-gradient(
        90deg,
        transparent,
        var(--ui-accent) 22%,
        color-mix(in srgb, var(--ui-accent) 70%, #fff) 50%,
        var(--ui-accent) 78%,
        transparent
      );
    }

    /* Hide Autodesk default loader only, keep toolbar visible */
    .adsk-viewing-viewer .adsk-loading,
    .adsk-viewing-viewer .adsk-viewing-viewer-loading,
    .adsk-viewing-viewer .adsk-loading-container {
      display: none !important;
    }

    /* Split 3D pane: same built-in loader can still appear (separate viewer instance). */
    #forgeViewer3D .adsk-loading,
    #forgeViewer3D .adsk-viewing-viewer-loading,
    #forgeViewer3D .adsk-loading-container,
    #forgeViewer3D .adsk-viewing-viewer-loading-screen,
    #forgeViewer3D .progressbg,
    #forgeViewer3D .progressfg,
    #forgeViewer3D .forge-spinner,
    #forgeViewer3D .lmv-spinner {
      display: none !important;
      visibility: hidden !important;
      opacity: 0 !important;
      pointer-events: none !important;
    }

    /* Hide Explode tool (model exploder slider) from viewer toolbar */
    .adsk-viewing-viewer #toolbar-explodeTool {
      display: none !important;
    }
    /* Use only our custom #propsPanel; hide the viewer's built-in Properties toolbar button and panel */
    .adsk-viewing-viewer #toolbar-propertiesTool {
      display: none !important;
    }

    /* Split view: hide all built-in toolbar buttons; we use our own custom toolbar only */
    #forgeViewer3D #toolbar-bimWalkTool,
    #forgeViewer3D #toolbar-fullscreenTool,
    #forgeViewer3D #toolbar-modelStructureTool,
    #forgeViewer3D #toolbar-measurementSubmenuTool,
    #forgeViewer3D #toolbar-sectionTool,
    #forgeViewer3D #toolbar-settingsTool,
    #forgeViewer3D #toolbar-cameraSubmenuTool,
    #forgeViewer3D #toolbar-orbitTool,
    #forgeViewer3D #toolbar-orbitTools,
    #forgeViewer3D #toolbar-panTool,
    #forgeViewer3D #toolbar-zoomTool,
    #forgeViewer3D #toolbar-floorSelectorTool,
    #forgeViewer3D [id*="level"],
    #forgeViewer3D [id*="Level"] {
      display: none !important;
    }

    /* Original Close 3D button: hidden; close action is on toolbar button next to fullscreen */
    #forgeViewer3D .pg-close-3d-view-hidden,
    button.pg-close-3d-view-hidden {
      position: absolute !important;
      left: -9999px !important;
      width: 1px !important;
      height: 1px !important;
      overflow: hidden !important;
      clip: rect(0, 0, 0, 0) !important;
    }

    /* Split 3D toolbar: custom buttons (first person, fullscreen, measure, close) – same design as Document browser */
    #forgeViewer3D .pg-toolbar-custom-btn,
    #forgeViewer3D .pg-toolbar-custom-btn.adsk-button {
      background: rgba(255, 255, 255, 0.92) !important;
      border: 1px solid rgba(0, 0, 0, 0.14) !important;
      box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14) !important;
      font-size: 18px !important;
      cursor: pointer !important;
      color: #1d1d1f !important;
      padding: 4px 8px !important;
      line-height: 1 !important;
      border-radius: 8px !important;
      transition: background 0.2s ease, color 0.2s ease !important;
      min-width: 32px !important;
      height: 32px !important;
      display: inline-flex !important;
      align-items: center !important;
      justify-content: center !important;
    }
    #forgeViewer3D .pg-toolbar-custom-btn:hover,
    #forgeViewer3D .pg-toolbar-custom-btn.adsk-button:hover {
      background: rgba(255, 255, 255, 1) !important;
      border-color: rgba(0, 0, 0, 0.24) !important;
      color: #1d1d1f !important;
    }
    body.dark-theme #forgeViewer3D .pg-toolbar-custom-btn,
    body.dark-theme #forgeViewer3D .pg-toolbar-custom-btn.adsk-button {
      background: rgba(40, 44, 52, 0.9) !important;
      border-color: rgba(255, 255, 255, 0.22) !important;
      color: #f5f5f5 !important;
    }
    body.dark-theme #forgeViewer3D .pg-toolbar-custom-btn:hover,
    body.dark-theme #forgeViewer3D .pg-toolbar-custom-btn.adsk-button:hover {
      color: #ffffff !important;
      background: rgba(56, 62, 72, 0.96) !important;
    }
    #forgeViewer3D .pg-toolbar-custom-btn [data-lucide],
    #forgeViewer3D .pg-toolbar-custom-btn svg {
      width: 20px;
      height: 20px;
      stroke: currentColor;
    }

    /* Built-in property docking panel (exact id used by the viewer) */
    #ViewerPropertyPanel,
    .adsk-viewing-viewer #ViewerPropertyPanel {
      display: none !important;
      visibility: hidden !important;
    }

    /* View 3D (split) toolbar button: custom icon (split panels) so it's not confused with Zoom */
    .adsk-viewing-viewer .pg-view3d-split-icon {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 24px;
      height: 24px;
    }
    .adsk-viewing-viewer .pg-view3d-split-icon svg {
      width: 24px;
      height: 24px;
    }

    /* -------------------------------------------------------------------------
       Responsive: tablets & phones (≤900px) — layout + split 2D/3D + safe areas
       ------------------------------------------------------------------------- */
    .pg-sidebar-backdrop {
      display: none;
      position: fixed;
      inset: 0;
      z-index: 11999;
      background: rgba(0, 0, 0, 0.38);
      -webkit-tap-highlight-color: transparent;
    }

    body.pg-sidebar-drawer-open .pg-sidebar-backdrop {
      display: block;
    }

    /* Consistent frosted, dimmed backdrop for every foreground dialog/overlay.
       Declared after all modal definitions so it unifies the dim + blur across
       them (and overrides .admin-user-edit-backdrop's weaker blur(8px)).
       .project-elements-modal keeps its own matching values; .auth-overlay is
       intentionally excluded — it's an opaque loading takeover, not a window. */
    .settings-modal,
    .analise-global-modal,
    .analise-global-graph-modal,
    .model-ready-popup-overlay,
    .confirm-dialog-backdrop,
    .admin-user-edit-backdrop,
    .pg-sidebar-backdrop {
      background: rgba(0, 0, 0, 0.45);
      backdrop-filter: saturate(120%) blur(14px);
      -webkit-backdrop-filter: saturate(120%) blur(14px);
    }

    @media (max-width: 900px) {
      :root {
        --ui-sidebar-viewport-inset: max(8px, env(safe-area-inset-left, 0px));
      }

      html,
      body {
        overscroll-behavior: none;
      }

      body.user-authenticated .app-sidebar {
        left: max(8px, env(safe-area-inset-left, 0px));
        top: max(8px, env(safe-area-inset-top, 0px));
        bottom: max(8px, env(safe-area-inset-bottom, 0px));
        max-height: calc(var(--app-vh) - max(16px, env(safe-area-inset-top, 0px) + env(safe-area-inset-bottom, 0px)));
      }

      .app-main {
        padding-right: max(0px, env(safe-area-inset-right, 0px));
      }

      body.user-authenticated .tab1-content {
        left: var(--ui-content-inset-left-collapsed);
        right: max(8px, env(safe-area-inset-right, 0px));
        top: max(8px, env(safe-area-inset-top, 0px));
        bottom: max(8px, env(safe-area-inset-bottom, 0px));
        width: auto;
        height: auto;
        min-height: 0;
        max-height: none;
        transform: none;
      }

      .tab3-content {
        padding: 16px 12px 20px;
        margin: 12px;
      }

      body.user-authenticated #tab3 .tab3-content,
      body.user-authenticated.sidebar-collapsed #tab3 .tab3-content {
        margin-top: max(8px, env(safe-area-inset-top, 0px));
        margin-right: max(8px, env(safe-area-inset-right, 0px));
        margin-bottom: max(8px, env(safe-area-inset-bottom, 0px));
        margin-left: var(--ui-content-inset-left-collapsed);
        padding-left: 12px;
        padding-right: 12px;
      }

      body.user-authenticated #tab4 .tab3-content,
      body.user-authenticated #tab6 .tab3-content,
      body.user-authenticated #tab7 .tab3-content,
      body.user-authenticated #tab8 .tab3-content,
      body.user-authenticated #tab9 .tab3-content,
      body.user-authenticated #tab11 .tab3-content,
      body.user-authenticated.sidebar-collapsed #tab4 .tab3-content,
      body.user-authenticated.sidebar-collapsed #tab6 .tab3-content,
      body.user-authenticated.sidebar-collapsed #tab7 .tab3-content,
      body.user-authenticated.sidebar-collapsed #tab8 .tab3-content,
      body.user-authenticated.sidebar-collapsed #tab9 .tab3-content,
      body.user-authenticated.sidebar-collapsed #tab11 .tab3-content {
        margin-top: max(8px, env(safe-area-inset-top, 0px));
        margin-right: max(8px, env(safe-area-inset-right, 0px));
        margin-bottom: max(8px, env(safe-area-inset-bottom, 0px));
        margin-left: var(--ui-content-inset-left-collapsed);
        padding-left: 12px;
        padding-right: 12px;
      }

      #tab3Content {
        padding-right: 0;
      }

      /* Bottom sheet: leave most of the canvas free so orbit/pan still work on phones. */
      #viewerRightPanels {
        width: min(100%, calc(100vw - 16px));
        left: max(8px, env(safe-area-inset-left, 0px));
        right: max(8px, env(safe-area-inset-right, 0px));
        top: auto;
        bottom: max(52px, calc(8px + env(safe-area-inset-bottom, 0px)));
        max-height: min(42vh, 340px);
        height: auto;
        min-height: 0;
        -webkit-overflow-scrolling: touch;
        align-items: stretch;
        gap: 8px;
      }

      #viewerRightPanels #propsPanel {
        flex: 1 1 auto;
        min-height: 0;
        max-height: min(36vh, 300px);
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        position: relative;
      }

      #viewerRightPanels #propsPanel.minimized {
        flex: 0 0 auto;
        max-height: none;
      }

      #floorplanPanel {
        flex: 0 0 auto;
        width: 100%;
        max-width: 100%;
        max-height: min(28vh, 200px);
        overflow: hidden;
      }

      #floorplanPanel.minimized {
        max-height: none;
      }

      /* Keep state legend clear of the bottom sheet + APS toolbar. */
      .viewer-state-legend {
        left: max(8px, env(safe-area-inset-left, 0px));
        right: auto;
        bottom: auto;
        top: max(8px, env(safe-area-inset-top, 0px));
        max-width: min(220px, calc(100vw - 24px));
      }

      .toast-container,
      #toastContainer {
        bottom: max(16px, env(safe-area-inset-bottom, 0px)) !important;
        right: max(12px, env(safe-area-inset-right, 0px)) !important;
      }

      #propsPanel .props-header,
      #propsPanel .props-multi-state-warning,
      #propsPanel .props-panel-tabs {
        flex-shrink: 0;
      }

      /*
        Panes wrap dynamic content; they must be flex items of #propsPanel so inner .props-content can use
        flex:1 + overflow scroll. (Otherwise flex on .props-content is ignored — parent was display:block.)
      */
      #propsPanel .props-panel-pane.active {
        display: flex;
        flex-direction: column;
        flex: 1 1 0%;
        min-height: 0;
        overflow: hidden;
      }

      #propsPanel #propsPanePropriedades > .props-panel-meta,
      #propsPanel #propsPanePropriedades > hr,
      #propsPanel #propsPanePropriedades > .props-panel-inline-tools,
      #propsPanel #propsPanePropriedades > .props-panel-footer-actions {
        flex-shrink: 0;
      }

      /* Execução / Financeira: scroll whole pane when content is taller than the stack */
      #propsPanel #propsPaneExecucao.active,
      #propsPanel #propsPaneFinanceira.active {
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior-y: contain;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y;
      }

      /*
        Mobile WebKit: flex basis 0% + min-height + scroll (not auto). No translateZ — it can widen compositor
        hit-testing and block taps on the viewer canvas on iOS.
      */
      #propsPanel #propsPanePropriedades.props-pane--multi.active {
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y;
      }

      #propsPanel #propsPanePropriedades .props-content:not(.props-content--multi),
      #propsPanel #propsPanePropriedades .props-content.props-content-scroll:not(.props-content--multi),
      #propsPanel #propsPanePropriedades .props-content.props-content-virtual {
        flex: 1 1 0%;
        min-height: 120px;
        display: flex;
        flex-direction: column;
        gap: 10px;
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior-y: contain;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y;
      }

      #propsPanel > .empty,
      #propsPanel .props-panel-pane.active > .empty {
        flex: 1 1 0%;
        min-height: 0;
        overflow-y: auto;
      }

      body.split-2d-3d #tab2.tab-content.active {
        display: flex;
        flex-direction: column;
        flex: 1;
        min-height: 0;
      }

      body.split-2d-3d #forgeViewer {
        position: relative !important;
        top: auto;
        left: auto;
        width: 100% !important;
        flex: var(--split-pct, 50) 1 0px;
        min-height: 200px;
        height: auto !important;
        overflow: hidden;
      }

      body.split-2d-3d #forgeViewer3D {
        position: relative !important;
        top: auto;
        left: auto !important;
        width: 100% !important;
        flex: calc(100 - var(--split-pct, 50)) 1 0px;
        min-height: 200px;
        height: auto !important;
        border-left: none;
        border-top: 2px solid #666;
      }

      body.split-2d-3d #splitResizer.split-resizer {
        position: relative !important;
        flex: 0 0 10px;
        width: 100% !important;
        height: 10px !important;
        min-height: 10px;
        cursor: row-resize;
        left: auto !important;
        transform: none !important;
        top: auto;
        z-index: 100;
      }

      body.user-authenticated #modelSelectorModal .project-elements-modal-content,
      body.user-authenticated #replaceModelModal .project-elements-modal-content,
      body.user-authenticated.sidebar-collapsed #modelSelectorModal .project-elements-modal-content,
      body.user-authenticated.sidebar-collapsed #replaceModelModal .project-elements-modal-content {
        left: 50%;
        transform: translateX(-50%);
        width: min(96vw, calc(100vw - 20px));
        max-width: min(96vw, calc(100vw - 20px));
        min-width: 0;
        top: max(24px, env(safe-area-inset-top, 0px));
      }

      body.user-authenticated .analise-global-modal,
      body.user-authenticated .analise-global-graph-modal,
      body.user-authenticated.sidebar-collapsed .analise-global-modal,
      body.user-authenticated.sidebar-collapsed .analise-global-graph-modal {
        padding-left: max(12px, env(safe-area-inset-left, 0px));
        padding-right: max(12px, env(safe-area-inset-right, 0px));
      }

      .settings-modal {
        padding: max(12px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px))
          max(12px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
      }

      .settings-modal-content.admin-modal-content {
        width: min(96vw, calc(100vw - 16px));
        max-width: min(96vw, calc(100vw - 16px));
      }

      .app-sidebar .sidebar-toggle,
      .app-sidebar .tab-button,
      .sidebar-actions button {
        min-height: 44px;
        box-sizing: border-box;
      }
    }

    @media (max-width: 480px) {
      .tab3-content {
        margin: 8px;
        padding: 12px 10px 16px;
      }
    }

    /* ============================================================
       Instruções (user guide) — Tab 9
       ============================================================ */

    /* Scrollable shell, mirroring tab4–tab8 (base .tab3-content is overflow:hidden). */
    #tab9.tab-content.active {
      overflow: hidden;
      display: flex;
      flex-direction: column;
      min-height: 0;
    }
    body.user-authenticated #tab9 .tab3-content,
    body.user-authenticated.sidebar-collapsed #tab9 .tab3-content {
      margin-top: var(--ui-sidebar-viewport-inset);
      margin-right: var(--ui-sidebar-viewport-inset);
      margin-bottom: var(--ui-sidebar-viewport-inset);
      padding-left: 24px;
      flex: 1 1 0;
      min-height: 0;
      max-height: 100%;
      overflow: hidden;
    }
    body.user-authenticated #tab9 .tab3-content {
      margin-left: var(--ui-content-inset-left-expanded);
    }
    body.user-authenticated.sidebar-collapsed #tab9 .tab3-content {
      margin-left: var(--ui-content-inset-left-collapsed);
    }

    .guide {
      max-width: 980px;
      margin: 0 auto;
      color: var(--ui-text-primary);
      font-size: var(--text-body-size);
      line-height: 1.55;
    }
    .guide-hero {
      padding: 22px 24px;
      border-radius: var(--ui-chrome-radius);
      background:
        linear-gradient(120deg, rgba(91, 156, 255, 0.2), rgba(91, 156, 255, 0.04) 55%),
        var(--ui-chrome-surface);
      border: 1px solid rgba(91, 156, 255, 0.32);
      box-shadow: var(--ui-chrome-shadow);
      margin-bottom: 18px;
    }
    .guide-title { margin: 0 0 6px; font-size: 1.5rem; font-weight: 650; color: #e2e8f0; }
    .guide-subtitle { margin: 0 0 8px; color: #93c5fd; opacity: 1; }
    .guide-lede { margin: 0; opacity: 0.9; }

    .guide-lede,
    .guide-steps li,
    .guide-warn,
    .guide-card p,
    .guide-card li,
    .guide-glossary dd,
    .guide-faq li,
    .guide-flow-alt {
      text-align: justify;
      hyphens: auto;
    }

    .guide-toc {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      margin-bottom: 22px;
    }
    .guide-toc a {
      padding: 6px 12px;
      border-radius: 999px;
      background: rgba(91, 156, 255, 0.08);
      border: 1px solid rgba(91, 156, 255, 0.28);
      color: #dbeafe;
      text-decoration: none;
      font-size: var(--text-label-size);
      transition: background var(--motion-smooth-medium), border-color var(--motion-smooth-medium);
    }
    .guide-toc a:hover {
      background: rgba(91, 156, 255, 0.2);
      border-color: rgba(91, 156, 255, 0.55);
    }

    .guide-section { margin-bottom: 30px; scroll-margin-top: 16px; }
    .guide-section > h2 {
      font-size: 1.2rem;
      font-weight: 620;
      margin: 0 0 14px;
      padding-bottom: 8px;
      border-bottom: 1px solid rgba(91, 156, 255, 0.22);
      color: #bfdbfe;
    }
    .guide-section h3 { font-size: 1rem; font-weight: 600; margin: 0 0 8px; display: flex; align-items: center; gap: 8px; }
    .guide-section h3 svg { width: 17px; height: 17px; color: #5b9cff; }

    .guide-chip {
      font-size: 11px;
      font-weight: 600;
      padding: 2px 9px;
      border-radius: 999px;
      background: #5b9cff;
      color: #fff;
      vertical-align: middle;
    }
    .guide-chip-soft {
      background: rgba(91, 156, 255, 0.12);
      color: #bfdbfe;
      border: 1px solid rgba(91, 156, 255, 0.28);
    }

    .guide-steps { margin: 0; padding-left: 20px; }
    .guide-steps li { margin-bottom: 8px; }

    .guide-warn {
      margin: 14px 0 0;
      padding: 12px 14px;
      border-radius: 10px;
      border: 1px solid rgba(240, 180, 41, 0.3);
      border-left: 3px solid #f0b429;
      background: rgba(240, 180, 41, 0.08);
    }

    .guide-cards {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
      gap: 14px;
    }
    .guide-card {
      padding: 16px;
      border-radius: var(--ui-chrome-radius);
      background:
        linear-gradient(160deg, rgba(91, 156, 255, 0.1), transparent 55%),
        rgba(0, 0, 0, 0.16);
      border: 1px solid rgba(91, 156, 255, 0.24);
      box-shadow: var(--ui-panel-muted-shadow);
    }
    .guide-card p { margin: 0 0 8px; opacity: 0.9; }
    .guide-card ul { margin: 0; padding-left: 18px; }
    .guide-card li { margin-bottom: 5px; }

    .guide-flow { overflow-x: auto; padding: 6px 0 12px; }
    .guide-flow-track { display: flex; align-items: center; gap: 8px; min-width: max-content; }
    .guide-state {
      padding: 7px 14px;
      border-radius: 999px;
      font-weight: 600;
      font-size: var(--text-label-size);
      white-space: nowrap;
      color: #fff;
    }
    /* Match construction-highlight-colors.js / viewer-state-legend swatches */
    .guide-swatch-initial {
      background: rgb(148, 163, 184);
      color: #0f172a;
    }
    .guide-swatch-emObra {
      background: rgb(255, 217, 0);
      color: #1a1a1a;
    }
    .guide-swatch-awaiting {
      background: rgb(255, 140, 0);
      color: #1a1a1a;
    }
    .guide-swatch-confirmed {
      background: rgb(158, 82, 242);
      color: #fff;
    }
    .guide-swatch-payable {
      background: rgb(38, 115, 250);
      color: #fff;
    }
    .guide-swatch-paid {
      background: rgb(46, 199, 89);
      color: #0f172a;
    }
    .guide-state-exec { background: hsl(var(--exec-hue, 160) 60% 38%); }
    .guide-state-fin { background: hsl(var(--fin-hue, 43) 75% 44%); }
    .guide-state-warn { background: #c0392b; }
    .guide-arrow { opacity: 0.5; font-weight: 700; }
    .guide-flow-alt { margin: 10px 0 0; font-size: var(--text-label-size); opacity: 0.9; }
    .guide-h3 {
      margin: 18px 0 8px;
      font-size: var(--text-subtitle, 1.05rem);
      font-weight: 650;
    }
    .guide-dot {
      display: inline-block;
      width: 12px;
      height: 12px;
      border-radius: 3px;
      margin-right: 8px;
      vertical-align: -1px;
      box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
    }

    .guide-table {
      width: 100%;
      border-collapse: collapse;
      margin: 6px 0;
      font-size: var(--text-label-size);
    }
    .guide-table th, .guide-table td {
      text-align: left;
      padding: 9px 12px;
      border-bottom: 1px solid var(--ui-panel-muted-border);
      vertical-align: top;
    }
    .guide-table th { font-weight: 600; background: var(--ui-panel-muted-surface); }
    .guide-table tr:last-child td { border-bottom: none; }

    .guide-glossary { margin: 0; }
    .guide-glossary dt { font-weight: 600; margin-top: 12px; }
    .guide-glossary dt:first-child { margin-top: 0; }
    .guide-glossary dd { margin: 4px 0 0; opacity: 0.9; }

    .guide-faq { margin: 0; padding-left: 18px; }
    .guide-faq li { margin-bottom: 10px; }

    @media (max-width: 480px) {
      .guide-hero { padding: 16px; }
      .guide-title { font-size: 1.25rem; }
    }

    /* ============================================================
       Documentação — Tab 10
       ============================================================ */

    #tab10.tab-content.active {
      overflow: hidden;
      display: flex;
      flex-direction: column;
      min-height: 0;
    }
    body.user-authenticated #tab10 .tab3-content,
    body.user-authenticated.sidebar-collapsed #tab10 .tab3-content {
      margin-top: var(--ui-sidebar-viewport-inset);
      margin-right: var(--ui-sidebar-viewport-inset);
      margin-bottom: var(--ui-sidebar-viewport-inset);
      padding: 16px 24px 24px;
      flex: 1 1 0;
      min-height: 0;
      max-height: 100%;
      overflow: hidden;
    }
    body.user-authenticated #tab10 .tab3-content {
      margin-left: var(--ui-content-inset-left-expanded);
    }
    body.user-authenticated.sidebar-collapsed #tab10 .tab3-content {
      margin-left: var(--ui-content-inset-left-collapsed);
    }

    .doc-tab { max-width: 1100px; margin: 0 auto; }
    .doc-tab-header {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 16px;
      margin-bottom: 16px;
      padding: 16px 18px;
      border-radius: var(--ui-chrome-radius);
      border: 1px solid rgba(91, 156, 255, 0.3);
      background:
        linear-gradient(120deg, rgba(91, 156, 255, 0.18), rgba(91, 156, 255, 0.04) 55%),
        var(--ui-chrome-surface);
      box-shadow: var(--ui-chrome-shadow);
    }
    .doc-tab-title { margin: 0 0 4px; font-size: 1.35rem; font-weight: 650; color: #e2e8f0; }
    .doc-tab-sub { margin: 0; color: #93c5fd; opacity: 1; font-size: var(--text-label-size); }
    .doc-infra-banner {
      padding: 10px 14px;
      margin-bottom: 14px;
      border-radius: var(--ui-chrome-radius);
      background: rgba(220, 53, 69, 0.12);
      border: 1px solid rgba(220, 53, 69, 0.35);
      color: var(--ui-text-primary);
      font-size: var(--text-label-size);
    }
    .doc-filters,
    .doc-toolbar,
    .doc-folder-config,
    .doc-view-toggle {
      display: flex;
      flex-wrap: wrap;
      gap: 12px 16px;
      margin-bottom: 16px;
      align-items: flex-end;
      padding: 12px 14px;
      border-radius: var(--ui-chrome-radius);
      border: 1px solid rgba(91, 156, 255, 0.24);
      background:
        linear-gradient(105deg, rgba(91, 156, 255, 0.1), transparent 50%),
        rgba(0, 0, 0, 0.14);
    }
    .doc-view-toggle {
      align-items: center;
    }
    .doc-filters label {
      display: flex;
      flex-direction: column;
      gap: 4px;
      font-size: var(--text-label-size);
      min-width: 140px;
    }
    .doc-filters select,
    .doc-filters input[type="search"] {
      padding: 6px 10px;
      border-radius: 8px;
      border: 1px solid rgba(91, 156, 255, 0.28);
      background: rgba(15, 23, 42, 0.35);
      color: var(--ui-text-primary);
    }
    .doc-btn {
      padding: 8px 14px;
      border-radius: 8px;
      border: 1px solid rgba(91, 156, 255, 0.28);
      background: rgba(91, 156, 255, 0.08);
      color: #dbeafe;
      cursor: pointer;
      font-size: var(--text-label-size);
    }
    .doc-btn:hover {
      border-color: rgba(91, 156, 255, 0.55);
      background: rgba(91, 156, 255, 0.16);
    }
    .doc-btn-primary {
      background: linear-gradient(180deg, #2f6fed, #1d4ed8);
      border-color: transparent;
      color: #ffffff;
      box-shadow: 0 1px 3px rgba(37, 99, 235, 0.28);
    }
    .doc-btn-primary:hover {
      filter: brightness(1.06);
    }
    .doc-btn-danger { border-color: rgba(220, 53, 69, 0.5); color: #dc3545; }
    .doc-btn-sm { padding: 4px 10px; font-size: 12px; }
    .doc-group {
      margin-bottom: 12px;
      border: 1px solid rgba(91, 156, 255, 0.24);
      border-radius: var(--ui-chrome-radius);
      background:
        linear-gradient(180deg, rgba(91, 156, 255, 0.08), transparent 40%),
        rgba(0, 0, 0, 0.16);
    }
    .doc-group summary {
      padding: 10px 14px;
      cursor: pointer;
      font-weight: 600;
      color: #bfdbfe;
    }
    .doc-group-list { padding: 0 10px 10px; display: flex; flex-direction: column; gap: 8px; }
    .doc-row {
      display: flex;
      gap: 12px;
      justify-content: space-between;
      align-items: flex-start;
      padding: 10px 12px;
      border-radius: 8px;
      background: rgba(15, 23, 42, 0.35);
      border: 1px solid rgba(91, 156, 255, 0.18);
    }
    .doc-row:hover {
      border-color: rgba(91, 156, 255, 0.4);
      background: rgba(91, 156, 255, 0.08);
    }
    .doc-row-title { font-weight: 600; margin-bottom: 4px; }
    .doc-row-meta {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      font-size: var(--text-label-size);
      opacity: 0.85;
    }
    .doc-row-actions { display: flex; flex-wrap: wrap; gap: 6px; flex-shrink: 0; }
    .doc-chip {
      padding: 2px 8px;
      border-radius: 999px;
      font-size: 11px;
      font-weight: 600;
    }
    .doc-chip--pending { background: rgba(91, 156, 255, 0.2); color: #bfdbfe; }
    .doc-chip--approved { background: rgba(40, 167, 69, 0.15); color: #155724; }
    .doc-chip--rejected { background: rgba(220, 53, 69, 0.12); color: #721c24; }
    body.dark-theme .doc-chip--approved { color: #86efac; }
    body.dark-theme .doc-chip--rejected { color: #fca5a5; }
    .doc-reject-reason { margin: 6px 0 0; font-size: var(--text-label-size); opacity: 0.9; }
    .doc-empty { opacity: 0.7; padding: 12px 0; }
    .doc-empty--error {
      color: #ff3b3b !important;
      opacity: 1 !important;
      font-weight: 600;
    }
    body.dark-theme .doc-empty--error {
      color: #ff5252 !important;
    }
    .doc-admin-section {
      margin-top: 28px;
      padding-top: 20px;
      border-top: 1px solid rgba(91, 156, 255, 0.22);
    }
    .doc-hint { font-size: var(--text-label-size); opacity: 0.8; margin: 0 0 12px; }
    .doc-folder-list,
    .doc-overview-wrap {
      border-radius: var(--ui-chrome-radius);
      border: 1px solid rgba(91, 156, 255, 0.22);
      background:
        linear-gradient(180deg, rgba(91, 156, 255, 0.06), transparent 48px),
        rgba(0, 0, 0, 0.14);
      padding: 12px;
    }
    .doc-breadcrumb {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
      align-items: center;
    }
    .doc-crumb {
      background: transparent;
      border: 0;
      color: #93c5fd;
      cursor: pointer;
      font-size: var(--text-label-size);
      padding: 0;
    }
    .doc-crumb:hover { color: #e0f2fe; text-decoration: underline; }
    .doc-crumb-sep { opacity: 0.45; }
    .doc-row--up {
      opacity: 0.92;
      cursor: pointer;
    }
    .doc-row--up .doc-row-title { font-weight: 600; }
    .doc-contact-form {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      margin-bottom: 12px;
    }
    .doc-contact-form input {
      padding: 6px 10px;
      border-radius: 8px;
      border: 1px solid var(--ui-panel-muted-border);
      background: var(--ui-chrome-bg);
      color: var(--ui-text-primary);
      min-width: 140px;
    }
    .doc-contact-list { list-style: none; margin: 0; padding: 0; }
    .doc-contact-item {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 12px;
      padding: 8px 0;
      border-bottom: 1px solid var(--ui-panel-muted-border);
      font-size: var(--text-label-size);
    }
    .doc-modal {
      border: 1px solid var(--ui-panel-muted-border);
      border-radius: var(--ui-chrome-radius);
      padding: 20px;
      max-width: 480px;
      background: #ffffff;
      color: var(--ui-text-primary);
      box-shadow: var(--shadow-lg);
    }
    body.dark-theme .doc-modal {
      background: #212736;
    }
    .doc-modal::backdrop {
      background: rgba(0, 0, 0, 0.55);
    }
    .doc-modal form label {
      display: flex;
      flex-direction: column;
      gap: 4px;
      margin-bottom: 12px;
      font-size: var(--text-label-size);
    }
    .doc-modal input,
    .doc-modal select,
    .doc-modal textarea {
      padding: 8px 10px;
      border-radius: 8px;
      border: 1px solid var(--ui-panel-muted-border);
      background: var(--ui-panel-muted-surface);
      color: var(--ui-text-primary);
    }
    .doc-modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
    .doc-error { color: #dc3545; font-size: var(--text-label-size); margin: 8px 0 0; }
    .doc-approve-contacts { margin: 12px 0; display: flex; flex-direction: column; gap: 8px; }
    .doc-check { display: flex; align-items: center; gap: 8px; font-size: var(--text-label-size); }

    .doc-folder-tab { max-width: 1280px; }
    .doc-folder-config {
      display: flex;
      flex-wrap: wrap;
      gap: 12px;
      align-items: flex-end;
      margin-bottom: 16px;
      padding: 12px 14px;
      border: 1px solid rgba(91, 156, 255, 0.28);
      border-radius: var(--ui-chrome-radius);
      background:
        linear-gradient(105deg, rgba(91, 156, 255, 0.12), transparent 55%),
        rgba(0, 0, 0, 0.14);
    }
    .doc-folder-config label {
      display: flex;
      flex-direction: column;
      gap: 4px;
      font-size: var(--text-label-size);
      flex: 1 1 220px;
    }
    .doc-folder-config input {
      padding: 8px 10px;
      border-radius: 8px;
      border: 1px solid rgba(91, 156, 255, 0.28);
      background: rgba(15, 23, 42, 0.35);
      color: var(--ui-text-primary);
    }
    .doc-toolbar {
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
      gap: 12px;
      align-items: center;
      margin-bottom: 14px;
      padding: 12px 14px;
      border-radius: var(--ui-chrome-radius);
      border: 1px solid rgba(91, 156, 255, 0.24);
      background:
        linear-gradient(105deg, rgba(91, 156, 255, 0.1), transparent 50%),
        rgba(0, 0, 0, 0.14);
    }
    .doc-breadcrumb {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 4px;
      font-size: var(--text-label-size);
    }
    .doc-crumb {
      border: 0;
      background: transparent;
      color: #93c5fd;
      cursor: pointer;
      padding: 2px 4px;
    }
    .doc-crumb:hover { color: #e0f2fe; text-decoration: underline; }
    .doc-crumb-sep { opacity: 0.45; }
    .doc-toolbar-actions {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      align-items: flex-end;
    }
    .doc-filter-status {
      display: flex;
      flex-direction: column;
      gap: 4px;
      font-size: var(--text-label-size);
    }
    .doc-filter-status select {
      padding: 6px 10px;
      border-radius: 8px;
      border: 1px solid rgba(91, 156, 255, 0.28);
      background: rgba(15, 23, 42, 0.35);
      color: var(--ui-text-primary);
    }
    .doc-folder-list {
      display: flex;
      flex-direction: column;
      gap: 8px;
      border-radius: var(--ui-chrome-radius);
      border: 1px solid rgba(91, 156, 255, 0.22);
      background:
        linear-gradient(180deg, rgba(91, 156, 255, 0.06), transparent 48px),
        rgba(0, 0, 0, 0.14);
      padding: 12px;
    }
    .doc-row--dir { cursor: pointer; }
    .doc-row--dir:hover { border-color: rgba(91, 156, 255, 0.55); }
    .doc-row--pending { border-left: 4px solid #5b9cff; }
    .doc-row--approved { border-left: 4px solid #28a745; }
    .doc-row--rejected { border-left: 4px solid #dc3545; }
    .doc-chip--pending,
    .doc-chip-select.doc-chip--pending {
      background: rgba(91, 156, 255, 0.22);
      color: #bfdbfe;
    }
    .doc-chip--approved,
    .doc-chip-select.doc-chip--approved {
      background: rgba(40, 167, 69, 0.2);
      color: #86efac;
    }
    .doc-chip--rejected,
    .doc-chip-select.doc-chip--rejected {
      background: rgba(220, 53, 69, 0.18);
      color: #fca5a5;
    }
    .doc-chip-select {
      border: 0;
      border-radius: 999px;
      padding: 3px 8px;
      font-size: 12px;
      font-weight: 650;
      cursor: pointer;
    }
    .doc-history-list {
      list-style: none;
      margin: 0 0 12px;
      padding: 0;
      max-height: 320px;
      overflow: auto;
    }
    .doc-history-list li {
      display: flex;
      flex-direction: column;
      gap: 2px;
      padding: 8px 0;
      border-bottom: 1px solid var(--ui-panel-muted-border);
      font-size: var(--text-label-size);
    }
    .doc-preview-modal { max-width: min(920px, 96vw); width: 920px; }
    .doc-preview-body { min-height: 240px; margin: 8px 0 12px; }
    .doc-preview-img { max-width: 100%; max-height: 70vh; display: block; margin: 0 auto; }
    .doc-preview-frame { width: 100%; height: 70vh; border: 0; background: var(--ui-chrome-bg); }
    .doc-view-toggle {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      align-items: center;
      margin-bottom: 14px;
      padding: 12px 14px;
      border-radius: var(--ui-chrome-radius);
      border: 1px solid rgba(91, 156, 255, 0.24);
      background:
        linear-gradient(105deg, rgba(91, 156, 255, 0.1), transparent 50%),
        rgba(0, 0, 0, 0.14);
    }
    .doc-view-toggle #docNewFolderBtnStatus { margin-left: auto; }
    .doc-ov-scroll { overflow-x: auto; }
    .doc-ov-table {
      width: 100%;
      border-collapse: collapse;
      font-size: var(--text-label-size);
    }
    .doc-ov-table th,
    .doc-ov-table td {
      border: 1px solid rgba(91, 156, 255, 0.2);
      padding: 8px;
      vertical-align: middle;
      text-align: center;
    }
    .doc-ov-table thead th {
      background: rgba(91, 156, 255, 0.12);
      color: #bfdbfe;
      font-weight: 650;
    }
    .doc-ov-name { text-align: left !important; min-width: 220px; position: sticky; left: 0; background: var(--ui-chrome-bg); }
    .doc-ov-section td {
      text-align: left;
      font-weight: 700;
      letter-spacing: 0.02em;
      background: var(--ui-panel-muted-surface);
    }
    .doc-ov-folder,
    .doc-ov-cell {
      border: 0;
      background: transparent;
      color: inherit;
      cursor: pointer;
      width: 100%;
      text-align: inherit;
      padding: 4px 2px;
      border-radius: 6px;
    }
    .doc-ov-folder { text-align: left; font-weight: 650; color: var(--ui-accent); }
    .doc-ov-cell--empty { color: #888; }
    .doc-ov-cell--pending { background: rgba(91, 156, 255, 0.18); color: #bfdbfe; font-weight: 650; }
    .doc-ov-cell--approved { background: rgba(40, 167, 69, 0.16); color: #86efac; font-weight: 650; }
    .doc-ov-cell--rejected { background: rgba(220, 53, 69, 0.16); color: #fca5a5; font-weight: 650; }
    .doc-drawer-modal { max-width: min(960px, 96vw); width: 960px; }
    .doc-drawer-head {
      display: flex;
      justify-content: space-between;
      gap: 12px;
      align-items: flex-start;
    }
    .doc-drawer-head h3 { margin: 0 0 4px; }
    .doc-drawer-body { max-height: 70vh; overflow: auto; margin-top: 8px; }
    .doc-drawer-group { margin-bottom: 18px; }
    .doc-drawer-group h4 { margin: 0 0 8px; font-size: 0.95rem; }
    .doc-drawer-files { display: flex; flex-direction: column; gap: 8px; }

    /* ============================================================
       Light theme readability — dark text on light surfaces
       (Hardcoded pale blues/whites were designed for dark panels.)
       ============================================================ */
    body:not(.dark-theme) .guide-title,
    body:not(.dark-theme) .guide-section > h2,
    body:not(.dark-theme) .guide-h3,
    body:not(.dark-theme) .guide-section h3 {
      color: #0f172a;
    }
    body:not(.dark-theme) .guide-subtitle {
      color: #1d4ed8;
    }
    body:not(.dark-theme) .guide-lede,
    body:not(.dark-theme) .guide-steps,
    body:not(.dark-theme) .guide-card,
    body:not(.dark-theme) .guide-glossary,
    body:not(.dark-theme) .guide-faq,
    body:not(.dark-theme) .guide-table,
    body:not(.dark-theme) .guide-warn {
      color: #0f172a;
    }
    body:not(.dark-theme) .guide-toc a {
      color: #1e3a8a;
      background: rgba(37, 99, 235, 0.08);
      border-color: rgba(37, 99, 235, 0.22);
    }
    body:not(.dark-theme) .guide-toc a:hover {
      background: rgba(37, 99, 235, 0.14);
      border-color: rgba(37, 99, 235, 0.4);
      color: #1e40af;
    }
    body:not(.dark-theme) .guide-chip-soft {
      color: #1e40af;
      background: rgba(37, 99, 235, 0.1);
      border-color: rgba(37, 99, 235, 0.25);
    }
    body:not(.dark-theme) .guide-hero {
      background:
        linear-gradient(120deg, rgba(37, 99, 235, 0.1), rgba(37, 99, 235, 0.03) 55%),
        rgba(255, 255, 255, 0.92);
      border-color: rgba(37, 99, 235, 0.22);
    }
    body:not(.dark-theme) .guide-card {
      background:
        linear-gradient(160deg, rgba(37, 99, 235, 0.06), transparent 55%),
        rgba(255, 255, 255, 0.88);
      border-color: rgba(37, 99, 235, 0.18);
    }
    body:not(.dark-theme) .guide-arrow {
      color: #334155;
      opacity: 0.7;
    }

    /* Construction dashboards on light chrome */
    body:not(.dark-theme) .construction-dash--obra .construction-obra-views .chip.active,
    body:not(.dark-theme) .construction-dash--obra .construction-obra-views .chip[data-view="exec"].active,
    body:not(.dark-theme) .construction-dash--obra .construction-obra-views .chip[data-view="fin"].active {
      color: #1e40af;
      background: rgba(37, 99, 235, 0.12);
      border-color: rgba(37, 99, 235, 0.35);
    }
    body:not(.dark-theme) .construction-dash .dash-frame .frame-head,
    body:not(.dark-theme) .construction-dash .ui-content-frame .frame-head,
    body:not(.dark-theme) .construction-dash--audit .audit-frame .frame-head {
      color: #1e3a8a !important;
      background: rgba(37, 99, 235, 0.08);
    }
    body:not(.dark-theme) .construction-dash .kpi-row .kpi:nth-child(1) .value,
    body:not(.dark-theme) .construction-dash .kpi-row .kpi:nth-child(2) .value,
    body:not(.dark-theme) .construction-dash .kpi-row .kpi:nth-child(3) .value,
    body:not(.dark-theme) .construction-dash .kpi-row .kpi:nth-child(4) .value {
      color: #1d4ed8;
    }
    body:not(.dark-theme) .construction-dash--plan .construction-tab-title,
    body:not(.dark-theme) .construction-dash .construction-tab-title {
      color: #0f172a;
    }
    body:not(.dark-theme) .construction-dash .chip.active {
      color: #1e40af;
    }

    /* Documentation tab on light chrome */
    body:not(.dark-theme) .doc-tab-title {
      color: #0f172a;
    }
    body:not(.dark-theme) .doc-tab-sub,
    body:not(.dark-theme) .doc-side-title,
    body:not(.dark-theme) .doc-tree-label,
    body:not(.dark-theme) .doc-ov-table thead th {
      color: #1e3a8a;
    }
    body:not(.dark-theme) .doc-chip--pending,
    body:not(.dark-theme) .doc-ov-cell--pending {
      color: #1e40af;
      background: rgba(37, 99, 235, 0.12);
    }
    body:not(.dark-theme) .doc-ov-cell--approved {
      color: #166534;
      background: rgba(22, 163, 74, 0.12);
    }
    body:not(.dark-theme) .doc-ov-cell--rejected {
      color: #991b1b;
      background: rgba(220, 38, 38, 0.1);
    }

    /* Selection filter badges on light panel */
    body:not(.dark-theme) .pg-sel-filter__badge {
      color: #1e40af;
      background: rgba(37, 99, 235, 0.12);
      border-color: rgba(37, 99, 235, 0.35);
    }
    body:not(.dark-theme) .pg-sel-filter__badge--muted {
      color: #475569;
      background: rgba(100, 116, 139, 0.12);
      border-color: rgba(100, 116, 139, 0.28);
    }

    /* Guest login panel is always dark glass — keep light input text in light theme */
    body:not(.dark-theme):not(.user-authenticated) .login-panel .user-name-input,
    body:not(.dark-theme):not(.user-authenticated) .login-panel .user-password-input {
      background: rgba(255, 255, 255, 0.12);
      color: #f8fafc;
      box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12);
    }
    body:not(.dark-theme):not(.user-authenticated) .login-panel .user-name-input::placeholder,
    body:not(.dark-theme):not(.user-authenticated) .login-panel .user-password-input::placeholder {
      color: rgba(255, 255, 255, 0.45);
    }
    body:not(.dark-theme):not(.user-authenticated) .login-panel .input-with-icon .input-icon,
    body:not(.dark-theme):not(.user-authenticated) .login-panel .input-with-icon svg {
      color: rgba(255, 255, 255, 0.65);
    }

    /* Analysis / tables: ensure inherited primary text stays dark */
    body:not(.dark-theme) .tab3-content,
    body:not(.dark-theme) #tab9 .tab3-content,
    body:not(.dark-theme) #tab10 .tab3-content {
      color: #0f172a;
    }
    body:not(.dark-theme) .construction-props-table th,
    body:not(.dark-theme) .construction-props-table td,
    body:not(.dark-theme) .project-elements-details,
    body:not(.dark-theme) .project-elements-form-row label {
      color: #0f172a;
    }

    /* ============================================================
       Light theme — Início (Home) surfaces must stay light
       ============================================================ */
    body:not(.dark-theme).user-authenticated .tab1-content {
      background:
        linear-gradient(180deg, #f8fafc 0%, #eef2f7 45%, #e8eef6 100%) !important;
      border: 1px solid rgba(15, 23, 42, 0.1) !important;
      color: #0f172a;
      box-shadow: var(--ui-chrome-shadow);
    }

    body:not(.dark-theme) #homeWorkspace,
    body:not(.dark-theme) .home-workspace-main {
      color: #0f172a;
    }

    body:not(.dark-theme) .home-workspace-header {
      background:
        linear-gradient(120deg, rgba(37, 99, 235, 0.1), rgba(37, 99, 235, 0.03) 55%),
        rgba(255, 255, 255, 0.95);
      border-color: rgba(37, 99, 235, 0.22);
    }
    body:not(.dark-theme) .home-workspace-brand-name {
      color: #0f172a;
      text-shadow: none;
    }
    body:not(.dark-theme) .scope-mark--home,
    body:not(.dark-theme) .scope-mark--login {
      /* SVG strokes are light-on-dark; force a solid dark mark in light theme */
      filter: brightness(0) saturate(100%);
      opacity: 0.9;
    }
    body:not(.dark-theme) .home-workspace-subtitle {
      color: #1e40af;
    }

    body:not(.dark-theme) .home-inner-tabs {
      background: rgba(37, 99, 235, 0.06);
      border-color: rgba(37, 99, 235, 0.2);
    }
    body:not(.dark-theme) .home-inner-tab {
      color: #334155;
    }
    body:not(.dark-theme) .home-inner-tab:hover {
      color: #0f172a;
      background: rgba(15, 23, 42, 0.05);
    }
    body:not(.dark-theme) .home-inner-tab.active,
    body:not(.dark-theme) .home-inner-tab--secondary.active {
      color: #0f172a;
      font-weight: 700;
      background: rgba(37, 99, 235, 0.14);
      border-color: rgba(37, 99, 235, 0.32);
      box-shadow: none;
    }

    body:not(.dark-theme) .home-card,
    body:not(.dark-theme) .home-equipas-summary,
    body:not(.dark-theme) .home-project-need-select,
    body:not(.dark-theme) .home-project-current-banner,
    body:not(.dark-theme) .home-team-card,
    body:not(.dark-theme) .home-hub-stats,
    body:not(.dark-theme) #tab1 .home-project-context,
    body:not(.dark-theme) #homePanelProject .home-project-context {
      background:
        linear-gradient(160deg, rgba(37, 99, 235, 0.06), transparent 55%),
        rgba(255, 255, 255, 0.94) !important;
      border-color: rgba(37, 99, 235, 0.2) !important;
      color: #0f172a;
    }
    body:not(.dark-theme) .home-team-card:hover {
      background:
        linear-gradient(160deg, rgba(37, 99, 235, 0.1), transparent 55%),
        rgba(248, 250, 252, 0.98) !important;
      border-color: rgba(37, 99, 235, 0.35) !important;
    }
    body:not(.dark-theme) .home-card-title,
    body:not(.dark-theme) .home-team-card-head strong,
    body:not(.dark-theme) .home-field-label,
    body:not(.dark-theme) .home-inline-hint,
    body:not(.dark-theme) .home-project-hint,
    body:not(.dark-theme) .home-project-label,
    body:not(.dark-theme) .home-ready-text,
    body:not(.dark-theme) .home-equipas-summary-line,
    body:not(.dark-theme) #homeCompanyNameMeta,
    body:not(.dark-theme) #homeCompanyHint,
    body:not(.dark-theme) #homeTeamsHint {
      color: #0f172a;
    }
    body:not(.dark-theme) .home-field-label {
      color: #475569;
      opacity: 1;
    }
    body:not(.dark-theme) .home-project-label {
      color: #0f172a !important;
      opacity: 1;
    }
    body:not(.dark-theme) .home-text-input,
    body:not(.dark-theme) .home-project-select,
    body:not(.dark-theme) .home-project-create-input,
    body:not(.dark-theme) select.home-text-input {
      background: #fff;
      border-color: rgba(15, 23, 42, 0.14);
      color: #0f172a;
    }
    body:not(.dark-theme) .home-text-input::placeholder,
    body:not(.dark-theme) .home-project-create-input::placeholder {
      color: #94a3b8;
    }
    body:not(.dark-theme) .home-secondary-btn {
      background: rgba(37, 99, 235, 0.08);
      border-color: rgba(37, 99, 235, 0.28);
      color: #1e40af !important;
    }
    body:not(.dark-theme) .home-secondary-btn:hover {
      background: rgba(37, 99, 235, 0.14);
      border-color: rgba(37, 99, 235, 0.4);
      color: #1e3a8a !important;
    }
    body:not(.dark-theme) .home-secondary-btn.danger {
      color: #b91c1c !important;
    }
    body:not(.dark-theme) .home-hub-stat-value {
      color: #1d4ed8;
    }
    body:not(.dark-theme) .home-hub-stat-label {
      color: #475569;
    }
    body:not(.dark-theme) .home-hub-stat {
      border-right-color: rgba(37, 99, 235, 0.16);
    }
    body:not(.dark-theme) .home-equipas-summary-chips li {
      color: #1e40af;
      background: rgba(37, 99, 235, 0.1);
      border-color: rgba(37, 99, 235, 0.28);
    }
    body:not(.dark-theme) .home-team-count {
      color: #1e40af !important;
      background: rgba(37, 99, 235, 0.1);
      border-color: rgba(37, 99, 235, 0.28);
      opacity: 1;
    }
    body:not(.dark-theme) .home-team-card-head strong {
      color: #0f172a !important;
    }
    body:not(.dark-theme) .home-team-preview {
      color: #334155 !important;
      opacity: 1;
    }
    body:not(.dark-theme) .home-team-preview-list li {
      color: #0f172a !important;
      background: rgba(37, 99, 235, 0.1);
      border-color: rgba(37, 99, 235, 0.28);
    }
    body:not(.dark-theme) .home-team-actions {
      border-top-color: rgba(15, 23, 42, 0.1);
    }
    body:not(.dark-theme) .home-team-card-head {
      border-bottom-color: rgba(37, 99, 235, 0.18);
    }
    body:not(.dark-theme) .home-team-actions .home-secondary-btn,
    body:not(.dark-theme) .home-teams-toolbar .home-secondary-btn,
    body:not(.dark-theme) .home-team-modal .home-secondary-btn {
      color: #1e40af !important;
      background: rgba(37, 99, 235, 0.08);
      border-color: rgba(37, 99, 235, 0.28);
    }
    body:not(.dark-theme) .home-team-actions .home-secondary-btn.danger,
    body:not(.dark-theme) .home-team-modal .home-secondary-btn.danger {
      color: #b91c1c !important;
    }
    body:not(.dark-theme) .home-team-modal .home-team-modal-title,
    body:not(.dark-theme) .home-team-modal .home-team-modal-hint,
    body:not(.dark-theme) .home-team-modal-member-meta strong,
    body:not(.dark-theme) .home-team-modal-member-meta span {
      color: #0f172a;
    }
    body:not(.dark-theme) .home-team-modal-member {
      background: rgba(248, 250, 252, 0.95);
      border-color: rgba(15, 23, 42, 0.12);
      color: #0f172a;
    }
    body:not(.dark-theme) .home-collapse-btn {
      background: rgba(15, 23, 42, 0.06);
      color: #0f172a;
    }
    body:not(.dark-theme) .home-project-icon-btn {
      color: #0f172a;
      border-color: rgba(15, 23, 42, 0.12);
      background: rgba(255, 255, 255, 0.9);
    }
    body:not(.dark-theme) .page-brand-rail img {
      opacity: 0.55;
      filter: none;
    }
    body:not(.dark-theme) .select-model-btn {
      color: #0f172a;
    }
