/* Reset & Basis */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #64748b;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #f59e0b;
    --bg: #f8fafc;
    --bg-white: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-light: #64748b;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 6px rgba(0,0,0,0.1);
    --radius: 6px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

/* Login Page */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-box {
    background: var(--bg-white);
    padding: 40px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
}

.login-box h1 {
    text-align: center;
    margin-bottom: 30px;
    color: var(--primary);
}

/* App Layout */
.app-container {
    display: none;
}

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

.app-header {
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header h1 {
    font-size: 20px;
    color: var(--primary);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-info span {
    color: var(--text-light);
}

/* Tabs */
.tabs {
    display: flex;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    padding: 0 20px;
}

.tab-btn {
    padding: 15px 25px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-light);
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: var(--primary);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Content */
.content {
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Cards */
.card {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.card-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

/* Forms */
.form-group {
    margin-bottom: 15px;
}

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

label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--text);
}

input, select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    transition: border-color 0.2s;
}

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

input[type="checkbox"] {
    width: auto;
    margin-right: 8px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    gap: 8px;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

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

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

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

.btn-success:hover {
    background: #15803d;
}

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

.btn-danger:hover {
    background: #b91c1c;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-outline:hover {
    background: var(--bg);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-group {
    display: flex;
    gap: 10px;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: var(--bg);
    font-weight: 600;
    white-space: nowrap;
}

tr:hover {
    background: #f1f5f9;
}

.text-right {
    text-align: right;
}

.text-center {
    text-align: center;
}

/* Search */
.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.search-bar input {
    flex: 1;
    max-width: 300px;
}

/* Alerts */
.alert {
    padding: 12px 15px;
    border-radius: var(--radius);
    margin-bottom: 15px;
}

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

.alert-success {
    background: #f0fdf4;
    color: var(--success);
    border: 1px solid #bbf7d0;
}

/* Modal */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

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

.modal {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-header h3 {
    font-size: 18px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-light);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Payroll Editor */
.payroll-section {
    margin-bottom: 25px;
}

.payroll-section h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary);
}

.calculation-result {
    background: var(--bg);
    padding: 15px;
    border-radius: var(--radius);
    margin-top: 20px;
}

.calc-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.calc-row:last-child {
    border-bottom: none;
}

.calc-row.total {
    font-weight: 600;
    font-size: 16px;
    margin-top: 10px;
    padding-top: 15px;
    border-top: 2px solid var(--primary);
}

.calc-label {
    color: var(--text-light);
}

.calc-value {
    font-weight: 500;
}

/* Items List */
.items-header {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr 1fr 1fr auto;
    gap: 10px;
    padding: 8px 0;
    background: var(--bg);
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    font-size: 12px;
    color: var(--text-light);
}

.items-header.pers-header {
    grid-template-columns: 2fr 1fr 4fr auto;
}

.items-legend {
    margin-top: 8px;
    color: var(--text-light);
}

.items-list {
    margin-top: 0;
}

.item-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr 1fr 1fr auto;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    align-items: center;
}

.item-row input, .item-row select {
    padding: 8px;
}

.remove-item {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 18px;
}

/* Month Picker */
.month-select {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 20px;
}

/* History */
.history-list {
    list-style: none;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid var(--border);
}

.history-item:hover {
    background: var(--bg);
}

.history-info {
    display: flex;
    flex-direction: column;
}

.history-monat {
    font-weight: 600;
}

.history-betrag {
    color: var(--text-light);
    font-size: 13px;
}

/* Badge */
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 500;
}

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

.badge-warning {
    background: #fef3c7;
    color: var(--warning);
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-light);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-light);
}

/* Responsive */
@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
    }

    .item-row {
        grid-template-columns: 1fr 1fr;
    }

    .tabs {
        overflow-x: auto;
    }

    .search-bar {
        flex-direction: column;
    }

    .search-bar input {
        max-width: none;
    }
}
