:root {
    --primary-color: #0f766e;
    --primary-dark: #0b5f59;
    --secondary-color: #123847;
    --success-color: #15803d;
    --danger-color: #dc2626;
    --warning-color: #d97706;
    --info-color: #0ea5e9;
    --accent-color: #f59e0b;
    --dark-color: #0b1720;
    --surface-color: #f4f7f6;
    --surface-strong: #ffffff;
    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;
    --header-height: 70px;
}

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

body {
    font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    color: #1f2937;
    background:
        radial-gradient(circle at top left, rgba(15, 118, 110, 0.07), transparent 28%),
        linear-gradient(180deg, #f8fbfa 0%, var(--surface-color) 100%);
}

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

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: margin-left 0.3s;
}

.main-content.sidebar-collapsed {
    margin-left: var(--sidebar-collapsed);
}

.sidebar {
    position: fixed;
    width: var(--sidebar-width);
    height: 100vh;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0) 20%),
        linear-gradient(180deg, #07161d 0%, #0d2a33 46%, #123847 100%);
    color: white;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: width 0.3s;
    box-shadow: 24px 0 50px rgba(7, 22, 29, 0.14);
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

.sidebar.collapsed .menu-section-title,
.sidebar.collapsed .menu-item span,
.sidebar.collapsed .brand-copy {
    display: none;
}

.sidebar.collapsed .menu-item,
.sidebar.collapsed .sidebar-logo {
    justify-content: center;
}

.sidebar-header {
    padding: 22px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 14px;
    color: white;
    text-decoration: none;
    min-width: 0;
}

.brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, #0f766e 0%, #16a34a 58%, #f59e0b 100%);
    box-shadow: 0 12px 22px rgba(15, 118, 110, 0.28);
    flex-shrink: 0;
}

.brand-mark i {
    font-size: 18px;
    color: #fff;
}

.brand-copy {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.brand-copy strong {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 22px;
    line-height: 1;
    letter-spacing: -0.04em;
}

.brand-copy small {
    color: rgba(255,255,255,0.62);
    font-size: 11px;
    line-height: 1.35;
    margin-top: 4px;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    display: none;
}

.sidebar-menu {
    flex: 1;
    padding: 16px 0;
    overflow-y: auto;
}

.menu-section {
    margin-bottom: 24px;
}

.menu-section-title {
    padding: 8px 20px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.5);
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.menu-item:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.menu-item.active {
    background: linear-gradient(90deg, rgba(15, 118, 110, 0.26), rgba(15, 118, 110, 0.04));
    color: white;
    border-left-color: var(--primary-color);
}

.menu-item i {
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px 0;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.main-header {
    height: var(--header-height);
    background: rgba(255, 255, 255, 0.84);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 8px 30px rgba(15, 23, 42, 0.06);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(16px);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-brand-pill {
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(15, 118, 110, 0.12), rgba(245, 158, 11, 0.12));
    color: #0b1720;
}

.header-brand-name {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.header-brand-tag {
    color: #4b5563;
    font-size: 12px;
}

.header-search {
    position: relative;
    min-width: 220px;
}

.header-search i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
}

.header-search .form-control {
    padding-left: 36px;
}

.btn-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 999px;
    color: #0f172a;
    background: linear-gradient(135deg, #eff6f5 0%, #eef2f7 100%);
    border: 1px solid #d9e4e7;
}

.btn-icon .badge {
    position: absolute;
    top: -4px;
    right: -4px;
}

.user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.sidebar-mobile-toggle {
    display: none;
}

.page-content {
    padding: 24px;
}

.page-title,
.header-title h1 {
    font-family: 'Space Grotesk', sans-serif;
    letter-spacing: -0.03em;
}

.card {
    border: 1px solid rgba(15, 23, 42, 0.05);
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.04);
}

.asset-action-bar {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.asset-qr-image {
    width: min(220px, 100%);
    aspect-ratio: 1 / 1;
    object-fit: contain;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 12px;
    background: #fff;
}

.asset-qr-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.attachment-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.attachment-card {
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    overflow: hidden;
    background: white;
}

.attachment-preview-link,
.attachment-preview-file {
    display: block;
    background: linear-gradient(135deg, #eef2ff 0%, #f8fafc 100%);
}

.attachment-preview-image {
    display: block;
    width: 100%;
    height: 180px;
    object-fit: cover;
}

.attachment-preview-file {
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6366f1;
    font-size: 2rem;
}

.attachment-card-body {
    padding: 14px;
}

.tiny {
    font-size: 11px;
}

.calendar-control-card {
    background: linear-gradient(135deg, rgba(15, 118, 110, 0.06), rgba(255, 255, 255, 0.92));
}

.calendar-chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.calendar-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    background: #f8fafc;
    border: 1px solid #dbe5e7;
    font-size: 12px;
    color: #334155;
    cursor: pointer;
}

.calendar-chip input {
    accent-color: var(--primary-color);
}

.calendar-switch {
    min-height: 42px;
    display: flex;
    align-items: center;
    padding-left: 44px;
}

.calendar-legend {
    row-gap: 10px;
}

.calendar-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 999px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    font-size: 12px;
    color: #334155;
}

.calendar-legend-item i {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    display: inline-block;
}

.calendar-helper {
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.06), rgba(15, 118, 110, 0.05));
}

.calendar-event-locked {
    opacity: 0.82;
}

.fc .fc-toolbar-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.25rem;
}

.fc .fc-button-primary {
    background: var(--secondary-color);
    border-color: var(--secondary-color);
}

.fc .fc-button-primary:not(:disabled).fc-button-active,
.fc .fc-button-primary:not(:disabled):active,
.fc .fc-button-primary:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.fc .fc-daygrid-event,
.fc .fc-timegrid-event {
    border-radius: 8px;
    border: 0;
    padding: 2px 4px;
    box-shadow: 0 6px 14px rgba(15, 23, 42, 0.08);
}

.table-compact-mobile td:first-child {
    width: 42%;
    color: #6b7280;
}

body.sidebar-open {
    overflow: hidden;
}

.breadcrumb {
    margin-bottom: 0;
    font-size: 12px;
}

.breadcrumb-item a {
    color: var(--primary-color);
    text-decoration: none;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.04);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.stat-primary .stat-icon { background: rgba(102, 126, 234, 0.1); color: var(--primary-color); }
.stat-success .stat-icon { background: rgba(40, 167, 69, 0.1); color: var(--success-color); }
.stat-warning .stat-icon { background: rgba(255, 193, 7, 0.1); color: var(--warning-color); }
.stat-danger .stat-icon { background: rgba(220, 53, 69, 0.1); color: var(--danger-color); }
.stat-info .stat-icon { background: rgba(23, 162, 184, 0.1); color: var(--info-color); }
.stat-purple .stat-icon { background: rgba(102, 16, 242, 0.1); color: var(--purple-color); }
.stat-pink .stat-icon { background: rgba(232, 62, 140, 0.1); color: var(--pink-color); }
.stat-orange .stat-icon { background: rgba(253, 126, 20, 0.1); color: var(--orange-color); }
.stat-teal .stat-icon { background: rgba(32, 201, 151, 0.1); color: var(--teal-color); }
.stat-dark .stat-icon { background: rgba(26, 26, 46, 0.1); color: var(--dark-color); }

.stat-content {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #1f2937;
}

.stat-label {
    font-size: 12px;
    color: #6b7280;
}

.card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.04);
    border: none;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid #f3f4f6;
    background: transparent;
}

.card-header h5 {
    margin: 0;
    font-weight: 600;
    color: #1f2937;
}

.card-header h5 i {
    margin-right: 8px;
    color: var(--primary-color);
}

.card-body {
    padding: 20px;
}

.btn {
    font-weight: 500;
    padding: 10px 20px;
    border-radius: 8px;
    transition: all 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    border: none;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--secondary-color) 100%);
    transform: translateY(-1px);
}

.btn-success { background: var(--success-color); border: none; color: white; }
.btn-danger { background: var(--danger-color); border: none; color: white; }
.btn-warning { background: var(--warning-color); border: none; color: black; }
.btn-info { background: var(--info-color); border: none; color: white; }

.table {
    margin-bottom: 0;
}

.table thead th {
    font-weight: 600;
    color: #6b7280;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #f3f4f6;
    padding: 12px;
}

.table tbody td {
    padding: 14px 12px;
    vertical-align: middle;
    border-bottom: 1px solid #f3f4f6;
}

.table-hover tbody tr:hover {
    background: #f9fafb;
}

.badge {
    padding: 6px 10px;
    font-weight: 500;
    font-size: 11px;
    border-radius: 6px;
}

.alert {
    border-radius: 8px;
    border: none;
}

.page-item.active .page-link {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.form-control, .form-select {
    border-radius: 8px;
    padding: 10px 14px;
    border: 1px solid #e5e7eb;
    font-size: 14px;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.card-filter {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.04);
}

.card-filter label {
    font-size: 12px;
    font-weight: 500;
    color: #6b7280;
    margin-bottom: 4px;
}

.ranking-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ranking-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #f9fafb;
    border-radius: 8px;
}

.ranking-position {
    width: 28px;
    height: 28px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 12px;
}

.ranking-name {
    flex: 1;
    font-weight: 500;
}

.ranking-count {
    font-weight: 700;
    color: var(--primary-color);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.status-badge.Aberta { background: #dbeafe; color: #1e40af; }
.status-badge.Planejada { background: #e0e7ff; color: #3730a3; }
.status-badge.Em_Execucao { background: #fef3c7; color: #92400e; }
.status-badge.Concluida { background: #d1fae5; color: #065f46; }
.status-badge.Cancelada { background: #fee2e2; color: #991b1b; }
.status-badge.Pausada { background: #f3f4f6; color: #374151; }

.priority-badge {
    display: inline-flex;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.priority-badge.Critica { background: #fee2e2; color: #dc2626; }
.priority-badge.Alta { background: #ffedd5; color: #ea580c; }
.priority-badge.Media { background: #fef9c3; color: #ca8a04; }
.priority-badge.Baixa { background: #dcfce7; color: #16a34a; }

@media (max-width: 1200px) {
    .main-header {
        padding: 0 16px;
    }

    .header-search {
        min-width: 180px;
    }
}

@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
        width: min(86vw, 320px);
        box-shadow: 0 24px 48px rgba(15, 23, 42, 0.24);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .main-content,
    .main-content.sidebar-collapsed {
        margin-left: 0;
    }
    
    .sidebar-mobile-toggle {
        display: block;
    }

    .header-right {
        gap: 10px;
    }

    .header-search {
        min-width: 0;
        flex: 1;
    }

    .user-info {
        display: none;
    }
}

@media (max-width: 768px) {
    .page-content {
        padding: 16px;
    }

    .main-header {
        height: auto;
        min-height: var(--header-height);
        padding: 12px 16px;
        align-items: flex-start;
        gap: 16px;
        flex-direction: column;
    }

    .header-left,
    .header-right {
        width: 100%;
    }

    .header-right {
        justify-content: space-between;
    }

    .breadcrumb {
        flex-wrap: wrap;
    }

    .stat-card {
        padding: 16px;
    }
    
    .stat-value {
        font-size: 22px;
    }
    
    .stat-icon {
        width: 44px;
        height: 44px;
        font-size: 20px;
    }

    .asset-action-bar .btn,
    .asset-qr-actions .btn {
        width: 100%;
    }

    .table-compact-mobile tbody,
    .table-compact-mobile tr,
    .table-compact-mobile td {
        display: block;
        width: 100%;
    }

    .table-compact-mobile tr {
        padding: 8px 0;
        border-bottom: 1px solid #f3f4f6;
    }

    .table-compact-mobile td {
        padding: 6px 0;
        border: 0;
    }

    .table-compact-mobile td:first-child {
        width: 100%;
        font-weight: 600;
    }
}

@media (max-width: 576px) {
    .page-content {
        padding: 12px;
    }

    .card-header,
    .card-body {
        padding-left: 14px;
        padding-right: 14px;
    }

    .btn {
        width: 100%;
    }

    .header-search {
        display: none;
    }
}

/* ═══════════════════════════════════════════════════════
   PRINT / PDF STYLES — SIGSE
   ═══════════════════════════════════════════════════════ */
@page {
    size: A4;
    margin: 15mm 12mm 18mm 12mm;
}

@media print {

    /* Reset básico */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }

    /* Esconder elementos de navegação */
    nav,
    .sidebar,
    .header,
    .footer,
    .btn,
    .progress,
    .page-header .d-flex > a,
    .page-header form,
    .alert,
    #sidebar,
    #header,
    .breadcrumb,
    .card-header .d-flex .btn,
    .no-print,
    .pagination,
    .filter-bar,
    footer,
    script {
        display: none !important;
        height: 0 !important;
        width: 0 !important;
        overflow: hidden !important;
        visibility: hidden !important;
    }

    /* Layout da página */
    html, body {
        width: 210mm;
        font-size: 9pt;
        line-height: 1.4;
        color: #000;
        background: #fff;
    }

    .page-content,
    .container-fluid {
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Tabelas */
    table {
        width: 100% !important;
        border-collapse: collapse !important;
        font-size: 8pt;
        page-break-inside: avoid;
    }

    thead {
        display: table-header-group;
    }

    th {
        background: #f0f0f0 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    td, th {
        border: 1px solid #555 !important;
        padding: 2px 4px !important;
        vertical-align: middle;
    }

    tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }

    tr:nth-child(even) {
        background: #fafafa !important;
        -webkit-print-color-adjust: exact;
    }

    /* Cabeçalhos de ficha de inspeção */
    .ficha-header td,
    .ficha-inspecao td,
    .ficha-inspecao th {
        font-size: 8pt !important;
        padding: 2px 4px !important;
    }

    .ficha-label {
        background: #e8e8e8 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        font-size: 7.5pt !important;
        font-weight: 700 !important;
    }

    /* Formulários em modo de exibição */
    .form-control,
    .form-select {
        border: none !important;
        border-bottom: 1px solid #aaa !important;
        box-shadow: none !important;
        padding: 1px 2px !important;
        font-size: 8pt !important;
        background: transparent !important;
        border-radius: 0 !important;
    }

    input[readonly],
    .form-control[readonly] {
        background: transparent !important;
    }

    textarea {
        border: 1px solid #aaa !important;
        resize: none;
        padding: 2px 4px !important;
        font-size: 8pt !important;
        background: transparent !important;
    }

    /* Cards */
    .card {
        box-shadow: none !important;
        border: 1px solid #ccc !important;
        page-break-inside: avoid;
        margin-bottom: 8pt;
    }

    .card-header {
        background: #e8e8e8 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        font-weight: 700;
        font-size: 9pt;
        padding: 3px 6px !important;
        page-break-after: avoid;
    }

    .card-body {
        padding: 6px !important;
    }

    /* Linhas de resultado (conformidade) */
    .row-ok {
        background: #d4edda !important;
        -webkit-print-color-adjust: exact;
    }

    .row-nao {
        background: #f8d7da !important;
        -webkit-print-color-adjust: exact;
    }

    /* Controles de fase */
    .phase-cell {
        padding: 1px 2px !important;
    }

    .phase-select,
    .result-select {
        border: none !important;
        font-size: 8pt !important;
        background: transparent !important;
        padding: 0 !important;
    }

    /* Rodapé de página */
    @page:last {
        margin-bottom: 10mm;
    }

    /* Quebras de página explícitas */
    .page-break-before {
        page-break-before: always;
    }

    .page-break-after {
        page-break-after: always;
    }

    .avoid-break {
        page-break-inside: avoid;
    }

    /* Estilos de texto */
    h1 { font-size: 14pt; }
    h2 { font-size: 12pt; }
    h3 { font-size: 11pt; }
    h4 { font-size: 10pt; }
    h5, h6 { font-size: 9pt; }

    .page-title {
        font-size: 14pt !important;
    }

    .text-muted {
        color: #555 !important;
    }

    /* Badge e badges sem cor de fundo em impressão */
    .badge {
        border: 1px solid #333 !important;
        color: #000 !important;
        background: transparent !important;
        font-size: 7pt !important;
        padding: 1px 4px !important;
    }

    /* Links — mostrar URL */
    a[href]::after {
        content: none;
    }

    /* Melhorias para impressão de tabelas */
    .table {
        font-size: 9pt !important;
        border-collapse: collapse !important;
    }

    .table th,
    .table td {
        padding: 4px 6px !important;
        border: 1px solid #333 !important;
    }

    .table th {
        background: #e5e5e5 !important;
        -webkit-print-color-adjust: exact;
        font-weight: bold !important;
    }

    .table-hover tbody tr:hover {
        background: transparent !important;
    }

    /* Cards sem borda */
    .card {
        border: none !important;
        box-shadow: none !important;
    }

    .card-header {
        background: transparent !important;
        border-bottom: 2px solid #000 !important;
        padding: 8px 0 !important;
    }

    /* Garantir que elementos de formulário não apareçam */
    input, select, textarea, button, .btn {
        border: none !important;
        box-shadow: none !important;
    }

    /* Imprimir cores de status quando necessário */
    .status-ok, .status-conforme, .status-aprovado {
        background: #d4edda !important;
        -webkit-print-color-adjust: exact;
    }

    .status-erro, .status-nao-conforme, .status-rejeitado {
        background: #f8d7da !important;
        -webkit-print-color-adjust: exact;
    }

    .status-pendente, .status-em-analise {
        background: #fff3cd !important;
        -webkit-print-color-adjust: exact;
    }

    /* Cabeçalho do sistema */
    .app-wrapper {
        display: block !important;
    }

    .sidebar, .navbar, .header, nav {
        display: none !important;
    }

    .main-content {
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Remover elementos de ação */
    .no-print, .actions, .btn-group, .dropdown {
        display: none !important;
    }
}
