/* One TDS return (tds-return.html), usually inside the client page. */
.embed .hd { display: none; }
.rt { max-width: 1600px; margin: 0 auto; padding: 16px 20px 64px; display: grid; gap: 12px; }
.rt .gate { max-width: 460px; margin: 40px auto; }
.rt-head { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: flex-end; }
.rt-head > div { margin-right: auto; min-width: 0; }
.rt-head p { color: var(--muted); margin-top: 2px; }
.rt-status { color: var(--muted); font-size: 12px; white-space: nowrap; }
.rt-status.bad { color: var(--crit); }
.rt-undo { display: inline-flex; gap: 4px; align-self: center; }
.rt-undo .btn { height: 30px; width: 30px; }
.rt .tabs { padding: 0; background: none; }
.rt .banner { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; padding: 9px 14px; border-radius: var(--r); background: var(--info-bg); color: var(--info); }
.rt .banner.warn { background: var(--warn-bg); color: var(--warn); }
.rt .banner input { width: 200px; }
.rt-main { display: grid; gap: 10px; min-width: 0; }
.rt .toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.rt .toolbar .nil { display: inline-flex; gap: 6px; align-items: center; color: var(--ink-2); font-size: 12.5px; }
.rt .toolbar .chk { margin-left: auto; color: var(--crit); font-size: 12.5px; }
.rt .toolbar .chk.good { color: var(--ok); }
.rt .hint { font-size: 12px; }
.rt .err { color: var(--crit); }
.rt .file { position: relative; overflow: hidden; }
.rt .file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.rt .empty { color: var(--muted); padding: 16px 18px; }

/* the rows: a sheet like Excel, its headings and totals always in view, every cell typed or pasted in place */
.rt .sheet-card { padding: 0; overflow: hidden; }
.rt .sheet { max-height: calc(100vh - 200px); min-height: 150px; overflow: auto; scroll-padding: 56px 0 34px; }
table.rt-grid { font-size: 12.5px; border-collapse: separate; border-spacing: 0; }
table.rt-grid th { white-space: nowrap; font-size: 11.5px; position: sticky; top: 0; z-index: 2; background: var(--surface-2); border-bottom: 1px solid var(--line); padding: 7px 6px; }
/* two rows of headings: "Challan" over its number and details, the second row kept in view under the first */
table.rt-grid th.grp, table.rt-grid tr.h2 th { height: 26px; padding: 4px 6px; line-height: 17px; }
table.rt-grid th.grp { border-bottom-color: var(--line-2); }
table.rt-grid tr.h2 th { top: 26px; }
table.rt-grid th[data-c] { cursor: pointer; }
table.rt-grid td { padding: 0; vertical-align: middle; border-bottom: 1px solid var(--line-2); border-right: 1px solid var(--line-2); }
table.rt-grid input, table.rt-grid select { height: 28px; padding: 0 6px; font-size: 12.5px; width: 100%; min-width: 0; border: 0; border-radius: 0; background: transparent; }
table.rt-grid input:focus, table.rt-grid select:focus { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--surface); }
table.rt-grid input:disabled, table.rt-grid select:disabled { background: transparent; border-color: transparent; color: var(--ink); opacity: 1; }
table.rt-grid tr.new td { background: var(--surface-2); }
table.rt-grid tr.new td.n::before { content: "+"; }
table.rt-grid td:last-child { border-right: 0; padding: 0 6px; }
table.rt-grid input.r { text-align: right; font-variant-numeric: tabular-nums; }
table.rt-grid td.n { color: var(--muted); white-space: nowrap; text-align: right; width: 40px; padding: 0 6px; background: var(--surface-2); }
table.rt-grid .w-pan { width: 108px; text-transform: uppercase; }
table.rt-grid .w-name { min-width: 160px; }
table.rt-grid .w-code { width: 70px; }
table.rt-grid .w-date { width: 92px; }
table.rt-grid .w-amt { width: 104px; }
table.rt-grid .w-rate { width: 64px; }
table.rt-grid .w-rem { width: 56px; }
table.rt-grid .w-ref { width: 112px; text-transform: uppercase; }
table.rt-grid tr.hl td { background: var(--warn-bg); }
/* the # column stays in view when the sheet scrolls sideways */
table.rt-grid td.n, table.rt-grid th.n { position: sticky; left: 0; z-index: 1; }
table.rt-grid th.n { z-index: 3; }
/* cells with something to fix or review (hover for why) */
table.rt-grid td.c-block { background: var(--crit-bg); box-shadow: inset 0 -2px 0 var(--crit); }
table.rt-grid td.c-demand { background: var(--warn-bg); box-shadow: inset 0 -2px 0 var(--warn); }
table.rt-grid td.c-warn { background: var(--info-bg); box-shadow: inset 0 -2px 0 var(--info); }
table.rt-grid tr[hidden] { display: none; }
/* the challan cell: its number here, typed or picked */
table.rt-grid td.ch { min-width: 70px; }
.ch-in { display: flex; align-items: center; }
table.rt-grid .w-chno { width: 42px; flex: 1; }
/* the challan's own cells after it: faded, to read, select and copy, not to type in */
table.rt-grid td.cd { background: var(--surface-2); }
table.rt-grid td.cd input { color: var(--muted); font-size: 12px; cursor: default; }
table.rt-grid td.cd input.neg { color: var(--crit); }
table.rt-grid .w-cdate { width: 84px; }
table.rt-grid .w-cbsr { width: 66px; }
table.rt-grid .w-cser { width: 56px; }
table.rt-grid .w-cfig { width: 80px; }
table.rt-grid .w-csm { width: 64px; }
/* cells selected: tinted, with a line around the block (the one with the focus keeps its outline); no text is selected
   while dragging over them */
table.rt-grid tbody td.sel { background-color: var(--accent-soft);
  box-shadow: inset 0 var(--sel-t, 0) 0 var(--accent), inset 0 var(--sel-b, 0) 0 var(--accent), inset var(--sel-l, 0) 0 0 var(--accent), inset var(--sel-r, 0) 0 0 var(--accent); }
table.rt-grid tbody td.sel-t { --sel-t: 2px; }
table.rt-grid tbody td.sel-b { --sel-b: -2px; }
table.rt-grid tbody td.sel-l { --sel-l: 2px; }
table.rt-grid tbody td.sel-r { --sel-r: -2px; }
table.rt-grid.dragging, table.rt-grid.dragging * { user-select: none; -webkit-user-select: none; cursor: cell; }
table.rt-grid td.n { cursor: pointer; }
.ch-in .ch-open { flex: none; border: 0; background: none; color: var(--muted); height: 28px; width: 24px; padding: 0; cursor: pointer; }
.ch-in .ch-open:hover { color: var(--ink); background: var(--surface-2); }
.rt .find-bar input[type=search] { width: min(360px, 100%); }
.rt .find-bar select { width: auto; }
/* the list of challans under a challan cell */
.ch-pop { position: fixed; z-index: 50; min-width: 380px; max-width: calc(100vw - 12px); max-height: min(340px, 70vh); overflow: auto; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r-sm); box-shadow: 0 8px 24px rgba(0,0,0,.16); font-size: 12.5px; padding: 4px 0; }
.ch-pop-head, .ch-opt { display: grid; grid-template-columns: 34px 82px minmax(120px, 1fr) 80px 80px; gap: 8px; padding: 5px 10px; align-items: center; }
.ch-pop-head { color: var(--muted); font-size: 11px; position: sticky; top: -4px; background: var(--surface); border-bottom: 1px solid var(--line-2); }
.ch-opt { cursor: pointer; font-variant-numeric: tabular-nums; }
.ch-opt .all { grid-column: 1 / -1; }
.ch-opt .r, .ch-pop-head .r { text-align: right; }
.ch-opt:hover, .ch-opt.hl { background: var(--accent-soft); }
.ch-opt.on { font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.ch-opt.short { color: var(--muted); }
.ch-pop-all { display: block; padding: 6px 10px; font-size: 12px; }
.ch-pop-note { color: var(--muted); font-size: 11.5px; padding: 4px 10px 6px; margin: 0; }
table.rt-grid tfoot td { font-weight: 600; font-variant-numeric: tabular-nums; padding: 6px; position: sticky; bottom: 0; background: var(--surface-2); border-top: 1px solid var(--line); border-right: 0; }
.flag { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-left: 5px; vertical-align: middle; background: transparent; }
.flag.block { background: var(--crit); }
.flag.demand { background: var(--warn); }
.flag.warn { background: var(--info); }

/* checks, in their own tab */
.checks { display: grid; gap: 10px; max-width: 900px; }
.checks h2 { font-size: 14px; }
.checks .sum { color: var(--ink-2); font-size: 12.5px; }
.checks .sum.good { color: var(--ok); }
.checks ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.checks li { border-left: 3px solid var(--line); padding: 2px 0 2px 9px; font-size: 12.5px; display: grid; gap: 2px; }
.checks li.block { border-color: var(--crit); }
.checks li.demand { border-color: var(--warn); }
.checks li.warn { border-color: var(--info); }
.checks li b { font-weight: 600; }
.checks li .link { justify-self: start; font-size: 12px; }
.checks details.each summary { cursor: pointer; color: var(--link); font-size: 12px; }
.checks details.each ol { margin: 4px 0 0; padding-left: 20px; display: grid; gap: 2px; max-height: 260px; overflow: auto; }
.checks details.each li { display: list-item; border: 0; padding: 0; }

/* challans and deductor details */
table.rt-ch td, table.rt-ch th { font-size: 12.5px; }
table.rt-ch input { height: 28px; width: 100px; text-align: right; }
table.rt-ch tr.hl td { background: var(--warn-bg); }
table.rt-ch td.acts { white-space: nowrap; }
table.rt-ch td.no { white-space: nowrap; }
table.rt-ch .move { display: inline-flex; align-items: center; gap: 2px; }
table.rt-ch .move .link { font-size: 10px; padding: 2px 3px; }
table.rt-ch .move .link:disabled { visibility: hidden; }
table.rt-ch input.w-no { width: 40px; }
.rt details.more-ch summary { cursor: pointer; color: var(--link); }
.rt details.more-ch > p { margin: 8px 0; }

/* linking rows to one challan */
.hy-modal .pick-tools { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
.hy-modal .pick-tools input { flex: 1; min-width: 160px; }
.hy-modal .pick { max-height: 45vh; overflow: auto; border: 1px solid var(--line); border-radius: var(--r-sm); }
.hy-modal form.pick-form { width: min(820px, 100%); }
.hy-modal form.pick-form.pick-wide { width: min(1280px, 96vw); max-width: none; }
.hy-modal form.pick-form.pick-wide .pick { max-height: 55vh; }
.hy-modal .pick tbody tr { cursor: pointer; }
.hy-modal .pick tbody tr:hover td { background: var(--accent-soft); }
.hy-modal .pick tbody tr[hidden] { display: none; }
.hy-modal .pick td.num, .hy-modal .pick th.r { text-align: right; white-space: nowrap; }
.hy-modal .pick th, .hy-modal .pick td { padding: 3px 8px; font-size: 12px; line-height: 1.35; }
.hy-modal .pick input[type=checkbox] { margin: 0; vertical-align: middle; }
.hy-modal .pick th { position: sticky; top: 0; background: var(--surface-2); }
.hy-modal .sum { font-size: 12.5px; color: var(--ink-2); }
.hy-modal .sum.err { color: var(--crit); }
/* the PAN checks: the PANs to look at, then the rest, each table scrolling on its own */
.hy-modal form.pick-form.pan-checks h3 { font-size: 13px; font-weight: 600; margin: 4px 0 -4px; }
.hy-modal form.pick-form.pan-checks .pick { max-height: 32vh; }
.hy-modal form.pick-form.pan-checks .pick tbody tr { cursor: default; }
.hy-modal form.pick-form.pan-checks .pick td { vertical-align: top; white-space: normal; }
.hy-modal form.pick-form.pan-checks .pick td.mono, .hy-modal form.pick-form.pan-checks .pick td.num, .hy-modal form.pick-form.pan-checks .pick td.st { white-space: nowrap; }
.hy-modal form.pick-form.pan-checks .pick td.why { min-width: 300px; }
.hy-modal form.pick-form.pan-checks .pick td.why div + div { margin-top: 3px; }
.hy-modal form.pick-form.pan-checks .btn-row { flex-wrap: wrap; }

/* fill in RPU: sheets in RPU's columns and formats, each heading copying its column */
.rt .rpu-step { display: grid; gap: 8px; }
.rt .rpu-step .card-head { margin-bottom: 0; }
.rt .rpu-step .btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.rt .banner.warn span + span::before { content: "·"; margin-right: 14px; }
.rt .sheet.xl { max-height: 55vh; min-height: 0; overflow: auto; border: 1px solid var(--line); border-radius: var(--r-sm); }
table.xl { border-collapse: separate; border-spacing: 0; font-family: var(--mono); font-size: 11.5px; width: auto; }
table.xl th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); padding: 0; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line-2); font-family: var(--font); }
table.xl th .link { display: flex; gap: 4px; align-items: center; width: 100%; padding: 6px 8px; color: var(--ink-2); font-size: 11.5px; white-space: nowrap; text-align: left; }
table.xl th .link:hover { background: var(--accent-soft); text-decoration: none; }
table.xl td { padding: 3px 8px; border-bottom: 1px solid var(--line-2); border-right: 1px solid var(--line-2); }
table.xl td.n, table.xl th.n { color: var(--muted); background: var(--surface-2); text-align: right; position: sticky; left: 0; }
table.xl th.n { z-index: 2; }
table.xl td.n .goto, table.rpu-count .goto { font-family: var(--font); font-size: 11.5px; }
table.rpu-count { width: auto; }
.rt .note { font-size: 12px; }
.rt details.add summary { cursor: pointer; color: var(--link); }
.rt form.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px 12px; align-items: end; margin-top: 10px; }
.rt form.grid label, .ded label { display: grid; gap: 4px; font-size: 12px; color: var(--ink-2); }
.rt form.grid .span { grid-column: 1 / -1; }
.rt label.check { display: inline-flex; gap: 6px; align-items: center; }
.ded { display: grid; gap: 14px; max-width: 900px; }
.ded fieldset { border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px 12px; margin: 0; }
.ded legend { font-weight: 600; padding: 0 4px; }
.ded .span { grid-column: 1 / -1; }
.ded .missing { color: var(--crit); font-size: 12.5px; }
.ded .row-end { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.hy-modal textarea.paste { min-height: 180px; font-family: var(--mono); font-size: 12px; white-space: pre; }
.hy-modal .preview { font-size: 12.5px; color: var(--ink-2); max-height: 140px; overflow: auto; }

@media (max-width: 640px) { .rt { padding: 12px 12px 48px; } }
