/* smallbiztools.org v2 design system
   Clean, modern, high-contrast, responsive. Linear / Stripe docs aesthetic.
   Plain CSS, no build step, works completely offline from disk.
*/

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  /* Color palette - Light */
  --bg-canvas: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-card: #ffffff;
  --bg-elevated: #ffffff;
  --bg-muted: #f1f5f9;
  --bg-accent: #eff6ff;

  --border-subtle: #e2e8f0;
  --border-strong: #cbd5e1;
  --border-focus: #3b82f6;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-faint: #64748b;
  --text-inverse: #ffffff;

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-subtle: #dbeafe;
  --primary-text: #1e40af;

  --success: #059669;
  --success-subtle: #d1fae5;
  --success-text: #065f46;

  --warning: #d97706;
  --warning-subtle: #fef3c7;
  --warning-text: #92400e;

  --danger: #dc2626;
  --danger-subtle: #fee2e2;
  --danger-text: #991b1b;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;

  --container-max: 1120px;
  --container-narrow: 800px;
}

[data-theme="dark"] {
  --bg-canvas: #090d16;
  --bg-subtle: #0f172a;
  --bg-card: #131c31;
  --bg-elevated: #1a2540;
  --bg-muted: #1e293b;
  --bg-accent: #172554;

  --border-subtle: #1e293b;
  --border-strong: #334155;
  --border-focus: #60a5fa;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-faint: #64748b;
  --text-inverse: #090d16;

  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-subtle: #1e3a8a;
  --primary-text: #93c5fd;

  --success: #10b981;
  --success-subtle: #064e3b;
  --success-text: #6ee7b7;

  --warning: #f59e0b;
  --warning-subtle: #78350f;
  --warning-text: #fcd34d;

  --danger: #ef4444;
  --danger-subtle: #7f1d1d;
  --danger-text: #fca5a5;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

/* Reset and base */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-main);
  background-color: var(--bg-canvas);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-canvas);
  color: var(--text-main);
  max-width: 100vw;
  overflow-x: hidden;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  text-decoration: underline;
}

h1, h2, h3, h4, h5, h6 {
  margin-top: 0;
  color: var(--text-main);
  font-weight: 600;
  line-height: 1.25;
}

h1 { font-size: 1.875rem; letter-spacing: -0.025em; }
h2 { font-size: 1.5rem; letter-spacing: -0.02em; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }

p {
  margin-top: 0;
  margin-bottom: 1rem;
  color: var(--text-muted);
}

strong {
  color: var(--text-main);
  font-weight: 600;
}

/* Layout containers */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-left: auto;
  margin-right: auto;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

.container-narrow {
  width: 100%;
  max-width: var(--container-narrow);
  margin-left: auto;
  margin-right: auto;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

main {
  flex: 1 0 auto;
  padding-top: 2rem;
  padding-bottom: 3.5rem;
}

/* Header & navigation (52px sticky top bar per docs/DESIGN.md) */
.site-header {
  border-bottom: 1px solid var(--border-subtle);
  background-color: var(--bg-canvas);
  position: sticky;
  top: 0;
  z-index: 100;
  height: 52px;
  max-height: 52px;
  box-sizing: border-box;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  min-height: 52px;
  max-height: 52px;
  padding-block: 0;
  gap: 0.5rem;
  box-sizing: border-box;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-main);
  text-decoration: none;
  letter-spacing: -0.02em;
  white-space: nowrap;
  flex-shrink: 0;
}

.brand:hover {
  text-decoration: none;
  color: var(--primary);
}

.header-search {
  flex: 1 1 200px;
  max-width: 320px;
  display: flex;
  align-items: center;
}

.header-search-input {
  width: 100%;
  height: 32px;
  min-height: 32px;
  padding: 0.25rem 0.625rem;
  font-size: 0.875rem;
  border-radius: var(--radius-sm);
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  box-sizing: border-box;
}

.header-search-input:focus {
  outline: none;
  border-color: var(--border-focus);
}

@media (max-width: 680px) {
  .header-search {
    display: none;
  }
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.nav-link {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: color 0.15s ease;
  white-space: nowrap;
}

.nav-link:hover, .nav-link.active {
  color: var(--text-main);
  text-decoration: none;
}

.btn-share {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  cursor: pointer;
  line-height: 1.2;
  white-space: nowrap;
}

.btn-share:hover {
  background-color: var(--bg-muted);
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.4rem 0.6rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  transition: all 0.15s ease;
}

.theme-toggle:hover {
  background-color: var(--bg-subtle);
  color: var(--text-main);
  border-color: var(--border-strong);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border-subtle);
  background-color: var(--bg-subtle);
  padding: 2.5rem 0 2rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.footer-content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem 2rem;
}

.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
}

.footer-links a:hover {
  color: var(--text-main);
  text-decoration: underline;
}

.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.8125rem;
  color: var(--text-faint);
}

/* Tool page layout */
.tool-header {
  margin-bottom: 1.75rem;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-faint);
  margin-bottom: 0.5rem;
}

.breadcrumb a {
  color: var(--text-muted);
}

.tool-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.tool-title-group {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-width: 0;
}

.tool-title-group h1,
.tool-title-row h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.25;
}

.tool-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  stroke: var(--primary);
  stroke-width: 2;
  fill: none;
}

.tool-subtitle {
  margin-top: 0.25rem;
  font-size: 0.9375rem;
  color: var(--text-muted);
  margin-bottom: 0;
}

/* Two-column responsive tool workspace (inputs left, sticky answer right on desktop; inputs first, sticky compact bottom answer on phone) */
.tool-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}

@media (min-width: 861px) {
  .tool-grid > form {
    grid-column: 1;
    grid-row: 1 / span 5;
  }
  .tool-grid > .result-card {
    grid-column: 2;
    grid-row: 1;
    position: sticky;
    top: calc(52px + 12px);
    z-index: 10;
  }
  .tool-grid > .detail-results {
    grid-column: 2;
    grid-row: 2;
  }
}

@media screen and (max-width: 860px) {
  .tool-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 90px;
  }
  .tool-grid > form {
    order: 1;
    width: 100%;
    min-width: 0;
  }
  .tool-grid > .detail-results,
  .tool-grid > aside,
  .tool-grid > .card.prose {
    order: 2;
    width: 100%;
    min-width: 0;
  }
  .tool-grid > .result-card:not(.invoice-preview-pane) {
    order: 3;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 90;
    margin: 0;
    padding: 6px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-bottom: none;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    height: auto;
    max-height: 80px;
    min-height: 52px;
    box-sizing: border-box;
  }
  .tool-grid > .result-card:not(.invoice-preview-pane) .primary-result-box {
    display: flex;
    flex-direction: column;
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    min-width: 0;
    flex: 1 1 auto;
  }
  .tool-grid > .result-card:not(.invoice-preview-pane) .primary-result-label {
    font-size: 0.72rem;
    margin-bottom: 0;
    line-height: 1.1;
    color: var(--text-faint);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .tool-grid > .result-card:not(.invoice-preview-pane) .primary-result-value {
    font-size: 1.25rem !important;
    font-weight: 800;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
  }
  .tool-grid > .result-card:not(.invoice-preview-pane) .primary-result-sub {
    display: none !important;
  }
  .tool-grid > .result-card:not(.invoice-preview-pane) .action-row {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin: 0;
  }
  .tool-grid > .result-card:not(.invoice-preview-pane) .action-row .btn {
    padding: 6px 12px;
    font-size: 0.85rem;
    min-height: 32px;
  }
  .tool-grid > .result-card .dropdown-menu,
  .tool-grid > .result-card details.more .dropdown-menu {
    bottom: 100%;
    top: auto;
    margin-bottom: 0.5rem;
    margin-top: 0;
  }
  .tool-grid > .result-card:not(.invoice-preview-pane) .results-breakdown,
  .tool-grid > .result-card:not(.invoice-preview-pane) .schedule-preview,
  .tool-grid > .result-card:not(.invoice-preview-pane) .table-responsive,
  .tool-grid > .result-card:not(.invoice-preview-pane) .split-table,
  .tool-grid > .result-card:not(.invoice-preview-pane) .cf-table,
  .tool-grid > .result-card:not(.invoice-preview-pane) .metric-grid,
  .tool-grid > .result-card:not(.invoice-preview-pane) .metric-card,
  .tool-grid > .result-card:not(.invoice-preview-pane) .card-header,
  .tool-grid > .result-card:not(.invoice-preview-pane) .sig-preview-card,
  .tool-grid > .result-card:not(.invoice-preview-pane) .sig-code-block,
  .tool-grid > .result-card:not(.invoice-preview-pane) .breakdown-section,
  .tool-grid > .result-card:not(.invoice-preview-pane) hr {
    display: none !important;
  }
}

/* Cards & panels */
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  color: var(--text-main);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Inputs & Form controls */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group:last-child {
  margin-bottom: 0;
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-main);
  margin-bottom: 0.375rem;
}

.input-helper {
  font-size: 0.8125rem;
  color: var(--text-faint);
  margin-top: 0.25rem;
  margin-bottom: 0;
}

.input-affix {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background-color: var(--bg-card);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  overflow: hidden;
}

.input-affix:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.affix-text {
  display: flex;
  align-items: center;
  padding: 0 0.75rem;
  background-color: var(--bg-subtle);
  color: var(--text-muted);
  font-size: 0.9375rem;
  font-weight: 500;
  user-select: none;
  border-right: 1px solid var(--border-subtle);
}

.affix-text.suffix {
  border-right: none;
  border-left: 1px solid var(--border-subtle);
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="search"],
input[type="email"],
input[type="tel"],
input[type="url"],
select,
textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 0.625rem 0.875rem;
  font-size: 0.9375rem;
  font-family: inherit;
  color: var(--text-main);
  background-color: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box;
}

.input-affix input {
  border: none;
  border-radius: 0;
  background: transparent;
}

.input-affix input:focus {
  outline: none;
  box-shadow: none;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Result Card */
.result-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.primary-result-box {
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  text-align: left;
}

.primary-result-label {
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  color: var(--text-faint);
  margin-bottom: 0.25rem;
}

.primary-result-value {
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-main);
  line-height: 1.15;
}

.primary-result-value.highlight-good {
  color: var(--success);
}

.primary-result-sub {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  margin-bottom: 0;
}

/* Secondary results grid */
.results-breakdown {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

@media (max-width: 440px) {
  .results-breakdown {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
  }
  .metric-box {
    padding: 0.625rem 0.75rem;
  }
  .metric-value {
    font-size: 1.125rem;
  }
}

.metric-box {
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.875rem 1rem;
}

.metric-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.metric-value {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.2;
}

/* Formula explanation */
.formula-note {
  font-size: 0.8125rem;
  color: var(--text-muted);
  background-color: var(--bg-muted);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  border-left: 3px solid var(--primary);
  line-height: 1.4;
}

/* Action row */
.action-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  padding: 0.625rem 1.125rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.25;
  text-decoration: none;
}

.btn:hover {
  text-decoration: none;
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  color: #ffffff;
}

.btn-secondary {
  background-color: var(--bg-card);
  border-color: var(--border-strong);
  color: var(--text-main);
}

.btn-secondary:hover {
  background-color: var(--bg-subtle);
  border-color: var(--text-muted);
}

.btn-icon {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background-color: var(--bg-card);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 1rem;
}

.btn-icon:hover {
  background-color: var(--bg-subtle);
  color: var(--text-main);
}

.btn-help {
  width: 1.875rem;
  height: 1.875rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-strong);
  background-color: var(--bg-card);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.btn-help:hover {
  background-color: var(--primary-subtle);
  color: var(--primary-text);
  border-color: var(--primary);
}

/* More menu dropdown */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 0.375rem;
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 0.375rem 0;
  min-width: 160px;
  z-index: 50;
  display: none;
}

.dropdown-menu.show {
  display: block;
}

.dropdown-item {
  display: block;
  width: 100%;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  text-align: left;
  background: none;
  border: none;
  color: var(--text-main);
  cursor: pointer;
  text-decoration: none;
}

.dropdown-item:hover {
  background-color: var(--bg-subtle);
  text-decoration: none;
}

/* Help sheet modal / drawer */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  z-index: 90;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  box-sizing: border-box;
}

.modal-backdrop.show {
  display: flex;
}

.modal-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  padding: 1.75rem;
  position: relative;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-header h3 {
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-faint);
  cursor: pointer;
  padding: 0.25rem;
}

.modal-close:hover {
  color: var(--text-main);
}

.help-steps {
  padding-left: 1.25rem;
  margin-bottom: 1.25rem;
}

.help-steps li {
  margin-bottom: 0.5rem;
  color: var(--text-muted);
}

.help-limits {
  background-color: var(--bg-subtle);
  padding: 1rem;
  border-radius: var(--radius-md);
  border-left: 3px solid var(--warning);
  font-size: 0.875rem;
  color: var(--text-muted);
}

.help-limits strong {
  color: var(--text-main);
}

/* Toast notifications */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  background-color: var(--text-main);
  color: var(--text-inverse);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: auto;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Card grid (for home and catalog) */
.tool-catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
}

@media (max-width: 440px) {
  .tool-catalog-grid {
    grid-template-columns: 1fr;
  }
}

.tool-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-decoration: none;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.tool-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  text-decoration: none;
}

.tool-card-top {
  margin-bottom: 0.75rem;
}

.tool-card-category {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  margin-bottom: 0.375rem;
}

.tool-card-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.375rem;
}

.tool-card-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 0;
  line-height: 1.4;
}

.tool-card-arrow {
  margin-top: 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Search bar component */
.search-box {
  position: relative;
  width: 100%;
}

.search-input {
  width: 100%;
  padding: 0.875rem 1.125rem 0.875rem 2.75rem;
  font-size: 1.0625rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-strong);
  background-color: var(--bg-card);
  box-shadow: var(--shadow-sm);
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  pointer-events: none;
}

/* Filter pills */
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
  margin-bottom: 1.5rem;
}

.filter-pill {
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 0.375rem 0.875rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-pill:hover {
  background-color: var(--bg-subtle);
  color: var(--text-main);
}

.filter-pill.active {
  background-color: var(--text-main);
  color: var(--text-inverse);
  border-color: var(--text-main);
}

/* Legal & docs article styling */
.prose {
  line-height: 1.7;
  color: var(--text-muted);
}

.prose h1, .prose h2, .prose h3 {
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  color: var(--text-main);
}

.prose h1:first-child {
  margin-top: 0;
}

.prose p {
  margin-bottom: 1.25rem;
}

.prose ul, .prose ol {
  margin-bottom: 1.25rem;
  padding-left: 1.5rem;
}

.prose li {
  margin-bottom: 0.375rem;
}

.summary-callout {
  background-color: var(--bg-accent);
  border: 1px solid var(--primary-subtle);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 2rem;
  color: var(--text-main);
}

.summary-callout strong {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--primary-text);
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Print styling */
@media print {
  .site-header,
  .site-footer,
  .btn,
  .btn-help,
  .theme-toggle,
  .modal-backdrop,
  .toast-container,
  .breadcrumb,
  .action-row,
  .dropdown {
    display: none !important;
  }

  body {
    background: #ffffff !important;
    color: #000000 !important;
  }

  .tool-grid {
    grid-template-columns: 1fr !important;
  }

  .card, .result-card, .metric-box, .primary-result-box {
    border: 1px solid #cccccc !important;
    box-shadow: none !important;
    background: #ffffff !important;
  }
}

/* Foundation integration. Existing design tokens remain the shared source. */
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--border-focus); outline-offset: 3px; }
.skip-link { position: absolute; left: 1rem; top: -6rem; z-index: 100; background: var(--bg-card); padding: .75rem; }
.skip-link:focus { top: .5rem; }
.site-header { position: sticky; top: 0; z-index: 100; height: 52px; max-height: 52px; box-sizing: border-box; }
.header-inner { height: 52px; min-height: 52px; max-height: 52px; padding-block: 0; flex-wrap: nowrap; box-sizing: border-box; }
.brand { font-size: 1rem; }
button, summary { touch-action: manipulation; }
button { font-family: inherit; }
button:disabled { opacity: .55; cursor: not-allowed; }
.btn-icon, .btn-help, .theme-toggle { min-width: 36px; min-height: 36px; }
.btn-icon[aria-pressed="true"] { color: var(--primary-text); background: var(--primary-subtle); }
.tool-title-row { flex-wrap: wrap; align-items: center; }
h1, .tool-title-row h1, .prose h1, .info-page h1 { font-size: 22px !important; line-height: 1.3 !important; }
.tool-header { margin-bottom: 1rem; }
.tool-grid > *, .tool-card { min-width: 0; }
.primary-result-value { overflow-wrap: anywhere; font-variant-numeric: tabular-nums; font-size: clamp(2rem, 5vw, 3rem); }
.primary-result-label, .metric-label, .card-title { text-transform: none; letter-spacing: normal; color: var(--text-muted); }
.result-card { background: var(--bg-accent); }
.result-card p { margin-bottom: 0; }
.section { margin-top: 2rem; }
.section h2 { font-size: 1.2rem; }
.catalog-controls { display: grid; grid-template-columns: minmax(0, 2fr) 1fr 1fr; gap: 1rem; align-items: end; margin-bottom: 1rem; }
.catalog-controls label { margin: 0; }
.catalog-controls input, .catalog-controls select { margin-top: .4rem; min-height: 46px; }
.tool-card { position: relative; padding-right: 4.5rem; }
.tool-card .heart { position: absolute; top: 1rem; right: 1rem; }
.tool-card a { display: inline-block; }
.tool-card h3 { font-size: 1.1rem; margin-bottom: .5rem; }
.tool-card p { margin: 0; font-size: .94rem; }
.tool-catalog-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }
.empty { padding: 1rem; border: 1px dashed var(--border-strong); border-radius: var(--radius-md); }
.muted { color: var(--text-muted); font-size: .875rem; }
details.more { position: relative; }
details.more > summary { list-style: none; }
details.more > summary::-webkit-details-marker { display: none; }
details.more[open] .dropdown-menu { display: block; }
details.more .dropdown-menu { right: 0; left: auto; min-width: 190px; }
.dropdown-item { min-height: 44px; }
dialog { color: var(--text-main); background: var(--bg-card); border: 1px solid var(--border-strong); border-radius: var(--radius-lg); padding: 1.5rem; width: min(520px, calc(100% - 2rem)); max-height: 85vh; overflow: auto; }
dialog::backdrop { background: #0009; }
dialog h2 { font-size: 1.25rem; }
dialog .btn { margin-top: 1rem; }
.explainer { max-width: 800px; margin-top: 1.5rem; }
.explainer summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-main);
  padding: 0.5rem 0;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  user-select: none;
}
.explainer summary::-webkit-details-marker { display: none; }
.explainer summary::before {
  content: '▸';
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: transform 0.15s ease;
}
.explainer[open] summary::before {
  transform: rotate(90deg);
}
.explainer h2 { font-size: 1.1rem; margin-top: 1rem; margin-bottom: .4rem; }
.explainer h3 { font-size: 0.95rem; margin-top: 0.75rem; margin-bottom: 0.3rem; }
.site-footer { padding: 1.25rem 0; }
.toast-container { max-width: calc(100vw - 2rem); }
[data-theme="dark"] { --text-faint: #94a3b8; --primary: #60a5fa; --primary-hover: #93c5fd; }
[data-theme="dark"] .btn-primary { background: #2563eb; }
[data-theme="dark"] .btn-primary:hover { background: #1d4ed8; }
@media (max-width: 600px) {
  main { padding-top: 1.25rem; }
  .catalog-controls { grid-template-columns: 1fr 1fr; }
  .catalog-controls label:first-child { grid-column: 1 / -1; }
  .card, .result-card { padding: 1rem; }
  .tool-grid { gap: 1rem; }
  .site-nav { gap: .5rem; }
  input[type="number"], input[type="search"], select { font-size: 1rem; }
  .tool-grid input { min-height: 44px; }
  .tool-grid .form-group { margin-bottom: 1rem; }
  .tool-grid .card > p:last-of-type { margin-bottom: 0; }
  .results-breakdown { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); margin-top: 1rem; }
  .metric-box { padding: .75rem; min-width: 0; }
  .metric-value { overflow-wrap: anywhere; }
  #catalog > .section { margin-top: 1rem; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } }
@media print {
  .skip-link, .heart, dialog, .explainer, .more, noscript { display: none !important; }
  html[data-theme], body { color-scheme: light; --bg-canvas: #fff; --text-main: #000; --text-muted: #333; --text-faint: #333; }
  .result-card, .card, input { color: #000 !important; background: #fff !important; }
  .tool-grid { break-inside: avoid; }
}
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

/* Support forms keep labels, long messages and actions usable on small screens. */
#message-form textarea { resize: vertical; min-height: 7rem; }
#message-form input, #message-form select, #message-form textarea { font-size: 1rem; min-height: 44px; }
#message-form button, #donate { white-space: normal; max-width: 100%; }
#form-status, #donate-status { margin-top: 1rem; }
.tool-grid .prose h2:first-child { margin-top: 0; }

#message-form > #form-status { margin-top: 0; margin-bottom: 1.25rem; }

/* Reading pages share the same navigation, color system and comfortable measure. */
.info-page { max-width: 720px; margin-inline: auto; overflow-wrap: anywhere; }
.info-page .summary-callout p { margin-bottom: 0; }
.info-page .summary-callout strong { text-transform: none; letter-spacing: normal; }
.legal-draft { font-size: .875rem; border-bottom: 1px solid var(--border-subtle); padding-bottom: 1rem; }
.site-footer .footer-links { gap: .25rem 1.5rem; }
.site-footer .footer-links a { display: inline-flex; align-items: center; min-height: 44px; }
.site-footer .footer-content { gap: .5rem; }
.site-footer .footer-bottom { align-items: baseline; }
.site-footer .footer-bottom span { max-width: 32rem; }
@media print {
  .info-page, .info-page h1, .info-page h2, .info-page p { color: #000; }
  .info-page .summary-callout { color: #000; background: #fff; border-color: #888; }
  .info-page .summary-callout strong { color: #000; }
  .info-page section { break-inside: avoid; }
}

/* Invoice, quote, receipt builder styles */
.invoice-workspace {
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.2fr);
  align-items: start;
}
@media (max-width: 960px) {
  .invoice-workspace {
    grid-template-columns: 1fr;
  }
}
.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.75rem;
}
@media (max-width: 600px) {
  .form-row-2, .form-row-3 {
    grid-template-columns: 1fr;
  }
}
.cf-compact-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.cf-compact-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.4rem;
}
@media (max-width: 600px) {
  #card-fees-form {
    padding: 0.75rem;
  }
  #card-fees-form .form-group {
    margin-bottom: 0.45rem;
  }
  #card-fees-form label {
    font-size: 0.8125rem;
    margin-bottom: 0.2rem;
  }
  #card-fees-form input, #card-fees-form select {
    min-height: 38px;
    padding: 0.3rem 0.5rem;
    font-size: 0.9375rem;
  }
  .cf-processor-fieldset {
    padding: 0.5rem 0.6rem;
    margin: 0.4rem 0;
  }
  .cf-processor-fieldset .form-legend {
    font-size: 0.8125rem;
  }
  .tool-grid:has(#card-fees-form) {
    gap: 0.75rem;
  }
  .tool-grid:has(#card-fees-form) .result-card {
    padding: 0.75rem;
  }
  .tool-grid:has(#card-fees-form) .primary-result-value {
    font-size: 1.75rem;
  }
  .tool-grid:has(#card-fees-form) .primary-result-sub {
    font-size: 0.8125rem;
    margin-bottom: 0.4rem;
  }
  .tool-grid:has(#card-fees-form) .results-breakdown {
    margin-top: 0.4rem;
    gap: 0.4rem;
  }
  .tool-grid:has(#card-fees-form) .metric-box {
    padding: 0.4rem 0.5rem;
  }
  .tool-grid:has(#card-fees-form) .metric-label {
    font-size: 0.6875rem;
  }
  .tool-grid:has(#card-fees-form) .metric-value {
    font-size: 0.9375rem;
  }
  .tool-grid:has(#card-fees-form) .action-row {
    margin-top: 0.5rem;
  }
}
.form-section {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.875rem;
  margin: 1rem 0;
  background: var(--bg-subtle);
}
.form-legend {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
  padding: 0 0.5rem;
}
.logo-control-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.invoice-items-inputs {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.invoice-summary-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  margin-bottom: 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.invoice-summary-bar .summary-metric {
  display: flex;
  flex-direction: column;
}
.invoice-summary-bar .summary-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
}
.invoice-summary-bar .summary-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.2;
}

.invoice-item-row {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(65px, 0.8fr) minmax(85px, 1fr) 38px;
  gap: 0.5rem;
  align-items: end;
  margin-bottom: 0.5rem;
}
.invoice-item-field {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.item-field-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-faint);
  margin-bottom: 0.2rem;
  white-space: nowrap;
}
.invoice-item-row input {
  min-height: 38px;
  font-size: 0.875rem;
}
.btn-remove-item {
  background: none;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--danger-text);
  cursor: pointer;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0;
}
.btn-remove-item:hover {
  background: var(--danger-subtle);
  border-color: var(--danger);
}
.btn-sm {
  font-size: 0.8125rem;
  padding: 0.4rem 0.75rem;
  min-height: 36px;
}

/* Invoice sheet preview */
.invoice-preview-pane {
  background: var(--bg-subtle);
  padding: 1rem;
}
.preview-actions {
  margin-bottom: 1rem;
  display: flex;
  gap: 0.75rem;
  align-items: center;
}
.invoice-sheet {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 2rem;
  box-shadow: var(--shadow-md);
  font-size: 0.9375rem;
  line-height: 1.5;
}
[data-theme="dark"] .invoice-sheet {
  background: #ffffff;
  color: #0f172a;
}
.invoice-sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
  border-bottom: 2px solid #0f172a;
  padding-bottom: 1.25rem;
  margin-bottom: 1.5rem;
}
.invoice-sheet-logo {
  max-height: 60px;
  max-width: 180px;
  object-fit: contain;
  margin-bottom: 0.75rem;
  display: block;
}
.invoice-sheet-business {
  font-size: 1.25rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 0.25rem;
}
.invoice-sheet-subtext {
  font-size: 0.875rem;
  color: #475569;
  white-space: pre-line;
}
.invoice-sheet-meta {
  text-align: right;
}
.invoice-sheet-doc-type {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: #0f172a;
  margin: 0 0 0.5rem;
}
.invoice-meta-line {
  font-size: 0.875rem;
  margin: 0.15rem 0;
  color: #334155;
}
.invoice-sheet-billto {
  margin-bottom: 1.5rem;
}
.invoice-sheet-heading {
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  margin: 0 0 0.35rem;
}
.invoice-billto-name {
  font-size: 1rem;
  font-weight: 600;
  color: #0f172a;
  margin: 0 0 0.25rem;
}
.invoice-sheet-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
}
.invoice-sheet-table th {
  background: #f1f5f9;
  color: #334155;
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid #cbd5e1;
}
.invoice-sheet-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid #e2e8f0;
  font-size: 0.875rem;
  color: #1e293b;
}
.text-right {
  text-align: right;
}
.invoice-sheet-totals {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1.5rem;
}
.invoice-totals-table {
  width: min(280px, 100%);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.totals-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.875rem;
  color: #334155;
  padding: 0.2rem 0;
}
.totals-total {
  font-size: 1.05rem;
  font-weight: 700;
  color: #0f172a;
  border-top: 1px solid #cbd5e1;
  padding-top: 0.4rem;
  margin-top: 0.2rem;
}
.totals-balance {
  font-size: 1.15rem;
  font-weight: 800;
  color: #0f172a;
  background: #f8fafc;
  padding: 0.4rem 0.5rem;
  border-radius: var(--radius-sm);
}
.invoice-sheet-footer {
  border-top: 1px solid #e2e8f0;
  padding-top: 1rem;
}

/* Dedicated print mode for invoice */
@media print {
  body.printing-invoice {
    background: #ffffff !important;
  }
  body.printing-invoice .site-header,
  body.printing-invoice .site-footer,
  body.printing-invoice .tool-header,
  body.printing-invoice .invoice-summary-bar,
  body.printing-invoice .editor-pane,
  body.printing-invoice .preview-actions,
  body.printing-invoice .explainer,
  body.printing-invoice #invoice-storage-note,
  body.printing-invoice #inv-error,
  body.printing-invoice #inv-receipt-error,
  body.printing-invoice .skip-link,
  body.printing-invoice .toast-container,
  body.printing-invoice dialog {
    display: none !important;
  }
  body.printing-invoice main.container {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  body.printing-invoice .invoice-workspace {
    display: block !important;
    width: 100% !important;
  }
  body.printing-invoice .invoice-preview-pane {
    background: none !important;
    padding: 0 !important;
  }
  body.printing-invoice .invoice-sheet {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    background: #ffffff !important;
    color: #000000 !important;
  }
  body.printing-invoice .invoice-sheet * {
    color: #000000 !important;
  }
  body.printing-invoice .invoice-sheet-header {
    border-bottom: 2px solid #000000 !important;
  }
  body.printing-invoice .invoice-sheet-table th {
    background: #f0f0f0 !important;
    border-bottom: 1px solid #000000 !important;
  }
  body.printing-invoice .invoice-sheet-table td {
    border-bottom: 1px solid #dddddd !important;
  }
}

/* Keep invoice, bol, and packing controls and preview sheets within narrow screens. */
.invoice-workspace fieldset,
.invoice-workspace input,
.invoice-workspace select,
.invoice-workspace textarea,
.invoice-sheet-header > div,
.bol-item-field,
.ps-item-field {
  min-width: 0;
  max-width: 100%;
}
.invoice-workspace input[type="file"] { max-width: 100%; }
.invoice-sheet, .bol-sheet, .packing-sheet { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.invoice-sheet-table { table-layout: fixed; }
.invoice-sheet-table th:first-child { width: 40%; }
.invoice-sheet-table td, .invoice-sheet-table th { overflow-wrap: anywhere; }
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1rem;
}
.bol-sheet-table, .ps-sheet-table {
  min-width: 480px;
}
.bol-item-field, .ps-item-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.bol-item-field input, .ps-item-field input, .bol-item-field select, .ps-item-field select {
  width: 100%;
  min-width: 0;
}
@media screen and (max-width: 600px) {
  .invoice-preview-pane, .invoice-sheet { padding: .75rem; }
  .invoice-item-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 38px; gap: 0.4rem; }
  .invoice-item-row .item-field-desc { grid-column: 1 / -1; }
  .invoice-item-row .item-field-qty { grid-column: 1 / 2; }
  .invoice-item-row .item-field-price { grid-column: 2 / 3; }
  .invoice-item-row .btn-remove-item { align-self: end; margin-bottom: 2px; }
  .invoice-sheet-header { flex-direction: column; gap: .75rem; }
  .invoice-sheet-meta { text-align: left; }
  .invoice-sheet-table td, .invoice-sheet-table th { padding: .4rem .2rem; font-size: .75rem; }
}

/* Bill of lading styles */
.bol-item-row {
  display: grid;
  grid-template-columns: 60px 100px 90px minmax(0, 1.5fr) 85px 65px 38px;
  gap: 0.4rem;
  align-items: end;
  margin-bottom: 0.5rem;
}
.bol-sheet {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  font-size: 0.875rem;
  line-height: 1.4;
}
[data-theme="dark"] .bol-sheet {
  background: #ffffff;
  color: #0f172a;
}
.bol-sheet-header {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  border-bottom: 2px solid #0f172a;
  padding-bottom: 1rem;
  margin-bottom: 1rem;
}
.bol-sheet-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: #0f172a;
  margin: 0 0 0.25rem;
}
.bol-sheet-subtext-bold {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #334155;
  margin: 0 0 0.35rem;
}
.bol-sheet-disclaimer {
  font-size: 0.6875rem;
  color: #64748b;
  line-height: 1.3;
  margin: 0;
  max-width: 550px;
}
.bol-header-meta {
  text-align: right;
  min-width: 220px;
}
.bol-meta-line {
  font-size: 0.8125rem;
  margin: 0.15rem 0;
  color: #1e293b;
}
.bol-addresses-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
.bol-address-box {
  border: 1px solid #cbd5e1;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  background: #f8fafc;
}
.bol-box-heading {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #475569;
  margin: 0 0 0.35rem;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 0.25rem;
}
.bol-company-name {
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 0.25rem;
}
.bol-address-text, .bol-contact-text {
  font-size: 0.8125rem;
  color: #334155;
  white-space: pre-line;
  margin: 0 0 0.25rem;
}
.bol-instructions-box {
  border: 1px solid #cbd5e1;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  background: #f8fafc;
  margin-bottom: 1rem;
}
.bol-instructions-text {
  font-size: 0.8125rem;
  color: #334155;
  margin: 0;
  white-space: pre-line;
}
.bol-workspace {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: 1.5rem;
}
@media (max-width: 1050px) {
  .bol-workspace {
    grid-template-columns: 1fr;
  }
}
.bol-sheet-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
}
.bol-sheet-table th {
  background: #f1f5f9;
  color: #1e293b;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  padding: 0.25rem 0.35rem;
  border: 1px solid #cbd5e1;
  line-height: 1.2;
}
.bol-sheet-table td {
  padding: 0.25rem 0.35rem;
  border: 1px solid #cbd5e1;
  font-size: 0.75rem;
  color: #1e293b;
}
.bol-total-row td {
  background: #f8fafc;
  font-weight: 700;
  border-top: 2px solid #0f172a;
}
.bol-signatures-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
  border-top: 1px solid #cbd5e1;
  padding-top: 1rem;
}
.bol-sig-box {
  border: 1px solid #e2e8f0;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  color: #475569;
}
.bol-sig-cert {
  font-size: 0.6875rem;
  line-height: 1.35;
  margin-bottom: 1.5rem;
  color: #64748b;
}
.bol-sig-line {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid #0f172a;
  padding-top: 0.25rem;
  font-size: 0.6875rem;
  font-weight: 600;
  color: #334155;
}

/* Dedicated print styles for BOL */
@media print {
  body.printing-bol {
    background: #ffffff !important;
  }
  body.printing-bol .site-header,
  body.printing-bol .site-footer,
  body.printing-bol .tool-header,
  body.printing-bol .invoice-summary-bar,
  body.printing-bol .editor-pane,
  body.printing-bol .preview-actions,
  body.printing-bol .explainer,
  body.printing-bol #bol-storage-note,
  body.printing-bol #bol-error,
  body.printing-bol .skip-link,
  body.printing-bol .toast-container,
  body.printing-bol dialog {
    display: none !important;
  }
  body.printing-bol main.container {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  body.printing-bol .invoice-workspace {
    display: block !important;
    width: 100% !important;
  }
  body.printing-bol .invoice-preview-pane {
    background: none !important;
    padding: 0 !important;
  }
  body.printing-bol .bol-sheet {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    width: 100% !important;
    background: #ffffff !important;
    color: #000000 !important;
  }
  body.printing-bol .bol-sheet * {
    color: #000000 !important;
  }
  body.printing-bol .bol-sheet-table tr,
  body.printing-bol .bol-signatures-grid,
  body.printing-bol .bol-addresses-grid,
  body.printing-bol .bol-instructions-box {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }
}

/* Packing slip and pick list styles */
.tabs-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.tab-btn {
  background: var(--bg-muted);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}
.tab-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}
.ps-item-row {
  display: grid;
  grid-template-columns: 110px minmax(0, 2fr) 90px 70px 38px;
  gap: 0.4rem;
  align-items: end;
  margin-bottom: 0.5rem;
}
.packing-sheet {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  font-size: 0.875rem;
  line-height: 1.4;
}
[data-theme="dark"] .packing-sheet {
  background: #ffffff;
  color: #0f172a;
}
.ps-sheet-header {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  border-bottom: 2px solid #0f172a;
  padding-bottom: 1rem;
  margin-bottom: 1rem;
}
.ps-sheet-title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #0f172a;
  margin: 0 0 0.35rem;
}
.ps-company-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 0.25rem;
}
.ps-address-subtext {
  font-size: 0.8125rem;
  color: #475569;
  white-space: pre-line;
}
.ps-header-meta {
  text-align: right;
  min-width: 180px;
}
.ps-meta-line {
  font-size: 0.8125rem;
  margin: 0.15rem 0;
  color: #1e293b;
}
.ps-shipto-box {
  border: 1px solid #cbd5e1;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  background: #f8fafc;
  margin-bottom: 1rem;
  max-width: 380px;
}
.ps-box-heading {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #475569;
  margin: 0 0 0.35rem;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 0.2rem;
}
.ps-recipient-name {
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 0.25rem;
}
.ps-sheet-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
}
.ps-sheet-table th {
  background: #f1f5f9;
  color: #1e293b;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.5rem 0.6rem;
  border: 1px solid #cbd5e1;
}
.ps-sheet-table td {
  padding: 0.5rem 0.6rem;
  border: 1px solid #cbd5e1;
  font-size: 0.8125rem;
  color: #1e293b;
}
.ps-total-row td {
  background: #f8fafc;
  font-weight: 700;
  border-top: 2px solid #0f172a;
}
.pick-checkbox {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  letter-spacing: 0.1em;
  color: #475569;
}
.ps-footer-section {
  border-top: 1px solid #e2e8f0;
  padding-top: 0.75rem;
  margin-top: 1rem;
}
.ps-notes-text {
  font-size: 0.8125rem;
  color: #475569;
  margin: 0;
  white-space: pre-line;
}

/* Dedicated print styles for Packing slip / Pick list */
@media print {
  body.printing-packing {
    background: #ffffff !important;
  }
  body.printing-packing .site-header,
  body.printing-packing .site-footer,
  body.printing-packing .tool-header,
  body.printing-packing .invoice-summary-bar,
  body.printing-packing .editor-pane,
  body.printing-packing .preview-actions,
  body.printing-packing .explainer,
  body.printing-packing #ps-storage-note,
  body.printing-packing #ps-error,
  body.printing-packing .skip-link,
  body.printing-packing .toast-container,
  body.printing-packing dialog {
    display: none !important;
  }
  body.printing-packing main.container {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  body.printing-packing .invoice-workspace {
    display: block !important;
    width: 100% !important;
  }
  body.printing-packing .invoice-preview-pane {
    background: none !important;
    padding: 0 !important;
  }
  body.printing-packing .packing-sheet {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    width: 100% !important;
    background: #ffffff !important;
    color: #000000 !important;
  }
  body.printing-packing .packing-sheet * {
    color: #000000 !important;
  }
}

@media print {
  body.printing-bol .table-responsive,
  body.printing-packing .table-responsive {
    overflow: visible !important;
  }
  body.printing-bol .bol-sheet-table,
  body.printing-packing .ps-sheet-table {
    min-width: 0 !important;
    width: 100% !important;
  }
}

@media screen and (max-width: 600px) {
  .bol-sheet, .packing-sheet { padding: 0.75rem; }
  .bol-item-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0.35rem;
  }
  .bol-item-row .item-desc { grid-column: 1 / -1; }
  .bol-item-row .item-pkgs { grid-column: 1 / 2; }
  .bol-item-row .item-type { grid-column: 2 / 3; }
  .bol-item-row .item-weight { grid-column: 1 / 2; }
  .bol-item-row .item-nmfc { grid-column: 2 / 3; }
  .bol-item-row .item-class { grid-column: 1 / 2; }
  .bol-item-row .bol-remove-item { grid-column: 2 / 3; justify-self: end; align-self: end; margin-bottom: 2px; }
  .bol-sheet-header, .bol-addresses-grid, .bol-signatures-grid {
    flex-direction: column;
    grid-template-columns: minmax(0, 1fr);
  }
  .bol-header-meta { text-align: left; min-width: 0; }
  .ps-item-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0.35rem;
  }
  .ps-item-row .item-sku { grid-column: 1 / 2; }
  .ps-item-row .item-bin { grid-column: 2 / 3; }
  .ps-item-row .item-desc { grid-column: 1 / -1; }
  .ps-item-row .item-qty { grid-column: 1 / 2; }
  .ps-item-row .ps-remove-item { grid-column: 2 / 3; justify-self: end; align-self: end; margin-bottom: 2px; }
  .ps-sheet-header { flex-direction: column; }
  .ps-header-meta { text-align: left; min-width: 0; }
}

/* Timecard and shift styles */
.tc-shift-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 0.8fr) minmax(0, 0.8fr) 36px;
  gap: 0.5rem;
  align-items: end;
  margin-bottom: 0.6rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border-subtle);
}
.tc-shift-row input {
  min-height: 38px;
  font-size: 0.9375rem;
}
.shift-net-display {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
}
@media screen and (max-width: 600px) {
  .tc-shift-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 0.9fr) 36px;
    gap: 0.35rem;
  }
  .tc-shift-row .tc-shift-day { grid-column: 1 / -1; }
  .tc-shift-row .tc-shift-start { grid-column: 1 / 2; }
  .tc-shift-row .tc-shift-end { grid-column: 2 / 3; }
  .tc-shift-row .tc-shift-break { grid-column: 1 / 2; }
  .tc-shift-row .tc-shift-hours { grid-column: 2 / 3; }
  .tc-shift-row .tc-remove-shift { grid-column: 4 / 5; align-self: end; }
}

/* Tip pool styles */
.tp-staff-row {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr) 36px;
  gap: 0.5rem;
  align-items: end;
  margin-bottom: 0.6rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border-subtle);
}
.tp-staff-row input {
  min-height: 38px;
  font-size: 0.9375rem;
}
.tp-payout-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.tp-payout-table th, .tp-payout-table td {
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border-subtle);
}
.tp-payout-table th {
  background: var(--bg-subtle);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.tp-total-row td {
  background: var(--bg-subtle);
  font-weight: 700;
  border-top: 2px solid var(--border-strong, #333);
}
@media screen and (max-width: 600px) {
  .tp-staff-row {
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) 36px;
    gap: 0.35rem;
  }
  .tp-staff-row .tp-staff-name { grid-column: 1 / -1; }
}


/* Keep time entry readable within the calculator's half-width editor. */
.tc-shift-row {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 36px;
}
.tc-shift-row .tc-shift-day { grid-column: 1 / 3; }
.tc-shift-row .tc-shift-start { grid-column: 1; }
.tc-shift-row .tc-shift-end { grid-column: 2; }
.tc-shift-row .tc-shift-break { grid-column: 1; }
.tc-shift-row .tc-shift-hours { grid-column: 2; }
.tc-shift-row .tc-remove-shift { grid-column: 3; }

/* Recipe costing styles */
.rc-item-row {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr) minmax(0, 0.8fr) minmax(0, 1fr) 36px;
  gap: 0.5rem;
  align-items: end;
  margin-bottom: 0.6rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border-subtle);
}
.rc-item-row input {
  min-height: 38px;
  font-size: 0.9375rem;
}
.rc-remove-row {
  align-self: end;
  margin-bottom: 2px;
  min-height: 38px;
  width: 36px;
  font-size: 1.25rem;
}
.rc-scaled-table {
  width: 100%;
  border-collapse: collapse;
}
.rc-scaled-table th, .rc-scaled-table td {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.875rem;
}
.rc-scaled-table th {
  background: var(--bg-subtle);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.rc-total-row td {
  font-weight: 700;
  border-top: 2px solid var(--border-strong, #333);
  background: var(--bg-subtle);
}
@media screen and (max-width: 600px) {
  .rc-item-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 36px;
    gap: 0.35rem;
  }
  .rc-item-row .rc-field-name { grid-column: 1 / -1; }
  .rc-item-row .rc-field-qty { grid-column: 1 / 2; }
  .rc-item-row .rc-field-unit { grid-column: 2 / 3; }
  .rc-item-row .rc-field-price { grid-column: 1 / 2; }
  .rc-item-row .rc-remove-row { grid-column: 3 / 4; align-self: end; }
}


/* Recipe labels and fractional prices must remain readable. */
@media (min-width: 681px) {
  .rc-item-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 36px; }
  .rc-field-name { grid-column: 1 / -1; }
  .rc-field-price { grid-column: 1 / 3; }
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 52px;
  max-height: 52px;
  background-color: var(--bg-canvas);
  border-bottom: 1px solid var(--border-subtle);
  box-sizing: border-box;
  width: 100%;
  max-width: 100vw;
  overflow: hidden;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  max-height: 52px;
  padding-block: 0;
  gap: 0.5rem;
  box-sizing: border-box;
  min-width: 0;
  max-width: 100%;
}

.header-search {
  flex: 0 1 200px;
  min-width: 0;
  display: flex;
  align-items: center;
}

.header-search input[type="search"] {
  width: 100%;
  min-width: 0;
  height: 30px;
  min-height: 30px;
  padding: 0.2rem 0.6rem;
  font-size: 0.8125rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
  color: var(--text-main);
  box-sizing: border-box;
}

.header-inner > .site-nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
  min-width: 0;
}

@media (min-width: 861px) {
  .header-inner > .site-nav {
    justify-content: flex-end;
  }
}

@media (max-width: 680px) {
  .header-search {
    display: none !important;
  }
  .site-header {
    overflow: hidden !important;
    max-width: 100%;
  }
  .header-inner {
    gap: 0.25rem;
    overflow: hidden;
  }
  .header-inner > .site-nav {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    min-width: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
  .header-inner > .site-nav .nav-link,
  .header-inner > .site-nav .btn-share,
  .header-inner > .site-nav .theme-toggle {
    font-size: 0.75rem;
    padding: 0.2rem 0.35rem;
    white-space: nowrap;
    flex-shrink: 0;
  }
}

/* Tool icon & compact headings */
.tool-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tool-title-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.tool-title-group h1,
.tool-title-row h1,
h1 {
  font-size: 20px !important;
  line-height: 1.25 !important;
  margin: 0;
}

.tool-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  stroke: var(--primary);
  stroke-width: 2;
  fill: none;
  display: inline-block;
  vertical-align: middle;
}

/* Prevent mobile horizontal overflow across all pages */
html, body {
  max-width: 100%;
  overflow-x: hidden;
}

.invoice-workspace,
.bol-workspace,
.invoice-preview-pane,
.bol-sheet,
.packing-sheet,
.editor-pane,
.card,
.table-responsive {
  min-width: 0 !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

.invoice-preview-pane,
.bol-sheet,
.packing-sheet {
  overflow-x: hidden;
}

.table-responsive {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch;
  display: block !important;
  box-sizing: border-box !important;
}

@media screen and (max-width: 600px) {
  main {
    padding-top: 1rem !important;
  }
  .tool-header {
    margin-bottom: 0.75rem !important;
  }
  .card {
    padding: 0.85rem !important;
  }
  .form-row-2, .form-row-3 {
    grid-template-columns: 1fr !important;
    gap: 0.5rem !important;
  }
  .bol-addresses-grid,
  .bol-signatures-grid {
    grid-template-columns: 1fr !important;
  }
  .bol-sheet-header {
    flex-direction: column !important;
  }
  .bol-header-meta {
    text-align: left !important;
    min-width: 0 !important;
    width: 100% !important;
  }
  .invoice-summary-bar {
    padding: 0.6rem 0.85rem !important;
    gap: 0.4rem !important;
  }
  .container, .container-narrow {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }
}

@media print {
  @page {
    margin: 0.5in;
  }
  .result-card { position: static !important; max-height: none !important; overflow: visible !important; }
  body.printing-bol .tool-grid,
  body.printing-packing .tool-grid,
  body.printing-invoice .tool-grid,
  body.printing-bol .result-card,
  body.printing-packing .result-card,
  body.printing-invoice .result-card {
    break-inside: auto !important;
    page-break-inside: auto !important;
  }
  body.printing-bol tfoot,
  .bol-sheet tfoot {
    display: table-row-group !important;
  }
  body.printing-bol,
  body.printing-packing,
  body.printing-invoice {
    background: #ffffff !important;
    color: #000000 !important;
  }
}

/* Document & hiring tools: keep inputs first and document preview reachable on phones. */
@media screen and (max-width: 860px) {
  .invoice-workspace > .editor-pane { order: 0 !important; }
  .invoice-workspace > .invoice-preview-pane { order: 1 !important; }
  .invoice-preview-pane .table-responsive { display: block !important; }
}

/* Embedded inside shell iframe */
html.embedded .site-header,
html.embedded .site-footer,
html.embedded .tool-header,
html.embedded #storage-note {
  display: none !important;
}
.embedded-toolbar {
  display: none;
}
html.embedded .embedded-toolbar {
  display: flex !important;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: 4px !important;
}
html.embedded .embedded-toolbar .embedded-help-btn {
  height: 28px !important;
  min-height: 28px !important;
  max-height: 32px !important;
  font-size: 0.8125rem !important;
  padding: 2px 10px !important;
  box-sizing: border-box !important;
}
.invoice-workspace input:not([type="checkbox"]):not([type="radio"]),
.invoice-workspace select,
.tool-grid input:not([type="checkbox"]):not([type="radio"]),
.tool-grid select {
  height: 28px;
  min-height: 28px;
  max-height: 32px;
  padding: 3px 8px;
  font-size: 0.875rem;
  border-radius: var(--radius-sm);
  box-sizing: border-box;
}

html.embedded input[type="text"],
html.embedded input[type="number"],
html.embedded input[type="date"],
html.embedded input[type="search"],
html.embedded input[type="email"],
html.embedded input[type="tel"],
html.embedded input[type="url"],
html.embedded select {
  height: 28px !important;
  min-height: 28px !important;
  max-height: 32px !important;
  padding: 2px 8px !important;
  font-size: 0.875rem !important;
  box-sizing: border-box !important;
}
html.embedded .btn {
  height: 28px !important;
  min-height: 28px !important;
  max-height: 32px !important;
  padding: 2px 10px !important;
  font-size: 0.8125rem !important;
  box-sizing: border-box !important;
}
html.embedded .form-group {
  margin-bottom: 4px !important;
}
html.embedded .form-group label {
  font-size: 0.75rem !important;
  margin-bottom: 2px !important;
}
html.embedded main {
  padding-top: 0.25rem !important;
  max-width: 100% !important;
}
html.embedded .invoice-summary-bar {
  padding: 4px 6px !important;
  margin-bottom: 4px !important;
  gap: 4px !important;
  box-shadow: none !important;
}
.invoice-summary-bar .action-row,
.invoice-summary-bar .preview-actions,
html.embedded .invoice-summary-bar .action-row,
html.embedded .invoice-summary-bar .preview-actions {
  margin: 0 !important;
}
html.embedded .invoice-summary-bar .summary-metric {
  flex-direction: row !important;
  align-items: baseline !important;
  gap: 4px !important;
}
html.embedded .invoice-summary-bar .summary-label {
  font-size: 0.6875rem !important;
}
html.embedded .invoice-summary-bar .summary-value {
  font-size: 0.8125rem !important;
  font-weight: 600 !important;
}
html.embedded .editor-pane > p.muted,
html.embedded .form-section > p.muted {
  display: none !important;
}
html.embedded .form-section {
  padding: 4px 6px !important;
  margin: 4px 0 !important;
}
html.embedded .form-section > legend {
  font-size: 0.75rem !important;
  margin-bottom: 2px !important;
  font-weight: 600 !important;
}
html.embedded .card {
  padding: 6px 8px !important;
  box-shadow: none !important;
}

/* Theme-aware document preview on screen, crisp black ink on white paper for print */
.hiring-tool .bol-sheet {
  background: var(--bg-card) !important;
  color: var(--text-main) !important;
  border-color: var(--border-subtle) !important;
}
.hiring-tool .bol-sheet [data-theme-box] {
  background: var(--bg-subtle) !important;
  border-color: var(--border-subtle) !important;
  color: var(--text-main) !important;
}
@media print {
  .hiring-tool .bol-sheet {
    background: #ffffff !important;
    color: #000000 !important;
    border: none !important;
  }
  .hiring-tool .bol-sheet * {
    color: #000000 !important;
  }
}
/* Print only the completed hiring document, including all score rows. */
@media print {
  .hiring-tool .editor-pane,
  .hiring-tool .tool-header,
  .hiring-tool .invoice-summary-bar,
  .hiring-tool main > .section { display: none !important; }
  .hiring-tool main.container { max-width: none; padding: 0 !important; margin: 0; }
  .hiring-tool .tool-grid { display: block !important; break-inside: auto !important; }
  .hiring-tool .invoice-workspace { display: block !important; padding: 0; }
  .hiring-tool .invoice-preview-pane,
  .hiring-tool .packing-sheet {
    position: static !important; overflow: visible !important;
    max-height: none !important; padding: 0 !important; border: 0 !important;
    break-inside: auto !important;
  }
  .hiring-tool .table-responsive { display: block !important; overflow: visible !important; }
  .hiring-tool tr { break-inside: avoid; }
  .hiring-tool thead { display: table-header-group; }
}

/* A status message must never intercept a tool action, even while fading out. */
.toast-container, .toast { pointer-events: none; }

/* Full account digits belong only on the completed paper authorization. */
@media screen { .bank-print-account { display: none; } }
@media print { .bank-screen-account { display: none; } }

/* QR Generator styles */
.qr-preview-box {
  background: #ffffff;
  padding: 1.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 240px;
  margin-bottom: 1rem;
}
.qr-preview-box canvas,
.qr-preview-box svg {
  max-width: 100%;
  height: auto;
  image-rendering: pixelated;
}
.qr-payload-text {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  word-break: break-all;
  max-height: 80px;
  overflow-y: auto;
  background: var(--bg-subtle);
  padding: 0.5rem;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
  width: 100%;
  box-sizing: border-box;
}

/* Barcode Generator styles */
.barcode-preview-box {
  background: #ffffff;
  padding: 1.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  margin-bottom: 1rem;
  color: #000000;
}
.barcode-preview-box svg {
  max-width: 100%;
  height: auto;
}
.barcode-label-text {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
  text-align: center;
  color: #000000;
}
.barcode-price-tag {
  font-size: 1.1rem;
  font-weight: 700;
  color: #000000;
  margin-top: 0.25rem;
}

/* PDF Tools styles */
.pdf-dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 1.5rem;
  text-align: center;
  background: var(--bg-subtle);
  cursor: pointer;
  transition: border-color 0.15s ease;
  margin-bottom: 1rem;
}
.pdf-dropzone:hover, .pdf-dropzone:focus-within {
  border-color: var(--accent);
}
.pdf-file-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem 0;
}
.pdf-file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}
.pdf-file-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pdf-file-actions {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
}
.pdf-file-actions .btn-sm {
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
}


/* Core file tools: input-first, compact controls in standalone and shell views. */
@media screen {
  .core-tool main.container { padding: 8px; }
  .core-tool .tool-header { margin: 4px 0 8px; }
  .core-tool h1 { font-size: 16px; }
  .core-tool .tool-grid { gap: 8px; align-items: start; }
  .core-tool .card, .core-tool .result-card, .core-tool .invoice-summary-bar {
    padding: 8px; border-radius: 3px; box-shadow: none; margin-bottom: 8px;
  }
  .core-tool .summary-value { font-size: 14px; overflow-wrap: anywhere; }
  .core-tool .summary-label { text-transform: none; }
  .core-tool .form-group { margin-bottom: 8px; }
  .core-tool input:not([type=checkbox]), .core-tool select, .core-tool .btn {
    min-height: 28px; padding: 4px 8px; font-size: 14px; border-radius: 3px;
  }
  .core-tool .section { margin-top: 8px; }
  .core-tool .qr-preview-box, .core-tool .barcode-preview-box { min-height: 0; padding: 8px; margin-bottom: 8px; }
  .core-tool .qr-preview-box { color: #000; }
  .core-tool .pdf-dropzone { padding: 8px; margin-bottom: 8px; }
  .core-tool .pdf-file-item { padding: 4px; margin-bottom: 4px; }
  .core-tool #pdf-action-btn { padding: 4px 8px !important; margin-top: 8px !important; font-size: 14px !important; }
  .core-tool .invoice-preview-pane { position: static; }
}
@media screen and (max-width: 760px) {
  .core-tool .tool-grid { display: flex; flex-direction: column; }
  .core-tool .editor-pane { order: 0; width: 100%; }
  .core-tool .invoice-preview-pane { order: 1; width: 100%; }
}
@media print {
  .core-tool .editor-pane, .core-tool .invoice-summary-bar,
  .core-tool .explainer, .core-tool .tool-header { display: none !important; }
  .core-tool .result-card { border: 0; box-shadow: none; padding: 0; }
  .core-tool .result-card > :not(.qr-preview-box):not(.barcode-preview-box) { display: none !important; }
  #rc-sheet.layout-compact-3x5 {
    width: 3.5in !important;
    height: 5in !important;
    min-height: 5in !important;
    max-height: 5in !important;
    box-sizing: border-box !important;
  }
  #rc-sheet.layout-vertical-4x6 {
    width: 4in !important;
    height: 6in !important;
    min-height: 6in !important;
    max-height: 6in !important;
    box-sizing: border-box !important;
  }
}

/* Help and worked examples are not part of the user's printed document. */
@media print { .tool-explainer { display: none !important; } }

/* The freight editor shares the screen with its preview. Use its own width,
   rather than the full viewport, when arranging commodity fields. */
.bol-items-inputs { container-type: inline-size; }
@container (max-width: 680px) {
  .bol-item-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .bol-item-row .item-desc { grid-column: 1 / -1; }
}
@container (max-width: 380px) {
  .bol-item-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.bol-item-field label, #bol-top-total-label { color: var(--text-muted) !important; }

/* Reserve the document space until the first live render, without flashing HTML examples. */
:is(#invoice-sheet,#bol-sheet,#packing-sheet,#jp-sheet,#rc-sheet):not([data-preview-ready]){visibility:hidden}

/* Document paper retains readable ink independent of the surrounding UI theme. */
:is(#bol-sheet,#invoice-sheet,#packing-sheet,#jp-sheet) { --text-main:#0f172a; --text-muted:#334155; }
:is(#bol-sheet,#invoice-sheet,#packing-sheet,#jp-sheet) strong { color:inherit; }
:is(#inv-top-total-label,#ps-top-total-label,#jp-top-title-label,#rc-top-label) { color:var(--text-muted)!important; }
:is(#inv-items-list,#ps-items-list) label { color:var(--text-muted)!important; }
:is(#ps-tab-manual,#ps-tab-csv).active { color:var(--primary-text); }

/* v3 shell embed: same colors as the shell, compact desktop-software density */
html.embedded{--radius-sm:3px;--radius-md:4px;--radius-lg:4px;--shadow-sm:none;--shadow-md:none;--shadow-lg:none;--font-sans:system-ui,-apple-system,"Segoe UI",Roboto,sans-serif}
html.embedded[data-theme="light"]{--bg-canvas:#FFFFFF;--bg-card:#FFFFFF;--bg-elevated:#FFFFFF;--bg-subtle:#F4F5F6;--bg-muted:#EBECEE;--bg-accent:#EBECEE;--text-main:#1D1F22;--text-muted:#555B63;--text-faint:#7A808A;--border-subtle:#D9DCE0;--border-strong:#B8BDC4;--border-focus:#1F5FBF;--primary:#1F5FBF;--primary-hover:#184C99;--primary-subtle:#E5EDFA;--primary-text:#FFFFFF;--text-inverse:#FFFFFF}
html.embedded[data-theme="dark"]{--bg-canvas:#1E1F22;--bg-card:#1E1F22;--bg-elevated:#25272B;--bg-subtle:#25272B;--bg-muted:#2C2E33;--bg-accent:#2C2E33;--text-main:#E4E5E7;--text-muted:#A3A7AD;--text-faint:#80858C;--border-subtle:#34373C;--border-strong:#4A4E55;--border-focus:#6F9CEB;--primary:#6F9CEB;--primary-hover:#8DB1F0;--primary-subtle:#26324A;--primary-text:#111317;--text-inverse:#111317}
html.embedded[data-theme="neutral"]{--bg-canvas:#E9E9E7;--bg-card:#E9E9E7;--bg-elevated:#F2F2F0;--bg-subtle:#E1E1DF;--bg-muted:#D9D9D6;--bg-accent:#D9D9D6;--text-main:#252523;--text-muted:#5A5A56;--text-faint:#7C7C77;--border-subtle:#C9C9C5;--border-strong:#AFAFAA;--border-focus:#3B5B7A;--primary:#3B5B7A;--primary-hover:#2E4860;--primary-subtle:#D5DDE5;--primary-text:#FFFFFF;--text-inverse:#FFFFFF}
html.embedded body{background:var(--bg-canvas)!important;font-size:14px!important;line-height:1.4!important}
html.embedded .site-header,html.embedded .site-footer,html.embedded .skip-link,html.embedded nav.breadcrumb,html.embedded .breadcrumbs{display:none!important}
html.embedded .tool-header h1{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)}
html.embedded main,html.embedded .container{max-width:none!important;padding:10px 14px!important;margin:0!important}
html.embedded h1{font-size:17px!important}html.embedded h2{font-size:14px!important;margin:10px 0 6px!important}html.embedded h3{font-size:13.5px!important}
html.embedded .card,html.embedded .result-card,html.embedded section{border-radius:4px!important;box-shadow:none!important}
html.embedded .card,html.embedded .result-card{padding:10px!important}
html.embedded input,html.embedded select,html.embedded textarea{font-size:14px!important;min-height:28px!important;padding:3px 6px!important;border-radius:3px!important}
html.embedded .btn,html.embedded button{font-size:13.5px!important;padding:4px 10px!important;min-height:28px!important;border-radius:3px!important}
html.embedded label{font-size:13px!important;margin-bottom:2px!important}
html.embedded [class*="grid"],html.embedded .tool-grid{gap:10px!important}
html.embedded p{margin:4px 0 8px!important}

/* Shared accessibility palettes. Red hearts retain fill/outline state cues. */
html:root[data-theme="contrast"]{--bg:#000000;--bar:#121212;--ink:#FFFFFF;--muted:#FFFFFF;--line:#A6A6A6;--sel:#FFFFFF;--sel-ink:#000000;--accent:#FFFFFF;--hover:#242424;--ok:#FFFFFF;--heart:#FF6666;--bg-2:#000000;--bg-3:#121212;--bg-4:#242424;--line-2:#A6A6A6;--text:#FFFFFF;--text-2:#FFFFFF;--text-3:#FFFFFF;--accent-hover:#FFFFFF;--accent-ink:#000000;--accent-2:#FFFFFF;--good:#FFFFFF;--warn:#FFFFFF;--green:#FFFFFF;--lime:#FFFFFF;--paper:#000000;--white:#000000;--x-in:#000000;--bg-canvas:#000000;--bg-card:#000000;--bg-elevated:#121212;--bg-subtle:#121212;--bg-muted:#242424;--bg-accent:#FFFFFF;--text-main:#FFFFFF;--text-muted:#FFFFFF;--text-faint:#FFFFFF;--border-subtle:#A6A6A6;--border-strong:#A6A6A6;--border-focus:#FFFFFF;--primary:#FFFFFF;--primary-hover:#FFFFFF;--primary-subtle:#FFFFFF;--primary-text:#000000;--text-inverse:#000000;--success:#FFFFFF;--success-subtle:#121212;--success-text:#FFFFFF;--warning:#FFFFFF;--warning-subtle:#121212;--warning-text:#FFFFFF;--danger:#FFFFFF;--danger-subtle:#121212;--danger-text:#FFFFFF;--e-bg:#000000;--e-in:#000000;--e-ink:#FFFFFF;--e-muted:#FFFFFF;--e-line:#A6A6A6;--e-line2:#A6A6A6;--e-acc:#FFFFFF;--e-acc-ink:#000000;color-scheme:dark}
html:root[data-theme="mono"]{--bg:#FFFFFF;--bar:#F2F2F2;--ink:#000000;--muted:#333333;--line:#666666;--sel:#000000;--sel-ink:#FFFFFF;--accent:#000000;--hover:#E6E6E6;--ok:#000000;--heart:#C00020;--bg-2:#FFFFFF;--bg-3:#F2F2F2;--bg-4:#E6E6E6;--line-2:#666666;--text:#000000;--text-2:#333333;--text-3:#333333;--accent-hover:#000000;--accent-ink:#FFFFFF;--accent-2:#000000;--good:#000000;--warn:#000000;--green:#000000;--lime:#000000;--paper:#FFFFFF;--white:#FFFFFF;--x-in:#FFFFFF;--bg-canvas:#FFFFFF;--bg-card:#FFFFFF;--bg-elevated:#F2F2F2;--bg-subtle:#F2F2F2;--bg-muted:#E6E6E6;--bg-accent:#000000;--text-main:#000000;--text-muted:#333333;--text-faint:#333333;--border-subtle:#666666;--border-strong:#666666;--border-focus:#000000;--primary:#000000;--primary-hover:#000000;--primary-subtle:#000000;--primary-text:#FFFFFF;--text-inverse:#FFFFFF;--success:#000000;--success-subtle:#F2F2F2;--success-text:#000000;--warning:#000000;--warning-subtle:#F2F2F2;--warning-text:#000000;--danger:#000000;--danger-subtle:#F2F2F2;--danger-text:#000000;--e-bg:#FFFFFF;--e-in:#FFFFFF;--e-ink:#000000;--e-muted:#333333;--e-line:#666666;--e-line2:#666666;--e-acc:#000000;--e-acc-ink:#FFFFFF;color-scheme:light}
html:root[data-theme="colorblind"]{--bg:#FFFFFF;--bar:#F0F4F7;--ink:#17232D;--muted:#44515C;--line:#78838D;--sel:#DCEAF5;--sel-ink:#123B56;--accent:#005A85;--hover:#E7EFF5;--ok:#005A85;--heart:#C00020;--bg-2:#FFFFFF;--bg-3:#F0F4F7;--bg-4:#E7EFF5;--line-2:#78838D;--text:#17232D;--text-2:#44515C;--text-3:#44515C;--accent-hover:#005A85;--accent-ink:#FFFFFF;--accent-2:#005A85;--good:#005A85;--warn:#17232D;--green:#005A85;--lime:#DCEAF5;--paper:#FFFFFF;--white:#FFFFFF;--x-in:#FFFFFF;--bg-canvas:#FFFFFF;--bg-card:#FFFFFF;--bg-elevated:#F0F4F7;--bg-subtle:#F0F4F7;--bg-muted:#E7EFF5;--bg-accent:#DCEAF5;--text-main:#17232D;--text-muted:#44515C;--text-faint:#44515C;--border-subtle:#78838D;--border-strong:#78838D;--border-focus:#005A85;--primary:#005A85;--primary-hover:#005A85;--primary-subtle:#DCEAF5;--primary-text:#FFFFFF;--text-inverse:#FFFFFF;--success:#005A85;--success-subtle:#F0F4F7;--success-text:#17232D;--warning:#17232D;--warning-subtle:#F0F4F7;--warning-text:#17232D;--danger:#17232D;--danger-subtle:#F0F4F7;--danger-text:#17232D;--e-bg:#FFFFFF;--e-in:#FFFFFF;--e-ink:#17232D;--e-muted:#44515C;--e-line:#78838D;--e-line2:#78838D;--e-acc:#005A85;--e-acc-ink:#FFFFFF;color-scheme:light}
html[data-theme=contrast] .brand{color:#fff}html[data-theme=contrast] :is(.row.cur,.b.give,.seg button[aria-pressed=true]){color:#000}html[data-theme=mono] .brand{color:#000}
html[data-theme=contrast] :focus-visible{outline:3px solid var(--accent,#FFFFFF)!important;outline-offset:2px}html[data-theme=mono] :focus-visible{outline:3px solid #000!important;outline-offset:2px}
@media screen{html[data-theme=contrast] a,html[data-theme=mono] a,html[data-theme=colorblind] a{text-decoration:underline}}

/* Primary actions must remain readable on the yellow high-contrast accent. */
html[data-theme=contrast] :is(.btn-primary,.btn-primary:hover){color:var(--accent-ink,#000)!important}

/* Personal accent controls remain compact and native-keyboard accessible. */
.accent-controls{display:inline-flex;align-items:center;gap:4px;flex-shrink:0}.accent-controls label{font-size:12px;display:inline-flex;align-items:center;gap:4px;margin:0}.accent-controls input[type=color]{width:28px;height:24px;padding:1px;border:1px solid var(--line);background:var(--bar);cursor:pointer}.accent-controls button{font:inherit;padding:2px 5px;border:1px solid var(--line);background:var(--bar);color:var(--ink);border-radius:3px;cursor:pointer}html[data-custom-accent] .b.give{background:var(--accent);color:var(--accent-ink)}html[data-custom-accent] :is(.row.cur,.seg button[aria-pressed=true]){color:var(--sel-ink)}
@media(max-width:600px){.accent-controls label span{display:none}.accent-controls button{font-size:11px;padding:2px 3px}.accent-controls{gap:2px}}
