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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f0f2f5;
    color: #333;
    min-height: 100vh;
}

.header {
    background: linear-gradient(135deg, #1a237e, #283593);
    color: white;
    padding: 20px 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    position: relative;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-logo {
    height: 90px;
    width: auto;
    border-radius: 6px;
}

.header-info h1 {
    font-size: 28px;
    letter-spacing: 1px;
    margin-bottom: 5px;
}

.sync-status {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 14px;
    color: #ffd54f;
    cursor: default;
    transition: color 0.3s;
}
.sync-status.synced {
    color: #81c784;
}
.sync-status.error {
    color: #e57373;
}
.sync-status.loading {
    animation: pulse 1s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

@media (max-width: 768px) {
    .sync-status {
        top: 6px;
        right: 10px;
        font-size: 12px;
    }
}

.header-info p {
    font-size: 14px;
    opacity: 0.9;
    line-height: 1.6;
}

.nav {
    background: white;
    display: flex;
    gap: 0;
    padding: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
    overflow-x: auto;
}

.nav-btn {
    background: none;
    border: none;
    padding: 14px 24px;
    font-size: 15px;
    font-weight: 500;
    color: #555;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    border-bottom: 3px solid transparent;
}

.nav-btn:hover {
    background: #f5f5f5;
    color: #1a237e;
}

.nav-btn.active {
    color: #1a237e;
    border-bottom-color: #1a237e;
    font-weight: 600;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 20px;
}

.page {
    display: none;
}

.page.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

h2 {
    color: #1a237e;
    margin-bottom: 20px;
    font-size: 22px;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 10px;
}

h3 {
    color: #333;
    margin: 20px 0 10px;
    font-size: 17px;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    text-align: center;
}

.stat-number {
    font-size: 36px;
    font-weight: 700;
    color: #1a237e;
    margin-bottom: 5px;
}

.quick-actions {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.action-btns {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.form {
    background: white;
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 24px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
    color: #444;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 15px;
    transition: border-color 0.2s;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #1a237e;
    box-shadow: 0 0 0 3px rgba(26,35,126,0.1);
}

.form-group input.readonly {
    background: #f5f5f5;
    color: #666;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.btn-primary {
    background: #1a237e;
    color: white;
    border: none;
    padding: 11px 24px;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: #283593;
}

.btn-secondary {
    background: white;
    color: #1a237e;
    border: 2px solid #1a237e;
    padding: 9px 22px;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: #f0f0f0;
}

.btn-sm {
    padding: 4px 8px;
    font-size: 11px;
    border-radius: 3px;
    border: none;
    cursor: pointer;
    margin: 1px;
    font-weight: 500;
    white-space: nowrap;
}

.btn-sm-print {
    background: #1a237e;
    color: white;
}

.btn-sm-print:hover {
    background: #283593;
}

.btn-sm-deliver {
    background: #2e7d32;
    color: white;
}

.btn-sm-deliver:hover {
    background: #388e3c;
}

.btn-sm-edit {
    background: #f57f17;
    color: white;
}

.btn-sm-edit:hover {
    background: #f9a825;
}

.btn-sm-delete {
    background: #c62828;
    color: white;
}

.btn-sm-delete:hover {
    background: #e53935;
}

.search-input {
    padding: 10px 14px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 14px;
    width: 100%;
    max-width: 400px;
    margin-bottom: 12px;
}

.search-input:focus {
    outline: none;
    border-color: #1a237e;
}

.table-container {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

thead th {
    background: #1a237e;
    color: white;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
}

tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid #e0e0e0;
}

tbody tr:hover {
    background: #f5f5f5;
}

tbody tr:last-child td {
    border-bottom: none;
}

.empty-msg {
    text-align: center;
    padding: 40px;
    color: #888;
    font-style: italic;
}

/* ============= PRINT STYLES ============= */
@page {
    margin: 5mm;
}

@media print {
    body {
        background: white;
    }
    .no-print {
        display: none !important;
    }
    .page, .nav, .nav-btn, .container > .form,
    .container > .table-container, .form-actions,
    .btn-primary, .btn-secondary, #rel-resultado,
    .modal-overlay {
        display: none !important;
    }
    #page-relatorios { display: none !important; }
}

.print-container {
    display: none;
}

.print-container.active {
    display: block;
}

.print-os, .print-entrega {
    max-width: 210mm;
    width: 210mm;
    min-height: 148mm;
    margin: 0 auto;
    padding: 12mm 15mm;
    background: white;
    font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    position: relative;
}

.print-header {
    text-align: center;
    border-bottom: 3px double #000;
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.print-header h1 {
    font-size: 22px;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.print-header p {
    font-size: 12px;
    line-height: 1.5;
    margin: 2px 0;
}

.print-title {
    text-align: center;
    font-size: 18px;
    font-weight: bold;
    margin: 15px 0;
    text-transform: uppercase;
    border: 2px solid #000;
    display: inline-block;
    padding: 5px 30px;
}

.print-section {
    margin: 10px 0;
}

.print-section table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    border: 1px solid #000;
}

.print-section table td {
    padding: 4px 8px;
    border: 1px solid #000;
    vertical-align: top;
    word-break: break-word;
}

.print-section table td.label {
    font-weight: bold;
    width: 1%;
    white-space: nowrap;
    background: #f0f0f0;
}

.print-warranty {
    margin-top: 15px;
    padding: 8px;
    border: 2px solid #000;
    text-align: center;
    font-size: 12px;
    font-weight: bold;
}

.print-signature {
    margin-top: 30px;
    display: flex;
    justify-content: space-between;
}

.print-signature div {
    text-align: center;
    width: 45%;
}

.print-signature .line {
    border-top: 1px solid #000;
    margin-top: 40px;
    padding-top: 5px;
    font-size: 12px;
}

.print-obs {
    margin-top: 10px;
    font-size: 11px;
    border: 1px dashed #999;
    padding: 8px;
    min-height: 40px;
}

@media screen {
    .print-container.active {
        padding: 20px;
        background: #e0e0e0;
        text-align: center;
    }
    .print-container.active .print-os,
    .print-container.active .print-entrega {
        box-shadow: 0 4px 12px rgba(0,0,0,0.2);
        margin: 0 auto 20px;
        text-align: left;
    }
    .print-btn-bar {
        max-width: 210mm;
        margin: 0 auto 10px;
        display: flex;
        gap: 10px;
        text-align: left;
    }
}

@media print {
    .print-container {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 9999;
        overflow: auto;
    }
    .print-container.active {
        display: block !important;
    }
    .print-os, .print-entrega {
        width: auto;
        max-width: 100%;
        box-shadow: none;
        margin: 0;
        padding: 8mm 12mm;
    }
    .print-btn-bar, .no-print {
        display: none !important;
    }
}

.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

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

.modal {
    background: white;
    border-radius: 8px;
    padding: 24px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.modal h3 {
    margin-top: 0;
    margin-bottom: 16px;
}

.modal .form-group {
    margin-bottom: 12px;
}

.modal .form-actions {
    margin-top: 16px;
}

.modal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 14px;
}

.btn-compact {
    padding: 7px 12px;
    font-size: 12px;
}

.login-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(135deg, #1a237e, #283593);
    z-index: 9999;
    justify-content: center;
    align-items: center;
}
.login-overlay.active {
    display: flex;
}
.login-box {
    background: white;
    padding: 40px 32px;
    border-radius: 12px;
    text-align: center;
    width: 90%;
    max-width: 360px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.login-logo {
    height: 80px;
    border-radius: 8px;
    margin-bottom: 16px;
}
.login-box h2 {
    color: #1a237e;
    font-size: 20px;
    margin-bottom: 4px;
    border: none;
    padding: 0;
}
.login-box p {
    color: #666;
    font-size: 14px;
    margin-bottom: 24px;
}
.login-box input[type="password"] {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #ccc;
    border-radius: 8px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s;
    margin-bottom: 16px;
    box-sizing: border-box;
}
.login-box input[type="password"]:focus {
    border-color: #1a237e;
}
.login-box .btn-primary {
    width: 100%;
    padding: 12px;
    font-size: 16px;
}
.login-error {
    color: #c62828;
    font-size: 13px;
    margin-top: 10px;
    display: none;
}
.login-error.active {
    display: block;
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        text-align: center;
        gap: 10px;
        padding: 0 12px;
    }
    .header-logo {
        height: 70px;
    }
    .header-info h1 {
        font-size: 20px;
    }
    .header-info p {
        font-size: 12px;
    }
    .nav {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .nav-btn {
        padding: 12px 16px;
        font-size: 13px;
        flex-shrink: 0;
    }
    .container {
        padding: 16px 12px;
    }
    .form-grid {
        grid-template-columns: 1fr;
    }
    .stats {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 10px;
    }
    .stat-card {
        padding: 16px;
    }
    .stat-number {
        font-size: 26px;
    }
    .form {
        padding: 16px;
    }
    .table-container {
        padding: 12px;
    }
    table {
        font-size: 12px;
    }
    thead th, tbody td {
        padding: 6px 8px;
    }
    .form-actions {
        flex-direction: column;
    }
    .form-actions .btn-primary,
    .form-actions .btn-secondary {
        width: 100%;
        text-align: center;
    }
    .action-btns {
        flex-direction: column;
    }
    .action-btns button {
        width: 100%;
    }
    .search-input {
        max-width: 100%;
    }
    .modal {
        width: 95%;
        padding: 16px;
        margin: 10px;
    }
    .modal-actions {
        flex-direction: column;
    }
    .modal-actions .btn-compact {
        width: 100%;
        text-align: center;
    }
    .print-container.active {
        padding: 10px;
    }
    .print-os, .print-entrega {
        width: 100%;
        padding: 8mm 10mm;
    }
    .print-title {
        font-size: 15px;
        padding: 4px 16px;
    }
    .print-header h1 {
        font-size: 18px;
    }
}

@media (max-width: 480px) {
    .header-info h1 {
        font-size: 17px;
    }
    .header-logo {
        height: 55px;
    }
    .nav-btn {
        padding: 10px 12px;
        font-size: 12px;
    }
    .stat-number {
        font-size: 22px;
    }
    h2 {
        font-size: 18px;
    }
    h3 {
        font-size: 15px;
    }
    .quick-actions {
        padding: 14px;
    }
    .btn-sm {
        font-size: 10px;
        padding: 3px 6px;
    }
}
