/* Mahnwesen (mahnwesen.html) — this page only. Colours and spacing come from the shared custom
   properties in coolhanx.css; the work bar, the "?" bubble and the tab bar are in ui.css.

   The idea of the page: someone who is owed money asks four things — who owes me, how late are they,
   which letter is due next, and what exactly will that letter claim. So the tabs ARE the next step
   (each with how many invoices wait for it and what they are worth), a row says how many days late
   with a coloured edge, and the panel beside the list shows the letter itself — the itemised claim
   first, the wording under it — with the send bar pinned to the bottom of the panel so the figure
   that is about to be demanded is in sight when the button is pressed. */

.mw .page-head{margin-bottom:3px}
.mw-bar{flex-wrap:wrap;gap:8px 10px;align-items:flex-end}
.mw-tabs{border-bottom:0;margin:0;overflow:visible;flex:0 1 auto}
.mw-tabs [role=tab]{display:flex;flex-direction:column;align-items:flex-start;gap:1px;padding:6px 12px 7px;line-height:1.25}
.mw-tabs [role=tab] .mw-tl{display:inline-flex;align-items:center;gap:5px;font-size:.88rem}
.mw-tabs [role=tab] .badge{margin-left:0;padding:1px 7px}
.mw-tabs [role=tab] .mw-ts{font-size:.72rem;font-weight:600;color:var(--muted);white-space:nowrap}
.mw-tabs [role=tab][aria-selected=true] .badge{background:var(--accent-soft);color:var(--accent-strong);border-color:transparent}
.mw-tabs [role=tab].crit .badge{background:var(--crit-soft);color:var(--crit);border-color:color-mix(in srgb,var(--crit) 30%,transparent)}
.mw-tabs .mw-tab-log{margin-left:10px;border-left:1px solid var(--line-2);padding-left:16px}
.mw-search{width:170px;min-width:0;margin-bottom:6px;background:var(--surface-2);border:1px solid var(--line-2);border-radius:8px;padding:8px 11px;color:var(--ink);font:inherit;font-size:.86rem;box-sizing:border-box}
.mw-search:focus{border-color:var(--accent);background:var(--surface)}
@media(max-width:1400px){.mw-search{width:150px}.mw-tabs [role=tab]{padding:6px 8px 7px}.mw-tabs .mw-tab-log{margin-left:4px;padding-left:10px}}

/* ---- the figures: one line ---- */
.mw-strip{display:flex;flex-wrap:wrap;align-items:baseline;gap:4px 28px;margin:0 2px 10px}
.mw-fig{display:inline-flex;align-items:baseline;gap:7px;min-width:0}
.mw-fig .lab{font-size:.78rem;font-weight:650;color:var(--muted)}
.mw-fig b{font-family:var(--mono);font-variant-numeric:tabular-nums;font-size:1.05rem;font-weight:800;letter-spacing:-.01em;white-space:nowrap}
.mw-fig .sub{font-size:.76rem;color:var(--muted)}
.mw-fig.crit b{color:var(--crit)}
.mw-fig.warn b{color:var(--warn)}

/* ---- the list ---- */
.mw-grid{grid-template-columns:minmax(0,1fr)}
.mw-grid.has-side{grid-template-columns:minmax(0,1fr) 410px}
@media(max-width:1100px){.mw-grid.has-side{grid-template-columns:minmax(0,1fr)}}
@media(max-width:1400px){.mw-grid.has-side{grid-template-columns:minmax(0,1fr) 380px}}
.mw-left{min-width:0}
.mw-listcard{overflow:visible}
.mw-listhead{display:flex;align-items:center;gap:6px;padding:9px 14px;border-bottom:1px solid var(--line)}
.mw-listhead .grow{flex:1 1 auto}
.mw-step{font-size:.9rem;font-weight:800;display:inline-flex;align-items:center}
.mw-bulk{padding:5px 12px;font-size:.8rem;width:auto;white-space:nowrap}
.mw-tbl{table-layout:fixed;width:100%}
.mw-tbl th,.mw-tbl td{padding-left:10px;padding-right:10px}
.mw-tbl th:nth-child(2){width:128px}
.mw-tbl th:nth-child(3){width:112px}
.mw-tbl th:nth-child(4){width:132px}
.mw-tbl th:nth-child(5){width:122px}
.mw-tbl th:nth-child(6){width:140px}
.mw-tbl th:nth-child(3),.mw-tbl th:nth-child(4){text-align:right}
.mw-ltbl th:nth-child(1){width:96px}
.mw-ltbl th:nth-child(2){width:auto}
.mw-ltbl th:nth-child(3){width:210px}
.mw-ltbl th:nth-child(3),.mw-ltbl th:nth-child(4){text-align:left}
.mw-ltbl th:nth-child(4){width:200px}
.mw-tbl td{vertical-align:middle;padding-top:7px;padding-bottom:7px;overflow:hidden}
.mw-tbl td.mw-actions{overflow:visible}
.mw-tbl td.empty{overflow:visible;white-space:normal}
.mw-tbl td:first-child{box-shadow:inset 3px 0 0 var(--rail,transparent)}
.mw-row.mw-ok{--rail:var(--accent)}
.mw-row.mw-warn{--rail:var(--warn)}
.mw-row.mw-late{--rail:var(--crit)}
.mw-row.mw-sent{--rail:var(--good)}
.mw-row.mw-draft{--rail:var(--warn)}
.mw-row.sel{background:var(--accent-soft)}
.mw-grid.has-side .mw-tbl th:nth-child(5),.mw-grid.has-side .mw-tbl td:nth-child(5){display:none}
.mw-grid.has-side .mw-tbl th:nth-child(2){width:112px}
.mw-grid.has-side .mw-tbl th:nth-child(3){width:104px}
.mw-grid.has-side .mw-tbl th:nth-child(4){width:150px}
.mw-grid.has-side .mw-tbl th:nth-child(6){width:138px}
.mw-what{min-width:0}
@media(max-width:1400px){
  /* with the panel open the open amount is in the panel; the room goes to the number and the customer */
  .mw-grid.has-side .mw-tbl th:nth-child(3),.mw-grid.has-side .mw-tbl td:nth-child(3){display:none}
  .mw-grid.has-side .mw-tbl th:nth-child(2){width:100px}
  .mw-grid.has-side .mw-tbl th:nth-child(4){width:140px}
  .mw-grid.has-side .mw-tbl th:nth-child(6){width:128px}
}
.mw-num{display:block;max-width:100%;padding:0;background:none;border:0;color:var(--ink);font-family:var(--mono);font-size:.84rem;font-weight:700;text-align:left;cursor:pointer;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.mw-num:hover{color:var(--accent-strong);text-decoration:underline}
.mw-cust{display:block;margin-top:1px;font-size:.76rem;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.mw-due{white-space:nowrap}
.mw-due>span{display:block}
.mw-days{font-size:.76rem;font-weight:700}
.mw-row.mw-ok .mw-days{color:var(--muted)}
.mw-row.mw-warn .mw-days{color:var(--warn)}
.mw-row.mw-late .mw-days{color:var(--crit)}
.mw-amt{text-align:right;white-space:nowrap}
.mw-amt .mw-sub{display:block}
.mw-sub{display:block;font-size:.72rem;font-weight:500;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.mw-sub.warn{color:var(--warn)}
.mw-c-last{font-size:.8rem}
.mw-state{font-size:.8rem;font-weight:700}
.mw-state.ok{color:var(--good)} .mw-state.warn{color:var(--warn)}
.mw-foot{padding:9px 14px;border-top:1px solid var(--line);font-size:.78rem;color:var(--muted)}
.mw-foot .num{font-weight:700;color:var(--ink)}

/* one main action and a "more" menu */
.mw-actions{white-space:nowrap;text-align:right}
.mw-main{padding:5px 11px;font-size:.78rem;border-color:color-mix(in srgb,var(--accent) 45%,var(--line-2));color:var(--accent-strong)}
.mw-menu-host{display:inline-block;position:relative;margin-left:6px;vertical-align:middle}
.mw-menu-host>summary{list-style:none;padding:4px 10px;font-size:.95rem;line-height:1.2;cursor:pointer}
.mw-menu-host>summary::-webkit-details-marker{display:none}
.mw-menu-host[open]>summary{border-color:var(--accent)}
.mw-menu-host:not([open])>.mw-menu{display:none}
.mw-menu{position:absolute;right:0;top:calc(100% + 4px);z-index:20;min-width:170px;padding:5px;display:flex;flex-direction:column;background:var(--surface);border:1px solid var(--line-2);border-radius:9px;box-shadow:var(--sh-2);text-align:left}
.mw-mi{padding:7px 10px;background:none;border:0;border-radius:6px;color:var(--ink);font:inherit;font-size:.82rem;text-align:left;cursor:pointer}
.mw-mi:hover,.mw-mi:focus-visible{background:var(--accent-soft);color:var(--accent-strong)}

/* ---- the panel beside the list ---- (it stops above the chat button in the corner, so the send bar is never covered) */
.mw-side{position:sticky;top:74px;min-width:0;max-height:calc(100vh - 160px);display:flex;flex-direction:column}
.mw-side[hidden]{display:none}
@media(max-width:1100px){.mw-side{position:static;max-height:none}}
.mw-panel{display:flex;flex-direction:column;min-height:0;max-height:calc(100vh - 160px);overflow:hidden;padding:0}
.mw-pbody{flex:1 1 auto;min-height:0;overflow-y:auto;overflow-x:hidden;padding:14px 16px 12px}
.mw-ph{display:flex;align-items:flex-start;gap:8px}
.mw-pt{flex:1;min-width:0}
.mw-title{margin:0;font-size:1.02rem;font-weight:800;font-family:var(--mono);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.mw-pcust{display:block;margin-top:2px;font-size:.84rem;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.mw-close{height:28px;min-width:28px;padding:0;font-size:1.05rem;line-height:1;width:auto}
.mw-facts{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;margin:12px 0 0;padding:10px 0 0;border-top:1px solid var(--line)}
.mw-fact .lab{display:block;font-size:.72rem;font-weight:700;color:var(--muted)}
.mw-fact b{font-family:var(--mono);font-variant-numeric:tabular-nums;font-size:.9rem;font-weight:800;white-space:nowrap}
.mw-fact.crit b{color:var(--crit)}
.mw-to{margin:8px 0 0;font-size:.8rem;overflow:hidden;text-overflow:ellipsis}
.mw-to.warn{color:var(--warn);font-weight:650}
.mw-torow{display:flex;align-items:center;justify-content:space-between;gap:8px;margin:8px 0 0}
.mw-torow .mw-to{margin:0;min-width:0;flex:1}
.mw-sm{padding:4px 10px;font-size:.78rem;width:auto}
.mw-ptabs{margin:12px 0 10px;overflow:visible}
.mw-ptabs [role=tab]{padding:7px 12px;font-size:.86rem}
.mw-ptabs [role=tab][aria-selected=true]{color:var(--ink);border-bottom-color:var(--accent)}
.mw-ptabs [role=tab] .badge{margin-left:4px;padding:1px 7px}
.mw-pl[hidden],.mw-pf[hidden],.mw-hl[hidden],.mw-sendbar[hidden],.mw-pbody .form-msg[hidden]{display:none}

.mw-form2{display:grid;grid-template-columns:minmax(0,1.5fr) minmax(0,1fr);gap:10px}
.mw-panel .fld{margin:0 0 10px}
.mw-panel .fld label{display:flex;align-items:center;font-size:.76rem;color:var(--muted);margin-bottom:3px}
.mw-panel .fld select,.mw-panel .fld input,.mw-panel .fld textarea{width:100%;box-sizing:border-box}
.mw-panel .fld textarea{resize:vertical;min-height:52px}
.mw-biz{display:flex;align-items:center;gap:8px;margin:0 0 10px;font-size:.84rem}
.mw-biz input{width:auto}
.mw-h4{display:flex;align-items:center;margin:12px 0 6px;font-size:.84rem;font-weight:800}
.mw-h4-first{margin-top:0}
.mw-pbody .form-msg:empty{display:none}

/* what the letter claims */
.mw-ledger{border:1px solid var(--line);border-radius:var(--r);background:var(--surface-2);padding:6px 12px}
.mw-ledger:empty{display:none}
.mw-lr{display:flex;justify-content:space-between;align-items:baseline;gap:12px;padding:3px 0;font-size:.84rem}
.mw-lr .l{display:inline-flex;align-items:center;color:var(--muted)}
.mw-lr .v{font-family:var(--mono);font-variant-numeric:tabular-nums;white-space:nowrap}
.mw-lr.warn .v{color:var(--warn);font-family:inherit;font-size:.78rem;text-align:right;white-space:normal}
.mw-lr.tot{margin-top:4px;padding-top:7px;border-top:1px solid var(--line-2);font-weight:800}
.mw-lr.tot .l{color:var(--ink)}
.mw-lr.tot .v{font-size:.98rem}
.mw-rate{margin:6px 0 0;font-size:.76rem;line-height:1.4}
.mw-rate:empty{display:none}
.mw-panel .form-msg:empty{display:none}

/* the wording of the letter: a sheet of paper, monospaced because the figures line up in columns */
.mw-letter{margin:0;padding:12px 14px;min-height:180px;max-height:46vh;overflow:auto;background:var(--surface);border:1px solid var(--line-2);border-radius:6px;box-shadow:inset 3px 0 0 var(--line-2);font-family:var(--mono);font-size:.76rem;line-height:1.5;white-space:pre-wrap;word-break:break-word;color:var(--ink)}
.mw-letter:focus-visible{outline:2px solid var(--accent);outline-offset:1px}

/* the send bar stays at the bottom of the panel */
.mw-sendbar{flex:none;padding:10px 16px 12px;border-top:1px solid var(--line-2);background:var(--surface)}
.mw-tot{display:flex;justify-content:space-between;align-items:baseline;margin:0 0 8px}
.mw-tot .lab{font-size:.78rem;font-weight:700;color:var(--muted)}
.mw-tot b{font-family:var(--mono);font-size:1.15rem;font-weight:800;letter-spacing:-.01em}
.mw-sendbtns{display:flex;align-items:center;gap:2px;flex-wrap:wrap}
.mw-sendbtns .btn{width:auto}
.mw-sendbtns .btn-primary{margin-left:auto}
.mw-sendbtns .qh{flex:none;margin-left:6px}
.mw-why{margin:8px 0 0;font-size:.78rem;color:var(--warn);line-height:1.4}
.mw-why:empty{display:none}

/* the history of one invoice */
.mw-none{margin:6px 0}
/* the timeline: filled dot = it went out, orange = created but not sent */
.mw-tline{list-style:none;margin:2px 0 0;padding:0 0 0 20px;position:relative}
.mw-tline::before{content:"";position:absolute;left:5px;top:6px;bottom:12px;width:2px;background:var(--line-2)}
.mw-tline li{position:relative;padding:0 0 14px;font-size:.84rem;line-height:1.35}
.mw-tline li:last-child{padding-bottom:0}
.mw-tline li::before{content:"";position:absolute;left:-20px;top:3px;width:12px;height:12px;border-radius:50%;box-sizing:border-box;background:var(--surface);border:2px solid var(--faint)}
.mw-tline li.done::before{background:var(--good);border-color:var(--good)}
.mw-tline li.warn::before{background:var(--warn-soft);border-color:var(--warn)}
.mw-tl-t{display:flex;justify-content:space-between;gap:10px;font-weight:650}
.mw-tl-t .d{flex:none;font-family:var(--mono);font-size:.74rem;font-weight:500;color:var(--muted)}
.mw-tl-s{font-size:.78rem;margin:1px 0 4px}
.mw-tl-d summary{cursor:pointer;font-size:.78rem;color:var(--accent-strong)}
.mw-tl-d .mw-letter{margin-top:6px;max-height:220px}
.mw-tline .mw-sm{margin-top:6px}

/* the dialogs */
.mw-conf{display:grid;grid-template-columns:auto 1fr;gap:6px 16px;margin:0 0 12px;font-size:.9rem}
.mw-conf dt{color:var(--muted);font-weight:650}
.mw-conf dd{margin:0;min-width:0;overflow-wrap:anywhere}
.mw-warn-line{margin:10px 0 0;font-size:.82rem;font-weight:650;color:var(--warn)}
.mw-dbar{display:flex;gap:8px;justify-content:flex-end;margin-top:14px}
.mw-dbar .btn{width:auto}
.mw-dint{margin:0 0 10px;font-size:.84rem}
.mw-dcount{margin:10px 0 0;font-size:.84rem;font-weight:650}
.mw-btbl-wrap{max-height:300px;overflow:auto;border:1px solid var(--line);border-radius:var(--r)}
.mw-btbl{width:100%;font-size:.84rem}
.mw-btbl th:first-child,.mw-btbl td:first-child{width:34px;text-align:center}
.mw-btbl td{vertical-align:top;padding-top:6px;padding-bottom:6px}
.mw-btbl .mw-amt{text-align:right;white-space:nowrap}
