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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #3152e6 0%, #434ff1 100%);
    min-height: 100vh;
}

.container {
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.header {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

.header h1 {
    font-size: 2.5em;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.back-button {
    position: flex;
    top: 20px;
    left: 20px;
    padding: 5px 10px;
    background: linear-gradient(135deg, #9ea4a8, #495057);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.4em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    margin-bottom: 2px;
}

.back-button:hover {
    background: linear-gradient(135deg, #5a6268, #343a40);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.back-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.info-panel {
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
}

.info-panel.is-locked {
    opacity: 0.6;
    pointer-events: none;
    filter: grayscale(0.2);
}

.info-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.label {
    font-size: 0.9em;
    opacity: 0.8;
    margin-bottom: 5px;
}

.production-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    padding: 20px;
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
}

.card {
    background: white;
    padding: 15px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
}

.card h3 {
    color: #495057;
    font-size: 0.9em;
    margin-bottom: 10px;
}

.target-value { color: #007bff; font-size: 2.5em; font-weight: bold; }
.produced-value { 
    color: #28a745; 
    font-size: 2em; 
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1px;
}
.produced-value small {
    font-size: 0.4em;
    opacity: 0.9;
    font-weight: normal;
    position: relative;
    top: 4px;
}
.defect-value { 
    color: #dc3545; 
    font-size: 2.5em; 
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1px;
}
.defect-value small {
    font-size: 0.4em;
    opacity: 0.9;
    font-weight: normal;
    position: relative;
    top: 4px;
}
.balance-value { color: #6c757d; font-size: 2.5em; font-weight: bold; }

.grid-container {
    padding: 30px;
    background: white;
}

.macho-nome {
    font-size: 0.8em;
    display: block;
    margin-bottom: 5px;
    padding: 3px 0;
    white-space: pre-line;
    line-height: 1.4;
    border-bottom: 1px solid #eee;
}
.grid-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 20px;
}

.grid-header h2 {
    color: #2c3e50;
    font-size: 1.4em;
}

.legend {
    display: flex;
    gap: 20px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.square {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 2px solid #dee2e6;
}

.square.good { background: #28a745; }
.square.defect { background: #dc3545; }
.square.empty { background: #e9ecef; }

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: 10px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 15px;
    max-height: 400px;
    overflow-y: auto;
}

.grid-square {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid #dee2e6;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.grid-square:hover {
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.grid-square.good {
    background: linear-gradient(135deg, #28a745, #20c997);
}

.grid-square.defect {
    background: linear-gradient(135deg, #dc3545, #e74c3c);
}

.grid-square.empty {
    background: #e9ecef;
}

.grid-square.empty:hover {
    background: #dee2e6;
}

.grid-square .number {
    font-size: 0.8em;
    opacity: 0.8;
}

.controls {
    padding: 30px;
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.btn {
    padding: 24px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, #dc3545, #e74c3c);
    color: white;
}

.btn-secondary {
    background: linear-gradient(135deg, #6c757d, #495057);
    color: white;
}

.btn-success {
    background: linear-gradient(135deg, #1d20c5, #546fe4);
    color: white;
}

.btn-warning {
    background: linear-gradient(135deg, #ffc107, #fd7e14);
    color: white;
}

.btn-info {
    background: linear-gradient(135deg, #17a2b8, #20c997);
    color: white;
}

/* Status messages */
.status-message {
    padding: 10px 15px;
    border-radius: 5px;
    margin: 10px 0;
    font-weight: bold;
    text-align: center;
}

.status-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.status-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.status-message.warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.status-message.info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Refugo summary */
.refugo-summary {
    padding: 15px;
    margin: 10px 0;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.refugo-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 10px;
}

.refugo-card {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 15px;
    min-width: 200px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.refugo-card h5 {
    margin: 0 0 10px 0;
    color: #2c3e50;
    font-size: 1.1em;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

.refugo-card ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.refugo-card li {
    padding: 2px 0;
    border-bottom: 1px solid #f8f9fa;
    font-size: 0.8em;
}

.refugo-card li:last-child {
    border-bottom: none;
}

/* Modal styles */
.refugo-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.refugo-modal-content {
    background: white;
    padding: 15px;
    border-radius: 10px;
    max-width: 600px;
    width: 90%;
    max-height: 100vh;
    overflow-y: auto;
}

.refugo-options {
    margin: 15px 0;
}

.refugo-options label {
    display: block;
    margin: 10px 0;
    font-weight: normal;
}

.refugo-type-section {
    margin: 15px 0;
}

.refugo-type-section select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    margin-top: 5px;
}

.refugo-macho-list {
    max-height: 200px;
    overflow-y: auto;
    margin: 15px 0;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 10px;
}

.macho-refugo-item {
    margin: 10px 0;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background: #f9f9f9;
}

.macho-refugo-item input[type="checkbox"] {
    margin-right: 10px;
}

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

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.btn:active {
    transform: translateY(0);
}

/* estado de confirmação */
.grid-square.confirm-delete {
    position: relative;
    cursor: pointer;
    animation: pulse 0.3s;
}

.grid-square.confirm-delete::after {
    content: '🗑️';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    pointer-events: none; /* permite que o segundo clique ainda seja no quadrado */
}

@keyframes pulse {
    from { transform: scale(1); }
    50% { transform: scale(1.1); }
    to { transform: scale(1); }
}

@media (max-width: 868px) {
    .header h1 {
        font-size: 2em;
    }
    
    .grid {
        grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    }
    
    .grid-square {
        width: 40px;
        height: 40px;
    }
    
    .controls {
        flex-direction: column;
    }

    body {
        min-height: 100vh;
        padding: 0px;
    }

    .container {
        border-radius: 0px;
    }
}