:root {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #1f2937;
    background: #f4f6f8;
    font-synthesis: none;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
}

button, input { font: inherit; }

.container {
    width: min(1460px, calc(100% - 32px));
    margin: 36px auto 72px;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
}

.eyebrow {
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .14em;
    color: #667085;
}

h1 {
    margin: 4px 0 6px;
    font-size: clamp(30px, 4vw, 44px);
    letter-spacing: -.035em;
    color: #111827;
}

h2 {
    margin: 0 0 6px;
    font-size: 19px;
    color: #111827;
}

p { margin: 0; line-height: 1.55; }

.version {
    padding: 7px 10px;
    border: 1px solid #d7dce2;
    border-radius: 999px;
    background: #fff;
    color: #667085;
    font-size: 12px;
    font-weight: 700;
}

.card {
    margin-top: 16px;
    padding: 22px;
    background: #fff;
    border: 1px solid #e1e5ea;
    border-radius: 12px;
    box-shadow: 0 5px 18px rgba(20, 30, 45, .04);
}

.card.compact { padding-block: 18px; }

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.muted { color: #667085; font-size: 14px; }

.upload-row {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-top: 16px;
}

input[type="file"] {
    width: 100%;
    padding: 11px;
    border: 1px dashed #b8c0ca;
    border-radius: 8px;
    background: #fafbfc;
}

button {
    border: 0;
    border-radius: 8px;
    padding: 10px 15px;
    cursor: pointer;
    font-weight: 700;
    white-space: nowrap;
}

button:disabled { opacity: .55; cursor: wait; }

.primary { background: #1f2937; color: #fff; }
.primary:hover:not(:disabled) { background: #111827; }
.secondary { background: #eef1f4; color: #273142; }
.secondary:hover:not(:disabled) { background: #e2e7ec; }

.grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-top: 20px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field.wide { grid-column: span 2; }
.field.small { max-width: 130px; }

.field span {
    font-size: 13px;
    font-weight: 700;
    color: #475467;
}

.field input {
    width: 100%;
    min-height: 40px;
    border: 1px solid #cfd5dc;
    border-radius: 7px;
    padding: 8px 10px;
    background: #fff;
    color: #111827;
}

.field input:focus {
    outline: 2px solid rgba(31, 41, 55, .12);
    border-color: #667085;
}

.actions {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 20px;
}

.status {
    margin-top: 14px;
    padding: 11px 13px;
    border-radius: 7px;
    background: #f1f4f7;
    color: #344054;
    font-size: 14px;
}

.status.error, .status-inline.error { color: #a21d1d; }
.status-inline { font-size: 14px; color: #475467; }

.warning {
    margin-top: 16px;
    padding: 13px 14px;
    border: 1px solid #e5c56f;
    border-radius: 8px;
    background: #fff9e8;
    color: #5e4a12;
    font-size: 14px;
    line-height: 1.5;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    font-weight: 650;
}

.success {
    margin-top: 18px;
    padding: 14px;
    border: 1px solid #9bc7aa;
    border-radius: 8px;
    background: #eef8f1;
    color: #1f5b33;
}

.success a { color: inherit; font-weight: 800; }

.raw-text {
    margin-top: 22px;
    color: #475467;
    font-size: 13px;
}

.raw-text summary { cursor: pointer; font-weight: 700; }
.raw-text pre {
    max-height: 340px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    padding: 12px;
    border-radius: 8px;
    background: #f6f7f9;
    color: #344054;
}

.table-wrap {
    margin-top: 16px;
    overflow-x: auto;
    border: 1px solid #e3e7eb;
    border-radius: 8px;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 850px;
    font-size: 13px;
}

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

th {
    background: #f7f8fa;
    color: #475467;
    font-size: 12px;
}

tbody tr:last-child td { border-bottom: 0; }
.amount-cell { text-align: right; font-variant-numeric: tabular-nums; }
.empty { text-align: center; color: #98a2b3; padding: 22px; }
.table-link { color: #344054; font-weight: 700; }

.hidden { display: none !important; }

code {
    padding: 1px 4px;
    border-radius: 4px;
    background: #eef1f4;
    font-size: .93em;
}

@media (max-width: 850px) {
    .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .upload-row, .section-heading { align-items: stretch; flex-direction: column; }
    .field.small { max-width: none; }
}

@media (max-width: 540px) {
    .container { width: min(100% - 20px, 1460px); margin-top: 20px; }
    .card { padding: 16px; }
    .grid { grid-template-columns: 1fr; }
    .field.wide { grid-column: span 1; }
}

/* v0.3 */
.field select {
    width: 100%;
    min-height: 40px;
    border: 1px solid #cfd5dc;
    border-radius: 7px;
    padding: 8px 10px;
    background: #fff;
    color: #111827;
    font: inherit;
}

.field select:focus {
    outline: 2px solid rgba(31, 41, 55, .12);
    border-color: #667085;
}

.field input:disabled,
.field select:disabled {
    background: #f3f4f6;
    color: #667085;
    cursor: not-allowed;
}

.payment-section {
    margin-top: 22px;
    padding: 16px;
    border: 1px solid #dfe4e9;
    border-radius: 9px;
    background: #f8fafb;
}

.payment-title {
    font-size: 13px;
    font-weight: 800;
    color: #344054;
}

.payment-grid {
    margin-top: 12px;
    grid-template-columns: repeat(2, minmax(0, 260px));
}

.pay {
    background: #e9f5ed;
    color: #22623a;
    border: 1px solid #b9d9c3;
}

.pay:hover:not(:disabled) {
    background: #dcefe2;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .03em;
    white-space: nowrap;
}

.badge.OOTEL {
    background: #fff4cf;
    color: #795b00;
    border: 1px solid #ead58c;
}

.badge.MAKSTUD {
    background: #e8f5ec;
    color: #24603a;
    border: 1px solid #b9d8c2;
}

.badge.KINNITATUD {
    background: #e8eef8;
    color: #294f7d;
    border: 1px solid #b7c9e2;
}

.row-actions {
    /*display: flex;*/
    gap: 6px;
    align-items: center;
    white-space: nowrap;
}
.row-actions * {
    margin-right: 10px;
}

button.mini {
    padding: 6px 9px;
    font-size: 12px;
}

.locked {
    color: #98a2b3;
    font-size: 12px;
    font-weight: 700;
}

@media (max-width: 850px) {
    .payment-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 540px) {
    .payment-grid { grid-template-columns: 1fr; }
}


/* v0.4 */

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.invoice-workspace {
    display: block;
    margin-top: 16px;
}

.invoice-workspace.preview-open {
    display: grid;
    grid-template-columns: minmax(560px, 1fr) minmax(440px, .95fr);
    gap: 18px;
    align-items: start;
}

.form-pane {
    min-width: 0;
}

.pdf-preview-pane {
    min-width: 0;
    border: 1px solid #dfe4e9;
    border-radius: 10px;
    overflow: hidden;
    background: #f7f8fa;
    position: sticky;
    top: 12px;
}

.preview-header {
    min-height: 44px;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid #dfe4e9;
    background: #fff;
    color: #344054;
    font-size: 13px;
}

.pdf-preview-pane iframe {
    display: block;
    width: 100%;
    height: min(76vh, 850px);
    min-height: 620px;
    border: 0;
    background: #e9edf1;
}

.recipient-info {
    margin-top: 16px;
    padding: 13px 15px;
    border: 1px solid #b9cfdf;
    border-radius: 8px;
    background: #f2f7fb;
    color: #29445a;
    font-size: 14px;
    line-height: 1.5;
}

.recipient-info-title {
    font-weight: 800;
    margin-bottom: 5px;
}

.recipient-info ul {
    margin: 4px 0 0 20px;
    padding: 0;
}

.recipient-warning {
    margin-top: 9px;
    padding-top: 9px;
    border-top: 1px solid #d4b463;
    color: #6b4d00;
    font-weight: 750;
}

.payments-filters {
    display: flex;
    align-items: end;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 18px;
    padding: 14px;
    border: 1px solid #e3e7eb;
    border-radius: 9px;
    background: #f8f9fa;
}

.filter-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.filter-field span {
    font-size: 12px;
    font-weight: 700;
    color: #475467;
}

.filter-field input,
.filter-field select {
    min-height: 38px;
    border: 1px solid #cfd5dc;
    border-radius: 7px;
    padding: 7px 9px;
    background: #fff;
    color: #111827;
    font: inherit;
}

.page-size-field {
    width: 105px;
}

.filter-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.filter-help {
    margin-top: 8px;
    font-size: 12px;
}

.pagination {
    margin-top: 14px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}

.pdf-links {
    /*display: flex;*/
    flex-wrap: wrap;
    gap: 8px;
}
.pdf-links * {
    margin-right: 10px;
}

@media (max-width: 1120px) {
    .invoice-workspace.preview-open {
        grid-template-columns: 1fr;
    }

    .pdf-preview-pane {
        position: static;
    }

    .pdf-preview-pane iframe {
        height: 720px;
        min-height: 520px;
    }
}

@media (max-width: 650px) {
    .header-actions,
    .payments-filters,
    .filter-actions,
    .pagination {
        align-items: stretch;
        flex-direction: column;
    }

    .page-size-field {
        width: 100%;
    }

    .pdf-preview-pane iframe {
        height: 70vh;
        min-height: 420px;
    }
}
