/* =========================================================
   RESET / BASE
========================================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: Arial, Helvetica, sans-serif;
    background: #f4f6f9;
    color: #1f2937;
    line-height: 1.4;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

a {
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

/* =========================================================
   LOGIN
========================================================= */
body.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.login-card {
    background: #ffffff;
    border-radius: 14px;
    padding: 32px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
}

.login-card h1 {
    font-size: 28px;
    color: #1f2937;
    margin-bottom: 8px;
    text-align: center;
}

.subtitulo {
    text-align: center;
    color: #6b7280;
    margin-bottom: 24px;
}

.alerta-erro {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}

/* =========================================================
   APP LAYOUT
========================================================= */
body.app-body {
    margin: 0;
}

.topbar {
    background: #1f2937;
    color: #fff;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.topbar h1 {
    margin: 0;
    font-size: 22px;
}

.topbar-subtitle {
    display: block;
    margin-top: 4px;
    font-size: 13px;
    color: #cbd5e1;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.page-container {
    width: 100%;
    max-width: 1280px;
    margin: 24px auto;
    padding: 0 16px 32px;
}

/* =========================================================
   BOTÕES
========================================================= */
.btn-topbar,
.btn-topbar-danger,
.btn-primary,
.btn-secondary,
.btn-warning,
.btn-remove,
.btn-print,
.btn-mail,
.btn-whatsapp,
.btn-close,
.toolbar a,
.toolbar button,
.toolbar-print .btn-toolbar,
.acoes-tabela .btn-acao {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 10px 16px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
    transition: 0.2s;
}

.btn-topbar {
    background: #374151;
    color: #fff;
}

.btn-topbar-danger {
    background: #b91c1c;
    color: #fff;
}

.btn-primary {
    background: #2563eb;
    color: #fff;
    text-transform: uppercase;
}

.btn-primary:hover {
    background: #1d4ed8;
}

.btn-secondary {
    background: #e5e7eb;
    color: #111827;
    text-transform: uppercase;
}

.btn-secondary:hover {
    background: #d1d5db;
}

.btn-warning {
    background: #f59e0b;
    color: #fff;
    text-transform: uppercase;
}

.btn-warning:hover {
    background: #d97706;
}

.btn-remove {
    background: #dc2626;
    color: #fff;
    text-transform: uppercase;
}

.btn-remove:hover {
    background: #b91c1c;
}

.btn-print {
    background: #2563eb;
    color: #fff;
}

.btn-mail {
    background: #7c3aed;
    color: #fff;
}

.btn-whatsapp {
    background: #16a34a;
    color: #fff;
}

.btn-close {
    background: #e5e7eb;
    color: #111827;
}

/* =========================================================
   CARDS / BLOCOS
========================================================= */
.card-section {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
    margin-bottom: 16px;
    overflow: hidden;
}

.card-header {
    padding: 18px 20px;
    border-bottom: 1px solid #e5e7eb;
    background: #fafafa;
}

.card-header-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.card-header h2 {
    margin: 0;
    font-size: 18px;
}

.card-body {
    padding: 20px;
}

.mt-16 {
    margin-top: 16px;
}

/* =========================================================
   FORMULÁRIOS
========================================================= */
.form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 18px;
}

.form-group label {
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: bold;
    color: #374151;
}

.form-group input,
.form-group select,
.form-group textarea,
.item-input {
    width: 100%;
    min-height: 42px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    outline: none;
    background: #fff;
}

.item-input {
    min-height: 40px;
    padding: 8px 10px;
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.item-input:focus {
    border-color: #2563eb;
}

.form-group small {
    margin-top: 6px;
    font-size: 12px;
    color: #6b7280;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    gap: 16px;
}

/* =========================================================
   TABELAS
========================================================= */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.items-table {
    width: 100%;
    min-width: 950px;
    border-collapse: collapse;
    font-size: 13px;
}

.items-table th,
.items-table td {
    border-bottom: 1px solid #e5e7eb;
    padding: 10px 8px;
    text-align: left;
    vertical-align: top;
}

.items-table th {
    background: #f9fafb;
    font-size: 14px;
    color: #374151;
}

/* =========================================================
   TOTAIS / AÇÕES
========================================================= */
.totais-box {
    margin-top: 20px;
    padding: 18px;
    border-radius: 12px;
    background: #f9fafb;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
}

.total-label {
    font-size: 16px;
    font-weight: bold;
    color: #374151;
}

.total-value {
    font-size: 26px;
    font-weight: bold;
    color: #111827;
}

.actions-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.actions-right {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* =========================================================
   TIMELINE
========================================================= */
.timeline {
    position: relative;
    margin-top: 8px;
    padding-left: 24px;
    border-left: 2px solid #dbe3ea;
}

.timeline-item {
    position: relative;
    padding: 0 0 18px 12px;
}

.timeline-dot {
    position: absolute;
    left: -31px;
    top: 4px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #2563eb;
    border: 3px solid #ffffff;
    box-shadow: 0 0 0 1px #cbd5e1;
}

.timeline-content {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 12px 14px;
}

.timeline-header {
    font-size: 15px;
    color: #111827;
    margin-bottom: 4px;
}

.timeline-meta {
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 8px;
}

.timeline-observacao {
    font-size: 14px;
    color: #374151;
    line-height: 1.5;
    white-space: pre-wrap;
}

/* =========================================================
   GALERIA / ANEXOS
========================================================= */
.anexos-bloco {
    margin-bottom: 24px;
}

.anexos-titulo {
    margin: 0 0 14px 0;
    font-size: 18px;
    color: #1f2937;
}

.galeria-fotos {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.foto-card {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.04);
}

.foto-thumb {
    width: 100%;
    height: 180px;
    object-fit: cover;
    background: #e5e7eb;
}

.foto-info {
    padding: 12px;
}

.foto-nome {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 6px;
    word-break: break-word;
}

.foto-data {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 10px;
}

.foto-acoes {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* =========================================================
   TOOLBARS
========================================================= */
.toolbar,
.toolbar-print {
    max-width: 1100px;
    margin: 20px auto 0;
    padding: 0 16px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.toolbar a {
    color: #fff;
}

.toolbar-print .btn-toolbar {
    min-width: 150px;
    height: 40px;
    box-sizing: border-box;
    font-family: Arial, Helvetica, sans-serif;
    text-decoration: none !important;
}

/* =========================================================
   AÇÕES DAS TABELAS
========================================================= */
.acoes-tabela {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.acoes-tabela .btn-acao {
    min-width: 135px;
    height: 36px;
    padding: 0 12px;
    font-size: 13px;
    line-height: 1;
    box-sizing: border-box;
}

.acoes-tabela .btn-ver {
    background: #2563eb;
    color: #fff !important;
}

.acoes-tabela .btn-imprimir {
    background: #475569;
    color: #fff !important;
}

.acoes-tabela .btn-cotacao {
    background: #7c3aed;
    color: #fff !important;
}

.acoes-tabela .btn-solicitar {
    background: #0f766e;
    color: #fff !important;
}

.acoes-tabela .btn-comprada {
    background: #d97706;
    color: #fff !important;
}

.acoes-tabela .btn-acao:hover {
    opacity: 0.92;
}

/* =========================================================
   DASHBOARD
========================================================= */
.dashboard-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.dashboard-card a {
    margin-top: 12px;
}

/* =========================================================
   IMPRESSÃO
========================================================= */
.assinaturas {
    margin-top: 60px;
}

.rodape {
    margin-top: 60px;
    text-align: center;
    font-size: 12px;
    color: #9ca3af;
    border-top: 1px solid #e5e7eb;
    padding-top: 10px;
}

@media print {
    .rodape {
        position: fixed;
        bottom: 5mm;
        left: 0;
        right: 0;
        font-size: 9px;
    }
}

/* =========================================================
   RESPONSIVO
========================================================= */
@media (max-width: 1100px) {
    .form-grid {
        grid-template-columns: repeat(2, minmax(180px, 1fr));
    }
}

@media (max-width: 900px) {
    .acoes-tabela {
        min-width: 220px;
    }

    .acoes-tabela .btn-acao {
        width: 100%;
        min-width: 100%;
    }
}

@media (max-width: 640px) {
    .login-card {
        padding: 24px 18px;
    }

    .topbar {
        padding: 14px 16px;
    }

    .topbar,
    .topbar-right,
    .toolbar,
    .toolbar-print,
    .actions-row,
    .actions-right {
        flex-direction: column;
        align-items: stretch;
    }

    .page-container {
        margin-top: 16px;
        padding: 0 12px 24px;
    }

    .card-body,
    .card-header {
        padding: 16px;
    }

    .card-header h2 {
        font-size: 17px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .total-value {
        font-size: 22px;
    }

    .actions-row,
    .actions-right {
        width: 100%;
    }

    .actions-row button,
    .actions-row a,
    .actions-right button,
    .actions-right a,
    .toolbar a,
    .toolbar button,
    .toolbar-print .btn-toolbar,
    .btn-topbar,
    .btn-topbar-danger {
        width: 100%;
    }

    .acoes-tabela {
        flex-direction: column;
        align-items: stretch;
    }

    .acoes-tabela .btn-acao {
        width: 100%;
        min-width: 100%;
    }

    .totais-box {
        justify-content: flex-start;
    }

    .foto-acoes {
        flex-direction: column;
    }

    .foto-acoes a,
    .foto-acoes button {
        width: 100%;
    }
}