/* Lane IV2. Shared tokens for the sales redesign (Invoices + Receipts, list / create / view).
   Tokens mirror design/handoff-sales/README.md and are reused via plain CSS variables so Razor
   markup can stay close to the design without inlining colours. */

:root {
    --nb-page:        #F4F7EF;
    --nb-canvas:      #E9EDE5;
    --nb-surface:     #FFFFFF;
    --nb-ink:         #1C2A11;
    --nb-muted:       #4B5545;
    --nb-subtle:      #6B7563;
    --nb-disabled:    #9AA693;

    --nb-primary:     #314025;
    --nb-primary-hv:  #26331C;
    --nb-sage:        #BACCA8;
    --nb-leaf:        #7A9E5A;

    --nb-border:      #DDE5D4;
    --nb-input:       #CDD6C5;
    --nb-focus:       #E3EEDA;

    /* Status colour pairs: background on left, text on right. */
    --nb-paid-bg:     #E3EEDA;  --nb-paid-fg:    #2F6B1F;
    --nb-pending-bg:  #FFF4D6;  --nb-pending-fg: #8A5A00; --nb-pending-bd: #E8C46A;
    --nb-unpaid-bg:   #FDECEA;  --nb-unpaid-fg:  #B42318;
    --nb-overdue-bg:  #FDE9DA;  --nb-overdue-fg: #A0430A;
    --nb-void-bg:     #EEF0EC;  --nb-void-fg:    #4B5545;
}

/* Container sizing from the handoff: 32px page padding on laptop, 24 tablet, 16 phone. */
.sales-page    { background: var(--nb-page); min-height: 100vh; padding: 32px; }
@media (max-width: 1023px) { .sales-page { padding: 24px; } }
@media (max-width:  767px) { .sales-page { padding: 16px; } }

.sales-card    { background: var(--nb-surface); border: 1px solid var(--nb-border); border-radius: 12px; padding: 16px; }
.sales-shell   { max-width: 1200px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; color: var(--nb-ink); }
.sales-h1      { font-size: 26px; font-weight: 700; color: var(--nb-primary); line-height: 1.15; margin: 0; }
@media (max-width: 767px) { .sales-h1 { font-size: 22px; } }
.sales-section-title { font-size: 16px; font-weight: 700; color: var(--nb-ink); margin: 0; }
.sales-label   { font-size: 13px; font-weight: 700; color: var(--nb-muted); }
.sales-help    { font-size: 13px; color: var(--nb-muted); }

/* Inputs, buttons: 44px tall, 8px radius. */
.sales-input, .sales-select, .sales-btn {
    height: 44px; border-radius: 8px; border: 1px solid var(--nb-input); background: var(--nb-surface);
    padding: 0 12px; font-size: 14px; color: var(--nb-ink); outline: none;
}
.sales-input:focus, .sales-select:focus { box-shadow: 0 0 0 3px var(--nb-focus); border-color: var(--nb-primary); }

.sales-btn-primary { background: var(--nb-primary); color: #fff; border-color: var(--nb-primary); font-weight: 700; }
.sales-btn-primary:hover:not(:disabled) { background: var(--nb-primary-hv); }
.sales-btn-primary:disabled { background: var(--nb-disabled); border-color: var(--nb-disabled); cursor: not-allowed; }
.sales-btn-ghost   { background: var(--nb-surface); color: var(--nb-primary); border-color: var(--nb-input); font-weight: 700; }
.sales-btn-ghost:hover  { background: var(--nb-focus); }

/* Status pill. One source of truth; used by every list and view. */
.sales-pill    { display: inline-flex; align-items: center; height: 22px; padding: 0 10px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: 0.2px; }
.sales-pill--paid    { background: var(--nb-paid-bg);    color: var(--nb-paid-fg); }
.sales-pill--pending { background: var(--nb-pending-bg); color: var(--nb-pending-fg); }
.sales-pill--unpaid  { background: var(--nb-unpaid-bg);  color: var(--nb-unpaid-fg); }
.sales-pill--overdue { background: var(--nb-overdue-bg); color: var(--nb-overdue-fg); }
.sales-pill--void    { background: var(--nb-void-bg);    color: var(--nb-void-fg); }
.sales-pill--refunded{ background: var(--nb-void-bg);    color: var(--nb-void-fg); }

/* Chips: 999px radius for payment term pills, unit chips. */
.sales-chip    { display: inline-flex; align-items: center; height: 28px; padding: 0 12px; border-radius: 999px; background: var(--nb-focus); color: var(--nb-primary); font-size: 12px; font-weight: 700; border: 1px solid var(--nb-border); }
.sales-chip--on { background: var(--nb-primary); color: #fff; border-color: var(--nb-primary); }

/* Error / warning banners (used by the Create forms' error list and stock refusal). */
.sales-banner  { border: 1px solid var(--nb-border); border-radius: 8px; padding: 12px 14px; font-size: 13px; }
.sales-banner--error   { background: var(--nb-unpaid-bg); color: var(--nb-unpaid-fg); border-color: #F6BDBD; }
.sales-banner--warning { background: var(--nb-pending-bg); color: var(--nb-pending-fg); border-color: var(--nb-pending-bd); }

/* Live badge (list pages). */
.sales-live    { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--nb-muted); }
.sales-live::before { content: ""; width: 8px; height: 8px; border-radius: 999px; background: var(--nb-leaf); box-shadow: 0 0 0 3px rgba(122,158,90,0.25); }

/* Totals block in the Summary column. */
.sales-total   { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--nb-ink); }

/* Table / list skeleton. */
.sales-skel    { background: linear-gradient(90deg, var(--nb-focus) 0%, var(--nb-canvas) 50%, var(--nb-focus) 100%); background-size: 200% 100%; animation: sales-skel 1.4s infinite; border-radius: 6px; }
@keyframes sales-skel { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* Lane IV4. Layout primitives for the sales pages (lists, create, view). The design frames in
   design/handoff-sales use these consistently; using classes keeps Razor markup close to the
   frames. Breakpoints match the Lane IV4 plan: 1024px (laptop/tablet) and 768px (tablet/phone). */

/* List pages: header band, metric cards, toolbar, show-only chips. */
.sales-page-head { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 12px 20px; }
.sales-page-head__meta { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.sales-metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 1023px) { .sales-metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width:  767px) { .sales-metric-grid { grid-template-columns: 1fr; } }
.sales-metric      { background: var(--nb-surface); border: 1px solid var(--nb-border); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.sales-metric__label { font-size: 12px; font-weight: 700; color: var(--nb-muted); text-transform: uppercase; letter-spacing: 0.4px; }
.sales-metric__value { font-size: 22px; font-weight: 700; color: var(--nb-ink); font-variant-numeric: tabular-nums; letter-spacing: -0.3px; }
.sales-metric__sub   { font-size: 12px; color: var(--nb-subtle); }
.sales-metric__dot   { width: 10px; height: 10px; border-radius: 999px; display: inline-block; }
/* Lane IV5/IV6. Caption that sits under the metric grid: "Totals follow your search and filters."
   Lane IV6 bumps the top/bottom margins so the line has air above (metric cards) and below
   (before the toolbar card), matching the Sales Lists frame. */
.sales-metric__footnote { font-size: 12px; color: var(--nb-subtle); margin: 12px 0 20px; }

/* Lane IV5. Lock + "Business . Branch" subhead on Create Invoice. */
.sales-sub-head { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--nb-muted); margin-top: 4px; }

/* Lane IV5. Discount preset chips (0/5/10/15/20) for item lines. */
.sales-preset-row { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.sales-preset-btn { height: 24px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--nb-input); background: var(--nb-surface); color: var(--nb-primary); font-size: 11px; font-weight: 700; cursor: pointer; }
.sales-preset-btn:hover { background: var(--nb-focus); }
.sales-preset-btn--on { background: var(--nb-primary); color: #fff; border-color: var(--nb-primary); }

.sales-toolbar   { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.sales-toolbar__search { flex: 1 1 260px; display: flex; height: 44px; border: 1px solid var(--nb-input); border-radius: 8px; background: var(--nb-surface); overflow: hidden; }
.sales-toolbar__search input { flex: 1; height: 100%; border: 0; outline: none; padding: 0 12px 0 36px; font-size: 14px; background: var(--nb-surface); color: var(--nb-ink); }
.sales-toolbar__search button { height: 100%; padding: 0 16px; background: var(--nb-primary); color: #fff; border: 0; font-weight: 700; font-size: 14px; cursor: pointer; }
.sales-toolbar__search button:hover { background: var(--nb-primary-hv); }
.sales-toolbar__search-icon { position: absolute; margin: 14px 0 0 12px; pointer-events: none; color: var(--nb-subtle); }

.sales-showonly  { display: flex; flex-wrap: wrap; gap: 6px; }
.sales-showonly__btn { height: 32px; padding: 0 14px; border-radius: 999px; background: var(--nb-surface); border: 1px solid var(--nb-input); color: var(--nb-primary); font-size: 13px; font-weight: 700; cursor: pointer; }
.sales-showonly__btn--on { background: var(--nb-primary); color: #fff; border-color: var(--nb-primary); }

/* Lists: responsive column auto-hide + phone cards.
   Laptop (>=1024): full table.
   Tablet (768-1023): email/start-date hidden (merged under client/number).
   Phone (<768): table hidden, cards shown. */
.sales-colhide-tablet { display: table-cell; }
.sales-sub-tablet     { display: none; }

/* Lane IV6. Keep every column visible at >=1024 by letting Email truncate rather than pushing
   Amount/Status/⋮ off the right edge. The table itself fits inside its container; the inner
   overflow-x:auto wrapper is only a safety net for very narrow screens. */
.sales-list-fit       { width: 100%; }
.sales-cell-ellipsis  { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (min-width: 1024px) and (max-width: 1279px) {
  .sales-cell-ellipsis { max-width: 180px; }
}
@media (max-width: 1023px) {
  .sales-colhide-tablet { display: none; }
  .sales-sub-tablet     { display: block; font-size: 12px; color: var(--nb-subtle); margin-top: 2px; }
}
.sales-list-table   { display: block; }
.sales-list-cards   { display: none; }
@media (max-width: 767px) {
  .sales-list-table { display: none; }
  .sales-list-cards { display: block; }
}
.sales-row-card     { background: var(--nb-surface); border: 1px solid var(--nb-border); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.sales-row-card + .sales-row-card { margin-top: 10px; }
.sales-row-card__top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.sales-row-card__num { font-size: 15px; font-weight: 700; color: var(--nb-primary); }
.sales-row-card__sub { font-size: 12px; color: var(--nb-subtle); }
.sales-row-card__body { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 13px; color: var(--nb-ink); }
.sales-row-card__amt  { font-weight: 700; font-variant-numeric: tabular-nums; }

/* Create / Edit pages: two-column shell with Summary rail on laptop. On tablet/phone the rail
   stacks below the items (natural DOM order: left-content first, rail second). */
.sales-create-shell { display: flex; flex-direction: column; gap: 20px; }
.sales-create-left  { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
@media (min-width: 1024px) {
  .sales-create-shell { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
  .sales-create-rail  { position: sticky; top: 20px; }
}
.sales-rail       { display: flex; flex-direction: column; gap: 16px; }

/* Payment-terms chip row (invoices only). The chips are the design's primary interaction. */
.sales-terms-row  { display: flex; flex-wrap: wrap; gap: 6px; }

/* View pages: coloured header band + document paper. */
.sales-doc-band   { background: var(--nb-primary); color: #fff; border-top-left-radius: 14px; border-top-right-radius: 14px; padding: 20px 24px; display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 10px 20px; }
.sales-doc-band__label { font-size: 11px; letter-spacing: 1.2px; text-transform: uppercase; font-weight: 700; color: var(--nb-sage); }
.sales-doc-band__num   { font-size: 22px; font-weight: 700; }
.sales-doc-band__right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
@media (max-width: 767px) {
  .sales-doc-band  { padding: 18px 16px; }
  .sales-doc-band__right { align-items: flex-start; }
}
.sales-doc-paper  { background: var(--nb-surface); border: 1px solid var(--nb-border); border-bottom-left-radius: 14px; border-bottom-right-radius: 14px; padding: 24px 28px; display: flex; flex-direction: column; gap: 20px; }
@media (max-width: 1023px) { .sales-doc-paper { padding: 24px; } }
@media (max-width:  767px) { .sales-doc-paper { padding: 18px 16px; } }

.sales-doc-grid   { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 767px) { .sales-doc-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.sales-totals-box { background: var(--nb-page); border: 1px solid var(--nb-border); border-radius: 10px; padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; }
.sales-paylink    { border-top: 1px dashed var(--nb-border); padding-top: 12px; margin-top: 8px; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

/* View page: items table on >=768, flex cards on <768. */
.sales-items-wide { display: block; }
.sales-items-cards{ display: none; }
@media (max-width: 767px) {
  .sales-items-wide { display: none; }
  .sales-items-cards{ display: flex; flex-direction: column; gap: 10px; }
}
.sales-item-card  { border: 1px solid var(--nb-border); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.sales-item-card__row { display: flex; justify-content: space-between; gap: 10px; }
.sales-item-card__name{ font-weight: 600; color: var(--nb-ink); }
.sales-item-card__meta{ font-size: 12px; color: var(--nb-subtle); }

/* Not-found card (view pages). */
.sales-notfound   { background: var(--nb-surface); border: 1px solid var(--nb-border); border-radius: 12px; padding: 32px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; }
.sales-notfound__icon { width: 44px; height: 44px; border-radius: 999px; background: var(--nb-focus); color: var(--nb-primary); display: inline-flex; align-items: center; justify-content: center; }
