/* ======================================
   Portal Clientes Contabilidades.pt
   ====================================== */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --success: #16a34a;
    --warning: #f59e0b;
    --danger: #dc2626;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    --radius: 10px;
    --radius-sm: 6px;
    /* Sombras em duas camadas (mais suaves e "elevadas") em vez de uma única
       sombra dura — visual mais atual sem alterar nenhuma disposição. */
    --shadow: 0 1px 2px rgba(15,23,42,.06), 0 1px 1px rgba(15,23,42,.04);
    --shadow-md: 0 4px 10px -2px rgba(15,23,42,.08), 0 2px 4px -2px rgba(15,23,42,.05);
    --shadow-lg: 0 12px 24px -6px rgba(15,23,42,.12), 0 4px 8px -4px rgba(15,23,42,.08);
    --transition: 150ms cubic-bezier(.4,0,.2,1);
}

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

html { overflow-x: hidden; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ======================================
   LOGIN
   ====================================== */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
    padding: 20px;
}

.login-card {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 40px;
    width: 100%;
    max-width: 420px;
}

.login-card .logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-card .logo h1 {
    font-size: 24px;
    color: var(--gray-900);
}

.login-card .logo h1 span { color: var(--primary); }
.login-card .logo p { color: var(--gray-500); font-size: 14px; margin-top: 4px; }

.form-group { margin-bottom: 20px; }
.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 15px;
    transition: border-color .2s;
    outline: none;
    font-family: inherit;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* A regra acima é pensada para inputs de texto — sem isto, qualquer
   checkbox/radio dentro de um .form-group (ex: "Ativo", listas de seleção
   de tarefas) herdava width:100% + padding + borda e ficava um bloco
   gigante em vez de um quadrado pequeno. */
.form-group input[type="checkbox"], .form-group input[type="radio"] {
    width: auto;
    padding: 0;
    border: none;
    flex-shrink: 0;
    accent-color: var(--primary);
}
.form-group input[type="checkbox"]:focus, .form-group input[type="radio"]:focus {
    box-shadow: none;
    outline: 2px solid var(--primary-light);
}
.form-group label input[type="checkbox"],
.form-group label input[type="radio"] {
    margin-right: 6px;
}

.form-group textarea { min-height: 100px; resize: vertical; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition), box-shadow var(--transition), transform var(--transition);
    text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--primary); color: white; box-shadow: 0 1px 2px rgba(37,99,235,.3); }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; box-shadow: 0 2px 6px rgba(37,99,235,.4); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #15803d; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--gray-300);
    color: var(--gray-700);
}
.btn-outline:hover { background: var(--gray-100); }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }

.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 14px;
}
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-info { background: var(--primary-light); color: #1e40af; border: 1px solid #bfdbfe; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }

.alert-close {
    float: right;
    cursor: pointer;
    font-weight: bold;
    background: none;
    border: none;
    font-size: 18px;
    color: inherit;
    opacity: .6;
}
.alert-close:hover { opacity: 1; }

.login-footer { text-align: center; margin-top: 20px; font-size: 14px; color: var(--gray-500); }

/* ======================================
   LAYOUT (logado)
   ====================================== */

.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--gray-900);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,.1);
}

.sidebar-header h2 { font-size: 18px; }
.sidebar-header h2 span { color: #60a5fa; }

.sidebar-header .sub {
    font-size: 12px;
    color: var(--gray-400);
    margin-top: 2px;
}

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    margin: 1px 8px;
    border-radius: var(--radius-sm);
    color: var(--gray-300);
    text-decoration: none;
    font-size: 14px;
    transition: background var(--transition), color var(--transition);
    border-left: 3px solid transparent;
    width: calc(100% - 16px);
}

.sidebar-nav a:hover {
    background: rgba(255,255,255,.08);
    color: white;
    text-decoration: none;
}

.sidebar-nav a.active {
    background: rgba(37,99,235,.18);
    color: #60a5fa;
    border-left-color: var(--primary);
    font-weight: 600;
}

.sidebar-nav a .icon { width: 20px; text-align: center; font-size: 16px; }
.notif-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    padding: 0 5px;
    margin-left: auto;
    line-height: 1;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,.1);
    font-size: 13px;
}

.sidebar-footer .cliente-info { color: var(--gray-400); margin-bottom: 8px; }
.sidebar-footer .cliente-info strong { color: white; display: block; }

.sidebar-footer a {
    color: var(--gray-400);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 0;
}
.sidebar-footer a:hover { color: #fca5a5; }

.main-content {
    margin-left: 260px;
    flex: 1;
    padding: 24px 32px;
    min-height: 100vh;
    overflow-x: hidden;
    min-width: 0;
}

.page-header {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--gray-200);
}

.page-header h1 { font-size: 24px; color: var(--gray-900); }
.page-header p { color: var(--gray-500); font-size: 14px; margin-top: 4px; }

/* ======================================
   CARDS & STATS
   ====================================== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stats-grid:not(.stats-grid-2):not(.stats-grid-3):not(.stats-grid-4):not(.stats-grid-5):not(.stats-grid-6) {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.stats-grid-2 { grid-template-columns: 1fr 1fr; }
.stats-grid-3 { grid-template-columns: repeat(3, 1fr); }
.stats-grid-4 { grid-template-columns: repeat(4, 1fr); }
.stats-grid-5 { grid-template-columns: repeat(5, 1fr); }
.stats-grid-6 { grid-template-columns: repeat(6, 1fr); }

.stat-card {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    transition: box-shadow var(--transition), transform var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.stat-card .label { font-size: 13px; color: var(--gray-500); margin-bottom: 4px; }
.stat-card .value { font-size: 28px; font-weight: 700; color: var(--gray-900); }
.stat-card .sublabel { font-size: 12px; color: var(--gray-400); margin-top: 4px; }

.stat-card.purple { border-left: 4px solid #8b5cf6; }
.stat-card.blue { border-left: 4px solid var(--primary); }
.stat-card.green { border-left: 4px solid var(--success); }
.stat-card.orange { border-left: 4px solid var(--warning); }
.stat-card.red { border-left: 4px solid var(--danger); }

.card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    transition: box-shadow var(--transition);
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: var(--radius) var(--radius) 0 0;
}

.card-header h3 { font-size: 16px; color: var(--gray-800); }

.card-body { padding: 20px; }

/* ======================================
   TABLES
   ====================================== */

.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

table th {
    text-align: left;
    padding: 9px 14px;
    font-weight: 600;
    color: var(--gray-600);
    background: var(--gray-50);
    border-bottom: 2px solid var(--gray-200);
    white-space: nowrap;
    font-size: 12.5px;
    text-transform: uppercase;
    letter-spacing: .5px;
    position: sticky;
    top: 0;
    z-index: 1;
}

table td {
    padding: 9px 14px;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}

/* Zebra subtil — mais fácil seguir uma linha em tabelas longas (Clientes,
   Pagamentos, Tarefas...) sem perder o destaque do hover. */
table tbody tr:nth-child(even) td { background: rgba(248,250,252,.6); }
table tr:hover td { background: var(--primary-light) !important; transition: background var(--transition); }

/* Desktop: minimo 1100px na tabela para caber tudo sem quebrar */
.table-cols-hide { min-width: 1100px; }

/* Nome ocupa mais espaco */
.table-cols-hide td:nth-child(2) { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Desktop: esconder colunas menos relevantes em ecras pequenos (< 1400px) */
@media (max-width: 1400px) {
    .table-cols-hide td:nth-child(4),
    .table-cols-hide th:nth-child(4),
    .table-cols-hide td:nth-child(7),
    .table-cols-hide th:nth-child(7),
    .table-cols-hide td:nth-child(9),
    .table-cols-hide th:nth-child(9) { display: none; }
}

.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--gray-400);
}

.empty-state .big-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ======================================
   BADGES & STATUS
   ====================================== */

.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fef2f2; color: #991b1b; }
.badge-info { background: var(--primary-light); color: #1e40af; }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }
.badge-secondary { background: var(--gray-200); color: var(--gray-700); }

/* ======================================
   FORMS INTERNAS
   ====================================== */

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 768px) { .form-row { grid-template-columns: 1fr; } }

/* ======================================
   UPLOAD
   ====================================== */

.upload-zone {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius);
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all .3s;
    background: var(--gray-50);
}

.upload-zone:hover { border-color: var(--primary); background: var(--primary-light); }
.upload-zone .icon { font-size: 40px; color: var(--gray-400); margin-bottom: 8px; }
.upload-zone p { color: var(--gray-500); font-size: 14px; }
.upload-zone p strong { color: var(--primary); }

/* ======================================
   ADMIN SIDEBAR
   ====================================== */

.sidebar-admin .sidebar-nav a.active {
    background: rgba(37,99,235,.15);
    color: #60a5fa;
    border-left-color: #2563eb;
}

/* ======================================
   FAQ DETAILS
   ====================================== */

details summary {
    list-style: none;
}
details summary::-webkit-details-marker {
    display: none;
}
details summary::before {
    content: '+';
    display: inline-block;
    width: 20px;
    font-weight: bold;
    color: var(--primary);
}
details[open] summary::before {
    content: '-';
}

/* ======================================
   PRAZOS TIMELINE
   ====================================== */

.prazo-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 0;
    border-bottom: 1px solid var(--gray-100);
}

.prazo-item:last-child { border-bottom: none; }

.prazo-item .prazo-data {
    width: 60px;
    text-align: center;
    flex-shrink: 0;
}

.prazo-item .prazo-data .dia {
    font-size: 20px;
    font-weight: 700;
    display: block;
    color: var(--gray-800);
}

.prazo-item .prazo-data .mes {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--gray-500);
    letter-spacing: 1px;
}

.prazo-item .prazo-info { flex: 1; }
.prazo-item .prazo-info strong { display: block; font-size: 15px; }
.prazo-item .prazo-info .desc { font-size: 13px; color: var(--gray-500); }

.prazo-item .prazo-contagem {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    padding: 4px 12px;
    border-radius: 999px;
}

.prazo-urgente .prazo-contagem { background: #fef2f2; color: #991b1b; }
.prazo-proximo .prazo-contagem { background: #fef3c7; color: #92400e; }
.prazo-tranquilo .prazo-contagem { background: #dcfce7; color: #166534; }

/* ======================================
   TICKETS
   ====================================== */

.ticket-item {
    padding: 16px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    margin-bottom: 12px;
    transition: all .2s;
    cursor: pointer;
}

.ticket-item:hover { border-color: var(--primary); }

.ticket-item .topo {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.ticket-item .topo h4 { font-size: 15px; color: var(--gray-800); }
.ticket-item .preview { font-size: 13px; color: var(--gray-500); }
.ticket-item .meta { font-size: 12px; color: var(--gray-400); margin-top: 6px; }

/* ======================================
   PERFIL
   ====================================== */

.perfil-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.perfil-item {}
.perfil-item .label { font-size: 12px; color: var(--gray-500); text-transform: uppercase; letter-spacing: .5px; }
.perfil-item .valor { font-size: 15px; color: var(--gray-800); margin-top: 2px; font-weight: 500; }

/* ======================================
   DASHBOARD NOVO
   ====================================== */

.stat-icon { font-size: 20px; margin-bottom: 4px; }

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--gray-900);
}
.stat-card .stat-label {
    font-size: 13px;
    color: var(--gray-500);
    margin-bottom: 2px;
}
.stat-card .stat-sub {
    font-size: 12px;
    color: var(--gray-400);
}

.dashboard-grid-3 {
    display: grid;
    grid-template-columns: 1.5fr 1.5fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}
.dashboard-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 1024px) {
    .dashboard-grid-3 { grid-template-columns: 1fr 1fr; }
}
.dia-grid { grid-template-columns: 1fr 340px; }
@media (max-width: 768px) {
    .dia-grid { grid-template-columns: 1fr; }
}

/* Ranking */
.ranking-list { }
.ranking-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--gray-100);
}
.ranking-item:last-child { border-bottom: none; }
.ranking-pos {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 13px;
    font-weight: 600;
    background: var(--gray-100);
    color: var(--gray-600);
    flex-shrink: 0;
}
.ranking-pos.top {
    background: var(--primary);
    color: white;
}
.ranking-info { flex: 1; min-width: 0; }
.ranking-info strong { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ranking-meta { font-size: 11px; color: var(--gray-400); }
.ranking-valor {
    font-size: 16px;
    font-weight: 700;
    color: var(--gray-800);
    white-space: nowrap;
}
.ranking-periodo {
    font-size: 11px;
    color: var(--gray-400);
}

/* Prazos */
.prazo-item .prazo-tipo { font-size: 10px; padding: 1px 6px; margin-top: 2px; display: inline-block; }
.prazo-item .prazo-cliente { font-size: 12px; color: var(--gray-500); margin-top: 1px; }

.prazo-data {
    text-align: center;
    flex-shrink: 0;
    width: 50px;
}
.prazo-dia {
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
}
.prazo-mes {
    font-size: 10px;
    text-transform: uppercase;
    color: var(--gray-500);
}
.prazo-dias {
    font-size: 10px;
    color: var(--gray-400);
    margin-top: 2px;
}
.prazo-dias.atrasado { color: var(--danger); font-weight: 600; }

.badge-purple { background: #f3e8ff; color: #6b21a8; }

/* Distribuicao */
.dist-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--gray-100);
}
.dist-item:last-child { border-bottom: none; }
.dist-label { flex: 1; font-size: 13px; color: var(--gray-700); }
.dist-bar-wrapper {
    width: 100px;
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
}
.dist-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #60a5fa);
    border-radius: 4px;
    transition: width .3s;
}
.dist-count { font-size: 14px; font-weight: 600; color: var(--gray-700); width: 30px; text-align: right; }

/* Stats mini */
.stats-mini-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.stat-mini {
    text-align: center;
    padding: 12px;
    background: var(--gray-50);
    border-radius: var(--radius);
}
.stat-mini-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
}
.stat-mini-label {
    font-size: 11px;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-top: 2px;
}

/* Logs */
.log-item {
    display: flex;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--gray-100);
}
.log-item:last-child { border-bottom: none; }
.log-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--gray-100);
    font-size: 13px;
    flex-shrink: 0;
}
.log-content { flex: 1; font-size: 13px; }
.log-content strong { color: var(--gray-800); }
.log-acao { color: var(--gray-500); margin-left: 4px; }
.log-detalhes { font-size: 11px; color: var(--gray-400); margin-top: 2px; }
.log-data { font-size: 11px; color: var(--gray-400); margin-top: 2px; }

/* ======================================
   CALENDARIO
   ====================================== */

.calendar-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.calendar-nav h2 { font-size: 20px; }

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--gray-200);
    border-radius: var(--radius);
    overflow: hidden;
}
.calendar-header {
    background: var(--gray-800);
    color: white;
    text-align: center;
    padding: 8px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.calendar-day {
    background: white;
    min-height: 100px;
    padding: 6px;
    position: relative;
}
.calendar-day.other-month { background: var(--gray-50); }
.calendar-day.today { border: 2px solid var(--primary); }
.calendar-day-number {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-600);
    margin-bottom: 4px;
}
.calendar-day.today .calendar-day-number {
    background: var(--primary);
    color: white;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}
.calendar-events { }
.calendar-event {
    font-size: 10px;
    padding: 2px 4px;
    border-radius: 3px;
    margin-bottom: 2px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--gray-700);
    border-left: 3px solid var(--primary);
    background: var(--gray-50);
}
.calendar-event.atrasado { border-left-color: var(--danger); background: #fef2f2; }
.calendar-event.cumprido { border-left-color: var(--success); background: #f0fdf4; }

@media (max-width: 768px) {
    .calendar-day { min-height: 60px; padding: 4px; }
    .calendar-event { font-size: 8px; }
}

/* ======================================
   COBRANCAS
   ====================================== */

.client-row-risco { background: #fffbeb !important; }

.filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}
.filter-bar input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 14px;
}
.filter-bar select {
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 14px;
}

/* ======================================
   TABS & FILTERS
   ====================================== */

.tab-bar {
    display: flex; gap: 0; margin-bottom: 20px;
    background: #fff; border: 1px solid var(--gray-200);
    border-radius: var(--radius); overflow: hidden;
}
.tab-bar a {
    flex: 1; text-align: center; padding: 10px 14px; font-size: 13px;
    text-decoration: none; color: var(--gray-600); transition: all 0.15s;
    border-right: 1px solid var(--gray-200);
}
.tab-bar a:last-child { border-right: none; }
.tab-bar a.active { background: var(--primary); color: #fff; font-weight: 600; }
.tab-bar a:hover:not(.active) { background: var(--gray-50); }

.mes-nav {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px; background: #fff; border: 1px solid var(--gray-200);
    border-radius: var(--radius); margin-bottom: 20px;
}
.mes-nav select { padding: 6px 10px; border: 1px solid var(--gray-300); border-radius: var(--radius); font-size: 13px; }

/* Matriz mensal */
.matriz-wrapper { overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; }

/* Navegação */
.matriz-nav {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    margin-bottom: 16px; background: #fff;
    border: 1px solid var(--gray-200); border-radius: var(--radius);
    padding: 10px 14px;
}
.matriz-nav-btn {
    text-decoration: none; color: var(--primary); font-size: 18px;
    padding: 6px 10px; border: 1px solid var(--gray-200);
    border-radius: var(--radius); display: inline-flex;
    align-items: center; justify-content: center;
    min-width: 36px; min-height: 36px; transition: all .15s;
}
.matriz-nav-btn:hover { background: var(--gray-50); text-decoration: none; }
.matriz-nav-select {
    font-size: 14px; padding: 8px 10px; border: 1px solid var(--gray-300);
    border-radius: var(--radius); max-width: 130px; background: #fff;
}
.matriz-nav-data {
    font-size: 13px; color: var(--gray-400); margin-left: auto; white-space: nowrap;
}

/* Secção (Empresas / Independentes) */
.matriz-section { margin-bottom: 24px; }
.matriz-section-header {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 8px; padding: 0 4px;
}
.matriz-section-header h3 { margin: 0; font-size: 15px; color: var(--gray-700); }
.matriz-count { font-size: 13px; color: var(--gray-500); }

/* Tabela */
.matriz-table-wrap {
    overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch;
    background: #fff; border: 1px solid var(--gray-200);
    border-radius: var(--radius);
}
.matriz-table-wrap::after {
    content: '';
    display: block;
    height: 1px;
}
.matriz-table-wrap::-webkit-scrollbar { height: 8px; }
.matriz-table-wrap::-webkit-scrollbar-track { background: var(--gray-100); border-radius: 4px; }
.matriz-table-wrap::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 4px; }

.matriz-table {
    width: 100%; border-collapse: collapse; font-size: 12px; min-width: 700px;
}
.matriz-table thead { position: sticky; top: 0; z-index: 2; }

.matriz-th-cliente {
    position: sticky; left: 0; z-index: 3;
    background: var(--gray-800); color: #fff;
    padding: 9px 12px; text-align: left;
    font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
    min-width: 140px; max-width: 180px;
    border-right: 1px solid rgba(255,255,255,.1);
}
.matriz-th {
    background: var(--gray-800); color: #fff;
    padding: 9px 6px; text-align: center;
    font-size: 10px; text-transform: uppercase; letter-spacing: .3px;
    white-space: nowrap; min-width: 52px;
    border-right: 1px solid rgba(255,255,255,.05);
}
.matriz-th:last-child { border-right: none; }

.matriz-tr { border-bottom: 1px solid var(--gray-100); transition: background .1s; }
.matriz-tr:hover { background: var(--gray-50); }
.matriz-tr:last-child { border-bottom: none; }

.matriz-td-cliente {
    position: sticky; left: 0; z-index: 1;
    background: #fff; border-right: 1px solid var(--gray-200);
    padding: 8px 12px; font-weight: 500;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 180px; font-size: 13px;
}
.matriz-tr:hover .matriz-td-cliente { background: var(--gray-50); }
.matriz-td-cliente a { color: inherit; text-decoration: none; }

.matriz-td {
    padding: 4px; text-align: center;
    border-right: 1px solid var(--gray-100);
    vertical-align: middle;
}
.matriz-td:last-child { border-right: none; }

.matriz-na { background: var(--gray-50); }

/* Botão checkbox */
.matriz-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; min-width: 32px; min-height: 32px;
    border: 2px solid var(--gray-300); border-radius: 6px;
    background: #fff; cursor: pointer;
    font-size: 0; color: transparent;
    transition: all .15s ease;
    padding: 0; margin: 0;
    outline: none;
}
.matriz-btn:hover {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.15);
    transform: scale(1.08);
}
.matriz-btn:active { transform: scale(0.95); }
.matriz-btn-done {
    border-color: var(--success); background: var(--success);
    font-size: 16px; color: #fff;
}
.matriz-btn-done:hover {
    border-color: #15803d; background: #15803d;
    box-shadow: 0 0 0 3px rgba(22,163,74,.2);
}
.matriz-btn.loading { opacity: .5; pointer-events: none; }
.matriz-icon { line-height: 1; }

.matriz-footer {
    display: flex; justify-content: flex-end;
    padding: 6px 12px 8px; font-size: 12px; color: var(--gray-500);
}
.matriz-summary { font-weight: 500; }

.matriz-empty {
    text-align: center; padding: 40px; color: var(--gray-400);
    background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius);
}

.text-muted { color: var(--gray-400); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }

/* ======================================
   MOBILE OVERRIDES - Otimizado para telemovel
   ====================================== */
@media (max-width: 768px) {
    /* Login */
    .login-card { padding: 24px 20px; }
    .login-card .logo { margin-bottom: 24px; }
    .login-card .logo h1 { font-size: 20px; }

    /* Sidebar - overlay no mobile */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 260px !important;
        z-index: 100;
        overflow-y: auto;
    }
    .sidebar.open {
        transform: translateX(0);
    }

    /* Sidebar header */
    .sidebar-header { padding: 20px; text-align: left; }

    /* Sidebar nav */
    .sidebar-nav a { justify-content: flex-start; padding: 10px 20px; }
    .sidebar-nav a span { display: inline; }

    /* Sidebar footer */
    .sidebar-footer { padding: 16px 20px; text-align: left; }
    .sidebar-footer .cliente-info { display: block; }
    .sidebar-footer a { justify-content: flex-start; }
    .sidebar-footer a span { display: inline; }

    /* Toggle button fixo no ecra, visivel sempre */
    .sidebar-toggle {
        display: flex !important;
        position: fixed;
        bottom: 20px;
        left: 0;
        width: 40px;
        height: 48px;
        background: var(--gray-800);
        border: 1px solid var(--gray-700);
        border-left: none;
        color: white;
        cursor: pointer;
        align-items: center;
        justify-content: center;
        font-size: 16px;
        border-radius: 0 8px 8px 0;
        z-index: 101;
        padding: 0;
        line-height: 1;
        min-height: 48px;
        touch-action: manipulation;
        transition: left 0.3s ease;
    }
    .sidebar.open ~ .sidebar-toggle { left: 260px; opacity: 0; pointer-events: none; }
    .sidebar-toggle:hover { background: var(--gray-700); }
    .sidebar.open .sidebar-toggle { display: none; }

    /* Overlay */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 99;
    }
    .sidebar-overlay.show { display: block; }

    /* Main content */
    .main-content {
        margin-left: 0 !important;
        padding: 16px;
        padding-top: 12px;
        overflow-x: hidden;
    }

    /* Stats grid */
    .stats-grid { display: flex; flex-wrap: wrap; gap: 10px; width: 100%; max-width: 100%; }
    .stat-card { width: calc(50% - 5px); min-width: 0; flex: 0 1 auto; padding: 14px; box-sizing: border-box; }
    .stat-card .value,
    .stat-card .stat-value { font-size: 22px; }

    /* Cards */
    .card-header { padding: 12px 14px; flex-wrap: wrap; gap: 8px; }
    .card-body { padding: 14px; }

    /* Forms */
    .form-row { grid-template-columns: 1fr; gap: 12px; }
    .form-group { margin-bottom: 14px; }
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* Previne zoom iOS */
        padding: 12px 14px;
    }
    .btn {
        padding: 12px 20px;
        font-size: 16px;
        min-height: 44px;
    }

    /* Tables */
    table { font-size: 13px; }
    table th,
    table td { padding: 8px 10px; }
    .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }

    /* Page header */
    .page-header h1 { font-size: 20px; }

    /* Dashboard grids */
    .dashboard-grid-3,
    .dashboard-grid-2 { grid-template-columns: 1fr; gap: 14px; }

    /* Calendario */
    .calendar-day { min-height: 50px; padding: 3px; }
    .calendar-event { font-size: 8px; }
    .calendar-nav h2 { font-size: 16px; }

    /* Tickets */
    .ticket-item { padding: 12px; }
    .ticket-item .topo { flex-wrap: wrap; gap: 6px; }
    .ticket-item .topo h4 { font-size: 14px; }

    /* Perfil grid */
    .perfil-grid { grid-template-columns: 1fr; }

    /* Prazo items */
    .prazo-item { flex-wrap: wrap; gap: 10px; }

    /* Page header actions */
    .page-header[style*="display:flex"] { flex-direction: column; gap: 10px; align-items: flex-start !important; }

    /* Filter bar */
    .filter-bar { flex-direction: column; gap: 8px; }
    .filter-bar input,
    .filter-bar select { width: 100%; }

    /* Ranking */
    .ranking-item { flex-wrap: wrap; gap: 8px; }
    .ranking-valor { font-size: 14px; }

    /* Distribuicao bars */
    .dist-bar-wrapper { width: 60px; }

    /* Modals em mobile */
    #catalogModal > div,
    .modal-content { width: 95% !important; max-width: none !important; padding: 16px !important; }

    /* Tabela prazos - esconder tipo em mobile */
    .prazos-table th:nth-child(4),
    .prazos-table td:nth-child(4) { display: none; }

    /* Tabelas - esconder colunas menos importantes em mobile */
    .table-cols-hide td:nth-child(3),
    .table-cols-hide th:nth-child(3),
    .table-cols-hide td:nth-child(4),
    .table-cols-hide th:nth-child(4),
    .table-cols-hide td:nth-child(5),
    .table-cols-hide th:nth-child(5),
    .table-cols-hide td:nth-child(7),
    .table-cols-hide th:nth-child(7),
    .table-cols-hide td:nth-child(9),
    .table-cols-hide th:nth-child(9),
    .table-cols-hide td:nth-child(11),
    .table-cols-hide th:nth-child(11) { display: none; }
    .table-cols-hide { min-width: auto; width: 100%; font-size: 11px; }
    .table-cols-hide th,
    .table-cols-hide td { padding: 4px 6px; }
    .table-cols-hide td:nth-child(2) { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

    /* Grid de editar cliente - empilhar em mobile */
    .editar-grid { grid-template-columns: 1fr !important; }

    /* Checkboxes touch - área de toque maior */
    .task-check { 
        width: 36px !important; 
        height: 36px !important; 
        font-size: 16px !important; 
    }

    /* Alertas no calendário - fontes maiores */
    .ca-alerta { font-size: 11px !important; }
    .ca-lista-tag { font-size: 11px !important; }
    .ca-lista-tarefa { font-size: 13px !important; }

    /* Botões de ação em tabelas mobile */
    td .btn-sm { font-size: 13px !important; padding: 8px 12px !important; }

    /* Matriz mensal - mobile */
    .matriz-nav { margin: 0 -16px 16px; border-radius: 0 !important; border-left: none !important; border-right: none !important; padding: 8px 10px !important; gap: 4px; }
    .matriz-nav-btn { min-width: 40px !important; min-height: 40px !important; font-size: 20px !important; }
    .matriz-nav-select { font-size: 15px !important; padding: 10px 12px !important; min-height: 44px !important; max-width: 110px !important; }
    .matriz-nav-data { display: none; }
    .matriz-table-wrap { margin: 0 -16px; border-radius: 0 !important; border-left: none !important; border-right: none !important; overflow-x: auto !important; -webkit-overflow-scrolling: touch !important; }
    /* min-width > viewport garante que o scroll horizontal é activado; width: auto evita que a tabela fique colada ao container */
    .matriz-table { min-width: 750px !important; width: auto !important; font-size: 11px !important; }
    .matriz-th-cliente { min-width: 100px !important; max-width: 120px !important; font-size: 10px !important; padding: 8px 6px !important; white-space: normal !important; line-height: 1.3 !important; box-shadow: 2px 0 4px rgba(0,0,0,.18) !important; }
    .matriz-th { min-width: 42px !important; font-size: 9px !important; padding: 8px 3px !important; white-space: normal !important; line-height: 1.2 !important; word-break: break-word !important; }
    .matriz-td-cliente { min-width: 100px !important; max-width: 120px !important; font-size: 12px !important; padding: 6px 6px !important; box-shadow: 2px 0 3px rgba(0,0,0,.07) !important; }
    .matriz-td { padding: 2px 2px !important; }
    .matriz-btn { width: 34px !important; height: 34px !important; min-width: 34px !important; min-height: 34px !important; border-radius: 7px !important; border-width: 2px !important; }
    .matriz-btn-done { font-size: 18px !important; }
    .matriz-section-header { padding: 0 4px; }
    .matriz-section { margin-bottom: 20px; }
    .matriz-section-header h3 { font-size: 14px !important; }
    .matriz-summary { font-size: 11px !important; }

    /* === CARDS MOBILE - substitui a tabela em ecras pequenos === */
    .matriz-desktop-only { display: none !important; }
    .matriz-mobile-only { display: block !important; }

    .matriz-cards {
        display: flex; flex-direction: column; gap: 12px;
    }
    .matriz-card {
        background: #fff; border: 1px solid var(--gray-200);
        border-radius: var(--radius); overflow: hidden;
    }
    .matriz-card-header {
        background: var(--gray-800); color: #fff;
        padding: 10px 14px; font-size: 14px; font-weight: 600;
    }
    .matriz-card-header a {
        color: #fff; text-decoration: none;
    }
    .matriz-card-tarefas {
        display: grid; grid-template-columns: 1fr 1fr;
        gap: 2px; padding: 6px;
    }
    .matriz-card-item {
        display: flex; align-items: center; gap: 6px;
        padding: 6px 8px; border-radius: 6px;
        font-size: 12px;
    }
    .matriz-card-item-assoc { background: var(--gray-50); }
    .matriz-card-item-na {
        background: transparent; color: var(--gray-300);
    }
    .matriz-card-label {
        flex: 1; font-weight: 500; line-height: 1.2;
        word-break: break-word;
    }
    .matriz-card-na-label {
        color: var(--gray-300); font-size: 11px;
        font-style: italic; width: 100%; text-align: center;
    }
    .matriz-card .matriz-btn {
        width: 34px !important; height: 34px !important;
        min-width: 34px !important; min-height: 34px !important;
    }

    /* Inputs tel em mobile */
    input[type="tel"] { font-size: 16px; }

    /* Pagina de configuracoes - abas responsive */
    [style*="separadores"] a,
    div[style*="display:flex"][style*="border-bottom"] a { font-size: 12px !important; padding: 8px 12px !important; }
}
@media (min-width: 769px) {
    .sidebar-overlay { display: none !important; }
    .sidebar-toggle { display: none !important; }
    .mobile-menu-btn { display: none !important; }
    .matriz-mobile-only { display: none !important; }
}

/* ======================================
   MOBILE EXTRA - Responsivo completo
   ====================================== */
@media (max-width: 768px) {
    /* Stats grids - todos flex 2 colunas */
    .stats-grid-3,
    .stats-grid-4,
    .stats-grid-5,
    .stats-grid-6 { display: flex !important; flex-wrap: wrap !important; gap: 10px !important; }
    .stats-grid-3 .stat-card,
    .stats-grid-4 .stat-card,
    .stats-grid-5 .stat-card,
    .stats-grid-6 .stat-card { width: calc(50% - 5px) !important; min-width: 0 !important; flex: 0 1 auto !important; }
    .stats-grid-2 { gap: 10px !important; }

    /* Stats base (sem classe de contagem) - usa auto-fit */
    .stats-grid:not(.stats-grid-2):not(.stats-grid-3):not(.stats-grid-4):not(.stats-grid-5):not(.stats-grid-6) {
        display: flex !important; flex-wrap: wrap !important; gap: 10px !important;
    }
    .stats-grid:not(.stats-grid-2):not(.stats-grid-3):not(.stats-grid-4):not(.stats-grid-5):not(.stats-grid-6) .stat-card {
        width: calc(50% - 5px) !important; min-width: 0 !important; flex: 0 1 auto !important;
    }

    /* Stat cards mais compactos */
    .stat-card { padding: 12px !important; }
    .stat-card .stat-value,
    .stat-card .value { font-size: 20px !important; }
    .stat-card .stat-label,
    .stat-card .label { font-size: 12px !important; }
    .stat-card .stat-sub { font-size: 11px !important; }

    /* Grids de 2 colunas sem classe */
    div[style*="grid-template-columns: 1fr 1fr"]:not(.stats-grid):not(.dashboard-grid-2):not(.dashboard-grid-3):not(.form-row) {
        grid-template-columns: 1fr !important;
    }

    /* Tabelas - garantir scroll horizontal */
    .card-body > table:not(.matriz-table):not(.conta-corrente-table):not(.extrato-table) {
        display: block; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch;
    }
    .card-body > table:not(.matriz-table) th,
    .card-body > table:not(.matriz-table) td { white-space: nowrap; padding: 6px 8px; font-size: 12px; }

    /* Matriz table - width 100% */
    .matriz-table-wrap { margin: 0 -16px; border-radius: 0 !important; border-left: none !important; border-right: none !important; overflow-x: auto !important; -webkit-overflow-scrolling: touch !important; }
    .matriz-table { min-width: 750px !important; width: 100% !important; font-size: 11px !important; }

    /* Stats mini grid (dashboard) */
    .stats-mini-grid { grid-template-columns: 1fr 1fr !important; gap: 8px; }

    /* Task items */
    .task-item { flex-wrap: wrap; gap: 8px; }
    .task-item .task-cliente { min-width: 120px !important; max-width: 100%; }
    .task-item .task-prazo { min-width: 70px !important; }

    /* Flex containers sem wrap */
    form[style*="gap:4px"],
    div[style*="gap:4px"] { flex-wrap: wrap; }
    form[style*="gap:4px"] input,
    form[style*="gap:4px"] select,
    form[style*="gap:4px"] button,
    div[style*="gap:4px"] input,
    div[style*="gap:4px"] select,
    div[style*="gap:4px"] button,
    .matriz-card .matriz-btn { min-height: 44px; font-size: 16px; }

    /* Grid de tarefas no editar cliente */
    div[style*="minmax(280px,1fr)"] { grid-template-columns: 1fr !important; }

    /* Grid de alertas 2 colunas */
    div[style*="grid-template-columns:1fr 1fr"][style*="gap:8px"] { grid-template-columns: 1fr !important; }

    /* Calendario navegacao */
    .calendar-nav[style*="display:flex"] { flex-wrap: wrap; gap: 8px; }
    .calendar-nav[style*="display:flex"] h2 { width: 100%; text-align: center; order: -1; }

    /* ----------------------------------------
       CONTA CORRENTE - tabela geral (8 colunas)
       ---------------------------------------- */
    /* Esconder colunas: Movimentos (7), Situacao (6) */
    .conta-corrente-table th:nth-child(7),
    .conta-corrente-table td:nth-child(7) { display: none; }
    .conta-corrente-table th:nth-child(6),
    .conta-corrente-table td:nth-child(6) { display: none; }

    /* Extrato movimentos - esconder Categoria (3) e Ref. (4) */
    .extrato-table th:nth-child(3),
    .extrato-table td:nth-child(3),
    .extrato-table th:nth-child(4),
    .extrato-table td:nth-child(4) { display: none; }

    /* ----------------------------------------
       Responsivo EXTRA para ecrãs < 480px (1 coluna)
       ---------------------------------------- */
}

@media (max-width: 480px) {
    .stats-grid-3,
    .stats-grid-4,
    .stats-grid-5,
    .stats-grid-6 { display: flex !important; flex-wrap: wrap !important; gap: 8px !important; }
    .stats-grid-3 .stat-card,
    .stats-grid-4 .stat-card,
    .stats-grid-5 .stat-card,
    .stats-grid-6 .stat-card { width: calc(50% - 4px) !important; min-width: 0 !important; flex: 0 1 auto !important; }

    /* Tabela conta corrente com menos colunas ainda */
    .conta-corrente-table th:nth-child(5),
    .conta-corrente-table td:nth-child(5) { display: none; }

    /* Tabela clientes - core: NIF, Nome, Status, Editar */
    .table-cols-hide td:nth-child(6),
    .table-cols-hide th:nth-child(6),
    .table-cols-hide td:nth-child(8),
    .table-cols-hide th:nth-child(8) { display: none; }

    /* Estatisticas muito pequenas - 1 coluna */
    .stat-card { padding: 10px !important; }
    .stat-card .stat-value,
    .stat-card .value { font-size: 18px !important; }
}

/* ======================================
   DOCS TABLE — específica para documentos.php
   Colunas: Data, Empresa, Origem, Tipo, Nome, Tamanho, Ações
   ====================================== */
.docs-table { width: 100%; }

/* Desktop com sidebar estreita: esconder Origem e Tamanho */
@media (max-width: 1400px) {
    .docs-table td:nth-child(3),
    .docs-table th:nth-child(3),
    .docs-table td:nth-child(6),
    .docs-table th:nth-child(6) { display: none; }
}

/* Mobile: esconder Origem, Tamanho */
@media (max-width: 768px) {
    .docs-table td:nth-child(3),
    .docs-table th:nth-child(3),
    .docs-table td:nth-child(6),
    .docs-table th:nth-child(6) { display: none; }
    .docs-table { min-width: auto; width: 100%; font-size: 11px; }
    .docs-table th, .docs-table td { padding: 4px 6px; }
    .docs-table td:nth-child(5) { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* Mobile pequeno: só Empresa, Nome, Ações */
@media (max-width: 480px) {
    .docs-table td:nth-child(1),
    .docs-table th:nth-child(1),
    .docs-table td:nth-child(4),
    .docs-table th:nth-child(4) { display: none; }
}

/* ── Meu Dia: mobile ── */
@media (max-width: 768px) {
    .dia-grid { gap: 12px !important; }
    .dia-grid .card { margin-bottom: 12px !important; }
    .dia-grid .card-header {
        flex-wrap: wrap !important;
        gap: 6px;
    }
    .dia-grid .card-header h3 { font-size: 14px; }
    .dia-grid .card-header .btn,
    .dia-grid .card-header a.btn { font-size: 10px; padding: 3px 6px; white-space: nowrap; }
    .dia-grid .card-header .badge { font-size: 10px; padding: 1px 5px; }
    .dia-grid .card-body { padding: 8px 10px !important; }
    .dia-grid .card-body [style*="padding:"] {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }
    .dia-grid .page-header { flex-direction: column; align-items: flex-start !important; }
    .dia-grid .page-header h1 { font-size: 20px; }
    .dia-grid .page-header > div:last-child {
        width: 100%;
        justify-content: flex-start !important;
    }
    .dia-grid .page-header .btn {
        font-size: 11px;
        padding: 5px 10px;
        white-space: nowrap;
    }

    /* Items de tarefas — classes td-item / td-body / td-actions */
    .td-item {
        flex-wrap: wrap !important;
        gap: 6px !important;
        padding: 8px 10px !important;
    }
    .td-item .td-body {
        flex: 1 1 calc(100% - 70px) !important;
        min-width: 0 !important;
    }
    .td-item .td-actions {
        flex: 0 0 auto !important;
        width: auto !important;
        margin-left: auto !important;
    }
    .td-item .td-actions .btn {
        font-size: 10px !important;
        padding: 2px 6px !important;
        min-width: 26px;
        text-align: center;
    }
    .td-item .td-check {
        flex: 0 0 auto !important;
    }

    /* Outros items inline (lembretes, prazos, etc) */
    .dia-grid .card-body [style*="display:flex"][style*="align-items:center"] {
        flex-wrap: wrap !important;
        gap: 6px !important;
    }
    .dia-grid .card-body [style*="display:flex"][style*="align-items:center"] .btn {
        font-size: 10px !important;
        padding: 2px 6px !important;
    }

    /* TOConline */
    .toc-cliente-row [style*="padding:9px 16px"] { padding: 8px 12px !important; }
    .toc-cliente-row [style*="padding:5px 16px 5px 34px"] { padding: 5px 10px 5px 24px !important; }
    .toc-cliente-row [style*="font-size:13px"][style*="font-weight:600"] { font-size: 12px !important; }

    /* Formulários */
    #formTarefa .form-row,
    #formLembrete .form-row { flex-direction: column; }
    #formTarefa .form-row .form-group,
    #formLembrete .form-row .form-group { flex: 1 1 auto !important; width: 100%; }

    /* Prazos urgentes */
    .dia-grid [style*="padding:8px 14px"] {
        padding: 6px 10px !important;
        flex-wrap: wrap !important;
    }
}

/* Animação pulse (disponibilidade contabilista) */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}
