/* Approvals in the alert bell (approvals.js). Every class starts with ap-; colors are the app's own tokens, so light
   and dark follow Settings > Appearance. The review window sits above the app's own popups. */

/* ---- the bell section ---- */
.ap-sec { display: flex; flex-direction: column; gap: 8px; padding-bottom: 12px; margin-bottom: 2px; border-bottom: 1px solid var(--line); }
.ap-sec-h { margin: 0 0 2px; font-size: 12.5px; font-weight: 600; color: var(--muted); letter-spacing: .01em; }
.ap-card { border-left: 3px solid var(--text); }
.ap-card .card-row { padding-left: 2px; }
.ap-ico { flex: none; display: grid; place-items: center; color: var(--text); }
.ap-pill { flex: none; padding: 1px 8px; border: 1px solid var(--line-strong); border-radius: 999px; font-size: 11px; font-weight: 600; color: var(--text-2); white-space: nowrap; }
.ap-pill-edit { border-color: transparent; background: var(--amber-bg); color: var(--amber); }
.ap-card .btn.small { flex: none; }

/* ---- the review window: a desk with the document on it ---- */
.pop-backdrop.ap-backdrop { z-index: 70; padding-top: 32px; }
.pop.ap-review { width: min(920px, 100%); max-height: calc(100vh - 48px); }
.ap-head-text { min-width: 0; margin-right: auto; }
.ap-head-text h2 { margin: 0; font-size: 17px; }
.ap-meta { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.ap-body { gap: 12px; padding: 16px 20px 24px; background: var(--bg); }
.ap-error { margin: 0; padding: 9px 11px; border-radius: 6px; background: #FEF3F2; color: #B42318; font-size: 13px; }
.ap-hint { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.ap-body > .ap-hint { max-width: 820px; width: 100%; margin: 0 auto; }

/* the page itself */
.ap-paper { width: 100%; max-width: 820px; margin: 0 auto; padding: 36px 40px 34px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 4px; box-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px -12px rgba(16, 24, 40, .18); color: var(--text); font-size: 14px; }
.ap-ph { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; padding-bottom: 22px; border-bottom: 2px solid var(--text); }
.ap-from { display: flex; align-items: flex-start; gap: 12px; min-width: 0; }
.ap-logo { display: block; max-height: 44px; max-width: 120px; width: auto; object-fit: contain; flex: none; }
.ap-mark { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 4px; background: var(--text); color: var(--surface);
  font-size: 13px; font-weight: 700; letter-spacing: .02em; }
.ap-from-t { display: flex; flex-direction: column; min-width: 0; }
.ap-co { font-size: 15px; }
.ap-co-addr { font-size: 12.5px; color: var(--muted); white-space: pre-line; }
.ap-docid { text-align: right; flex: none; max-width: 55%; }
.ap-doc-kind { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; line-height: 1.15; }
.ap-doc-title { margin-top: 2px; font-size: 13px; color: var(--text-2); }
.ap-dl { display: grid; grid-template-columns: auto auto; justify-content: end; gap: 3px 12px; margin: 10px 0 0; font-size: 12.5px; }
.ap-dl dt { color: var(--muted); }
.ap-dl dd { margin: 0; display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.ap-dim { color: var(--muted); }
.ap-st { padding: 0 7px; border-radius: 3px; font-size: 11.5px; font-weight: 600; line-height: 19px; }
.ap-st-draft { background: var(--amber-bg); color: var(--amber); }
.ap-st-ok { background: var(--green-bg); color: var(--green); }
.ap-st-no { background: #FEF3F2; color: #B42318; }
.ap-st-off { background: var(--subtle); color: var(--text-2); border: 1px solid var(--line); line-height: 17px; }

.ap-lbl { margin-bottom: 3px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.ap-parties { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px 36px; padding: 22px 0 4px; }
.ap-party .ap-x, .ap-party .ap-ro { font-size: 15px; }
.ap-party:first-child .ap-sel, .ap-party:first-child > .ap-ro { font-weight: 600; }
.ap-details { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px 28px; padding: 18px 0 2px; }
.ap-parties + .ap-details { margin-top: 14px; border-top: 1px solid var(--line); }
.ap-notes { display: flex; flex-direction: column; gap: 14px; margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line); }

/* a value: reads as document text, edits in place */
.ap-ro { display: inline-block; min-height: 26px; padding: 3px 0; overflow-wrap: anywhere; }
.ap-pre { white-space: pre-line; }
.ap-x { display: block; width: 100%; min-height: 30px; margin: 0 0 0 -7px; width: calc(100% + 14px); padding: 4px 6px; border: 1px solid transparent; border-radius: 3px;
  background: transparent; font: inherit; color: inherit; line-height: 1.4;
  background-image: linear-gradient(to right, var(--line-strong) 55%, transparent 0); background-size: 5px 1px; background-repeat: repeat-x;
  background-position: 6px calc(100% - 3px); transition: background-color 120ms ease-out, border-color 120ms ease-out; }
.ap-x:hover { background-color: var(--subtle); border-color: var(--line); background-image: none; }
.ap-x:focus { outline: none; background-color: var(--surface); background-image: none; border-color: var(--text); box-shadow: 0 0 0 3px rgba(16, 24, 40, .1); }
.ap-x[disabled] { opacity: .7; }
.ap-x[aria-invalid="true"] { border-color: #F04438; background-image: none; background-color: #FEF3F2; }
.ap-ta { resize: none; overflow: hidden; }
.ap-sel { appearance: none; -webkit-appearance: none; padding-right: 26px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2398A2B3' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-size: 12px 12px; background-position: right 8px center; background-repeat: no-repeat; }
.ap-sel:hover, .ap-sel:focus { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }
.ap-n { font-variant-numeric: tabular-nums; }
.ap-money { position: relative; display: flex; align-items: center; }
.ap-money .ap-cur { position: absolute; left: 0; color: var(--muted); pointer-events: none; z-index: 1; }
.ap-money .ap-x { padding-left: 16px; }
.ap-with-unit { display: flex; align-items: center; gap: 4px; }
.ap-with-unit .ap-x { width: auto; flex: 1 1 auto; min-width: 0; }
.ap-unit { flex: none; font-size: 13px; color: var(--muted); }
/* changed from the draft */
.ap-chg.ap-x, .ap-chg .ap-x { background-color: #FEF0C7; background-image: none; box-shadow: inset 0 -2px 0 #F79009; }
.ap-chg.ap-x:focus, .ap-chg .ap-x:focus { background-color: var(--surface); box-shadow: 0 0 0 3px rgba(16, 24, 40, .1); }
.ap-locked { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); }
.ap-locked svg { color: var(--faint); flex: none; }
.ap-was-chg { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ap-changed { margin-left: 6px; padding: 0 6px; border-radius: 3px; background: var(--amber-bg); color: var(--amber); font-size: 11px; font-weight: 600; vertical-align: 1px; }

/* the lines */
.ap-lines { margin-top: 26px; }
.ap-ln { display: grid; grid-template-columns: minmax(0, 1fr) 76px 76px 118px 112px 30px; gap: 0 10px; align-items: center; min-height: 42px;
  padding: 3px 0; border-bottom: 1px solid var(--line); }
.ap-lh { min-height: 0; padding: 0 0 7px; border-bottom: 1px solid var(--line-strong); font-size: 11px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted); }
.ap-c-qty, .ap-c-price, .ap-c-amt { text-align: right; }
.ap-c-qty .ap-x, .ap-c-price .ap-x { text-align: right; margin: 0 -7px 0 0; }
.ap-c-desc .ap-x, .ap-c-unit .ap-x { margin-left: -7px; }
.ap-c-price .ap-money .ap-cur { left: 6px; }
.ap-c-price .ap-money .ap-x { padding-left: 18px; }
.ap-c-amt { font-variant-numeric: tabular-nums; font-weight: 500; }
.ap-c-rm { display: flex; justify-content: flex-end; }
.ap-ln-new { box-shadow: inset 3px 0 0 #F79009; }
.ap-ln-new .ap-c-desc { padding-left: 8px; }
.ap-rm { display: grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 3px; background: none; color: var(--faint); cursor: pointer; opacity: .55; }
.ap-ln:hover .ap-rm, .ap-rm:focus-visible { opacity: 1; }
.ap-rm:hover { background: #FEF3F2; color: #B42318; }
.ap-rm[disabled] { opacity: .25; cursor: default; background: none; color: var(--faint); }
.ap-add { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; min-height: 32px; padding: 0 11px; border: 1px dashed var(--line-strong);
  border-radius: 3px; background: none; font: inherit; font-size: 13px; font-weight: 500; color: var(--text-2); cursor: pointer; }
.ap-add:hover { border-style: solid; background: var(--subtle); color: var(--text); }
.ap-add[disabled] { opacity: .5; cursor: default; }

/* the totals */
.ap-totals { width: min(330px, 100%); margin: 18px 0 0 auto; display: flex; flex-direction: column; }
.ap-tr { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 34px; font-size: 13.5px; color: var(--text-2); }
.ap-tv { text-align: right; font-variant-numeric: tabular-nums; color: var(--text); font-weight: 500; }
.ap-tv .ap-money { width: 130px; margin-left: auto; }
.ap-tv .ap-money .ap-x { text-align: right; margin: 0 -7px 0 0; }
.ap-tv .ap-money .ap-cur { left: 8px; }
.ap-grand { margin-top: 6px; padding-top: 8px; border-top: 2px solid var(--text); color: var(--text); font-weight: 700; font-size: 15px; }
.ap-total-v { font-size: 18px; font-weight: 700; }

/* the footer */
.ap-foot { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--surface); }
.ap-foot [hidden] { display: none !important; }
.ap-grow { flex: 1 1 auto; }
.ap-foot .btn { flex: none; }
.ap-foot .btn svg { margin-left: -2px; }
.ap-foot .ap-note { flex: 1 1 auto; min-width: 0; }
.ap-foot-note { margin-right: auto; font-size: 13px; color: var(--muted); }
.ap-foot-status { min-width: 0; font-size: 13px; color: var(--muted); text-align: right; }
.ap-foot-status.ap-bad { color: #B42318; font-weight: 500; }
.ap-in { width: 100%; min-height: 34px; padding: 6px 9px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface);
  font: inherit; font-size: 14px; color: var(--text); }
.ap-in:hover { border-color: var(--muted); }
.ap-in:focus { outline: none; border-color: var(--text); box-shadow: 0 0 0 3px rgba(16, 24, 40, .1); }

[data-theme="dark"] .ap-error, [data-theme="dark"] .ap-st-no, [data-theme="dark"] .ap-rm:hover,
[data-theme="dark"] .ap-x[aria-invalid="true"] { background: #55160C; color: #FDA29B; }
[data-theme="dark"] .ap-foot-status.ap-bad { color: #FDA29B; }
[data-theme="dark"] .ap-x:focus, [data-theme="dark"] .ap-in:focus { border-color: #84ADFF; box-shadow: 0 0 0 3px rgba(132, 173, 255, .18); }
[data-theme="dark"] .ap-mark { background: var(--text); color: var(--bg); }
[data-theme="dark"] .ap-chg.ap-x, [data-theme="dark"] .ap-chg .ap-x { background-color: rgba(247, 144, 9, .16); box-shadow: inset 0 -2px 0 #FDB022; }
[data-theme="dark"] .ap-chg.ap-x:focus, [data-theme="dark"] .ap-chg .ap-x:focus { background-color: var(--surface); box-shadow: 0 0 0 3px rgba(132, 173, 255, .18); }

@media (max-width: 720px) {
  .pop-backdrop.ap-backdrop { padding: 8px; }
  .pop.ap-review { max-height: calc(100vh - 16px); }
  .ap-body { padding: 12px 10px 18px; }
  .ap-paper { padding: 22px 18px 24px; }
  .ap-ph { flex-direction: column; gap: 14px; }
  .ap-docid { text-align: left; max-width: none; }
  .ap-dl { justify-content: start; }
  .ap-dl dd { justify-content: flex-start; }
  .ap-lh { display: none; }
  .ap-ln { grid-template-columns: 1fr 1fr 1fr 30px; grid-template-areas: "desc desc desc rm" "qty unit price price" "amt amt amt amt"; gap: 2px 10px; padding: 8px 0; }
  .ap-c-desc { grid-area: desc; } .ap-c-qty { grid-area: qty; } .ap-c-unit { grid-area: unit; } .ap-c-price { grid-area: price; }
  .ap-c-amt { grid-area: amt; } .ap-c-rm { grid-area: rm; }
  .ap-c-qty, .ap-c-price { text-align: left; }
  .ap-c-qty .ap-x, .ap-c-price .ap-x { text-align: left; margin: 0 0 0 -7px; }
  .ap-card .card-row { flex-wrap: wrap; }
  .ap-foot { flex-wrap: wrap; }
  .ap-foot-status { flex-basis: 100%; order: -1; text-align: left; }
}
