* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --primary: #008b4d;
    --primary-dark: #006f3d;
    --secondary: #59b88a;
    --accent: #087f72;
    --warning: #f39c12;
    --danger: #e74c3c;
    --success: #27ae60;
    --bg: #f7faf8;
    --card-bg: #ffffff;
    --text: #172026;
    --text-light: #66727a;
    --border: #dfe8e3;
    --shadow: 0 4px 20px rgba(0,0,0,0.08);
    --shadow-hover: 0 8px 30px rgba(0,0,0,0.12);
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

.header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 1rem 2rem;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo { display: flex; align-items: center; gap: 0.75rem; }

.logo-icon {
    width: 50px;
    height: 50px;
    background: var(--secondary);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.logo-text h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.5px; }
.logo-text p { font-size: 0.75rem; opacity: 0.9; font-weight: 400; }

.company-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255,255,255,0.15);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    backdrop-filter: blur(10px);
}

.company-selector select {
    background: transparent;
    border: none;
    color: white;
    font-size: 0.9rem;
    cursor: pointer;
    outline: none;
}

.company-selector select option { color: var(--text); }

.nav-container {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
    overflow-x: auto;
}

.nav {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    gap: 0.5rem;
}

.nav-item {
    padding: 1rem 1.25rem;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-light);
}

.nav-item:hover { color: var(--primary); background: rgba(0, 139, 77, 0.05); }
.nav-item.active { color: var(--primary); border-bottom-color: var(--primary); }
.nav-item i { font-size: 1rem; }

.main-container { max-width: 1400px; margin: 0 auto; padding: 2rem; }

.tab-content { display: none; animation: fadeIn 0.3s ease; }
.tab-content.active { display: block; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    transition: box-shadow 0.3s ease;
}

.card:hover { box-shadow: var(--shadow-hover); }

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn {
    padding: 0.625rem 1.25rem;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-2px); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #219a52; }
.btn-danger { background: var(--danger); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-secondary { background: var(--text-light); color: white; }
.btn-outline { background: transparent; border: 2px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: white; }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8rem; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.25rem;
}

.form-group { display: flex; flex-direction: column; gap: 0.375rem; }
.form-group label { font-size: 0.875rem; font-weight: 500; color: var(--text); }
.form-group label .required { color: var(--danger); }

.form-control {
    padding: 0.625rem 0.875rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    background: white;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 139, 77, 0.1);
}

textarea.form-control { min-height: 100px; resize: vertical; }

.table-container { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table th {
    background: var(--bg);
    padding: 0.875rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.data-table td { padding: 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:hover { background: rgba(0, 139, 77, 0.02); }

.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    display: inline-block;
}

.badge-success { background: rgba(39, 174, 96, 0.15); color: var(--success); }
.badge-warning { background: rgba(243, 156, 18, 0.15); color: var(--warning); }
.badge-danger { background: rgba(231, 76, 60, 0.15); color: var(--danger); }
.badge-info { background: rgba(0, 139, 77, 0.15); color: var(--primary); }
.badge-assinatura-remota { background: #e1efff; color: #174d83; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: transform 0.3s ease;
}

.stat-card:hover { transform: translateY(-5px); }

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-icon.blue { background: rgba(0, 139, 77, 0.15); color: var(--primary); }
.stat-icon.green { background: rgba(39, 174, 96, 0.15); color: var(--success); }
.stat-icon.orange { background: rgba(243, 156, 18, 0.15); color: var(--warning); }
.stat-icon.red { background: rgba(231, 76, 60, 0.15); color: var(--danger); }
.stat-icon.purple { background: rgba(155, 89, 182, 0.15); color: #9b59b6; }

.stat-info h3 { font-size: 1.75rem; font-weight: 700; color: var(--text); }
.stat-info p { font-size: 0.875rem; color: var(--text-light); }

.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    backdrop-filter: blur(4px);
}

.modal-overlay.active { display: flex; }

.modal {
    background: white;
    border-radius: 16px;
    max-width: 700px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlide 0.3s ease;
}

@keyframes modalSlide {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title { font-size: 1.25rem; font-weight: 600; }

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
    transition: color 0.3s;
}

.modal-close:hover { color: var(--danger); }

.modal-body { padding: 1.5rem; }

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Login padronizado C2 System */
.login-screen {
    background: linear-gradient(145deg, #f7faf8 0%, #edf3f0 100%);
    padding: 24px;
}

.login-modal-card {
    width: min(100%, 410px);
    max-width: 410px;
    border: 1px solid #dfe8e3;
    border-radius: 18px;
    box-shadow: 0 18px 50px rgba(23, 55, 39, 0.14);
    overflow: hidden;
}

.login-brand {
    padding: 28px 32px 0;
    text-align: center;
}

.login-brand img {
    display: block;
    width: 158px;
    height: 158px;
    object-fit: contain;
    margin: 0 auto 10px;
}

.login-brand h1 { margin: 0; font-size: 24px; color: #172026; }
.login-brand p { margin: 7px 0 0; color: #66727a; font-size: 14px; line-height: 1.4; }
.login-modal-card .modal-body { padding: 24px 32px 8px; }
.login-modal-card .form-group { margin-bottom: 16px; }
.login-modal-card .form-group label { margin-bottom: 7px; font-size: 14px; font-weight: 700; }
.login-modal-card .form-control { padding: 12px 13px; border-radius: 9px; font-size: 15px; }
.login-modal-card .form-control:focus { border-color: #008b4d; box-shadow: 0 0 0 3px rgba(0, 139, 77, 0.13); }
.login-modal-card .modal-footer { padding: 4px 32px 32px; border-top: 0; }
.login-modal-card .modal-footer .btn { width: 100%; justify-content: center; padding: 13px; border-radius: 9px; background: #008b4d; border-color: #008b4d; }
.login-modal-card .modal-footer .btn:hover { background: #006f3d; border-color: #006f3d; }

@media (max-width: 480px) {
    .login-screen { padding: 16px; }
    .login-brand { padding: 22px 21px 0; }
    .login-brand img { width: 138px; height: 138px; }
    .login-modal-card .modal-body { padding: 22px 21px 6px; }
    .login-modal-card .modal-footer { padding: 4px 21px 25px; }
}

.alert {
    padding: 1rem 1.25rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert-warning {
    background: rgba(243, 156, 18, 0.1);
    border-left: 4px solid var(--warning);
    color: #d68910;
}

.alert-danger {
    background: rgba(231, 76, 60, 0.1);
    border-left: 4px solid var(--danger);
    color: #c0392b;
}

.alert-success {
    background: rgba(39, 174, 96, 0.1);
    border-left: 4px solid var(--success);
    color: #219a52;
}

.signature-pad {
    border: 2px dashed var(--border);
    border-radius: 8px;
    background: #fafafa;
    cursor: crosshair;
    touch-action: none;
}

.timeline { position: relative; padding-left: 2rem; }

.timeline::before {
    content: '';
    position: absolute;
    left: 0.5rem;
    top: 0; bottom: 0;
    width: 2px;
    background: var(--border);
}

.timeline-item { position: relative; padding-bottom: 1.5rem; }

.timeline-item::before {
    content: '';
    position: absolute;
    left: -1.5rem;
    top: 0.25rem;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary);
    border: 3px solid white;
    box-shadow: 0 0 0 2px var(--primary);
}

.timeline-content { background: var(--bg); padding: 1rem; border-radius: 8px; }
.timeline-date { font-size: 0.75rem; color: var(--text-light); margin-bottom: 0.25rem; }

.charts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); gap: 1.5rem; }
.chart-container { position: relative; height: 300px; }

.employee-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg);
    border-radius: 12px;
    margin-bottom: 1rem;
}

.employee-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    font-weight: 600;
}

.employee-info h4 { font-weight: 600; margin-bottom: 0.25rem; }
.employee-info p { font-size: 0.875rem; color: var(--text-light); }

.search-bar { display: flex; gap: 0.75rem; margin-bottom: 1.5rem; flex-wrap: wrap; }

.search-input { flex: 1; min-width: 200px; position: relative; }

.search-input i {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
}

.search-input input {
    width: 100%;
    padding: 0.625rem 0.875rem 0.625rem 2.5rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
}

.checkbox-group { display: flex; flex-direction: column; gap: 0.5rem; }

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    transition: background 0.2s;
}

.checkbox-item:hover { background: var(--bg); }

.checkbox-item input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); }
.checkbox-item input[type="radio"] { width: 18px; height: 18px; accent-color: var(--primary); }

.footer {
    background: var(--primary-dark);
    color: white;
    text-align: center;
    padding: 1.5rem;
    margin-top: 3rem;
}

.footer p { opacity: 0.8; font-size: 0.875rem; }

@media (max-width: 768px) {
    .header-content { flex-direction: column; text-align: center; }
    .nav { gap: 0; }
    .nav-item { padding: 0.875rem 1rem; font-size: 0.8rem; }
    .main-container { padding: 1rem; }
    .stats-grid { grid-template-columns: 1fr; }
    .charts-grid { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
}

@media print {
    .header, .nav-container, .btn, .modal-overlay, .footer { display: none !important; }
    .tab-content { display: block !important; }
}

.sub-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border);
}

.sub-tab {
    padding: 0.75rem 1.25rem;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-weight: 500;
    color: var(--text-light);
    transition: all 0.3s;
}

.sub-tab:hover { color: var(--primary); }
.sub-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.sub-content { display: none; }
.sub-content.active { display: block; }

.epi-list-container {
    background: var(--bg);
    border-radius: 8px;
    padding: 1rem;
    margin-top: 0.5rem;
}

.epi-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: white;
    padding: 0.375rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    margin: 0.25rem;
    border: 1px solid var(--border);
}

.epi-tag .remove { cursor: pointer; color: var(--danger); font-weight: bold; }

.dashboard-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 1.5rem; }

@media (max-width: 1024px) { .dashboard-grid { grid-template-columns: 1fr; } }

.alerts-container { max-height: 400px; overflow-y: auto; }

.alert-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
    border-left: 4px solid var(--warning);
    background: rgba(243, 156, 18, 0.05);
    margin-bottom: 0.75rem;
    border-radius: 0 8px 8px 0;
}

.alert-item.danger { border-left-color: var(--danger); background: rgba(231, 76, 60, 0.05); }
.alert-item.info { border-left-color: var(--primary); background: rgba(0, 139, 77, 0.05); }

.alert-icon { font-size: 1.25rem; }
.alert-content { flex: 1; }
.alert-title { font-weight: 600; font-size: 0.9rem; margin-bottom: 0.25rem; }
.alert-desc { font-size: 0.8rem; color: var(--text-light); }

.cargo-row {
    background: var(--bg);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
}

.ficha-epi-document {
    background: white;
    padding: 2rem;
    border: 1px solid #ccc;
    font-family: 'Times New Roman', serif;
    max-width: 800px;
    margin: 0 auto;
}

.ficha-header { text-align: center; margin-bottom: 2rem; border-bottom: 2px solid #333; padding-bottom: 1rem; }
.ficha-title { font-size: 1.5rem; font-weight: bold; margin-bottom: 0.5rem; }
.ficha-subtitle { font-size: 0.9rem; color: #666; }
.ficha-section { margin-bottom: 1.5rem; }
.ficha-section h4 { border-bottom: 1px solid #ddd; padding-bottom: 0.5rem; margin-bottom: 1rem; }

.ficha-table { width: 100%; border-collapse: collapse; margin: 1rem 0; }
.ficha-table th, .ficha-table td { border: 1px solid #333; padding: 0.5rem; text-align: left; }
.ficha-table th { background: #f0f0f0; }

.ficha-texto { text-align: justify; font-size: 0.85rem; line-height: 1.6; margin: 1rem 0; }

.ficha-assinatura { margin-top: 3rem; display: flex; justify-content: space-between; }
.ficha-assinatura-box { width: 45%; text-align: center; }
.ficha-assinatura-line { border-top: 1px solid #333; margin-top: 3rem; padding-top: 0.5rem; }

/* Identidade C2 System: mesma marca e paleta do login AEP. */
.app-brand { flex-direction: row; gap: 1rem; }
.app-brand-logo {
    display: block;
    width: 88px;
    height: 88px;
    object-fit: contain;
    flex-shrink: 0;
    padding: 4px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 3px 12px rgba(0, 0, 0, .12);
}
.app-brand-text { display: flex; flex-direction: column; text-align: left; }
.app-brand-text .logo-text h1 { letter-spacing: -.5px; }
@media (max-width: 768px) {
    .header { padding: 1rem; }
    .app-brand-logo { width: 72px; height: 72px; }
    .header-content > div:last-child { flex-wrap: wrap; justify-content: center; gap: .75rem; }
    .company-selector { max-width: 100%; }
    .company-selector select { min-width: 0; max-width: 190px; }
}

/* Login responsivo 20261014 */
#loginModal {
    box-sizing: border-box;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 16px;
    overflow: auto;
}
#loginModal .login-modal-card {
    box-sizing: border-box;
    flex: 0 1 410px;
    width: 100%;
    min-width: 0;
    max-width: 410px;
    max-height: none;
    margin: auto;
    overflow: visible;
}
#loginModal .login-brand,
#loginModal .modal-body,
#loginModal .modal-footer,
#loginModal .form-control { box-sizing: border-box; min-width: 0; max-width: 100%; }
#loginModal .login-brand h1,
#loginModal .login-brand p { overflow-wrap: anywhere; }
#loginModal .form-control { width: 100%; font-size: 16px; }
@media (max-width: 480px) {
    #loginModal .login-brand { padding: 20px 20px 0; }
    #loginModal .modal-body { padding: 20px 20px 6px; }
    #loginModal .modal-footer { padding: 4px 20px 24px; }
}
/* Celular e assinatura - 20261014 */
#signaturePad.signature-pad,
#signaturePadPendente.signature-pad {
    display: block;
    width: 100%;
    max-width: 100%;
    height: 180px;
    padding: 0;
    border: 0;
    box-shadow: inset 0 0 0 2px var(--border);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}
@media screen and (max-width: 768px) {
    html, body { width: 100%; min-width: 0; }
    .header { position: relative; padding: 12px; }
    .header-content, .header-content > div { width: 100%; min-width: 0; }
    .header-content > div:last-child { display: flex; flex-wrap: wrap; gap: 8px; }
    .header-content > div:last-child > button { margin-left: 0 !important; flex: 1 1 auto; }
    .app-brand { justify-content: center; }
    .app-brand-text { min-width: 0; }
    .company-selector { width: 100%; min-width: 0; padding: 8px 12px; }
    .company-selector select { flex: 1; width: 0; min-width: 0; max-width: none; }
    .nav-container { padding: 0; max-width: 100%; overscroll-behavior-x: contain; }
    .nav { width: max-content; min-width: 100%; }
    .nav-item { min-height: 48px; flex-shrink: 0; }
    .main-container { width: 100%; min-width: 0; padding: 12px; }
    .tab-content, .card, .card-header, .page-header, .form-group { min-width: 0; max-width: 100%; }
    .card { padding: 14px; margin-bottom: 14px; border-radius: 12px; }
    .card-header, .page-header, .filters { flex-wrap: wrap; gap: 10px; }
    .card-header .btn { flex: 1 1 auto; }
    .stats-grid, .charts-grid, .dashboard-grid, .form-grid { grid-template-columns: minmax(0, 1fr) !important; gap: 12px; }
    .main-container [style*="grid-template-columns"],
    .modal-body [style*="grid-template-columns"]:not(#fichaContent, #fichaContent *) {
        grid-template-columns: minmax(0, 1fr) !important;
    }
    .main-container [style*="min-width"],
    .modal-body [style*="min-width"]:not(#fichaContent, #fichaContent *) { min-width: 0 !important; }
    .form-grid > *, .modal-body [style*="grid-template-columns"] > * { min-width: 0; }
    .form-control, .search-input, select, textarea { min-width: 0; max-width: 100%; }
    input:not([type="checkbox"]):not([type="radio"]):not([type="color"]), select, textarea { font-size: 16px !important; }
    .form-control, .btn { min-height: 44px; }
    .btn { white-space: normal; overflow-wrap: anywhere; }
    .search-input { flex: 1 1 100%; }
    .table-container { width: 100%; max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
    .data-table { min-width: 640px; }
    .data-table th, .data-table td { padding: 10px; }
    .sub-tabs { max-width: 100%; overflow-x: auto; }
    .sub-tab { white-space: nowrap; flex-shrink: 0; min-height: 44px; }
    .modal-overlay { padding: 12px; height: 100vh; height: 100dvh; overflow-y: auto; }
    .modal-overlay .modal {
        min-width: 0; width: 100%; max-width: 100% !important;
        max-height: calc(100vh - 24px) !important;
        max-height: calc(100dvh - 24px) !important;
        display: flex; flex-direction: column; overflow-y: auto;
    }
    .modal > form { min-height: 0; max-height: inherit; display: flex; flex-direction: column; }
    .modal-header { padding: 12px 14px; gap: 8px; flex-shrink: 0; }
    .modal-title { min-width: 0; overflow-wrap: anywhere; font-size: 18px; }
    .modal-close { min-width: 44px; min-height: 44px; flex-shrink: 0; }
    .modal-body { padding: 14px; min-width: 0; min-height: 0; overflow-y: auto; }
    .modal-footer { padding: 12px 14px; gap: 8px; flex-wrap: wrap; flex-shrink: 0; }
    .modal-footer .btn { flex: 1 1 130px; margin: 0; }
    #loginModal .login-modal-card { max-width: 410px !important; flex-shrink: 0; }
    .checkbox-group { display: flex; flex-direction: column; align-items: stretch; }
    .checkbox-item { flex-wrap: wrap; gap: 8px; min-height: 44px; }
    #motivoOutro { width: 100%; min-width: 0; margin-left: 0 !important; min-height: 44px; }
    #entregaItensContainer > div > div:first-child { flex-wrap: wrap; gap: 8px; }
    .chart-container { min-width: 0; max-width: 100%; }
    .footer { padding: 16px 12px; }
    #fichaModal .modal-body { overflow-x: auto; }
    #fichaContent { min-width: 680px; }
}

/* Saudacao acima dos botoes da conta */
.account-menu { display:flex; flex-direction:column; align-items:flex-end; gap:6px; margin-left:16px; min-width:0; }
.account-menu #usuarioSaudacao { font-size:1rem; font-weight:600; overflow-wrap:anywhere; max-width:320px; text-align:right; }
.account-actions { display:flex; gap:8px; }
@media screen and (max-width:768px) {
    .account-menu { width:100%; margin-left:0; align-items:stretch; }
    .account-menu #usuarioSaudacao { max-width:100%; text-align:left; }
    .account-actions .btn { flex:1 1 0; min-width:0; margin:0; }
}

/* Login: mesmas medidas do AEP, isoladas dos modais internos */
#loginModal.login-screen {
    padding:24px; height:100vh; height:100dvh;
    flex-direction:row; overflow:auto;
    font-family:Arial,Helvetica,sans-serif; line-height:normal;
}
#loginModal #epiLoginForm {
    display:block!important; flex:0 1 auto!important;
    width:min(100%,410px)!important; max-width:410px!important;
    min-width:0; max-height:none!important; margin:auto;
    padding:32px; box-sizing:border-box; overflow:visible;
}
#loginModal .login-brand { padding:0; margin-bottom:24px; }
#loginModal .login-brand img { width:158px; height:158px; margin:0 auto 10px; }
#loginModal .login-brand h1 { font-size:24px; margin:0; line-height:normal; }
#loginModal .login-brand p { font-size:14px; margin:7px 0 0; line-height:1.4; }
#loginModal .form-group { margin-bottom:16px; }
#loginModal .form-group label { display:block; margin-bottom:7px; font-size:14px; font-weight:700; line-height:normal; }
#loginModal .form-control { width:100%; padding:12px 13px; border:1px solid #cbd7d1; border-radius:9px; font-size:15px; line-height:normal; min-height:0; }
#loginModal .login-submit { display:block; width:100%; min-height:0; padding:13px; margin-top:4px; border:0; border-radius:9px; font-size:15px; font-weight:700; line-height:normal; justify-content:center; background:#008b4d; }
#loginModal .login-submit:hover { background:#006f3d; }
#loginModal .login-forgot { display:block; width:100%; min-height:0; margin-top:14px; padding:0; border:0; background:transparent; color:#008b4d; text-align:center; font-family:inherit; font-size:14px; font-weight:700; line-height:normal; cursor:pointer; }
#loginModal .login-forgot:hover { text-decoration:underline; }
#loginModal .login-error { min-height:18px; margin:12px 0 0; font-size:13px; text-align:center; color:#b42318; }
@media screen and (max-width:480px) {
    #loginModal.login-screen { padding:16px; }
    #loginModal #epiLoginForm { padding:25px 21px; }
    #loginModal .login-brand img { width:138px; height:138px; }
}

/* Controles de listas, fora da rolagem horizontal da tabela. */
.pagina-oculta { display: none !important; }
.paginacao { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:1rem; padding:1rem 0 .25rem; border-top:1px solid var(--border-color, #e1e8e5); margin-top:.75rem; font-size:.875rem; color:var(--text-light, #64756f); }
.paginacao label { display:flex; align-items:center; gap:.5rem; margin:0; white-space:nowrap; }
.paginacao select { width:auto; padding:.45rem .65rem; border:1px solid #d9e3de; border-radius:8px; background:var(--white,#fff); color:var(--text-dark,#243b32); }
.paginacao-botoes { display:flex; align-items:center; gap:.35rem; }
.paginacao button { width:34px; height:34px; border:1px solid #d9e3de; border-radius:8px; background:#fff; color:var(--primary-color,#008554); cursor:pointer; font-size:1.2rem; }
.paginacao button:hover:not(:disabled) { background:#edf7f1; }
.paginacao button:disabled { opacity:.4; cursor:default; }
.paginacao button:focus-visible,.paginacao select:focus-visible { outline:2px solid var(--primary-color,#008554); outline-offset:2px; }
.paginacao-numero { min-width:55px; text-align:center; font-variant-numeric:tabular-nums; }
@media(max-width:600px) { .paginacao { gap:.75rem; } .paginacao-contador { order:3; width:100%; } }

/* Contenção de conteúdo e formulários em celular, tablet e notebook. */
.header-content > *, .header-content .company-selector, .header-content .account-menu { min-width: 0; }
.company-selector { max-width: 100%; }
.company-selector select { min-width: 0; max-width: 100%; }
.main-container, .tab-content, .card, .form-group { min-width: 0; }
.modal-overlay { padding: 12px; }
.modal { max-width: calc(100vw - 24px); max-height: calc(100dvh - 24px); overflow-y: auto; }
.modal-body { min-width: 0; }
.form-control { max-width: 100%; }
.epi-picker { position: relative; min-width: 0; width: 100%; }
.epi-picker-native { position: absolute !important; width: 1px !important; height: 1px !important; opacity: 0; pointer-events: none; padding: 0 !important; }
.epi-picker-button { width: 100%; text-align: left; height: auto !important; min-height: 44px; white-space: normal; overflow-wrap: anywhere; padding-right: 30px !important; position: relative; cursor: pointer; }
.epi-picker-button::after { content: '▾'; position: absolute; right: 10px; top: 12px; }
.epi-picker-button[aria-invalid=true] { border-color: #c62828; }
.epi-picker-popup { position: fixed; z-index: 20000; display: flex; flex-direction: column; gap: 8px; padding: 10px; background: white; color: #20302c; border: 1px solid #b8ccc4; border-radius: 10px; box-shadow: 0 6px 26px #0003; overflow: hidden; box-sizing: border-box; }
.epi-picker-topo { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-shrink: 0; }
.epi-picker-popup > input { width: 100%; flex-shrink: 0; min-height: 44px; font-size: 16px; }
.epi-picker-options { overflow-y: auto; min-height: 0; overscroll-behavior: contain; }
.epi-picker-options button { display: block; width: 100%; min-height: 44px; text-align: left; white-space: normal; overflow-wrap: anywhere; border: 0; border-bottom: 1px solid #e3ebe7; padding: 12px; background: white; color: inherit; font: inherit; cursor: pointer; }
.epi-picker-options button:hover, .epi-picker-options button:focus, .epi-picker-options button[aria-selected=true] { background: #e3f4eb; outline-offset: -2px; }
@media (max-width: 1024px) {
 .header-content > div:last-child { max-width: 100%; flex-wrap: wrap; gap: 10px; }
 .form-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
}
@media (max-width: 768px) {
 .paginacao button, .paginacao select, .modal-close { min-width: 44px; min-height: 44px; }
 .page-header h2, .card-header h3, .modal-title { overflow-wrap: anywhere; min-width: 0; }
 .modal-header { gap: 8px; }
 .modal-header > h3 { min-width: 0; }
 .modal-close { flex-shrink: 0; }
}
@media (pointer: coarse) {
 .btn, .modal-close, .paginacao button, .paginacao select { min-height: 44px; }
 .modal-close, .paginacao button { min-width: 44px; }
}
@media (max-width: 768px) {
 #loginModal .login-forgot, #loginModal .login-submit { min-height: 44px; }
}

/* Identidade da unidade no seletor do cabeçalho. */
.company-logo-wrap{display:flex;align-items:center;justify-content:center;flex:0 0 auto;max-width:44px}
#companyHeaderLogo{display:block;width:40px;height:34px;padding:3px;object-fit:contain;background:#fff;border-radius:5px}
#companyHeaderLogo[hidden],#companyHeaderBuilding[hidden]{display:none!important}
#linkAssinaturaModal [hidden],#entregaRemotaOpcao[hidden],[data-assinatura-local][hidden],#entregaLinkInfo[hidden]{display:none!important}

/* Cabeçalho: marca, unidade e conta compartilham o mesmo eixo vertical. */
.header{padding:14px 24px}
.header .header-content{display:grid;grid-template-columns:minmax(250px,.85fr) minmax(0,2.15fr);align-items:center;gap:24px}
.header .app-brand{min-width:0;gap:14px}
.header .app-brand-logo{width:80px;height:80px}
.header .header-tools{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:20px;width:100%;min-width:0}
.header .company-selector{width:100%;min-width:0;min-height:80px;gap:12px;padding:8px 12px}
.header .company-logo-wrap{width:64px;max-width:64px;min-height:64px;flex:0 0 64px}
.header #companyHeaderLogo{width:64px;height:64px;padding:4px;border-radius:8px}
.header .company-selector select{flex:1;width:0;min-width:0;max-width:100%;min-height:40px;text-align:center;text-align-last:center}
.header .company-selector #btnNovaEmpresaHeader{flex-shrink:0;margin:0;min-height:34px}
.header .account-menu{margin:0;width:auto;max-width:320px;align-items:center;justify-content:center;gap:6px}
.header .account-menu #usuarioSaudacao{width:100%;max-width:100%;margin:0;text-align:center;line-height:1.35}
.header .account-actions{align-items:center;justify-content:center;gap:8px;flex-wrap:wrap}
.header .account-actions .btn{margin:0;min-height:36px;display:inline-flex;align-items:center;justify-content:center;gap:6px;white-space:nowrap}
.header .account-actions a{text-decoration:none}
@media(max-width:1100px){
 .header .header-content{grid-template-columns:minmax(0,1fr);gap:14px}
 .header .app-brand{justify-content:center}
 .header .header-tools{gap:16px}
}
@media(max-width:640px){
 .header{padding:12px}
 .header .header-tools{grid-template-columns:minmax(0,1fr);gap:12px}
 .header .company-selector{min-height:72px;gap:8px;padding:8px 10px}
 .header .company-logo-wrap{width:56px;max-width:56px;min-height:56px;flex-basis:56px}
 .header #companyHeaderLogo{width:56px;height:56px}
 .header .account-menu{width:100%;max-width:none}
 .header .account-actions{width:100%}
 .header .account-actions .btn{min-height:42px;flex:1 1 auto}
}

/* Layout da aplicação em telas estreitas. As fichas usam o próprio layout. */
@media screen {
    .nav { flex-wrap: wrap; }
    .main-container .data-table { width: 100%; }
    .data-table:not(#fichaContent *, #fichaDocumento *) :is(th, td) {
        white-space: normal;
        overflow-wrap: break-word;
        word-break: normal;
    }
    .main-container .data-table .badge { white-space: normal; }
    .page-header > *, .filters > *, .modal-footer > * { min-width: 0; max-width: 100%; }
    .modal-footer { flex-wrap: wrap; }
}
@media screen and (max-width: 1100px) {
    .nav { width: 100%; min-width: 0; flex-wrap: wrap; justify-content: center; }
    .nav-item { white-space: normal; text-align: center; }
    .sub-tabs { flex-wrap: wrap; }
    .sub-tab { max-width: 100%; white-space: normal; }
}
@media screen {
    .tabela-cartoes { display: block; width: 100%; min-width: 0; }
    .tabela-cartoes > thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
    }
    .tabela-cartoes > tbody { display: block; }
    .tabela-cartoes > tbody > tr {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 4px 12px;
        padding: 10px;
        margin-bottom: 10px;
        border: 1px solid var(--border);
        border-radius: 10px;
    }
    .tabela-cartoes > tbody > tr > td {
        display: block;
        width: auto !important;
        min-width: 0 !important;
        padding: 6px 4px;
        border: 0;
        overflow-wrap: anywhere;
    }
    .tabela-cartoes > tbody > tr > td[colspan],
    .tabela-cartoes > tbody > tr > td:has(.btn) { grid-column: 1 / -1; }
    .tabela-cartoes td[data-rotulo-coluna]:not([data-rotulo-coluna=""])::before {
        display: block;
        content: attr(data-rotulo-coluna);
        font-size: .78rem;
        font-weight: 700;
        margin-bottom: 4px;
    }
    .tabela-cartoes td .btn { margin: 2px; white-space: normal; }
    #entregasTable.tabela-cartoes > tbody > tr {
        grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr));
    }
    #entregasTable td { overflow-wrap: break-word; word-break: normal; }
    #entregasTable td:last-child .btn { white-space: nowrap; }
}
@media screen and (max-width: 900px) {
    .paginacao, .paginacao-botoes { flex-wrap: wrap; max-width: 100%; }
}
@media screen and (max-width: 420px) {
    .tabela-cartoes > tbody > tr { grid-template-columns: minmax(0, 1fr); }
    .nav-item { padding-inline: 9px; }
}

/* Formulário de advertência */
.login-senha-campo {
    position: relative;
}
.login-senha-campo .form-control {
    padding-inline-end: 3rem;
}
.login-senha-toggle {
    position: absolute;
    inset-block: 0;
    inset-inline-end: 0;
    width: 2.75rem;
    border: 0;
    border-radius: .5rem;
    background: transparent;
    color: #52655c;
    cursor: pointer;
}
.login-senha-toggle:focus-visible {
    outline: 2px solid #008b4d;
    outline-offset: -3px;
}
#advertenciaForm {
    display: grid;
    gap: 1rem;
    margin-top: 1rem;
}
#advertenciaForm .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}
#advertenciaForm .advertencia-seletor,
#advertenciaForm label:not([hidden]) {
    display: grid;
    gap: .375rem;
    min-width: 0;
    font-size: .875rem;
    font-weight: 500;
}
#advertenciaForm .form-control {
    width: 100%;
    min-width: 0;
}
#advertenciaForm textarea {
    min-height: 7rem;
    resize: vertical;
}
@media (max-width: 600px) {
    #advertenciaForm .form-grid {
        grid-template-columns: minmax(0, 1fr);
    }
    #advertenciaForm .advertencia-acoes > button {
        flex: 1 1 100%;
    }
}

.fornecimento-config { position: relative; }
.fornecimento-config > summary { cursor: pointer; }
.fornecimento-config > div {
    position: absolute;
    z-index: 4;
    right: 0;
    display: grid;
    gap: .5rem;
    padding: .5rem;
    min-width: 13rem;
    background: white;
    border: 1px solid var(--border);
    border-radius: .5rem;
}
.fornecimento-detalhes { overflow-wrap: break-word; }
.fornecimento-detalhes ul { margin-top: .75rem; padding-left: 1.25rem; }
.fornecimento-detalhes li { margin-bottom: .75rem; }
.fornecimento-detalhes-acoes { gap: .5rem; }
#entregasTable td[data-assinatura-estado] .badge { margin: 2px 0; }
@media screen and (max-width: 600px) {
    .fornecimento-config > div { position: static; min-width: 0; }
    #fornecimento .search-bar > * { min-width: 0 !important; }
    #fornecimento .search-bar .search-input { flex-basis: 100% !important; }
    #entregasTable.tabela-cartoes > tbody > tr { grid-template-columns: minmax(0, 1fr); }
}

.anexo-justificativa-modal {
    position: fixed;
    inset: 0;
    margin: auto;
    padding: 0;
    border: 0;
    width: min(700px, calc(100% - 24px));
    max-height: calc(100dvh - 24px);
    color: var(--text);
    box-shadow: 0 16px 48px rgba(0,0,0,.25);
}
.anexo-justificativa-modal::backdrop {
    background: rgba(0,0,0,.5);
    backdrop-filter: blur(4px);
}
.anexo-justificativa-modal .modal-body {
    display: grid;
    place-items: center;
    background: var(--bg);
}
.anexo-justificativa-modal img {
    display: block;
    max-width: 100%;
    max-height: min(64dvh, calc(100dvh - 170px));
    object-fit: contain;
}

.aviso-versao {
    position: fixed;
    right: 1rem;
    bottom: max(1rem, env(safe-area-inset-bottom));
    z-index: 2100;
    width: min(29rem, calc(100% - 2rem));
    padding: .85rem 1rem;
    color: var(--text);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: .75rem;
    box-shadow: 0 8px 28px #0003;
}
.aviso-versao-acoes {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-top: .65rem;
}

.comprovante-conferencia:not(:empty) {
    display: grid;
    gap: .75rem;
    margin: .75rem 0;
    padding: .9rem;
    border: 1px solid #dce6df;
    border-radius: .6rem;
    overflow-wrap: anywhere;
}
.comprovante-conferencia ul { padding-inline-start: 1.25rem; }
.comprovante-conferencia details { padding: .65rem; background: #f5f8f6; border-radius: .4rem; }
.comprovante-conferencia summary { cursor: pointer; font-weight: 600; }
.comprovante-termo { max-height: 16rem; overflow: auto; margin-top: .5rem; }
.comprovante-termo img { max-width: 100%; height: auto; }
.comprovante-conferencia label { display: flex; gap: .5rem; align-items: baseline; }
.signature-pad[inert] { opacity: .5; }

#fichaAbrirImpressao[hidden] { display: none; }

/* Ajustes de leitura em tela; o PDF usa clone separado em largura A4. */
.aviso-retroativo{border-left:4px solid #b7791f;padding:10px;background:#fff8e6;overflow-wrap:anywhere}
details[data-mobile-secao]>summary{padding:12px;cursor:pointer;font-weight:600;background:#eef5f1}
@media screen and (max-width:768px){
 #fichaModal .modal{min-width:0!important;width:calc(100% - 1rem)!important;max-width:calc(100% - 1rem)!important}
 #fichaContent{min-width:0!important;width:100%;overflow-x:hidden!important;box-sizing:border-box}
 #fichaContent #fichaDocumento{zoom:var(--ficha-escala,1)}
}
@media screen and (min-width:769px){details[data-mobile-secao]>summary{display:none}}
@media print{details[data-mobile-secao]{display:block}details[data-mobile-secao]>summary{display:none}}
