/* Ponto da Esfiha — Bootstrap visual layer */
:root {
    --pe-red: #9b111e;
    --pe-red-dark: #6f0c16;
    --pe-wood: #5a3827;
    --pe-cream: #fff7ea;
    --pe-bg: #f6f1ea;
    --pe-ink: #221a16;
    --sidebar-width: 78px;
    --sidebar-open: 270px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: Arial, Helvetica, sans-serif;
    background:
        radial-gradient(circle at top right, rgba(155, 17, 30, .12), transparent 34%),
        linear-gradient(135deg, #fbf8f2 0%, var(--pe-bg) 100%);
    color: var(--pe-ink);
}

.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, var(--pe-wood) 0%, var(--pe-red-dark) 100%);
    color: #fff;
    transition: width .22s ease;
    overflow: hidden;
    z-index: 1050;
    box-shadow: 8px 0 28px rgba(0,0,0,.16);
}

.sidebar:hover { width: var(--sidebar-open); }

.sidebar-logo {
    height: 76px;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 18px;
    border-bottom: 1px solid rgba(255,255,255,.16);
    white-space: nowrap;
    color: #fff;
    text-decoration: none;
}

.sidebar-logo:hover { color: #fff; }

.brand-icon {
    width: 42px;
    height: 42px;
    min-width: 42px;
    border-radius: 14px;
    background: var(--pe-cream);
    color: var(--pe-red);
    display: grid;
    place-items: center;
    font-weight: 900;
    letter-spacing: -.5px;
    box-shadow: inset 0 -3px 0 rgba(155,17,30,.12);
}

.sidebar-logo .text {
    display: flex;
    flex-direction: column;
    line-height: 1.05;
    opacity: 0;
    transform: translateX(-6px);
    transition: .18s ease;
}

.sidebar-logo .text small {
    opacity: .75;
    margin-top: 5px;
    font-size: 12px;
}

.sidebar:hover .sidebar-logo .text,
.sidebar:hover .sidebar-menu .text {
    opacity: 1;
    transform: translateX(0);
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    padding: 16px 12px;
}

.sidebar-menu a {
    color: rgba(255,255,255,.9);
    text-decoration: none;
    min-height: 52px;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 15px;
    margin-bottom: 7px;
    white-space: nowrap;
    border-radius: 16px;
    transition: .16s ease;
}

.sidebar-menu a:hover,
.sidebar-menu a.active {
    background: rgba(255,255,255,.15);
    color: #fff;
    box-shadow: inset 3px 0 0 var(--pe-cream);
}

.sidebar-menu .icon {
    width: 22px;
    min-width: 22px;
    text-align: center;
    font-size: 22px;
}

.sidebar-menu .text {
    opacity: 0;
    transform: translateX(-6px);
    transition: .18s ease;
    font-weight: 800;
    font-size: 14px;
}

.main {
    margin-left: var(--sidebar-width);
    padding: 26px;
}

.topbar {
    border: 0;
    border-radius: 24px;
    margin-bottom: 22px;
    padding: 24px 28px;
    background:
        linear-gradient(135deg, rgba(91,54,35,.94), rgba(155,17,30,.94)),
        linear-gradient(135deg, #5a3827, #9b111e);
    color: #fff;
    box-shadow: 0 14px 36px rgba(69,36,22,.22);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.topbar h1 {
    margin: 0 0 4px;
    font-size: 28px;
    font-weight: 900;
    letter-spacing: -.5px;
}

.topbar p {
    margin: 0;
    color: rgba(255,255,255,.78);
}

.turno-badge {
    background: rgba(255,255,255,.16);
    color: #fff;
    border: 1px solid rgba(255,255,255,.25);
    padding: 10px 14px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 900;
    white-space: nowrap;
}

.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 18px;
}

.card {
    background: #fff;
    border: 0;
    border-radius: 22px;
    padding: 22px;
    box-shadow: 0 12px 30px rgba(52,35,26,.08);
    cursor: pointer;
    text-align: left;
    transition: transform .16s ease, box-shadow .16s ease;
    position: relative;
    overflow: hidden;
}

button.card::after {
    content: "";
    position: absolute;
    width: 92px;
    height: 92px;
    right: -36px;
    top: -36px;
    background: rgba(155,17,30,.10);
    border-radius: 50%;
    transition: .18s ease;
}

button.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 18px 40px rgba(52,35,26,.13);
}

button.card:hover::after { transform: scale(1.25); }

.card-title {
    font-size: 20px;
    font-weight: 900;
    margin-bottom: 8px;
    position: relative;
    z-index: 1;
}

.card-subtitle {
    color: #756c66;
    font-size: 14px;
    position: relative;
    z-index: 1;
}

.btn {
    border-radius: 13px;
    padding: 11px 15px;
    cursor: pointer;
    font-weight: 800;
    text-decoration: none;
    display: inline-block;
    font-size: 14px;
    border: 1px solid transparent;
}

.btn-primary {
    background: var(--pe-red) !important;
    border-color: var(--pe-red) !important;
    color: #fff !important;
}

.btn-primary:hover { background: var(--pe-red-dark) !important; }

.btn-dark { background: #1f1b18 !important; color: #fff !important; }
.btn-light { background: #f3ede5 !important; color: #1f1b18 !important; }
.btn-danger { background: #b00020 !important; color: #fff !important; }

.form-box,
.table-box {
    background: #fff;
    padding: 22px;
    border-radius: 22px;
    box-shadow: 0 12px 30px rgba(52,35,26,.08);
}

.form-box { max-width: 640px; }

.form-row { margin-bottom: 16px; }

label {
    display: block;
    margin-bottom: 7px;
    font-weight: 800;
}

input, select, textarea {
    width: 100%;
    padding: 13px 14px;
    border-radius: 14px;
    border: 1px solid #d8ccc0;
    font-size: 16px;
    background: #fff;
}

input:focus, select:focus, textarea:focus {
    outline: 0;
    border-color: rgba(155,17,30,.45);
    box-shadow: 0 0 0 .25rem rgba(155,17,30,.12);
}

textarea {
    resize: vertical;
    min-height: 85px;
}

.table-box { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    border-bottom: 1px solid #f0e7df;
    padding: 13px;
    text-align: left;
}

th {
    color: #6a5d55;
    background: #fffaf5;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .06em;
}

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(27,19,15,.62);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.modal-overlay.active { display: flex; }

.system-modal {
    display: block;
    position: relative;
    width: 100%;
    max-width: 470px;
    background: #fff;
    border-radius: 24px;
    padding: 26px;
    box-shadow: 0 22px 60px rgba(0,0,0,.22);
}

.system-modal h2 {
    margin-top: 0;
    font-weight: 900;
    letter-spacing: -.3px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 18px;
}

.alert {
    padding: 14px 16px;
    border-radius: 18px;
    margin-bottom: 18px;
    background: #e8f7ed;
    color: #126126;
    font-weight: 800;
    border: 0;
    box-shadow: 0 8px 24px rgba(52,35,26,.06);
}

.alert.error {
    background: #ffe6e6;
    color: #9b111e;
}

.print-area {
    background: #fff;
    width: 80mm;
    min-height: 120mm;
    padding: 8mm;
    color: #000;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    line-height: 1.35;
    margin: 0 auto;
    border-radius: 10px;
    box-shadow: 0 16px 38px rgba(0,0,0,.10);
    box-sizing: border-box;
}

.print-title { text-align: center; font-weight: bold; font-size: 15px; margin-bottom: 4px; }
.print-subtitle { text-align: center; font-size: 11px; margin-bottom: 10px; }
.print-sep { border-top: 1px dashed #000; margin: 9px 0; }
.print-section-title { font-weight: bold; text-align: center; margin: 8px 0; }
.print-row { margin-bottom: 6px; }
.print-small { font-size: 11px; }
.no-print { display: block; }

@media (max-width: 768px) {
    .sidebar {
        top: auto;
        bottom: 0;
        width: 100%;
        height: 74px;
        overflow-x: auto;
        overflow-y: hidden;
        box-shadow: 0 -8px 24px rgba(0,0,0,.16);
    }

    .sidebar:hover { width: 100%; }
    .sidebar-logo { display: none; }

    .sidebar-menu {
        min-width: max-content;
        height: 74px;
        flex-direction: row;
        align-items: center;
        padding: 6px 8px;
        gap: 4px;
    }

    .sidebar-menu a {
        min-width: 76px;
        min-height: 62px;
        flex-direction: column;
        justify-content: center;
        gap: 2px;
        padding: 5px 9px;
        margin: 0;
        border-radius: 14px;
    }

    .sidebar-menu .icon {
        width: auto;
        min-width: 0;
        font-size: 20px;
    }

    .sidebar-menu .text,
    .sidebar:hover .sidebar-menu .text {
        opacity: 1;
        transform: none;
        font-size: 10px;
        line-height: 1.1;
    }

    .main {
        margin-left: 0;
        padding: 16px 14px 94px;
    }

    .topbar {
        flex-direction: column;
        align-items: flex-start;
        padding: 18px;
        border-radius: 18px;
    }

    .topbar h1 { font-size: 23px; }

    .grid-cards {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 12px;
    }

    .card {
        padding: 17px;
        border-radius: 18px;
    }

    .card-title { font-size: 17px; }
    .form-box, .table-box { padding: 16px; border-radius: 18px; }
    th, td { padding: 11px 9px; }

    .modal-overlay { padding: 12px; }
    .system-modal {
        max-height: 92vh;
        overflow-y: auto;
        padding: 20px;
        border-radius: 20px;
    }

    .modal-actions {
        flex-direction: column-reverse;
    }

    .modal-actions .btn { width: 100%; text-align: center; }
}

@media print {
    body { background: #fff !important; margin: 0; }
    .sidebar, .topbar, .no-print { display: none !important; }
    .main { margin: 0; padding: 0; }
    .print-area { width: 80mm; margin: 0; box-shadow: none; border-radius: 0; padding: 6mm; }
    @page { size: 80mm auto; margin: 0; }
}


body.modal-open-sistema { overflow: hidden; }

button:disabled,
input[type="submit"]:disabled {
    cursor: wait;
    opacity: .7;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 5px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 900;
}

.status-active { background: #e8f7ed; color: #126126; }
.status-inactive { background: #f3ede5; color: #6a5d55; }
.status-open { background: #fff0d5; color: #7a4a00; }
.status-closed { background: #e8f7ed; color: #126126; }

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.summary-card {
    background: #fff;
    border-radius: 18px;
    padding: 16px;
    box-shadow: 0 10px 26px rgba(52,35,26,.07);
}

.summary-card small {
    display: block;
    color: #756c66;
    font-weight: 800;
    margin-bottom: 4px;
}

.summary-card strong {
    font-size: 21px;
    line-height: 1.1;
}

.inline-form { display: inline; }

.planilha-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.planilha-box {
    max-width: 760px;
    margin: 0 auto;
}

.planilha-help {
    margin-bottom: 14px;
    padding: 12px 14px;
    border-radius: 14px;
    background: #f7f3ee;
    color: #5b5049;
    font-weight: 700;
}

.copy-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
    border: 1px solid #e3ddd7;
    border-radius: 14px;
}

.copy-table th,
.copy-table td {
    border-bottom: 1px solid #e9e3dd;
    border-right: 1px solid #e9e3dd;
}

.copy-table th:last-child,
.copy-table td:last-child {
    border-right: 0;
    width: 170px;
    white-space: nowrap;
}

.copy-table tbody tr:last-child td {
    border-bottom: 0;
}

.copy-table tbody tr:hover td {
    background: #fff9f4;
}

.copy-success {
    background: #126126 !important;
    border-color: #126126 !important;
}

@media (max-width: 768px) {
    .planilha-actions {
        width: 100%;
        justify-content: stretch;
    }

    .planilha-actions .btn {
        flex: 1 1 100%;
        text-align: center;
    }

    .copy-table th:last-child,
    .copy-table td:last-child {
        width: 115px;
    }
}


/* Comprovante de vale: duas páginas curtas para corte automático */
.modal-actions-vale {
    flex-wrap: wrap;
}

.modal-actions-vale .btn-primary {
    min-width: 210px;
}

.receipt-page {
    margin: 0;
    padding: 24px;
    background: #efe9e3;
    color: #000;
    font-family: Arial, Helvetica, sans-serif;
}

.receipt-toolbar {
    width: min(100%, 92mm);
    margin: 0 auto 16px;
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.receipt-sheet {
    width: 80mm;
    margin: 0 auto;
}

.receipt-copy {
    width: 80mm;
    min-height: 72mm;
    box-sizing: border-box;
    margin: 0 auto 16px;
    padding: 4mm 5mm;
    background: #fff;
    box-shadow: 0 12px 32px rgba(0,0,0,.14);
    font-size: 11px;
    line-height: 1.18;
    break-inside: avoid;
    page-break-inside: avoid;
}

.receipt-copy:not(:last-child) {
    break-after: page;
    page-break-after: always;
}

.receipt-brand {
    text-align: center;
    font-size: 14px;
    font-weight: 900;
    letter-spacing: .03em;
}

.receipt-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-top: 3px;
}

.receipt-heading strong {
    font-size: 14px;
}

.receipt-heading span {
    font-size: 9px;
    font-weight: 900;
}

.receipt-separator {
    margin: 5px 0;
    border-top: 1px dashed #000;
}

.receipt-row {
    margin: 4px 0;
}

.receipt-row span {
    display: block;
    font-size: 8px;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.receipt-row strong {
    display: block;
    margin-top: 1px;
    font-size: 12px;
    overflow-wrap: anywhere;
}

.receipt-reason strong {
    max-height: 28px;
    overflow: hidden;
}

.receipt-value {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin: 6px 0;
    padding: 5px 0;
    border-top: 1px solid #000;
    border-bottom: 1px solid #000;
}

.receipt-value span {
    font-size: 9px;
    font-weight: 900;
    text-transform: uppercase;
}

.receipt-value strong {
    font-size: 22px;
    line-height: 1;
}

.receipt-date {
    margin-top: 5px;
    text-align: right;
    font-size: 9px;
    font-weight: 700;
}

.receipt-signature {
    margin-top: 9mm;
    text-align: center;
    font-size: 9px;
}

.receipt-signature-line {
    margin-bottom: 3px;
    border-top: 1px solid #000;
}

.receipt-cancelled {
    margin: 5px 0;
    padding: 4px;
    text-align: center;
    font-size: 10px;
    font-weight: 900;
    border: 2px solid #000;
}

@media (max-width: 480px) {
    .receipt-page {
        padding: 12px 0 30px;
    }

    .receipt-toolbar {
        padding: 0 12px;
    }

    .receipt-toolbar .btn {
        width: 100%;
    }

    .receipt-sheet,
    .receipt-copy {
        width: min(80mm, 100vw);
    }
}

@media print {
    html,
    body.receipt-page {
        width: 80mm !important;
        min-width: 80mm !important;
        max-width: 80mm !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: hidden !important;
        background: #fff !important;
    }

    .receipt-sheet {
        display: block !important;
        width: 80mm !important;
        min-width: 80mm !important;
        max-width: 80mm !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .receipt-copy {
        display: flex !important;
        flex-direction: column !important;
        width: 80mm !important;
        min-width: 80mm !important;
        max-width: 80mm !important;
        height: 80mm !important;
        min-height: 80mm !important;
        max-height: 80mm !important;
        margin: 0 !important;
        padding: 3mm 4mm !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
        box-shadow: none !important;
        break-inside: avoid !important;
        page-break-inside: avoid !important;
    }

    .receipt-copy:not(:last-child) {
        break-after: page !important;
        page-break-after: always !important;
    }

    .receipt-signature {
        margin-top: auto !important;
        padding-top: 5mm !important;
    }

    @page {
        size: 80mm 80mm;
        margin: 0;
    }
}

.table-actions {
    display: flex;
    gap: 7px;
    align-items: center;
    flex-wrap: wrap;
}

.table-actions .btn {
    white-space: nowrap;
}


/* Medição com as mesmas dimensões usadas na impressão do relatório */
body.report-page.report-measuring .print-area {
    width: 80mm !important;
    min-width: 80mm !important;
    max-width: 80mm !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    padding: 3mm 4mm 4mm !important;
    box-sizing: border-box !important;
    overflow: visible !important;
    box-shadow: none !important;
    border-radius: 0 !important;
}

/* Relatórios em bobina contínua de 80 mm */
@media print {
    body.report-page {
        width: 80mm !important;
        min-width: 80mm !important;
        max-width: 80mm !important;
        height: auto !important;
        min-height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: visible !important;
        background: #fff !important;
    }

    body.report-page .main {
        width: 80mm !important;
        min-width: 80mm !important;
        max-width: 80mm !important;
        height: auto !important;
        min-height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: visible !important;
    }

    body.report-page .print-area {
        display: block !important;
        width: 80mm !important;
        min-width: 80mm !important;
        max-width: 80mm !important;
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
        margin: 0 !important;
        padding: 3mm 4mm 4mm !important;
        box-sizing: border-box !important;
        overflow: visible !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        break-before: auto !important;
        break-after: auto !important;
        break-inside: auto !important;
        page-break-before: auto !important;
        page-break-after: auto !important;
        page-break-inside: auto !important;
    }

    body.report-page .print-area,
    body.report-page .print-area * {
        break-before: auto !important;
        break-after: auto !important;
        page-break-before: auto !important;
        page-break-after: auto !important;
    }
}
