/* ========== RESET & VARIABLES ========== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #a5b4fc;
    --secondary: #8b5cf6;
    --accent: #06b6d4;
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --dark: #1e1b4b;
    --text: #334155;
    --text-light: #94a3b8;
    --bg: #f1f5f9;
    --white: #ffffff;
    --border: #e2e8f0;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.1);

    --bronze: #cd7f32;
    --bronze-light: #f5e6d0;
    --silber: #9ca3af;
    --silber-light: #e8eaed;
    --gold: #eab308;
    --gold-light: #fef9c3;
    --diamant: #06b6d4;
    --diamant-light: #cffafe;

    --header-height: 110px;
    --tab-height: 60px;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    padding-top: calc(var(--header-height) + var(--tab-height));
    overflow-x: hidden;
}

/* ========== CONFETTI CANVAS ========== */
#confettiCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}

/* ========== MODAL ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.modal-overlay[hidden] {
    display: none;
}

.modal {
    background: var(--white);
    border-radius: var(--radius);
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    text-align: center;
    animation: scaleIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: var(--shadow-lg);
}

.modal-edit {
    max-width: 480px;
    text-align: left;
}

.modal-icon {
    font-size: 4rem;
    margin-bottom: 0.5rem;
    animation: bounce 0.6s ease 0.3s;
}

.modal h2 {
    font-size: 1.5rem;
    color: var(--dark);
    margin-bottom: 0.5rem;
}

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

.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

/* ========== HEADER ========== */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: var(--white);
    padding: 1rem 1.25rem 0.75rem;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.3);
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.logo {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.month-picker {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 0.95rem;
}

.month-nav {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: var(--white);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.month-nav:hover {
    background: rgba(255, 255, 255, 0.35);
}

.header-total {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.header-total-label {
    font-size: 0.8rem;
    opacity: 0.85;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.header-total-value {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

/* ========== TAB NAVIGATION ========== */
.tab-nav {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    z-index: 99;
    display: flex;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    padding: 0.5rem 0.25rem;
    border: none;
    background: none;
    color: var(--text-light);
    cursor: pointer;
    font-size: 0.7rem;
    font-weight: 500;
    font-family: inherit;
    transition: color 0.2s;
    position: relative;
}

.tab-icon {
    font-size: 1.2rem;
}

.tab::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 20%;
    right: 20%;
    height: 3px;
    border-radius: 3px 3px 0 0;
    background: var(--primary);
    transform: scaleX(0);
    transition: transform 0.2s ease;
}

.tab.active {
    color: var(--primary);
    font-weight: 600;
}

.tab.active::after {
    transform: scaleX(1);
}

/* ========== MAIN ========== */
.main {
    max-width: 700px;
    margin: 0 auto;
    padding: 1rem;
}

/* ========== TAB CONTENT ========== */
.tab-content {
    display: none;
    animation: fadeSlideUp 0.35s ease;
}

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

/* ========== CARDS ========== */
.card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.card-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.card-header .card-title {
    margin-bottom: 0;
}

/* ========== TIER CARD (Dashboard) ========== */
.tier-card {
    text-align: center;
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
}

.tier-card::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0.06;
    background: radial-gradient(circle at 50% 0%, currentColor 0%, transparent 70%);
}

.tier-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.tier-icon {
    font-size: 3rem;
    line-height: 1;
}

.tier-name {
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.tier-motivation {
    margin-top: 0.5rem;
    color: var(--text-light);
    font-size: 0.9rem;
}

/* Tier Colors */
.tier-card.tier-bronze { color: var(--bronze); background: linear-gradient(135deg, var(--white), var(--bronze-light)); }
.tier-card.tier-silber { color: var(--silber); background: linear-gradient(135deg, var(--white), var(--silber-light)); }
.tier-card.tier-gold { color: var(--gold); background: linear-gradient(135deg, var(--white), var(--gold-light)); }
.tier-card.tier-diamant { color: var(--diamant); background: linear-gradient(135deg, var(--white), var(--diamant-light)); }

.tier-card.tier-diamant .tier-icon {
    animation: shimmer 2s ease-in-out infinite;
}

/* ========== PROGRESS BAR ========== */
.progress-container {
    position: relative;
    margin-bottom: 0.75rem;
}

.progress-bar {
    height: 28px;
    background: var(--bg);
    border-radius: 14px;
    overflow: visible;
    position: relative;
}

.progress-fill {
    height: 100%;
    border-radius: 14px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    min-width: 0;
}

.progress-pulse {
    position: absolute;
    top: 50%;
    transform: translate(50%, -50%);
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--white);
    box-shadow: 0 0 0 3px var(--primary), 0 0 12px rgba(99, 102, 241, 0.4);
    transition: right 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2;
}

.progress-markers {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
    padding: 0 2px;
}

.progress-marker {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.65rem;
    color: var(--text-light);
    position: relative;
}

.progress-marker::before {
    content: '';
    width: 2px;
    height: 8px;
    background: var(--border);
    margin-bottom: 2px;
    border-radius: 1px;
}

.progress-marker.reached {
    color: var(--primary);
    font-weight: 600;
}

.progress-marker.reached::before {
    background: var(--primary);
}

.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-light);
}

/* ========== REWARDS ========== */
.rewards-grid {
    display: grid;
    gap: 0.75rem;
}

.reward-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: var(--bg);
    border-radius: var(--radius-sm);
}

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

.reward-value {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text);
}

.reward-total {
    background: linear-gradient(135deg, #eef2ff, #e0e7ff);
    border: 1px solid var(--primary-light);
}

.reward-total .reward-value {
    color: var(--primary);
    font-size: 1.25rem;
}

/* ========== TIER OVERVIEW ========== */
.tier-info-base {
    padding: 0.65rem 0.85rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    color: #b91c1c;
    margin-bottom: 0.75rem;
    text-align: center;
    font-weight: 500;
}

.tier-info-base.reached {
    background: var(--success-light);
    border-color: #86efac;
    color: #166534;
}

.tier-overview {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.tier-overview-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    background: var(--bg);
    border: 2px solid transparent;
    transition: border-color 0.3s, background 0.3s;
    position: relative;
}

.tier-overview-item.current {
    border-color: var(--primary);
    background: #eef2ff;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.tier-overview-item.reached {
    opacity: 1;
}

.tier-overview-item.locked {
    opacity: 0.55;
}

.tier-overview-icon {
    font-size: 1.8rem;
    line-height: 1;
    flex-shrink: 0;
}

.tier-overview-info {
    flex: 1;
    min-width: 0;
}

.tier-overview-name {
    font-weight: 700;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.tier-overview-threshold {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 0.1rem;
}

.tier-overview-rewards {
    text-align: right;
    flex-shrink: 0;
}

.tier-overview-bonus {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--success);
}

.tier-overview-profit {
    font-size: 0.75rem;
    color: var(--text-light);
}

.tier-badge-current {
    font-size: 0.6rem;
    background: var(--primary);
    color: white;
    padding: 0.1rem 0.4rem;
    border-radius: 8px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.tier-checkmark {
    color: var(--success);
    font-weight: 700;
}

/* ========== FORM ========== */
.form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

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

.form-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.optional {
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.75rem;
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="time"] {
    padding: 0.7rem 0.85rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    color: var(--text);
    background: var(--white);
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
}

input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.input-euro {
    position: relative;
}

.input-euro input {
    padding-right: 2.5rem;
}

.euro-symbol {
    position: absolute;
    right: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    font-weight: 600;
    pointer-events: none;
}

/* ========== BUTTONS ========== */
.btn {
    padding: 0.7rem 1.25rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s, background 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: var(--white);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.btn-full {
    width: 100%;
    padding: 0.85rem;
    font-size: 1rem;
}

.btn-small {
    padding: 0.45rem 0.85rem;
    font-size: 0.8rem;
    background: var(--bg);
    color: var(--text);
}

.btn-small:hover {
    background: var(--border);
}

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

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

.btn-success {
    display: none;
}

.btn.show-success .btn-text {
    display: none;
}

.btn.show-success .btn-success {
    display: inline;
    color: var(--success);
}

.btn.show-success {
    background: var(--success-light);
    box-shadow: none;
}

/* ========== ENTRIES LIST ========== */
.entries-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.entry-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: var(--bg);
    border-radius: var(--radius-sm);
    animation: fadeSlideUp 0.3s ease;
}

.entry-info {
    flex: 1;
}

.entry-date {
    font-size: 0.75rem;
    color: var(--text-light);
}

.entry-desc {
    font-size: 0.85rem;
    color: var(--text);
    margin-top: 0.1rem;
}

.entry-amount {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--success);
    margin: 0 0.75rem;
    white-space: nowrap;
}

.entry-actions {
    display: flex;
    gap: 0.25rem;
}

.entry-action {
    background: none;
    border: none;
    padding: 0.3rem;
    cursor: pointer;
    font-size: 1rem;
    opacity: 0.5;
    transition: opacity 0.2s;
    border-radius: 6px;
}

.entry-action:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.05);
}

.entry-count {
    font-size: 0.8rem;
    color: var(--text-light);
    background: var(--bg);
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
}

.entries-total {
    display: flex;
    justify-content: space-between;
    padding: 0.85rem;
    margin-top: 0.5rem;
    background: linear-gradient(135deg, #eef2ff, #e0e7ff);
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--primary);
}

/* ========== TIMESHEET TABLE ========== */
.timesheet-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.timesheet-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    min-width: 500px;
}

.timesheet-table th {
    text-align: left;
    padding: 0.6rem 0.5rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-light);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.timesheet-table td {
    padding: 0.6rem 0.5rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.timesheet-table tbody tr:hover {
    background: var(--bg);
}

.timesheet-table tfoot td {
    border-bottom: none;
    border-top: 2px solid var(--border);
    padding-top: 0.75rem;
}

/* ========== EMPTY STATE ========== */
.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-light);
}

.empty-state[hidden] {
    display: none;
}

.empty-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.empty-hint {
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

/* ========== STATS ========== */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.stat-item {
    padding: 0.85rem;
    background: var(--bg);
    border-radius: var(--radius-sm);
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.25rem;
}

.stat-value {
    display: block;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
}

/* ========== DATA ACTIONS ========== */
.data-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* ========== CANVAS CHARTS ========== */
canvas {
    width: 100% !important;
    max-width: 100%;
}

/* ========== ANIMATIONS ========== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    40% { transform: translateY(-15px); }
    60% { transform: translateY(-5px); }
}

@keyframes shimmer {
    0%, 100% { transform: scale(1); filter: brightness(1); }
    50% { transform: scale(1.1); filter: brightness(1.2); }
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 3px var(--primary), 0 0 12px rgba(99, 102, 241, 0.4); }
    50% { box-shadow: 0 0 0 5px var(--primary-light), 0 0 20px rgba(99, 102, 241, 0.6); }
}

.progress-pulse {
    animation: pulse 2s ease-in-out infinite;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 480px) {
    :root {
        --header-height: 100px;
    }

    .header {
        padding: 0.75rem 1rem 0.5rem;
    }

    .logo {
        font-size: 1.1rem;
    }

    .header-total-value {
        font-size: 1.4rem;
    }

    .tab-label {
        font-size: 0.6rem;
    }

    .tab-icon {
        font-size: 1.1rem;
    }

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

    .form-row .form-group:last-child {
        grid-column: 1 / -1;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .tier-icon {
        font-size: 2.5rem;
    }

    .tier-name {
        font-size: 1.2rem;
    }
}

@media (min-width: 768px) {
    .main {
        padding: 1.5rem;
    }

    .tab-label {
        font-size: 0.8rem;
    }

    .tab {
        flex-direction: row;
        gap: 0.4rem;
        font-size: 0.85rem;
    }

    .rewards-grid {
        grid-template-columns: 1fr 1fr;
    }

    .rewards-grid .reward-total {
        grid-column: 1 / -1;
    }
}

/* ========== PRINT STYLES ========== */
@media print {
    body {
        padding-top: 0;
        background: white;
        color: black;
        font-size: 11pt;
    }

    .header,
    .tab-nav,
    #confettiCanvas,
    .no-print,
    .btn,
    .data-actions {
        display: none !important;
    }

    .main {
        max-width: 100%;
        padding: 0;
    }

    .tab-content {
        display: none !important;
    }

    #tab-timeTracking {
        display: block !important;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
        break-inside: avoid;
    }

    .timesheet-table {
        min-width: auto;
        font-size: 10pt;
    }

    .timesheet-table th {
        background: #f0f0f0;
        color: black;
    }

    .empty-state {
        display: none;
    }

    #timesheetCard::before {
        content: 'Stundenzettel — ' attr(data-month);
        display: block;
        font-size: 16pt;
        font-weight: bold;
        margin-bottom: 12pt;
        text-align: center;
    }

    .no-print {
        display: none !important;
    }
}

/* ========== REDUCED MOTION ========== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .progress-pulse {
        animation: none;
    }
}
