/* Reset und Basis-Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

#app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

header h1 {
    color: #4a5568;
    font-size: 1.8rem;
    font-weight: 600;
}

nav {
    display: flex;
    gap: 10px;
}

.nav-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
}

.nav-btn:hover {
    background: #5a6fd8;
    transform: translateY(-2px);
}

/* Views */
.view {
    display: none;
}

.view.active {
    display: block !important;
}

#login-view {
    display: block;
}

/* Cards */
.card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.card h2 {
    color: #2d3748;
    margin-bottom: 25px;
    font-size: 1.6rem;
    font-weight: 600;
}

.card h3 {
    color: #4a5568;
    margin: 20px 0 15px 0;
    font-size: 1.3rem;
    font-weight: 500;
}

/* Form Elements */
.form-group {
    margin-bottom: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #4a5568;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
textarea,
select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s ease;
    background: white;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

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

/* Radio Buttons */
input[type="radio"] {
    margin-right: 8px;
}

label:has(input[type="radio"]) {
    display: inline-block;
    margin-right: 20px;
    margin-bottom: 10px;
    cursor: pointer;
}

/* Checkboxes */
input[type="checkbox"] {
    margin-right: 8px;
}

label:has(input[type="checkbox"]) {
    display: flex;
    align-items: center;
    cursor: pointer;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: #e2e8f0;
    color: #4a5568;
}

.btn-secondary:hover {
    background: #cbd5e0;
    transform: translateY(-2px);
}

.btn-danger {
    background: #f56565;
    color: white;
}

.btn-danger:hover {
    background: #e53e3e;
    transform: translateY(-2px);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    color: white;
}

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

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

.modal-content {
    background: white;
    border-radius: 16px;
    padding: 30px;
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    min-width: 400px;
}

.close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    cursor: pointer;
    color: #999;
    transition: color 0.3s ease;
}

.close:hover {
    color: #333;
}

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

/* Global Options */
.global-options {
    background: #f7fafc;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 30px;
    border: 2px solid #e2e8f0;
}

.global-options .btn {
    margin-top: 15px;
    font-size: 16px;
    padding: 12px 24px;
}

/* Accordion */
.accordion {
    background: #f8f9fa;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 10px;
    overflow: hidden;
}

.accordion-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    cursor: pointer;
    font-weight: 500;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
}

.accordion-header:hover {
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
}

.accordion-header::after {
    content: '▼';
    font-size: 12px;
    transition: transform 0.3s ease;
}

.accordion-header.active::after {
    transform: rotate(180deg);
}

.accordion-content {
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: all 0.3s ease;
}

.accordion-content.active {
    padding: 20px;
    max-height: 500px;
    overflow-y: auto;
}

/* Cable Form */
.cable-form {
    display: grid;
    gap: 15px;
}

.cable-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 15px;
    align-items: center;
    padding: 15px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.cable-name {
    font-weight: 500;
    color: #2d3748;
}

.cable-input {
    width: 80px;
}

/* Tables */
.table-container {
    overflow-x: auto;
    margin: 20px 0;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

th {
    background: #f8f9fa;
    font-weight: 600;
    color: #4a5568;
}

tr:hover {
    background: #f8f9fa;
}

/* Set Quantity Input */
.set-quantity-input {
    width: 100px !important;
    padding: 8px 12px;
}

/* Cable Balance */
.cable-balance {
    display: grid;
    gap: 10px;
    margin: 20px 0;
}

.balance-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 15px;
    padding: 10px 15px;
    background: white;
    border-radius: 6px;
    border-left: 4px solid #e2e8f0;
    align-items: center;
}

.balance-row.shortage {
    border-left-color: #f56565;
    background: #fed7d7;
}

.balance-row.excess {
    border-left-color: #48bb78;
    background: #c6f6d5;
}

.balance-row.balanced {
    border-left-color: #4299e1;
    background: #bee3f8;
}

/* Summary Cards */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.summary-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border-left: 4px solid #667eea;
}

.summary-value {
    font-size: 2rem;
    font-weight: bold;
    color: #2d3748;
    margin-bottom: 5px;
}

.summary-label {
    color: #718096;
    font-size: 0.9rem;
}

.summary-card.shortage {
    border-left-color: #f56565;
}

.summary-card.excess {
    border-left-color: #48bb78;
}

/* Categories */
.category-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: white;
    border-radius: 8px;
    margin-bottom: 10px;
    border: 1px solid #e2e8f0;
}

.category-actions {
    display: flex;
    gap: 10px;
}

.btn-small {
    padding: 6px 12px;
    font-size: 14px;
}

/* Set Assignment */
.set-assignment {
    display: grid;
    gap: 10px;
    margin: 20px 0;
}

.set-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 15px;
    align-items: center;
    padding: 15px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

/* Results */
.result-section {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.result-sets {
    display: grid;
    gap: 10px;
}

.result-set {
    background: white;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #48bb78;
}

.result-cables {
    display: grid;
    gap: 5px;
}

.result-cable {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: white;
    border-radius: 6px;
}

/* Responsive Design */
@media (max-width: 768px) {
    #app {
        padding: 10px;
    }
    
    header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .card {
        padding: 20px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .cable-row {
        grid-template-columns: 1fr;
        gap: 10px;
        text-align: center;
    }
    
    .cable-input {
        width: 100%;
        max-width: 120px;
        margin: 0 auto;
    }
    
    .balance-row {
        grid-template-columns: 1fr;
        text-align: center;
    }
    
    .modal-content {
        min-width: 90vw;
        padding: 20px;
    }
    
    .summary-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-actions {
        flex-direction: column;
    }
    
    table {
        font-size: 14px;
    }
    
    th, td {
        padding: 8px 10px;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.4rem;
    }
    
    .card h2 {
        font-size: 1.3rem;
    }
    
    .btn {
        padding: 10px 16px;
        font-size: 14px;
    }
}
