/* ==========================================================================
   Editable document lines (<x-doc.lines>). Module stylesheet: tokens only, shared parts live in components.css.
   ========================================================================== */

/* ---- Editable document lines (<x-doc.lines>): a compact table on desktop, one compact card per line on small screens ---- */
.dl { display: grid; gap: var(--sp-2); }
.dl-scroll { overflow-x: auto; }
.dl-table { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.dl-table th { font-size: var(--fs-xs); font-weight: var(--fw-medium); color: var(--text-muted); text-align: start; padding: 0 4px 4px; white-space: nowrap; }
.dl-table .dl-th--qty { width: 76px; } .dl-table .dl-th--unit { width: 84px; } .dl-table .dl-th--price { width: 112px; }
.dl-table--quotation .dl-th--disc { width: 84px; } .dl-table--invoice .dl-th--disc { width: 128px; } .dl-table .dl-th--tax { width: 72px; }
.dl-table .dl-th--amount { width: 118px; text-align: end; } .dl-table .dl-th--grip { width: 24px; } .dl-table .dl-th--act { width: 40px; }
.dl-cell { padding: 3px 4px; vertical-align: top; border-block-start: 1px solid var(--border); min-width: 0; }
.dl-row:hover .dl-cell { background: var(--surface-hover); }
.dl-row.is-ghost { opacity: .45; }
.dl-cell .m-input, .dl-cell .m-select, .dl-cell .m-textarea { width: 100%; }
.dl-cell .m-field { margin: 0; gap: 0; } .dl-cell .m-field__error:empty { display: none; }
.dl-num { text-align: end; font-variant-numeric: tabular-nums; }
.dl-desc { margin-block-start: 4px; min-height: 30px; font-size: var(--fs-sm); resize: none; overflow: hidden; }
.dl-desc[hidden] { display: none; }
.dl-disc { display: flex; gap: 4px; } .dl-disc .m-select { width: 54px; flex: none; padding-inline: 4px; } .dl-disc .m-input { min-width: 0; }
.dl-cell--amount { text-align: end; font-weight: var(--fw-medium); padding-block-start: 9px; font-variant-numeric: tabular-nums; }
.dl-cell--grip { padding-inline: 0; } .dl-grip { border: 0; background: none; color: var(--text-faint); cursor: grab; padding: 6px 2px; border-radius: var(--r-sm); }
.dl-grip:hover { color: var(--text); } .dl-grip:focus-visible { outline: 2px solid var(--accent); }
.dl-cell--act { white-space: nowrap; text-align: end; } .dl-cell--act .icon-btn { width: 28px; height: 28px; }
.dl-errs { display: grid; gap: 2px; margin-block-start: 2px; }
.dl-bar { display: flex; align-items: center; gap: var(--sp-3); position: relative; }
.dl-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: flex-start; gap: var(--sp-4); padding-block-start: var(--sp-2); border-block-start: 1px solid var(--border); }
.dl-settings { border: 1px dashed var(--border-strong); border-radius: var(--r-md); padding: var(--sp-2) var(--sp-3) var(--sp-3); margin: 0; flex: 1 1 360px; max-width: 520px; min-width: 0; margin-inline-end: auto; }
.dl-settings legend { float: none; width: auto; font-size: var(--fs-xs); font-weight: var(--fw-medium); color: var(--text-muted); padding: 0 4px; margin: 0; }
.dl-settings__grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-2); }
.dl-sum { margin: 0; flex: 0 0 280px; display: grid; gap: 3px; }
.dl-sum > div { display: flex; justify-content: space-between; gap: var(--sp-3); }
.dl-sum dt { font-weight: var(--fw-regular); color: var(--text-muted); } .dl-sum dd { margin: 0; font-variant-numeric: tabular-nums; }
.dl-sum__total { border-block-start: 1px solid var(--border); padding-block-start: 5px; margin-block-start: 2px; font-size: var(--fs-md); font-weight: var(--fw-semibold); }
.dl-sum__total dt { color: var(--text); font-weight: var(--fw-semibold); }
@media (max-width: 991.98px) {
  .dl-table, .dl-table tbody { display: block; } .dl-table thead { display: none; }
  .dl-row { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px 6px; padding: var(--sp-2); margin-block-end: var(--sp-2); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); position: relative; }
  .dl-row:hover .dl-cell { background: none; }
  .dl-cell { border: 0; padding: 0; display: block; }
  .dl-cell[data-label]::before { content: attr(data-label); display: block; font-size: var(--fs-2xs); color: var(--text-muted); margin-block-end: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .dl-cell--grip { position: absolute; inset-block-start: 4px; inset-inline-end: 34px; z-index: 1; }
  .dl-cell--item { grid-column: 1 / -1; padding-inline-end: 70px; }
  .dl-cell--act { position: absolute; inset-block-start: 4px; inset-inline-end: 2px; }
  .dl-cell--qty, .dl-cell--unit { grid-column: span 3; } .dl-cell--price { grid-column: span 3; }
  .dl-table--invoice .dl-cell--disc { grid-column: span 3; } .dl-table--invoice .dl-cell--tax { grid-column: span 3; }
  .dl-table--quotation .dl-cell--disc { grid-column: span 3; }
  .dl-cell--amount { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: baseline; border-block-start: 1px dashed var(--border); padding-block-start: 4px; }
  .dl-cell--amount::before { margin: 0; }
  .dl-settings { max-width: none; flex-basis: 100%; } .dl-sum { flex-basis: 100%; }
}
@media (max-width: 575.98px) { .dl-settings__grid { grid-template-columns: 1fr 1fr; } }

/* description toggle: highlighted while the field is open; a dot says "there is text in here" while it is folded away */
.dl-desc-toggle { position: relative; color: var(--text-muted); }
.dl-desc-toggle.is-open { color: var(--accent-text); background: var(--accent-soft); }
.dl-desc-toggle.has-text:not(.is-open)::after { content: ''; position: absolute; inset-block-start: 4px; inset-inline-end: 4px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }

/* the description toggle belongs to the item field: it sits right beside the item input */
.dl-itemline { display: flex; align-items: flex-start; gap: 4px; }
.dl-itemline > .m-field { flex: 1 1 auto; min-width: 0; }
.dl-itemline .dl-desc-toggle { flex: none; width: var(--ctl-h); height: var(--ctl-h); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
.dl-itemline .dl-desc-toggle:hover { background: var(--surface-hover); color: var(--text); }
.dl-itemline .dl-desc-toggle.is-open { border-color: var(--accent); }
.dl-itemline .dl-desc-toggle.has-text:not(.is-open)::after { inset-block-start: 3px; inset-inline-end: 3px; }
