/* ============================================================
   Orders page redesign - pastel green/mint identity (matching
   the dashboard's light key) + Orders/Draft Orders switcher.
   Scoping the pastel tokens to .orders-page re-themes the
   section cards, tables, badges and buttons in one place.
   ============================================================ */
.orders-page {
  /* Grid item in .page-content: without min-width:0 it defaults to min-width:auto
     and expands to the orders table's 1240px min-width, overflowing the workspace
     (the green bg then appears to "cut off"). Zeroing it lets .table-shell's
     overflow:auto scroll the wide table internally instead. */
  min-width: 0;
  /* Uniform vertical rhythm between header, switcher, filter card and table. */
  display: flex; flex-direction: column; gap: 18px;
}
/* Drop block-flow margins so they don't double the flex gap above. */
.orders-page > .view-switch { margin-bottom: 0; }
.orders-page .section-card,
.orders-page .table-shell { background: #fff; border-color: var(--line); }

/* --- Orders + Draft Orders: pagination sits below the scroll, not inside it ---
   The shell used to be the scroll container with the footer as its last child,
   which cost two things: the horizontal scrollbar is painted at the bottom edge
   of the scroll box, so it landed on top of the footer; and on a full page of
   rows the footer sat past the fold, so "Showing 1-25 of 150" and Previous/Next
   could only be reached by scrolling the table down. Giving the rows their own
   .table-scroll child and leaving the footer outside it pins the footer to the
   bottom of the card - which is the empty space under a short table - and keeps
   the scrollbar off it. The sticky thead just re-anchors to .table-scroll. */
.orders-page > .table-shell {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.orders-page > .table-shell > .table-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}
.orders-page > .table-shell > .table-footer { flex: 0 0 auto; }
.orders-page .button { border-color: var(--accent); color: var(--accent); background: #fff; }
.orders-page .button:hover:not([disabled]) { background: var(--accent); color: #fff; }
.orders-page .button[disabled] { opacity: 0.6; cursor: default; }
.orders-page .button-ghost:hover { color: var(--accent); border-color: var(--accent); }

/* The sync state under the page title. */
.orders-statusline { margin: 0 0 12px; }

/* --- Orders / Draft Orders: one table panel --------------------------------- */
.otoolbar { display: flex; flex-direction: column; }

/* Faintly recessed, so the filter row reads as a strip attached to the table
   rather than a second block of form. */

/* The switcher sits inside the panel now: drop the standalone bottom margin and
   let the row's padding place it. */
.otoolbar .view-switch { margin-bottom: 0; }

/* Search: icon inside the field, no label - the placeholder says what it takes. */

/* Pills carry their own value, so no label is needed above them: at rest they
   read "Any payment", once set they read "Paid" and turn accent. */
.ofilter-pill {
  min-height: 32px;
  padding: 0 28px 0 11px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  background-color: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none' stroke='%23566b62' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
}
.ofilter-pill:hover { color: var(--accent); border-color: var(--accent); }
.ofilter-pill:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(20, 124, 100, 0.14);
}
.ofilter-pill.is-set {
  color: #0f5f4c;
  background-color: var(--accent-weak);
  border-color: #b7dccd;
  font-weight: 650;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none' stroke='%230f5f4c' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5'/%3E%3C/svg%3E");
}

/* The date filter: the native from/to pair, then its preset chips. */

/* Rows per page is a view setting, not a filter, so it sits apart: pushed to the
   end of the row and never tinted, or it would read as "a filter is on". */
.ofilter-pill-rows { color: var(--faint); font-weight: 600; }
.ofilter-pill-rows:hover { color: var(--accent); }

/* Table region: owns the clipping, the sideways scroll and the bottom corners.
   Same flex split as .table-shell so the footer stays out of the scrollbar. */
.otable-body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-top: 1px solid var(--line);
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
}
.otable-body > .table-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; }
.otable-body > .table-footer { flex: 0 0 auto; }

/* Scroll-linked motion is exactly what this setting is for: keep the layout
   change, drop the animation. */
@media (prefers-reduced-motion: reduce) {
  .orders-page .export-banner,
.orders-page .export-banner-icon { transition: none; }
}

@media (max-width: 720px) {
  /* Stack: the switcher takes its own line, search goes full width, and the
     count drops under the pills instead of squeezing them. */
        }

/* Segmented Orders / Draft Orders switcher */
/* Segmented control: a recessed tray with the active view lifted out of it as a
   white card. Choosing a view is a small navigational act, so this reads quieter
   than the filled pill it replaces - which outweighed both the Sync buttons and
   the table beneath it. The accent survives only in the active count.
   Shared by Orders/Draft Orders (2 tabs, with counts) and Vendors (3 tabs, no
   counts), so nothing here may assume a count is present. */
.view-switch {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  /* A shade under the page ground so the tray reads as sunken and the white
     active segment as raised out of it. */
  background: #ebe9e3;
  border-radius: 10px;
  margin-bottom: 20px;
  /* Hug the tabs' width even inside a flex-column page (e.g. the vendors
     fill layout), so it matches the compact Orders/Draft Orders switcher. */
  align-self: flex-start;
}

.view-switch-tab {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 15px; border-radius: 7px;
  font-size: 13.5px; font-weight: 600; color: var(--muted); text-decoration: none;
  transition: background 0.12s ease, color 0.12s ease;
}

.view-switch-tab:hover { color: var(--text); }
.view-switch-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.view-switch-tab.is-active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 2px rgba(16, 35, 28, .1);
}

/* A tab whose feature isn't on the plan: still visible, links to plans. */
.view-switch-tab.is-locked { color: var(--faint); }
.view-switch-tab.is-locked .trig-lock { position: static; }
/* Home's setup guide sets it beside the step's title, not in a corner. */
[data-setup-guide] .trig-lock { position: static; }

/* Draft-order status badge (OPEN reads as accent) */
.badge-info { color: var(--accent); background: var(--accent-weak); border-color: #bfe0d3; }

/* Draft view states */
.empty-state-title { font-size: 15px; font-weight: 700; color: var(--text); margin: 0 0 4px; }

@keyframes draft-spin { to { transform: rotate(360deg); } }

/* Shared line-item thumbnail (Order/Draft detail + HTML invoice) */
.li-thumb { flex: none; border-radius: 9px; overflow: hidden; border: 1px solid var(--line); display: grid; place-items: center; background: #fff; }
.li-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.li-thumb-empty { border-style: dashed; background: var(--line-soft, #eef2f0); color: var(--faint, #8ba095); }
.draft-row[data-href] { cursor: pointer; }
/* Product image in HTML invoice line-item desc cell */
.inv-li-cell { display: flex; gap: 10px; align-items: flex-start; }
.inv-li-cell .li-thumb { margin-top: 1px; }
/* Multi-page print: keep line-item rows intact and repeat the table header. */
@media print {
  .preview-line-items tr { break-inside: avoid; }
  .preview-line-items thead { display: table-header-group; }
}

