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

:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --success-color: #16a34a;
    --success-dark: #15803d;
    --danger-color: #dc2626;
    --danger-dark: #b91c1c;
    --secondary-color: #64748b;
    --secondary-dark: #475569;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-color: #1e293b;
    --text-light: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
}

.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 1rem;
    box-shadow: var(--shadow-lg);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-info span {
    font-size: 0.9rem;
}

.btn-logout {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    text-decoration: none;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.3);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

.action-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    text-align: center;
}

.btn-large {
    padding: 1rem 1.5rem;
    font-size: 1.1rem;
}

.btn-block {
    width: 100%;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: var(--success-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: var(--secondary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ordens-lista {
    background: var(--card-bg);
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.ordens-lista h3 {
    margin-bottom: 1rem;
    color: var(--text-color);
    font-size: 1.25rem;
}

.ordens-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.ordem-card {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    background: var(--bg-color);
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1rem;
    transition: all 0.2s;
}

.ordem-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow);
}

.ordem-info {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
}

.ordem-field {
    font-size: 0.9rem;
}

.ordem-field.full-width {
    grid-column: 1 / -1;
}

.ordem-field strong {
    color: var(--text-light);
    display: block;
    margin-bottom: 0.25rem;
}

.btn-remove {
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 0.375rem;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.2s;
}

.btn-remove:hover {
    background: var(--danger-dark);
    transform: scale(1.1);
}

.empty-state {
    text-align: center;
    color: var(--text-light);
    padding: 2rem;
    font-size: 1rem;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay p {
    color: white;
    margin-top: 1rem;
    font-size: 1.1rem;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-content {
    background: var(--card-bg);
    border-radius: 0.75rem;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-light);
    line-height: 1;
    padding: 0;
    width: 2rem;
    height: 2rem;
}

.modal-close:hover {
    color: var(--text-color);
}

.modal-body {
    padding: 1.5rem;
}

.modal-body p {
    margin-bottom: 1rem;
    color: var(--text-light);
}

#assinaturaCanvas {
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
    cursor: crosshair;
    width: 100%;
    height: auto;
    touch-action: none;
}

.signature-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 1rem;
}

.notification {
    position: fixed;
    top: 5rem;
    right: 1rem;
    background: var(--card-bg);
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    transform: translateX(400px);
    transition: transform 0.3s;
    max-width: 300px;
}

.notification.show {
    transform: translateX(0);
}

.notification-success {
    border-left: 4px solid var(--success-color);
}

.notification-error {
    border-left: 4px solid var(--danger-color);
}

.notification-info {
    border-left: 4px solid var(--primary-color);
}

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
}

.login-container {
    background: var(--card-bg);
    border-radius: 0.75rem;
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h1 {
    font-size: 1.75rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.login-header p {
    color: var(--text-light);
    font-size: 0.9rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

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

.form-group label {
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.9rem;
}

.form-group input,
.form-group select {
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.login-info {
    text-align: center;
    margin-top: 1rem;
    color: var(--text-light);
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
}

.alert-error {
    background: #fee2e2;
    color: var(--danger-dark);
    border: 1px solid #fecaca;
}

.filtros-panel {
    background: var(--card-bg);
    border-radius: 0.75rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.filtros-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
}

.historico-lista {
    background: var(--card-bg);
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.historico-lista h3 {
    margin-bottom: 1rem;
    color: var(--text-color);
    font-size: 1.25rem;
}

.ordens-historico {
    display: grid;
    gap: 1rem;
}

.ordem-historico-card {
    background: var(--bg-color);
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.ordem-historico-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.ordem-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.ordem-of {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 1.1rem;
}

.ordem-data {
    color: var(--text-light);
    font-size: 0.85rem;
}

.ordem-body {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.ordem-info-row {
    font-size: 0.9rem;
}

.ordem-info-row strong {
    color: var(--text-light);
    margin-right: 0.5rem;
}

.ordem-footer {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background: #dcfce7;
    color: var(--success-dark);
}

.badge-info {
    background: #dbeafe;
    color: var(--primary-dark);
}

.detalhes-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.detalhes-section {
    background: var(--card-bg);
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.detalhes-section h3 {
    margin-bottom: 1rem;
    color: var(--text-color);
    font-size: 1.25rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.detalhes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.detalhe-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.detalhe-item.full-width {
    grid-column: 1 / -1;
}

.detalhe-item label {
    font-weight: 600;
    color: var(--text-light);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detalhe-value {
    font-size: 1rem;
    color: var(--text-color);
    padding: 0.5rem;
    background: var(--bg-color);
    border-radius: 0.375rem;
}

.assinatura-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
}

.assinatura-img {
    max-width: 100%;
    height: auto;
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1rem;
    background: white;
}

.assinatura-info {
    text-align: center;
    color: var(--text-light);
}

.assinatura-info p {
    margin: 0.25rem 0;
}

.imagem-original-container {
    display: flex;
    justify-content: center;
}

.imagem-original {
    max-width: 100%;
    height: auto;
    border-radius: 0.5rem;
    box-shadow: var(--shadow);
}

.texto-extraido {
    background: var(--bg-color);
    border-radius: 0.5rem;
    padding: 1rem;
    overflow-x: auto;
}

.texto-extraido pre {
    margin: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    color: var(--text-color);
}

@media (max-width: 768px) {
    .header h1 {
        font-size: 1.25rem;
    }
    
    .user-info span {
        display: none;
    }
    
    .action-buttons {
        grid-template-columns: 1fr;
    }
    
    .ordem-info {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .detalhes-grid {
        grid-template-columns: 1fr;
    }
    
    .signature-actions {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        margin: 1rem;
    }
    
    #assinaturaCanvas {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0.75rem;
    }
    
    .header-content {
        padding: 0 0.5rem;
    }
    
    .btn {
        padding: 0.65rem 1rem;
        font-size: 0.95rem;
    }
    
    .btn-large {
        padding: 0.85rem 1rem;
        font-size: 1rem;
    }
}
