/* ===================================================
   EFICÁCIA CRM — Premium Design System
   ================================================= */

/* ---------- CSS Custom Properties (Design Tokens) ---------- */
:root {
    /* Primary Palette — Vermelho Eficácia (based on eficacia.pt branding) */
    --primary-50: #fef2f2;
    --primary-100: #fee2e2;
    --primary-200: #fecaca;
    --primary-300: #f87171;
    --primary-400: #dc2626;
    --primary-500: #DA0A0D;
    --primary-600: #CC1616;
    --primary-700: #9B1010;
    --primary-800: #6D0206;
    --primary-900: #450a0a;

    /* Neutral */
    --neutral-0: #ffffff;
    --neutral-50: #f8fafc;
    --neutral-100: #f1f5f9;
    --neutral-200: #e2e8f0;
    --neutral-300: #cbd5e1;
    --neutral-400: #94a3b8;
    --neutral-500: #64748b;
    --neutral-600: #475569;
    --neutral-700: #334155;
    --neutral-800: #1e293b;
    --neutral-900: #0f172a;
    --neutral-25: #fafafa;

    /* Semantic Colors */
    --success-50: #ecfdf5;
    --success-100: #d1fae5;
    --success-200: #a7f3d0;
    --success-500: #10b981;
    --success-600: #059669;
    --success-700: #047857;
    --warning-50: #fffbeb;
    --warning-100: #fef3c7;
    --warning-500: #f59e0b;
    --warning-600: #d97706;
    --error-50: #fef2f2;
    --error-100: #fee2e2;
    --error-200: #fecaca;
    --error-400: #f87171;
    --error-500: #ef4444;
    --error-600: #dc2626;
    --error-700: #b91c1c;
    --info-50: #eff6ff;
    --info-500: #3b82f6;

    /* Sidebar */
    --sidebar-bg: #000000; /* manter igual ao ds-tokens.css — o override :root:root ganha, mas os dois valores não podem divergir */
    --sidebar-width: 272px;
    --sidebar-collapsed-width: 72px;

    /* Layout */
    --header-height: 64px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-spring: 400ms cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --text-xs: 0.6875rem;
    --text-sm: 0.8125rem;
    --text-base: 0.875rem;
    --text-lg: 1rem;
    --text-xl: 1.125rem;
    --text-2xl: 1.375rem;
    --text-3xl: 1.75rem;

}

/* ---------- LOGIN SCREEN ---------- */
/* Hide login instantly on F5/reload when token exists (set by inline script in head) */
html.auth-reload .login-screen {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.login-screen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0a0a0a 0%, #1a0a0a 50%, var(--primary-900) 100%);
    transition: opacity 0.4s ease, visibility 0.4s ease;
}
.login-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* ---------- SPINNER DE ARRANQUE (marca) ----------
   Vê-se só entre «autentiquei pelo mini-login do head» e «o app.js montou a
   app» — o intervalo em que antes se ficava a olhar para o formulário. O
   asterisco é o mesmo da barra inferior/FAB. */
.boot-spinner {
    position: fixed;
    inset: 0;
    z-index: 9998; /* por baixo do login (9999) — quando isto aparece, o login já foi escondido pelo auth-reload */
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    background: var(--neutral-0);
}
.boot-spinner.ativo { display: flex; }
.boot-spinner-ast {
    display: inline-block;
    font-family: var(--font-family);
    font-weight: 900;
    font-size: 84px;
    line-height: 1;
    color: var(--primary-500);
    animation: bootSpinnerRodar 1.1s linear infinite;
}
.boot-spinner-txt {
    color: var(--neutral-500);
    font-size: var(--text-sm);
}
@keyframes bootSpinnerRodar { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .boot-spinner-ast { animation: none; } }
.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--neutral-0);
    border-radius: var(--radius-xl);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.3);
    padding: 40px 36px 32px;
    animation: loginSlideUp 0.5s ease-out;
}
@keyframes loginSlideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
.login-header {
    text-align: center;
    margin-bottom: 32px;
}
.login-logo-img-wrap {
    margin: 0 auto 20px;
    display: flex;
    justify-content: center;
}
.login-logo-img {
    height: 40px;
    width: auto;
    filter: invert(1);
}
.login-subtitle {
    font-size: var(--text-sm);
    color: var(--neutral-400);
    margin: 0;
}
.login-form { display: flex; flex-direction: column; gap: 20px; }
.login-field label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--neutral-700);
    margin-bottom: 6px;
}
.login-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.login-input-wrap svg {
    position: absolute;
    left: 14px;
    width: 18px;
    height: 18px;
    color: var(--neutral-400);
    pointer-events: none;
}
.login-input-wrap input {
    width: 100%;
    padding: 12px 14px 12px 44px;
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-md);
    font-size: var(--text-base);
    font-family: var(--font-family);
    color: var(--neutral-800);
    background: var(--neutral-50);
    outline: none;
    transition: var(--transition-fast);
}
.login-input-wrap input:focus {
    border-color: var(--primary-400);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
    background: var(--neutral-0);
}
.login-input-wrap input::placeholder { color: var(--neutral-400); }
.login-error {
    background: var(--error-50, #fef2f2);
    color: var(--error-600, #dc2626);
    border: 1px solid var(--error-200, #fecaca);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    font-size: var(--text-sm);
    text-align: center;
}
.login-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--text-base);
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    transition: var(--transition-fast);
    margin-top: 4px;
}
.login-btn:hover { background: linear-gradient(135deg, var(--primary-700), var(--primary-800)); transform: translateY(-1px); }
.login-btn:active { transform: translateY(0); }
.login-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.login-btn svg { width: 18px; height: 18px; }
.login-footer {
    text-align: center;
    margin-top: 24px;
    font-size: var(--text-xs);
    color: var(--neutral-400);
}

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html {
    background: var(--neutral-0);
}

body {
    font-family: var(--font-family);
    font-size: var(--text-base);
    color: var(--neutral-800);
    background: var(--neutral-0);
    line-height: 1.6;
    overflow: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

input,
select,
textarea {
    font-family: inherit;
    font-size: inherit;
}

ul,
ol {
    list-style: none;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--neutral-300);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--neutral-400);
}

/* ---------- App Layout ---------- */
.app-layout {
    display: flex;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    overflow: hidden;
    background: var(--neutral-0);
}

/* ---------- SIDEBAR ---------- */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100vh;
    height: 100dvh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    transition: width var(--transition-slow), min-width var(--transition-slow);
    z-index: 100;
    position: relative;
    overflow: hidden;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
    min-width: var(--sidebar-collapsed-width);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    overflow: hidden;
    cursor: pointer;
}

.sidebar-logo-img {
    height: 28px;
    width: auto;
    transition: var(--transition-fast);
}

.sidebar.collapsed .sidebar-logo-img {
    height: 24px;
}

/* Caixa RESERVADA, não deduzida do conteúdo.
   O botão nasce com um `<i data-lucide>` vazio (12 px de altura, só o
   padding) e o Lucide troca-o por um `<svg>` ~80 ms depois: o cabeçalho
   passava de 65 para 79,4 px e empurrava o menu inteiro 14 px para baixo.
   Era o ÚNICO layout shift presente em todas as páginas da app — o menu
   "assentava" à frente do utilizador em cada carregamento.
   Fixar 42x42 (o tamanho que já tinha depois de hidratar) elimina-o e, de
   caminho, dá ao controlo um alvo de toque decente em vez de 12 px. */
.sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    color: var(--neutral-400);
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}

.sidebar-toggle:hover {
    color: white;
    background: rgba(255, 255, 255, 0.08);
}

.sidebar.collapsed .sidebar-logo,
.sidebar.collapsed .sidebar-search,
.sidebar.collapsed .user-info,
.sidebar.collapsed .user-menu-btn,
.sidebar.collapsed .nav-item-label,
.sidebar.collapsed .nav-item-chevron,
.sidebar.collapsed .nav-badge,
.sidebar.collapsed .nav-section-title {
    display: none;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: 18px 0;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 10px 0;
}

.sidebar.collapsed .nav-item-icon {
    margin: 0;
}

.sidebar.collapsed .sidebar-nav {
    padding: 12px 10px;
}

.sidebar.collapsed .nav-sub {
    display: none;
}

.sidebar.collapsed .sidebar-user {
    justify-content: center;
}

/* Sidebar Search Trigger */
.sidebar-search {
    padding: 12px 16px;
}

.sidebar-search-input {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-md);
    color: var(--neutral-400);
    font-size: var(--text-sm);
    cursor: pointer;
    transition: var(--transition-fast);
}

.sidebar-search-input:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.12);
}

.sidebar-search-input .search-icon {
    width: 16px;
    height: 16px;
}

.sidebar-search-input kbd {
    margin-left: auto;
    font-size: 10px;
    padding: 2px 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    font-family: inherit;
    color: var(--neutral-500);
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 12px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
}

.nav-section-title {
    font-size: 10px;
    font-weight: 700;
    color: var(--neutral-500);
    text-transform: uppercase;
    letter-spacing: 1.2px;
    padding: 16px 12px 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 9px 12px;
    border-radius: var(--radius-md);
    color: rgba(255, 255, 255, 0.85);
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    margin-bottom: 2px;
    position: relative;
    white-space: nowrap;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--neutral-200);
}

.nav-item.active {
    background: rgba(218, 10, 13, 0.15);
    color: var(--primary-300);
}

.nav-item.active .nav-item-icon {
    color: var(--primary-400);
}

.nav-item-icon {
    width: 20px;
    height: 20px;
    min-width: 20px;
    margin-right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-item-icon svg {
    width: 18px;
    height: 18px;
}

.nav-item-label {
    flex: 1;
}

.nav-item-chevron {
    width: 16px;
    height: 16px;
    transition: transform var(--transition-fast);
}

.nav-item-chevron svg {
    width: 16px;
    height: 16px;
}

.nav-item.expanded .nav-item-chevron {
    transform: rotate(90deg);
}

.nav-badge {
    padding: 1px 7px;
    font-size: 10px;
    font-weight: 700;
    background: var(--primary-500);
    color: white;
    border-radius: var(--radius-full);
    margin-left: 8px;
}

/* Sub-navigation */
.nav-sub {
    overflow: hidden;
    max-height: 0;
    transition: max-height var(--transition-slow);
}

.nav-sub.open {
    max-height: 400px;
}

.nav-sub-item {
    display: flex;
    align-items: center;
    padding: 8px 12px 8px 44px;
    font-size: var(--text-sm);
    color: var(--neutral-500);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
    position: relative;
}

.nav-sub-item::before {
    content: '';
    position: absolute;
    left: 26px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--neutral-600);
    transition: var(--transition-fast);
}

.nav-sub-item:hover {
    color: var(--neutral-200);
}

.nav-sub-item:hover::before {
    background: var(--neutral-400);
}

.nav-sub-item.active {
    color: var(--primary-300);
}

.nav-sub-item.active::before {
    background: var(--primary-400);
}

/* Sidebar Footer */
.sidebar-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding: 12px 16px;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
}

.sidebar-user:hover {
    background: rgba(255, 255, 255, 0.06);
}

.user-avatar {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 0;
    background: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0;
    font-weight: 700;
    color: transparent;
    letter-spacing: 0.5px;
    position: relative;
    z-index: 1;
}

/* Avatar do perfil = asterisco do logótipo "eficácia*" em vermelho */
.user-avatar::before {
    content: '*';
    position: absolute;
    inset: -30%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 46px;
    font-weight: 900;
    line-height: 1;
    color: var(--primary-500);
    z-index: 0;
    pointer-events: none;
}

.user-info {
    overflow: hidden;
}

.user-name {
    display: block;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--neutral-100);
}

.user-role {
    display: block;
    font-size: var(--text-xs);
    color: var(--neutral-500);
}

.user-menu-btn {
    margin-left: auto;
    color: var(--neutral-500);
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}

.user-menu-btn:hover {
    color: var(--neutral-300);
    background: rgba(255, 255, 255, 0.08);
}

/* Sidebar User Dropdown */
.sidebar-user-dropdown {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 16px;
    right: 16px;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 24px rgba(0,0,0,0.15), 0 1px 4px rgba(0,0,0,0.1);
    z-index: 1000;
    overflow: hidden;
}
.sidebar-user-dropdown.hidden { display: none; }
.sidebar-user-dropdown-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--neutral-200);
}
.sidebar-user-dropdown-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--neutral-900);
}
.sidebar-user-dropdown-role {
    font-size: 12px;
    color: var(--neutral-500);
}
.sidebar-user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    font-size: 14px;
    color: var(--neutral-700);
    cursor: pointer;
    transition: var(--transition-fast);
}
.sidebar-user-dropdown-item:hover {
    background: var(--neutral-50);
}
.sidebar-user-dropdown-item svg {
    width: 16px;
    height: 16px;
}
.sidebar-user-dropdown-logout {
    color: var(--error-500);
}
.sidebar-user-dropdown-logout:hover {
    background: var(--error-50, #fef2f2);
}
.sidebar-user-dropdown-divider {
    border-top: 1px solid var(--neutral-200);
}
.sidebar-footer {
    position: relative;
}

/* ---------- MAIN CONTENT ---------- */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--neutral-0);
}

/* Header */
.main-header {
    height: calc(var(--header-height) + env(safe-area-inset-top));
    min-height: calc(var(--header-height) + env(safe-area-inset-top));
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: env(safe-area-inset-top) 28px 0 28px;
    background: var(--primary-500);
    border-bottom: none;
    z-index: 50;
    position: relative;
    overflow: hidden;
}

/* Marca de água: o asterisco do logótipo "eficácia*" esbatido no canto da topbar */
.main-header::after {
    content: '*';
    position: absolute;
    right: -45px;
    top: 50%;
    transform: translateY(-30%);
    /* Cresce com a status bar do iPhone (25/08): com o cabecalho mais
       alto, os 300px fixos deixavam ver o fim das hastes do glifo --
       "meio cortado". A escalar com a safe-area volta a sangrar em
       cima e em baixo; em desktop env() e 0 e fica nos 300px. */
    font-size: calc(300px + env(safe-area-inset-top, 0px) * 3);
    font-weight: 900;
    color: rgba(0, 0, 0, 0.18);
    line-height: 1;
    pointer-events: none;
    z-index: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
    z-index: 1;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 6px;
    position: relative;
    z-index: 1;
}

.mobile-sidebar-toggle {
    display: none;
    padding: 8px;
    color: rgba(255, 255, 255, 0.8);
    border-radius: var(--radius-sm);
    z-index: 1;
}

.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--text-sm);
    color: rgba(255, 255, 255, 0.7);
    position: relative;
    z-index: 1;
}

.breadcrumbs a {
    color: rgba(255, 255, 255, 0.7);
    transition: var(--transition-fast);
}

.breadcrumbs a:hover {
    color: #ffffff;
}

/* Fica a versão do `origin/master`. O comentário que aqui estava explicava a
   escolha de `--ink-400` para uma barra CLARA, e a barra deixou de ser clara: o
   commit 14fc10e (Guilherme, 24-07) pô-la no vermelho da marca. Um separador
   escuro sobre vermelho não se vê — e desfazer o trabalho de outra pessoa a
   pretexto de resolver um conflito seria pior do que o conflito. */
.breadcrumbs .separator {
    color: rgba(255, 255, 255, 0.4);
}

.breadcrumbs .current {
    color: #ffffff;
    font-weight: 600;
}

.header-search-trigger,
.header-notifications,
.header-quick-add {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    color: rgba(255, 255, 255, 0.8);
    transition: var(--transition-fast);
    position: relative;
    cursor: pointer;
    z-index: 1;
}

.header-search-trigger:hover,
.header-notifications:hover,
.header-quick-add:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
}

.header-search-trigger svg,
.header-notifications svg,
.header-quick-add svg {
    width: 20px;
    height: 20px;
}

.notification-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--error-500);
    color: white;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--primary-500);
}

.header-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: white;
    cursor: pointer;
    z-index: 2;
    border: 2px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(4px);
    margin-left: 8px;
    position: relative;
    overflow: visible;
}

/* Page Content */
.page-content {
    flex: 1;
    overflow-y: auto;
    transition: opacity var(--transition-base), transform var(--transition-base);
    padding: 28px;
    padding-bottom: calc(28px + env(safe-area-inset-bottom));
    background: var(--neutral-0);
}

/* ---------- COMMAND PALETTE ---------- */
.command-palette-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 20vh;
    animation: fadeIn var(--transition-fast);
}

.command-palette {
    width: 560px;
    background: var(--neutral-0);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl), 0 0 0 1px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    animation: slideDown var(--transition-spring);
}

.command-palette-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--neutral-200);
}

.command-palette-header svg {
    width: 20px;
    height: 20px;
    color: var(--neutral-400);
}

.command-palette-header input {
    flex: 1;
    border: none;
    outline: none;
    font-size: var(--text-lg);
    color: var(--neutral-800);
    background: transparent;
}

.command-palette-header input::placeholder {
    color: var(--neutral-400);
}

.command-palette-header kbd {
    font-size: 11px;
    padding: 3px 8px;
    background: var(--neutral-100);
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-sm);
    color: var(--neutral-500);
    font-family: inherit;
}

.command-palette-results {
    max-height: 360px;
    overflow-y: auto;
    padding: 8px;
}

.command-result-group {
    padding: 4px 0;
}

.command-result-group-title {
    font-size: var(--text-xs);
    font-weight: 700;
    color: var(--neutral-400);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 8px 12px 6px;
}

.command-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
}

.command-result-item:hover {
    background: var(--primary-50);
}

.command-result-item svg {
    width: 18px;
    height: 18px;
    color: var(--neutral-400);
}

.command-result-item:hover svg {
    color: var(--primary-500);
}

.command-result-item span {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--neutral-700);
}

/* ---------- TOAST NOTIFICATIONS ---------- */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: var(--neutral-0);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--primary-500);
    min-width: 320px;
    animation: slideInRight var(--transition-spring);
    font-size: var(--text-sm);
}

.toast.success {
    border-left-color: var(--success-500);
}

.toast.warning {
    border-left-color: var(--warning-500);
}

.toast.error {
    border-left-color: var(--error-500);
}

.toast svg {
    width: 20px;
    height: 20px;
    min-width: 20px;
}

.toast.success svg {
    color: var(--success-500);
}

.toast.warning svg {
    color: var(--warning-500);
}

.toast.error svg {
    color: var(--error-500);
}

.toast .toast-message {
    flex: 1;
    color: var(--neutral-700);
}

.toast .toast-close {
    color: var(--neutral-400);
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}

.toast .toast-close:hover {
    background: var(--neutral-100);
    color: var(--neutral-600);
}

/* ---------- MODAL ---------- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn var(--transition-fast);
}

.modal-content {
    background: var(--neutral-0);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 90%;
    max-width: 640px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideDown var(--transition-spring);
}
.modal-content.modal-lg { max-width: 900px; max-height: 95vh; }
.modal-content.modal-xl { max-width: calc(100vw - 80px); width: 90%; max-height: 95vh; }
.modal-content.modal-auto { width: fit-content; min-width: 500px; max-width: calc(100vw - 80px); max-height: 95vh; }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--neutral-200);
}

.modal-header h2 {
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--neutral-900);
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--neutral-400);
    transition: var(--transition-fast);
}

.modal-close:hover {
    background: var(--neutral-100);
    color: var(--neutral-600);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    min-height: 0;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--neutral-200);
    background: var(--neutral-50);
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ---------- OBRA FASES TABS (Chrome-style) ---------- */
.fase-tabs {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    padding: 0 24px;
    background: var(--neutral-100);
    border-bottom: 1px solid var(--neutral-200);
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.fase-tabs::-webkit-scrollbar { display: none; }
.fase-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px 9px;
    font-size: 12px;
    font-weight: 600;
    color: var(--neutral-500);
    background: var(--neutral-50);
    border: 1px solid var(--neutral-200);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
    position: relative;
    top: 1px;
}
.fase-tab:hover { background: var(--neutral-0); color: var(--neutral-700); }
.fase-tab.active {
    background: var(--neutral-0);
    color: var(--primary-700);
    border-color: var(--neutral-200);
    border-bottom: 1px solid var(--neutral-0);
    z-index: 1;
}
.fase-tab .fase-tab-badge {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 8px;
    font-weight: 700;
}
.fase-tab-add {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px dashed var(--neutral-300);
    background: transparent;
    color: var(--neutral-400);
    cursor: pointer;
    font-size: 16px;
    margin-bottom: 4px;
    transition: all 0.15s;
    flex-shrink: 0;
}
.fase-tab-add:hover { background: var(--primary-50); border-color: var(--primary-300); color: var(--primary-600); }

/* ---------- QUICK ADD DROPDOWN ---------- */
.quick-add-dropdown {
    position: fixed;
    z-index: 200;
    background: var(--neutral-0);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl), 0 0 0 1px rgba(0, 0, 0, 0.04);
    padding: 6px;
    min-width: 200px;
    animation: slideDown var(--transition-spring);
}

.quick-add-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--neutral-700);
    transition: var(--transition-fast);
}

.quick-add-item:hover {
    background: var(--primary-50);
    color: var(--primary-700);
}

.quick-add-item svg {
    width: 18px;
    height: 18px;
    color: var(--neutral-400);
}

.quick-add-item:hover svg {
    color: var(--primary-500);
}

/* ---------- NOTIFICATIONS DROPDOWN ---------- */
.notifications-dropdown {
    position: fixed;
    z-index: 200;
    background: var(--neutral-0);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl), 0 0 0 1px rgba(0, 0, 0, 0.04);
    width: 380px;
    max-height: 460px;
    overflow: hidden;
    animation: slideDown var(--transition-spring);
}

.notifications-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--neutral-200);
}

.notifications-header h3 {
    font-size: var(--text-base);
    font-weight: 700;
    color: var(--neutral-900);
}

.mark-all-read {
    font-size: var(--text-xs);
    color: var(--primary-600);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
}

.mark-all-read:hover {
    color: var(--primary-700);
}

.notifications-list {
    max-height: 380px;
    overflow-y: auto;
    padding: 8px;
}

.notification-item {
    display: flex;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
    cursor: pointer;
}

.notification-item:hover {
    background: var(--neutral-50);
}

.notification-item.unread {
    background: var(--primary-50);
}

.notification-item .notif-icon {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
}

.notification-item .notif-icon svg {
    width: 18px;
    height: 18px;
}

.notification-item .notif-content {
    flex: 1;
}

.notification-item .notif-title {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--neutral-800);
}

.notification-item .notif-desc {
    font-size: var(--text-xs);
    color: var(--neutral-500);
    margin-top: 2px;
}

.notification-item .notif-time {
    font-size: 10px;
    color: var(--neutral-400);
    margin-top: 4px;
}

/* ---------- NOTIFICATION PREFERENCES ---------- */
.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--neutral-300);
    border-radius: 22px;
    transition: background 0.2s;
}
.switch-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.switch input:checked + .switch-slider { background: var(--primary-500); }
.switch input:checked + .switch-slider::before { transform: translateX(18px); }
.notif-pref-category.collapsed .notif-pref-items { display: none; }
.notif-pref-category.collapsed .notif-pref-cat-header [data-lucide="chevron-down"] { transform: rotate(-90deg); }
.notif-cat-toggle { width: 14px; height: 14px; accent-color: var(--primary-500); cursor: pointer; }

/* ---------- PAGE COMPONENTS ---------- */

/* Page Header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
}

.page-title {
    font-size: var(--text-2xl);
    font-weight: 800;
    color: var(--neutral-900);
    letter-spacing: -0.025em;
}

/* (Os títulos de página deixaram de levar asterisco — 21/08: ficam só
   com o ícone da rota, injetado pelo app.js quando o módulo não traz um.) */

/* Rodapé de paginação com respiro: o «Por página» encostava ao bordo
   do cartão e os números às linhas da lista. */
.ds-pagination.ds-pagination {
    padding: 12px 14px;
}

/* Ícone da rota junto ao título (injetado pelo app.js nas páginas cujo
   módulo não desenha ícone próprio) — tile igual ao das ds-listagens. */
.titulo-ico {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #ffffff;
    border: 1px solid rgba(15, 12, 41, 0.08);
    color: var(--primary-500);
    margin-right: 10px;
    vertical-align: -0.5em;
}

.titulo-ico svg {
    width: 20px;
    height: 20px;
}

/* O tile das ds-listagens ganha a mesma borda subtil para o formato
   ficar igual ao ícone injetado nas restantes páginas. */
.ds-lst-cab-ico.ds-lst-cab-ico {
    border: 1px solid rgba(15, 12, 41, 0.08);
    border-radius: 10px;
    background: #ffffff;
}

/* (Cabeçalhos de tabela mantêm os neutros do design-system.) */

/* Nomes/ligações nas listas de Clientes e Agências (mcl-link) a PRETO,
   por pedido de 21/08 — com o vermelho unificado vivo, páginas inteiras
   de nomes vermelhos eram demasiado. O negrito e o sublinhado no hover
   mantêm a affordance de ligação. (Classe dobrada: o mod-clientes.css
   carrega depois do style.css.) */
.mcl-link.mcl-link {
    color: var(--neutral-900);
}

.mcl-link.mcl-link:hover {
    color: var(--primary-500);
}

/* O dashboard trazia um segundo sino de notificações no cabeçalho da
   página; a topbar já tem um (com a contagem sincronizada pelo próprio
   mod-home) — fica só o de cima. O botão de atualizar mantém-se. */
.mh-acoes .mh-sino-wrap {
    display: none;
}

/* Nas células com nome + marca/nota (ds-cell-primary + ds-cell-muted),
   a segunda linha estava COLADA à primeira («…SRLSara…», «EficáciaEficácia»)
   porque são spans inline seguidos. A secundária passa a linha própria. */
.ds-td-wrap .ds-cell-muted {
    display: block;
    margin-top: 2px;
}

/* ===== Correções mobile (auditoria ago/2026) ===== */

/* Filas de separadores deslizam na horizontal em vez de cortar:
   o .ds-tabs tinha scroll-snap configurado mas faltava o overflow-x,
   e as abas fora do ecrã ficavam inacessíveis em mobile. */
.ds-tabs,
.tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.ds-tabs::-webkit-scrollbar,
.tabs::-webkit-scrollbar {
    display: none;
}

.tabs .tab {
    white-space: nowrap;
    flex: 0 0 auto;
}

/* Gráficos (chart.js) nunca transbordam o cartão */
#pageContent canvas {
    max-width: 100%;
    height: auto;
}

/* Breadcrumb da topbar: o título ganha reticências em vez de cortar */
@media (max-width: 1024px) {
    .main-header .header-left {
        min-width: 0;
        flex: 1 1 auto;
    }

    .main-header .breadcrumbs {
        min-width: 0;
        flex: 1 1 auto;
    }

    .main-header .breadcrumbs .current {
        min-width: 0;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* Em ecrãs estreitos o "Home /" rouba espaço ao título — fica só o atual */
@media (max-width: 640px) {
    .main-header .breadcrumbs a:first-child,
    .main-header .breadcrumbs .separator:first-of-type {
        display: none;
    }
}

/* ===== Barra inferior mobile: pílula flutuante vermelha =====
   Reestiliza a barra do mod-barrainferior: em vez de faixa branca
   colada ao fundo, uma pílula vermelha (#DA0A0D) flutuante; o botão
   do Dashboard é o asterisco da marca, elevado como FAB. */
@media (max-width: 1024px) {
    .barra-inf.barra-inf:not([hidden]) {
        left: 0;
        right: 0;
        bottom: 0;
        height: calc(68px + env(safe-area-inset-bottom, 0px));
        padding: 0 6px env(safe-area-inset-bottom, 0px);
        padding-left: calc(6px + env(safe-area-inset-left, 0px));
        padding-right: calc(6px + env(safe-area-inset-right, 0px));
        background: var(--primary-500);
        border-top: none;
        border-radius: 28px 28px 0 0;
        box-shadow: 0 -6px 24px rgba(15, 12, 41, 0.12);
    }

    .barra-inf .barra-inf-item {
        color: rgba(255, 255, 255, 0.72);
        border-radius: 9999px;
    }

    .barra-inf .barra-inf-item:active {
        background: rgba(255, 255, 255, 0.16);
    }

    .barra-inf .barra-inf-item.is-activa {
        color: #ffffff;
        box-shadow: none;
    }

    /* Botão do Dashboard = asterisco da marca em FAB elevado */
    .barra-inf .barra-inf-item[data-rota="dashboard"] svg {
        display: none;
    }

    .barra-inf .barra-inf-item[data-rota="dashboard"]::before {
        content: '*';
        display: flex;
        align-items: center;
        justify-content: center;
        width: 62px;
        height: 62px;
        margin-top: -34px;
        background: #ffffff;
        border-radius: 50%;
        color: var(--primary-500);
        font-size: 64px;
        font-weight: 900;
        line-height: 0.4;
        padding-top: 23px;
        box-sizing: border-box;
        box-shadow: 0 6px 16px rgba(0, 0, 0, 0.28);
    }

    /* Sem legenda «Início» — o asterisco fala por si e ganha realce. */
    .barra-inf .barra-inf-item[data-rota="dashboard"] .barra-inf-rotulo {
        display: none;
    }

    .barra-inf .barra-inf-item[data-rota="dashboard"] {
        color: #ffffff;
    }

    /* Clique no FAB = recarregar a app (listener no app.js); enquanto a
       página nova não chega, o asterisco roda como feedback. */
    @keyframes fab-rodar { to { transform: rotate(360deg); } }

    .barra-inf .barra-inf-item[data-rota="dashboard"].a-recarregar::before {
        animation: fab-rodar 0.8s linear infinite;
    }

    /* Reordenação: Menu no extremo esquerdo, Início (asterisco) ao centro.
       A DOM vem [dashboard, itens..., menu]; o flex `order` reposiciona sem
       tocar no JS. Com os 5 itens atuais fica: Menu · item · Início · item · item. */
    .barra-inf .barra-inf-item:nth-child(2) { order: 1; }
    .barra-inf .barra-inf-item:nth-child(3) { order: 3; }
    .barra-inf .barra-inf-item:nth-child(4) { order: 4; }
    .barra-inf .barra-inf-item:nth-child(5) { order: 5; }
    .barra-inf .barra-inf-item:nth-child(6) { order: 6; }

    .barra-inf .barra-inf-item[data-rota="dashboard"] { order: 2; }

    .barra-inf .barra-inf-item[data-rota="__menu"] { order: -1; }

    /* A barra flutuante ocupa mais 10px do que a original: dar folga extra
       ao conteúdo (vence o !important do módulo por especificidade de id). */
    #pageContent.page-content {
        padding-bottom: calc(92px + env(safe-area-inset-bottom, 0px)) !important;
    }
}

/* ===== Estilo ggv no interior das páginas =====
   Fonte Geist + cartões de raio grande com borda ténue e sombra dupla
   suave, como na ggv-app. O triple :root ganha ao :root:root do
   ds-tokens.css sem tocar nos ficheiros do design-system. */
:root:root:root {
    --font-sans: 'Geist', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-family: var(--font-sans);

    /* Vermelho único da marca (#DA0A0D, o da topbar) em TODO o lado:
       os tons escuros (textos, valores, ligações) passam ao vermelho da
       marca, e o tint de fundo dos cartões destacados passa a branco —
       sem sombreados rosados. */
    --brand-50: #ffffff;
    --brand-600: #DA0A0D;
    --brand-700: #DA0A0D;

    /* Sem sombreados coloridos no conteúdo (pedido de 21/08): os fundos
       tinted (rosa/amarelo/verde/azul) dos alertas, badges e faixas
       passam a um neutro claro — a cor fica no texto/ícone/borda. */
    --error-50: #F7F8FA;
    --danger-50: #F7F8FA;
    --warning-50: #F7F8FA;
    --success-50: #F7F8FA;
    --info-50: #F7F8FA;

    /* Verde da plataforma mais escuro (pedido 21/08): estados «ok»,
       badges e indicadores ganham peso e contraste sobre branco. */
    --success-500: #15803D;
    --success-600: #116932;
    --success-700: #0E5A2B;
    --success-800: #0A4A22;
    --success-200: rgba(21, 128, 61, 0.40);
}

.card,
.kpi-card,
.kpi-grid > .card {
    border-radius: 20px;
    border: 1px solid rgba(15, 12, 41, 0.06);
    box-shadow: 0 1px 2px rgba(15, 12, 41, 0.06), 0 8px 24px -12px rgba(15, 12, 41, 0.10);
}

.card:hover,
.kpi-card:hover {
    box-shadow: 0 1px 2px rgba(15, 12, 41, 0.08), 0 12px 32px -12px rgba(15, 12, 41, 0.16);
}

/* ===== Identidade da marca nos módulos do design-system ===== */

/* Cartões KPI de todos os módulos: marca de água do asterisco
   + o mesmo tratamento ggv (raio grande, borda ténue, sombra suave)

   O `.fo-dash-kpi` (mostradores da LISTA de Folhas de Obra) faltava nas três
   listas — a moldura, o asterisco e o estado selecionado. Era só isso que
   separava aquela página das outras nove: sem o asterisco e sem esta borda,
   ela lia-se como um ecrã de outra aplicação. O `.fo-kpi` que já cá estava é
   o da FICHA de folha de obra, não o da lista. */
.ds-kpi, .fo-kpi, .fo-dash-kpi, .ma-kpi, .mav-kpi, .mcl-kpi, .meq-kpi, .mh-kpi, .mp-kpi {
    position: relative;
    overflow: hidden;
    border-radius: 18px;
    border: 1px solid rgba(15, 12, 41, 0.06);
    box-shadow: 0 1px 2px rgba(15, 12, 41, 0.06), 0 8px 24px -12px rgba(15, 12, 41, 0.10);
}

/* Linhas das listagens e painel Análise com o mesmo raio/sombra ggv */
.ds-lst-linha,
.ds-analise .ds-analise-toggle,
.ds-card {
    border-radius: 18px;
    border-color: rgba(15, 12, 41, 0.06);
    box-shadow: 0 1px 2px rgba(15, 12, 41, 0.06), 0 8px 24px -12px rgba(15, 12, 41, 0.10);
}

.ds-lst-tab tbody tr.ds-lst-linha:hover {
    box-shadow: 0 1px 2px rgba(15, 12, 41, 0.08), 0 12px 32px -12px rgba(15, 12, 41, 0.16);
}

.ds-kpi::after, .fo-kpi::after, .fo-dash-kpi::after, .ma-kpi::after, .mav-kpi::after,
.mcl-kpi::after, .meq-kpi::after, .mh-kpi::after, .mp-kpi::after {
    content: '*';
    position: absolute;
    right: -10px;
    top: -24px;
    font-size: 76px;
    font-weight: 900;
    line-height: 1;
    color: var(--primary-500);
    opacity: 1;
    pointer-events: none;
}

/* Chip selecionado (fundo vermelho sólido): a marca de água passa a
   branco, senão desaparece sobre o vermelho. */
.ds-kpi[aria-pressed="true"]::after, .fo-kpi[aria-pressed="true"]::after,
.fo-dash-kpi[aria-pressed="true"]::after,
.ma-kpi[aria-pressed="true"]::after, .mav-kpi[aria-pressed="true"]::after,
.mcl-kpi[aria-pressed="true"]::after, .meq-kpi[aria-pressed="true"]::after,
.mh-kpi[aria-pressed="true"]::after, .mp-kpi[aria-pressed="true"]::after {
    color: #ffffff;
    opacity: 1;
}

/* Micro-legendas dos chips a branco quando o chip está selecionado
   (fundo vermelho) — o cinzento desaparecia sobre o vermelho. */
.ds-lst-kpi[aria-pressed="true"] [class*="kpi-nota"],
.mav-kpi[aria-pressed="true"] [class*="kpi-nota"],
.mav-kpi[aria-pressed="true"] [class*="kpi-sub"] {
    color: rgba(255, 255, 255, 0.92);
}

/* (Sem fundos vermelho-claro: a barra "Análise" mantém o fundo branco
   do design-system — o vermelho da marca usa-se sólido, nunca em tint.) */

/* Botões do design-system: pílula + o MESMO vermelho da topbar (#DA0A0D).
   O ds-btn--primary usava --primary-600 (#B80A0C), mais escuro que a barra. */
.ds-btn.ds-btn {
    border-radius: 9999px;
}

.ds-btn.ds-btn--primary {
    background: var(--primary-500);
    border-color: var(--primary-500);
}

.ds-btn.ds-btn--primary:hover {
    background: var(--primary-500);
    border-color: var(--primary-500);
    filter: brightness(0.9);
}

/* Chips seletores das listagens: o formato é UNIFORME POR FILA (pedido
   de 21/08 — uma fila mista de pílulas e mosaicos destoava):
   · fila só de chips simples (número+rótulo, ex. Contratos) → todos em
     pílula esticada, número e rótulo em linha (como o "Minhas Tarefas"
     da AV app);
   · fila onde ALGUM chip tem micro-legenda (*-nota/-sub, ex. Clientes)
     → todos em mosaico coluna do design-system (pô-los em linha
     esmagava o texto — bug de Fornecedores/Tickets).
   Selecionado = vermelho sólido com texto branco em ambos os casos.
   Sem :has() o browser ignora a pílula e fica tudo em coluna: seguro. */
.ds-lst-kpis .ds-lst-kpi {
    border-radius: 18px;
}

.ds-lst-kpis:not(:has([class*="-nota"], [class*="-sub"])) .ds-lst-kpi {
    border-radius: 9999px;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    min-width: 0;
    min-height: 0;
    padding: 11px 22px;
}

.ds-lst-kpis .ds-lst-kpi[aria-pressed="true"],
.mav-kpi[aria-pressed="true"],
.mav-cob-btn[aria-pressed="true"] {
    background: var(--primary-500);
    border-color: var(--primary-500);
    box-shadow: none;
}

.ds-lst-kpi[aria-pressed="true"] .ds-lst-kpi-n,
.ds-lst-kpi[aria-pressed="true"] .ds-lst-kpi-rot,
.mav-kpi[aria-pressed="true"] .mav-kpi-n,
.mav-kpi[aria-pressed="true"] .mav-kpi-rot,
.mav-kpi[aria-pressed="true"] .mav-kpi-sub {
    color: #ffffff;
}

/* Títulos de secção ds: marcador asterisco da marca.
   (Não aplicar aos títulos de gráficos *-graf-tit: são flex em coluna
   e o ::before ficava órfão numa linha própria.) */
.ds-card-title::before,
.ds-secao-titulo::before {
    content: '*';
    color: var(--primary-500);
    font-weight: 900;
    font-size: 26px;
    line-height: 0;
    vertical-align: -0.24em;
    margin-right: 9px;
}

.page-subtitle {
    font-size: var(--text-sm);
    color: var(--neutral-500);
    margin-top: 4px;
}

.page-header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    font-size: var(--text-sm);
    font-weight: 600;
    border-radius: 9999px;
    transition: var(--transition-fast);
    cursor: pointer;
    border: none;
    white-space: nowrap;
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: var(--primary-500);
    color: white;
    box-shadow: 0 1px 2px rgba(218, 10, 13, 0.3);
}

.btn-primary:hover {
    background: var(--primary-500);
    filter: brightness(0.9);
    box-shadow: 0 4px 12px rgba(218, 10, 13, 0.3);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--neutral-0);
    color: var(--neutral-700);
    border: 1px solid var(--neutral-200);
}

.btn-secondary:hover {
    background: var(--neutral-50);
    border-color: var(--neutral-300);
}

.btn-ghost {
    background: transparent;
    color: var(--neutral-600);
}

.btn-ghost:hover {
    background: var(--neutral-100);
}

.btn-danger {
    background: var(--error-50);
    color: var(--error-500);
    border: 1px solid var(--error-200);
}

.btn-danger:hover {
    background: var(--error-500);
    color: var(--neutral-0);
}

.btn-sm {
    padding: 6px 12px;
    font-size: var(--text-xs);
}

.btn-icon {
    width: 38px;
    height: 38px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
}

/* Cards */
.card {
    background: var(--neutral-0);
    border-radius: var(--radius-lg);
    border: 1px solid var(--neutral-200);
    transition: var(--transition-base);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--neutral-100);
}

.card-header h3 {
    font-size: var(--text-base);
    font-weight: 700;
    color: var(--neutral-900);
}

/* Marcador da marca nos títulos de secção — tamanho generoso, como no
   logótipo (o glifo * senta alto: o line-height/vertical-align compensam) */
.card-header h3::before,
.card > h3::before {
    content: '*';
    color: var(--primary-500);
    font-weight: 900;
    font-size: 26px;
    line-height: 0;
    vertical-align: -0.24em;
    margin-right: 9px;
}

.card-body {
    padding: 22px;
}

.card-body.no-padding {
    padding: 0;
}

/* KPI Cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 28px;
}

.kpi-card {
    background: var(--neutral-0);
    border-radius: var(--radius-lg);
    padding: 22px;
    border: 1px solid var(--neutral-200);
    transition: var(--transition-base);
    position: relative;
    overflow: hidden;
}

.kpi-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-color: var(--primary-200);
}

/* Asterisco da marca em marca de água nos cartões KPI (eco da topbar) */
.kpi-grid > .card {
    position: relative;
    overflow: hidden;
}

.kpi-card::after,
.kpi-grid > .card::after {
    content: '*';
    position: absolute;
    right: -16px;
    top: -38px;
    font-size: 120px;
    font-weight: 900;
    line-height: 1;
    color: var(--primary-500);
    opacity: 1;
    pointer-events: none;
}

.kpi-card-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.kpi-card-icon svg {
    width: 22px;
    height: 22px;
}

.kpi-card-icon.blue {
    background: var(--info-50);
    color: var(--info-500);
}

.kpi-card-icon.green {
    background: var(--success-50);
    color: var(--success-500);
}

.kpi-card-icon.purple {
    background: var(--primary-50);
    color: var(--primary-500);
}

.kpi-card-icon.orange {
    background: var(--warning-50);
    color: var(--warning-500);
}
.kpi-card-icon.red {
    background: var(--error-50);
    color: var(--error-500);
}

.kpi-value {
    font-size: var(--text-3xl);
    font-weight: 800;
    color: var(--neutral-900);
    letter-spacing: -0.025em;
    line-height: 1;
}

.kpi-label {
    font-size: var(--text-sm);
    color: var(--neutral-500);
    margin-top: 6px;
    font-weight: 500;
}

.kpi-trend {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: var(--text-xs);
    font-weight: 600;
    margin-top: 10px;
    padding: 3px 8px;
    border-radius: var(--radius-full);
}

.kpi-trend.up {
    background: var(--success-50);
    color: var(--success-600);
}

.kpi-trend.down {
    background: var(--error-50);
    color: var(--error-600);
}

.kpi-trend svg {
    width: 14px;
    height: 14px;
}

/* Tables */
.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.data-table.table-fixed {
    table-layout: fixed;
}

.data-table.table-fixed tbody td {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 12px 10px;
}

.data-table.table-fixed thead th {
    padding: 10px 10px;
}

.data-table thead th {
    font-size: var(--text-xs);
    font-weight: 700;
    color: var(--neutral-500);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--neutral-200);
    background: var(--neutral-50);
    white-space: nowrap;
    position: sticky;
    top: 0;
}

.data-table thead th:first-child {
    border-radius: var(--radius-md) 0 0 0;
}

.data-table thead th:last-child {
    border-radius: 0 var(--radius-md) 0 0;
}

.data-table tbody tr {
    transition: var(--transition-fast);
}

.data-table tbody tr:hover {
    background: var(--neutral-50);
}

.data-table tbody td {
    padding: 14px 16px;
    font-size: var(--text-sm);
    color: var(--neutral-700);
    border-bottom: 1.5px solid rgba(218, 10, 13, 0.08);
    white-space: nowrap;
}

.data-table tbody td:first-child {
    font-weight: 600;
    color: var(--neutral-900);
}

.data-table .row-actions {
    display: flex;
    gap: 6px;
    opacity: 0;
    transition: var(--transition-fast);
}

.data-table tbody tr:hover .row-actions {
    opacity: 1;
}

.data-table .action-btn {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--neutral-400);
    transition: var(--transition-fast);
}

.data-table .action-btn:hover {
    background: var(--neutral-100);
    color: var(--neutral-700);
}

.data-table .action-btn svg {
    width: 16px;
    height: 16px;
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 700;
    white-space: nowrap;
    border: 1px solid transparent;
}

.status-badge::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-badge.producao {
    background: #bfdbfe;
    color: #1e3a8a;
    border-color: #93c5fd;
}

.status-badge.producao::before {
    background: #2563eb;
}

.status-badge.encomendado {
    background: #fde68a;
    color: #78350f;
    border-color: #fbbf24;
}

.status-badge.encomendado::before {
    background: #d97706;
}

.status-badge.por-montar {
    background: #fde2e2;
    color: #991b1b;
    border-color: #ef4444;
}

.status-badge.por-montar::before {
    background: #ef4444;
}

.status-badge.por-cortar {
    background: #fbcfe8;
    color: #831843;
    border-color: #f472b6;
}

.status-badge.por-cortar::before {
    background: #db2777;
}

.status-badge.por-encomendar {
    background: #fed7aa;
    color: #7c2d12;
    border-color: #fb923c;
}

.status-badge.por-encomendar::before {
    background: #ea580c;
}

.status-badge.montagem {
    background: #fecdd3;
    color: #881337;
    border-color: #fb7185;
}

.status-badge.montagem::before {
    background: #e11d48;
}

.status-badge.expedido {
    background: #a7f3d0;
    color: #064e3b;
    border-color: #34d399;
}

.status-badge.expedido::before {
    background: #059669;
}

.status-badge.por-expedir {
    background: #ddd6fe;
    color: #4c1d95;
    border-color: #f87171;
}

.status-badge.por-expedir::before {
    background: #7c3aed;
}

.status-badge.acabamentos {
    background: #a5f3fc;
    color: #164e63;
    border-color: #22d3ee;
}

.status-badge.acabamentos::before {
    background: #0891b2;
}

.status-badge.por-faturar {
    background: #fecaca;
    color: #450a0a;
    border-color: #f87171;
}

.status-badge.por-faturar::before {
    background: #DA0A0D;
}

.status-badge.por-cobrar {
    background: #f5d0fe;
    color: #701a75;
    border-color: #e879f9;
}

.status-badge.por-cobrar::before {
    background: #c026d3;
}

.status-badge.pendente {
    background: #fde68a;
    color: #78350f;
    border-color: #fbbf24;
}

.status-badge.pendente::before {
    background: #d97706;
}

.status-badge.parcial {
    background: #bfdbfe;
    color: #1e3a8a;
    border-color: #60a5fa;
}

.status-badge.parcial::before {
    background: #2563eb;
}

.status-badge.completo {
    background: #15803D;
    color: #ffffff;
    border-color: #15803D;
}

.status-badge.completo::before {
    background: #ffffff;
}

.status-badge.concluido {
    background: #15803D;
    color: #ffffff;
    border-color: #15803D;
}

.status-badge.concluido::before {
    background: #ffffff;
}

.status-badge.por-medir {
    background: #e2e8f0;
    color: #1e293b;
    border-color: #94a3b8;
}

.status-badge.por-medir::before {
    background: #475569;
}

.status-badge.por-adjudicar {
    background: #e9d5ff;
    color: #581c87;
    border-color: #c084fc;
}

.status-badge.por-adjudicar::before {
    background: #9333ea;
}

.status-badge.adjudicado {
    background: #bae6fd;
    color: #0c4a6e;
    border-color: #38bdf8;
}

.status-badge.adjudicado::before {
    background: #0284c7;
}

.status-badge.anulado {
    background: #e5e7eb;
    color: #374151;
    border-color: #9ca3af;
}

.status-badge.anulado::before {
    background: #6b7280;
}

.status-badge.urgente {
    background: #fecaca;
    color: #7f1d1d;
    border-color: #f87171;
}

.status-badge.urgente::before {
    background: #dc2626;
}

/* Estado Custom Dropdown (edit modal) */
.estado-dropdown {
    position: relative;
}
.estado-dropdown-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-lg);
    cursor: pointer;
    background: var(--neutral-0);
    transition: var(--transition-fast);
}
.estado-dropdown-trigger:hover {
    border-color: var(--primary-300);
    box-shadow: 0 0 0 3px var(--primary-50);
}
.estado-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 100;
    background: var(--neutral-0);
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    padding: 6px;
    min-width: 180px;
    max-height: 280px;
    overflow-y: auto;
}
.estado-dropdown-menu.open {
    display: block;
}
.estado-dropdown-item {
    padding: 4px 6px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background 0.15s;
}
.estado-dropdown-item:hover {
    background: var(--neutral-100);
}

/* Searchable Select Dropdown */
.searchable-select {
    position: relative;
}
.searchable-select-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 50;
    background: var(--neutral-0);
    color: var(--neutral-900);
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    max-height: 220px;
    overflow-y: auto;
    margin-top: 4px;
}
.searchable-select-menu.ss-fixed {
    position: fixed;
    z-index: 10100;
    margin-top: 0;
}
.searchable-select-menu.open {
    display: block;
}
.searchable-select-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    transition: background 0.15s;
}
.searchable-select-item:hover {
    background: var(--primary-50);
}

/* Observations HTML content */
.obs-html-content p { margin: 0 0 4px; }
.obs-html-content ul, .obs-html-content ol { margin: 4px 0; padding-left: 20px; }
.obs-html-content li { margin-bottom: 2px; }
.obs-html-content blockquote { border-left: 3px solid var(--neutral-300); margin: 4px 0; padding: 4px 12px; color: var(--neutral-600); }
.obs-html-content a { color: var(--primary-600); text-decoration: underline; }

/* Rich text editor contenteditable */
[contenteditable="true"] p { margin: 0 0 4px; }
[contenteditable="true"] ul, [contenteditable="true"] ol { margin: 4px 0; padding-left: 20px; }
[contenteditable="true"] blockquote { border-left: 3px solid var(--primary-300); margin: 4px 0; padding: 4px 12px; color: var(--neutral-600); }

/* RAL Color Grid */
.ral-color-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
    gap: 6px;
}

.ral-color-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 6px 4px;
    border-radius: 8px;
    border: 1.5px solid var(--neutral-200);
    background: var(--neutral-50);
    cursor: pointer;
    transition: all 0.15s ease;
}

.ral-color-option:hover {
    border-color: var(--primary-300);
    background: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.ral-color-option.selected {
    border-color: var(--primary-500);
    background: var(--primary-50);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.ral-swatch {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0,0,0,0.12);
    flex-shrink: 0;
}

.ral-swatch.ral-none {
    background: var(--neutral-100);
    border: 1.5px dashed var(--neutral-300);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: none;
}

.ral-label {
    font-size: 9px;
    font-weight: 600;
    color: var(--neutral-600);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    line-height: 1.2;
}

.ral-color-option.selected .ral-label {
    color: var(--primary-700);
}

/* Color Badge (table + preview) */
.color-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--neutral-700);
}

.color-swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

/* Multi-select Dropdown */
.multiselect-dropdown {
    position: relative;
}

.multiselect-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 42px;
    padding: 6px 12px;
    border: 1px solid var(--neutral-300);
    border-radius: 8px;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

.multiselect-trigger:hover {
    border-color: var(--primary-400);
}

.multiselect-placeholder {
    color: var(--neutral-400);
    font-size: 14px;
}

.multiselect-trigger:not(.multiselect-placeholder) {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.multiselect-tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    background: var(--primary-50);
    color: var(--primary-700);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid var(--primary-200);
    white-space: nowrap;
}

.multiselect-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--neutral-200);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    z-index: 100;
    display: none;
    overflow: hidden;
}

.multiselect-menu.open {
    display: block;
}

.multiselect-search-wrap {
    padding: 10px 12px 8px;
    border-bottom: 1px solid var(--neutral-100);
}

.multiselect-search {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--neutral-200);
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
    font-family: 'Inter', sans-serif;
}

.multiselect-search:focus {
    border-color: var(--primary-400);
}

.multiselect-list {
    max-height: 260px;
    overflow-y: auto;
    padding: 6px;
}

.multiselect-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
}

.multiselect-item:hover {
    background: var(--neutral-50);
}

.multiselect-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary-600);
    cursor: pointer;
    flex-shrink: 0;
}

.multiselect-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-100);
    color: var(--primary-700);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
}

.multiselect-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.multiselect-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--neutral-800);
}

.multiselect-role {
    font-size: 11px;
    color: var(--neutral-400);
}

/* Os estilos de `.time-entry-*` e `.folha-user-card` foram apagados com os ecras
   que os usavam (Registar Horas e Folha de Ponto do pages2.js): a Gestao de Tempo
   e agora o MOD.tempo, com `mod-tempo.css` (prefixo mt-) sobre a moldura
   `ds-listagem.css`. `.mobile-label` fica: e partilhado por outras tabelas legadas. */

.mobile-label {
    display: none;
}

/* ---------- Mapa de Férias ---------- */
.ferias-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 20px;
    padding: 12px 16px;
    background: var(--neutral-25, #fafafa);
    border-radius: var(--radius-lg);
    border: 1px solid var(--neutral-100);
}
.ferias-legend {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    align-items: center;
}
.ferias-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--neutral-600);
}
.ferias-legend-dot {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    display: inline-block;
}
.ferias-legend-dot.weekend { background: #e2e8f0; }
.ferias-legend-dot.holiday { background: #fed7aa; border: 1px solid #f97316; }
.ferias-legend-dot.selected { background: rgba(21, 128, 61, 0.30); border: 1px solid #15803D; }
.ferias-legend-dot.booked { background: #15803D; border: 1px solid #15803D; }
.ferias-legend-dot.company-holiday { background: #fecaca; border: 1px solid #DA0A0D; }
.ferias-legend-dot.cancel-selected { background: #fca5a5; border: 1px solid #ef4444; }
.ferias-user-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    max-height: 240px;
    overflow-y: auto;
    z-index: 100;
    margin-top: 4px;
}
.ferias-user-dropdown-item {
    padding: 8px 14px;
    font-size: 13px;
    cursor: pointer;
    color: var(--neutral-700);
    transition: background 0.1s;
}
.ferias-user-dropdown-item:hover { background: var(--primary-50); color: var(--primary-700); }
.ferias-user-dropdown-item.active { background: var(--primary-100); color: var(--primary-700); font-weight: 600; }
.ferias-legend-dot.pending { background: #fde68a; border: 1px solid #f59e0b; }
.ferias-counters {
    display: flex;
    gap: 20px;
    align-items: center;
}
.ferias-counter {
    font-size: 13px;
    color: var(--neutral-600);
}
.ferias-counter strong {
    font-size: 15px;
    color: var(--neutral-900);
}
.ferias-counter small {
    color: var(--neutral-400);
}
.text-primary { color: var(--primary-600) !important; }
.text-success { color: var(--success-500) !important; }
.ferias-year-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 20px;
}
.ferias-year-label {
    font-size: 20px;
    font-weight: 700;
    color: var(--neutral-900);
}
.ferias-submit-form {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.ferias-calendar-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
.ferias-month {
    border: 1px solid var(--neutral-100);
    border-radius: var(--radius-md);
    padding: 10px;
    background: var(--neutral-0);
}
.ferias-month-title {
    text-align: center;
    font-weight: 700;
    font-size: 13px;
    color: var(--neutral-800);
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--neutral-100);
}
.ferias-month-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
}
.ferias-day-header {
    text-align: center;
    font-size: 10px;
    font-weight: 600;
    color: var(--neutral-400);
    padding: 2px 0 4px;
}
.ferias-day {
    text-align: center;
    font-size: 11px;
    padding: 3px 1px;
    border-radius: 3px;
    color: var(--neutral-700);
    cursor: pointer;
    transition: background 0.15s;
    line-height: 1.6;
}
.ferias-day:hover:not(.weekend):not(.holiday):not(.company-holiday):not(.empty) {
    background: var(--primary-50);
}
.ferias-day.empty { cursor: default; }
.ferias-day.weekend {
    background: #e2e8f0;
    color: #94a3b8;
    cursor: default;
}
.ferias-day.holiday {
    background: #fed7aa;
    color: #c2410c;
    font-weight: 600;
    cursor: default;
}
.ferias-day.company-holiday {
    background: #fecaca;
    color: #9B1010;
    font-weight: 600;
    cursor: default;
}
.ferias-day.booked {
    background: #15803D;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
}
.ferias-day.booked:hover {
    background: #116932;
    box-shadow: inset 0 0 0 2px var(--error-400);
}
.ferias-day.cancel-selected {
    background: #fca5a5 !important;
    color: #991b1b !important;
    font-weight: 700;
    cursor: pointer;
    box-shadow: inset 0 0 0 2px #ef4444;
}
.ferias-day.selected {
    background: rgba(21, 128, 61, 0.30);
    color: #0E5A2B;
    font-weight: 700;
}
.ferias-day.pending {
    background: #fde68a;
    color: #92400e;
    font-weight: 600;
}
.ferias-day.today {
    box-shadow: inset 0 0 0 2px var(--primary-500);
    border-radius: 4px;
}
.ferias-footer {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    padding-top: 16px;
    border-top: 1px solid var(--neutral-100);
}

/* ========== GESTÃO DE FÉRIAS ========== */
.gestao-ferias-kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
.gestao-ferias-card {
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 16px;
    background: var(--neutral-0);
}
.gestao-ferias-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
}
.gestao-ferias-badge-pendente {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    background: var(--warning-50);
    color: var(--warning-600);
    border: 1px solid var(--warning-100);
    white-space: nowrap;
}
.gestao-ferias-cal-wrap {
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
}
.gestao-ferias-mini-cals {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
}
.gestao-ferias-mini-month {
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    background: var(--neutral-0);
    min-width: 180px;
}
.gestao-ferias-motivo {
    margin-bottom: 20px;
    padding: 14px 18px;
    background: var(--neutral-50);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--primary-300);
}
.gestao-ferias-obs-section {
    margin-bottom: 20px;
}
.gestao-ferias-obs-input {
    font-size: 13px;
    resize: vertical;
    min-height: 60px;
    width: 100%;
    box-sizing: border-box;
}
.gestao-ferias-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-wrap: wrap;
}
.gestao-ferias-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}
.gestao-ferias-btn-recusar {
    background: var(--error-50);
    color: var(--error-600);
    border: 1px solid var(--error-200);
}
.gestao-ferias-btn-recusar:hover {
    background: var(--error-100);
}
.gestao-ferias-btn-aprovar {
    background: var(--success-50);
    color: var(--success-600);
    border: 1px solid var(--success-200);
}
.gestao-ferias-btn-aprovar:hover {
    background: var(--success-100);
}
.gestao-ferias-btn-aprovar-tudo {
    background: var(--success-600);
    color: white;
    border: 1px solid var(--success-600);
}
.gestao-ferias-btn-aprovar-tudo:hover {
    background: var(--success-700);
}
.gestao-ferias-btn-cancel-aprovar {
    background: var(--error-600);
    color: white;
    border: 1px solid var(--error-600);
}
.gestao-ferias-btn-cancel-aprovar:hover {
    background: var(--error-700);
}

/* Filters — 2-row layout (boopgest style) */
.filter-bar {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--neutral-100);
}

.filter-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: nowrap;
}

/* Filter actions row (checkbox + button inline) */
.filter-actions-row {
    display: contents;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1 1 0;
    min-width: 0;
}

.filter-label {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--neutral-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Form Elements */
.form-input,
.form-select {
    padding: 9px 14px;
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    color: var(--neutral-700);
    background: var(--neutral-0);
    transition: var(--transition-fast);
    outline: none;
    min-width: 160px;
}

.form-input:focus,
.form-select:focus {
    border-color: var(--primary-400);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-input::placeholder {
    color: var(--neutral-400);
}

.form-input.sm,
.form-select.sm {
    padding: 7px 10px;
    min-width: 0;
    width: 100%;
    font-size: var(--text-xs);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--neutral-700);
}

.form-group .form-input,
.form-group .form-select {
    width: 100%;
}

/* ---------- Lockable Field ---------- */
.lockable-field {
    position: relative;
    display: flex;
    align-items: stretch;
}
.lockable-field .form-input {
    flex: 1;
    padding-right: 40px;
}
.lockable-field .lock-toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--neutral-400);
    transition: color 0.2s, background 0.2s;
}
.lockable-field .lock-toggle:hover {
    background: var(--neutral-100);
    color: var(--primary-500);
}
.lockable-field .lock-toggle.unlocked {
    color: var(--primary-500);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.form-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.form-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-600);
    cursor: pointer;
}

.form-checkbox span {
    font-size: var(--text-sm);
    color: var(--neutral-700);
}

textarea.form-input {
    resize: vertical;
    min-height: 120px;
    line-height: 1.6;
}

/* Rich Text Editor Placeholder */
.rich-text-editor {
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.rich-text-toolbar {
    display: flex;
    gap: 2px;
    padding: 8px 12px;
    background: var(--neutral-50);
    border-bottom: 1px solid var(--neutral-200);
    flex-wrap: wrap;
}

.rich-text-toolbar button {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--neutral-500);
    transition: var(--transition-fast);
    font-size: 14px;
    font-weight: 600;
}

.rich-text-toolbar button:hover {
    background: var(--neutral-200);
    color: var(--neutral-700);
}

.rich-text-content {
    padding: 14px 16px;
    min-height: 140px;
    outline: none;
    font-size: var(--text-sm);
    color: var(--neutral-700);
    line-height: 1.7;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--neutral-200);
    margin-bottom: 24px;
}

.tab {
    padding: 10px 18px;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--neutral-500);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    border-radius: 9999px;
    transition: var(--transition-fast);
    margin-bottom: 4px;
}

.tab:hover {
    color: var(--neutral-700);
    background: var(--neutral-100);
}

/* Separador ativo = pílula vermelha sólida (como o "Minhas Tarefas" da AV app) */
.tab.active {
    background: var(--primary-500);
    color: #ffffff;
    border-bottom-color: transparent;
}

/* Grid Layouts */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}

.grid-60-40 {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 24px;
}

/* Dashboard Activity Timeline */
.activity-timeline {
    display: flex;
    flex-direction: column;
}

.activity-item {
    display: flex;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid var(--neutral-100);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-icon {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
}

.activity-icon svg {
    width: 16px;
    height: 16px;
}

.activity-icon.blue {
    background: var(--info-50);
    color: var(--info-500);
}

.activity-icon.green {
    background: var(--success-50);
    color: var(--success-500);
}

.activity-icon.orange {
    background: var(--warning-50);
    color: var(--warning-500);
}

.activity-icon.purple {
    background: var(--primary-50);
    color: var(--primary-500);
}

.activity-content {
    flex: 1;
}

.activity-text {
    font-size: var(--text-sm);
    color: var(--neutral-700);
}

.activity-text strong {
    color: var(--neutral-900);
}

.activity-time {
    font-size: var(--text-xs);
    color: var(--neutral-400);
    margin-top: 4px;
}

/* Kanban Board */
.kanban-board {
    display: flex;
    gap: 10px;
    padding-bottom: 12px;
    min-height: 500px;
}

.kanban-column {
    flex: 1;
    min-width: 0;
    background: var(--neutral-50);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    border: 1px solid var(--neutral-100);
}

.kanban-column-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid var(--neutral-100);
}

.kanban-col-chevron {
    display: none;
}

.kanban-column-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--neutral-800);
}

.kanban-count {
    font-size: var(--text-xs);
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    background: var(--neutral-200);
    color: var(--neutral-600);
}

.kanban-column-body {
    flex: 1;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
}

.kanban-card {
    background: var(--neutral-0);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    border: 1px solid var(--neutral-200);
    cursor: pointer;
    transition: var(--transition-fast);
}

.kanban-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.kanban-card-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--neutral-900);
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.kanban-card-ref {
    font-size: var(--text-xs);
    color: var(--primary-500);
    font-weight: 600;
    margin-bottom: 6px;
}

.kanban-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: var(--text-xs);
    color: var(--neutral-500);
}

.kanban-card-avatar {
    width: 24px;
    height: 24px;
    border-radius: var(--radius-full);
    background: var(--primary-100);
    color: var(--primary-700);
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 22px;
    border-top: 1px solid var(--neutral-100);
}

.pagination-info {
    font-size: var(--text-sm);
    color: var(--neutral-500);
}

.pagination-controls {
    display: flex;
    gap: 4px;
}

.pagination-btn {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--neutral-600);
    transition: var(--transition-fast);
}

.pagination-btn:hover {
    background: var(--neutral-100);
}

.pagination-btn.active {
    background: var(--primary-600);
    color: white;
}

.pagination-btn svg {
    width: 16px;
    height: 16px;
}

.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 22px;
    border-top: 1px solid var(--neutral-100);
    width: 100%;
}
.pag-btn {
    min-width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-sm);
    background: white;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--neutral-600);
    cursor: pointer;
    transition: var(--transition-fast);
    padding: 0 8px;
}
.pag-btn:hover:not(:disabled):not(.active) { background: var(--neutral-50); border-color: var(--primary-300); }
.pag-btn.active { background: var(--primary-600); color: white; border-color: var(--primary-600); cursor: default; }
.pag-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.pag-btn svg { width: 16px; height: 16px; }
.pag-dots { display: inline-flex; align-items: center; padding: 0 4px; color: var(--neutral-400); font-weight: 600; }

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.empty-state svg {
    width: 48px;
    height: 48px;
    color: var(--neutral-300);
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--neutral-600);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: var(--text-sm);
    color: var(--neutral-400);
    max-width: 320px;
}

/* Calendar */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.calendar-header-cell {
    padding: 10px;
    text-align: center;
    font-size: var(--text-xs);
    font-weight: 700;
    color: var(--neutral-500);
    text-transform: uppercase;
}

.calendar-cell {
    padding: 8px;
    min-height: 80px;
    border: 1px solid var(--neutral-100);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    transition: var(--transition-fast);
}

.calendar-cell:hover {
    background: var(--neutral-50);
}

.calendar-cell.today {
    background: var(--primary-50);
    border-color: var(--primary-200);
}

.calendar-day-number {
    font-weight: 600;
    color: var(--neutral-700);
    margin-bottom: 4px;
}

.calendar-event {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    margin-bottom: 2px;
    font-weight: 500;
    cursor: pointer;
}

/* Stats/Bar */
.progress-bar-container {
    width: 100%;
    height: 8px;
    background: var(--neutral-100);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    border-radius: var(--radius-full);
    background: linear-gradient(90deg, var(--primary-500), var(--primary-400));
    transition: width var(--transition-slow);
}

/* Animations */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ---------- Skeleton Screens ---------- */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
.skeleton {
    background: linear-gradient(90deg, var(--neutral-100) 25%, var(--neutral-200) 50%, var(--neutral-100) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: 6px;
}
.skeleton-text { height: 14px; margin-bottom: 8px; }
.skeleton-text.sm { height: 10px; width: 60%; }
.skeleton-text.lg { height: 18px; width: 80%; }
.skeleton-card {
    background: var(--neutral-0);
    border: 1px solid var(--neutral-100);
    border-radius: 12px;
    padding: 20px;
}
.skeleton-kpi {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
}
.skeleton-kpi .skeleton-card {
    flex: 1;
    height: 96px;
}
.skeleton-table-row {
    display: flex;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--neutral-100);
}
.skeleton-table-row > .skeleton { flex: 1; height: 16px; }
.skeleton-table-row > .skeleton:first-child { flex: 0.5; }
.skeleton-table-row > .skeleton:last-child { flex: 0.7; }

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(60px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-in {
    animation: slideUp var(--transition-base) both;
}

.animate-in-delay-1 {
    animation: slideUp var(--transition-base) 50ms both;
}

.animate-in-delay-2 {
    animation: slideUp var(--transition-base) 100ms both;
}

.animate-in-delay-3 {
    animation: slideUp var(--transition-base) 150ms both;
}

.animate-in-delay-4 {
    animation: slideUp var(--transition-base) 200ms both;
}

/* Page Transitions */
.page-transition-out {
    opacity: 0;
    transform: translateY(6px);
}

.page-transition-in {
    animation: slideUp var(--transition-base) both;
}

/* Contenteditable placeholder */
.rich-text-content:empty::before {
    content: attr(data-placeholder);
    color: var(--neutral-400);
    font-style: italic;
    pointer-events: none;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.text-right {
    text-align: right;
}

.text-center {
    text-align: center;
}

.mt-4 {
    margin-top: 16px;
}

.mt-6 {
    margin-top: 24px;
}

.mb-4 {
    margin-bottom: 16px;
}

.gap-4 {
    gap: 16px;
}

/* Chart Container */
.chart-container {
    position: relative;
    width: 100%;
    height: 280px;
}

/* View Toggle */
.view-toggle {
    display: flex;
    background: var(--neutral-100);
    border-radius: var(--radius-md);
    padding: 3px;
}

.view-toggle-btn {
    padding: 6px 14px;
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--neutral-500);
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 6px;
}

.view-toggle-btn:hover {
    color: var(--neutral-700);
}

.view-toggle-btn.active {
    background: var(--neutral-0);
    color: var(--neutral-900);
    box-shadow: var(--shadow-xs);
}

.view-toggle-btn svg {
    width: 14px;
    height: 14px;
}

/* ---------- Custom Date Picker ---------- */
.dp-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
}

.dp-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 14px;
    border: 1.5px solid var(--neutral-200);
    border-radius: var(--radius-lg);
    background: var(--neutral-0);
    cursor: pointer;
    transition: var(--transition-fast);
    font-family: var(--font-family);
    font-size: var(--text-base);
    color: var(--neutral-700);
    min-height: 44px;
}

.dp-display:focus-within {
    border-color: var(--primary-400);
    box-shadow: 0 0 0 3px var(--primary-50);
}

.dp-display:hover {
    border-color: var(--primary-300);
    box-shadow: 0 0 0 3px var(--primary-50);
}

.dp-display.sm {
    padding: 6px 10px;
    font-size: var(--text-sm);
    min-height: 36px;
}

.dp-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    padding: 0;
    margin: 0;
    min-width: 0;
    cursor: text;
    -webkit-appearance: none;
    appearance: none;
}

.dp-input.sm { padding: 0; }

.dp-input::placeholder { color: var(--neutral-400); }

.dp-cal-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    padding: 4px;
}

.dp-icon {
    width: 18px;
    height: 18px;
    color: var(--neutral-400);
    flex-shrink: 0;
    transition: color var(--transition-fast);
    pointer-events: none;
}

.dp-cal-btn:hover .dp-icon, .dp-display:focus-within .dp-icon {
    color: var(--primary-500);
}

.dp-panel {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 1000;
    background: var(--neutral-0);
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-lg);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.06);
    padding: 16px;
    width: 300px;
    animation: dpFadeIn 0.15s ease-out;
}

.dp-panel.dp-above {
    top: auto;
    bottom: calc(100% + 6px);
}

.dp-panel.dp-hidden {
    display: none;
}

@keyframes dpFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.dp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    gap: 4px;
}

.dp-title {
    flex: 1;
    text-align: center;
    font-weight: 600;
    font-size: var(--text-base);
    color: var(--neutral-800);
    white-space: nowrap;
}

.dp-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--neutral-500);
    cursor: pointer;
    transition: var(--transition-fast);
}

.dp-nav:hover {
    background: var(--primary-50);
    color: var(--primary-600);
}

.dp-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0;
    margin-bottom: 4px;
}

.dp-weekdays span {
    text-align: center;
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--neutral-400);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 4px 0;
}

.dp-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.dp-day {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 1;
    border: none;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--neutral-700);
    font-size: var(--text-sm);
    font-family: var(--font-family);
    cursor: pointer;
    transition: var(--transition-fast);
    font-weight: 500;
}

.dp-day:hover:not(.dp-selected) {
    background: var(--primary-50);
    color: var(--primary-600);
}

.dp-day.dp-other {
    color: var(--neutral-300);
}

.dp-day.dp-other:hover {
    color: var(--primary-500);
}

.dp-day.dp-today {
    background: var(--primary-50);
    color: var(--primary-600);
    font-weight: 700;
    position: relative;
}

.dp-day.dp-today::after {
    content: '';
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--primary-500);
}

.dp-day.dp-selected {
    background: var(--primary-600);
    color: white;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.dp-day.dp-selected::after {
    display: none;
}

.dp-day.dp-weekend {
    color: var(--error-500);
}

.dp-day.dp-weekend.dp-other {
    color: rgba(239, 68, 68, 0.3);
}

.dp-day.dp-weekend:hover:not(.dp-selected) {
    background: var(--error-50);
    color: var(--error-600);
}

.dp-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--neutral-100);
}

.dp-today-btn,
.dp-clear-btn {
    padding: 5px 12px;
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--text-xs);
    font-family: var(--font-family);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
}

.dp-today-btn {
    background: var(--primary-50);
    color: var(--primary-600);
}

.dp-today-btn:hover {
    background: var(--primary-100);
}

.dp-clear-btn {
    background: transparent;
    color: var(--neutral-500);
}

.dp-clear-btn:hover {
    background: var(--neutral-100);
    color: var(--neutral-700);
}

/* ========== RESPONSIVE — TABLET (≤1024px) ========== */
@media (max-width: 1024px) {
    /* Sidebar: off-canvas overlay (GPU-accelerated) */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh !important;
        height: 100dvh !important;
        transform: translateX(-100%);
        /* `visibility: hidden` e SEM `will-change`: fechado, o menu tem de
           SAIR da árvore de composição, não ficar só transparente. No iPhone
           (app instalada) o iOS prolonga os pixels do topo do conteúdo para a
           faixa da status bar, e uma camada composta viva com opacity 0
           continuava a entrar nessa mistura — era isso que deixava a faixa
           escurecida DEPOIS de fechar o menu (dono, 27/08, nos dois iPhones).

           O FECHO É INSTANTÂNEO de propósito (transition: none aqui): a
           primeira versão escondia no fim do slide de 280ms, e a faixa só
           voltava ao vermelho passado esse atraso — o dono pediu para o tirar
           de todo. A transição de ABERTURA vive na regra .mobile-open (o
           browser lê a transition do estado de destino), por isso abrir
           continua a deslizar. */
        visibility: hidden;
        transition: none;
        z-index: 1100;
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
    .sidebar.mobile-open {
        transform: translateX(0);
        visibility: visible;
        transition: transform 280ms cubic-bezier(0.32, 0.72, 0, 1);
    }
    /* A tira branca fixa que aqui viveu ("prevents backdrop from tinting
       status bar") era da era black-translucent e saiu a 27/08: em modo
       default o env() é 0 e ela era inerte, e num install translucent pintava
       de BRANCO a zona da status bar por cima do cabeçalho vermelho — pior
       que o problema que resolvia. A cor da faixa é hoje coreografada pelo
       theme-color (abrir menu → preto · fechar → vermelho · login → escuro),
       ver openMobileSidebar/closeMobileSidebar e pintarStatusBar no app.js. */
    /* Backdrop behind sidebar (smooth fade) */
    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.45);
        z-index: 1050;
        -webkit-tap-highlight-color: transparent;
        opacity: 0;
        /* Mesmo padrão do .sidebar acima, e este é o culpado principal: o véu
           cobre o ecrã INTEIRO com rgba preto, e com opacity 0 a camada
           continuava composta — o iOS misturava-a na faixa da status bar e a
           cor "presa" era literalmente o vermelho do cabeçalho × este preto a
           45%. `visibility: hidden` tira-o da composição; `transition: none`
           torna o fecho instantâneo (a faixa volta ao vermelho no mesmo
           frame — o atraso de 280ms da 1.ª versão incomodava o dono). O fade
           de ENTRADA vive na regra .active. */
        visibility: hidden;
        pointer-events: none;
        transition: none;
    }
    .sidebar-backdrop.active {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transition: opacity 280ms cubic-bezier(0.32, 0.72, 0, 1);
    }
    .mobile-sidebar-toggle {
        display: flex;
    }

    /* Grids stack */
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .grid-2,
    .grid-3,
    .grid-60-40 {
        grid-template-columns: 1fr;
    }

    /* Header */
    .main-header {
        padding: 0 16px;
    }

    /* Kanban: accordion on mobile (corte-accordion style) */
    .kanban-board {
        flex-direction: column !important;
        overflow-x: visible;
        min-height: auto !important;
        gap: 0;
    }
    .kanban-column {
        min-width: 0 !important;
        background: transparent;
        border: none;
        border-radius: 0;
    }
    .kanban-column-header {
        cursor: pointer;
        -webkit-tap-highlight-color: rgba(99, 102, 241, 0.1);
        background: var(--neutral-0);
        padding: 12px 16px !important;
        border-radius: var(--radius-lg);
        border: none;
        border-bottom: 2px solid var(--neutral-100);
        margin-bottom: 12px;
        transition: background 0.15s;
    }
    .kanban-column-header:active {
        background: var(--neutral-50);
    }
    .kanban-column.kanban-col-open > .kanban-column-header {
        border-bottom-color: var(--primary-200);
    }
    .kanban-col-chevron {
        display: block !important;
        width: 16px;
        height: 16px;
        color: var(--neutral-400);
        transition: transform 0.2s;
        flex-shrink: 0;
        margin-left: auto;
    }
    .kanban-column .kanban-column-body {
        display: none !important;
    }
    .kanban-column.kanban-col-open .kanban-column-body {
        display: flex !important;
        padding: 0 0 16px 0;
    }
    .kanban-column.kanban-col-open .kanban-col-chevron {
        transform: rotate(180deg);
    }

    /* Férias calendar: 3 cols on tablet */
    .ferias-calendar-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    /* Calendar cells smaller */
    .calendar-cell {
        min-height: 60px;
        padding: 6px;
    }

    /* Command palette */
    .command-palette {
        width: 90vw;
        max-width: 500px;
    }

    /* Notifications dropdown */
    .notifications-dropdown {
        width: 340px;
        right: 8px;
    }

    /* Modal responsive */
    .modal-content {
        width: 95%;
        max-width: 95vw;
    }
    .modal-content.modal-lg {
        max-width: 95vw;
    }
    .modal-content.modal-xl {
        max-width: 95vw;
        width: 95%;
    }
    .modal-content.modal-auto {
        min-width: unset;
        width: 95%;
        max-width: 95vw;
    }
}

/* ========== RESPONSIVE — MOBILE (≤768px) ========== */
@media (max-width: 768px) {
    /* ---- Prevent iOS auto-zoom on input focus ---- */
    input[type="text"],
    input[type="number"],
    input[type="email"],
    input[type="password"],
    input[type="search"],
    input[type="tel"],
    input[type="url"],
    input[type="date"],
    input:not([type]),
    textarea,
    select,
    .form-input,
    .form-select,
    .dp-input,
    .searchable-select input,
    .searchable-select-trigger {
        font-size: 16px !important;
    }

    /* ---- Dashboard tables: NO horizontal scroll, fit screen width ---- */
    .dash-hide-mobile {
        display: none !important;
    }
    /* Page content: prevent ANY horizontal overflow */
    .page-content {
        overflow-x: hidden !important;
    }
    .page-content * {
        max-width: 100vw;
    }
    /* Cards inside grids must not expand beyond grid */
    .grid-2 > *,
    .grid-3 > *,
    .grid-60-40 > * {
        min-width: 0 !important;
        overflow: hidden;
    }
    /* All cards with dashboard tables: force fit within grid */
    .card:has(.dash-tickets-table),
    .card:has(.dash-entregas-table),
    .card:has(.dash-enc-table) {
        max-width: 100%;
        min-width: 0 !important;
        overflow: hidden;
    }
    /* Grid children must not overflow */
    .grid-2 > .card,
    .grid-60-40 > .card {
        min-width: 0 !important;
    }
    .card:has(.dash-tickets-table) .table-container,
    .card:has(.dash-entregas-table) .table-container,
    .card:has(.dash-enc-table) .table-container {
        overflow-x: hidden !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    /* All dash tables: fixed layout, no min-width */
    .dash-tickets-table,
    .dash-entregas-table,
    .dash-enc-table {
        min-width: 0 !important;
        width: 100% !important;
        table-layout: fixed;
    }
    /* All dash cells: compact */
    .dash-tickets-table td, .dash-tickets-table th,
    .dash-entregas-table td, .dash-entregas-table th,
    .dash-enc-table td, .dash-enc-table th {
        font-size: 11px;
        padding: 10px 6px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    /* (hidden columns handled by visibility:collapse above) */
    /* Tickets: Assunto 75%, Cliente 25% */
    .dash-tickets-table th:nth-child(2),
    .dash-tickets-table td:nth-child(2) { width: 75%; }
    .dash-tickets-table th:nth-child(3),
    .dash-tickets-table td:nth-child(3) { width: 25%; }
    /* Entregas: Refª 25%, Data 25%, Estado 50% — badge right-aligned */
    .dash-entregas-table th:nth-child(1),
    .dash-entregas-table td:nth-child(1) { width: 25%; }
    .dash-entregas-table th:nth-child(3),
    .dash-entregas-table td:nth-child(3) { width: 25%; }
    .dash-entregas-table th:nth-child(4),
    .dash-entregas-table td:nth-child(4) { width: 50%; text-align: right; }
    .dash-entregas-table th:nth-child(4) { text-align: right; }
    /* Encomendas: Nº 15%, Forn 28%, Data 24%, Estado 33% — badge right */
    .dash-enc-table th:nth-child(1),
    .dash-enc-table td:nth-child(1) { width: 15%; }
    .dash-enc-table th:nth-child(2),
    .dash-enc-table td:nth-child(2) { width: 28%; }
    .dash-enc-table th:nth-child(3),
    .dash-enc-table td:nth-child(3) { width: 24%; }
    .dash-enc-table th:nth-child(4),
    .dash-enc-table td:nth-child(4) { width: 33%; text-align: right; }
    .dash-enc-table th:nth-child(4) { text-align: right; }
    /* Compact status badges in dashboard */
    .dash-entregas-table .status-badge,
    .dash-enc-table .status-badge {
        font-size: 9px;
        padding: 2px 5px;
        gap: 3px;
        border-width: 0;
    }
    .dash-entregas-table .status-badge::before,
    .dash-enc-table .status-badge::before {
        width: 4px;
        height: 4px;
    }
    /* Encomendas Pendentes header: hide search, clean layout */
    #dashEncFornWrap {
        display: none !important;
    }
    .card:has(.dash-enc-table) .card-header {
        flex-wrap: wrap;
        gap: 8px;
    }
    .card:has(.dash-enc-table) .card-header h3 {
        font-size: var(--text-sm);
    }

    /* KPI 2-col stays, tighter gap */
    .kpi-grid {
        gap: 12px;
    }

    /* Page content */
    .page-content {
        padding: 16px;
    }

    /* Page header stack */
    .page-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 12px;
        margin-bottom: 20px;
    }
    .page-header > div:first-child {
        text-align: center;
    }
    .page-header-actions {
        flex-wrap: wrap;
        gap: 8px;
        justify-content: center;
    }
    .page-title {
        font-size: var(--text-xl);
    }

    /* Filter bar stack */
    .filter-bar {
        gap: 10px;
        padding: 12px 14px;
    }
    .filter-row {
        flex-wrap: wrap;
        gap: 10px;
    }
    .filter-row .filter-group {
        flex: unset;
        width: 100%;
    }
    /* Checkbox + Procurar button side by side, equal halves */
    .filter-actions-row {
        display: flex;
        align-items: center;
        width: 100%;
        gap: 8px;
    }
    .filter-actions-row > * {
        flex: 1;
        justify-content: center;
    }
    .filter-group {
        flex: unset;
        width: 100%;
    }
    .form-input,
    .form-select {
        min-width: 0;
        width: 100%;
    }

    /* Tables: scroll horizontal */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -16px;
        padding: 0 16px;
    }
    .data-table {
        min-width: 600px;
    }
    .data-table thead th {
        padding: 10px 12px;
        font-size: 10px;
    }
    .data-table tbody td {
        padding: 10px 12px;
        font-size: var(--text-xs);
    }
    /* Always show row actions on mobile (no hover) */
    .data-table .row-actions {
        opacity: 1;
    }

    /* Cards tighter */
    .card-header {
        padding: 14px 16px;
    }
    .card-body {
        padding: 16px;
    }

    /* Buttons touch-friendly */
    .btn {
        padding: 10px 16px;
        font-size: var(--text-sm);
    }
    .btn-sm {
        padding: 8px 12px;
    }

    /* Modal: nearly full screen with slight margins all around */
    .modal-overlay {
        align-items: flex-end;
        padding: 0 6px 6px;
    }
    .modal-content {
        width: 100%;
        max-width: calc(100vw - 12px);
        max-height: 91vh;
        border-radius: var(--radius-xl);
        animation: mobileModalSlideUp 0.3s ease-out;
    }
    .modal-content.modal-lg,
    .modal-content.modal-xl,
    .modal-content.modal-auto {
        width: 100%;
        max-width: calc(100vw - 12px);
        max-height: 91vh;
        border-radius: var(--radius-xl);
    }
    .modal-header {
        padding: 16px 18px;
    }
    .modal-header h2 {
        font-size: var(--text-lg);
    }
    .modal-body {
        padding: 16px 14px;
        overflow-x: hidden;
    }
    .modal-footer {
        padding: 14px 18px;
        flex-wrap: wrap;
    }

    /* ======= FASE TABS (Chrome-style) — mobile ======= */
    .fase-tabs {
        padding: 8px 10px 0 !important;
        gap: 4px;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        flex-shrink: 0 !important;
        flex-wrap: nowrap !important;
        align-items: flex-end;
        position: relative;
        top: 0 !important;
        border-radius: 0 !important;
    }
    .fase-tab {
        padding: 10px 14px 8px;
        font-size: 12px;
        min-height: 38px;
        flex-shrink: 0;
        top: 0 !important;
        position: relative;
        border-radius: 8px 8px 0 0;
    }
    .fase-tab .fase-tab-badge {
        font-size: 9px;
        padding: 1px 5px;
        max-width: 72px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .fase-tab-add {
        width: 32px;
        height: 32px;
        min-width: 32px;
        flex-shrink: 0;
        margin-bottom: 2px;
    }

    /* ======= GLOBAL: All modal content must fit inside ======= */
    /* Force every element inside modal-body to respect boundaries */
    .modal-body > * {
        max-width: 100% !important;
        overflow-x: hidden;
    }
    /* Any inline grid inside modals: single column */
    .modal-body [style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }
    /* Inner 2-col grids (field pairs): keep 2 cols but contained */
    .modal-body [style*="grid-template-columns: 1fr 1fr;"],
    .modal-body [style*="grid-template-columns:1fr 1fr;"] {
        grid-template-columns: 1fr 1fr !important;
        gap: 10px 16px !important;
    }
    /* All divs inside modal: no overflow */
    .modal-body div {
        max-width: 100%;
        box-sizing: border-box;
    }
    /* Status badges inside modals: compact */
    .modal-body .status-badge {
        font-size: 9px;
        padding: 2px 6px;
        gap: 3px;
        flex-shrink: 0;
    }
    .modal-body .status-badge::before {
        width: 5px;
        height: 5px;
    }
    /* Tables inside modals: fit width */
    .modal-body .data-table {
        min-width: 0 !important;
        width: 100% !important;
        font-size: 11px;
    }
    .modal-body .data-table td,
    .modal-body .data-table th {
        padding: 8px 6px;
        font-size: 11px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .modal-body .table-container {
        overflow-x: hidden !important;
    }
    /* Info blocks with background: contained */
    .modal-body [style*="background:var(--neutral-50)"] {
        overflow: hidden;
        max-width: 100%;
        box-sizing: border-box;
    }
    /* Form rows and grids inside modals */
    .modal-body .form-grid,
    .modal-body .form-row {
        grid-template-columns: 1fr !important;
    }
    /* Buttons and actions: wrap */
    .modal-body [style*="display:flex"][style*="justify-content:space-between"] {
        flex-wrap: wrap;
        gap: 8px;
    }
    /* Links and text: truncate */
    .modal-body a {
        word-break: break-word;
    }

    /* ======= Obra Detail: section separators ======= */
    .obra-detail-grid {
        grid-template-columns: 1fr !important;
        gap: 0 !important;
    }
    .obra-detail-info {
        padding-bottom: 20px;
        border-bottom: 1px solid var(--neutral-200);
        margin-bottom: 20px;
    }
    .obra-detail-enc {
        padding-bottom: 20px;
        border-bottom: 1px solid var(--neutral-200);
        margin-bottom: 20px;
    }
    .obra-detail-desp {
        padding-bottom: 10px;
    }

    /* Form grid: single col on mobile */
    .form-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }
    .form-row {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    /* Kanban: handled by 768px accordion */

    /* Férias calendar: 2 cols */
    .ferias-calendar-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .ferias-top-bar {
        flex-direction: column;
        gap: 10px;
        padding: 10px 12px;
    }
    .ferias-counters {
        flex-wrap: wrap;
        gap: 12px;
    }
    .ferias-footer {
        flex-direction: column;
        gap: 12px;
    }
    .ferias-submit-form {
        padding: 16px;
    }
    .ferias-actions-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    .ferias-actions-grid > div {
        min-height: auto;
    }
    .ferias-actions-grid h3 {
        font-size: 14px !important;
    }
    .ferias-actions-grid .ferias-submit-form textarea {
        font-size: 14px !important;
    }
    .ferias-actions-grid .ferias-submit-form .btn {
        font-size: 14px !important;
        height: 44px !important;
    }

    /* Gestão de Férias mobile */
    .gestao-ferias-kpi-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }
    .gestao-ferias-kpi .card-body {
        padding: 12px 14px !important;
    }
    .gestao-ferias-kpi .card-body div:last-child {
        font-size: 22px !important;
    }
    .gestao-ferias-card {
        padding: 16px;
    }
    .gestao-ferias-mini-month {
        min-width: 0;
        flex: 1 1 100%;
        max-width: 100%;
        padding: 16px 20px;
        box-sizing: border-box;
    }
    .gestao-ferias-mini-month > div:first-child {
        font-size: 15px !important;
        margin-bottom: 12px !important;
    }
    .gestao-ferias-mini-month > div:nth-child(2) {
        gap: 4px !important;
        font-size: 13px !important;
    }
    .gestao-ferias-mini-month > div:nth-child(2) > div {
        padding: 6px 0 !important;
    }
    .gestao-ferias-mini-cals {
        flex-direction: column;
        width: 100%;
    }
    .gestao-ferias-cal-wrap {
        display: block;
    }
    .gestao-ferias-actions {
        flex-direction: column;
    }
    .gestao-ferias-btn {
        justify-content: center;
        width: 100%;
        padding: 12px 16px;
        font-size: 14px;
    }
    /* History table: same pattern as clients-list-table */
    .gf-hide-mobile {
        display: none !important;
    }
    .gestao-ferias-history {
        table-layout: fixed !important;
        width: 100% !important;
        min-width: 0 !important;
    }
    .gestao-ferias-history td,
    .gestao-ferias-history th {
        padding: 12px 10px;
    }
    .gestao-ferias-history td:first-child,
    .gestao-ferias-history th:first-child {
        width: 28%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .gestao-ferias-history th:nth-child(2),
    .gestao-ferias-history td:nth-child(2) {
        width: 28%;
        text-align: center;
    }
    .gestao-ferias-history th:nth-child(3),
    .gestao-ferias-history td:nth-child(3) {
        width: 16%;
        text-align: center;
    }
    /* nth-child(4) is Motivo — hidden via gf-hide-mobile */
    .gestao-ferias-history th:nth-child(5),
    .gestao-ferias-history td:nth-child(5) {
        width: 28%;
        text-align: right;
    }
    .card:has(.gestao-ferias-history) .gestao-ferias-history-wrap {
        overflow-x: hidden !important;
    }

    /* Calendar (montagens etc) */
    .calendar-grid {
        font-size: var(--text-xs);
    }
    .calendar-cell {
        min-height: 50px;
        padding: 4px;
    }
    .calendar-header-cell {
        padding: 6px 2px;
        font-size: 10px;
    }
    .calendar-event {
        font-size: 9px;
        padding: 1px 4px;
    }

    /* Toast: full width top */
    .toast-container {
        top: 12px;
        right: 12px;
        left: 12px;
    }
    .toast {
        min-width: unset;
        width: 100%;
    }

    /* Command palette */
    .command-palette-overlay {
        padding-top: 10vh;
        padding-left: 12px;
        padding-right: 12px;
    }
    .command-palette {
        width: 100%;
        max-width: 100%;
    }

    /* Notifications dropdown full-width */
    .notifications-dropdown {
        position: fixed;
        top: var(--header-height);
        left: 8px;
        right: 8px;
        width: auto;
    }

    /* User profile dropdown */
    .quick-add-dropdown {
        position: fixed !important;
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        min-width: unset !important;
        width: 100% !important;
        box-shadow: 0 -4px 24px rgba(0,0,0,0.15);
        animation: mobileModalSlideUp 0.25s ease-out;
    }

    /* Breadcrumbs: truncate */
    .breadcrumbs {
        max-width: 200px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Header compact */
    .main-header {
        height: 56px;
        min-height: 56px;
        padding: 0 12px;
    }

    /* Date picker panel: centered on mobile */
    .dp-panel {
        position: fixed;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%);
        width: calc(100vw - 32px);
        max-width: 340px;
        z-index: 1200;
    }
    .dp-panel.dp-above {
        top: 50% !important;
        bottom: auto;
        transform: translate(-50%, -50%);
    }

    /* Multiselect dropdown full-width */
    .multiselect-menu {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        max-height: 60vh;
        z-index: 1200;
    }

    /* Estado dropdown */
    .estado-dropdown-menu {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        max-height: 50vh;
        z-index: 1200;
        min-width: unset;
    }

    /* Searchable select — keep dropdown below the input field on mobile */
    .searchable-select-menu {
        max-height: 180px;
        z-index: 1200;
    }

    /* Tabs scroll horizontal */
    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .tabs::-webkit-scrollbar {
        display: none;
    }
    .tab {
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* RAL color grid */
    .ral-color-grid {
        grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
        gap: 4px;
    }
    .ral-color-option {
        padding: 5px 3px;
    }

    /* Pagination compact */
    .pagination {
        flex-direction: column;
        gap: 10px;
        padding: 12px 16px;
    }
    .pagination-bar {
        flex-direction: column;
        gap: 10px;
        padding: 12px 16px;
    }

    /* Progress bar */
    .progress-bar-container {
        height: 6px;
    }

    /* View toggle */
    .view-toggle {
        flex-wrap: wrap;
    }

    /* Rich text toolbar */
    .rich-text-toolbar {
        padding: 6px 8px;
    }
    .rich-text-toolbar button {
        width: 36px;
        height: 36px;
    }
    .rich-text-content {
        min-height: 100px;
        padding: 12px 14px;
    }

    /* Time entry table — mobile card layout handled in 480px breakpoint */

    /* KPI cards */
    .kpi-card {
        padding: 16px;
    }
    .kpi-value {
        font-size: var(--text-2xl);
    }
    .kpi-card-icon {
        width: 38px;
        height: 38px;
        margin-bottom: 12px;
    }
    .kpi-card-icon svg {
        width: 18px;
        height: 18px;
    }

    /* Activity timeline */
    .activity-item {
        gap: 10px;
        padding: 10px 0;
    }

    /* Login */
    .login-card {
        margin: 16px;
        padding: 28px 24px 24px;
    }

    /* ===== LISTA TICKETS: show ID, Assunto, Estado ===== */
    table:has(#ticketsTableBody) {
        table-layout: fixed !important;
        width: 100% !important;
        min-width: 0 !important;
    }
    /* Hide: Data(3), Prioridade(4), Enviado por(5), Atribuído a(6) */
    table:has(#ticketsTableBody) th:nth-child(3),
    table:has(#ticketsTableBody) td:nth-child(3),
    table:has(#ticketsTableBody) th:nth-child(4),
    table:has(#ticketsTableBody) td:nth-child(4),
    table:has(#ticketsTableBody) th:nth-child(5),
    table:has(#ticketsTableBody) td:nth-child(5),
    table:has(#ticketsTableBody) th:nth-child(6),
    table:has(#ticketsTableBody) td:nth-child(6) {
        display: none !important;
    }
    table:has(#ticketsTableBody) th:nth-child(1),
    table:has(#ticketsTableBody) td:nth-child(1) { width: 40px !important; }
    table:has(#ticketsTableBody) th:nth-child(7),
    table:has(#ticketsTableBody) td:nth-child(7) { width: 85px !important; }
    table:has(#ticketsTableBody) td:nth-child(2) {
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 0;
    }

    /* ===== DESPESAS: show Descrição, Valor, Responsável ===== */
    table:has(#despTableBody) {
        table-layout: fixed !important;
        width: 100% !important;
        min-width: 0 !important;
    }
    /* Hide: Data(1), Categoria(3), Delete btn(6) */
    table:has(#despTableBody) th:nth-child(1),
    table:has(#despTableBody) td:nth-child(1),
    table:has(#despTableBody) th:nth-child(3),
    table:has(#despTableBody) td:nth-child(3),
    table:has(#despTableBody) th:nth-child(6),
    table:has(#despTableBody) td:nth-child(6) {
        display: none !important;
    }
    table:has(#despTableBody) td:nth-child(2) {
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 0;
    }
    table:has(#despTableBody) th:nth-child(4),
    table:has(#despTableBody) td:nth-child(4) { width: 80px !important; }
    table:has(#despTableBody) th:nth-child(5),
    table:has(#despTableBody) td:nth-child(5) { width: 90px !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

    /* ===== LISTA FORNECEDORES: show Nome, Tipo ===== */
    table:has(#fornecedorTableBody) {
        table-layout: fixed !important;
        width: 100% !important;
        min-width: 0 !important;
    }
    /* Hide: NIF(2), Email(4), Telefone(5), Localidade(6) */
    table:has(#fornecedorTableBody) th:nth-child(2),
    table:has(#fornecedorTableBody) td:nth-child(2),
    table:has(#fornecedorTableBody) th:nth-child(4),
    table:has(#fornecedorTableBody) td:nth-child(4),
    table:has(#fornecedorTableBody) th:nth-child(5),
    table:has(#fornecedorTableBody) td:nth-child(5),
    table:has(#fornecedorTableBody) th:nth-child(6),
    table:has(#fornecedorTableBody) td:nth-child(6) {
        display: none !important;
    }
    table:has(#fornecedorTableBody) td:nth-child(1) {
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 0;
    }
    table:has(#fornecedorTableBody) th:nth-child(3),
    table:has(#fornecedorTableBody) td:nth-child(3) { width: 90px !important; }

    /* ===== LISTA ARTIGOS: show Ref, Nome, Fornecedor ===== */
    table:has(#artTableBody) {
        table-layout: fixed !important;
        width: 100% !important;
        min-width: 0 !important;
    }
    /* Hide: Categoria(3), Cor(4), Stock(6), Unidade(7), Preço(8) */
    table:has(#artTableBody) th:nth-child(3),
    table:has(#artTableBody) td:nth-child(3),
    table:has(#artTableBody) th:nth-child(4),
    table:has(#artTableBody) td:nth-child(4),
    table:has(#artTableBody) th:nth-child(6),
    table:has(#artTableBody) td:nth-child(6),
    table:has(#artTableBody) th:nth-child(7),
    table:has(#artTableBody) td:nth-child(7),
    table:has(#artTableBody) th:nth-child(8),
    table:has(#artTableBody) td:nth-child(8) {
        display: none !important;
    }
    table:has(#artTableBody) th:nth-child(1),
    table:has(#artTableBody) td:nth-child(1) { width: 70px !important; }
    table:has(#artTableBody) td:nth-child(2) {
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 0;
    }
    table:has(#artTableBody) td:nth-child(5) {
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }

    /* ===== LISTA ENCOMENDAS: show Nº, Obra, Fornecedor, Estado ===== */
    .card:has(#encTableBody) .table-container {
        overflow-x: hidden !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    table:has(#encTableBody) {
        table-layout: auto !important;
        width: 100% !important;
        min-width: 0 !important;
    }
    /* Hide: Categoria(3), Descrição(5), Data(6), Dias(7), Valor(8), Responsável(9) */
    table:has(#encTableBody) th:nth-child(3),
    table:has(#encTableBody) td:nth-child(3),
    table:has(#encTableBody) th:nth-child(5),
    table:has(#encTableBody) td:nth-child(5),
    table:has(#encTableBody) th:nth-child(6),
    table:has(#encTableBody) td:nth-child(6),
    table:has(#encTableBody) th:nth-child(7),
    table:has(#encTableBody) td:nth-child(7),
    table:has(#encTableBody) th:nth-child(8),
    table:has(#encTableBody) td:nth-child(8),
    table:has(#encTableBody) th:nth-child(9),
    table:has(#encTableBody) td:nth-child(9) {
        display: none !important;
    }
    table:has(#encTableBody) td,
    table:has(#encTableBody) th {
        font-size: 11px;
        padding: 10px 6px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    /* Nº Encomenda */
    table:has(#encTableBody) th:nth-child(1),
    table:has(#encTableBody) td:nth-child(1) { max-width: 90px; }
    /* Obra */
    table:has(#encTableBody) th:nth-child(2),
    table:has(#encTableBody) td:nth-child(2) { max-width: 70px; }
    /* Fornecedor: take remaining space */
    table:has(#encTableBody) td:nth-child(4) { max-width: 0; }
    /* Estado */
    table:has(#encTableBody) th:nth-child(10),
    table:has(#encTableBody) td:nth-child(10) {
        width: 75px;
        text-align: right;
    }
    table:has(#encTableBody) .status-badge {
        font-size: 9px;
        padding: 2px 5px;
        gap: 3px;
        border-width: 0;
    }
    table:has(#encTableBody) .status-badge::before {
        width: 4px;
        height: 4px;
    }

    /* ===== REGISTAR HORAS: KPIs 2+1 ===== */
    .kpi-grid[style*="repeat(3,1fr)"],
    .kpi-grid[style*="repeat(4,1fr)"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* O bloco mobile de «Registar Horas» (tabela → cartoes, ~260 linhas de
       !important) foi apagado com o ecra. O formulario novo ja nasce em cartoes
       colapsaveis (`.mt-linha`), e o botao «Remover periodo» e de largura total
       dentro do cartao — era o icone de 32 px na 8.ª coluna que fazia o auditor
       responsivo acusar 4 sobreposicoes a 320/375/390/414 px. */



    /* ===== LISTA CLIENTES: 3 cols only (Nome, Telefone, Contacto) ===== */
    .clients-hide-mobile {
        display: none !important;
    }
    .clients-list-table {
        table-layout: fixed !important;
        width: 100% !important;
        min-width: 0 !important;
    }
    .clients-list-table .clients-name-cell {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 0;
        width: 45%;
    }
    .clients-list-table th:nth-child(4),
    .clients-list-table td:nth-child(4) {
        width: 28%;
    }
    .clients-list-table th:nth-child(6),
    .clients-list-table td:nth-child(6) {
        width: 27%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .card:has(.clients-list-table) .table-container {
        overflow-x: hidden !important;
    }

    /* ===== LISTA FORNECEDORES: 2 cols only (Nome, Tipo) ===== */
    .fornec-hide-mobile {
        display: none !important;
    }
    .fornecedores-list-table {
        table-layout: fixed !important;
        width: 100% !important;
        min-width: 0 !important;
    }
    .fornecedores-list-table .fornec-name-cell {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 0;
        width: 70%;
    }
    .fornecedores-list-table th:nth-child(3),
    .fornecedores-list-table td:nth-child(3) {
        width: 30%;
        text-align: right;
        overflow: hidden;
    }
    .fornecedores-list-table td:nth-child(3) .status-badge {
        font-size: 10px;
        padding: 2px 6px;
        white-space: nowrap;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        display: inline-block;
    }
    .card:has(.fornecedores-list-table) .table-container {
        overflow-x: hidden !important;
    }
}

/* ========== RESPONSIVE — SMALL MOBILE (≤480px) ========== */
@media (max-width: 480px) {
    /* KPI 2-col on small mobile too */
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px;
    }

    /* Page content tighter */
    .page-content {
        padding: 12px;
    }

    /* Page title smaller */
    .page-title {
        font-size: var(--text-lg);
    }

    /* Header actions */
    .page-header-actions {
        width: 100%;
    }
    .page-header-actions .btn {
        flex: 1;
        justify-content: center;
    }

    /* Modal full height */
    .modal-content,
    .modal-content.modal-lg,
    .modal-content.modal-xl,
    .modal-content.modal-auto {
        max-height: 95vh;
    }

    /* Férias: single col */
    .ferias-calendar-grid {
        grid-template-columns: 1fr;
    }

    /* Gestão de Férias — small mobile */
    .gestao-ferias-kpi-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
    .gestao-ferias-kpi .card-body {
        padding: 10px 12px !important;
    }
    .gestao-ferias-kpi .card-body div:first-child {
        font-size: 10px !important;
    }
    .gestao-ferias-kpi .card-body div:last-child {
        font-size: 20px !important;
    }
    .gestao-ferias-card {
        padding: 14px;
    }
    .gestao-ferias-card-header {
        margin-bottom: 16px;
    }
    .gestao-ferias-obs-input {
        min-height: 70px;
    }

    /* Calendar: day numbers only */
    .calendar-cell {
        min-height: 40px;
        padding: 2px;
    }
    .calendar-header-cell {
        font-size: 9px;
        padding: 4px 0;
    }

    /* Breadcrumbs hide */
    .breadcrumbs {
        max-width: 140px;
    }

    /* Kanban: handled by 768px accordion */

    /* Smaller header avatar */
    .header-avatar {
        width: 30px;
        height: 30px;
        font-size: 10px;
    }

    /* Login */
    .login-card {
        padding: 24px 20px 20px;
    }
    .login-logo-img {
        height: 50px;
    }

    /* Chart container smaller */
    .chart-container {
        height: 200px;
    }
}

/* ========== MOBILE MODAL ANIMATION ========== */
@keyframes mobileModalSlideUp {
    from {
        opacity: 0;
        transform: translateY(100%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========== TOUCH DEVICE IMPROVEMENTS ========== */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .nav-item {
        padding: 12px 12px;
        min-height: 44px;
    }
    .nav-sub-item {
        padding: 10px 12px 10px 44px;
        min-height: 40px;
    }
    /* Row actions always visible */
    .data-table .row-actions {
        opacity: 1;
    }
    /* Disable hover transforms */
    .kpi-card:hover {
        transform: none;
    }
    .btn-primary:hover {
        transform: none;
    }
    .kanban-card:hover {
        transform: none;
    }
    /* Tap highlight */
    .btn, .nav-item, .nav-sub-item, .kanban-card, .tab {
        -webkit-tap-highlight-color: rgba(99, 102, 241, 0.1);
    }
    /* Checkbox larger */
    input[type="checkbox"] {
        min-width: 20px;
        min-height: 20px;
    }
    /* Select touch-friendly */
    .form-select {
        min-height: 44px;
    }
    .form-input {
        min-height: 44px;
    }
}

/* Criar Artigo layout — mobile first: stacked */
.criar-artigo-layout {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 16px;
    align-items: start;
    max-width: 100%;
    box-sizing: border-box;
    padding: 0 4px;
}
.criar-artigo-layout > .card {
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    overflow: hidden;
}
.criar-artigo-layout > .card > .card-body {
    max-width: 100%;
    box-sizing: border-box;
}

/* Desktop: form left + preview right */
@media (min-width: 769px) {
    .criar-artigo-layout {
        grid-template-columns: 3fr 2fr !important;
        gap: 24px;
        padding: 0;
    }
    .criar-artigo-layout > .card:last-child {
        position: sticky;
        top: 24px;
    }
}

@media (max-width: 768px) {
    .criar-artigo-layout > .card > .card-body {
        padding: 16px !important;
    }
    .criar-artigo-layout .form-row {
        grid-template-columns: 1fr !important;
    }
    .criar-artigo-layout .ral-color-grid {
        grid-template-columns: repeat(auto-fill, minmax(54px, 1fr));
    }
}

/* Criar Colaborador — desktop default */
.colab-form-top {
    display: flex;
    gap: 40px;
    align-items: flex-start;
    margin-bottom: 28px;
}
.colab-photo-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    min-width: 140px;
}
.colab-fields-grid {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px 20px;
}
.colab-creds-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px 20px;
}

/* Criar Colaborador — mobile redesign */
@media (max-width: 768px) {
    .colab-form-body {
        padding: 24px 16px !important;
    }
    .colab-form-top {
        flex-direction: column;
        align-items: stretch;
        gap: 24px;
    }
    .colab-photo-area {
        align-items: center;
        padding-bottom: 20px;
        border-bottom: 1px solid var(--neutral-100);
    }
    .colab-fields-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px 12px;
    }
    .colab-creds-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px 12px;
    }
}

/* ======= Rentabilidade Modal — Base Styles ======= */
.rent-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}
.rent-header-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.rent-header-info {
    flex: 1;
    min-width: 0;
}
.rent-header-label {
    font-size: 20px;
    font-weight: 800;
    color: var(--neutral-800);
}
.rent-header-sub {
    font-size: 13px;
    color: var(--neutral-500);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.rent-badge-externo {
    font-size: 10px;
    font-weight: 700;
    color: #d97706;
    background: #fef3c7;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.rent-header-margin {
    text-align: right;
    flex-shrink: 0;
}
.rent-margin-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--neutral-400);
    letter-spacing: 0.5px;
}
.rent-margin-value {
    font-size: 28px;
    font-weight: 800;
    line-height: 1;
}
.rent-kpi-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}
.rent-kpi-card {
    padding: 18px 16px;
    border-radius: 14px;
    position: relative;
    overflow: hidden;
}
.rent-kpi-blue { background: linear-gradient(135deg, #eff6ff, #dbeafe); }
.rent-kpi-red { background: linear-gradient(135deg, #fef2f2, #fee2e2); }
.rent-kpi-green { background: #15803D; }
.rent-kpi-bubble {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
}
.rent-kpi-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}
.rent-kpi-value {
    font-size: 22px;
    font-weight: 800;
}
.rent-decomp {
    margin-bottom: 20px;
}
.rent-decomp-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
}
.rent-decomp-bar {
    display: flex;
    height: 10px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--neutral-100);
}
.rent-decomp-legend {
    display: flex;
    gap: 16px;
    margin-top: 8px;
    flex-wrap: wrap;
}
.rent-legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: var(--neutral-500);
}
.rent-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}
.rent-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.rent-detail-card {
    border-radius: 14px;
    border: 1px solid var(--neutral-100);
    overflow: hidden;
}
.rent-detail-card-header {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid var(--neutral-100);
}
.rent-detail-card-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--neutral-700);
}
.rent-detail-card-amount {
    margin-left: auto;
    font-size: 14px;
    font-weight: 800;
}
.rent-detail-card-body {
    padding: 12px 16px;
    max-height: 140px;
    overflow-y: auto;
}
.rent-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid var(--neutral-50);
}
.rent-detail-row-label {
    font-size: 12px;
    color: var(--neutral-600);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1;
    margin-right: 8px;
}
.rent-detail-row-value {
    font-size: 12px;
    font-weight: 600;
    color: var(--neutral-700);
    flex-shrink: 0;
}
.rent-detail-empty {
    text-align: center;
    padding: 16px 0;
    color: var(--neutral-400);
    font-size: 12px;
}

/* ======= Rentabilidade Modal — Mobile ======= */
@media (max-width: 768px) {
    .rent-header {
        flex-wrap: wrap;
        gap: 12px;
    }
    .rent-header-icon {
        width: 44px;
        height: 44px;
        border-radius: 12px;
    }
    .rent-header-icon i {
        width: 20px !important;
        height: 20px !important;
    }
    .rent-header-label {
        font-size: 17px;
    }
    .rent-header-sub {
        font-size: 12px;
    }
    .rent-header-margin {
        text-align: left;
        width: 100%;
        display: flex;
        align-items: baseline;
        gap: 8px;
        padding: 0 0 0 68px;
    }
    .rent-margin-label {
        font-size: 11px;
    }
    .rent-margin-value {
        font-size: 22px;
    }
    .rent-kpi-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }
    .rent-kpi-card {
        padding: 14px 16px;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    .rent-kpi-label {
        margin-bottom: 0;
        font-size: 11px;
    }
    .rent-kpi-value {
        font-size: 20px;
    }
    .rent-decomp-legend {
        gap: 10px;
    }
    .rent-detail-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    .rent-detail-card-header {
        padding: 10px 14px;
    }
    .rent-detail-card-title {
        font-size: 12px;
    }
    .rent-detail-card-amount {
        font-size: 13px;
    }
    .rent-detail-card-body {
        padding: 10px 14px;
        max-height: 120px;
    }
}

/* ===== LISTA ARTIGOS MOBILE ===== */
@media (max-width: 768px) {
    .artigos-list-table {
        min-width: 0 !important;
        width: 100% !important;
        table-layout: fixed !important;
    }
    /* Hide: Categoria(3), Cor(4), Stock(6), Unidade(7), Preço(8) */
    .artigos-list-table th:nth-child(3),
    .artigos-list-table td:nth-child(3),
    .artigos-list-table th:nth-child(4),
    .artigos-list-table td:nth-child(4),
    .artigos-list-table th:nth-child(6),
    .artigos-list-table td:nth-child(6),
    .artigos-list-table th:nth-child(7),
    .artigos-list-table td:nth-child(7),
    .artigos-list-table th:nth-child(8),
    .artigos-list-table td:nth-child(8) {
        display: none !important;
    }
    /* Ref column: fixed narrow */
    .artigos-list-table th:nth-child(1),
    .artigos-list-table td:nth-child(1) {
        width: 90px !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    /* Nome column: flexible, truncate */
    .artigos-list-table th:nth-child(2),
    .artigos-list-table td:nth-child(2) {
        max-width: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    /* Fornecedor column: flexible, truncate */
    .artigos-list-table th:nth-child(5),
    .artigos-list-table td:nth-child(5) {
        max-width: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* ===== CRIAR EQUIPAMENTO ===== */
.criar-equip-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
@media (max-width: 768px) {
    .criar-equip-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

/* ===== COBRANÇAS MOBILE ===== */
@media (max-width: 768px) {
    .cobrancas-kpi-grid {
        grid-template-columns: 1fr 1fr !important;
    }
    .cobrancas-desktop-table { display: none !important; }
    .cobrancas-mobile-cards { display: block !important; }
}

/* ===== DESPESAS LIST MOBILE ===== */
@media (max-width: 768px) {
    .desp-action-btn {
        width: 100% !important;
        flex: 1 1 100% !important;
        justify-content: center !important;
    }
    .despesas-list-table {
        min-width: 0 !important;
        width: 100% !important;
        table-layout: fixed !important;
    }
    /* Hide: Data(1), Categoria(3), Actions(6) */
    .despesas-list-table th:nth-child(1),
    .despesas-list-table td:nth-child(1),
    .despesas-list-table th:nth-child(3),
    .despesas-list-table td:nth-child(3),
    .despesas-list-table th:nth-child(6),
    .despesas-list-table td:nth-child(6) {
        display: none !important;
    }
    .despesas-list-table td,
    .despesas-list-table th {
        padding: 10px 8px !important;
        font-size: 12px !important;
    }
    /* Descrição */
    .despesas-list-table th:nth-child(2),
    .despesas-list-table td:nth-child(2) {
        width: 40%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    /* Valor */
    .despesas-list-table th:nth-child(4),
    .despesas-list-table td:nth-child(4) {
        width: 28%;
    }
    /* Responsável */
    .despesas-list-table th:nth-child(5),
    .despesas-list-table td:nth-child(5) {
        width: 32%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* ===== VISÃO FINANCEIRA TOP 5 MOBILE ===== */
@media (max-width: 768px) {
    .fin-top5-table {
        min-width: 0 !important;
        width: 100% !important;
        table-layout: fixed !important;
    }
    .fin-top5-table td,
    .fin-top5-table th {
        padding: 10px 8px !important;
        font-size: 12px !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .fin-top5-table th:nth-child(1),
    .fin-top5-table td:nth-child(1) { width: 25%; }
    .fin-top5-table th:nth-child(2),
    .fin-top5-table td:nth-child(2) { width: 30%; }
    .fin-top5-table th:nth-child(3),
    .fin-top5-table td:nth-child(3) { width: 30%; }
    .fin-top5-table th:nth-child(4),
    .fin-top5-table td:nth-child(4) { width: 15%; }
}

/* ===== MANUTENÇÃO MODAL GRID ===== */
.manut-modal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
@media (max-width: 768px) {
    .manut-modal-grid {
        grid-template-columns: 1fr;
    }
    .manut-modal-grid .form-group[style*="grid-column"] {
        grid-column: auto !important;
    }
}

/* ===== MANUTENÇÃO MOBILE ===== */
@media (max-width: 768px) {
    .manut-grid {
        grid-template-columns: 1fr !important;
    }
    /* Próximas Manutenções: fit in card */
    .manut-proximas-table {
        min-width: 0 !important;
        width: 100% !important;
        table-layout: fixed !important;
    }
    .manut-proximas-table td,
    .manut-proximas-table th {
        padding: 10px 8px !important;
        font-size: 12px !important;
    }
    .manut-proximas-table td:first-child,
    .manut-proximas-table th:first-child {
        width: 35%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .manut-proximas-table td:nth-child(2),
    .manut-proximas-table th:nth-child(2) {
        width: 38%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .manut-proximas-table td:nth-child(3),
    .manut-proximas-table th:nth-child(3) {
        width: 27%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .manut-proximas-table .status-badge {
        font-size: 10px !important;
        padding: 2px 6px !important;
    }
    /* Equipamentos Inoperacionais: fit in card */
    .manut-inop-table {
        min-width: 0 !important;
        width: 100% !important;
        table-layout: fixed !important;
    }
    .manut-inop-table td,
    .manut-inop-table th {
        padding: 10px 8px !important;
        font-size: 12px !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .manut-inop-table td:first-child,
    .manut-inop-table th:first-child {
        width: 40%;
    }
    .manut-inop-table td:nth-child(2),
    .manut-inop-table th:nth-child(2) {
        width: 30%;
    }
    .manut-inop-table td:nth-child(3),
    .manut-inop-table th:nth-child(3) {
        width: 30%;
    }
    /* Histórico: hide Tipo(3), Problema(4), Resolução(5), Resp(6) — keep Data, Equip, Custo, Estado */
    .manut-historico-table {
        min-width: 0 !important;
        width: 100% !important;
        table-layout: fixed !important;
    }
    .manut-historico-table th:nth-child(3),
    .manut-historico-table td:nth-child(3),
    .manut-historico-table th:nth-child(4),
    .manut-historico-table td:nth-child(4),
    .manut-historico-table th:nth-child(5),
    .manut-historico-table td:nth-child(5),
    .manut-historico-table th:nth-child(6),
    .manut-historico-table td:nth-child(6) {
        display: none !important;
    }
    .manut-historico-table td,
    .manut-historico-table th {
        padding: 10px 8px !important;
        font-size: 12px !important;
    }
    /* Data */
    .manut-historico-table th:nth-child(1),
    .manut-historico-table td:nth-child(1) {
        width: 25% !important;
    }
    /* Equipamento */
    .manut-historico-table th:nth-child(2),
    .manut-historico-table td:nth-child(2) {
        width: 30% !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    /* Custo */
    .manut-historico-table th:nth-child(7),
    .manut-historico-table td:nth-child(7) {
        width: 20% !important;
    }
    /* Estado */
    .manut-historico-table th:nth-child(8),
    .manut-historico-table td:nth-child(8) {
        width: 25% !important;
    }
    .manut-historico-table .status-badge {
        font-size: 10px !important;
        padding: 2px 6px !important;
    }
}

/* ===== VISÃO FINANCEIRA ===== */
.fin-pipeline-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}
.fin-desp-body {
    display: flex;
    align-items: center;
    gap: 24px;
}
.fin-desp-chart {
    width: 180px;
    height: 180px;
    flex-shrink: 0;
}
.fin-desp-legend {
    flex: 1;
    font-size: 13px;
    color: var(--neutral-500);
}

/* ===== VISÃO FINANCEIRA MOBILE ===== */
@media (max-width: 768px) {
    .fin-pipeline-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px;
    }
    .fin-pipeline-grid .card {
        padding: 14px !important;
    }
    .fin-pipeline-grid .card > div:first-child {
        font-size: 10px !important;
        margin-bottom: 4px !important;
    }
    .fin-pipeline-grid .card > div:nth-child(2) {
        font-size: 18px !important;
    }
    .fin-desp-body {
        flex-direction: column;
        align-items: center;
        gap: 16px;
    }
    .fin-desp-chart {
        width: 160px;
        height: 160px;
    }
    .fin-desp-legend {
        width: 100%;
        text-align: center;
    }
}
@media (max-width: 480px) {
    .fin-pipeline-grid .card > div:nth-child(2) {
        font-size: 16px !important;
        word-break: break-all;
    }
    /* KPI values auto-shrink to fit */
    .kpi-grid .kpi-card .kpi-value {
        font-size: clamp(1rem, 4.5vw, 1.375rem);
        word-break: break-word;
    }
}

/* =====================================================================================
   LOGIN — nada salta enquanto carrega

   O QUE SE VIA: a pessoa abria a página, começava a escrever, e o cartão dava um salto.
   Duas causas somadas:

     1. o logótipo era um `<img>` de www.eficacia.pt SEM altura reservada — até chegar,
        ocupava zero e o cartão nascia 40-60px mais curto;
     2. os `<i data-lucide>` são substituídos por `<svg>` quando o lucide (unpkg) corre.
        O `<i>` está no fluxo; o `<svg>` final é `position:absolute`. A troca mexe no
        layout da linha, e no botão empurra o «Entrar» para o lado ao abrir espaço à seta.

   Resolve-se RESERVANDO ESPAÇO, não escondendo o problema: o logótipo passou a vir
   embutido no HTML (ver index.html) e as caixas dos ícones têm agora a medida final
   desde o primeiro pixel. Mesmo que o CDN do lucide falhe por completo, o formulário
   fica com o aspeto certo e funciona — só sem ícones.

   O spinner que se segue é para o intervalo restante: entre o HTML estar de pé e o
   JavaScript estar pronto a aceitar o `submit`.
   ===================================================================================== */

.login-logo-svg {
    height: 40px;
    width: auto;
    display: block;
}

/* As letras herdam a cor do texto — sem `filter: invert()`, que pintava tudo do mesmo
   tom e era por isso que o asterisco aparecia preto. */
.login-logo-svg .ef-letra {
    fill: currentColor;
}

/* O asterisco é a marca. Vermelho fixo (#e21013, o mesmo do id.svg oficial) e não uma
   variável: é a cor do logótipo, não a cor do tema — se um dia o tema mudar, a marca
   não muda com ele. */
.login-logo-svg .ef-ast {
    fill: #e21013;
}

.login-logo-img-wrap {
    color: var(--neutral-900, #111);
    min-height: 40px;          /* a altura final, desde o início */
}

/* ---- caixas dos ícones reservadas ------------------------------------------------
   O seletor apanha o `<i>` de ANTES e o `<svg>` de DEPOIS com a mesma medida, por isso
   a substituição não move um pixel. */
.login-input-wrap i[data-lucide],
.login-input-wrap svg {
    position: absolute;
    left: 14px;
    width: 18px;
    height: 18px;
    color: var(--neutral-400);
    pointer-events: none;
}

.login-btn i[data-lucide],
.login-btn svg {
    display: inline-block;
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
}

/* ---- spinner até o formulário estar pronto ---------------------------------------
   Cobre o CARTÃO, não o ecrã: quem chega vê logo que aterrou no sítio certo, e o que
   está a carregar é só o formulário. Sai sozinho quando o `app.js` marca
   `data-pronto="1"` — e sai também por um temporizador de segurança, para uma falha
   do CDN não deixar ninguém trancado à porta. */
.login-card {
    position: relative;
}

.login-card[data-pronto="0"] .login-form,
.login-card[data-pronto="0"] .login-footer {
    opacity: 0;
    pointer-events: none;
}

.login-card[data-pronto="0"]::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 62%;
    width: 28px;
    height: 28px;
    margin: -14px 0 0 -14px;
    border: 3px solid var(--neutral-200, #e5e7eb);
    border-top-color: var(--primary-600, #DA0A0D);
    border-radius: 50%;
    animation: loginSpin .7s linear infinite;
}

@keyframes loginSpin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .login-card[data-pronto="0"]::after { animation-duration: 2.4s; }
}

/* =============================================================
   Verde unico da marca (21/08): tudo o que e verde na app usa
   #15803D (o verde dos estados), e os cartoes/badges verdes tem
   letras brancas por dentro. Overrides aos modulos com verdes
   proprios (classes dobradas: os mod-*.css carregam depois).
   ============================================================= */
.fc-corpo.fc-corpo,
.fc-legenda.fc-legenda {
    --fc-sel-bg: rgba(21, 128, 61, 0.30);
    --fc-sel-fg: #0E5A2B;
    --fc-sel-bd: #15803D;
    --fc-aprov-bg: #15803D;
    --fc-aprov-fg: #ffffff;
    --fc-aprov-bd: #15803D;
}

.ds-badge--green.ds-badge--green {
    background: var(--success-500);
    color: #ffffff;
    border-color: var(--success-500);
}

.mt-barra-fill.mt-barra-fill[data-cor="green"] { background: var(--success-500); }
.mt-num--pos.mt-num--pos { color: var(--success-600); }
.mt-badge.mt-badge[data-estado="completo"] { --mt-badge-cor: var(--success-600); }
.mt-ponto.mt-ponto[data-cor="green"],
.mt-ponto.mt-ponto[data-estado="completo"],
.mt-cal-dia.mt-cal-dia[data-estado="completo"] { --mt-cor: var(--success-500); }
.mt-spark-col.mt-spark-col {
    background: linear-gradient(to top, var(--success-500) calc(100% - var(--mt-extra, 0%)), #f59e0b 0);
}

.mf-doc-cel.mf-doc-cel[data-tom="bom"] { border-left-color: var(--success-500); }
.rc-Day--feriasRemovido.rc-Day--feriasRemovido { background: rgba(21, 128, 61, 0.22); color: #0E5A2B; }

/* cartao verde: tudo o que esta dentro em branco */
.rent-kpi-green, .rent-kpi-green * { color: #ffffff; }

/* Sem legendas explicativas debaixo dos graficos (pedido 21/08):
   os textos "Barra clara: ...", "Cada barra filtra a lista", etc.
   saem das paginas. Ficam os avisos funcionais (ex.: cadeado de
   permissoes do mod-artigos) e os sumarios com dados (fo-dash-nota).
   Classes dobradas: os mod-*.css carregam depois do style.css. */
.mp-dash-nota.mp-dash-nota,
.mtk-dash-nota.mtk-dash-nota,
.ma-dash-legenda.ma-dash-legenda,
.fo-dash-graf-sub.fo-dash-graf-sub {
    display: none;
}

/* Bolinhas dos KPIs a cinzento passam a PRETO em toda a plataforma
   (pedido 21/08). Cobre as listagens ds-lst e os mosaicos dos modulos
   com paleta propria; o marcador do ponto (mod-tempo) idem. */
.ds-lst-kpi.ds-lst-kpi[data-cor="gray"],
.mav-kpi.mav-kpi[data-cor="gray"],
.meq-kpi.meq-kpi[data-cor="gray"] {
    --kpi-cor: var(--ink-900, #1B1618);
}

.mt-ponto.mt-ponto[data-cor="gray"] { --mt-cor: var(--ink-900, #1B1618); }

/* Dashboard sem o botao de refrescar (pedido 21/08): o asterisco da
   barra inferior ja faz esse papel, e em desktop os dados chegam
   frescos a cada navegacao. */
.mdb-refrescar.mdb-refrescar { display: none; }

/* Dashboard (mod-home) sem as notas explicativas por baixo dos
   graficos (pedido 21/08) - mesmo criterio das outras legendas. */
.mh-gnota.mh-gnota { display: none; }

/* Mapa de equipamentos: o marcador e o asterisco da marca na cor do
   estado (substitui a bolinha meq-pin-dot; ver pinIcon no JS). */
.meq-pin-ast {
    display: block;
    width: 26px;
    height: 26px;
    font-size: 40px;
    font-weight: 900;
    line-height: 0.4;
    padding-top: 13px;
    box-sizing: border-box;
    text-align: center;
    font-family: var(--font-sans, sans-serif);
    text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 1px 4px rgba(0, 0, 0, .35);
}

/* Nos popups do Leaflet, o CSS do mapa pinta <a> de azul e ganhava
   ao .ds-btn--primary: o "Ver ficha" vermelho fica com letras brancas. */
.leaflet-container a.ds-btn--primary { color: #ffffff; }

/* "De vez em quando fica assim" (21/08): a concha da app e 100vh com
   scroll interno, mas um focus()/scrollIntoView num elemento fora do
   ecra consegue deslocar a janela inteira (mesmo com overflow hidden
   no body), deixando um vazio branco por baixo sem forma de voltar.
   Trava-se tambem o html; o app.js repoe o scroll se algo o mexer. */
html {
    height: 100%;
    overflow: hidden;
}

/* Estados "Em Aberto" (e restantes badges amber) a amarelo solido com
   letras brancas — mesmo padrao dos badges verdes (pedido 21/08). */
.ds-badge--amber.ds-badge--amber {
    background: var(--warning-500, #F59E0B);
    color: #ffffff;
    border-color: var(--warning-500, #F59E0B);
}

/* Ativacoes (21/08): filas de acao em Kanban — as 3 listas lado a
   lado em desktop; e nos cartoes so o TITULO fica na cor do nivel,
   o corpo da mensagem le-se a preto. */
@media (min-width: 1024px) {
    .mav-painel-listas.mav-painel-listas { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Regra geral (21/08): em TODOS os alertas da app so o titulo fica
   na cor do nivel; o corpo da mensagem le-se a preto. */
.ds-alerta .ds-alerta-detalhe {
    color: var(--ink-900, #1B1618);
    opacity: 1;
}

/* Dashboard (mod-home) sem o botao de refrescar do cabecalho (21/08). */
.mh-acao[data-mh-refrescar] { display: none; }

/* Badges de PERFIL dos colaboradores (Admin, Comercial, Producao,
   Externo...) todos a vermelho da marca com letras brancas (21/08). */
.ds-lst-c--cperfil .ds-badge {
    background: var(--brand-500, #DA0A0D);
    color: #ffffff;
    border-color: var(--brand-500, #DA0A0D);
}

/* Status bar do iPhone a vermelho (25/08): com a status bar
   translucida (black-translucent) a app passa por baixo dela; o
   cabecalho cresce a safe-area INTEIRA (altura + padding) e pinta a
   faixa de vermelho. A media query <=768px fixava height:56px e
   anulava o crescimento -- o asterisco da marca de agua ficava com o
   fim das hastes a mostra ("meio cortado"). Estas regras no fim do
   ficheiro vencem todas as MQs. Em desktop env() e 0 e nada muda. */
.main-header {
    height: calc(var(--header-height) + env(safe-area-inset-top, 0px));
    min-height: calc(var(--header-height) + env(safe-area-inset-top, 0px));
    padding-top: env(safe-area-inset-top, 0px);
}

@media (max-width: 768px) {
    .main-header {
        height: calc(56px + env(safe-area-inset-top, 0px));
        min-height: calc(56px + env(safe-area-inset-top, 0px));
    }
}

/* Chips do tipo de negocio nos Equipamentos (28/08): Todos / Outdoors
   e Monopostes / Sinaletica / Digitais — filtram lista, mapa e painel. */
.meq-tipos { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 2px; }
.meq-tipo {
    border: 1px solid rgba(15, 12, 41, 0.12);
    background: #fff;
    border-radius: 9999px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-700, #4A4245);
    cursor: pointer;
    font-family: inherit;
}
.meq-tipo.is-ativo { background: var(--brand-500, #DA0A0D); border-color: var(--brand-500, #DA0A0D); color: #fff; }

/* ============ Clientes e marcas clicáveis nas listagens (reunião 21/08) ============
   Discreto em repouso (herda a cor da célula), sublinha e pinta no hover. */
.ds-lst-cli.ds-lst-cli { color: inherit; text-decoration: none; }
.ds-lst-cli.ds-lst-cli:hover,
.ds-lst-cli.ds-lst-cli:focus-visible { text-decoration: underline; color: var(--primary-500, #DA0A0D); }

/* ============ Cartões de gestão do Dashboard clicáveis (reunião 21/08) ============
   O cartão passou a <button>: repõe-se a herança tipográfica e o alinhamento
   do cartão, e dá-se resposta visual ao rato e ao teclado. */
.mh-gkpi--btn.mh-gkpi--btn {
    font: inherit; color: inherit; text-align: left;
    cursor: pointer; width: 100%;
    transition: transform .12s ease, box-shadow .12s ease;
}
.mh-gkpi--btn.mh-gkpi--btn:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(27, 22, 24, .1); }
.mh-gkpi--btn.mh-gkpi--btn:focus-visible { outline: 2px solid var(--primary-500, #DA0A0D); outline-offset: 2px; }
/* A FAIXA BRANCA DO FUNDO NA APP INSTALADA (27/08, iPhone do dono).

   O caminho dos metas nao chegou: o `black-translucent` esta deprecado e o
   iOS 15-18 aplica-o de forma inconsistente — o dono reinstalou a app com os
   metas certos no ar e a faixa branca por baixo da barra vermelha ficou na
   mesma. O que o iOS faz nesse modo e encaixar a app ENTRE as safe areas
   (env() da 0) e pintar as faixas de cima e de baixo com o FUNDO DA PAGINA
   (html/body) — que aqui era --neutral-0, branco. A faixa sempre la esteve;
   so se tornou visivel quando a barra inferior passou a vermelha.

   A correcao pinta o documento de vermelho SO na app instalada
   (display-mode: standalone): o iOS passa a pintar as duas faixas com o
   vermelho da marca, que casa com o cabecalho em cima e com a pilula em
   baixo. Dentro da app nada muda — .app-layout e o ecran de login cobrem o
   viewport inteiro com os seus proprios fundos. No browser normal e no
   desktop esta media query nunca e verdadeira.

   E se um dia o black-translucent voltar a funcionar (env() > 0), continua
   certo: o cabecalho e a pilula ja pintam as faixas por dentro, e o fundo
   vermelho fica tapado pelo conteudo. */
@media (display-mode: standalone) {

    html,
    body {
        background: var(--primary-500, #DA0A0D);
    }

    /* A faixa acompanha o ECRÃ, não é vermelha fixa (dono, 27/08, iPhone 14):
       no LOGIN o fundo é o gradiente escuro, e uma faixa #DA0A0D em cima dele
       parecia um remendo. Enquanto o ecrã de login está visível, o documento
       pinta-se com o topo do gradiente (#0a0a0a) e o iOS copia essa cor para
       a zona do notch; ao entrar, o login ganha .hidden e volta o vermelho,
       que casa com o cabeçalho. O :not(.auth-reload) cobre o F5 com sessão:
       nesse arranque o login nem chega a ver-se e a faixa nasce logo
       vermelha. `:has()` existe no iOS desde o 15.4 — qualquer iPhone que
       corra esta app instala iOS 16+. */
    html:has(.login-screen:not(.hidden)):not(.auth-reload),
    html:has(.login-screen:not(.hidden)):not(.auth-reload) body {
        background: #0a0a0a;
    }
}
