/* Reusable components. Values come from tokens.css; no screen-specific ids here. */
.sub { color: var(--muted); margin: 0 0 var(--space-5); }
.row { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; margin: var(--space-3) 0; }
/* A row that heads a card has no margin of its own; nor does a line of text in a row or a bar. */
.row.flush { margin: 0; }
.row > .sub, .actionbar > .sub { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
/* Editable table cell: one component on every screen (Review, Prices, Stock). */
input.cell-input { width: 100%; min-width: 56px; min-height: 28px; padding: 3px 6px; margin: 0; display: block;
                   background: transparent; border: 0; border-radius: var(--radius-sm); box-shadow: inset 0 -1px 0 var(--field-border); }
input.cell-input:hover { box-shadow: inset 0 -2px 0 var(--accent); border: 0; }
input.cell-input:focus { background: var(--panel); box-shadow: 0 0 0 2px var(--accent); border: 0; }
td.num input.cell-input { text-align: right; font-variant-numeric: tabular-nums; }
input.cell-input.strong { font-weight: 600; }
button.secondary { background: transparent; color: var(--accent-text); border: 1px solid var(--accent); }
button.secondary:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
/* Destructive or low-priority actions: text only, red. */
button.danger-ghost { background: transparent; color: var(--err); border: 0; padding: 2px var(--space-2); }
button.danger-ghost:hover { background: color-mix(in srgb, var(--err) 10%, transparent); }
button.ghost { background: transparent; color: var(--accent-text); border: 0; padding: 2px var(--space-2); }
button.ghost:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
/* Row actions that only show on hover / keyboard focus of their row. */
@media (hover: hover) and (pointer: fine) {
  tr:not(:hover):not(:focus-within) .row-hover { opacity: 0; }
}
/* Small disclosure menus (⋯) built on <details>. */
details.menu { position: relative; display: inline-block; }
details.menu > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 4px;
                         min-height: var(--control-h); padding: 2px var(--space-3); border: 1px solid var(--field-border);
                         border-radius: var(--radius-md); color: var(--accent-text); font-size: var(--text-sm); }
details.menu > summary::-webkit-details-marker { display: none; }
details.menu[open] > summary { background: color-mix(in srgb, var(--accent) 8%, transparent); }
details.menu .menu-pop { position: absolute; right: 0; top: calc(100% + 4px); z-index: 5; min-width: 140px; display: grid;
                         background: var(--panel); border: 1px solid var(--field-border); border-radius: var(--radius-lg);
                         box-shadow: 0 6px 20px rgba(0,0,0,.12); padding: var(--space-1); }
details.menu .menu-pop button { background: transparent; color: var(--text); text-align: left; min-height: 30px; font-size: var(--text-md); }
details.menu .menu-pop button:hover { background: var(--bg); }
details.menu .menu-pop button.danger { color: var(--err); }
/* Sticky action bar at the bottom of a long card. */
.actionbar { position: sticky; bottom: 0; z-index: 2; display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap;
             background: var(--panel); border-top: 1px solid var(--border); margin: var(--space-4) calc(-1 * var(--space-4)) calc(-1 * var(--space-4));
             padding: var(--space-3) var(--space-4); border-radius: 0 0 calc(var(--radius-xl) - 1px) calc(var(--radius-xl) - 1px);
             box-shadow: 0 -6px 12px -8px rgb(0 0 0 / .15); }
.actionbar .status { color: var(--muted); font-size: var(--text-sm); }
.actionbar .status.dirty { color: var(--warn-text); }
.actionbar .status.dirty::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--warn-text); margin-right: 6px; }
/* A message not shown yet takes no room, and stays in the page for screen readers. */
.actionbar > :empty { position: absolute; }
/* Empty state inside a table or card. */
.empty { text-align: center; color: var(--muted); padding: var(--space-6) var(--space-4); }
.empty strong { display: block; color: var(--text); margin-bottom: var(--space-1); }
.empty button { margin-top: var(--space-3); }
/* Breadcrumb above a detail page. */
.crumbs { display: flex; gap: var(--space-2); align-items: center; font-size: var(--text-sm); color: var(--muted); margin: 0 0 var(--space-3); }
.crumbs a { color: var(--accent-text); }
.crumbs [aria-current] { color: var(--text); font-weight: 600; }
.dlg-buttons { justify-content: flex-end; margin-bottom: 0; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--border);
           border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite;
           vertical-align: -2px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-xl); padding: var(--space-4); margin-top: var(--space-4); }
.meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--space-3); }
.meta label { display: block; color: var(--muted); font-size: var(--text-sm); font-weight: 600; margin-bottom: 2px; }
.meta input, .meta select { width: 100%; }
.warnings { background: var(--warn-bg); color: var(--warn-text); border-radius: var(--radius-lg); padding: 10px 14px; margin-top: var(--space-3); }
.warnings ul { margin: var(--space-1) 0 0; padding-left: 18px; }
.okmsg { color: var(--ok-text); margin-top: var(--space-3); }
/* relative: the .sr-only texts inside scroll with the table instead of widening the page. */
.tablewrap { position: relative; overflow-x: auto; margin-top: var(--space-3); }
th.edit::after { content: " ✎"; content: " ✎" / ""; font-weight: 400; }
th.edit { color: var(--accent-text); }
tr.flag td { background: var(--warn-bg); }
tr.flag td:first-child { box-shadow: inset 3px 0 var(--highlight-line); }
.pill { display: inline-block; font-size: var(--text-sm); line-height: 1.4; padding: 1px 8px; border-radius: var(--radius-pill); border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.pill.warn { background: var(--warn-bg); border-color: transparent; color: var(--warn-text); font-weight: 600; }
.pill.ok { background: var(--ok-bg); border-color: transparent; color: var(--ok-text); }
.pill.ai { border-color: var(--accent); color: var(--accent-text); background: color-mix(in srgb, var(--accent) 8%, transparent); }
/* Totals check in a table footer. */
.check { font-size: var(--text-sm); font-weight: 600; white-space: nowrap; }
.check.ok { color: var(--ok-text); }
.check.bad { color: var(--err); }
.pill.credit { border-color: var(--accent); color: var(--accent-text); font-size: var(--text-sm); }
/* Wins over the display of any class below or in a screen's file. */
.hidden { display: none !important; }
/* A number field holding text that isn't a number (not sent to /check, blocks Download). */
.meta input.bad { box-shadow: 0 0 0 2px var(--err); }
input.bad:focus { border-color: var(--err); box-shadow: 0 0 0 2px var(--err), 0 0 0 4px var(--panel), 0 0 0 6px var(--accent); }
/* Page header. */
.topbar { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; margin-bottom: var(--space-3); }
.topbar .brand { flex-grow: 1; margin: 0; font-weight: 700; font-size: var(--text-lg); }
.page-head { margin: 0 0 var(--space-4); }
.page-head h1 { margin: 0; }
.page-head .sub { margin: var(--space-1) 0 0; }
/* The first card of a view sits right under its title. */
.page-head + .card { margin-top: 0; }
/* Log out, in the page header. */
#userbar { display: flex; gap: 10px; align-items: center; color: var(--muted); }
/* Top nav (Invoices | Prices & stock) and the tabs inside Prices & stock: links to routes. */
.nav, .tabs { display: flex; gap: var(--space-1); flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.nav { margin: 0 0 var(--space-4); }
.nav a, .tabs a { background: transparent; color: var(--muted); border-radius: var(--radius-md) var(--radius-md) 0 0;
                  border-bottom: 2px solid transparent; }
.nav a, .tabs a { display: inline-flex; align-items: center; min-height: var(--control-h); padding: 4px 14px; text-decoration: none; font-weight: 500; }
.nav a:hover, .tabs a:hover { color: var(--text); background: color-mix(in srgb, var(--text) 5%, transparent); }
.nav a[aria-current=page], .tabs a[aria-current=page] { color: var(--accent-text); border-bottom-color: var(--accent); }
button.small { padding: 2px var(--space-2); min-height: var(--control-h-sm); font-size: var(--text-sm); }
.note { color: var(--muted); font-size: var(--text-sm); margin: var(--space-2) 0 0; }
table.inner { min-width: 0; font-size: var(--text-md); }
input.bad { box-shadow: 0 0 0 2px var(--err); }
/* Keeps the ring of an invalid cell while it is hovered. */
input.cell-input.bad:hover:not(:focus) { box-shadow: 0 0 0 2px var(--err); }
/* A second, muted line in a cell. */
td .from { display: block; color: var(--muted); font-size: var(--text-sm); }
.pager { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; margin-top: var(--space-2); color: var(--muted); }
/* Filters and actions above a table. */
.toolbar { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; margin: var(--space-3) 0; }
.toolbar .group { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
.toolbar .end { margin-left: auto; padding-left: var(--space-3); border-left: 1px solid var(--border); }
.toolbar .group-label { font-size: var(--text-sm); font-weight: 600; color: var(--muted); }
.toolbar .end .note { flex-basis: 100%; text-align: right; margin: 0; }
@media (max-width: 640px) {
  .toolbar .end { margin-left: 0; padding-left: 0; border-left: 0; }
}
/* Actions of a table row. */
td.acts { white-space: nowrap; }
/* The logged-in address in the header: a link to the account screen. */
#userbar a { color: var(--muted); text-decoration: none; display: inline-flex; align-items: center; min-height: var(--control-h); }
#userbar a:hover, #userbar a[aria-current=page] { color: var(--accent-text); text-decoration: underline; }
