/* The document (estimate → repair order → invoice) as an app, not a sheet of
   paper. One markup, four layouts: phone, 11" tablet portrait, tablets
   landscape, desk. Paper is for print. */
.docs-pane { padding: 0; border: 0; background: transparent; min-width: 0; }
.dc { display: flex; flex-direction: column; gap: 12px; min-width: 0; padding-bottom: 84px; }

/* Top strip: what this is, where it stands, the number that matters */
.dc-top { position: sticky; top: 0; z-index: 4; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); box-shadow: 0 6px 18px rgba(0,0,0,.25); }
.dc-kind { font-size: 17px; font-weight: 800; }
.dc-top-sub { display: flex; gap: 8px; align-items: center; margin-top: 2px; flex-wrap: wrap; }
.dc-saved { font-size: 12px; color: #5fd38e; }
.dc-saved.busy { color: #f6b955; }
.dc-top-total { text-align: right; }
.dc-top-total span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.dc-top-total strong { font-size: 22px; }
.dc-chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; background: rgba(100,116,139,.25); color: var(--text); border: 0; font-family: inherit; text-decoration: none; }
.dc-chip.ok { background: rgba(31,138,76,.25); color: #5fd38e; }
.dc-chip.todo { background: rgba(240,160,32,.22); color: #f6b955; }
.dc-chip.owing { background: rgba(226,86,59,.22); color: #ff9c8a; }
.dc-chip.link { background: rgba(47,111,179,.22); color: #8ab8ec; cursor: pointer; }
.dc-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }

/* Grid */
.dc-grid { display: grid; grid-template-columns: 1fr; gap: 12px; align-items: start; }
.dc-main, .dc-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.dc-two { display: grid; grid-template-columns: 1fr; gap: 12px; }

/* Cards */
.dc-card { background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.dc-card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.dc-card-head h2 { margin: 0; font-size: 12px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.dc-mini { border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 8px; padding: 4px 10px; font: inherit; font-size: 13px; min-height: 32px; }
.dc-strong { font-weight: 800; font-size: 16px; }
.dc-link { background: none; border: 0; padding: 0; color: #8ab8ec; text-decoration: underline; font: inherit; cursor: pointer; text-align: left; }
.dc-warn { color: #f6b955; font-size: 13px; }
.dc-internal { padding: 6px 8px; border-radius: 8px; background: rgba(240,160,32,.1); border-left: 3px solid #f0a020; font-size: 13px; }
.dc-empty { padding: 6px 0; }
.ro-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .04em; }

/* Jobs */
.dc-jobs { display: flex; flex-direction: column; gap: 10px; }
.dc-job { padding: 0; overflow: hidden; border-left: 5px solid #64748b; }
.dc-job.ok { border-left-color: #1f8a4c; }
.dc-job.todo { border-left-color: #f0a020; }
.dc-job.wait { border-left-color: #2f6fb3; }
.dc-job-head { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 14px 6px; background: none; border: 0; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.dc-jobno { flex: 0 0 auto; width: 24px; height: 24px; border-radius: 50%; background: var(--text); color: var(--bg); font-size: 12px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
.dc-job-title { flex: 1 1 auto; font-weight: 800; font-size: 15px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dc-job-ccc { font-weight: 400; font-size: 12.5px; color: var(--muted); }
.dc-job-amt { font-weight: 800; white-space: nowrap; }
.dc-status { margin: 0 14px; font-size: 12px; font-weight: 700; color: var(--muted); }
.dc-status.ok { color: #5fd38e; }
.dc-status.todo { color: #f6b955; }
.dc-status.wait { color: #8ab8ec; }
.dc-lines { display: flex; flex-direction: column; margin-top: 6px; border-top: 1px solid var(--line); }
.dc-line { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 14px; min-height: 52px; border: 0; border-bottom: 1px solid var(--line); background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.dc-line:disabled { cursor: default; opacity: .9; }
.dc-line:not(:disabled):active { background: rgba(255,255,255,.04); }
.dc-line-kind { flex: 0 0 56px; font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.dc-line-kind.k-labor { color: #8ab8ec; }
.dc-line-kind.k-part { color: #f6b955; }
.dc-line-kind.k-discount { color: #5fd38e; }
.dc-line-main { flex: 1 1 auto; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dc-line-desc { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dc-line-sub { font-size: 12.5px; color: var(--muted); }
.dc-line-amt { font-weight: 800; white-space: nowrap; }
.dc-addrow { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 14px 12px; }
.dc-addrow button { border: 1px dashed var(--line); background: var(--panel); color: var(--text); border-radius: 8px; padding: 8px 12px; min-height: 40px; font: inherit; font-weight: 700; font-size: 13px; }
.dc-addjob { min-height: 54px; border: 2px dashed var(--line); border-radius: 14px; background: transparent; color: var(--text); font: inherit; font-weight: 800; font-size: 15px; }

/* Totals, approval, invoice, record */
.dc-totals .dc-trow { display: flex; justify-content: space-between; padding: 3px 0; font-size: 14px; }
.dc-trow.strong { font-weight: 800; border-top: 1px solid var(--line); margin-top: 4px; padding-top: 6px; }
.dc-trow.big { font-size: 18px; font-weight: 800; }
.dc-trow.owing { color: #ff9c8a; }
.dc-trow.ok { color: #5fd38e; }
.dc-approve { border: 2px solid #f0a020; }
.dc-approve.additional { border-color: #e2563b; }
.dc-approve-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; }
.dc-invoice.owing { border-color: #e2563b; }
.dc-invoice.paid { border-color: #1f8a4c; }
.dc-rec { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.dc-rec:last-child { border-bottom: 0; }
.dc-library summary { cursor: pointer; font-weight: 700; }

/* Buttons */
.dc-btn { min-height: 46px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit; font-weight: 700; cursor: pointer; }
.dc-btn.primary { background: #1f6feb; border-color: #1f6feb; color: #fff; }
.dc-btn.danger { background: transparent; border-color: #e2563b; color: #ff9c8a; }
.dc-btn[disabled] { opacity: .45; cursor: default; }

/* Action bar (phone & tablet portrait: pinned above the app's bottom bar) */
.dc-bar { position: fixed; left: 8px; right: 8px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 6; display: flex; gap: 6px; overflow-x: auto; padding: 8px; border-radius: 14px; background: rgba(2,6,23,.96); border: 1px solid var(--line); box-shadow: 0 8px 24px rgba(0,0,0,.45); scrollbar-width: none; }
.dc-bar-btn { flex: 1 0 auto; min-height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit; font-weight: 800; white-space: nowrap; }
.dc-bar-btn.primary { background: #1f6feb; border-color: #1f6feb; color: #fff; }

/* Sheets: bottom sheet on phones, centred dialog on big screens */
.dc-sheet-wrap { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; }
.dc-sheet { width: 100%; max-height: 92vh; overflow-y: auto; background: var(--panel-2); border-radius: 18px 18px 0 0; padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; animation: dcUp .25s ease; }
@keyframes dcUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.dc-sheet-head { display: flex; justify-content: space-between; align-items: center; }
.dc-sheet-head h3 { margin: 0; font-size: 17px; }
.dc-x { border: 0; background: var(--panel); color: var(--text); width: 40px; height: 40px; border-radius: 50%; font-size: 16px; }
.dc-sheet-body { display: flex; flex-direction: column; gap: 10px; }
.dc-sheet-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; padding-top: 4px; }
.dc-sheet-actions .dc-btn.primary { flex: 1 1 140px; }
.dc-f { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); min-width: 0; }
.dc-f small { font-size: 11.5px; }
.dc-in { width: 100%; box-sizing: border-box; min-height: 46px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text); font: inherit; font-size: 16px; }
textarea.dc-in { min-height: 64px; resize: vertical; }
.dc-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dc-row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.dc-row-total { display: flex; justify-content: space-between; align-items: baseline; font-weight: 800; padding: 6px 0; border-top: 1px solid var(--line); }
.dc-linetotal { font-size: 20px; }
.dc-paygrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* 11" tablet portrait and up: two cards side by side */
@media (min-width: 700px) {
  .dc-two { grid-template-columns: 1fr 1fr; }
  .dc-approve-btns { grid-template-columns: repeat(4, 1fr); }
  .dc-paygrid { grid-template-columns: repeat(3, 1fr); }
  .dc-sheet-wrap { align-items: center; padding: 16px; }
  .dc-sheet { width: min(640px, 100%); max-height: 86vh; border-radius: 18px; }
}
/* Tablets landscape and desks: document on the left, totals & actions on the right; no floating bar */
@media (min-width: 1030px) {
  .dc { padding-bottom: 12px; }
  .dc-grid { grid-template-columns: minmax(0, 1fr) 320px; }
  .dc-side { position: sticky; top: 72px; }
  .dc-bar { position: static; box-shadow: none; background: var(--panel-2); margin-top: 4px; }
  .dc-top { top: 0; }
}
@media (min-width: 1400px) {
  .dc-grid { grid-template-columns: minmax(0, 1fr) 360px; }
}
@media print { .dc-bar, .dc-sheet-wrap, .dc-mini, .dc-addrow, .dc-addjob { display: none !important; } }
