body {
    font-family: "Segoe UI", Arial, sans-serif;
    margin: 0;
    background: linear-gradient(135deg, #eef4ff, #f8fbff);
    color: #23374d;
}
.container {
    max-width: 1200px;
    margin: 30px auto;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 30px rgba(0,0,0,0.08);
    overflow: hidden;
}
.header {
    background: linear-gradient(135deg, #0f4c81, #1f6feb);
    color: white;
    padding: 28px 32px;
}
.header h1 {
    margin: 0 0 8px;
    font-size: 26px;
}
.header p {
    margin: 0;
    opacity: 0.95;
}
.content {
    padding: 16px 16px 20px;
}
.card {
    background: #f8fbff;
    border: 1px solid #dfe9f5;
    border-radius: 12px;
    padding: 10px;
    margin-bottom: 10px;
}
.card h2 {
    margin-top: 0;
    margin-bottom: 6px;
    font-size: 17px;
    color: #1746a2;
}
.order-number {
    display: inline-block;
    margin-bottom: 10px;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(255,255,255,0.18);
    font-weight: 700;
    letter-spacing: 0.4px;
}
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 8px;
}
.summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}
.summary-combined {
    grid-column: span 2;
}

/* .field e .auth-field unificados — mesma estrutura de card de dado */
.field,
.auth-field {
    background: white;
    border-radius: 8px;
    padding: 8px 9px;
    border: 1px solid #e5ecf4;
}
.field strong,
.auth-field strong {
    display: block;
    font-size: 10px;
    color: #6b7a90;
    text-transform: uppercase;
    margin-bottom: 2px;
    letter-spacing: 0.4px;
}
.field div,
.auth-field div {
    font-size: 13px;
    line-height: 1.3;
}
/* Destaque numérico (apenas .field) */
.field.numeric-value,
.field.highlight-field {
    text-align: right;
    background: #fff8dc;
    border-color: #f0d87a;
    font-weight: 700;
}
/* Dado de autorização tem peso/cor próprios */
.auth-field div {
    color: #23374d;
    font-weight: 500;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}
th, td {
    padding: 8px 6px;
    border-bottom: 1px solid #e5ecf4;
    text-align: left;
    font-size: 13px;
}
th {
    background: #f2f6fb;
    color: #4d5d75;
}

/* .orders-table: apenas o que difere das regras base de table/th/td */
.orders-table {
    margin-top: 4px;
}
.orders-table th,
.orders-table td {
    padding: 7px 6px;
    font-size: 12px;
}
.orders-table th {
    font-weight: 700;
}

.status {
    display: inline-block;
    padding: 6px 10px;
    border-radius: 999px;
    background: #e7f5eb;
    color: #2f7d4f;
    font-weight: bold;
    font-size: 12px;
}
.actions {
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
    margin-top: 8px;
}
.actions-top {
    margin-top: 0;
    margin-bottom: 10px;
}
.btn {
    border: none;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 12px rgba(0,0,0,0.12);
}
.btn-approve {
    background: #2e7d32;
    color: white;
}
.btn-reject {
    background: #c62828;
    color: white;
}
.btn-secondary {
    background: #6b7a90;
    color: white;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-primary {
    background: #1746a2;
    color: white;
}
.btn-danger {
    background: #c62828;
    color: white;
}
.reason-box {
    margin-top: 8px;
}
.reason-box textarea {
    width: 100%;
    min-height: 70px;
    border: 1px solid #cfd8dc;
    border-radius: 8px;
    padding: 8px 10px;
    resize: vertical;
    font-size: 13px;
    box-sizing: border-box;
}
.authorization-info {
    margin-top: 12px;
}
.auth-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
}
.error {
    color: #b00020;
    background: #fdecea;
    border: 1px solid #f4c7c7;
    padding: 14px;
    border-radius: 8px;
}
.success {
    color: #2f7d4f;
    background: #e7f5eb;
    border: 1px solid #b7e1c2;
    padding: 14px;
    border-radius: 8px;
    margin-bottom: 10px;
}
.toggle-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin: 8px 0 10px;
}
.toggle-row button {
    background: #1746a2;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 14px;
    cursor: pointer;
}
.status-cell {
    text-align: center;
    padding: 0;
}
.status-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 40px;
    border-radius: 0;
    font-size: 16px;
    font-weight: 700;
    white-space: nowrap;
}
.status-approved {
    background: #e7f5eb;
    color: #2f7d4f;
}
.status-rejected {
    background: #fdecea;
    color: #b00020;
}
.status-pending {
    background: #fff8dc;
    color: #8a6d1f;
}
.status-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 12px;
    color: #4d5d75;
}
.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.legend-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
}
.legend-pending  { background: #fff8dc; }
.legend-approved { background: #e7f5eb; }
.legend-rejected { background: #fdecea; }

.btn-view {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    background: #1746a2;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

/* Painéis expansíveis — controlados pela classe .open no card */
.items-card,
.other-info-card {
    display: none;
}
.items-card.open,
.other-info-card.open {
    display: block;
}
/* Painéis internos: visíveis quando o card está aberto */
.items-panel,
.other-info-panel {
    margin-top: 10px;
}

@media (max-width: 768px) {
    .content {
        padding: 12px;
    }
    .header {
        padding: 18px 14px;
    }
    .header h1 {
        font-size: 20px;
    }
    .actions {
        flex-direction: row;
    }
    .btn {
        flex: 1;
    }
    .grid {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }
    .summary-grid {
        grid-template-columns: 1fr 1fr;
    }
    .summary-combined {
        grid-column: 1 / -1;
    }
    .field,
    .auth-field {
        padding: 7px;
    }
    .field strong,
    .auth-field strong {
        font-size: 9px;
    }
    .field div,
    .auth-field div {
        font-size: 12px;
    }
    th, td {
        padding: 7px 4px;
        font-size: 12px;
    }
    .orders-table.gestor-table .gestor-name-cell strong {
        white-space: normal;
        word-break: break-word;
    }
    .orders-table.gestor-table .gestor-count {
        font-size: 10px;
    }
    .btn-vincular {
        padding: 5px 8px;
        font-size: 10px;
    }
}

/* Form Styles */
.form-group {
    margin-bottom: 12px;
}
.form-group label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: #6b7a90;
    text-transform: uppercase;
    margin-bottom: 4px;
    letter-spacing: 0.4px;
}
.form-control {
    width: 100%;
    padding: 8px 10px;
    font-size: 13px;
    border: 1px solid #cfd8dc;
    border-radius: 8px;
    box-sizing: border-box;
    background: #fff;
    color: #23374d;
    transition: border-color 0.2s;
}
.form-control:focus {
    border-color: #1746a2;
    outline: none;
}
.form-control[readonly] {
    background: #eef2f6;
    color: #6b7a90;
    cursor: not-allowed;
}


.btn-home {
    background: #0f4c81;
    color: white;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn-home:hover {
    background: #1f6feb;
}

.gestor-card {
    background: linear-gradient(135deg, #1746a2, #1f6feb);
    border: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.gestor-card-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: rgba(255,255,255,0.7);
}
.gestor-card-nome {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}
.gestor-card-icon {
    font-size: 26px;
    line-height: 1;
    filter: drop-shadow(0 1px 3px rgba(0,0,0,0.3));
}
.app-menu {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}
.app-menu .btn {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 7px;
    text-align: left;
    white-space: normal;
    word-break: break-word;
    padding: 10px 12px;
    text-decoration: none;
    color: #1746a2;
    background: #ddeaff;
}
.app-menu .btn:focus {
    outline: 3px solid #1746a2;
    outline-offset: 2px;
    background: #c5d8f8;
}
.app-menu .btn.btn-danger {
    color: #7a1010;
    background: #fde0e0;
}
.app-menu .btn.btn-danger:focus {
    outline-color: #c62828;
    background: #f9c4c4;
}
@media (max-width: 480px) {
    .app-menu {
        grid-template-columns: 1fr;
    }
}
.chart-wrap {
    position: relative;
    max-height: 260px;
}

.empresa-total-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
}
.etl-desc {
    font-weight: 700;
}
.etl-valor {
    font-weight: 600;
    white-space: nowrap;
    text-align: right;
}
.etl-count {
    white-space: nowrap;
    text-align: right;
    opacity: 0.75;
    font-size: 11px;
}
.empresa-totais {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 260px;
}
@media (max-width: 480px) and (orientation: portrait) {
    .empresa-header {
        flex-direction: column;
    }
    .empresa-totais {
        min-width: 0;
        width: 100%;
    }
    .status-legend {
        flex-direction: column;
    }
    .legend-item {
        display: flex;
        width: 100%;
    }
}
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 10px;
    margin-top: 12px;
}
.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    padding: 8px 10px;
    border: 1px solid #dfe9f5;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    user-select: none;
}
.checkbox-item:hover {
    background: #f4f8fd;
    border-color: #bcd3ed;
}
.checkbox-item input[type="checkbox"] {
    cursor: pointer;
    width: 16px;
    height: 16px;
    margin: 0;
}
.checkbox-item span {
    font-size: 13px;
    color: #23374d;
}

/* Child row / expandable sub-table */

/* Contagem de empresas abaixo do nome */
.gestor-count {
    display: block;
    font-size: 11px;
    font-weight: 400;
    color: #5a7a9a;
    margin-top: 2px;
    font-style: normal;
}
.gestor-count.no-link {
    color: #b00020;
}

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

.orders-table .toggle-col,
.orders-table .toggle-cell {
    width: 28px;
    padding: 6px 4px;
}

.orders-table .gestor-id-col,
.orders-table .gestor-id-cell {
    width: 1%;
    white-space: nowrap;
    text-align: center;
}

.orders-table .gestor-name-col,
.orders-table .gestor-name-cell {
    width: auto;
    min-width: 160px;
}

.orders-table .gestor-name-cell strong {
    display: block;
    font-weight: 700;
    white-space: nowrap;
}

.orders-table .gestor-actions-col,
.orders-table .gestor-actions-cell {
    width: 1%;
    white-space: nowrap;
    text-align: center;
}

.btn-vincular {
    padding: 5px 10px;
    font-size: 11px;
}

/* Alternância de cor entre gestores (par gestor-row + child-row = 2 tr's por gestor) */
.orders-table tbody tr.gestor-row:nth-of-type(odd) {
    background: #ffffff;
}
.orders-table tbody tr.gestor-row:nth-of-type(even) {
    background: #f0f5fb;
}
/* Linha filha herda a cor da linha pai via borda lateral */
.orders-table tbody tr.gestor-row:nth-of-type(odd) + tr.child-row td.child-cell {
    border-left: 3px solid #c8d9ee;
    background: #f8fbff;
}
.orders-table tbody tr.gestor-row:nth-of-type(even) + tr.child-row td.child-cell {
    border-left: 3px solid #aec6e8;
    background: #edf3fb;
}

.gestor-row:hover {
    filter: brightness(0.97);
}
.toggle-cell {
    text-align: center;
    padding: 6px 4px;
    color: #4d5d75;
}
.row-arrow {
    display: inline-block;
    font-size: 10px;
    transition: transform 0.2s ease;
}
.row-arrow.open {
    transform: rotate(90deg);
}
.child-row {
    display: none;
}
.child-row td.child-cell {
    padding: 0;
    border-bottom: 2px solid #dfe9f5;
}
.child-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
}
.child-table td {
    padding: 5px 12px 5px 28px;
    font-size: 12px;
    color: #3a5068;
    border-bottom: 1px solid #e5ecf4;
    text-align: left;
}
.child-table tbody tr:last-child td {
    border-bottom: none;
}
