/**
 * MAGPC Weekly Completed Actions v1.4.0 (Phase 29) — light-only, like the action
 * pages it is reached beside.
 *
 * v1.4.0 — Phase 29: the rule line (.window.also) shares the summary line's gutter,
 *   and a raised or updated action (article.action.raised / .updated) carries a
 *   tinted left rule so the eye separates it from a completion.
 *
 * v1.3.1 — the headline summary line (.window.summary) takes the card's 28px
 *   gutter; it is rendered outside .head and sat flush against the card edge.
 *
 * v1.3.0 — Phase 28 follow-up: .kpis .sub, the quieter second figure under a KPI
 *   value, so the Overdue cell stops wrapping mid-value.
 *
 * v1.2.0 — Phase 28 follow-up: toolbar links are chips, shared vocabulary with the
 *   action and unmatched pages. Style only.
 *
 * v1.1.0 — Phase 28 (D6/D7): the good-news box, moved here from magpc-actions.html
 *   when that page became the Weekly Exceptions report. Section + box + empty-state
 *   rules, the mobile gutter, and a print rule that keeps the heading with its
 *   first entry WITHOUT making the box unbreakable — the list is uncapped.
 *
 * The palette is the one magpc-actions.html and css/unmatched-debtors.css already
 * use — #eef1f4 ground, #2c7a8b accent, #1f3a5a headings — so moving between the
 * weekly exceptions list and this report does not feel like changing product. The
 * reading column is 760px rather than the siblings' 680px because the headline
 * carries six KPI cells and the Area table six columns.
 *
 * LIGHT ONLY, on purpose, exactly as css/unmatched-debtors.css is. Not an oversight.
 *
 * LOCKED DECISION #14 — every rule below that sets display/flex/grid on an element
 * which can also carry [hidden] is scoped :not([hidden]). ID-selector specificity
 * beats the UA [hidden] rule, so without it the spinner, the error state and the
 * stale note leak into view.
 *
 * The @media print block at the foot is what makes Ctrl+P readable; the one-click
 * PDF is built by js/magpc-completed-actions-pdf.js and does not use it.
 */

/* ========================================================================
   Page shell
   ======================================================================== */

body.completed-actions {
    margin: 0;
    background: #eef1f4;
    font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #243140;
}

[hidden] { display: none !important; }

.completed-actions .toolbar {
    max-width: 760px;
    margin: 14px auto 0;
    display: flex;
    gap: 10px;
    align-items: flex-start;
    justify-content: space-between;
}
/* Toolbar chips (Phase 28). Sentence case, not the landing page's uppercase:
   uppercase plus letter-spacing costs about 40 per cent more width, which is what
   overflowed the column when a fifth link was added. The back link is always the
   first chip and stays plain - it is a way out, not a destination. */
.completed-actions .toolbar .links {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    min-width: 0;
}
.completed-actions .toolbar .links a {
    display: inline-flex;
    align-items: center;
    font-size: 12px;
    font-weight: 600;
    color: #215f6d;
    text-decoration: none;
    border: 1px solid rgba(44, 122, 139, .38);
    background: rgba(44, 122, 139, .09);
    padding: 6px 11px;
    border-radius: 8px;
    white-space: nowrap;
}
.completed-actions .toolbar .links a:hover {
    background: rgba(44, 122, 139, .19);
    border-color: rgba(44, 122, 139, .65);
    text-decoration: none;
}
.completed-actions .toolbar .links a:first-child {
    background: transparent;
    border-color: transparent;
    padding-left: 0;
    color: #5a6675;
}
.completed-actions .toolbar .links a:first-child:hover { background: transparent; color: #215f6d; }
.completed-actions .toolbar button {
    background: #2c7a8b;
    color: #fff;
    border: 0;
    border-radius: 6px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.completed-actions .toolbar button:disabled { background: #a9bcc3; cursor: not-allowed; }
.completed-actions .toolbar button:not(:disabled):hover { background: #24606d; }

.completed-actions .wrap:not([hidden]) {
    max-width: 760px;
    margin: 14px auto 40px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(20, 40, 60, .12);
    overflow: hidden;
}
.completed-actions .bar { height: 5px; background: linear-gradient(90deg, #2c7a8b, #4aa3b5); }

.completed-actions .head { padding: 20px 28px 6px; }
.completed-actions .logo {
    font-size: 10px;
    letter-spacing: 2px;
    color: #2c7a8b;
    font-weight: 700;
    text-transform: uppercase;
}
.completed-actions .logo .tag { color: #a9bcc3; letter-spacing: 1.2px; font-weight: 600; }
.completed-actions .head h1 { margin: 6px 0 0; font-size: 21px; color: #1f3a5a; }
.completed-actions .head .sub { margin: 4px 0 0; font-size: 12.5px; color: #7a8794; }
.completed-actions .window {
    margin: 8px 0 0;
    font-size: 12.5px;
    font-style: italic;
    color: #6a7889;
    line-height: 1.5;
}

/* State blocks — #14 applies to all three. */
.completed-actions .state:not([hidden]) {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 760px;
    margin: 24px auto;
    padding: 18px 22px;
    background: #fff;
    border-radius: 10px;
    font-size: 13.5px;
    color: #5a6675;
    box-shadow: 0 1px 3px rgba(20, 40, 60, .12);
}
.completed-actions .state.error:not([hidden]) { background: #fbf3f2; color: #8e1f1f; }
.completed-actions .spinner {
    width: 16px; height: 16px;
    border: 2px solid #cfd9e0;
    border-top-color: #2c7a8b;
    border-radius: 50%;
    animation: completed-spin .8s linear infinite;
}
@keyframes completed-spin { to { transform: rotate(360deg); } }

.completed-actions .stale-note:not([hidden]) {
    display: block;
    max-width: 760px;
    margin: 12px auto 0;
    padding: 10px 16px;
    background: #fff7e6;
    border: 1px solid #f0dcb4;
    border-radius: 8px;
    font-size: 12.5px;
    color: #7a5a00;
    line-height: 1.55;
}
.completed-actions .stale-note p { margin: 0 0 4px; }
.completed-actions .stale-note p:last-child { margin-bottom: 0; }

/* ========================================================================
   Headline
   ======================================================================== */

.completed-actions .window.also,
.completed-actions .window.summary { margin: 10px 28px 0; }
.completed-actions .window.summary { margin-top: 4px; }

.completed-actions .kpis {
    width: calc(100% - 56px);
    margin: 14px 28px 0;
    border-collapse: collapse;
    table-layout: fixed;
}
.completed-actions .kpis td {
    padding: 10px 6px;
    border: 1px solid #e6ebf0;
    text-align: center;
    vertical-align: top;
}
.completed-actions .kpis .lab {
    font-size: 9.5px;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: #7a8794;
}
.completed-actions .kpis .val {
    font-size: 15px;
    font-weight: 700;
    color: #1f3a5a;
    margin-top: 4px;
    font-variant-numeric: tabular-nums;
}
/* The quieter second figure under a KPI value. Six cells share the 760px column,
   so a cell carrying two facts on one line runs out of room and wraps mid-value;
   this gives the second one its own line, deliberately. */
.completed-actions .kpis .sub {
    font-size: 10px;
    font-weight: 600;
    color: #7a8794;
    margin-top: 3px;
    font-variant-numeric: tabular-nums;
}
.completed-actions .kpis .val.good { color: #1f8a4c; }
.completed-actions .kpis .val.bad { color: #c0392b; }

.completed-actions .ic-line,
.completed-actions .activity-summary {
    margin: 10px 28px 0;
    padding: 9px 14px;
    background: #f4f6f8;
    border: 1px solid #d7dee5;
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.55;
    color: #4a5563;
}

/* ========================================================================
   Good news — cleared & improving (Phase 28 D6/D7). Moved from
   magpc-actions.html's .good-box and restyled in this sheet's vocabulary; it
   sits at the foot of the headline strip, before the first client group.
   ======================================================================== */

.completed-actions section.good-news { margin: 18px 28px 0; }
.completed-actions section.good-news h2 {
    margin: 0 0 6px;
    padding-left: 10px;
    font-size: 15px;
    color: #1f3a5a;
    border-left: 4px solid #1f8a4c;
}
.completed-actions .good-box {
    background: #eef8f0;
    border: 1px solid #bfe3c7;
    border-radius: 8px;
    padding: 12px 16px;
}
.completed-actions .good-box h3 {
    margin: 0 0 6px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: #1f7a3d;
}
.completed-actions .good-box ul {
    margin: 0;
    padding-left: 18px;
    font-size: 12.5px;
    line-height: 1.7;
    color: #26402e;
}
.completed-actions .good-box .empty { margin: 0; font-size: 12.5px; font-style: italic; color: #4a5563; }

/* ========================================================================
   One section per client group
   ======================================================================== */

.completed-actions section.client {
    padding: 4px 28px 8px;
    margin-top: 18px;
    border-top: 1px solid #eef2f5;
}
.completed-actions section.client h2 {
    margin: 14px 0 4px;
    padding-left: 10px;
    font-size: 15px;
    color: #1f3a5a;
    border-left: 4px solid #2c7a8b;
}
.completed-actions .crm,
.completed-actions .combined {
    margin: 2px 0 0 14px;
    font-size: 12px;
    color: #6a7889;
    line-height: 1.55;
}
.completed-actions .combined { font-variant-numeric: tabular-nums; }
.completed-actions .crm .flag { color: #8a5a12; }

.completed-actions table.areas {
    width: 100%;
    margin: 10px 0 0;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 12px;
}
.completed-actions table.areas th {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: #7a8794;
    text-align: left;
    padding: 5px 6px;
    border-bottom: 1px solid #e6ebf0;
    font-weight: 700;
}
.completed-actions table.areas td {
    padding: 6px;
    border-bottom: 1px solid #f1f4f7;
    vertical-align: top;
    color: #3a4653;
}
.completed-actions table.areas th.num,
.completed-actions table.areas td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.completed-actions table.areas td.num.good { color: #1f8a4c; }
.completed-actions table.areas td.num.bad { color: #c0392b; }
.completed-actions table.areas tr.flagged td { background: #fff7e6; color: #7a5a00; }
.completed-actions table.areas tr.flag-note td {
    font-style: italic;
    font-size: 11.5px;
    color: #8a5a12;
    background: #fff7e6;
    border-bottom: 1px solid #f0dcb4;
}
.completed-actions table.areas td.nodebt { color: #97a2af; font-style: italic; }

/* ========================================================================
   The completed actions themselves
   ======================================================================== */

.completed-actions .acts { margin: 10px 0 2px; }
.completed-actions .acts .acts-head {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: #7a8794;
    margin-bottom: 6px;
}
.completed-actions article.action.raised { border-left-color: #4aa3b5; border-left-width: 3px; }
.completed-actions article.action.updated { border-left-color: #d9a441; border-left-width: 3px; }
.completed-actions article.action {
    border-left: 2px solid #d9e3e7;
    padding-left: 10px;
    margin: 0 0 12px;
}
.completed-actions article.action .meta {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: #2c7a8b;
}
.completed-actions article.action .name {
    font-weight: 600;
    font-size: 13px;
    color: #243140;
    margin-top: 2px;
}
.completed-actions article.action .comments {
    margin: 4px 0 0;
    font-size: 12.5px;
    line-height: 1.6;
    color: #3a4653;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.completed-actions ul.updates {
    margin: 6px 0 0;
    padding-left: 18px;
    font-size: 12.5px;
    line-height: 1.6;
    color: #4a5563;
}
.completed-actions ul.updates li { margin-bottom: 4px; overflow-wrap: anywhere; }
.completed-actions .cut { color: #97a2af; font-style: italic; }

.completed-actions .activity {
    margin: 8px 0 2px;
    padding: 8px 12px;
    background: #f7f9fb;
    border: 1px dashed #d7dee5;
    border-radius: 6px;
    font-size: 12px;
    color: #4a5563;
    line-height: 1.55;
}
.completed-actions .activity ul {
    margin: 6px 0 0;
    padding-left: 18px;
    font-size: 11.5px;
    line-height: 1.7;
    color: #5a6675;
}

/* ========================================================================
   Completed actions on clients with no Sage debtor row
   ======================================================================== */

.completed-actions section.unmatched-block {
    margin: 20px 28px 0;
    padding: 12px 16px;
    background: #f4f6f8;
    border: 1px solid #d7dee5;
    border-radius: 8px;
}
.completed-actions section.unmatched-block h2 {
    margin: 0 0 4px;
    font-size: 14px;
    color: #1f3a5a;
}
.completed-actions section.unmatched-block .lead {
    margin: 0 0 10px;
    font-size: 12px;
    color: #6a7889;
    line-height: 1.55;
}
.completed-actions section.unmatched-block article { margin: 0 0 12px; }
.completed-actions section.unmatched-block article:last-child { margin-bottom: 0; }
.completed-actions section.unmatched-block h3 { margin: 0; font-size: 13px; color: #243140; }
.completed-actions .flag { color: #8a5a12; font-size: 12px; line-height: 1.55; }

/* Brand chips — the three MAGPC colours, as the action page sets them. */
.completed-actions .pill {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 9px;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    letter-spacing: .3px;
    vertical-align: middle;
}
.completed-actions .b-maa { background: #2BA8C9; }
.completed-actions .b-rev { background: #2C5F8D; }
.completed-actions .b-vir { background: #E5202E; }

.completed-actions .foot {
    padding: 14px 28px 22px;
    font-size: 11.5px;
    color: #8a97a5;
    line-height: 1.55;
    border-top: 1px solid #eef1f4;
    margin-top: 16px;
}
.completed-actions .foot p { margin: 0 0 5px; }
.completed-actions .foot p:last-child { margin-bottom: 0; }

@media (max-width: 800px) {
    .completed-actions .wrap:not([hidden]),
    .completed-actions .toolbar { max-width: 100%; margin-left: 10px; margin-right: 10px; }
    .completed-actions .window.also,
    .completed-actions .window.summary { margin-left: 14px; margin-right: 14px; }
    .completed-actions .kpis { width: calc(100% - 28px); margin-left: 14px; margin-right: 14px; }
    .completed-actions section.client { padding-left: 14px; padding-right: 14px; }
    .completed-actions .ic-line,
    .completed-actions .activity-summary,
    .completed-actions section.good-news,
    .completed-actions section.unmatched-block { margin-left: 14px; margin-right: 14px; }
    .completed-actions .foot { padding-left: 14px; padding-right: 14px; }
    .completed-actions .acts { overflow-x: auto; }
}

/* ========================================================================
   Print (Ctrl+P). The one-click PDF does not come through here.
   ======================================================================== */

@media print {
    .completed-actions .toolbar,
    .completed-actions .stale-note,
    .completed-actions .state { display: none !important; }

    body.completed-actions { background: #fff; }
    .completed-actions .wrap:not([hidden]) {
        max-width: 100%;
        margin: 0;
        border: none;
        border-radius: 0;
        box-shadow: none;
    }

    /* A group's header and its Area table stay together; the action prose may
       split across pages, which is the whole point of C8. */
    .completed-actions section.client h2,
    .completed-actions .crm,
    .completed-actions .combined,
    .completed-actions table.areas { page-break-inside: avoid; }
    .completed-actions article.action { page-break-inside: auto; }

    /* Phase 28 D7 — the good-news heading stays with its first entry, and the
       box itself is deliberately NOT page-break-inside:avoid: the list is
       uncapped, and a block taller than a page would clip rather than flow. */
    .completed-actions section.good-news h2,
    .completed-actions .good-box h3 { page-break-after: avoid; }

    @page { margin: 14mm 12mm; }
    * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
