* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #1a1a2e;
    color: #eee;
    min-height: 100vh;
    overflow-x: hidden;
}
.header {
    background: linear-gradient(135deg, #16213e, #0f3460);
    color: #fff;
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 10px #0005;
    position: relative;
}
.header h1 {
    font-size: 24px;
    margin-bottom: 5px;
}
.user-area {
    position: absolute;
    right: 20px;
    top: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.user-chip {
    background: #ffffff1f;
    border: 1px solid #ffffff38;
    padding: 7px 12px;
    border-radius: 18px;
    font-size: 13px;
}
.logout-btn,
.btn {
    border: 0;
    border-radius: 7px;
    padding: 9px 14px;
    cursor: pointer;
    font-weight: 600;
    transition: 0.2s;
}
.logout-btn {
    background: #fff;
    color: #0f3460;
}
.container {
    max-width: 1400px;
    margin: 20px auto;
    padding: 0 20px;
}
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}
.stat-card {
    background: linear-gradient(135deg, #16213e, #1a1a2e);
    border-radius: 16px;
    padding: 25px;
    text-align: center;
    box-shadow: 0 4px 15px #0005;
    border: 1px solid #2a2a4a;
}
.stat-card .value {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 5px;
}
.stat-card .label {
    font-size: 14px;
    color: #888;
    text-transform: uppercase;
}
.pendente .value {
    color: #ff9800;
}
.producao .value {
    color: #2196f3;
}
.concluido .value {
    color: #4caf50;
}
.hoje .value {
    color: #e91e63;
}
.section {
    background: #16213e;
    border-radius: 16px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px #0005;
}
.section-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
.alert-list,
.timeline {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.alert-item {
    background: #ff57221a;
    border-left: 4px solid #ff5722;
    padding: 15px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.alert-item .cliente {
    font-weight: 600;
    color: #ff9800;
}
.alert-item .tempo {
    font-size: 12px;
    color: #ff8a65;
    display: block;
    margin-top: 4px;
}
.timeline-item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}
.timeline-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #4caf50;
    margin-top: 5px;
    flex: none;
}
.timeline-content {
    flex: 1;
    background: #ffffff0d;
    padding: 12px 15px;
    border-radius: 8px;
}
.meta {
    font-size: 12px;
    color: #888;
    margin-top: 4px;
}
.table-wrap {
    overflow-x: auto;
}
.os-table {
    width: 100%;
    border-collapse: collapse;
}
.os-table th,
.os-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #2a2a4a;
}
.os-table th {
    background: #ffffff0d;
    font-size: 12px;
    text-transform: uppercase;
    color: #999;
    cursor: pointer;
}
.os-table tr:hover {
    background: #ffffff08;
}
.status-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}
.status-aguardando_vendedor {
    background: #00897b;
    color: #fff;
}
.status-pendente {
    background: #ff9800;
    color: #000;
}
.status-ploteiro_producao {
    background: #2196f3;
}
.status-ploteiro_concluido {
    background: #03a9f4;
}
.status-calandreiro_producao {
    background: #ff5722;
}
.status-concluido {
    background: #4caf50;
}
.status-entregue {
    background: #7e57c2;
}
.status-cancelado {
    background: #d32f2f;
    color: #fff;
}
.btn-primary {
    background: #2196f3;
    color: #fff;
}
.btn-success {
    background: #4caf50;
    color: #fff;
}
.btn-danger {
    background: #c62828;
    color: #fff;
}
.btn-warning {
    background: #ff9800;
    color: #fff;
}
.btn-secondary {
    background: #2a2a4a;
    border: 1px solid #444;
    color: #fff;
}
.btn-small {
    padding: 6px 10px;
    font-size: 12px;
}
.btn:hover {
    opacity: 0.85;
}
.empty-state {
    text-align: center;
    padding: 30px;
    color: #777;
}
.refresh-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e91e63, #9c27b0);
    color: #fff;
    border: 0;
    cursor: pointer;
    box-shadow: 0 4px 15px #e91e6366;
    font-size: 24px;
    z-index: 900;
}
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
.refresh-btn.loading {
    animation: spin 1s linear infinite;
}
.filters,
.user-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    align-items: end;
    margin-bottom: 18px;
}
.field label {
    display: block;
    color: #aaa;
    font-size: 12px;
    margin-bottom: 5px;
}
.field input,
.field select,
.field textarea {
    width: 100%;
    padding: 10px;
    background: #10182e;
    border: 1px solid #3a4665;
    border-radius: 7px;
    color: #fff;
    font: inherit;
}
.field input[type='checkbox'] {
    width: auto;
}
.checks {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 9px 0;
}
.checks label {
    font-size: 13px;
    color: #ddd;
}
.color-dot {
    display: inline-block;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: -2px;
}
.user-card {
    background: #ffffff0d;
    border: 1px solid #2a2a4a;
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 9px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
}
.user-card.inativo {
    opacity: 0.55;
}
.user-info small {
    color: #999;
    display: block;
    margin-top: 5px;
}
.report-total {
    text-align: right;
    font-size: 18px;
    font-weight: 700;
    color: #4caf50;
    margin: 10px 0;
}
.last-update {
    text-align: center;
    color: #666;
    font-size: 12px;
    margin: 20px 0;
}
.login-overlay,
.modal {
    position: fixed;
    inset: 0;
    background: #0b1020e8;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.login-box,
.modal-box {
    width: 100%;
    max-width: 400px;
    background: #16213e;
    border: 1px solid #344365;
    border-radius: 14px;
    padding: 28px;
    box-shadow: 0 20px 50px #0008;
}
.login-box h2 {
    margin-bottom: 6px;
}
.login-box p {
    color: #aaa;
    margin-bottom: 20px;
}
.login-box label {
    display: block;
    font-size: 13px;
    margin: 12px 0 5px;
}
.login-box input {
    width: 100%;
    padding: 11px;
    background: #10182e;
    border: 1px solid #3a4665;
    border-radius: 8px;
    color: #fff;
}
.login-box button {
    width: 100%;
    margin-top: 18px;
}
.login-error {
    color: #ff5252;
    min-height: 20px;
    margin-top: 8px;
    font-size: 13px;
}
.modal-box {
    max-width: 900px;
    max-height: 90vh;
    overflow: auto;
    position: relative;
}
.close {
    position: absolute;
    right: 15px;
    top: 12px;
    background: none;
    border: 0;
    color: #fff;
    font-size: 25px;
    cursor: pointer;
}
.arte-detail {
    background: #ffffff0d;
    border-left: 4px solid #2196f3;
    padding: 13px;
    border-radius: 8px;
    margin: 10px 0;
}
.badges {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 8px;
}
.op-badge {
    color: #fff;
    padding: 4px 8px;
    border-radius: 5px;
    font-size: 11px;
}
.imenda-badge {
    display: inline-block;
    background: #d32f2f;
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
    margin-top: 5px;
}
.hidden {
    display: none !important;
}
.resumo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 14px;
    margin-bottom: 12px;
}
.resumo-card {
    background: linear-gradient(135deg, #16213e, #1a1a2e);
    border-radius: 14px;
    padding: 16px 18px;
    box-shadow: 0 4px 15px #0005;
    border: 1px solid #2a2a4a;
    border-top: 4px solid #607d8b;
}
.resumo-card.c-vendedor {
    border-top-color: #00897b;
}
.resumo-card.c-e1 {
    border-top-color: #2196f3;
}
.resumo-card.c-e2 {
    border-top-color: #ff9800;
}
.resumo-card.c-hoje {
    border-top-color: #4caf50;
}
.r-titulo {
    font-size: 12px;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    min-height: 30px;
}
.r-os {
    font-size: 34px;
    font-weight: 700;
    line-height: 1.1;
    display: inline-block;
}
.r-sub {
    display: inline-block;
    margin-left: 6px;
    color: #888;
    font-size: 13px;
}
.r-qtd {
    margin-top: 6px;
    font-size: 14px;
    color: #ddd;
    font-weight: 600;
}
.r-qtd small {
    color: #888;
    font-weight: 400;
}
.resumo-faixa {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 30px;
    background: #16213e;
    border: 1px solid #2a2a4a;
    border-radius: 12px;
    padding: 12px 18px;
    font-size: 14px;
    margin-bottom: 6px;
}
.f-rotulo {
    color: #888;
    text-transform: uppercase;
    font-size: 12px;
    margin-right: 6px;
}
.resumo-nota {
    color: #666;
    font-size: 12px;
    margin: 0 0 24px;
}
.report-actions {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 12px;
}
.report-section {
    margin: 18px 0 26px;
}
.report-header {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 15px;
    margin-bottom: 10px;
}
.report-header h3 {
    font-size: 17px;
}
.report-meta {
    color: #999;
    font-size: 12px;
}
.report-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.report-table th,
.report-table td {
    padding: 10px 9px;
    text-align: left;
    border-bottom: 1px solid #2a2a4a;
    vertical-align: top;
}
.report-table th {
    background: #285d4b;
    color: #fff;
    text-transform: uppercase;
    white-space: nowrap;
}
.report-table tbody tr:nth-child(even) {
    background: #ffffff08;
}
.report-table .pasta-col {
    max-width: 260px;
    word-break: break-all;
}
.report-table .mt-col {
    text-align: right;
    font-weight: 700;
    white-space: nowrap;
}
.detail-layout {
    display: grid;
    grid-template-columns: 170px 1fr;
    gap: 16px;
    align-items: start;
}
.detail-image,
.detail-no-image {
    width: 170px;
    min-height: 115px;
    border-radius: 8px;
    border: 1px solid #3a4665;
    background: #0f172b;
    object-fit: contain;
}
.detail-no-image {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #777;
}
.detail-info h3 {
    margin-bottom: 5px;
    word-break: break-word;
}
.detail-info p {
    color: #bbb;
    font-size: 13px;
    margin: 4px 0;
}
.detail-launch {
    display: grid;
    grid-template-columns: 1fr 28px;
    align-items: center;
    gap: 7px;
    margin-top: 7px;
    border-left: 4px solid #607d8b;
    padding-left: 7px;
}
.detail-launch .op-badge {
    display: block;
}
.detail-cancel {
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 50%;
    background: #c62828;
    color: #fff;
    cursor: pointer;
    font-size: 18px;
    font-weight: 700;
}
.detail-cancel:hover {
    background: #b71c1c;
}

/* BARRA LATERAL DA IA */
.ai-fab {
    position: fixed;
    bottom: 105px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00bcd4, #3f51b5);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    font-size: 24px;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}
.ai-fab:hover {
    transform: scale(1.05);
}
/* 100dvh = altura realmente visível no celular (100vh inclui a área atrás das barras do navegador
   e escondia a caixa de pergunta). 100vh fica de reserva para navegadores antigos. */
.ai-sidebar {
    position: fixed;
    right: -420px;
    top: 0;
    width: 400px;
    height: 100vh;
    height: 100dvh;
    background: #16213e;
    border-left: 1px solid #2a2a4a;
    z-index: 3000;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: -5px 0 20px rgba(0, 0, 0, 0.5);
}
.ai-sidebar.open {
    right: 0;
}
.ai-header {
    padding: 20px;
    background: #0f3460;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #2a2a4a;
}
.ai-header h3 {
    margin: 0;
    color: #fff;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.ai-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 28px;
    cursor: pointer;
}
.ai-chat-area {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}
.ai-message {
    flex-shrink: 0; /* sem isso, a conversa longa espreme as respostas e esconde o fim delas */
    max-width: 90%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}
.msg-user {
    align-self: flex-end;
    background: #2196f3;
    color: white;
    border-bottom-right-radius: 2px;
}
.msg-ai {
    align-self: flex-start;
    background: #ffffff1f;
    color: #eee;
    border-bottom-left-radius: 2px;
    border: 1px solid #3a4665;
    overflow-x: auto;
}
.msg-ai table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    margin-bottom: 10px;
    font-size: 12px;
}
.msg-ai th,
.msg-ai td {
    border: 1px solid #3a4665;
    padding: 8px;
    text-align: left;
}
.msg-ai th {
    background: #0f3460;
}
.msg-ai strong {
    color: #fff;
}
.ai-input-area {
    flex-shrink: 0;
    padding: 15px;
    padding-bottom: calc(15px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid #2a2a4a;
    background: #1a1a2e;
}
.ai-suggestions {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    overflow-x: auto;
    padding-bottom: 5px;
}
.ai-suggestions span {
    background: #ffffff1f;
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    border: 1px solid #3a4665;
    transition: 0.2s;
}
.ai-suggestions span:hover {
    background: #ffffff33;
}
.ai-input-wrapper {
    display: flex;
    gap: 10px;
}
.ai-input-wrapper input {
    flex: 1;
    padding: 12px 15px;
    border-radius: 25px;
    border: 1px solid #3a4665;
    background: #10182e;
    color: #fff;
    outline: none;
    font-size: 14px;
}
.ai-input-wrapper button {
    background: #00bcd4;
    color: white;
    border: none;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}
.ai-typing {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 12px 16px;
}
.dot {
    width: 6px;
    height: 6px;
    background: #888;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}
.dot:nth-child(1) {
    animation-delay: -0.32s;
}
.dot:nth-child(2) {
    animation-delay: -0.16s;
}
@keyframes bounce {
    0%,
    80%,
    100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

@media (max-width: 900px) {
    .grid-2 {
        grid-template-columns: 1fr;
    }
    .header {
        text-align: left;
        padding-bottom: 60px;
    }
    .user-area {
        left: 20px;
        right: auto;
        top: auto;
        bottom: 12px;
    }
    .section {
        padding: 16px;
    }
    .ai-sidebar {
        width: 100%;
        right: -100%;
    }
    .ai-header {
        padding: 14px 16px;
    }
    .ai-chat-area {
        padding: 14px;
    }
    .ai-input-wrapper input {
        font-size: 16px;
    }
}
@media (max-width: 650px) {
    .detail-layout {
        grid-template-columns: 1fr;
    }
    .detail-image,
    .detail-no-image {
        width: 100%;
        height: 190px;
    }
    .report-header {
        align-items: flex-start;
        flex-direction: column;
    }
}
@media print {
    body {
        background: #fff;
        color: #000;
    }
    body * {
        visibility: hidden !important;
    }
    body.print-producao #relatorio-impressao,
    body.print-producao #relatorio-impressao *,
    body.print-diario #relatorio-diario-impressao,
    body.print-diario #relatorio-diario-impressao *,
    body.print-testes #relatorio-testes-impressao,
    body.print-testes #relatorio-testes-impressao *,
    body.print-folhas #relatorio-folhas-impressao,
    body.print-folhas #relatorio-folhas-impressao * {
        visibility: visible !important;
    }
    body.print-producao #relatorio-impressao,
    body.print-diario #relatorio-diario-impressao,
    body.print-testes #relatorio-testes-impressao,
    body.print-folhas #relatorio-folhas-impressao {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        color: #000;
    }
    .report-section {
        break-inside: avoid;
        margin: 0 0 24px;
    }
    .report-header h3 {
        font-size: 16px;
    }
    .report-meta {
        color: #444;
    }
    .report-table {
        font-size: 9pt;
    }
    .report-table th {
        background: #2e6d57 !important;
        color: #fff !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .report-table td {
        border-color: #bbb;
    }
    .report-total {
        color: #000;
    }
    .no-print {
        display: none !important;
    }
}
/* ESTILO DAS SEÇÕES MINIMIZÁVEIS */
/* Seções recolhíveis. Não usam <details>: o Ctrl+F do navegador abre <details> fechados ao achar texto
   dentro deles. Com display:none a busca ignora as seções fechadas. */
.sessao-minimizada {
    background: #16213e;
    border-radius: 16px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    border: 1px solid #2a2a4a;
    transition: all 0.3s ease;
}
.sessao-minimizada > .sessao-cabecalho {
    cursor: pointer;
    outline: none;
    margin-bottom: 0 !important;
    user-select: none;
}
.sessao-minimizada > .sessao-cabecalho:focus-visible {
    box-shadow: 0 0 0 2px #00bcd4;
    border-radius: 6px;
}
.sessao-minimizada > .sessao-cabecalho::after {
    content: '▼';
    font-size: 14px;
    color: #888;
    transition: transform 0.3s;
    margin-left: 15px;
    display: inline-block;
}
.sessao-minimizada.aberta > .sessao-cabecalho::after {
    transform: rotate(180deg);
}
.conteudo-oculto {
    display: none;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #2a2a4a;
    animation: fadeIn 0.4s ease;
}
.sessao-minimizada.aberta > .conteudo-oculto {
    display: block;
}
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Chat da IA: PDFs e pergunta por voz */
.ai-arquivos {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 10px;
}
.ai-arquivos button {
    background: #0f3460;
    color: #fff;
    border: 1px solid #3a4665;
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    overflow-wrap: anywhere;
}
.ai-arquivos button:hover {
    border-color: #00bcd4;
}
.ai-input-wrapper input {
    min-width: 0;
}
.ai-input-wrapper button {
    flex-shrink: 0;
}
.ai-input-wrapper button:disabled {
    opacity: 0.5;
    cursor: default;
}
#ai-mic.gravando {
    background: #e53935;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}
.user-acoes {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
}
.link-telegram {
    width: 100%;
    padding: 10px;
    margin: 12px 0;
    border-radius: 6px;
    border: 1px solid #3a4665;
    background: #10182e;
    color: #fff;
    font-size: 13px;
}
