@font-face {
    font-family: 'TT Norms';
    src: url('fonts/TTNorms-Regular.woff2') format('woff2'),
         url('fonts/TTNorms-Regular.woff') format('woff');
    font-weight: 400;
    font-style: normal;
}

@font-face {
    font-family: 'TT Norms';
    src: url('fonts/TTNorms-Bold.woff2') format('woff2'),
         url('fonts/TTNorms-Bold.woff') format('woff');
    font-weight: 700;
    font-style: normal;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'TT Norms', Arial, Helvetica, sans-serif;
    background: #f5f7fb;
    color: #1d2433;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px;
}
.container.wide { max-width: 1280px; }

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
    margin-bottom: 18px;
}

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

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-card,
.card {
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 10px 30px rgba(0,0,0,.08);
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 420px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #c9d1df;
    color: #23314d;
    background: #fff;
    border-radius: 10px;
    padding: 10px 14px;
    text-decoration: none;
    cursor: pointer;
    font-size: 14px;
}

.btn.primary {
    background: #1e4ea7;
    color: #fff;
    border-color: #1e4ea7;
}

.btn.small {
    padding: 8px 10px;
    font-size: 13px;
    line-height: 1.2;
}

.btn.danger {
    background: #e74c3c;
    color: #fff;
}

label {
    display: grid;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
}

input, select, textarea {
    width: 100%;
    border: 1px solid #cad3e1;
    border-radius: 10px;
    padding: 12px 14px;
    font: inherit;
    background: #fff;
}

.grid {
    display: grid;
    gap: 16px;
}

.grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid .full {
    grid-column: 1 / -1;
}

.stack-form,
.form-grid {
    display: grid;
    gap: 18px;
}

.service-grid {
    grid-template-columns: 2fr 1fr;
    align-items: end;
}

.service-head {
    font-weight: 700;
    color: #44536e;
    padding-bottom: 4px;
}

.form-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.helper-box,
.muted {
    color: #66758f;
    font-size: 14px;
}

.table-wrap { overflow: auto; }

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px;
    border-bottom: 1px solid #e3e8f1;
    text-align: left;
    vertical-align: top;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin: 20px 0;
}

.stat-card {
    background: #fff;
    border-radius: 18px;
    padding: 22px;
    box-shadow: 0 1px 0 rgba(0,0,0,0.04);
}

.stat-title {
    font-size: 14px;
    color: #6b7280;
    margin-bottom: 10px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #0f172a;
}

.stat-card.income { border-left: 5px solid #2563eb; }
.stat-card.expense { border-left: 5px solid #ef4444; }
.stat-card.net { border-left: 5px solid #16a34a; }

.actions-cell {
    min-width: 360px;
    vertical-align: middle;
}
.nowrap-money {
    white-space: nowrap;
}
.action-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
}
.invoice-actions-top {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.invoice-actions-mail {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
}

.invoice-actions-mail input[type="email"] {
    width: 100%;
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid #cfd7e6;
    border-radius: 10px;
    background: #fff;
    font: inherit;
}

.btn.small {
    min-height: 36px;
    padding: 8px 12px;
    border-radius: 10px;
}

.btn.danger {
    background: #e74c3c;
    color: #fff;
    border-color: #e74c3c;
}

table td {
    vertical-align: top;
}

@media (max-width: 1100px) {
    .actions-cell {
        min-width: 300px;
    }

    .invoice-actions-mail {
        grid-template-columns: 1fr;
    }
}
.invoice-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 320px;
}
.action-row input[type="email"] {
    flex: 1;
    min-width: 180px;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #ccc;
}

.actions-cell button {
    white-space: nowrap;
}

.total-box {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    font-size: 20px;
    padding: 10px 0;
}

.preview-body { background: #eef2f8; }
.print-area { display: flex; justify-content: center; }

.invoice-page {
    position: relative;
    width: 210mm;
    height: 297mm;
    background: #fff;
    box-shadow: 0 10px 24px rgba(0,0,0,.08);
    overflow: hidden;
}

.invoice-bg {
    width: 100%;
    height: 100%;
    display: block;
}

.overlay {
    position: absolute;
    color: #161616;
    line-height: 1.25;
    font-family: 'TT Norms', Arial, sans-serif !important;
    letter-spacing: 0;
}

.recipient-box {
    left: 11.8%;
    top: 6.35%;
    width: 49%;
    min-height: 14%;
    font-size: 15.4px;
    line-height: 1.02;
    white-space: pre-line;
}

.recipient-box div { margin: 0 0 1px 0; }

.datum-value {
    left: 77.0%;
    top: 17.85%;
    width: 11%;
    font-size: 15.8px;
    text-align: left;
}

.invoice-no-value,
.customer-no-value,
.salutation-line,
.subtotal-value,
.grandtotal-value,
.purpose-value,
.bottom-invoice-no,
.service-line,
.amount-line {
    font-family: 'TT Norms', Arial, sans-serif !important;
}

.invoice-no-value {
    left: 24.4%;
    top: 27.80%;
    width: 14%;
    font-size: 15.8px;
    font-weight: 700;
}

.customer-no-value {
    left: 53.6%;
    top: 27.80%;
    width: 16%;
    font-size: 15.8px;
    font-weight: 700;
}

.salutation-line {
    left: 16.1%;
    top: 34.6%;
    width: 28%;
    font-size: 18px;
    font-weight: 700;
    background: transparent;
    padding: 0;
    white-space: nowrap;
}

body[data-salutation="Frau"] .salutation-line,
body[data-salutation="other"] .salutation-line {
    left: 9.9%;
    width: 44%;
    background: rgba(255,255,255,.94);
    padding: 0 2px;
}

.service-line {
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.amount-line {
    font-size: 15px;
    text-align: right;
    white-space: nowrap;
}

.subtotal-value {
    right: 9.6%;
    top: 60.7%;
    width: 20%;
    font-size: 13px;
    text-align: right;
    font-weight: 700;
}

.grandtotal-value {
    right: 9.6%;
    top: 65.07%;
    width: 20%;
    font-size: 17px;
    text-align: right;
    font-weight: 700;
}

.purpose-value {
    left: 30.0%;
    top: 86.10%;
    width: 40%;
    font-size: 15.8px;
    white-space: pre-line;
    font-weight: 700;
}

.bottom-invoice-no {
    left: 31.2%;
    top: 90.00%;
    width: 24%;
    font-size: 15.8px;
    font-weight: 700;
}

.login-logo {
    text-align: center;
    margin-bottom: 20px;
}

.login-logo img {
    max-width: 240px;
    height: auto;
}

@media (max-width: 900px) {
    .stats-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .action-row {
        flex-wrap: wrap;
    }

    .grid.two,
    .service-grid,
    .topbar {
        grid-template-columns: 1fr;
        flex-direction: column;
        align-items: stretch;
    }

    .invoice-page {
        transform-origin: top left;
    }
}

@media print {
    body { background: #fff; }
    .no-print { display: none !important; }
    .container, .container.wide { max-width: none; padding: 0; margin: 0; }
    .print-area { display: block; }
    .invoice-page {
        box-shadow: none;
        width: 210mm;
        height: 297mm;
        margin: 0;
    }
    @page {
        size: A4;
        margin: 0;
    }
}