/* Saasya Men cockpit v2: only the pieces Picasso's kit does not cover.
   The look is HIS: design/tokens.css + design/kit.css load after this file and own every shared class.
   Colours and type come ONLY from his tokens (CONTRACT section 2): no raw hex, no fixed font sizes, so a
   theme (dark, light, ivory, midnight) or a change to the type scale reaches every piece here too.
   Meaning that must survive any skin: aria-current marks where you are; data-level on a bell row;
   data-days-left on a bin row; a Low chip is red with its word; gold is the signature only. */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: 16px; background: var(--bg); }
.gate-card { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 14px; padding: 32px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-xl); box-shadow: var(--shadow-2); }
.gate-card h1 { font-size: var(--fs-section); margin-top: 8px; }
.gate-card form { display: flex; flex-direction: column; gap: 12px; }
.gate-card .btn--primary { width: 100%; }
/* Pause notice only. The sign-in card above is unchanged. One sentence, a quiet reload. */
.gate-card--pause { max-width: 440px; gap: 0; padding: 0; overflow: hidden; }
.gate-card--pause::before { content: ""; display: block; height: 2px; background: var(--gold); }
.pause-line { margin: 0; padding: var(--s-8) var(--s-8) var(--s-6); font-size: var(--fs-card); font-weight: var(--w-regular); line-height: var(--lh); letter-spacing: var(--track-body); color: var(--ink); text-wrap: pretty; }
.pause-foot { display: flex; justify-content: flex-end; padding: var(--s-3) var(--s-5) var(--s-5); border-top: 1px solid var(--line); }
.gate-card--pause .btn { width: auto; }
.error { color: var(--red-ink); min-height: 1.2em; font-size: var(--fs-small); margin: 0; }
.loading { padding: 40px; color: var(--ink-2); }

.myday-hello { font-size: var(--fs-section); font-weight: var(--w-semi); }
.myday { display: flex; flex-direction: column; gap: 8px; }
.myday .empty { margin-top: 16px; border: 1px dashed var(--line-2); border-radius: var(--r-lg); }
.empty-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); justify-content: center; }
.empty-actions .btn { margin-top: 0; }
.cards { display: flex; flex-direction: column; gap: 16px; max-width: 760px; }
.cards .dcard { display: flex; flex-direction: column; gap: 10px; }

.filter-bar { margin: 4px 0 16px; display: flex; flex-direction: column; gap: 8px; }
.filter-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filter-search { flex: 1 1 220px; }
.filter-row .filter-select { flex: 0 0 auto; max-width: 100%; width: auto; min-width: 190px; }   /* as wide as its longest choice: a label is never clipped (15 Oct) */
.filter-date { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-label); color: var(--ink-2); }
.filter-foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filter-count { color: var(--ink-3); font-size: var(--fs-label); }
.filter-foot .chip button { color: inherit; margin-left: 2px; }
.filter-add { display: flex; flex-direction: column; gap: 12px; }

.bin-list, .file-list, .bell-list, .members { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.bin-row, .file-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px; border-radius: var(--r-sm); }
.bin-row:hover, .file-row:hover { background: var(--hover); }
.bin-row > div { flex: 1 1 260px; min-width: 0; }
.file-name { flex: 1 1 180px; font-weight: var(--w-medium); min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.file-thumb { width: 40px; height: 40px; object-fit: cover; border-radius: var(--r-xs); background: var(--card-2); flex: none; }
.files { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.files .file-list { align-self: stretch; }
.members li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.members a { color: var(--ink); font-weight: var(--w-medium); }

.panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100%); z-index: 60; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 18px 22px; background: var(--raised); border-left: 1px solid var(--line-2); box-shadow: var(--shadow-3); }
.panel-head { display: flex; justify-content: space-between; align-items: center; }

.bell-feeds { display: grid; gap: 18px; }
.bell-feeds h3 { font-size: var(--fs-body); margin-bottom: 6px; }
.bell-row { display: flex; flex-direction: column; gap: 2px; padding: 8px 0; font-size: var(--fs-small); }
.bell-row[data-level="error"] b { color: var(--red-ink); }
.bell-row[data-level="warn"] b { color: var(--orange-ink); }
.share-url { width: 100%; }
.share-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.update-notice { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 9999; display: flex; gap: 14px; align-items: center; padding: 10px 10px 10px 16px; background: var(--raised); color: var(--ink); border: 1px solid var(--line-2); border-radius: var(--r-lg); box-shadow: var(--shadow-3); font-size: var(--fs-small); }
/* JOB 14: the Owner-only grace banner, kept quiet */
.lic-grace { margin: 0 0 12px; padding: 8px 14px; background: var(--raised); color: var(--muted); border: 1px solid var(--line-2); border-radius: var(--r-md); font-size: var(--fs-small); }

/* forms */
.modal:has(.form-grid), .modal:has(.table-wrap) { width: min(760px, calc(100vw - 32px)); }
.modal-body { overflow-y: auto; }
.modal-body form { display: flex; flex-direction: column; gap: var(--s-4); }
.modal-foot .spacer, .form-actions .spacer, .dcard-head > .spacer { flex: 1; }   /* JOB 12 Part B: a card's button sits at the head's right edge */
.t-note { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }   /* a long Note ends in an ellipsis; the full text on hover and in the form */
.modal-foot { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
.form-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.phone-field { display: grid; grid-template-columns: minmax(96px, 40%) 1fr; gap: var(--s-2); }
.form-actions { display: flex; justify-content: flex-end; margin-top: var(--s-4); }
.details-form .dcard { display: flex; flex-direction: column; gap: var(--s-4); }
.logo-preview { max-width: 180px; max-height: 120px; object-fit: contain; border-radius: var(--r-sm); background: var(--card-2); padding: var(--s-2); }
.new-hh, .new-vendor { padding: var(--s-4); border: 1px dashed var(--line-2); border-radius: var(--r-md); }

/* lists and records */
.row-link { cursor: pointer; }
.row-link:hover td { background: var(--hover); }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3) var(--s-5); margin: 0; }
.facts dt { color: var(--ink-3); font-size: var(--fs-label); }
.facts dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.section-title { font-size: var(--fs-card); margin: var(--s-8) 0 var(--s-1); }
.impact { margin: var(--s-3) 0; padding-left: var(--s-5); display: flex; flex-direction: column; gap: var(--s-1); }
.vendor-owed { display: flex; align-items: center; gap: var(--s-2); color: var(--ink-2); margin: 0; }

/* measurement sets */
.meas-kind { margin-top: var(--s-5); }
.meas-head { display: flex; align-items: center; gap: var(--s-2); margin-bottom: var(--s-2); }
.meas-table th { vertical-align: bottom; white-space: nowrap; }
.meas-table .btn--link { font-size: var(--fs-label); padding: 0; height: auto; min-height: 0; }
.meas-now { font-weight: 600; font-size: var(--fs-title); color: var(--ink); width: 1%; white-space: nowrap; padding-right: var(--s-5); }
.meas-old { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.meas-table td { vertical-align: middle; }
.meas-was { display: inline-flex; gap: 6px; align-items: baseline; padding: 2px 8px; line-height: 18px; height: 22px; align-self: center; border-radius: 999px; background: var(--card-2); color: var(--ink-2); font-size: var(--fs-label); white-space: nowrap; }
.meas-was b { font-weight: 500; color: var(--ink); }
.meas-sets { margin-top: var(--s-2); }
.meas-sets summary { cursor: pointer; font-size: var(--fs-label); }
.meas-sets ul { margin: var(--s-2) 0 0; padding-left: var(--s-4); font-size: var(--fs-label); }
.meas-fields { display: flex; flex-direction: column; gap: var(--s-2); }

/* fabric stock: lots, codes, scanning, receiving */
.lot-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: var(--w-semi); letter-spacing: .02em; }
.lot-card { display: flex; flex-wrap: wrap; gap: var(--s-6); align-items: flex-start; }
.lot-card .facts { flex: 1 1 280px; }
.lot-codes { display: flex; flex-direction: column; align-items: center; gap: var(--s-2); padding: var(--s-3); background: var(--card-2); border-radius: var(--r-md); }
.lot-codes .qr { width: 112px; height: 112px; }
.lot-codes .bc { width: 180px; height: 44px; }

.scan-box { display: inline-flex; align-items: center; gap: var(--s-2); color: var(--ink-3); }
.scan-box .input { width: 220px; }
.rf-table td { vertical-align: top; }
.rf-table .select { min-width: 220px; }
.rf-table .input.money { width: 110px; }
.rf-new { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-1); margin-top: var(--s-1); }
.rf-total { color: var(--ink-2); }
.cam-reader { width: 100%; max-width: 420px; border-radius: var(--r-md); overflow: hidden; }

/* global search */
.tb-search { position: relative; }
.gs-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; min-width: 320px; z-index: 70; max-height: 60vh; overflow-y: auto; padding: var(--s-1); background: var(--raised); border: 1px solid var(--line-2); border-radius: var(--r-md); box-shadow: var(--shadow-3); }
.gs-row { display: flex; align-items: center; gap: var(--s-2); width: 100%; padding: var(--s-2) var(--s-3); border-radius: var(--r-sm); text-align: left; color: var(--ink); }
.gs-row:hover, .gs-row:focus-visible { background: var(--hover); }
.gs-row b { font-weight: var(--w-medium); }
.gs-row .muted { margin-left: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gs-none { padding: var(--s-3); margin: 0; }

/* Excel */
.sheet-preview { max-height: 50vh; overflow: auto; }
.sheet-errors { padding: var(--s-4); border-radius: var(--r-md); background: var(--red-tint); color: var(--ink); }
.sheet-errors ul { margin: var(--s-2) 0 0; padding-left: var(--s-5); display: flex; flex-direction: column; gap: var(--s-1); }

@media (max-width: 900px) {
  .update-notice { bottom: 84px; }
  .panel { width: 100%; }
  .form-grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .facts { grid-template-columns: 1fr; }
  .scan-box .input { width: 160px; }
  .tb-search { width: auto; flex: 1; }
}

/* a hidden box stays hidden whatever display a kit class gives it (the prototype hit this on Receive fabric) */
[hidden] { display: none !important; }
.modal:has(.rf-table) { width: min(1040px, calc(100vw - 32px)); }
.rf-table .select[name^="rf_g_"] { min-width: 84px; }
.page-head h1:focus, #main h1[tabindex="-1"]:focus { outline: none; box-shadow: none; }
.scan-box .input { width: 190px; }

/* JOB 5 Part 2 (15 Oct): below 640 px every list table shows each row as a card (one shared rule, so every later
   list inherits it): the first cell on its own line, the rest wrap beneath it; columns marked .hide-sm stay hidden */
@media (max-width: 640px) {
  .table-wrap:has(> .table--list) { overflow-x: visible; }
  .table--list thead { display: none; }
  .table--list, .table--list tbody { display: block; }
  .table--list tbody tr { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-1) var(--s-3); padding: var(--s-3); margin-bottom: var(--s-2); background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md); }
  .table--list tbody tr td { display: block; height: auto; padding: 0; white-space: normal; min-width: 0; border-radius: 0 !important; background: none !important; }
  .table--list tbody tr td:first-child { flex: 1 1 100%; }
  .table--list tbody tr td.t-num { margin-left: auto; }
  .table--list tbody tr td[colspan] { flex: 1 1 100%; }
  .filter-bar--closed .filter-row { display: none; }
}
fieldset.plain { border: 0; padding: 0; margin: 0; min-width: 0; }
.vb-brand .toolbar { align-items: flex-end; flex-wrap: wrap; margin: 0; padding: 0; border: 0; }
.vb-brand .field { flex: 1 1 220px; }
.filter-bar .filter-toggle { display: none; }
@media (max-width: 640px) { .filter-bar .filter-toggle { display: inline-flex; } }
/* the shared rupee input inside a GRC grid cell (Captain's gate, 15 Oct): ₹ sits inside the cell */
.cell-rs { position: relative; display: block; }
.cell-rs > span { position: absolute; left: 8px; top: 50%; transform: translateY(-50%); color: var(--ink-3); font-size: var(--fs-small); pointer-events: none; }
.cell-rs .cell-in { padding-left: 20px; }

/* Part 6 (Captain C): a link inside muted text reads as a link: the kit's link colour (.btn--link, .drop-file a) + hover underline */
.t-link { color: var(--gold-ink); font-weight: var(--w-semi); }
.t-link:hover, .t-link:focus-visible { text-decoration: underline; text-underline-offset: 2px; }
/* Part 6: Purchase return. The scan box sits in the GRC bar; a roll's metres are a short number field with its unit */
.ret-scan { display: flex; gap: var(--s-2); align-items: center; flex: 1 1 280px; max-width: 420px; }
.ret-scan .input { flex: 1; min-width: 0; }
.ret-m { display: inline-flex; align-items: center; gap: 6px; }
.ret-m .input { width: 92px; text-align: right; }
.ret-pick { display: grid; gap: var(--s-2); max-height: 50vh; overflow: auto; }
.reports-pick { display: grid; gap: var(--s-2); justify-items: start; }
.rep-row { display: flex; gap: var(--s-2); align-items: center; width: 100%; max-width: 420px; }
.rep-row .select { flex: 1; }
.ret-pick-row { display: flex; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; }
.lg-returned { font-size: var(--fs-meta); padding: 0 8px 4px; }

/* JOB 9 (16 Oct): Roles and access. Wide: the role name stays in view while the items scroll. Phones: each role is a
   card (the shared list rule) and every item carries its own label. */
.table--roles th:first-child, .table--roles td:first-child { position: sticky; left: 0; z-index: 1; background: var(--card); }
.table--roles th { white-space: normal; min-width: 96px; vertical-align: bottom; }
.table--roles td .select { min-width: 210px; }
.table--roles td .input[data-change="roleDisc"] { width: 88px; text-align: right; }   /* JOB 11 Part B: Discount without asking, up to % */   /* the choice reads in full: "Own and their team's", "Fabric in metres only" */
@media (max-width: 640px) {
  .table--roles th:first-child, .table--roles td:first-child { position: static; }
  .table--roles td[data-label] { flex: 1 1 45%; }
  .table--roles td .select { min-width: 0; width: 100%; }
  .table--roles td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 2px; font-size: var(--fs-label); color: var(--ink-3); }
}

/* JOB 11 Part C: the Counter sale. A discount is a number with Rs or % beside it; a payment row is How, how much, reference */
.cs-disc { display: flex; gap: var(--s-2); align-items: center; }
.cs-disc .input { width: 96px; min-width: 0; }
.cs-disc .select { width: auto; min-width: 64px; }
[data-bb-lines] .cs-disc .input { width: 56px; }
.cap-sm { display: none; }   /* JOB 11 Part G: a figure's column name, shown only on the phone card */
@media (max-width: 640px) { .cap-sm { display: inline; color: var(--ink-3, inherit); } }   /* JOB 11 G1: the B2B line table fits its card at 1280 */
.cs-pay { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1.3fr) auto; gap: var(--s-2); margin: var(--s-2) 0; align-items: center; }
.cs-sum td { padding: 6px 10px; }
@media (max-width: 640px) {
  [data-cs-form] > .dcard { grid-column: span 12; }
  .cs-pay { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  [data-cs-line] td .select { max-width: 100%; }
}
.toolbar .cs-scan { flex: 1 1 220px; max-width: 360px; }
[data-cs-line] select[name=hsn] { min-width: 118px; }
/* JOB 12 Part C fold-in: a figure that opens its rows (Money in and out, By How / By day) sits flush right under its right-aligned heading */
.table td.t-num > .btn--ghost.money { padding-inline: 0; }

/* JOB 12 Part D: the stock count scan box holds its whole placeholder; on a phone it takes the row */
.sc-scan .scan-box .input { width: 300px; }
@media (max-width: 640px) { .sc-scan .scan-box { flex: 1 1 100%; } .sc-scan .scan-box .input { width: 100%; } }

/* JOB 12 Part F fold-ins. Tally export, Sales side at 1280+: the table is wider than the page, so it scrolls sideways inside its
   box with a scrollbar you can see, and Date, Kind and Number stay put while the figures move. Phones keep the card rows. */
@media (min-width: 641px) {
  .table-wrap[data-ts-wrap] { overflow: auto; max-height: max(280px, calc(100vh - 480px)); padding-bottom: var(--s-2); scrollbar-width: auto; scrollbar-color: var(--ink-3) var(--line); }
  [data-ts-wrap] thead th { position: sticky; top: 0; z-index: 2; background: var(--bg); }
  .table-wrap[data-ts-wrap]::-webkit-scrollbar { height: 12px; width: 12px; }
  .table-wrap[data-ts-wrap]::-webkit-scrollbar-track { background: var(--line); border-radius: var(--r-full); }
  .table-wrap[data-ts-wrap]::-webkit-scrollbar-thumb { background: var(--ink-3); border-radius: var(--r-full); }
  [data-ts-wrap] td:nth-child(-n+3) { position: sticky; z-index: 1; background: var(--bg); }
  [data-ts-wrap] thead th:nth-child(-n+3) { z-index: 3; }
  [data-ts-wrap] th:nth-child(1), [data-ts-wrap] td:nth-child(1) { left: 0; min-width: 112px; }
  [data-ts-wrap] th:nth-child(2), [data-ts-wrap] td:nth-child(2) { left: 112px; min-width: 116px; }
  [data-ts-wrap] th:nth-child(3), [data-ts-wrap] td:nth-child(3) { left: 228px; min-width: 196px; box-shadow: 1px 0 0 var(--line); }
}
/* Our details > Tally ledger names: room for a real Tally name (about 30 characters) */
[data-ledger-name] { width: 100%; min-width: 30ch; }
