/* ---------- formatting editor and attachments ---------- */
.rte { border: 1px solid var(--line); border-radius: 10px; background: var(--surface, #fff); overflow: hidden; }
.rte__bar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 6px; background: var(--sunken); border-bottom: 1px solid var(--line); }
.rte__btn { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 32px; padding: 0 8px; border: 0; border-radius: 7px; background: transparent; color: inherit; font: inherit; font-size: 13.5px; cursor: pointer; position: relative; white-space: nowrap; }
.rte__btn:hover { background: color-mix(in srgb, var(--ink, #111) 8%, transparent); }
.rte__btn:focus-visible, .rte__sel:focus-visible { outline: 2px solid var(--accent, #2563eb); outline-offset: 1px; }
.rte__btn.is-on { background: color-mix(in srgb, var(--accent, #2563eb) 18%, transparent); }
.rte__btn:disabled, .rte__sel:disabled { opacity: .4; cursor: default; }
.rte__btn--b { font-weight: 800; } .rte__btn--i { font-style: italic; font-family: Georgia, serif; } .rte__btn--u { text-decoration: underline; } .rte__btn--s { text-decoration: line-through; }
.rte__btn--mono { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.rte__btn--color { overflow: hidden; }
.rte__btn--hi { background: #fff3a3; }
.rte__color { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; padding: 0; border: 0; }
.rte__sel { height: 32px; border: 1px solid transparent; border-radius: 7px; background: transparent; font: inherit; font-size: 13.5px; padding: 0 6px; color: inherit; max-width: 110px; }
.rte__sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.rte__popwrap { position: relative; display: inline-flex; }
.rte__pop { position: absolute; top: 36px; left: 0; z-index: 20; display: grid; grid-template-columns: repeat(8, 32px); gap: 2px; padding: 6px; background: var(--surface, #fff); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .14); }
.rte__pop[hidden] { display: none; }
.rte__pop--list { grid-template-columns: 1fr; min-width: 140px; }
.rte__pop--list button { text-align: left; padding: 7px 10px; border: 0; background: transparent; border-radius: 6px; font: inherit; cursor: pointer; }
.rte__pop--list button:hover, .rte__ch:hover { background: var(--sunken); }
.rte__ch { height: 32px; border: 0; background: transparent; border-radius: 6px; font: inherit; font-size: 16px; cursor: pointer; }
.rte__area { min-height: 300px; padding: 14px 16px; line-height: 1.55; outline: 0; overflow-wrap: anywhere; }
.rte__area:focus { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent, #2563eb) 35%, transparent); }
.rte__area[hidden], .rte__src[hidden] { display: none; }
.rte__src { width: 100%; min-height: 300px; border: 0; padding: 14px 16px; font: 12.5px/1.5 ui-monospace, Menlo, monospace; resize: vertical; background: var(--surface, #fff); color: inherit; }
.rte__area p, .rte__view p { margin: 0 0 .8em; }
.rte__area ul, .rte__area ol, .rte__view ul, .rte__view ol { margin: 0 0 .8em; padding-left: 1.5em; }
.rte__area table, .rte__view table { border-collapse: collapse; width: 100%; }
.rte__area a, .rte__view a { color: var(--accent, #2563eb); text-decoration: underline; }
.rte--full { position: fixed; inset: 0; z-index: 100; border-radius: 0; display: flex; flex-direction: column; background: var(--surface, #fff); }
.rte--full .rte__area, .rte--full .rte__src { flex: 1; min-height: 0; overflow: auto; }
body.rte-lock { overflow: hidden; }
.rte__view { line-height: 1.55; overflow-wrap: anywhere; }
.em-preview--rich { white-space: normal; }
.em-preview__subj { margin-bottom: 10px; }
.draft__rich { padding: 12px 14px; background: var(--sunken); border: 1px solid var(--line); border-radius: 10px; }
.draft__warn[hidden] { display: none; }
.attach { margin-top: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.attach__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.attach__list { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 6px; }
.attach__list li { display: flex; align-items: center; gap: 8px 10px; flex-wrap: wrap; }
.attach__name { flex: 1 1 140px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.attach__hint { margin: 4px 0 0; font-size: 13px; }
.attach__pick { position: relative; cursor: pointer; display: inline-flex; margin-top: 4px; }
.attach__input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
@media (max-width: 640px) { .rte__sel { max-width: 90px; } }

/* ---------- merge fields and the file library ---------- */
.tokpicker { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.tokgrp { border-top: 1px solid var(--line); padding: 8px 0; }
.tokgrp:first-of-type { border-top: 0; }
.tokgrp summary { cursor: pointer; font-weight: 600; padding: 2px 0 8px; }
.tokgrp__note { margin: 0 0 8px; font-size: 13px; }
.tokpeople { display: grid; gap: 6px; }
.tokpeople__row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.attach__codewrap { font: 12.5px ui-monospace, Menlo, monospace; color: var(--muted, #667); white-space: nowrap; }
.attach__code { width: 12ch !important; flex: none; border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; font: inherit; }

/* ---- task row icons and menu ---- */
.sec { overflow: visible; }
.sec__head { border-radius: var(--r-panel) var(--r-panel) 0 0; }
.sec .item:last-child { border-radius: 0 0 var(--r-panel) var(--r-panel); }
.ibar { display: flex; align-items: center; gap: 2px; flex-wrap: nowrap; justify-content: flex-end; }
.ibar .iconbtn { width: 28px; height: 28px; }
.cbadge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; margin-right: 2px; border: 0; border-radius: 8px; background: var(--sunken); color: var(--ink); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.cbadge:hover { filter: brightness(0.96); }
.avatar { display: inline-grid; place-items: center; width: 24px; height: 24px; margin: 0 2px; border: 0; border-radius: 50%; background: var(--ink); color: var(--surface); font: inherit; font-size: 10.5px; font-weight: 700; cursor: pointer; }
.ms { color: #d9930d; display: inline-flex; align-self: center; }
.iconbtn.ms { color: #d9930d; }
.item--child { padding-left: 46px; background: var(--sunken); }
.item--child .item__title::before { content: ""; width: 10px; height: 10px; border-left: 2px solid var(--faint); border-bottom: 2px solid var(--faint); border-radius: 0 0 0 4px; align-self: center; margin-right: 2px; }
.imenu { position: relative; display: inline-block; }
.imenu__list { position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; width: 250px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.16); }
.imenu__list .mi { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 12px; border: 0; border-radius: 8px; background: none; color: var(--ink); font: inherit; font-size: 14px; text-align: left; cursor: pointer; }
.imenu__list .mi:hover, .imenu__list .mi:focus-visible { background: var(--sunken); }
.imenu__list .mi svg { flex: none; color: var(--muted); }
.imenu__list .mi--danger, .imenu__list .mi--danger svg { color: var(--red); }
.imenu__list hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.imenu__lbl { padding: 4px 12px; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.imenu__omit { justify-content: space-between; }
.imenu__circles { display: flex; justify-content: space-around; padding: 4px 8px 6px; }
.imenu__circles .iconbtn { width: 36px; height: 36px; }
.imenu__circles .iconbtn.on { background: var(--sunken); color: var(--ink); box-shadow: inset 0 0 0 2px var(--line); }

/* ---- status circle (replaces the status dropdown) ---- */
.item > .item__status { width: 34px; height: 34px; justify-self: start; color: var(--muted); }
.item > .item__status.is-done { color: var(--green, #2f7d4f); }

/* ---- date under the title, roomier row menu ---- */
.item { grid-template-columns: 34px minmax(0, 1fr) auto; }
.item__main .item__due { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.item__main .item__due input { width: 150px; min-height: 32px; }
.item__main .item__due small { display: inline; margin: 0; }
.ibar { gap: 4px; }
.ibar .iconbtn { width: 34px; height: 34px; }
.imenu__list { width: 300px; padding: 8px; }
.imenu__list .mi { gap: 14px; padding: 12px 14px; font-size: 15px; }
.imenu__list .mi svg { width: 20px; height: 20px; }
.imenu__lbl { padding: 6px 14px; font-size: 13px; }
.imenu__circles { padding: 6px 10px 10px; }
.imenu__circles .iconbtn { width: 44px; height: 44px; }
.imenu__circles .iconbtn svg { width: 26px; height: 26px; }
@media (max-width: 760px) {
  .item { grid-template-columns: 34px minmax(0, 1fr); }
  .item > .item__status { grid-column: 1; grid-row: 1; }
  .item > .item__main { grid-column: 2; grid-row: 1; }
  .item > .item__more { grid-column: 2; grid-row: 2; justify-content: flex-start; }
  .imenu__list { right: auto; left: 0; max-width: calc(100vw - 48px); }
}

/* ---- every action visible on the row ---- */
.item__more.ibar { flex-wrap: wrap; max-width: 330px; justify-content: flex-end; align-self: start; gap: 2px; }
.ibar .iconbtn { width: 32px; height: 32px; color: var(--muted); }
.ibar .iconbtn:hover { color: var(--ink); background: var(--sunken); }
.ibar .iconbtn.on { color: var(--ink); background: var(--sunken); box-shadow: inset 0 0 0 2px var(--line); }
.ibar .iconbtn.is-off { color: var(--faint); }
.ibar .iconbtn.ms { color: #d9930d; }
.ibar .iconbtn.danger, .ibar .iconbtn.danger:hover { color: var(--red); }
@media (max-width: 760px) { .item__more.ibar { max-width: none; justify-content: flex-start; } }

/* ---- omitted tasks: red icon, crossed out, listed under Done ---- */
.ibar .iconbtn.omitted, .ibar .iconbtn.omitted:hover { color: var(--red); background: color-mix(in srgb, var(--red) 12%, transparent); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--red) 40%, transparent); }
.item > .item__status.is-omitted { color: var(--red); }
.item.b-na .item__title > span:first-child { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--red); text-decoration-thickness: 2px; }

/* document rows: uploads and counts */
.ibar__upload { position: relative; display: inline-flex; }
.ibar__count { position: absolute; top: -2px; right: -2px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--ink); color: var(--paper, #fff); font-size: 11px; line-height: 16px; text-align: center; pointer-events: none; }
.uplist { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.uplist li { display: inline-flex; align-items: center; gap: 6px; padding: 2px 4px 2px 10px; border-radius: 999px; background: var(--sunken); font-size: 13px; max-width: 100%; }
.uplist__name { background: none; border: 0; padding: 4px 0; font: inherit; color: var(--ink); text-decoration: underline; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 240px; }
.uplist__x { background: none; border: 0; width: 24px; height: 24px; border-radius: 50%; color: var(--muted); cursor: pointer; display: inline-grid; place-items: center; }
.uplist__x:hover { color: var(--red); background: color-mix(in srgb, var(--red) 12%, transparent); }

/* signature tracking pills under a document title */
.sigrow { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.sigpill { min-width: 34px; height: 26px; padding: 0 10px; border: 0; border-radius: 999px; font: inherit; font-size: 12.5px; font-weight: 700; cursor: pointer; }
.sigpill.is-missing { background: #f8d7de; color: #9b1c3a; }
.sigpill.is-signed { background: #d6efd8; color: #1d6b32; }
.sigpill:hover { filter: brightness(0.96); }
.sigpill:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.sigrow__sep { display: none; }
.sigrow__label { font-size: 13px; color: var(--muted); }
.sigrow__label.is-full { color: #1d6b32; font-weight: 600; }
@media (prefers-color-scheme: dark) { .sigpill.is-missing { background: #5a2330; color: #ffc9d4; } .sigpill.is-signed { background: #1f4a2a; color: #bfe9c6; } .sigrow__label.is-full { color: #8fd7a0; } }

/* required documents: red icon. conditional documents: yellow icon */
.ibar .iconbtn[aria-label^="Required:"], .ibar .iconbtn[aria-label^="Required:"]:hover { color: var(--red); background: color-mix(in srgb, var(--red) 12%, transparent); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--red) 40%, transparent); }
.ibar .iconbtn[aria-label^="Conditional ("], .ibar .iconbtn[aria-label^="Conditional ("]:hover { color: #b7791f; background: color-mix(in srgb, #f2b705 22%, transparent); box-shadow: inset 0 0 0 2px color-mix(in srgb, #f2b705 60%, transparent); }
@media (prefers-color-scheme: dark) { .ibar .iconbtn[aria-label^="Conditional ("], .ibar .iconbtn[aria-label^="Conditional ("]:hover { color: #f2c94c; } }

/* no box frame around row icons: the color alone shows the state */
.ibar .iconbtn.on, .ibar .iconbtn.omitted, .ibar .iconbtn.omitted:hover,
.ibar .iconbtn[aria-label^="Required:"], .ibar .iconbtn[aria-label^="Required:"]:hover,
.ibar .iconbtn[aria-label^="Conditional ("], .ibar .iconbtn[aria-label^="Conditional ("]:hover { background: transparent; box-shadow: none; }
.ibar .iconbtn.on:hover { background: var(--sunken); }

/* out for signature: orange when selected */
.ibar .iconbtn.on[aria-label^="Out for signature:"], .ibar .iconbtn.on[aria-label^="Out for signature:"]:hover { color: #e8710a; }

/* document form code (RPA, AD...) shows before the title; visual order only, so strike-through still lands on the title */
.item__title > .ms { order: -2; }
.item__title > .tag--code { order: -1; }
.item__title::before { order: -3; }

/* contract dates list on the Dates tab */
.cdates__list { display: grid; gap: 4px; }
.cdates__row { display: grid; grid-template-columns: minmax(0, 1fr) 170px 70px; gap: 12px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.cdates__row:first-child { border-top: 0; }
@media (max-width: 640px) { .cdates__row { grid-template-columns: minmax(0, 1fr) 150px; } .cdates__row > span:last-child { display: none; } }

/* ---------- email signatures ---------- */
.sigs { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 18px; align-items: start; }
.siglist { display: flex; flex-direction: column; gap: 6px; }
.siglist .sigrow { display: flex; flex-direction: column; gap: 2px; text-align: left; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); font: inherit; color: inherit; cursor: pointer; }
.siglist .sigrow:hover { background: var(--sunken); }
.siglist .sigrow[aria-current="true"] { border-color: var(--blue); box-shadow: inset 3px 0 0 var(--blue); }
.siglist .sigrow b { font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
.siglist .sigrow small { color: var(--muted); font-size: 12px; }
.sigbadge { display: inline-block; padding: 1px 7px; border-radius: 6px; background: var(--green-wash); color: var(--green); font-size: 11px; font-weight: 600; }
.sigedit { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.sigarea { min-height: 150px; padding: 14px; background: #fff; color: #222; font: 14px/1.4 Arial, Helvetica, sans-serif; outline: none; overflow-wrap: anywhere; }
.sigarea img { max-width: 100%; cursor: pointer; }
.sigarea img.is-sel { outline: 2px solid var(--blue); outline-offset: 2px; }
.sigarea a { color: #1155cc; text-decoration: underline; }
.sigimg { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--sunken); }
.sigimg .field { min-width: 120px; }
.sigacts { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sigacts .grow { flex: 1; }
.signote { font-size: 12.5px; color: var(--muted); margin: 0; }
.sigframe { border: 1px solid var(--line); border-radius: 8px; background: #fff; display: block; }
.sigtabs { display: flex; gap: 6px; margin-bottom: 10px; }
.sigtabs button[aria-pressed="true"] { background: var(--blue-wash); border-color: var(--blue); }
.sigtext { white-space: pre-wrap; font: 13px/1.5 ui-monospace, Menlo, monospace; padding: 12px; background: var(--sunken); border-radius: 8px; max-width: 640px; }
.sigerr { color: var(--red); font-size: 13px; margin: 0; }
@media (max-width: 760px) { .sigs { grid-template-columns: 1fr; } }

/* ---------- wider workspace: use more of the screen ---------- */
@media (min-width: 761px) {
  .page { max-width: 1760px !important; padding-left: 28px; padding-right: 28px; }
  .page:has(#mp-signatures) { max-width: 1240px !important; }
}

/* ---- task and document rows: a few labeled buttons, the rest under "More" ---- */
.item__more.rbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: flex-end; align-self: start; max-width: 440px; }
.rbtn, .rpill { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font: inherit; font-size: 13px; line-height: 1; cursor: pointer; white-space: nowrap; }
.rbtn:hover, .rpill:hover { background: var(--sunken); }
.rbtn.on { box-shadow: inset 0 0 0 1.5px var(--line); background: var(--sunken); }
.rpill { color: var(--muted); }
.rpill__state { font-size: 11.5px; font-weight: 700; padding: 1px 6px; border-radius: 999px; background: var(--sunken); color: var(--faint); }
.rpill.on[data-icon="agent"] { color: var(--steel); border-color: color-mix(in srgb, var(--steel) 55%, transparent); background: color-mix(in srgb, var(--steel) 12%, transparent); }
.rpill.on[data-icon="client"] { color: var(--green); border-color: color-mix(in srgb, var(--green) 55%, transparent); background: color-mix(in srgb, var(--green) 12%, transparent); }
.rpill.on .rpill__state { background: color-mix(in srgb, currentColor 18%, transparent); color: inherit; }
.rmenu__list { min-width: 300px; }
.rmenu__list button { display: flex; flex-direction: column; align-items: flex-start; }
.rmenu__row { display: flex; gap: 8px; align-items: baseline; }
.rmenu__tick { width: 14px; font-weight: 700; color: var(--green); }
.rmenu__list button.is-danger { color: var(--red); }
.rmenu__list small { margin-left: 22px; }
@media (max-width: 760px) { .item__more.rbar { justify-content: flex-start; max-width: none; } .rmenu__list { left: 0; right: auto; max-width: calc(100vw - 48px); } }
/* the buttons sit on their own line under the task, so the task name keeps its width */
@media (min-width: 761px) {
  .item { grid-template-columns: 34px minmax(0, 1fr); }
  .item > .item__status { grid-column: 1; grid-row: 1; }
  .item > .item__main { grid-column: 2; grid-row: 1; }
  .item > .item__more.rbar { grid-column: 2; grid-row: 2; justify-content: flex-start; max-width: none; align-self: center; }
}
.rmenu__list { left: 0; right: auto; }

/* contract date rows use the same buttons as task rows */
.cdates__icons.rbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: flex-end; }
.rbtn:disabled { opacity: .45; cursor: not-allowed; }
.cdates__icons .rmenu__list { left: auto; right: 0; }
