/* ============================================================
   PASSAGE by Khoshà — Documents & signing (staff view)

   Scoped to .dt-* so it cannot reach into any other module's
   markup. Tokens come from styles.css (--paper --bone --ink --gold
   --green --red, Bricolage Grotesque + Hanken Grotesk); nothing here
   redefines a colour.

   The PUBLIC signing page does NOT use this file — it is
   server-rendered with its own inline, nonce'd stylesheet in
   server/routes-doctemplates.js, because it must load standalone on a
   worker's phone with no app shell around it.
   ============================================================ */

.dt-wrap { display: flex; flex-direction: column; gap: 18px; }

.dt-back {
  align-self: flex-start; font-size: 13px; font-weight: 600; color: var(--ink-soft);
  padding: 6px 0; cursor: pointer;
}
.dt-back:hover { color: var(--gold-deep); }

.dt-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}
.dt-h1 { font-family: var(--disp); font-weight: 800; font-size: 26px; letter-spacing: -.01em; line-height: 1.15; }
.dt-lede { color: var(--ink-soft); font-size: 13.5px; margin-top: 5px; max-width: 62ch; }

/* ---------- tabs ---------- */
.dt-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.dt-tab {
  background: rgba(255,255,255,.5); border: 1px solid var(--stroke-soft); border-radius: 99px;
  padding: 8px 16px; font-size: 13px; font-weight: 600; color: var(--ink-soft);
  display: flex; align-items: center; gap: 7px; min-height: 40px;
}
.dt-tab span {
  background: var(--bone-2); border-radius: 99px; padding: 1px 8px;
  font-size: 11px; font-weight: 700; color: var(--ink-soft);
}
.dt-tab.on { background: var(--green); border-color: var(--green); color: var(--paper); }
.dt-tab.on span { background: rgba(255,255,255,.2); color: var(--paper); }

/* ---------- list ---------- */
.dt-list { display: flex; flex-direction: column; gap: 8px; }
.dt-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  background: rgba(255,255,255,.55); border: 1px solid var(--stroke-soft);
  border-radius: var(--r-md); padding: 14px 18px; cursor: pointer;
  transition: border-color .2s, transform .2s, box-shadow .2s;
}
.dt-row:hover { border-color: var(--gold); transform: translateY(-1px); box-shadow: var(--shadow-soft); }
.dt-row-main { min-width: 0; }
.dt-row-title { font-weight: 600; font-size: 15px; line-height: 1.3; }
.dt-row-sub { color: var(--ink-faint); font-size: 12.5px; margin-top: 3px; }

.dt-empty { text-align: center; padding: 34px 22px; }
.dt-empty-t { font-family: var(--disp); font-weight: 700; font-size: 17px; margin-bottom: 6px; }
.dt-empty-b { color: var(--ink-soft); font-size: 13.5px; max-width: 52ch; margin: 0 auto 14px; line-height: 1.6; }

/* ---------- status pills ---------- */
.dt-pill {
  font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  padding: 4px 11px; border-radius: 99px; white-space: nowrap;
}
.dt-pill.dt-big { font-size: 12px; padding: 6px 15px; }
.dt-p-grey  { background: var(--bone-2); color: var(--ink-soft); }
.dt-p-gold  { background: rgba(169,130,76,.16); color: var(--gold-deep); }
.dt-p-green { background: rgba(30,58,51,.13); color: var(--green); }
.dt-p-red   { background: rgba(140,59,46,.13); color: var(--red); }

/* ---------- detail ---------- */
.dt-toolbar { display: flex; gap: 8px; flex-wrap: wrap; }
.dt-toolbar .btn { min-height: 42px; }
.dt-danger { color: var(--red); border-color: rgba(140,59,46,.4) !important; }

.dt-frozen {
  border-left: 3px solid var(--gold); color: var(--ink-soft);
  font-size: 13.5px; line-height: 1.6;
}

.dt-cols { display: grid; grid-template-columns: 1fr; gap: 16px; }
.dt-col-main, .dt-col-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.dt-sec + .dt-sec { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--stroke-soft); }
.dt-sec-t {
  font-family: var(--disp); font-weight: 700; font-size: 11.5px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--gold-deep); margin-bottom: 10px;
}
.dt-kv {
  display: flex; gap: 4px 14px; flex-wrap: wrap;
  padding: 7px 0; border-bottom: 1px solid var(--stroke-soft);
}
.dt-kv .k { flex: 1 1 100%; color: var(--ink-soft); font-size: 12.5px; }
.dt-kv .v { flex: 1 1 100%; font-weight: 600; font-size: 14px; word-break: break-word; }

.dt-signer-row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 11px 0; border-bottom: 1px solid var(--stroke-soft);
}
.dt-signer-row:last-child { border-bottom: none; }
.dt-signer-name { font-weight: 600; font-size: 14px; }
.dt-signer-sub { color: var(--ink-faint); font-size: 12px; margin-top: 2px; word-break: break-word; }
.dt-signer-act { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.dt-mini {
  background: none; border: 1px solid var(--stroke); border-radius: 99px;
  padding: 5px 12px; font-size: 11.5px; font-weight: 600; color: var(--ink-soft); min-height: 32px;
}
.dt-mini:hover { border-color: var(--gold); color: var(--gold-deep); }

.dt-aud { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.dt-aud th {
  text-align: left; color: var(--ink-faint); font-weight: 600; font-size: 10px;
  letter-spacing: .08em; text-transform: uppercase; padding: 3px 8px 5px 0;
  border-bottom: 1px solid var(--stroke-soft);
}
.dt-aud td { padding: 5px 8px 5px 0; border-bottom: 1px solid var(--stroke-soft); color: var(--ink-soft); vertical-align: top; }
.dt-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }

/* ---------- wizard (inside .m-card) ---------- */
.dt-mhead { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.dt-x {
  background: none; border: none; font-size: 24px; line-height: 1; color: var(--ink-faint);
  padding: 4px 8px; min-height: 40px; min-width: 40px;
}
.dt-x:hover { color: var(--ink); }

.dt-modal { display: flex; flex-direction: column; gap: 4px; }

.dt-steps { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.dt-steps span {
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-faint); background: var(--bone); border-radius: 99px; padding: 5px 12px;
}
.dt-steps span.on { background: var(--green); color: var(--paper); }
.dt-steps span.done { background: rgba(169,130,76,.18); color: var(--gold-deep); }

.dt-tpl-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.dt-tpl {
  text-align: left; background: rgba(255,255,255,.6); border: 1px solid var(--stroke-soft);
  border-radius: var(--r-md); padding: 15px 17px; transition: border-color .2s, transform .2s;
}
.dt-tpl:hover { border-color: var(--gold); transform: translateY(-1px); }
.dt-tpl-name { font-family: var(--disp); font-weight: 700; font-size: 15.5px; margin-bottom: 4px; }
.dt-tpl-desc { color: var(--ink-soft); font-size: 13px; line-height: 1.5; }
.dt-tpl-meta { color: var(--ink-faint); font-size: 11.5px; margin-top: 7px; letter-spacing: .04em; }

.dt-lbl {
  display: block; font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-faint); font-weight: 600; margin: 12px 0 5px;
}
.dt-req { color: var(--red); font-weight: 700; letter-spacing: .06em; }
.dt-from { color: var(--gold-deep); font-weight: 600; text-transform: none; letter-spacing: 0; font-size: 10.5px; }
.dt-in {
  width: 100%; border: 1px solid var(--stroke); border-radius: 12px; padding: 11px 13px;
  background: #fff; outline: 0; font-size: 16px; min-height: 46px;
  transition: border-color .2s, box-shadow .2s;
}
.dt-in:focus { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(169,130,76,.10); }
textarea.dt-in { resize: vertical; min-height: 78px; line-height: 1.5; }
.dt-help { color: var(--ink-faint); font-size: 11.5px; margin-top: 4px; line-height: 1.5; }
.dt-two { display: grid; grid-template-columns: 1fr; gap: 0 12px; }

.dt-prefill {
  background: rgba(169,130,76,.10); border: 1px solid rgba(169,130,76,.3);
  border-radius: var(--r-sm); padding: 11px 14px; font-size: 13.5px; margin-bottom: 6px;
}

.dt-signer { display: grid; grid-template-columns: 1fr; gap: 6px; margin-bottom: 12px; }
.dt-signer-role {
  font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--gold-deep);
}

.dt-actions {
  display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap;
  margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--stroke-soft);
}
.dt-actions .btn { min-height: 46px; }

.dt-err {
  background: rgba(140,59,46,.10); border: 1px solid rgba(140,59,46,.35); color: var(--red);
  border-radius: var(--r-sm); padding: 10px 13px; font-size: 13px; margin-top: 12px;
}
.dt-verdict {
  border-radius: var(--r-sm); padding: 12px 15px; font-weight: 600; font-size: 14.5px; margin-bottom: 12px;
}
.dt-verdict.ok  { background: rgba(30,58,51,.10); border: 1px solid rgba(30,58,51,.3); color: var(--green); }
.dt-verdict.bad { background: rgba(140,59,46,.12); border: 1px solid rgba(140,59,46,.4); color: var(--red); }

/* ---------- wider screens ---------- */
@media (min-width: 720px) {
  .dt-two { grid-template-columns: 1fr 1fr; }
  .dt-tpl-grid { grid-template-columns: 1fr 1fr; }
  .dt-signer { grid-template-columns: 130px 1fr 1fr; align-items: center; gap: 10px; }
  .dt-signer-role { margin: 0; }
  .dt-kv .k { flex: 0 0 42%; }
  .dt-kv .v { flex: 1 1 auto; }
}
@media (min-width: 1100px) {
  .dt-cols { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); align-items: start; }
}

/* ============================================================
   UPLOADED AGREEMENTS — .dtu-*

   The firm's own retainer, converted from a Word file, and the
   screen where they point at their own blanks and say what each one
   is. Scoped to .dtu-* so it cannot reach the envelope views above.

   Mobile-first, like the rest of this file: everything below is the
   390px layout and the media queries only widen it. The one thing
   that must never move is the document column — a converted
   agreement has a fee table in it, and that table scrolls INSIDE
   its own wrapper rather than pushing the page sideways.
   ============================================================ */

/* ---------- the drop / choose-a-file panel ---------- */
.dtu-drop {
  border: 1.5px dashed var(--stroke-soft); border-radius: var(--r-md);
  background: rgba(255,255,255,.45); padding: 22px 16px; text-align: center;
}
.dtu-drop-in { max-width: 52ch; margin: 0 auto; }
.dtu-drop svg { width: 30px; height: 30px; color: var(--gold-deep); margin-bottom: 8px; }
.dtu-drop-t { font-family: var(--disp); font-weight: 700; font-size: 17px; margin-bottom: 5px; }
.dtu-drop-b { color: var(--ink-soft); font-size: 13.5px; line-height: 1.6; margin-bottom: 14px; }
/* The real <input type=file> is inside the label and visually gone, so the
   control the firm sees is the house button rather than the browser's. */
.dtu-file { position: relative; overflow: hidden; display: inline-flex; min-height: 46px;
            align-items: center; justify-content: center; cursor: pointer; }
.dtu-file input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }
.dtu-uperr { text-align: left; }

/* ---------- the template manager ---------- */
.dtu-group { display: flex; flex-direction: column; gap: 10px; }
.dtu-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.dtu-card {
  background: var(--paper); border: 1px solid var(--stroke-soft); border-radius: var(--r-md);
  padding: 14px 15px; display: flex; flex-direction: column; gap: 7px; min-width: 0;
}
.dtu-card.is-draft { border-left: 3px solid var(--gold); }
.dtu-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.dtu-card-name { font-weight: 600; font-size: 15px; line-height: 1.3; min-width: 0; }
.dtu-card-sub { color: var(--ink-soft); font-size: 13px; line-height: 1.5; }
.dtu-card-meta { color: var(--ink-faint); font-size: 12px; line-height: 1.5; }
.dtu-card-acts { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 3px; }
.dtu-go { border-color: var(--green) !important; color: var(--green) !important; font-weight: 700; }

/* ---------- the mapping screen ---------- */
.dtu-wrap { gap: 14px; }
.dtu-setup { padding: 15px 16px; }
.dtu-setup-row { display: grid; grid-template-columns: 1fr; gap: 12px; margin-bottom: 12px; }
.dtu-check {
  display: flex; align-items: flex-start; gap: 9px; font-size: 13.5px; line-height: 1.5;
  color: var(--ink); margin: 10px 0 6px; cursor: pointer;
}
.dtu-check input { width: 20px; height: 20px; flex: 0 0 20px; margin-top: 1px; accent-color: var(--green); }

.dtu-notes-toggle {
  align-self: flex-start; background: none; border: none; padding: 6px 0; min-height: 40px;
  font-size: 13px; font-weight: 700; color: var(--gold-deep); cursor: pointer;
}
.dtu-notes { padding: 14px 16px; }
.dtu-notes-list { margin: 8px 0 0 18px; color: var(--ink-soft); font-size: 13px; line-height: 1.65; }
.dtu-notes-list li { margin-bottom: 5px; }

.dtu-cols { display: grid; grid-template-columns: 1fr; gap: 14px; align-items: start; min-width: 0; }
.dtu-doc {
  padding: 18px 16px; max-width: 100%; min-width: 0; overflow-x: hidden;
  /* Serif-free but document-like: this is the firm's contract, being read
     as a contract, not a form. */
  font-size: 14px; line-height: 1.65;
}
.dtu-h { font-family: var(--disp); font-weight: 700; line-height: 1.3; margin: 18px 0 8px; }
.dtu-h:first-child { margin-top: 0; }
.dtu-h1 { font-size: 17px; }
.dtu-h2 { font-size: 15px; }
.dtu-h3 { font-size: 14px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .1em; }
.dtu-p { margin: 0 0 10px; }
.dtu-li { margin: 0 0 7px 18px; position: relative; }
.dtu-li::before { content: '•'; position: absolute; left: -14px; color: var(--gold); }
.dtu-li.lvl1 { margin-left: 32px; } .dtu-li.lvl2 { margin-left: 46px; }
.dtu-li.lvl3 { margin-left: 60px; } .dtu-li.lvl4 { margin-left: 74px; }

.dtu-tblwrap {
  width: 100%; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch;
  border: 1px solid var(--stroke-soft); border-radius: var(--r-sm);
  margin: 10px 0 14px; background: rgba(255,255,255,.5);
}
.dtu-tbl { border-collapse: collapse; font-size: 13px; min-width: 100%; }
.dtu-tbl th, .dtu-tbl td {
  padding: 8px 11px; border-bottom: 1px solid var(--stroke-soft); vertical-align: top; text-align: left;
}
.dtu-tbl th { background: var(--bone-2); font-weight: 700; white-space: nowrap; }
.dtu-tbl tr:last-child td { border-bottom: none; }

/* A blank the firm already wrote, waiting to be bound. */
mark.dtu-slot {
  background: rgba(169,130,76,.22); color: var(--gold-deep); font-weight: 700;
  border-radius: 4px; padding: 1px 5px; cursor: pointer; box-shadow: inset 0 -1.5px 0 var(--gold);
}
mark.dtu-slot:hover { background: rgba(169,130,76,.36); }
mark.dtu-legend { cursor: default; font-weight: 600; }
/* A blank that has been bound. The original words stay visible with the
   field's name beside them, so the firm can see WHAT they replaced. */
.dtu-bound {
  background: rgba(30,58,51,.12); border-radius: 4px; padding: 1px 5px; cursor: pointer;
  box-shadow: inset 0 -1.5px 0 var(--green); color: var(--green); font-weight: 700;
}
.dtu-bound:hover { background: rgba(30,58,51,.2); }
.dtu-bound i {
  font-style: normal; font-size: 10.5px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; background: var(--green); color: var(--paper);
  border-radius: 3px; padding: 1px 5px; margin-left: 6px; white-space: nowrap;
}

.dtu-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.dtu-side-card {
  background: var(--paper); border: 1px solid var(--stroke-soft); border-radius: var(--r-md); padding: 15px 16px;
}
.dtu-counts { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--ink-soft); margin: 10px 0; }
.dtu-counts b { color: var(--ink); font-size: 15px; }
.dtu-selbtn { width: 100%; min-height: 46px; margin-bottom: 4px; }
.dtu-selbtn:disabled { opacity: .5; }
.dtu-sample {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px;
  background: var(--bone-2); border-radius: var(--r-sm); padding: 9px 11px;
  margin: 4px 0 10px; word-break: break-word; color: var(--ink-soft);
}
.dtu-bound-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.dtu-bound-row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  padding: 9px 0; border-top: 1px solid var(--stroke-soft); flex-wrap: wrap;
}
.dtu-bound-lbl { font-weight: 600; font-size: 13.5px; }
.dtu-bound-sub { color: var(--ink-faint); font-size: 12px; margin-top: 2px; word-break: break-word; }
.dtu-bound-act { display: flex; gap: 6px; }
.dtu-bottom { position: sticky; bottom: 0; background: var(--bone); padding: 10px 0; z-index: 2; }

@media (min-width: 720px) {
  .dtu-grid { grid-template-columns: 1fr 1fr; }
  .dtu-setup-row { grid-template-columns: 1fr 260px; }
  .dtu-doc { padding: 26px 30px; }
}
@media (min-width: 1100px) {
  .dtu-cols { grid-template-columns: minmax(0, 1.5fr) minmax(0, 380px); }
  /* The binder follows you down a twelve-page retainer instead of sitting
     at the top of it. */
  .dtu-side { position: sticky; top: 14px; }
}
