:root {
    --primary-color: #1e293b; --accent-color: #3b82f6; --success-color: #10b981;
    --danger-color: #ef4444; --bg-color: #f8fafc; --border-color: #e2e8f0;
}

* { box-sizing: border-box; font-family: sans-serif; }
body { background: var(--bg-color); margin: 0; padding: 20px 20px 160px 20px; color: #334155; }
body.modal-open { overflow: hidden; }

.app-container { max-width: 1000px; margin: 0 auto; }

/* Kort og Layout */
.card { background: white; padding: 25px; border-radius: 10px; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1); margin-bottom: 25px; }
.card-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color); margin: -25px -25px 20px -25px; padding: 15px 25px; background: #f1f5f9; border-radius: 10px 10px 0 0; }
h1, h2, h3 { color: var(--primary-color); margin-top: 0; }

/* Skjemaelementer */
.grid-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin-bottom: 15px; }
.form-group { display: flex; flex-direction: column; }
label { font-size: 0.8rem; font-weight: bold; text-transform: uppercase; color: #64748b; margin-bottom: 5px; }
input, select { padding: 10px; border: 1px solid var(--border-color); border-radius: 6px; font-size: 1rem; }

/* Tabeller */
table { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
th { text-align: left; font-size: 0.8rem; color: #64748b; padding: 10px; border-bottom: 2px solid var(--border-color); }
td { padding: 5px; border-bottom: 1px solid var(--border-color); }
td input { width: 100%; border: none; background: #f8fafc; }

/* Knapper */
.btn { padding: 10px 18px; border-radius: 6px; cursor: pointer; font-weight: bold; border: none; transition: 0.2s; display: inline-flex; align-items: center; gap: 5px; }
.btn-primary { background: var(--accent-color); color: white; }
.btn-outline { border: 1px solid var(--accent-color); color: var(--accent-color); background: transparent; }
.btn-success { background: var(--success-color); color: white; }
.btn-text { background: transparent; padding: 5px; }

/* Sticky-meny i bunnen */
.sticky-summary { position: fixed; bottom: 0; left: 0; width: 100%; background: var(--primary-color); color: white; padding: 20px; box-shadow: 0 -4px 10px rgba(0,0,0,0.2); z-index: 100; }
.totals-grid { max-width: 1000px; margin: 0 auto; display: flex; justify-content: space-around; flex-wrap: wrap; }
.total-item { text-align: center; }
.total-label { display: block; font-size: 0.7rem; opacity: 0.8; }
.total-value { font-size: 1.4rem; font-weight: bold; }
#grand-total { color: #fbbf24; }

/* Modal / Forhåndsvisning */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); display: flex; justify-content: center; align-items: center; z-index: 1000; padding: 20px; }
.modal-content { background: white; width: 100%; max-width: 900px; max-height: 95vh; border-radius: 8px; display: flex; flex-direction: column; box-shadow: 0 20px 25px -5px rgba(0,0,0,0.2); }
.modal-header { padding: 15px 25px; border-bottom: 1px solid #ddd; display: flex; justify-content: space-between; align-items: center; background: #f8fafc; }
.modal-body { padding: 40px; overflow-y: auto; flex: 1; }

/* Dokument-styling inne i modal */
.expense-report-document { color: black; font-family: serif; }
.document-header { display: flex; justify-content: space-between; border-bottom: 2px solid black; margin-bottom: 20px; }
.expense-table th { background: #f1f5f9; color: black; border: 1px solid #000; }
.expense-table td { border: 1px solid #000; padding: 8px; }
.summary-row { margin-top: 20px; font-size: 1.2rem; border-top: 2px solid black; padding-top: 10px; display: flex; justify-content: space-between; }
.sig-box { height: 80px; border-bottom: 1px solid black; margin: 10px 0; width: 250px; }

/* --- INTEGRERT KREDITT I STICKY SUMMARY --- */
.sticky-credit {
    max-width: 1000px;
    margin: 15px auto -10px auto; 
    font-size: 0.75rem;
    color: #64748b;              
    text-align: left;            
    padding-left: 10px;
}

/* Legger til touch-action for bedre mobil-signering */
#sig-canvas { touch-action: none; }

/* --- UTSKRIFT / PDF-LOGIKK (A4) --- */
@media print {
    /* 1. Sett A4 format og standard marger for selve arket */
    @page { 
        size: A4; 
        margin: 15mm 20mm; 
    }

    /* 2. Tving nettleseren til å tegne bakgrunnsfarger (for tabellheadere) */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* 3. Skjul hele appen og grensesnittet, vis KUN modalen */
    body { 
        background: white !important; 
        margin: 0 !important; 
        padding: 0 !important; 
        color: black !important;
    }
    
    .app-container, 
    .no-print, 
    .sticky-summary, 
    .modal-header, 
    .btn { 
        display: none !important; 
    }

    /* 4. Flatt ut modalen slik at den blir selve arket */
    body.modal-open .modal-overlay { 
        position: absolute !important; 
        top: 0 !important; 
        left: 0 !important; 
        width: 100% !important; 
        background: white !important; 
        padding: 0 !important;
        display: block !important;
    }

    body.modal-open .modal-content { 
        box-shadow: none !important; 
        border: none !important; 
        width: 100% !important; 
        max-width: none !important;
        border-radius: 0 !important;
        margin: 0 !important;
    }

    body.modal-open .modal-body { 
        padding: 0 !important; 
        overflow: visible !important; 
    }

    /* 5. Typografi og styling for selve dokumentet */
    .expense-report-document {
        font-family: 'Times New Roman', Times, serif !important; /* Tradisjonell dokumentfont */
        font-size: 11pt !important;
        line-height: 1.4 !important;
        width: 100% !important;
    }

    .expense-report-document h1 { font-size: 22pt !important; margin-bottom: 5px !important; }
    .expense-report-document h3 { font-size: 13pt !important; margin-bottom: 5px !important; margin-top: 15px !important; }
    .expense-report-document p { margin: 3px 0 !important; }

    /* 6. Sikre at tabellen ser pen ut på papir */
    .expense-table { 
        width: 100% !important; 
        border-collapse: collapse !important;
        margin: 15px 0 !important;
    }
    
    .expense-table th {
        background-color: #f1f5f9 !important;
        color: black !important;
        font-weight: bold !important;
        padding: 6px !important;
    }

    .expense-table td {
        padding: 6px !important;
    }

    /* 7. Sørg for at elementer ikke brekker stygt over to sider */
    .expense-table { page-break-inside: auto; }
    .expense-table tr { page-break-inside: avoid; page-break-after: auto; }
    .document-header, 
    .employee-section, 
    .travel-section, 
    .diet-section, 
    .signature-section { 
        page-break-inside: avoid !important; 
    }

    /* 8. Begrens størrelsen på signaturen */
    .sig-box img {
        max-height: 2cm !important;
        width: auto !important;
    }
}


/* --- VIPPS DONASJON --- */
.vipps-card {
    text-align: center;
    border: 2px solid #ff5b24; /* Gir kortet en diskret Vipps-ramme */
}

.vipps-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 40px;
    margin-top: 20px;
}

.vipps-qr-section {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.vipps-qr-img {
    max-width: 150px;
    border-radius: 10px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}

.vipps-help-text {
    font-size: 0.8rem;
    color: #64748b;
    margin-top: 10px;
}

.vipps-text-section {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.vipps-number {
    font-size: 2.5rem;
    color: #ff5b24; /* Offisiell Vipps-oransje */
    margin: 5px 0 15px 0;
    letter-spacing: 2px;
}

.btn-vipps {
    background-color: #ff5b24;
    color: white;
    font-size: 1.1rem;
    padding: 12px 24px;
    border-radius: 30px; /* Runde knapper er typisk for Vipps */
    text-decoration: none;
    display: inline-block;
    width: 100%;
    max-width: 250px;
}

.btn-vipps:hover {
    background-color: #e04a1a;
}
