/* ╔════════════════════════════════════════════════════════════╗
   ║  SMART INVOICE PORTAL — the Smart Approvals design system    ║
   ║  Palette: Business Central deep teal (see web-approver).   ║
   ║  Base = web-approver/wwwroot/app.css minus the approval-   ║
   ║  only blocks; invoice form/table blocks from the prototype ║
   ╚════════════════════════════════════════════════════════════╝ */
:root {
    --primary:           #015F69;                       /* deep teal */
    --primary-active:    #008089;                       /* BC Tertiary shade 2 (hover/active) */
    --primary-disabled:  #b3e8eb;                       /* derived pale primary */
    --primary-soft:      rgba(1, 95, 105, 0.10);
    --primary-soft-text: #015F69;
    --teal:              #35AB22;                       /* BC Favorable */
    --teal-soft:         rgba(53, 171, 34, 0.10);
    --teal-soft-text:    #2c8f1c;
    --ink:               #212121;                       /* BC Standard / Strong */
    --body:              #505C6D;                       /* BC Secondary */
    --muted:             #A7ADB6;                       /* BC Subordinate */
    --topbar:            #015F69;                       /* deep teal — matches CTA at rest */
    --canvas:            #ffffff;
    --surface-soft:      #f6f9fc;
    --surface-strong:    #f2f4f7;
    --hairline:          #e3e8ee;
    --border-strong:     #A7ADB6;
    --warning:           #9F9700;                       /* BC Ambiguous */
    --warning-soft:      rgba(159, 151, 0, 0.14);
    --error:             #EB6965;                       /* BC Unfavorable / Attention */
    --error-soft:        rgba(235, 105, 101, 0.10);
    --shadow-1: 0 0 0 1px rgba(33, 33, 33, 0.02),
                0 2px 6px rgba(33, 33, 33, 0.04),
                0 4px 8px rgba(33, 33, 33, 0.10);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
    font-family: 'Inter', -apple-system, 'SF Pro Display', "Segoe UI", system-ui, sans-serif;
    color: var(--ink);
    background: var(--canvas);
    line-height: 1.55;
    font-size: 16px;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Installed on a phone (standalone): keep content clear of the home bar. */
    padding-bottom: env(safe-area-inset-bottom);
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-active); text-decoration: underline; }

/* ─────────────────────────────────────────────────────────────
   TOP BAR — dark navy variant (top-nav-dark)
   ───────────────────────────────────────────────────────────── */
header.site-header {
    background: var(--topbar);
    color: #ffffff;
    /* The teal bar runs under a translucent status bar when installed on iOS;
       the inset keeps the brand and nav below the clock. */
    padding: calc(14px + env(safe-area-inset-top)) 56px 14px;
    display: flex;
    align-items: center;
    gap: 32px;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 50;
}
header.site-header .brand {
    color: #ffffff;
    font-weight: 600;
    font-size: 1.15rem;
    letter-spacing: -0.2px;
    text-decoration: none;
}
header.site-header .brand:hover {
    color: #ffffff;
    text-decoration: none;
}
header.site-header nav {
    display: flex;
    gap: 22px;
    flex-wrap: wrap;
}
header.site-header nav a {
    color: rgba(255, 255, 255, 0.78);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    padding: 4px 2px;
    border-bottom: 2px solid transparent;
    transition: border-color 0.15s ease, color 0.15s ease;
}
header.site-header nav a:hover {
    color: #ffffff;
    text-decoration: none;
    border-bottom-color: rgba(255, 255, 255, 0.45);
}
header.site-header nav a.active {
    color: #ffffff;
    border-bottom-color: #ffffff;
}

/* ─────────────────────────────────────────────────────────────
   PAGE CONTAINER
   ───────────────────────────────────────────────────────────── */
.page {
    max-width: 1040px;
    margin: 0 auto;
    padding: 32px 56px 64px;
}

/* ─────────────────────────────────────────────────────────────
   HERO
   ───────────────────────────────────────────────────────────── */
header.hero {
    border-bottom: 1px solid var(--hairline);
    padding-bottom: 32px;
    margin-bottom: 40px;
}
header.hero .eyebrow {
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    font-size: 0.78rem;
    font-weight: 700;
    margin-bottom: 14px;
}
h1 {
    color: var(--ink);
    font-size: 2.2rem;
    font-weight: 600;
    letter-spacing: -0.5px;
    margin: 0 0 14px;
    line-height: 1.2;
}
header.hero .lede {
    color: var(--body);
    font-size: 1.05rem;
    font-weight: 400;
    max-width: 760px;
    margin: 0;
    line-height: 1.55;
}
/* Posting description / BC document no. under the headline. Styled like the
   former "lede" line (the sent/due lede was removed — that info lives in the rail). */
.hero-note {
    margin: 0;
    max-width: 760px;
    color: var(--body);
    font-size: 1.05rem;
    font-weight: 400;
    line-height: 1.55;
}

/* ─────────────────────────────────────────────────────────────
   HEADINGS / BODY
   ───────────────────────────────────────────────────────────── */
h2 {
    color: var(--ink);
    font-size: 1.45rem;
    font-weight: 500;
    letter-spacing: -0.35px;
    margin: 56px 0 18px;
}
h3 {
    color: var(--ink);
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: -0.2px;
    margin: 28px 0 8px;
}
h4 {
    color: var(--ink);
    font-size: 1rem;
    font-weight: 600;
    margin: 16px 0 4px;
}
p { margin: 0 0 12px; color: var(--body); }
p.lede {
    font-size: 1.05rem;
    color: var(--muted);
    max-width: 760px;
    margin: 4px 0 22px;
}
ul, ol { margin: 0 0 12px; padding-left: 22px; color: var(--body); }
ul li, ol li { margin-bottom: 6px; line-height: 1.55; }

code {
    background: var(--surface-soft);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.92em;
    color: var(--primary-soft-text);
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-feature-settings: 'tnum';
    border: 1px solid var(--hairline);
}

/* ─────────────────────────────────────────────────────────────
   CTA BUTTONS (pill-shaped — smart-air signature)
   ───────────────────────────────────────────────────────────── */
.cta-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 28px;
}
.cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 48px;
    padding: 0 24px;
    background: var(--primary);
    color: #ffffff;
    border-radius: 9999px;
    text-decoration: none;
    font-weight: 500;
    font-size: 1rem;
    line-height: 1.0;
    transition: background-color 160ms ease;
    border: 0;
    cursor: pointer;
    font-family: inherit;
}
.cta:hover {
    background: var(--primary-active);
    color: #ffffff;
    text-decoration: none;
}
.cta.secondary {
    background: var(--canvas);
    color: var(--ink);
    border: 1px solid var(--ink);
}
.cta.secondary:hover {
    background: var(--surface-strong);
    color: var(--ink);
}

/* ─────────────────────────────────────────────────────────────
   STATUS PILLS (used on approval cards / detail views)
   ───────────────────────────────────────────────────────────── */
.pill {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    padding: 4px 10px;
    border-radius: 9999px;
}
/* Invoice statuses: Open = draft, Released = ready to post, then posted and its
   payment state. The approver app's other modifiers are not used here. */
.pill.draft      { background: var(--surface-strong); color: var(--body); }
.pill.released   { background: var(--warning-soft);   color: var(--warning); }
.pill.posted     { background: var(--primary-soft);   color: var(--primary-soft-text); }
.pill.paid       { background: var(--teal-soft);      color: var(--teal-soft-text); }
.pill.unpaid     { background: var(--warning-soft);   color: var(--warning); }

/* List / page states */
.state {
    padding: 64px 24px;
    text-align: center;
    color: var(--muted);
    font-size: 0.95rem;
}
.state.error {
    color: var(--error);
}
.state .cta {
    margin-top: 16px;
}

/* ─────────────────────────────────────────────────────────────
   LIST TOOLBAR + VIEW TOGGLE (segmented control)
   ───────────────────────────────────────────────────────────── */
.list-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin: 24px 0 16px;
    flex-wrap: wrap;
}

.list-count {
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 500;
    font-feature-settings: 'tnum';
}

.view-toggle {
    display: inline-flex;
    background: var(--surface-strong);
    border-radius: 9999px;
    padding: 3px;
    gap: 2px;
}

.view-toggle-option {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.0;
    border-radius: 9999px;
    cursor: pointer;
    transition: background-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.view-toggle-option svg {
    width: 14px;
    height: 14px;
}

.view-toggle-option:hover {
    color: var(--ink);
}

.view-toggle-option.active {
    background: var(--canvas);
    color: var(--ink);
    box-shadow: var(--shadow-1);
}

.view-toggle-option .filter-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 6px;
    border-radius: 9999px;
    background: var(--hairline);
    color: var(--body);
    font-size: 0.72rem;
    font-weight: 600;
    font-feature-settings: 'tnum';
    line-height: 1;
}

.view-toggle-option.active .filter-count {
    background: var(--primary-soft);
    color: var(--primary-soft-text);
}

/* ─────────────────────────────────────────────────────────────
   INVOICE LIST (rows)
   ───────────────────────────────────────────────────────────── */
.invoice-list {
    display: flex;
    flex-direction: column;
    background: var(--canvas);
    border: 1px solid var(--hairline);
    border-radius: 14px;
    overflow: hidden;
}

.invoice-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto auto;
    gap: 20px;
    align-items: center;
    padding: 16px 20px;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid var(--hairline);
    transition: background-color 160ms ease;
}

.invoice-row:last-child {
    border-bottom: 0;
}

.invoice-row:hover {
    background: var(--surface-soft);
    text-decoration: none;
    color: inherit;
}

.invoice-row .row-vendor {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.invoice-row .row-vendor .vendor {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.invoice-row .row-vendor .doc-meta {
    font-size: 0.85rem;
    color: var(--muted);
}

.invoice-row .row-due {
    font-size: 0.85rem;
    color: var(--muted);
    font-feature-settings: 'tnum';
    white-space: nowrap;
}

.invoice-row .amount {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--ink);
    font-feature-settings: 'tnum';
    letter-spacing: -0.18px;
    white-space: nowrap;
}
@media (max-width: 720px) {
    .invoice-row {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 12px;
    }
    .invoice-row .pill,
    .invoice-row .row-due {
        display: none;
    }
}

/* ─────────────────────────────────────────────────────────────
   DETAIL PAGE
   ───────────────────────────────────────────────────────────── */
.back-link {
    display: inline-flex;
    align-items: center;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    margin-bottom: 24px;
    transition: color 160ms ease;
}
.back-link:hover {
    color: var(--ink);
    text-decoration: none;
}

.detail-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 32px;
    align-items: start;
}

.detail-main { min-width: 0; }

/* ─────────────────────────────────────────────────────────────
   SIGN-IN (Auðkenni)
   ───────────────────────────────────────────────────────────── */
.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(1200px 600px at 50% -10%, var(--primary-soft), transparent 60%),
        var(--surface-soft);
}
.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--canvas);
    border: 1px solid var(--hairline);
    border-radius: 18px;
    box-shadow: var(--shadow-1);
    padding: 40px 36px;
    text-align: center;
}
.auth-brand {
    color: var(--primary);
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: -0.2px;
    margin-bottom: 28px;
}
.auth-title {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.3px;
    margin: 0 0 8px;
}
.auth-sub {
    color: var(--body);
    font-size: 0.95rem;
    margin: 0 0 28px;
}
.auth-form {
    text-align: left;
    display: flex;
    flex-direction: column;
}
.auth-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--body);
    margin-bottom: 8px;
}
.auth-input {
    font-family: inherit;
    font-size: 1.35rem;
    font-weight: 600;
    letter-spacing: 2px;
    text-align: center;
    color: var(--ink);
    padding: 14px 16px;
    border: 1px solid var(--hairline);
    border-radius: 12px;
    background: var(--surface-soft);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    font-feature-settings: 'tnum';
}
.auth-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
    background: var(--canvas);
}
.auth-btn {
    margin-top: 20px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    background: var(--primary);
    border: 0;
    border-radius: 12px;
    padding: 14px 16px;
    cursor: pointer;
    transition: background 0.15s ease;
}
.auth-btn:hover:not(:disabled) { background: var(--primary-active); }
.auth-btn:disabled { background: var(--primary-disabled); cursor: default; }
.auth-btn.ghost {
    color: var(--body);
    background: transparent;
    border: 1px solid var(--hairline);
    margin-top: 12px;
}
.auth-btn.ghost:hover:not(:disabled) { background: var(--surface-soft); }
.auth-error {
    margin-top: 14px;
    color: var(--error);
    background: var(--error-soft);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 0.88rem;
}
.auth-controlcode {
    font-size: 3.2rem;
    font-weight: 700;
    letter-spacing: 6px;
    color: var(--ink);
    font-feature-settings: 'tnum';
    margin: 8px 0 24px;
}
.auth-waiting {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--body);
    font-size: 0.95rem;
    margin-bottom: 8px;
}
.auth-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--primary-soft);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: auth-spin 0.8s linear infinite;
}
@keyframes auth-spin { to { transform: rotate(360deg); } }

/* Company picker (shown when a kennitala has access to more than one company) */
.auth-company-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 4px;
}
.auth-company {
    margin-top: 0;
    text-align: center;
}

/* Company name chip in the header (left of the user name, on the teal bar) */
.site-company {
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.85rem;
    font-weight: 600;
    padding-right: 12px;
    border-right: 1px solid rgba(255, 255, 255, 0.25);
}

/* ─────────────────────────────────────────────────────────────
   TOAST (e.g. post success)
   ───────────────────────────────────────────────────────────── */
.toast {
    position: fixed;
    left: 50%;
    bottom: calc(28px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: var(--ink);
    color: #fff;
    padding: 12px 18px;
    border-radius: 12px;
    box-shadow: var(--shadow-1);
    font-size: 0.92rem;
    font-weight: 600;
    z-index: 1300; /* above the celebration overlay */
    animation: toast-in 0.2s ease;
    max-width: calc(100vw - 32px);
}
.toast svg {
    width: 18px;
    height: 18px;
    color: var(--teal);
    flex-shrink: 0;
}
@keyframes toast-in {
    from { opacity: 0; transform: translate(-50%, 8px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* Signed-in user chip + logout in the top bar */
.site-user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 14px;
}
.site-user-name {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.9rem;
    font-weight: 500;
}
.site-logout {
    color: rgba(255, 255, 255, 0.78);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 999px;
    padding: 5px 14px;
    transition: border-color 0.15s ease, color 0.15s ease;
}
.site-logout:hover {
    color: #ffffff;
    text-decoration: none;
    border-color: rgba(255, 255, 255, 0.6);
}

.detail-rail {
    background: var(--canvas);
    border: 1px solid var(--hairline);
    border-radius: 14px;
    padding: 24px;
    box-shadow: var(--shadow-1);
    position: sticky;
    top: 88px;
    /* query container so the amount can scale to the rail width, not the viewport */
    container-type: inline-size;
}

/* The signature amount-display moment */
.amount-display {
    text-align: center;
    padding: 8px 0 24px;
    border-bottom: 1px solid var(--hairline);
    margin-bottom: 20px;
}
.amount-display .amount-label {
    color: var(--muted);
    text-transform: uppercase;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.4px;
    margin-bottom: 10px;
}
.amount-display .amount-value {
    /* fluid: ~52px at the 320px rail, shrinks with the card down to 28px */
    font-size: clamp(1.75rem, 19cqi, 52px);
    font-weight: 700;
    line-height: 1.0;
    letter-spacing: -1px;
    color: var(--ink);
    font-feature-settings: 'tnum';
}
.amount-display .amount-currency {
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 500;
    margin-top: 10px;
    font-feature-settings: 'tnum';
    letter-spacing: 0.2px;
}

.detail-meta {
    margin: 0 0 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.detail-meta > div {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
.detail-meta dt {
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 500;
    margin: 0;
}
.detail-meta dd {
    color: var(--ink);
    font-size: 0.9rem;
    font-weight: 500;
    margin: 0;
    text-align: right;
    font-feature-settings: 'tnum';
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.action-pills {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-top: 20px;
    border-top: 1px solid var(--hairline);
}

.action-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 48px;
    padding: 0 24px;
    width: 100%;
    border-radius: 9999px;
    font-family: inherit;
    font-weight: 500;
    font-size: 1rem;
    line-height: 1.0;
    cursor: pointer;
    transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
    border: 0;
}
.action-pill.primary {
    background: var(--primary);
    color: #ffffff;
}
.action-pill.primary:hover:not(:disabled) {
    background: var(--primary-active);
}
.action-pill.primary:disabled {
    background: var(--primary-disabled);
    cursor: not-allowed;
}
.action-pill.outline {
    background: var(--canvas);
    color: var(--ink);
    border: 1px solid var(--ink);
}
.action-pill.outline:hover:not(:disabled) {
    background: var(--surface-strong);
}
.action-pill.outline:disabled {
    color: var(--muted);
    border-color: var(--hairline);
    cursor: not-allowed;
}
/* The outline pill doubles as a link ("Hætta við" on the form). */
a.action-pill {
    text-decoration: none;
}
a.action-pill:hover {
    text-decoration: none;
}

@media (max-width: 900px) {
    .detail-layout { grid-template-columns: 1fr; }
    .detail-rail { position: static; }
}

/* ─────────────────────────────────────────────────────────────
   RESPONSIVE
   ───────────────────────────────────────────────────────────── */
@media (max-width: 720px) {
    header.site-header { padding: calc(12px + env(safe-area-inset-top)) 20px 12px; gap: 16px; }
    header.site-header nav { gap: 14px; }
    .page { padding: 24px 20px 48px; }
    h1 { font-size: 1.7rem; letter-spacing: -0.35px; }
    h2 { font-size: 1.25rem; margin: 40px 0 14px; }
}

/* ─────────────────────────────────────────────────────────────
   BLAZOR DEFAULTS — preserved (validation + error boundary)
   ───────────────────────────────────────────────────────────── */
h1:focus { outline: none; }

.valid.modified:not([type=checkbox]) {
    outline: 1px solid var(--teal);
}
.invalid {
    outline: 1px solid var(--error);
}
.validation-message {
    color: var(--error);
}
.blazor-error-boundary {
    background: var(--error);
    padding: 16px 20px;
    color: #ffffff;
    border-radius: 14px;
    margin: 12px 0;
    font-weight: 500;
}
.blazor-error-boundary::after {
    content: "An error has occurred."
}

/* Warning toast: an exclamation in the warning colour. */
.toast.warning svg { color: var(--warning); }

/* ─────────────────────────────────────────────────────────────
   RAIL ACTIONS UNDER THE AMOUNT
   ───────────────────────────────────────────────────────────── */
/* The action block follows the amount directly; the amount's own rule
   separates them, and the block closes with a rule before the facts. */
.rail-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 0 0 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--hairline);
}
.rail-actions .action-pills {
    padding-top: 0;
    border-top: 0;
}
/* Why there is no "Bóka reikning" for this login. */
.rail-note {
    margin: 0;
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.45;
}
.detail-rail > .auth-error {
    margin: 0 0 20px;
}
.detail-rail > :last-child {
    margin-bottom: 0;
}

/* ─────────────────────────────────────────────────────────────
   SKELETON ROWS — the list while it loads
   ───────────────────────────────────────────────────────────── */
.skeleton-list {
    display: flex;
    flex-direction: column;
    margin-top: 24px;
    background: var(--canvas);
    border: 1px solid var(--hairline);
    border-radius: 14px;
    overflow: hidden;
}
.skeleton-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 20px;
    align-items: center;
    padding: 18px 20px;
    border-bottom: 1px solid var(--hairline);
}
.skeleton-row:last-child { border-bottom: 0; }
.skeleton-text { display: flex; flex-direction: column; gap: 9px; }
.skeleton-line,
.skeleton-block {
    display: block;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--surface-strong) 25%, var(--surface-soft) 37%, var(--surface-strong) 63%);
    background-size: 400% 100%;
    animation: shimmer 1.4s ease infinite;
}
.skeleton-line.w-vendor { height: 14px; width: 52%; max-width: 280px; }
.skeleton-line.w-meta   { height: 11px; width: 34%; max-width: 180px; }
.skeleton-block { height: 16px; width: 96px; }
@keyframes shimmer {
    from { background-position: 100% 0; }
    to   { background-position: 0 0; }
}
@media (prefers-reduced-motion: reduce) {
    .skeleton-line, .skeleton-block { animation: none; }
}
/* Visually hidden, read by screen readers. */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ─────────────────────────────────────────────────────────────
   HEADER USER MENU — initials avatar on phones
   ───────────────────────────────────────────────────────────── */
.site-user-menu {
    display: none;
    position: relative;
}
.site-user-menu > summary {
    list-style: none;
    cursor: pointer;
}
.site-user-menu > summary::-webkit-details-marker { display: none; }
.site-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.35);
    color: #ffffff;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    user-select: none;
}
.site-user-menu[open] .site-avatar { background: rgba(255, 255, 255, 0.3); }
.site-avatar:focus-visible { outline: 2px solid #ffffff; outline-offset: 2px; }
.site-user-card {
    position: absolute;
    right: 0;
    top: 44px;
    min-width: 220px;
    background: var(--canvas);
    color: var(--ink);
    border: 1px solid var(--hairline);
    border-radius: 14px;
    box-shadow: var(--shadow-1);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 60;
}
.site-user-card-name { font-size: 0.95rem; font-weight: 600; }
.site-user-card-company { font-size: 0.85rem; color: var(--body); }
.site-user-card .site-logout {
    align-self: flex-start;
    margin-top: 10px;
    color: var(--primary);
    border-color: var(--primary);
}
.site-user-card .site-logout:hover { color: var(--primary-active); border-color: var(--primary-active); }
@media (max-width: 720px) {
    .site-company,
    .site-user-name,
    .site-user > .site-logout { display: none; }
    .site-user-menu { display: block; }
}

/* ─────────────────────────────────────────────────────────────
   FORM CARDS + FIELDS (new-invoice header)
   ───────────────────────────────────────────────────────────── */
.form-card {
    background: var(--canvas);
    border: 1px solid var(--hairline);
    border-radius: 14px;
    padding: 24px;
    margin-bottom: 24px;
}

.form-card-title {
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: -0.2px;
    margin: 0 0 18px;
}

.form-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 16px;
}

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

.field label {
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 500;
}

.field-input {
    width: 100%;
    height: 44px;
    padding: 0 12px;
    background: var(--canvas);
    border: 1px solid var(--hairline);
    border-radius: 8px;
    color: var(--ink);
    font: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 160ms ease;
}
.field-input:hover {
    border-color: var(--border-strong);
}
.field-input:focus {
    border-color: var(--ink);
}
.field-input::placeholder {
    color: var(--muted);
}
.field-input.num {
    text-align: right;
    font-feature-settings: 'tnum';
}
select.field-input {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23505C6D' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 34px;
}

/* ─────────────────────────────────────────────────────────────
   LINES EDITOR (new-invoice rows)
   ───────────────────────────────────────────────────────────── */
.lines-editor {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.lines-editor .lines-head,
.lines-editor .line-row {
    display: grid;
    /* account · description · quantity · unit price · discount % · amount · remove */
    grid-template-columns: 2fr 3fr 80px 120px 90px 110px 36px;
    gap: 10px;
    align-items: center;
}

.lines-head {
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 500;
}

.lines-head .num {
    text-align: right;
}

.line-amount {
    text-align: right;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--ink);
    font-feature-settings: 'tnum';
    white-space: nowrap;
}

.line-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 9999px;
    background: transparent;
    color: var(--muted);
    font-size: 0.85rem;
    cursor: pointer;
    transition: background-color 160ms ease, color 160ms ease;
}
.line-remove:hover:not(:disabled) {
    background: var(--error-soft);
    color: var(--error);
}
.line-remove:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.add-line {
    height: 44px;
    border: 1px dashed var(--hairline);
    border-radius: 8px;
    background: transparent;
    color: var(--primary);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 160ms ease, background-color 160ms ease;
}
.add-line:hover {
    border-color: var(--primary);
    background: var(--primary-soft);
}

.totals-row {
    display: flex;
    justify-content: flex-end;
    align-items: baseline;
    gap: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--hairline);
}

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

.totals-amount {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--ink);
    font-feature-settings: 'tnum';
}

.totals-note {
    margin: 4px 0 0;
    text-align: right;
    color: var(--muted);
    font-size: 0.8rem;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 8px;
    flex-wrap: wrap;
}
.form-actions .action-pill {
    width: auto;
    min-width: 220px;
}

/* ─────────────────────────────────────────────────────────────
   LINES TABLE (read-only, detail page)
   ───────────────────────────────────────────────────────────── */
.lines-table {
    background: var(--canvas);
    border: 1px solid var(--hairline);
    border-radius: 14px;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
}

.lines-table .lines-head,
.lines-table .lines-table-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 80px 120px 130px;
    gap: 12px;
    align-items: center;
}

.lines-table .lines-head {
    padding-bottom: 10px;
    border-bottom: 1px solid var(--hairline);
}

.lines-table-row {
    padding: 12px 0;
    border-bottom: 1px solid var(--hairline);
    font-size: 0.95rem;
}
.lines-table-row:last-of-type {
    border-bottom: 0;
}

.lines-table-row .line-description {
    color: var(--ink);
    font-weight: 500;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lines-table .num {
    text-align: right;
    white-space: nowrap;
}

.lines-table .totals-row {
    margin-top: 4px;
}

.lines-empty {
    padding: 24px 0;
    text-align: center;
    color: var(--muted);
    font-size: 0.9rem;
}
/* Five columns here (VSK % between the unit price and the amount). */
.lines-table .lines-head,
.lines-table .lines-table-row {
    grid-template-columns: minmax(0, 1fr) 80px 120px 70px 130px;
}
/* Six when a line carries a discount (Afsl. % between the unit price and VSK %). */
.lines-table.with-discount .lines-head,
.lines-table.with-discount .lines-table-row {
    grid-template-columns: minmax(0, 1fr) 80px 120px 70px 70px 130px;
}

.confirm-note {
    margin: 0;
    color: var(--body);
    font-size: 0.9rem;
    line-height: 1.45;
}

.rail-error {
    margin: 0 0 16px;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--error-soft);
    color: var(--error);
    font-size: 0.85rem;
    line-height: 1.45;
}

/* ─────────────────────────────────────────────────────────────
   RESPONSIVE — the form and the tables on a phone
   ───────────────────────────────────────────────────────────── */
@media (max-width: 720px) {
    .form-grid { grid-template-columns: 1fr; }

    /* Line editor rows stack into small per-line cards: account and
       description full width, then quantity · unit price · discount %,
       then the amount with the remove button. */
    .lines-editor .lines-head { display: none; }
    .lines-editor .line-row {
        grid-template-columns: 1fr 1fr 1fr;
        border: 1px solid var(--hairline);
        border-radius: 8px;
        padding: 12px;
    }
    .lines-editor .line-row select,
    .lines-editor .line-row input[type="text"] {
        grid-column: 1 / -1;
    }
    .lines-editor .line-row .line-amount {
        grid-column: span 2;
    }
    .form-actions .action-pill { width: 100%; min-width: 0; }

    /* Description + amount only; quantity, unit price and VAT % are in the rail totals. */
    .lines-table .lines-head,
    .lines-table .lines-table-row {
        grid-template-columns: minmax(0, 1fr) 110px;
    }
    .lines-table .lines-head span:nth-child(2),
    .lines-table .lines-head span:nth-child(3),
    .lines-table .lines-head span:nth-child(4),
    .lines-table .lines-table-row span:nth-child(2),
    .lines-table .lines-table-row span:nth-child(3),
    .lines-table .lines-table-row span:nth-child(4),
    .lines-table.with-discount .lines-head span:nth-child(5),
    .lines-table.with-discount .lines-table-row span:nth-child(5) {
        display: none;
    }
}
