/* EntryOps — Muted Cyan palette.
 *
 * Two variants under one palette name, picked by the user's system
 * preference (prefers-color-scheme). Default = light, matching the
 * desktop TariffMill light-mode screenshots; dark = the muted-cyan
 * dark variant the desktop ships alongside.
 *
 * Add a manual override later by toggling [data-theme="dark"] on <html>;
 * the structure below is forward-compatible with that. */

:root {
  /* ---- Muted Cyan — LIGHT (default) ---- */
  --bg:           #eaf3f5;
  --panel:        #ffffff;
  --panel-2:      #f1f7f9;
  --text:         #1f3a44;
  --muted:        #5d7c86;
  --border:       #c5d6dc;
  --border-strong:#9fb9c2;
  --accent:       #4a8fa3;
  --accent-hover: #3a7a8d;
  --accent-soft:  #cce3eb;
  --error:        #c95757;
  --warn:         #d59644;
  --ok:           #4f9c6d;
  --shadow:       0 1px 3px rgba(31, 58, 68, 0.06), 0 1px 2px rgba(31, 58, 68, 0.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    /* ---- Muted Cyan — DARK ---- */
    --bg:           #0f1f25;
    --panel:        #16292f;
    --panel-2:      #1e353c;
    --text:         #c9d8dd;
    --muted:        #7a8f96;
    --border:       #2e4750;
    --border-strong:#3f6068;
    --accent:       #5fb3cc;
    --accent-hover: #74c4dc;
    --accent-soft:  rgba(95, 179, 204, 0.16);
    --error:        #d97070;
    --warn:         #e0a85a;
    --ok:           #6fc090;
    --shadow:       0 1px 3px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

/* Force transparent rendering for the SVG logo in all placements. */
img[src*="logo.svg"] {
  background: transparent;
}

/* ----------------------------------------------------------------- top bar */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.brand {
  font-weight: 600;
  font-size: 16px;
  color: var(--accent);
  letter-spacing: 0.3px;
}
.brand:hover { text-decoration: none; color: var(--accent-hover); }
.user-chip {
  color: var(--muted);
  margin-right: 12px;
  font-size: 13px;
}

.tabnav {
  display: flex;
  gap: 4px;
  flex: 1;
  justify-content: center;
}
.tab {
  padding: 8px 18px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--muted);
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.tab:hover {
  background: var(--accent-soft);
  color: var(--accent);
  text-decoration: none;
}
.tab.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}
.userarea { display: flex; align-items: center; gap: 10px; }
.userarea-link {
  padding: 5px 12px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  border: 1px solid var(--border);
  background: var(--panel-2);
}
.userarea-link:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
  text-decoration: none;
}
.userarea-link.active { background: var(--accent); color: white; border-color: var(--accent); }
.inline { display: inline; }
.link {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  padding: 0;
}
.link:hover { color: var(--accent-hover); text-decoration: underline; }

/* ------------------------------------------------------------------- page */

/* Full-width content with side padding — left-aligned. Matches the
 * desktop's "content fills the window" layout rather than the cloud's
 * earlier 1200px centered shell that left dead space on wide monitors. */
.page {
  margin: 0;
  padding: 24px;
  width: 100%;
  box-sizing: border-box;
}

.footer {
  color: var(--muted);
  font-size: 12px;
  padding: 16px 24px;
  background: var(--panel);
  border-top: 1px solid var(--border);
}
.footer .status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ----------------------------------------------------------------- cards */

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.card-narrow { max-width: 420px; margin: 60px auto; }

h1, h2 { margin-top: 0; }
h1 { font-size: 22px; font-weight: 600; }
h2 { font-size: 16px; font-weight: 600; color: var(--muted); margin-bottom: 12px; }
.muted { color: var(--muted); }

.stack { display: flex; flex-direction: column; gap: 14px; }
.row-between { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; }
.actions { display: flex; gap: 8px; align-items: center; }

/* Two-column split: left sidebar of controls, right main panel of
 * results / drop zone. Matches the desktop TariffMill PDF Processing +
 * Invoice Processing layout pattern. Collapses to a single column on
 * narrow viewports so mobile still works. */
.layout-split {
  display: grid;
  /* The `minmax(0, 1fr)` on the second column is the key piece — by
   * default CSS grid treats `1fr` as `minmax(auto, 1fr)` and the
   * `auto` floor is the intrinsic min-content width. A wide preview
   * table inside the right column would force the column wider than
   * the viewport, blowing past the page edge. `minmax(0, 1fr)` lets
   * the column shrink to 0 if needed; the inner .table-scroll then
   * gets to do its overflow:auto job and the table scrolls horizontally
   * INSIDE the card instead of pushing the whole page sideways. */
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  width: 100%;
}
.layout-main { min-width: 0; }  /* same intent for any non-grid parent */
@media (max-width: 880px) {
  .layout-split { grid-template-columns: 1fr; }
}
.layout-split .panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.layout-split .panel:last-child { margin-bottom: 0; }
.layout-split .panel h3 {
  margin: 0 0 12px 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* Bigger drop zone for the main panel where it's the visual centerpiece. */
.file-drop.large {
  padding: 60px 32px;
  font-size: 14px;
}
.file-drop.large span { font-size: 14px; margin-top: 12px; }

/* ----------------------------------------------------------------- forms */

label { display: block; }
label > span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
input[type="email"], input[type="password"], input[type="text"], select, textarea {
  width: 100%;
  padding: 9px 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
}
input[type="email"]:focus, input[type="password"]:focus,
input[type="text"]:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
select option { background: var(--panel); color: var(--text); }

.file-drop {
  display: block;
  /* Tightened in v0.4.61 — the 32px-padding zone was eating most of the
   * dashboard's vertical real estate above the Last Result Preview.
   * 14px keeps the dashed border visible + the labels readable without
   * dominating the page. drag-over keeps its outline so the operator
   * still gets the unmistakable "release here" feedback. */
  padding: 14px 20px;
  border: 2px dashed var(--border-strong);
  border-radius: 8px;
  text-align: center;
  cursor: pointer;
  background: var(--panel-2);
  transition: border-color 0.15s, background 0.15s;
}
.file-drop:hover { border-color: var(--accent); background: var(--accent-soft); }
.file-drop.drag-over {
  border-color: var(--accent);
  background: var(--accent-soft);
  /* slight scale + outline so the operator gets unmistakable feedback
   * that the drop will land here when they release the mouse */
  outline: 2px dashed var(--accent);
  outline-offset: -8px;
}
.file-drop input[type="file"] {
  width: 100%;
  margin-bottom: 8px;
  color: var(--text);
}
.file-drop span { display: block; color: var(--muted); font-size: 13px; }

button.primary, a.primary.button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 9px 18px;
  border-radius: 6px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  display: inline-block;
  transition: background 0.15s;
}
button.primary:hover, a.primary.button:hover {
  background: var(--accent-hover);
  text-decoration: none;
  color: white;
}

a.button, button.button {
  background: var(--panel-2);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 6px;
  border: 1px solid var(--border);
  display: inline-block;
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
a.button:hover, button.button:hover {
  border-color: var(--accent);
  background: var(--panel);
  text-decoration: none;
}

/* ----------------------------------------------------------------- flash */

.flash {
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  background: var(--panel);
}
.flash.info  { background: var(--accent-soft); border-color: var(--accent); }
.flash.error { background: rgba(201, 87, 87, 0.08); border-color: var(--error); color: var(--error); }
.flash.warn  { background: rgba(213, 150, 68, 0.10); border-color: var(--warn); color: var(--warn); }
.form-error  { color: var(--error); font-size: 13px; }

/* ----------------------------------------------------------------- tables */

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data th, table.data td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
table.data th {
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
  background: var(--panel-2);
}
table.data tbody tr:hover { background: var(--accent-soft); }

/* Results tables — bounded vertical scroll inside the card with sticky
 * column headers so the operator can scan a long list without losing
 * the column labels. Fixed 500px (not vh-relative) so the search form
 * above the table stays on screen at the operator's actual resolution.
 * 70vh used to leave too much room and the *page* scrolled instead
 * of the *table*. */
.table-scroll {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 500px;
  margin: 0 -24px;
  padding: 0 24px;
}
.table-scroll table.data thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--panel-2);
}

/* ----------------------------------------------------------------- badges */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}
.badge-pending          { background: var(--panel-2); color: var(--muted); border: 1px solid var(--border); }
.badge-running          { background: rgba(213, 150, 68, 0.15); color: var(--warn); }
.badge-succeeded        { background: rgba(79, 156, 109, 0.15); color: var(--ok); }
.badge-failed           { background: rgba(201, 87, 87, 0.15); color: var(--error); }
.badge-needs_net_weight { background: rgba(213, 150, 68, 0.15); color: var(--warn); }
.badge-needs_parts      { background: rgba(213, 150, 68, 0.15); color: var(--warn); }
.badge-needs_template   { background: rgba(213, 150, 68, 0.15); color: var(--warn); }
.badge-needs_mid        { background: rgba(213, 150, 68, 0.15); color: var(--warn); }

/* Make multi-chip badge links unobtrusive — keep the chip color
   doing the visual work; strip default link decoration and tighten
   spacing between adjacent chips. */
.badge-link {
  text-decoration: none;
  margin-right: 4px;
  display: inline-block;
}
.badge-link:hover .badge { filter: brightness(1.15); }

/* Composite /setup page — each needs_* gap gets its own fieldset
   block so the operator can see at a glance how many gaps remain. */
.setup-section {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 16px 14px;
  margin: 0;
}
.setup-section + .setup-section { margin-top: 14px; }
.setup-section legend {
  padding: 0 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* Missing Parts grid — many editable columns. Per-field min-widths
   so values like long MIDs ("INSIGMAC123BOM" — 14 chars), full
   descriptions ("Quinbin - litter bin of oval base..."), and 12-char
   HTS codes ("7326.90.8688") fit without truncating. The table sits
   inside .table-scroll, so anything that doesn't fit the viewport
   becomes a horizontal scroll instead of clipping. */
.missing-parts-table input[type="text"] {
  width: 100%;
  min-width: 110px;
  padding: 4px 6px;
  font-size: 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text);
}
.missing-parts-table input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--panel);
}
.missing-parts-table th,
.missing-parts-table td {
  padding: 4px 6px;
  font-size: 12px;
}
.missing-parts-table td code { font-size: 11px; }

/* Per-field widths. Inputs use min-width so they grow with viewport
   when the table has spare horizontal space; the cell follows the
   input. The Part # input keeps its dedicated .pn-input class for
   any future styling distinct from the generic field inputs. */
.missing-parts-table .pn-input,
.missing-parts-table input[data-field="part_number"]   { min-width: 140px; }
.missing-parts-table input[data-field="description"]   { min-width: 240px; }
.missing-parts-table input[data-field="hts_code"]      { min-width: 120px; }
.missing-parts-table input[data-field="qty_unit"]      { min-width:  70px; }
.missing-parts-table input[data-field="mid"]           { min-width: 170px; }
.missing-parts-table input[data-field="client_code"]   { min-width: 100px; }
.missing-parts-table input[data-field="country_origin"],
.missing-parts-table input[data-field="country_of_melt"],
.missing-parts-table input[data-field="country_of_cast"],
.missing-parts-table input[data-field="country_of_smelt"] { min-width: 90px; }
.missing-parts-table input[data-field$="_pct"]         { min-width:  75px; }

/* Inline HTS autocomplete dropdown (Missing/Incomplete Parts grid).
   Positioned absolutely against the active HTS Code input by JS.
   Sits above tables (z-index above .table-scroll's overflow stack). */
.hts-ac-dropdown {
  position: absolute;
  z-index: 1000;
  max-height: 320px;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  font-size: 12px;
  padding: 2px 0;
}
.hts-ac-dropdown[hidden] { display: none; }
.hts-ac-row {
  display: grid;
  grid-template-columns: 110px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 5px 10px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.hts-ac-row:last-child { border-bottom: none; }
.hts-ac-row:hover, .hts-ac-row.active {
  background: var(--accent-soft, #e8f1f9);
}
.hts-ac-row code {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
  white-space: nowrap;
}
.hts-ac-desc {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hts-ac-uom {
  color: var(--muted);
  font-size: 11px;
  font-style: italic;
  white-space: nowrap;
}
.hts-ac-empty {
  padding: 8px 12px;
  color: var(--muted);
  font-style: italic;
}

/* Inline edit on the run-preview table (preview.html). Editable cells
   show a subtle hover cue + ✎ marker in the header; clicking swaps
   the cell to an <input>. Saved cells flash a soft highlight. */
table.preview-editable th.editable-col { cursor: help; }
table.preview-editable th.editable-col .edit-marker {
  font-size: 10px;
  color: var(--muted);
  margin-left: 2px;
}
table.preview-editable td.editable-cell {
  cursor: text;
  position: relative;
}
table.preview-editable td.editable-cell:hover {
  background: var(--accent-soft, #eef4fa);
  outline: 1px dashed var(--accent);
  outline-offset: -1px;
}
table.preview-editable td.editable-cell.edited {
  background: rgba(127, 200, 127, 0.18);
  font-weight: 600;
}
.inline-edit-input {
  width: 100%;
  min-width: 60px;
  padding: 2px 4px;
  font-size: inherit;
  font-family: inherit;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 2px;
  color: var(--text);
  box-sizing: border-box;
}
.inline-edit-input:focus { outline: none; }

.edit-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 10px 0;
  padding: 10px 14px;
  background: rgba(255, 200, 0, 0.08);
  border: 1px solid #b07d2b;
  border-radius: 4px;
  font-size: 13px;
}
.edit-status-bar[hidden] { display: none; }
.edit-status-bar .inline {
  display: inline;
  margin: 0;
}

/* ----------------------------------------- parts search + table-click row */

.parts-search {
  margin: 16px 0 12px 0;
  padding: 14px 16px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.quick-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.qf {
  display: inline-block;
  padding: 5px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}
.qf:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); text-decoration: none; }
.qf.active { background: var(--accent); color: white; border-color: var(--accent); }
.qf.active:hover { background: var(--accent-hover); color: white; }

.search-grid {
  display: grid;
  grid-template-columns: 160px 130px 1fr 160px 160px auto;
  gap: 10px;
  align-items: end;
}
.search-grid .grow { grid-column: span 1; }
.search-actions { display: flex; gap: 6px; padding-bottom: 1px; }
@media (max-width: 880px) {
  .search-grid { grid-template-columns: 1fr 1fr; }
  .search-grid .grow { grid-column: 1 / -1; }
  .search-actions { grid-column: 1 / -1; }
}

.match-count { margin: 4px 0 12px 0; font-size: 12px; }

.parts-table tr.clickable { cursor: pointer; }
.parts-table tr.clickable:hover { background: var(--accent-soft); }

/* Row hover for both admin (editable) + read-only views. The
   admin grid no longer carries tr.clickable since cells are
   individually interactive, but a subtle row hover still helps
   the eye track horizontally across a wide table. */
.parts-table tbody tr:hover { background: var(--accent-soft); }

/* Part # link inside the editable parts grid — keep the code
   styling but make the link itself unstyled. */
.parts-table .part-link { color: inherit; text-decoration: none; }
.parts-table .part-link:hover { text-decoration: underline; }

/* Checkbox column — minimal width, centered. */
.parts-select-col { width: 32px; text-align: center; padding: 4px 6px; }
.parts-select-col input { cursor: pointer; }

/* Section 232 percentage cells — right-aligned numeric, tabular
   monospace so the digits line up across rows. Narrow column width
   keeps the 6 new percent columns from blowing out horizontal
   scroll. */
.parts-table .pct-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, monospace;
  width: 60px;
  min-width: 60px;
}

/* Editable cells — subtle hover affordance so the operator knows
   they can click; focus state gets the accent border so the active
   edit is obvious. */
.parts-table.editable td[contenteditable="true"] {
  cursor: text;
  border-left: 2px solid transparent;
}
.parts-table.editable td[contenteditable="true"]:hover {
  background: var(--accent-soft);
}
.parts-table.editable td[contenteditable="true"]:focus {
  outline: none;
  background: var(--panel);
  border-left-color: var(--accent);
  white-space: normal;  /* let long edits expand instead of clipping */
  text-overflow: clip;
}
/* Save-status flash. .cell-saving = in flight; .cell-saved = brief
   green pulse; .cell-error = persistent red border until next focus. */
.parts-table td.cell-saving  { background: rgba(255, 200, 0, 0.15); }
.parts-table td.cell-saved   { background: rgba(40, 180, 60, 0.20); }
.parts-table td.cell-error {
  background: rgba(220, 50, 50, 0.20);
  border-left: 2px solid #c0392b;
}

/* Selection toolbar — sticky to viewport bottom so it stays visible
   while the operator scrolls a long result set. The [hidden] override
   below restores the HTML attribute's display:none behavior, which
   the explicit `display: flex` here would otherwise mask. */
.parts-selection-toolbar[hidden] { display: none; }
.parts-selection-toolbar {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  z-index: 100;
}
.parts-selection-toolbar .psts-count { font-size: 14px; }
.parts-selection-toolbar .psts-count strong { color: var(--accent); }
.parts-selection-toolbar .link {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 0 4px;
  font-size: 12px;
  text-decoration: underline;
}
.parts-selection-toolbar .button.danger {
  background: #c0392b;
  color: white;
  border-color: #c0392b;
}
.parts-selection-toolbar .button.danger:hover {
  background: #a32a1f;
  border-color: #a32a1f;
}

/* Right-click context menu — single instance reused per click. */
.parts-context-menu {
  position: fixed;
  z-index: 200;
  margin: 0;
  padding: 4px 0;
  list-style: none;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  min-width: 180px;
  font-size: 13px;
}
.parts-context-menu .ctx-item {
  padding: 6px 14px;
  cursor: pointer;
  user-select: none;
}
.parts-context-menu .ctx-item:hover {
  background: var(--accent-soft);
  color: var(--accent);
}
.parts-context-menu .ctx-item.danger { color: #c0392b; }
.parts-context-menu .ctx-item.danger:hover {
  background: rgba(220, 50, 50, 0.15);
  color: #c0392b;
}
.parts-context-menu .ctx-item.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.parts-context-menu .ctx-item.disabled:hover {
  background: none;
  color: inherit;
}
.parts-context-menu .ctx-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* Bulk-edit modal. Simple centered card on a translucent backdrop.
   [hidden] override is required because the explicit `display: flex`
   masks the HTML attribute's default display:none. */
.parts-modal[hidden] { display: none; }
.parts-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
}
.parts-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}
.parts-modal-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  padding: 24px;
  min-width: 480px;
  max-width: 90vw;
}
.parts-modal-row {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
  align-items: flex-end;
}
.parts-modal-row label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
}
.parts-modal-row label.grow { flex: 1; }
.parts-modal-row label > span { color: var(--muted); }
.parts-modal-row input,
.parts-modal-row select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--panel-2);
  color: inherit;
  font-size: 14px;
}
.parts-modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* --------------------------------------------------- part detail sections */

.detail-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.detail-section header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 18px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
}
.detail-section header h3 {
  margin: 0;
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  padding: 0;
  border: none;
}
.detail-section > .detail-grid,
.detail-section > .inline-row,
.detail-section > p,
.detail-section > ul {
  padding: 12px 18px;
  margin: 0;
}
.detail-section > .inline-row + .inline-row,
.detail-section > .detail-grid + .inline-row { padding-top: 0; }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 32px;
}
.detail-grid .field {
  display: flex;
  gap: 8px;
  font-size: 13px;
  padding: 2px 0;
}
.detail-grid .field .label {
  flex: 0 0 160px;
  color: var(--muted);
  font-weight: 600;
}
.detail-grid .field .value { flex: 1; }
@media (max-width: 720px) {
  .detail-grid { grid-template-columns: 1fr; }
}

.inline-row {
  display: flex;
  gap: 12px;
  font-size: 13px;
  border-top: 1px dashed var(--border);
}
.inline-row .label {
  flex: 0 0 160px;
  color: var(--muted);
  font-weight: 600;
}
.inline-row .value { flex: 1; display: flex; flex-wrap: wrap; gap: 18px; }
.pct-item strong { color: var(--muted); font-weight: 600; }

/* Status badges (top-right of each detail section) */
.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.status-ok      { background: rgba(79, 156, 109, 0.18); color: var(--ok); }
.status-warn    { background: rgba(213, 150, 68, 0.20); color: var(--warn); }
.status-info    { background: var(--accent-soft); color: var(--accent); }
.status-danger  { background: rgba(201, 87, 87, 0.18); color: var(--error); }
.status-exempt  { background: rgba(79, 156, 109, 0.18); color: var(--ok); }
.status-na      { background: var(--panel); color: var(--muted); border: 1px solid var(--border); }

/* ----------------------------------------- user management table */

.role-chip {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.role-admin { background: rgba(213, 150, 68, 0.18); color: var(--warn); }
.role-user  { background: var(--accent-soft); color: var(--accent); }

.row-actions {
  text-align: right;
  white-space: nowrap;
}
.row-actions > * { margin-left: 6px; }
.row-action {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 9px;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.row-action:hover { border-color: var(--accent); color: var(--accent); }
.row-action.danger:hover { border-color: var(--error); color: var(--error); }

/* MID Management — collapsible per-importer groups. Each <details>
 * is one importer; the <summary> is the twisty header. */
.mid-groups { display: flex; flex-direction: column; gap: 10px; }
.mid-group {
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.mid-group-summary {
  /* `display: flex` on a <summary> removes the browser's built-in
   * disclosure marker (it depends on `display: list-item`). Strip the
   * default explicitly + add our own .mid-group-twisty arrow so the
   * twisty is visible across Chrome/Firefox/Safari. */
  cursor: pointer;
  padding: 10px 14px;
  background: var(--panel);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  user-select: none;
  list-style: none;
}
.mid-group-summary::-webkit-details-marker { display: none; }
.mid-group-summary:hover { background: var(--accent-soft); }
.mid-group-summary code { font-size: 13px; }
.mid-group-twisty {
  display: inline-block;
  font-size: 11px;
  color: var(--muted);
  width: 12px;
  transition: transform 0.15s ease;
}
.mid-group[open] > .mid-group-summary > .mid-group-twisty {
  transform: rotate(90deg);
}
.mid-group[open] > .mid-group-summary {
  border-bottom: 1px solid var(--border);
}
.mid-group > table.data { margin: 0; }

/* The Edit details/summary widget — `<summary>` is the trigger, the
 * form below pops out when expanded. */
.row-action-details { display: inline-block; }
.row-action-details summary {
  list-style: none;  /* hide the default ▶ marker */
  display: inline-block;
}
.row-action-details summary::-webkit-details-marker { display: none; }
.row-action-details[open] summary { color: var(--accent); border-color: var(--accent); }
.inline-edit-form {
  position: absolute;
  margin-top: 4px;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 6px;
  display: flex;
  gap: 6px;
  align-items: center;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.inline-edit-form input,
.inline-edit-form select {
  width: auto;
  padding: 6px 8px;
  font-size: 12px;
}
.inline-edit-form button {
  padding: 6px 12px;
  font-size: 12px;
}
.inline-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  white-space: nowrap;
  margin: 0;
}
.inline-checkbox input[type="checkbox"] {
  width: auto;
  margin: 0;
}

.add-user-form {
  display: grid;
  grid-template-columns: 1fr 1fr 150px auto;
  gap: 12px;
  align-items: end;
}
@media (max-width: 720px) {
  .add-user-form { grid-template-columns: 1fr; }
}

.oneshot-password {
  display: inline-block;
  padding: 4px 10px;
  background: var(--accent);
  color: white;
  border-radius: 4px;
  font-size: 14px;
  margin-left: 8px;
  user-select: all;
}

/* Admin sub-nav (Users / HTS Database tabs inside the /admin/* area) */
.admin-subnav {
  display: flex;
  gap: 4px;
  padding: 0 0 16px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.subtab {
  padding: 6px 14px;
  font-size: 13px;
  color: var(--muted);
  border-radius: 5px 5px 0 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.subtab:hover { color: var(--accent); text-decoration: none; }
.subtab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* HTS Database stats panel + search + import form */
.hts-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-top: 16px;
  padding: 14px 16px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.hts-stats > div { display: flex; flex-direction: column; gap: 2px; }
.hts-stats .muted { font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; }
.hts-stats strong { font-size: 14px; color: var(--text); }

.hts-search {
  display: grid;
  grid-template-columns: 1fr 140px auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 8px;
}
.hts-search .grow { grid-column: span 1; }
@media (max-width: 720px) {
  .hts-search { grid-template-columns: 1fr; }
  .search-actions { grid-column: 1; }
}

.hts-import-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px;
  align-items: end;
}
@media (max-width: 720px) {
  .hts-import-form { grid-template-columns: 1fr; }
}
.hts-import-form input[type="file"] {
  width: 100%;
  padding: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
}

/* Indeterminate progress bar for the HTS import. CSS-only — there's no
 * server-side progress channel today, so we just show "something's
 * happening" while the synchronous POST is in flight (the page
 * navigates away on success). */
.hts-progress { margin-top: 14px; }
.hts-progress-bar {
  height: 5px;
  background: var(--accent-soft);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}
.hts-progress-bar > div {
  position: absolute;
  top: 0;
  left: -40%;
  width: 40%;
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  animation: hts-progress-slide 1.5s ease-in-out infinite;
}
@keyframes hts-progress-slide {
  0%   { left: -40%; }
  100% { left: 100%; }
}
.hts-progress-label {
  margin: 8px 0 0 0;
  font-size: 12px;
  color: var(--muted);
}

/* Section 232 row text colors — match the desktop's preview palette.
 *
 *   row-steel       dark gray        - default 232 metal
 *   row-aluminum    blue             - Al-classified HTS
 *   row-copper      orange           - Cu-classified HTS
 *   row-wood        green            - wood
 *   row-auto        purple           - automotive
 *   row-non232      red              - Non-232 (non-metal) line
 *   row-notfound    gold             - part not in parts_master
 *   row-incomplete  pink             - in parts_master but missing data
 *   row-zero-metal  orange-red       - 9903.82.01 zero-metal derivative
 *   row-exempt      muted gold       - 9903.82.03 <15% weight exemption
 *   row-sec301      magenta          - parts_master has a 301 exclusion
 *
 * Applied via a class on each <tr> — see _row_color_class() in routes/web.py.
 * Theme-aware: dark-mode variants brighten the dim ones so they stay
 * visible against the dark panel background. */
table.data tr.row-steel      td { color: #4a4a4a; }
table.data tr.row-aluminum   td { color: #3498db; }
table.data tr.row-copper     td { color: #e67e22; }
table.data tr.row-wood       td { color: #558b2f; }              /* olive — leaves "true" green for non232 */
table.data tr.row-auto       td { color: #9b59b6; }
table.data tr.row-non232     td { color: #2e7d32; font-weight: 600; }  /* green — "not 232, no action needed" */
table.data tr.row-notfound   td { color: #d32f2f; font-weight: 700; }  /* vibrant red — needs attention */
table.data tr.row-incomplete td { color: #d32f2f; font-weight: 700; }
table.data tr.row-zero-metal td { color: #FF6600; font-weight: 600; }
table.data tr.row-exempt     td { color: #b07d2b; }

/* Section 301 — DON'T tint the whole row, just light up the Product No
 * cell with a magenta pill. The previous row-wide magenta text was
 * too close to row-notfound's red on operator screens (the user
 * couldn't tell sec301 from notfound at a glance). Targeted column
 * highlight makes the 301 status unmistakable without competing with
 * material / data-quality row tints. Product No is the 2nd <td>
 * (the 1st is the row-number index column rendered as <td class="muted">). */
table.data tr.row-sec301 td:nth-child(2) {
  background: rgba(194, 24, 91, 0.18);
  box-shadow: inset 3px 0 0 #c2185b;
  color: #c2185b;
  font-weight: 700;
  border-radius: 3px;
}

@media (prefers-color-scheme: dark) {
  /* Steel default of #4a4a4a vanishes on dark; brighten everything
   * just enough to stay visible without losing the per-material hue. */
  table.data tr.row-steel      td { color: #c8c8c8; }
  table.data tr.row-aluminum   td { color: #5fb3e3; }
  table.data tr.row-copper     td { color: #f5a05c; }
  table.data tr.row-wood       td { color: #9ccc65; }
  table.data tr.row-auto       td { color: #c084e0; }
  table.data tr.row-non232     td { color: #66bb6a; }
  table.data tr.row-notfound   td { color: #ff5252; }
  table.data tr.row-incomplete td { color: #ff5252; }
  table.data tr.row-zero-metal td { color: #ff944d; }
  table.data tr.row-exempt     td { color: #d4a259; }
  /* Dark-mode sec301 pill — brighter rose against the dark panel. */
  table.data tr.row-sec301 td:nth-child(2) {
    background: rgba(236, 64, 122, 0.22);
    box-shadow: inset 3px 0 0 #ec407a;
    color: #ec407a;
  }
}

/* Country-inferred indicator. Applied to CountryofMelt /
 * CountryOfCast / PrimCountryOfSmelt cells when the value came from
 * the MID-prefix fallback (no document-extracted country). Subtle —
 * italic + dotted underline + a trailing asterisk in the template
 * — so multi-country shipments stand out for review without
 * blocking the export or competing with row-level color signals
 * (which are reserved for "needs attention" states like notfound /
 * incomplete / sec301). Hover shows the explanatory tooltip. */
table.data td.country-inferred {
  font-style: italic;
  text-decoration: underline dotted;
  text-decoration-color: var(--muted);
  cursor: help;
}

/* Templates tab — keyword chips + collapsible Map Profile cards */

code.kw {
  display: inline-block;
  padding: 1px 7px;
  margin: 1px 4px 1px 0;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 3px;
  font-size: 11px;
}

.profile-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 8px;
  padding: 10px 14px;
}
.profile-card summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 2px 0;
}
.profile-card summary::-webkit-details-marker { display: none; }
.profile-card summary::before {
  content: "▸";
  color: var(--muted);
  font-size: 10px;
  width: 12px;
  display: inline-block;
  transition: transform 0.1s;
}
.profile-card[open] summary::before {
  transform: rotate(90deg);
}

/* Client-group twisty (PDF Supplier Templates page) */
.client-group {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 8px;
  padding: 8px 12px;
}
.client-group summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 6px 0;
  user-select: none;
}
.client-group summary::-webkit-details-marker { display: none; }
.client-group summary::before {
  content: "▸";
  color: var(--muted);
  font-size: 11px;
  width: 14px;
  display: inline-block;
  transition: transform 0.1s;
}
.client-group[open] summary::before { transform: rotate(90deg); }
.client-group .table-scroll { padding-top: 4px; }

/* Data Quality Flag list */
.flag-list { list-style: none; }
.flag-list .flag {
  display: flex;
  gap: 10px;
  padding: 6px 0;
  font-size: 13px;
}
.flag-icon {
  flex: 0 0 18px;
  color: var(--warn);
  font-weight: bold;
}
.flag-danger .flag-icon { color: var(--error); }
.flag-info .flag-icon { color: var(--accent); }

/* ---------------------------------------------------------- column resize
 * Tables marked `class="resizable"` get a thin drag handle on the right
 * edge of every <th>. The handle is invisible until hovered so it
 * doesn't compete with the header text; the cursor switch on hover is
 * the affordance. JS in invoice_processing.html owns the drag state +
 * localStorage persistence keyed by column header text. */
/* table-layout: auto so columns size to their widest cell -- the
 * outer .table-scroll container then horizontally scrolls when the
 * total table width exceeds the viewport. Heath asked 2026-05-30 for
 * left/right scroll on the dashboard's Last Result Preview after the
 * previous `fixed` layout was squeezing 20+ columns into the visible
 * width and ellipsizing headers ("COUN...", "PRIMCOUN..."). With
 * auto, every column shows its full content/header by default and
 * the operator scrolls horizontally to see the wide tail. */
table.resizable { table-layout: auto; width: max-content; min-width: 100%; }
/* th + td still allow ellipsis IF the operator drag-narrows a column
 * (the resize JS sets explicit pixel widths on the <th>, which
 * auto-layout still respects). Without an explicit width set,
 * white-space: nowrap means columns grow to fit content instead of
 * wrapping to multiple lines. */
table.resizable th { position: relative; white-space: nowrap; }
table.resizable td { white-space: nowrap; }
table.resizable th[style*="width"],
table.resizable td[style*="width"] {
  overflow: hidden;
  text-overflow: ellipsis;
}
.col-resize-handle {
  position: absolute;
  top: 0; right: 0;
  width: 5px;
  height: 100%;
  cursor: col-resize;
  user-select: none;
  background: transparent;
  transition: background-color 0.12s;
}
.col-resize-handle:hover,
.col-resize-handle.dragging {
  background-color: var(--accent);
}
body.col-resizing,
body.col-resizing * { cursor: col-resize !important; user-select: none !important; }

/* ------------------------------------------------------------ help tip
 * Small "?" chip whose hover popover holds the explanatory copy that
 * used to occupy three full paragraphs around the Invoice Processing
 * drop zone. Keyboard-accessible via tabindex on the wrapper; the
 * popover also reveals on focus so non-mouse users can read it. */
.help-tip { position: relative; display: inline-block; cursor: help; outline: none; }
.help-tip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  font-family: serif;
  user-select: none;
}
.help-tip-body {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 320px;
  max-width: 440px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.5;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-2px);
  transition: opacity 0.12s, transform 0.12s;
}
.help-tip:hover .help-tip-body,
.help-tip:focus .help-tip-body,
.help-tip:focus-within .help-tip-body {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* ============================================================
 * Dashboard — throughput + time-savings (v0.4.115)
 * ============================================================ */
.dash-toggles { display: flex; gap: 10px; flex-wrap: wrap; }
.seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.seg-btn {
  padding: 6px 12px;
  font-size: 13px;
  color: var(--muted);
  background: var(--panel);
  border-right: 1px solid var(--border);
}
.seg-btn:last-child { border-right: none; }
.seg-btn:hover { background: var(--accent-soft); }
.seg-btn.active { background: var(--accent); color: #fff; }

.dash-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 16px 0;
}
@media (max-width: 760px) { .dash-stats { grid-template-columns: repeat(2, 1fr); } }
.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.stat-card.accent { border-color: var(--accent); background: var(--accent-soft); }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1.1; }
.stat-unit { font-size: 16px; font-weight: 600; color: var(--muted); }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 6px; text-transform: uppercase; letter-spacing: 0.04em; }

.cmp-row { display: flex; align-items: center; gap: 12px; margin: 8px 0; }
.cmp-label { width: 200px; flex-shrink: 0; font-size: 13px; color: var(--muted); }
.cmp-bar-wrap { flex: 1; background: var(--panel-2); border-radius: 5px; overflow: hidden; }
.cmp-bar {
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  min-width: fit-content;
  border-radius: 5px;
}
.cmp-bar.manual { background: var(--border-strong); }
.cmp-bar.eo { background: var(--ok); }

.day-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 140px;
  padding-top: 8px;
  overflow-x: auto;
}
.day-col {
  flex: 1 0 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
}
.day-bar {
  width: 70%;
  min-height: 2px;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
  transition: height 0.2s;
}
.day-col:hover .day-bar { background: var(--accent-hover); }
.day-x { font-size: 9px; color: var(--muted); margin-top: 4px; transform: rotate(-45deg); white-space: nowrap; }

.dash-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 760px) { .dash-cols { grid-template-columns: 1fr; } }

.baseline-form {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  max-width: 520px;
}
.baseline-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.baseline-form input { padding: 6px 8px; }

/* ============================================================
 * Super-admin tenant monitoring + impersonation (v0.4.117)
 * ============================================================ */
.impersonation-banner {
  background: var(--warn);
  color: #1f1500;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  font-weight: 500;
}
.impersonation-banner code { background: rgba(0,0,0,0.12); padding: 1px 5px; border-radius: 3px; }
.impersonation-exit {
  background: #1f1500;
  color: #fff;
  border: none;
  padding: 5px 12px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.impersonation-exit:hover { background: #000; }

/* Small status pills used across the tenant overview/detail. */
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--border);
}
.pill-plan { background: var(--accent-soft); color: var(--accent-hover); border-color: var(--accent); }
.pill-ok   { background: rgba(79,156,109,0.15); color: var(--ok); border-color: var(--ok); }
.pill-warn { background: rgba(213,150,68,0.18); color: var(--warn); border-color: var(--warn); }

table.data.sa-tenants td { vertical-align: top; }
.stat-card.warn { border-color: var(--warn); background: rgba(213,150,68,0.12); }

/* ============================================================
 * HTS detail / duty stack (v0.4.120)
 * ============================================================ */
.hts-detail-form {
  display: flex;
  gap: 14px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.hts-detail-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}
.hts-detail-form select,
.hts-detail-form input {
  padding: 6px 8px;
  min-width: 220px;
}

.hts-stack {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 16px 0;
}
@media (max-width: 860px) { .hts-stack { grid-template-columns: 1fr; } }
.hts-stack > .card { margin: 0; }
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  gap: 10px;
}
.card-head h3 { margin: 0; font-size: 16px; }

table.data tr.row-total td {
  border-top: 2px solid var(--accent);
  padding-top: 10px;
}

/* HTS detail — per-section include toggle (v0.4.126) */
.incl-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  user-select: none;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  margin-left: auto;
  margin-right: 8px;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--panel-2);
}
.incl-toggle:hover { background: var(--accent-soft); color: var(--accent); }
.incl-toggle input { margin: 0; cursor: pointer; }
.incl-toggle input:checked + .incl-toggle-label { color: var(--accent); }
