/**
 * PW Customer Portal — Financials tab (1.7.9)
 * Brand tokens (--pwp-) match the rest of the portal.
 */

.pw-financials {
    --pwp-navy: #0e2038;
    --pwp-ink: #3a4e68;
    --pwp-muted: #6b7c93;
    --pwp-rule: #e5e7eb;
    --pwp-orange: #d9531e;
    font-size: 15px;
}

.pw-fin-loading,
.pw-fin-empty {
    padding: 28px 0;
    color: var(--pwp-muted);
}

.pw-fin-error {
    padding: 12px 14px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 4px;
    color: #991b1b;
}

/* ── Filters ── */
.pw-fin-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 18px;
}

.pw-fin-chip {
    padding: 6px 14px;
    border: 1px solid var(--pwp-rule);
    border-radius: 999px;
    background: #fff;
    color: var(--pwp-ink);
    font-size: 14px;
    cursor: pointer;
    line-height: 1.4;
}

.pw-fin-chip:hover { border-color: #c3cdda; }

.pw-fin-chip--on {
    background: var(--pwp-navy);
    border-color: var(--pwp-navy);
    color: #fff;
}

.pw-fin-select {
    padding: 6px 8px;
    border: 1px solid var(--pwp-rule);
    border-radius: 4px;
    background: #fff;
    color: var(--pwp-ink);
    font-size: 14px;
}

.pw-fin-account { margin-left: auto; }

.pw-fin-monthpick {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.pw-fin-monthpick-label {
    color: var(--pwp-muted);
    font-size: 13px;
}

/* ── The table. A grid, not a <table>: it reflows on a phone without a
      horizontal scrollbar, and the portal is used on phones. ── */
.pw-fin-table {
    border: 1px solid var(--pwp-rule);
    border-radius: 6px;
    overflow: hidden;
    background: #fff;
}

/* 1.9.0: six columns — Document was added between Number and Order, so every
   row carries its own delivery note or credit note instead of the separate
   block that used to sit under the table. */
.pw-fin-row {
    display: grid;
    grid-template-columns: 100px 120px 1fr 1fr 100px 110px;
    gap: 12px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--pwp-rule);
    align-items: center;
}

/* The document link reads as a document, not as body text: it is the thing a
   customer clicks on this screen. */
.pw-fin-doc {
    color: var(--pwp-orange);
    text-decoration: none;
    font-weight: 600;
    word-break: break-all;
}
.pw-fin-doc:hover { text-decoration: underline; }

/* 1.9.4: Email, on the same line as the document it sends. Quieter than the
   document link on purpose — opening the paperwork is the common action and
   sending it is the occasional one, so the link keeps the emphasis. */
.pw-fin-send {
    display: inline-block;
    margin-left: 10px;
    padding: 2px 8px;
    border: 1px solid var(--pwp-rule);
    border-radius: 4px;
    background: #fff;
    color: var(--pwp-muted);
    font: inherit;
    font-size: 12.5px;
    line-height: 1.6;
    cursor: pointer;
    white-space: nowrap;
}

.pw-fin-send:hover {
    border-color: var(--pwp-navy);
    color: var(--pwp-navy);
}

/* Narrow screens: the grid becomes unreadable long before a phone, so the row
   stacks with its labels rather than shrinking into slivers. */
@media (max-width: 900px) {
    .pw-fin-row {
        grid-template-columns: 1fr 1fr;
        gap: 6px 12px;
    }
    .pw-fin-row--head { display: none; }
}

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

.pw-fin-row--head {
    background: #f7f9fb;
    font-size: 12px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--pwp-muted);
}

.pw-fin-row--credit .pw-fin-cell--amt { color: var(--pwp-orange); }

.pw-fin-row--total {
    background: #f7f9fb;
    font-weight: 600;
    color: var(--pwp-navy);
}

.pw-fin-cell {
    color: var(--pwp-ink);
    min-width: 0;
    overflow-wrap: anywhere;
}

.pw-fin-cell--amt {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.pw-fin-muted {
    color: var(--pwp-muted);
    font-style: italic;
}

/* ── Delivery notes ── */
.pw-fin-downloads { margin-top: 24px; }

.pw-fin-downloads h3 {
    font-size: 15px;
    color: var(--pwp-navy);
    margin: 0 0 10px;
}

.pw-fin-dl-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.pw-fin-dl {
    display: inline-block;
    padding: 6px 12px;
    border: 1px solid var(--pwp-rule);
    border-radius: 4px;
    background: #fff;
    color: var(--pwp-navy);
    text-decoration: none;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

.pw-fin-dl:hover {
    border-color: var(--pwp-navy);
    text-decoration: none;
}

/* The email row sits under the download row, same shape, quieter, so the two
   read as "take it" and "send it" rather than four competing buttons. */
.pw-fin-dl--mail {
    margin-top: 8px;
    color: var(--pwp-muted);
    font: inherit;
    font-size: 14px;
    cursor: pointer;
}

.pw-fin-dl--mail:hover { color: var(--pwp-navy); }

/* ── 1.9.4: the send window ──
   Meaning is carried by LIGHTNESS, never by hue: the outcome line is a dark
   panel when it worked and a pale one when it did not, and both say so in
   words. Piotr has protanopia and a dental practice's office is no different
   one time in twelve — a green tick and a red cross are the same mark. */
.pw-fin-modal-back {
    position: fixed;
    inset: 0;
    background: rgba(14, 32, 56, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 100000;
}

.pw-fin-modal {
    background: #fff;
    border-radius: 8px;
    padding: 20px 22px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 12px 40px rgba(14, 32, 56, 0.3);
    font-size: 15px;
    color: var(--pwp-ink);
}

.pw-fin-modal-title {
    margin: 0 0 6px;
    font-size: 17px;
    color: var(--pwp-navy);
}

.pw-fin-modal-what {
    margin: 0 0 14px;
    color: var(--pwp-muted);
    font-size: 14px;
}

.pw-fin-modal-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 14px;
}

.pw-fin-modal-addr {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 9px;
    border: 1px solid var(--pwp-rule);
    border-radius: 4px;
    cursor: pointer;
    overflow-wrap: anywhere;
}

.pw-fin-modal-addr:hover { border-color: #c3cdda; }

.pw-fin-modal-msg:empty { display: none; }

.pw-fin-modal-msg {
    margin-bottom: 12px;
    padding: 8px 10px;
    border-radius: 4px;
    font-size: 14px;
    background: #f2f4f7;
    color: var(--pwp-ink);
}

.pw-fin-modal-msg--ok {
    background: var(--pwp-navy);
    color: #fff;
}

.pw-fin-modal-msg--bad {
    background: #fff;
    border: 1px solid var(--pwp-navy);
    color: var(--pwp-navy);
    font-weight: 600;
}

.pw-fin-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.pw-fin-btn {
    padding: 7px 15px;
    border: 1px solid var(--pwp-rule);
    border-radius: 4px;
    background: #fff;
    color: var(--pwp-ink);
    font: inherit;
    font-size: 14px;
    cursor: pointer;
}

.pw-fin-btn:hover { border-color: #c3cdda; }

.pw-fin-btn--go {
    background: var(--pwp-navy);
    border-color: var(--pwp-navy);
    color: #fff;
}

.pw-fin-btn--go:hover { border-color: var(--pwp-navy); }

.pw-fin-btn[disabled] { opacity: 0.55; cursor: default; }

/* ── Phone: the grid becomes stacked rows with labels. ── */
@media (max-width: 700px) {
    .pw-fin-row {
        grid-template-columns: 1fr auto;
        gap: 4px 12px;
    }
    .pw-fin-row--head { display: none; }
    .pw-fin-cell--amt {
        grid-row: 1;
        grid-column: 2;
        font-weight: 600;
    }
}
