:root {
    --primary-color: #2563eb;
    --primary-dark: #1e40af;
    --background: #f3f4f6;
    --card-bg: #ffffff;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--background);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

.app-container {
    width: 100%;
    max-width: 480px; /* Mobile app feel */
    background-color: var(--background);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-header {
    background-color: var(--primary-color);
    color: white;
    padding: 2rem 1.5rem 3rem;
    border-radius: 0 0 24px 24px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    margin-bottom: -1.5rem;
    z-index: 10;
}

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

.app-header p {
    font-size: 0.875rem;
    opacity: 0.9;
    margin-top: 0.25rem;
}

/* Tabs Styles */
.tabs-nav {
    display: flex;
    background: rgba(255,255,255,0.9);
    padding: 0.5rem;
    border-radius: 12px;
    margin: 0 1rem 1rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    z-index: 20;
}

.tab-btn {
    flex: 1;
    border: none;
    background: none;
    padding: 0.6rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-muted);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn.active {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

.tab-content {
    display: none;
    flex-direction: column;
    gap: 1rem;
    animation: fadeIn 0.3s ease;
}

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

.app-content {
    padding: 0 1rem 2rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 1.25rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

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

.card-header h2, .card-header-action h2 {
    font-size: 1.1rem;
    color: var(--text-main);
}

.toggle-icon {
    color: var(--text-muted);
    transition: transform 0.3s ease;
}

.card-body {
    margin-top: 1rem;
    transition: all 0.3s ease;
}

.hidden-config .card-body {
    display: none;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.row {
    display: flex;
    gap: 1rem;
}

.row .input-group {
    flex: 1;
}

label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
}

input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 1rem;
    background-color: #f9fafb;
    transition: border-color 0.2s;
}

input:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: #fff;
}

/* Toggles Styles */
.toggles-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.toggle-row input {
    display: none;
}

.slider {
    width: 44px;
    height: 24px;
    background-color: #e5e7eb;
    border-radius: 24px;
    position: relative;
    transition: 0.3s;
}

.slider::before {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    border-radius: 50%;
    transition: 0.3s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

input:checked + .slider {
    background-color: var(--primary-color);
}

input:checked + .slider::before {
    transform: translateX(20px);
}

/* Day Rows Styles */
.days-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.day-card {
    background-color: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.75rem;
    position: relative;
    animation: fadeIn 0.3s ease;
}

.day-card.rest-day {
    background-color: #f0fdf4; /* Green tint */
    border-color: #bbf7d0;
}

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

.day-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary-color);
    white-space: nowrap;
}

.day-date-input {
    flex: 1;
    padding: 0.3rem 0.5rem;
    font-size: 0.85rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: white;
}

.btn-remove {
    background: none;
    border: none;
    color: var(--danger);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 0.25rem;
}

.day-inputs {
    display: flex;
    gap: 0.5rem;
}

.day-inputs .input-group {
    margin-bottom: 0;
    flex: 1;
}

.day-inputs input {
    padding: 0.5rem;
    font-size: 0.95rem;
}

/* Info Pill */
.info-pill {
    background-color: #e0f2fe;
    color: #0369a1;
    padding: 0.75rem;
    border-radius: 12px;
    text-align: center;
    margin: 1rem 0;
    font-size: 0.85rem;
    font-weight: 500;
}

/* Buttons */
.btn-primary {
    width: 100%;
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(37, 99, 235, 0.2);
    transition: transform 0.1s;
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    border: none;
    background-color: var(--primary-color);
    color: white;
    font-size: 0.85rem;
    cursor: pointer;
    font-weight: 500;
}

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

.btn-text {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    text-decoration: underline;
}

/* Results */
.results-section {
    margin-top: 1.5rem;
    animation: slideUp 0.4s ease;
}

.hidden {
    display: none;
}

.results-section h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--text-main);
}

.result-card {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    padding: 1.5rem;
    border-radius: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.3);
}

.result-card strong {
    font-size: 1.5rem;
}

.details-list {
    background: white;
    border-radius: 16px;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.detail-item {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

.detail-item:last-child {
    border-bottom: none;
}

/* History List */
.history-card {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s;
    background: white; /* Ensure background is white */
}

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

.history-card:hover {
    background-color: #f9fafb;
}

.history-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.25rem;
    font-weight: 600;
    font-size: 0.95rem;
}

.history-date {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.btn-delete {
    color: var(--danger);
    font-size: 0.8rem;
    padding: 0.2rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: white;
    margin-left: 0.5rem;
}

/* Invoice Overlay */
.invoice-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    overflow: hidden; /* Prevent scrolling of overlay background */
}

.invoice-overlay.hidden {
    display: none;
}

.invoice-paper {
    background: white;
    width: 100%;
    max-width: 800px;
    height: 90vh; /* Fixed height relative to viewport */
    display: flex;
    flex-direction: column; /* Stack header and body */
    padding: 0; /* Remove default padding to manage inside */
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    font-family: 'Courier New', Courier, monospace;
    position: relative;
    border-radius: 8px; /* Slightly rounded corners for desktop */
}

.invoice-fixed-header {
    flex-shrink: 0; /* Don't shrink */
    padding: 2rem 2rem 1rem 2rem;
    background: white;
    z-index: 10;
    border-bottom: 1px solid #eee; /* Subtle separation */
}

.invoice-scrollable-body {
    flex: 1; /* Take remaining space */
    overflow-y: auto; /* Enable vertical scrolling */
    padding: 1rem 2rem 2rem 2rem;
}

/* Mobile Adjustments */
@media (max-width: 600px) {
    .invoice-overlay {
        padding: 0;
        align-items: flex-start;
    }
    
    .invoice-paper {
        height: 100%; /* Full height on mobile */
        width: 100%;
        border-radius: 0;
        box-shadow: none;
    }

    .invoice-fixed-header {
        padding: 1rem;
    }

    .invoice-scrollable-body {
        padding: 1rem;
    }

    .invoice-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 1rem;
    }

    .invoice-title {
        text-align: center;
    }
    
    .invoice-actions {
        justify-content: center;
    }

    .signatures {
        flex-direction: column;
        align-items: center;
        gap: 3rem;
    }
}

.invoice-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-bottom: 2rem;
}

.invoice-header {
    display: flex;
    justify-content: space-between;
    border-bottom: 2px solid #000;
    padding-bottom: 1rem;
    margin-bottom: 2rem;
}

.invoice-logo {
    max-height: 60px;
    object-fit: contain;
}

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

.company-info h1 {
    font-size: 1.25rem; /* Smaller font size as requested */
    margin: 0;
    line-height: 1.2;
    font-weight: 700;
}

.company-info p {
    margin: 0;
    font-size: 0.9rem;
    color: #333;
}

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

.invoice-title h2 {
    font-size: 1.2rem;
    margin-bottom: 0.25rem;
}

.invoice-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 2rem;
}

.invoice-table th, .invoice-table td {
    border: 1px solid #000;
    padding: 0.5rem;
    font-size: 0.9rem;
}

.invoice-table th {
    background-color: #f3f4f6;
    font-weight: bold;
}

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

.total-row {
    font-weight: bold;
    font-size: 1.1rem;
    background-color: #f3f4f6;
}

.legal-footer {
    margin-top: 3rem;
    font-size: 0.8rem;
    text-align: center;
}

.signatures {
    display: flex;
    justify-content: space-around;
    margin-top: 4rem;
    margin-bottom: 2rem;
}

.signature-box {
    text-align: center;
    width: 200px;
}

.signature-box .line {
    border-top: 1px solid #000;
    margin-bottom: 0.5rem;
}

.small-legal {
    font-size: 0.7rem;
    color: #666;
    margin-top: 2rem;
}

/* Footer */
.app-footer {
    text-align: center;
    padding: 2rem 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: auto;
}

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

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

/* Print Styles */
@media print {
    .no-print { display: none !important; }
    
    .invoice-overlay { 
        position: static; 
        background: white; 
        padding: 0;
        display: block;
        height: auto;
        overflow: visible;
    }

    .invoice-paper {
        box-shadow: none;
        max-width: 100%;
        width: 100%;
        height: auto;
        padding: 0;
        display: block; /* Disable flex layout for print */
        overflow: visible;
        border-radius: 0;
    }

    .invoice-fixed-header {
        position: static;
        padding: 0;
        border-bottom: none;
    }

    .invoice-scrollable-body {
        overflow: visible;
        height: auto;
        padding: 0;
        display: block;
    }

    .app-container { display: none; }
}