/* Ziwake v0.27 — layout refinements on the ink & ivory theme (D-169, revised). Loaded last (features/, name order).
 * The theme (deep-ink sidebar, ivory work area, tiles) stays as it was. This file only:
 *   - trims oversized controls on desktop (phones keep 48 px touch targets),
 *   - removes boxes inside boxes on forms (party type, GSTIN), settings in two columns,
 *   - lays sale & purchase entry out as ONE screen: header row -> item table (scrolls inside) -> bottom bar
 *     (payment, extras that open as pop-ups, totals, save). */

:root { --c-line: rgba(22, 23, 28, .09); --c-line-2: rgba(22, 23, 28, .055); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --c-line: rgba(244, 239, 228, .1); --c-line-2: rgba(244, 239, 228, .06); } }
:root[data-theme="dark"] { --c-line: rgba(244, 239, 228, .1); --c-line-2: rgba(244, 239, 228, .06); }

/* ------------------------------------------------------------------ controls: a size that suits a desk */
@media (min-width: 900px) {
  .input { min-height: 42px; font-size: 15px; }
  .btn { min-height: 42px; padding: 0 20px; }
  .btn--icon { width: 42px; min-height: 42px; padding: 0; }
  .field { margin-bottom: var(--s-3); }
}
.btn--text { background: none; box-shadow: none; padding: 0 8px; min-height: 34px; color: var(--c-accent); font-weight: 650; }
.btn--text:hover { background: var(--c-accent-soft); }

/* Party form: one sheet, not tinted panels inside it */
.gstin-box { padding: 0; background: none; border-radius: 0; }
.role-pick { background: none !important; padding: 0 !important; border: 0 !important; box-shadow: none !important; }

/* Settings: two columns on wide screens */
@media (min-width: 1100px) {
  .list--grid { display: grid; grid-template-columns: 1fr 1fr; }
  .list--grid > * { border-bottom: 1px solid var(--c-line-2); }
  .list--grid > *:nth-child(odd) { border-right: 1px solid var(--c-line-2); }
}

/* ================================================================== bill entry */
.bill-top { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; margin: var(--s-1) 0 var(--s-3); }
.bill-top h1 { margin: 0; }
.bill-top .scan-box { margin: 0 0 0 auto; padding: 0; background: none; box-shadow: none; }
.bill-top .scan-box__drop { padding: 4px 4px 4px 14px; gap: var(--s-3); border-radius: var(--r-pill); border-width: 1px; background: var(--c-surface); flex-wrap: nowrap; }
.bill-top .scan-box__icon, .bill-top .scan-box__hint, .bill-top .scan-box__foot, .bill-top .scan-box__eyebrow { display: none; }
.bill-top .scan-box__text { flex: none; }
.bill-top .scan-box__title { font-family: var(--font-sans); font-size: 13.5px; font-weight: 650; color: var(--c-text-2); white-space: nowrap; }
.bill-top .scan-box__actions .btn { min-height: 34px; padding: 0 14px; font-size: 13.5px; }
.bill-top .scan-box__camera { display: none; }

.bill { display: flex; flex-direction: column; gap: 10px; }
.bill > .alert { margin: 0; }
.bill-sheet { background: var(--c-surface); border-radius: var(--r-lg); box-shadow: var(--shadow-1); }
.bill-main { display: flex; flex-direction: column; min-height: 0; }

/* Header: every field in one row */
.bill-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px; padding: 14px 18px; border-bottom: 1px solid var(--c-line); }
.bill-head__main, .bill-head__meta, .bill-head__pair { display: contents; }
.bill-head .field { position: relative; flex: 1 1 150px; min-width: 0; margin: 0; }
.bill-head .field--party { flex: 2.4 1 280px; }
.bill-head .field--when { flex: 1.4 1 220px; }
.bill-head .field__label { font-size: 12.5px; margin-bottom: 5px; color: var(--c-text-2); display: flex; align-items: baseline; gap: 8px; white-space: nowrap; }
.bill-head__link { margin-left: auto; font-size: 12.5px; font-weight: 650; text-decoration: none; }
.bill-head__link:hover { text-decoration: underline; }
.bill-head__when { display: flex; gap: 6px; }
.bill-head__when input[type=time] { max-width: 118px; }

/* Item table */
.bill-lines { position: relative; }
.bl-head, .bill-line { display: flex; align-items: flex-start; gap: 8px; padding: 0 18px; }
.bl-head { min-height: 34px; align-items: center; border-bottom: 1px solid var(--c-line); background: var(--c-surface);
  font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--c-text-3); }
.bl-head > span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bill-line { flex-wrap: wrap; padding-top: 7px; padding-bottom: 7px; border-bottom: 1px solid var(--c-line-2); position: relative; }
.bill-line:focus-within { background: color-mix(in srgb, var(--c-accent-soft) 40%, transparent); }
.bl-n { width: 22px; flex: none; padding-top: 9px; color: var(--c-text-3); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.bl-head .bl-n { padding-top: 0; }
.bl-item { flex: 1 1 220px; min-width: 0; display: flex; gap: 6px; }
.bl-item > .combo, .bl-item > select { flex: 1; min-width: 0; }
.bl-qty { width: 76px; } .bl-unit { width: 96px; } .bl-free { width: 68px; } .bl-rate { width: 108px; } .bl-disc { width: 78px; } .bl-gst { width: 84px; }
.bl-qty, .bl-unit, .bl-free, .bl-rate, .bl-disc, .bl-gst { flex: none; display: block; }
.bl-amt { width: 112px; text-align: right; padding-top: 8px; font-weight: 700; font-variant-numeric: tabular-nums; }
.bl-head .bl-amt { padding-top: 0; }
.bl-x { width: 32px; flex: none; }
.bill-line .input { min-height: 36px; font-size: 14.5px; padding: 0 10px; border-width: 1px; border-radius: 9px; }
.bill-line select.input { padding-right: 26px; }
.bill-line .combo__chev { width: 30px; height: 30px; }
.bl-qty .input, .bl-free .input, .bl-rate .input, .bl-disc .input { text-align: right; }
.bl-lab { display: none; }
.bl-rm { width: 32px; min-height: 36px; padding: 0; border: 0; background: none; color: var(--c-text-3); border-radius: var(--r-sm); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.bl-rm:hover { background: var(--c-danger-soft); color: var(--c-danger); }
.bl-extra { flex: 1 0 100%; display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; padding-left: 30px; padding-right: 40px; }
.bl-extra:not(:has(> :not([hidden]):not(input[type=hidden]))) { display: none; }
.bl-extra > * { margin: 0 !important; }
.bl-extra .line-note { flex: 1 1 240px; min-height: 28px !important; font-size: 13px !important; background: transparent; border-color: transparent; padding-left: 0 !important; }
.bl-extra .line-note:hover, .bl-extra .line-note:focus { border-color: var(--c-border); padding-left: 10px !important; background: var(--c-surface); }
.bl-extra .check { font-size: 12.5px; color: var(--c-text-2); align-items: center; gap: 6px; }
.bl-extra .check input { width: 16px; height: 16px; margin: 0; }
.bl-extra [data-batch-fields], .bl-extra [data-serial-fields] { flex: 1 0 100%; }
.bl-extra [data-batch-fields]:not([hidden]) { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.bl-extra .field__error { flex: 1 0 100%; }
.bill-line .line-mrp { font-size: 12px; }
.bill-lines__foot { display: flex; align-items: center; gap: var(--s-2); padding: 4px 12px; }
.bill-lines__foot .btn { white-space: nowrap; }
.bill-lines__foot .field__error { margin: 0; }
.txn-hide-unit .bl-head [data-col="unit"], .txn-hide-discount .bl-head [data-col="discount"] { display: none !important; }
.is-quick .bill-line { padding: 7px 18px !important; }
.bill-exp { padding: 12px 18px; }
.bill-exp [data-repeat-row] .input { min-height: 38px; }
.bill-exp [data-repeat-remove] { width: 34px; padding: 0 !important; background: none; box-shadow: none; color: var(--c-text-3); }

/* Bottom bar: payment, extras, totals, save */
.bill-bar { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px 24px; padding: 12px 18px; }
.bill-bar__left { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.bill-pay { display: flex; flex-direction: column; gap: 6px; }
.bill-pay__head { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 700; color: var(--c-text-2); }
.bill-pay__head .icon { width: 16px; height: 16px; color: var(--c-text-3); }
.bill-pay__head [data-repeat-add] { min-height: 26px; font-size: 12.5px; padding: 0 8px; }
.bill-pay [data-repeater] { display: flex; flex-direction: column; gap: 6px; }
.bill-pay [data-repeat-row] { display: flex; gap: 6px; align-items: center; flex-wrap: nowrap; }
.bill-pay [data-repeat-row] .input { min-height: 36px; font-size: 14px; }
.bill-pay [data-repeat-row] select.input { width: auto; }
.bill-pay .prefix-field { width: 130px; flex: none; }
.bill-pay .prefix-field__prefix { padding: 0 10px; }
.bill-pay [data-repeat-row] input[name$="[reference]"] { flex: 1; min-width: 80px; }
.bill-pay [data-repeat-remove] { width: 30px; min-height: 36px; padding: 0; background: none; box-shadow: none; color: var(--c-text-3); flex: none; }
.bill-pay .field { margin: 0; }
.bill-pay .field select { min-height: 36px; }

.bill-pops { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 4px; margin-left: -10px; }
.bill-pop > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: var(--r-pill);
  font-size: 13px; font-weight: 650; color: var(--c-accent); user-select: none; }
.bill-pop > summary::-webkit-details-marker { display: none; }
.bill-pop > summary .icon { width: 15px; height: 15px; }
.bill-pop > summary:hover, .bill-pop[open] > summary { background: var(--c-accent-soft); }
.bill-pop.has-value > summary::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--c-gold); }
.bill-pop__panel { position: absolute; left: 12px; bottom: calc(100% + 8px); z-index: 40; width: min(720px, calc(100% - 24px)); max-height: min(62vh, 560px); overflow: auto;
  background: var(--c-surface); border-radius: var(--r-lg); box-shadow: var(--shadow-2); padding: 16px 18px; }
.bill-pop__title { display: flex; align-items: center; gap: 8px; margin: 0 0 var(--s-3); font-weight: 700; }
.bill-pop__title .btn { margin-left: auto; }
.bill-pop__panel .row { gap: 8px; }
.bill-pop__panel .stack > * + * { margin-top: 8px; }
.bill-pop__panel [data-repeat-row] .input { min-height: 38px; }
.bill-pop__panel [data-repeat-remove] { width: 34px; min-height: 38px; padding: 0 !important; background: none; box-shadow: none; color: var(--c-text-3); }
.bill-pop__panel .grid-2 .field { margin: 0; }
.bill-pop--quiet > summary { color: var(--c-text-3); font-weight: 550; }

.bill-right { display: flex; align-items: center; gap: 24px; }
.bill-sum { display: grid; grid-template-columns: auto auto; gap: 3px 14px; align-items: center; font-size: 13.5px; margin: 0; }
.bill-sum dt { color: var(--c-text-2); margin: 0; }
.bill-sum dd { margin: 0; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.bill-sum .input { width: 72px; min-height: 30px; padding: 0 8px; font-size: 13.5px; text-align: right; }
.bill-sum .check { gap: 6px; align-items: center; font-size: 13.5px; color: var(--c-text-2); }
.bill-sum .check input { width: 16px; height: 16px; margin: 0; }
.bill-sum__ro { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.bill-sum__ro .input { width: 64px; }
.bill-total { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; padding-left: 24px; border-left: 1px solid var(--c-line); }
.bill-total__label { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--c-text-3); }
.bill-total__value { font-size: 1.85rem; font-weight: 750; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.bill-total__due { font-size: 12.5px; color: var(--c-warn); font-weight: 650; }
.bill-total__due:empty { display: none; }
.bill-total .bill-profit { margin: 0; padding: 2px 10px; font-size: 12px; }
.bill-total__actions { display: flex; gap: 8px; margin-top: 6px; }
.bill-total__actions .btn--primary { min-width: 140px; }

/* Desktop: the whole bill fits the screen; only the item table scrolls */
@media (min-width: 900px) {
  /* the page is exactly one screen: messages above the bill shrink the item table, never push the bar away */
  body:has(form.bill) .main { height: 100vh; height: 100dvh; }
  body:has(form.bill) .content { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; padding-bottom: var(--s-3); }
  body:has(form.bill) .content > * { flex-shrink: 0; }
  form.bill { flex: 1 0 460px; height: auto; min-height: 460px; }
  .bill-main { flex: 1; }
  .bill-scroll { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; }
  .bill-scroll .bl-head { position: sticky; top: 0; z-index: 3; }
  .bill-bar { flex: none; }
  body:has(form.bill) .asst-fab { display: none; }
}
@media (min-width: 900px) and (max-width: 1240px) {
  .bill-bar { grid-template-columns: 1fr; }
  .bill-right { justify-content: space-between; border-top: 1px solid var(--c-line-2); padding-top: 10px; }
}

/* Phones: lines become compact cards; the bar stacks; save stays in reach */
@media (max-width: 899px) {
  .bill-top .scan-box { margin-left: 0; flex: 1 0 100%; }
  .bill-head { padding: var(--s-4); }
  .bill-head .field--party { flex-basis: 100%; }
  .bl-head { display: none; }
  .bill-line { padding: var(--s-3) var(--s-4); gap: 8px; }
  .bl-n { display: none; }
  .bl-item { order: 1; flex: 1 1 calc(100% - 44px); }
  .bl-x { order: 2; }
  .bl-qty, .bl-unit, .bl-free, .bl-rate, .bl-disc, .bl-gst { order: 3; width: calc(33.333% - 6px); }
  .bl-amt { order: 4; width: auto; flex: 1 0 100%; padding-top: 2px; display: flex; justify-content: space-between; }
  .bl-amt::before { content: attr(data-label); font-weight: 600; color: var(--c-text-2); font-size: 13px; }
  .bl-extra { order: 5; padding: 0; }
  .bl-lab { display: block; font-size: 11.5px; font-weight: 650; color: var(--c-text-3); margin-bottom: 2px; }
  .bill-line .input { min-height: 44px; }
  .bill-lines__foot { flex-wrap: wrap; }
  .bill-bar { grid-template-columns: 1fr; padding: var(--s-4); }
  .bill-pay [data-repeat-row] { flex-wrap: wrap; }
  .bill-pop__panel { position: static; width: auto; max-height: none; box-shadow: none; padding: 10px 0 4px; }
  .bill-right { flex-direction: column; align-items: stretch; gap: 12px; }
  .bill-sum { grid-template-columns: 1fr auto; }
  .bill-total { position: sticky; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 6; border-left: 0; padding: 10px var(--s-3); margin: 0 calc(-1 * var(--s-2));
    flex-direction: row; align-items: center; flex-wrap: wrap; justify-content: space-between; background: var(--c-surface); border-radius: var(--r-lg); box-shadow: var(--shadow-2); }
  .bill-total__label { display: none; }
  .bill-total__value { font-size: 1.3rem; }
  .bill-total__actions { margin: 0; }
  .bill-total__actions .btn { min-height: 44px; padding: 0 14px; }
  .bill-total__actions .btn--primary { min-width: 0; }
  body:has(form.bill) .asst-fab { display: none; }
}

/* v0.27 fit: header fields keep their size (only Party grows), so a wrapped row stays tidy */
@media (min-width: 900px) {
  .bill-head { gap: 10px 12px; }
  .bill-head .field { flex: 0 1 150px; }
  .bill-head .field--party { flex: 1 1 230px; }
  .bill-head .field--when { flex: 0 0 auto; }
  .bill-head .field--when input[type=date] { width: 148px; }
  .bill-head .field--when input[type=time] { width: 118px; max-width: none; }
  .bill-head .field--mobile { flex-basis: 170px; }
  .bill-head input[type=date] { padding-right: 8px; }
  .bl-unit { width: 88px; } .bl-free { width: 64px; } .bl-rate { width: 100px; } .bl-disc { width: 72px; } .bl-gst { width: 80px; } .bl-amt { width: 104px; }
  .bl-item { flex-basis: 240px; }
}
.bill-pay [data-repeat-row] select.input { width: 104px; flex: none; }
.bill-pay .prefix-field { width: 124px; }
.bill-pop--quiet > summary { padding: 5px 8px; }
.bill-sum__ro .input { width: 56px; }
@media (min-width: 900px) { body:has(form.bill) .content { max-width: 1480px; } }
@media (min-width: 900px) { #buyer-po input[name=buyer_po_no] { width: 150px; } }
@media (max-width: 899px) {
  .bill-pay [data-repeat-row] select.input { width: auto; flex: 1 1 30%; }
  .bill-pay [data-repeat-row] .prefix-field { flex: 1 1 40%; width: auto; }
  .bill-pay [data-repeat-row] [data-repeat-remove] { order: 4; }
  .bill-pay [data-repeat-row] input[name$="[reference]"] { order: 5; flex: 1 1 100%; }
  .bill-pop > summary { text-align: left; }
  .bill-head .field--when { flex-basis: 100%; }
  .bill-head__when input { flex: 1; min-width: 0; }
}

/* ================================================================== attachments (D-171) */
.attach { background: var(--c-surface); border-radius: var(--r-lg); box-shadow: var(--shadow-1); padding: 14px 18px; margin: 0 0 var(--s-4); }
.attach--nested { background: none; box-shadow: none; padding: 0; margin: 0; }
.attach.is-busy { opacity: .7; pointer-events: none; }
.attach__head { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14.5px; margin-bottom: 10px; }
.attach__head .icon { color: var(--c-gold); }
.attach__count { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--c-gold-soft); color: var(--c-gold); font-size: 12px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
.attach__note { margin-left: auto; font-size: 12.5px; font-weight: 500; color: var(--c-text-3); }
.attach__error { margin: 0 0 10px; font-size: 13.5px; }
.attach__list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.attach__item { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 6px 6px 6px 6px; border-radius: 12px; background: var(--c-bg); box-shadow: inset 0 0 0 1px var(--c-line-2); }
.attach__thumb { flex: none; width: 46px; height: 46px; border-radius: 9px; overflow: hidden; display: grid; place-items: center; background: var(--c-surface-2); text-decoration: none; }
.attach__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attach__ext { font-size: 10.5px; font-weight: 800; letter-spacing: .04em; color: var(--c-text-2); }
.attach__ext--pdf { color: #B42318; } .attach__ext--xlsx, .attach__ext--xls, .attach__ext--csv { color: #1B7950; } .attach__ext--docx, .attach__ext--doc { color: #2C69BA; }
.attach__meta { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.attach__name { font-weight: 650; font-size: 13.5px; color: var(--c-text); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach__name:hover { text-decoration: underline; }
.attach__meta small { color: var(--c-text-3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach__act { flex: none; width: 32px; height: 32px; border: 0; border-radius: 8px; background: none; color: var(--c-text-3); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.attach__act:hover { background: var(--c-surface-2); color: var(--c-text); }
.attach__act--del:hover, .attach__act--del.is-confirm { background: var(--c-danger-soft); color: var(--c-danger); }
.attach__act--del.is-confirm { width: auto; padding: 0 8px; }
.attach__act--del.is-confirm::after { content: attr(title); font-size: 12px; font-weight: 700; margin-left: 4px; }
.attach__delform { margin: 0; display: contents; }
.attach__drop { margin: 0; border: 1px dashed color-mix(in srgb, var(--c-text) 20%, transparent); border-radius: 12px; transition: background var(--t-fast), border-color var(--t-fast); }
.attach__drop.is-over { border-color: var(--c-accent); background: var(--c-accent-soft); }
.attach__pick { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; padding: 10px 12px; cursor: pointer; }
.attach__btn { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 13.5px; color: var(--c-accent); }
.attach__hint { font-size: 12.5px; color: var(--c-text-3); }
.attach__empty { margin: 0; font-size: 13px; color: var(--c-text-3); }
.attach__pick:focus-within { outline: 2px solid var(--c-accent); outline-offset: 2px; border-radius: 12px; }
.bill-pop__n { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--c-gold); color: #14151A; font-size: 11px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
#attach-pop.has-value > summary::after { display: none; }

/* Destructive actions stay folded until wanted */
.danger-zone { margin: var(--s-4) 0; }
.danger-zone > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 650; color: var(--c-text-3); padding: 4px 0; }
.danger-zone > summary::-webkit-details-marker { display: none; }
.danger-zone > summary:hover { color: var(--c-danger); }
.danger-zone[open] > summary { margin-bottom: var(--s-2); color: var(--c-danger); }

/* ================================================================== document pages: the document, with its actions beside it */
.doc-layout { display: grid; gap: var(--s-4); align-items: start; }
.doc-main { min-width: 0; }
.doc-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.doc-side > * { margin: 0 !important; }
.doc-side .card, .doc-side .attach, .doc-side .send-card { padding: 14px 16px; }
.doc-side .send-card__title { font-size: 1.1rem; }
.doc-side .send-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.doc-side .send-action { min-height: 58px; padding: 6px 4px; font-size: 12px; border-radius: 12px; }
.doc-side .send-card__link { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-side .section-title { margin: 6px 2px 0; }
.doc-side .list__item { min-height: 50px; padding: 8px 12px; }
.doc-side .attach__list { grid-template-columns: 1fr; }
.doc-side .row { gap: 8px; }
.doc-side .row .btn { flex: 1 1 auto; }
.doc-side .table { font-size: 12.5px; }
@media (min-width: 1200px) {
  body:has(.doc-layout) .content { max-width: 1480px; }
  .doc-layout { grid-template-columns: minmax(0, 1fr) 360px; }
  .doc-side { position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow-y: auto; overscroll-behavior: contain; padding-bottom: 76px; scrollbar-width: thin; }
}
@media (max-width: 1199px) { .doc-side { order: -1; } }
@media print { .doc-layout { display: block; } .doc-side { display: none !important; } }

/* Money received / paid earlier that can be linked */
.advance-note { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 0 0 var(--s-3); padding: 10px 14px; border-radius: var(--r-lg);
  background: var(--c-gold-soft); color: var(--c-text); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c-gold) 35%, transparent); }
.advance-note__icon { display: inline-flex; width: 30px; height: 30px; border-radius: 9px; align-items: center; justify-content: center; background: var(--c-surface); color: var(--c-gold); }
.advance-note__text { flex: 1; min-width: 200px; font-weight: 600; font-size: 14px; }
.btn--sm { min-height: 34px !important; padding: 0 14px !important; font-size: 13.5px; }

/* ================================================================== list pages: one toolbar row, a slim totals strip */
.list-head { margin-bottom: var(--s-3); }
.list-head .relative .menu { min-width: 240px; }
.list-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; margin: 0 0 var(--s-3); }
.list-search { position: relative; flex: 0 1 340px; min-width: 200px; display: block; }
.list-search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--c-text-3); pointer-events: none; }
.list-search .input { padding-left: 38px; min-height: 40px; }
.period-bar { gap: 6px; }
.period-select { position: relative; display: inline-flex; align-items: center; }
.period-select .icon { position: absolute; left: 11px; color: var(--c-text-3); pointer-events: none; }
.period-select select.input { min-height: 40px; padding-left: 34px; padding-right: 30px; width: auto; font-weight: 600; font-size: 14px; }
.period-bar__dates .input { min-height: 40px !important; }
.sum-strip { display: inline-flex; align-items: stretch; border-radius: var(--r-md); background: var(--c-surface); box-shadow: var(--shadow-1); overflow: hidden; }
.sum-strip__item { display: flex; flex-direction: column; justify-content: center; padding: 5px 14px; line-height: 1.2; text-decoration: none; color: var(--c-text); min-width: 0; }
.sum-strip__item + .sum-strip__item { border-left: 1px solid var(--c-line-2); }
.sum-strip__item small { font-size: 11.5px; font-weight: 650; color: var(--c-text-3); white-space: nowrap; }
.sum-strip__item strong { font-size: 15px; font-weight: 750; white-space: nowrap; }
.sum-strip__item--paid strong { color: var(--c-ok); }
.sum-strip__item--due strong { color: var(--c-warn); }
a.sum-strip__item:hover { background: var(--c-warn-soft); }
.list-count { white-space: nowrap; }
.doc-tabs { margin-bottom: var(--s-3); }
@media (max-width: 899px) {
  .list-search { flex: 1 1 100%; }
  .sum-strip { width: 100%; }
  .sum-strip__item { flex: 1; padding: 6px 10px; }
  .sum-strip__item strong { font-size: 14px; }
}

/* Document lists: one line per document */
.doc-table { background: var(--c-surface); border-radius: var(--r-lg); box-shadow: var(--shadow-1); }
.doc-row:last-child { border-radius: 0 0 var(--r-lg) var(--r-lg); }
.doc-row { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, 1.3fr) minmax(0, 1fr) 110px 130px 120px; align-items: center; gap: 12px;
  padding: 9px 18px; color: var(--c-text); text-decoration: none; border-top: 1px solid var(--c-line-2); font-size: 14px; }
.doc-row:first-child { border-top: 0; }
.doc-row:not(.doc-row--head):hover { background: color-mix(in srgb, var(--c-accent-soft) 45%, transparent); }
.doc-row--head { position: sticky; top: 68px; z-index: 4; border-radius: var(--r-lg) var(--r-lg) 0 0; background: var(--c-surface); padding-top: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--c-line);
  font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--c-text-3); }
.doc-row > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-row__party { display: flex; align-items: center; gap: 8px; }
.doc-row__party strong { font-weight: 650; overflow: hidden; text-overflow: ellipsis; }
.doc-row__clip { display: inline-flex; align-items: center; gap: 2px; font-size: 11.5px; font-weight: 700; color: var(--c-gold); flex: none; }
.doc-row__clip .icon { width: 14px; height: 14px; }
.doc-row__no, .doc-row__date { color: var(--c-text-2); font-size: 13.5px; }
.doc-row__no small, .doc-row__date small { margin-left: 6px; color: var(--c-text-3); font-size: 12px; }
.doc-row__amt { text-align: right; font-weight: 700; }
.doc-row__due { text-align: right; color: var(--c-text-3); }
.doc-row__due.is-due { color: var(--c-danger); font-weight: 650; }
.doc-row--head .doc-row__amt, .doc-row--head .doc-row__due { text-align: right; }
.pill--muted { background: var(--c-surface-2); color: var(--c-text-2); }
.list-pager { margin-top: var(--s-3); justify-content: center; }
@media (max-width: 899px) {
  .doc-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "party amt" "meta due"; gap: 2px 10px; padding: 10px 14px; }
  .doc-row--head { display: none; }
  .doc-row__party { grid-area: party; } .doc-row__amt { grid-area: amt; } .doc-row__due { grid-area: due; font-size: 12.5px; }
  .doc-row__no { grid-area: meta; font-size: 12.5px; } .doc-row__date, .doc-row__status { display: none !important; }
}

/* ================================================================== forms: use the width, not the height */
@media (min-width: 1200px) {
  body:has(form .grid-2), body:has(form .grid-3) { --form-cols: 1; }
  form .grid-2, form .grid-3 { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 16px; }
  form .card.stack > * + *, form.card.stack > * + * { margin-top: 12px; }
  form .card, form.card { padding: 18px 22px; }
  form details.card:not([open]) { padding-top: 12px; padding-bottom: 12px; }
  form .field__hint { font-size: 12.5px; }
}
/* Item kind picker: one slim row */
.role-cards, .kind-cards { gap: 8px !important; }
.grid-contents { display: contents; }
/* Party form: who they are + GSTIN on one line */
@media (min-width: 1200px) {
  .role-pick { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
  .role-pick__head { display: contents; }
  .role-pick__hint { order: 3; flex: 1 1 100%; margin-top: -4px; color: var(--c-text-3); font-size: 12.5px; }
  .gstin-box .input--big { min-height: 44px; font-size: 16px; }
}
/* Every form: the Save row stays in view */
@media (min-width: 900px) {
  form .form-actions, form > .row:last-child:has(> .btn--primary[type=submit]) { position: sticky; bottom: 0; z-index: 5; margin-top: 12px; padding: 10px 0 12px;
    background: linear-gradient(180deg, transparent 0, var(--c-bg) 14px); }
}

/* ---------------------------------------------------------------- v0.29 */
/* Forms on one sheet: a dense 3-column grid instead of a tall stack of fields. */
.form-sheet { background: var(--c-surface); border-radius: var(--r-lg); box-shadow: var(--shadow-1); padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.form-grid { display: grid; gap: 12px 16px; grid-template-columns: 1fr; }
.form-grid .field { margin: 0; }
@media (min-width: 720px) { .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .form-grid .span-2, .form-grid .span-3 { grid-column: span 2; } }
@media (min-width: 1100px) { .form-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .form-grid--3 .span-3 { grid-column: span 3; } }
.suffix-field { display: flex; align-items: stretch; }
.suffix-field .input { border-radius: var(--r-md) 0 0 var(--r-md); }
.suffix-field__suffix { display: inline-flex; align-items: center; padding: 0 10px; border-radius: 0 var(--r-md) var(--r-md) 0; background: var(--c-surface-2); color: var(--c-text-2); font-size: 13px; white-space: nowrap; box-shadow: inset 0 0 0 1px var(--c-border); }
.note-line { display: flex; align-items: center; gap: 8px; margin: 0 0 var(--s-3); padding: 8px 12px; border-radius: var(--r-md); background: var(--c-accent-soft); color: var(--c-text); font-size: 13.5px; }
.note-line .icon { color: var(--c-gold); flex: none; }
.menu--form { min-width: 300px; padding: 14px 16px; }
.menu__title { margin: 0 0 4px; font-weight: 700; }
.inline-form { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.inline-form .input { min-height: 32px; max-width: 140px; }
.input--auto { width: auto !important; }
.input--xs { width: 90px !important; min-height: 34px; }
.block { display: block; }
.btn--block { width: 100%; justify-content: center; }
.fold { margin: var(--s-3) 0; }
.fold > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-weight: 650; font-size: 13.5px; color: var(--c-text-2); padding: 4px 2px; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::after { content: "▾"; font-size: 11px; opacity: .6; transition: transform var(--t-fast); }
.fold[open] > summary::after { transform: rotate(180deg); }
.fold--inline { margin: 6px 0 0; }
.table--compact th, .table--compact td { padding: 7px 12px; }
.table--rows tbody tr:hover { background: var(--c-surface-2); }
.table .th-group { text-align: center; border-bottom: 1px solid var(--c-border); }
.table tr.tr-total td { background: var(--c-surface-2); font-weight: 650; }
.table tr.is-struck td { color: var(--c-text-3); text-decoration: line-through; }
.kv--tight { gap: 6px 12px; font-size: 13.5px; }
.kv--tight dd { text-align: right; overflow-wrap: anywhere; }
.stat-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: var(--s-3); }
.stat { background: var(--c-surface); border-radius: var(--r-lg); box-shadow: var(--shadow-1); padding: 12px 16px; display: flex; flex-direction: column; gap: 2px; }
.stat small { color: var(--c-text-2); font-size: 12px; font-weight: 600; }
.stat strong { font-family: var(--font-num); font-size: 1.25rem; }
.stat--accent { background: linear-gradient(135deg, var(--c-accent-soft), var(--c-surface)); }
.advance-note--gold .advance-note__icon { color: var(--c-gold); }
/* Settings pages: two columns of cards, the wide table across both. */
.settings-grid { display: grid; gap: 14px; align-items: start; }
.settings-grid > .card { margin: 0; }
@media (min-width: 1100px) { .settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .settings-grid > .span-all { grid-column: 1 / -1; } }
/* Party page: statement left, the party right. */
.party-layout .stmt-bar { margin-bottom: 8px; }
.stmt-bar .date-pair { display: inline-flex; align-items: center; gap: 6px; }
.stmt-bar .date-pair .input { width: auto; min-height: 34px; }
@media (min-width: 1200px) { .party-layout .stmt-wrap { max-height: calc(100vh - 260px); overflow: auto; } .party-layout .stmt-wrap thead th { position: sticky; top: 0; z-index: 1; } }
.party-bal { font-size: 1.9rem; font-weight: 800; font-family: var(--font-num); line-height: 1.15; }
.party-actions { margin-top: 10px; flex-wrap: wrap; }
.setoff { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--c-border); display: flex; flex-direction: column; gap: 8px; }
.setoff__sides { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.setoff__sides span { display: flex; flex-direction: column; }
.setoff__sides small { color: var(--c-text-2); font-size: 11.5px; }
.loyalty-card__head { display: flex; align-items: center; gap: 8px; font-weight: 650; }
.loyalty-card__head .icon { color: var(--c-gold); }
.loyalty-card__head strong { margin-left: auto; font-size: 1.3rem; font-family: var(--font-num); }
.mini-list { list-style: none; margin: 6px 0 0; padding: 0; font-size: 12.5px; }
.mini-list li { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--c-border); }
.mini-list li:last-child { border-bottom: 0; }
.mini-list .neg { color: var(--c-danger); }
.bill-total__fx { display: block; margin-top: 2px; }
/* Segmented tabs (v0.29): several things in one place, one shown at a time. */
.seg-tabs { display: flex; gap: 2px; padding: 3px; border-radius: var(--r-pill); background: var(--c-surface-2); margin-bottom: 10px; overflow-x: auto; scrollbar-width: none; }
.seg-tabs__btn { flex: 1 0 auto; min-height: 32px; padding: 0 12px; border: 0; border-radius: var(--r-pill); background: none; font: inherit; font-size: 12.5px; font-weight: 650; color: var(--c-text-2); cursor: pointer; white-space: nowrap; }
.seg-tabs__btn:hover { color: var(--c-text); }
.seg-tabs__btn.is-on { background: var(--c-surface); color: var(--c-text); box-shadow: var(--shadow-1); }
.list--flat { box-shadow: none; background: none; }
.list--flat .list__item { padding: 8px 4px; min-height: 0; }
.dash-tabs .health, .dash-tabs .card { box-shadow: none; padding: 0; margin: 0; background: none; }
/* Dashboard on a laptop: the whole picture in one screen. */
@media (min-width: 1200px) {
  body:has(.dash) .content { max-width: 1480px; }
  .dash-head { padding: 16px 22px 14px; margin: 0 0 12px; gap: 12px; }
  .dash-head__name { font-size: 2rem; }
  .dash-head__meta { margin-top: 8px; }
  .dash-search { min-height: 44px; }
  .quick { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-bottom: 12px; }
  .quick__tile { flex-direction: row; justify-content: flex-start; gap: 8px; padding: 8px 10px; text-align: left; }
  .quick__icon { width: 32px; height: 32px; border-radius: 10px; }
  .quick__icon .icon { width: 17px; height: 17px; }
  .quick__label { font-size: 12px; }
  .dash { grid-template-columns: minmax(0, 1fr) 340px; gap: 14px; }
  .dash .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px !important; }
  .dash .tile { padding: 10px 14px; }
  .dash .tile__q { font-size: 12px; }
  .dash .tile__v { font-size: 1.35rem; }
  .dash .tile__s { font-size: 11.5px; }
  .dash .scan-box { margin-bottom: 12px; }
  .dash-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 12px; align-items: stretch; }
  .dash-pair > * { margin: 0 !important; }
  .dash-pair #home-chart-card { display: flex; flex-direction: column; }
  .dash-pair .home-chart { flex: 1; min-height: 150px; }
  .dash-pair .dash-feed .feed { max-height: 268px; overflow-y: auto; scrollbar-width: thin; }
  .dash-pair .feed__row { padding: 7px 2px; }
  .dash__side > * + * { margin-top: 12px; }
  .dash-ai { padding: 14px 16px; }
  .dash-ai__chips { margin: 10px 0; }
  .dash-ai__chip { min-height: 34px; padding: 6px 12px; }
  .dash-tabs [data-panel] { max-height: 300px; overflow-y: auto; scrollbar-width: thin; }
}
@media (min-width: 1200px) {
  .dash .tiles { grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); }
  .dash .tile__v { font-size: 1.2rem; }
  .dash .scan-box--compact .scan-box__drop { padding: 8px 12px; }
  .dash .scan-box--compact .scan-box__icon { width: 34px; height: 34px; }
  .dash .scan-box--compact .scan-box__free, .dash .scan-box--compact .scan-box__foot:empty { display: none; }
  .dash .scan-box--compact .scan-box__foot { padding-top: 0; font-size: 11.5px; }
}
@media (min-width: 1200px) {
  .dash-head { padding: 12px 20px 12px; }
  .dash-head__name { font-size: 1.75rem; }
  .dash-head__hello { font-size: 11px; }
  .dash .tile__q { font-size: 11.5px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .dash .tile__s { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .dash-pair .dash-feed .feed { max-height: 216px; }
  .dash-pair .home-chart { min-height: 120px; }
  .dash-ai__chip:nth-child(n+4) { display: none; }
  .dash-ai__sub { display: none; }
  .dash-tabs [data-panel] { max-height: 214px; }
}
@media (min-width: 1200px) {
  .dash .tile__q { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; min-height: 2.6em; }
  .dash .tile { padding: 9px 12px; }
  .dash-pair .dash-feed .feed { max-height: 196px; }
  body:has(.dash) .content { padding-bottom: 12px; }
}
/* Reports index (v0.29): all reports in one screen. */
body:has(.report-index) .content { max-width: 1480px; }
.report-find { max-width: 360px; flex: 1 1 260px; }
.report-note { display: flex; align-items: center; gap: 6px; margin: 0 0 10px; }
.report-note .icon { color: var(--c-gold); }
.report-index { display: grid; gap: 14px 16px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); align-items: start; }
.report-col { background: var(--c-surface); border-radius: var(--r-lg); box-shadow: var(--shadow-1); padding: 12px 8px 8px; }
.report-col__title { display: flex; align-items: center; gap: 8px; margin: 0 8px 6px; font-size: 12px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; color: var(--c-text-2); }
.report-col__title .icon { color: var(--c-gold); }
.report-link { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 8px; border-radius: 9px; color: var(--c-text); text-decoration: none; font-size: 14px; font-weight: 550; }
.report-link .icon { opacity: 0; color: var(--c-text-3); transition: opacity var(--t-fast); }
.report-link:hover { background: var(--c-accent-soft); }
.report-link:hover .icon { opacity: 1; }
.report-link[hidden] { display: none; }
.health-fold { margin: 0 0 10px; }
.health-fold > summary { list-style: none; cursor: pointer; }
.health-fold > summary::-webkit-details-marker { display: none; }
.health-fold[open] .health-strip__more .icon { transform: rotate(180deg); }
.health-fold #health { margin-top: 8px; }
.health-strip { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; padding: 10px 16px; border-radius: var(--r-lg); background: var(--c-surface); box-shadow: var(--shadow-1); }
.health-strip__score { font-family: var(--font-num); font-size: 1.5rem; font-weight: 800; line-height: 1; }
.health-strip__score small { font-size: 12px; color: var(--c-text-3); font-weight: 600; }
.health-strip__score.is-ok { color: var(--c-ok); } .health-strip__score.is-warn { color: var(--c-warn); } .health-strip__score.is-bad { color: var(--c-danger); }
.health-strip__label { font-weight: 700; }
.health-strip__part { display: flex; flex-direction: column; min-width: 0; }
.health-strip__part small { font-size: 11px; color: var(--c-text-2); }
.health-strip__part strong { font-size: 13px; }
.health-strip__more { margin-left: auto; color: var(--c-text-3); }
.report-index { display: block; columns: 232px; column-gap: 16px; }
.report-col { break-inside: avoid; display: inline-block; width: 100%; margin: 0 0 14px; }
.report-col[hidden] { display: none; }
@media (min-width: 1200px) { .report-index { column-count: 4; } .report-link { padding: 6px 8px; font-size: 13.5px; } .report-col { padding: 10px 6px 6px; } }
@media (min-width: 1750px) { .report-index { column-count: 5; } }
.report-index { display: grid; columns: auto; column-count: auto; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; align-items: start; }
.report-stack { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.report-col { display: block; margin: 0; }
@media (min-width: 1200px) { .report-index { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
/* Cash & Bank (v0.29): accounts and recent money side by side. */
.money-grid { display: grid; gap: 14px; }
.money-grid > section { min-width: 0; }
.money-grid .section-title { margin-top: 0; }
@media (min-width: 1200px) {
  body:has(.money-grid) .content { max-width: 1480px; }
  .money-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
  .money-grid .list { max-height: calc(100vh - 372px); overflow-y: auto; scrollbar-width: thin; }
  .money-grid .list__item { min-height: 0; padding: 9px 14px; }
}
/* Settings home (v0.29): three columns, sign out in the header. */
@media (min-width: 1200px) {
  body:has(.settings-home) .content { max-width: 1480px; }
  body:has(.settings-home) .list--grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  body:has(.settings-home) .list--grid > *:nth-child(odd) { border-right: 0; }
  body:has(.settings-home) .list--grid > *:not(:nth-child(3n)) { border-right: 1px solid var(--c-line-2); }
  body:has(.settings-home) .list--grid .list__item { min-height: 0; padding: 12px 14px; }
}
/* Settings pages with tabs (v0.29). */
body:has(.settings-tabs) .content { max-width: 1480px; }
.settings-tabs { display: flex; flex-direction: column; gap: 12px; }
.seg-tabs--page { align-self: flex-start; margin: 0; padding: 4px; }
.seg-tabs--page .seg-tabs__btn { min-height: 36px; padding: 0 18px; font-size: 13.5px; }
.settings-grid > .card:only-child, .settings-grid > .card.span-all { grid-column: 1 / -1; }
.settings-tabs .form-actions { position: sticky; bottom: 0; z-index: 5; padding: 10px 0; background: linear-gradient(to top, var(--c-bg) 70%, transparent); }
.txs-numbers { display: grid; gap: 14px; }
@media (min-width: 1100px) { .txs-numbers { grid-template-columns: 1fr 1fr; } }
.txs-numbers .table td, .txs-numbers .table th { padding: 6px 10px; }
.txs-numbers .input { min-height: 34px; }
.stack-col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.stack-col > .card { margin: 0; }
.settings-tabs .card { padding: 16px 18px; }
.settings-tabs .check { padding: 2px 0; }
.settings-tabs .stack { gap: 10px; } .settings-tabs .form-actions { padding: 6px 0; }
/* Features (modules): a grid of switches, not a long list. */
body:has(.modules-form) .content { max-width: 1480px; }
.module-grid { border: 0; padding: 0; margin: 0; display: grid; gap: 8px 14px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.module-pick { padding: 10px 12px !important; border-radius: var(--r-md); box-shadow: inset 0 0 0 1px var(--c-border); align-items: flex-start; }
.module-pick:has(input:checked) { box-shadow: inset 0 0 0 1.5px var(--c-accent); background: var(--c-accent-soft); }
.module-grid { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); } .module-pick { background: var(--c-surface); } .modules-form .form-actions { position: sticky; bottom: 0; padding: 8px 0; background: linear-gradient(to top, var(--c-bg) 70%, transparent); }
/* Party form (v0.29): who + GSTIN on one line; the extra sections side by side, closed. */
.fold-row { display: grid; gap: 12px; }
.fold-row > details { margin: 0 !important; }
@media (min-width: 1100px) {
  .party-top { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 18px; align-items: start; }
  .party-top .role-pick__head { flex-direction: column; align-items: flex-start; gap: 2px; }
  .party-top .role-pick__hint { text-align: left; }
  .fold-row { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; }
  .fold-row > details[open] { grid-column: 1 / -1; order: -1; }
  .fold-row > details > summary { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .fold-row > details > summary .muted { display: none; }
}
@media (min-width: 1100px) {
  .party-top .role-pick { display: grid; grid-template-columns: auto; justify-items: start; gap: 8px; }
  .party-top .role-pick__label { order: 0; }
  .party-top .role-pick__seg { order: 1; margin: 0; }
  .party-top .role-pick__hint { order: 2; margin: 0; }
  #party-form .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .fold-row > details > summary { flex-wrap: nowrap; }
}
.ind-fields--bare { border: 0; padding: 0; margin: 0; }
[data-hsn-suggest] { min-height: 30px !important; padding: 0 10px !important; font-size: 12.5px; }
@media (min-width: 1100px) { #item-form .fold-row, form .fold-row { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); } }
@media (min-width: 1200px) {
  .party-layout .stmt-wrap { max-height: calc(100vh - 330px); }
  .stmt-bar { flex-wrap: nowrap; }
  .stmt-bar .date-pair .input { width: 150px; padding-inline: 10px; }
  .party-layout .doc-side { max-height: calc(100vh - 170px); }
}
@media (min-width: 1200px) { .party-layout .doc-side { max-height: calc(100vh - 236px); padding-bottom: 8px; } }
.settings-2col { display: grid; gap: 14px; align-items: start; }
.settings-2col .section-title { margin: 6px 2px 0; }
.settings-2col .stack-col > form.card, .settings-2col .stack-col > .card { margin: 0; }
@media (min-width: 1100px) { body:has(.settings-2col) .content { max-width: 1480px; } .settings-2col { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
/* Invoice templates (v0.29): options in tabs on the left, the live preview on the right — one screen. */
@media (min-width: 1100px) {
  .tpl-studio--tabs { grid-template-areas: "tabs stage" "pick stage" "opts stage"; }
  .tpl-studio--tabs .tpl-tabbar { margin: 0; }
  .tpl-studio--tabs .tpl-pick, .tpl-studio--tabs .tpl-opts > fieldset { max-height: calc(100vh - 300px); overflow-y: auto; scrollbar-width: thin; }
  .tpl-studio--tabs .tpl-stage { position: sticky; top: 76px; }
  .tpl-studio--tabs .tpl-viewport { max-height: calc(100vh - 200px); overflow: auto; }
}
.tpl-studio--tabs [data-panel][hidden] { display: none !important; }
.tpl-tabbar .seg-tabs__btn { padding: 0 9px; font-size: 12px; }
.seg-tabs--page { max-width: 100%; }
.stmt-bar .date-pair { flex-wrap: wrap; max-width: 100%; } .stmt-bar .date-pair .input { min-width: 0; flex: 1 1 130px; }
/* Stock count (v0.30) */
@media (min-width: 1200px) { .count-wrap { max-height: calc(100vh - 290px); overflow: auto; } .count-wrap thead th { position: sticky; top: 0; z-index: 1; } }
#count-sheet tr.is-muted td { color: var(--c-text-3); }
#count-sheet .is-ok { color: var(--c-ok); font-weight: 700; }
#count-sheet .is-plus { color: var(--c-ok); font-weight: 700; }
#count-sheet .is-minus { color: var(--c-danger); font-weight: 700; }
#count-form .form-actions { display: flex; align-items: center; gap: 12px; }
.prefix-field__prefix { white-space: nowrap; }

/* v0.30.1: long row lists scroll inside their card so the page itself fits one screen (item history, data page) */
.scroll-rows { max-height: max(240px, calc(100vh - 580px)); overflow: auto; overscroll-behavior: contain; }
.scroll-rows thead th { position: sticky; top: 0; z-index: 1; background: var(--c-surface); }
