/* Handoff shared visual system
   Loaded after each page's legacy styles so every surface can share one set of
   tokens without changing the app's existing layout or behavior. */
:root {
  color-scheme: light;
  --surface-page: #f4f7f5;
  --surface-1: #ffffff;
  --surface-2: #f8faf9;
  --surface-3: #eef3f0;
  --text: #111816;
  --text-soft: #33403b;
  --text-muted: #66716d;
  --border: #dce3df;
  --border-strong: #c8d2cd;
  --accent: #0f4f35;
  --accent-hover: #0a3d2a;
  --accent-soft: #e8f3ed;
  --accent-border: #c7ded2;
  --danger: #a94122;
  --danger-soft: #fff2ec;
  --warning-soft: #fff7dd;
  --focus-ring: rgba(15, 79, 53, 0.18);
  --overlay: rgba(11, 18, 15, 0.48);
  --shadow-sm: 0 1px 2px rgba(17, 24, 22, 0.04), 0 6px 18px rgba(17, 24, 22, 0.035);
  --shadow-md: 0 16px 40px rgba(17, 24, 22, 0.10);
  --radius-control: 8px;
  --radius-card: 10px;
  --radius-modal: 12px;
  --transition-fast: 150ms ease;

  /* Map the original palette variables to the shared system. */
  --green: var(--accent);
  --green-dark: var(--accent-hover);
  --green-soft: var(--accent-soft);
  --green-line: var(--accent-border);
  --ink: var(--text);
  --muted: var(--text-muted);
  --line: var(--border);
  --panel: var(--surface-1);
  --paper: var(--surface-1);
  --page: var(--surface-page);
  --soft: var(--surface-page);
  --warning: var(--danger);
  --yellow: var(--warning-soft);
  --shadow: var(--shadow-md);
  --radius: var(--radius-card);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --surface-page: #111513;
  --surface-1: #181d1a;
  --surface-2: #1d2320;
  --surface-3: #242b27;
  --text: #f2f5f3;
  --text-soft: #d3dbd7;
  --text-muted: #9da9a3;
  --border: #303834;
  --border-strong: #424c47;
  --accent: #66c89c;
  --accent-hover: #82d5ae;
  --accent-soft: #18382d;
  --accent-border: #2c5a46;
  --danger: #ff9a78;
  --danger-soft: #3c211b;
  --warning-soft: #3b3219;
  --focus-ring: rgba(102, 200, 156, 0.24);
  --overlay: rgba(0, 0, 0, 0.68);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.24), 0 8px 22px rgba(0, 0, 0, 0.12);
  --shadow-md: 0 20px 52px rgba(0, 0, 0, 0.36);
}

html {
  background: var(--surface-page);
}

body {
  color: var(--text);
  background: var(--surface-page);
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

button,
input,
select,
textarea,
a {
  transition: color var(--transition-fast), background-color var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

::selection {
  color: #ffffff;
  background: #176a4a;
}

/* Controls */
.button,
.mini-button,
.menu-button,
.auth-link-button,
.feedback-launcher,
.dashboard-action-menu summary,
.dashboard-action-menu-popover button,
.support-form button {
  border-radius: var(--radius-control);
}

.button {
  min-height: 42px;
  padding-inline: 16px;
  box-shadow: none;
}

.button:hover,
.mini-button:hover,
.menu-button:hover,
.support-form button:hover {
  transform: translateY(-1px);
}

.button:active,
.mini-button:active,
.menu-button:active,
.support-form button:active {
  transform: translateY(0);
}

.button-primary,
.dashboard-quick-bar .mini-button.is-primary,
.filter-buttons button.is-active,
.period-tabs button.is-active,
.support-form button {
  color: #ffffff;
  border-color: #0f4f35;
  background: #0f4f35;
  box-shadow: 0 1px 2px rgba(10, 53, 37, 0.18);
}

.button-primary:hover,
.dashboard-quick-bar .mini-button.is-primary:hover,
.filter-buttons button.is-active:hover,
.period-tabs button.is-active:hover,
.support-form button:hover {
  color: #ffffff;
  border-color: #0a3d2a;
  background: #0a3d2a;
}

html[data-theme="dark"] .button-primary,
html[data-theme="dark"] .dashboard-quick-bar .mini-button.is-primary,
html[data-theme="dark"] .filter-buttons button.is-active,
html[data-theme="dark"] .period-tabs button.is-active,
html[data-theme="dark"] .support-form button {
  border-color: #287d59;
  background: #287d59;
}

html[data-theme="dark"] .button-primary:hover,
html[data-theme="dark"] .dashboard-quick-bar .mini-button.is-primary:hover,
html[data-theme="dark"] .filter-buttons button.is-active:hover,
html[data-theme="dark"] .period-tabs button.is-active:hover,
html[data-theme="dark"] .support-form button:hover {
  border-color: #32956b;
  background: #32956b;
}

.button-secondary,
.button-plain,
.mini-button,
.menu-button {
  color: var(--text-soft);
  border-color: var(--border);
  background: var(--surface-1);
}

.button-secondary {
  color: var(--accent);
  border-color: var(--accent-border);
}

.button-secondary:hover,
.button-plain:hover,
.mini-button:hover,
.menu-button:hover {
  color: var(--accent);
  border-color: var(--accent-border);
  background: var(--accent-soft);
}

.button-danger {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 40%, var(--border));
  background: var(--surface-1);
}

.button-danger:hover {
  background: var(--danger-soft);
}

button:disabled,
.button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
  transform: none;
}

/* Inputs and selectable fields */
input:not([type="checkbox"]):not([type="radio"]),
select,
textarea,
.readonly-field {
  border-color: var(--border-strong);
  border-radius: var(--radius-control);
  color: var(--text);
  background: var(--surface-1);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.78;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

label,
.mini-label {
  color: var(--text-soft);
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: #176a4a;
}

/* Cards, dialogs, tables, and repeated surfaces */
.card,
.feature-card,
.step-card,
.industry-chip,
.cta-card,
.dashboard-mockup,
.stat-card,
.jobs-panel,
.legal-card,
.customer-card,
.history-row,
.customer-result,
.part-card,
.picker-part,
.mobile-card,
.dashboard-summary-card,
.dashboard-section-card,
.dashboard-widget,
.report-card,
.export-card,
.subsection,
.line-item,
.job-card,
.billing-status,
.tax-default-list div {
  border-color: var(--border);
  border-radius: var(--radius-card);
  color: var(--text);
  background: var(--surface-1);
  box-shadow: var(--shadow-sm);
}

.modal-card,
.customize-panel,
.customer-form-panel > .customer-form-inner,
.part-drawer {
  border-color: var(--border);
  border-radius: var(--radius-modal);
  color: var(--text);
  background: var(--surface-1);
  box-shadow: var(--shadow-md);
}

.customer-form-panel,
.modal-backdrop,
.customize-backdrop,
.drawer-backdrop {
  background: var(--overlay);
}

.drawer-actions,
.email-suggestions,
.quick-customer,
.asset-picker,
.customer-preview,
.cloud-sync-status,
.advanced-settings,
#settingsTaxLines .tax-line,
.tax-default-list div,
.mobile-card,
.customer-card,
.history-row,
.customer-result,
.part-card,
.picker-part,
.line-item,
.job-card {
  color: var(--text-soft);
  background: var(--surface-1);
}

.subsection,
.readonly-field,
.billing-status,
.advanced-settings,
#settingsTaxLines .tax-line,
.dashboard-action-menu-popover,
.browser-bar,
.mock-sidebar,
.quote-box,
.message-box {
  background: var(--surface-2);
}

.panel-head,
.drawer-head,
.drawer-actions,
th,
td,
.dashboard-invoice-row,
.dashboard-attention-row,
.job-row,
.jobs-title {
  border-color: var(--border);
}

th {
  color: var(--text-muted);
  background: var(--surface-2);
}

td,
.part-cell,
.part-more-cell,
.total-row,
.job-amount,
.quote-line,
.message-box p,
.check-list,
.industry-chip,
.nav-links,
.footer-links,
.login-link,
.mobile-panel a {
  color: var(--text-soft);
}

tbody tr:hover td {
  background: var(--surface-2);
}

.muted,
.fine-print,
.panel-head p,
.drawer-head p,
.dashboard-section-head p,
.dashboard-widget > p,
.dashboard-summary-card span,
.stat-label,
.footer-copy,
.legal-updated,
.legal-footer-inner {
  color: var(--text-muted);
}

.note,
.legal-note,
.customer-preview,
.job-subtotal,
.totals-box {
  color: var(--text-soft);
  border-color: var(--accent-border);
  border-radius: var(--radius-card);
  background: var(--accent-soft);
}

.billing-access-notice,
.unpaid-soft {
  color: var(--text);
  border-color: color-mix(in srgb, #d3a93d 45%, var(--border));
  background: var(--warning-soft);
}

.invoice-warning {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 40%, var(--border));
  border-radius: var(--radius-card);
  background: var(--danger-soft);
}

/* Pills are reserved for statuses. */
.status,
.status-pill,
.badge {
  border-radius: 999px;
}

.customer-type,
.industry-chip,
.icon-chip,
.step-number,
.dashboard-summary-card,
.dashboard-widget,
.report-card,
.export-card,
.quick-features li,
.quote-box,
.message-box,
.phone-buttons span,
.theme-choice {
  border-radius: var(--radius-control);
}

.status-draft,
.status-void {
  color: var(--text-soft);
  background: var(--surface-3);
}

.status-paid,
.badge-done,
.status-pill {
  color: var(--accent);
  background: var(--accent-soft);
}

.status-unpaid,
.status-overdue,
.badge-overdue {
  color: var(--danger);
  background: var(--danger-soft);
}

.status-partially-paid,
.badge-quote {
  color: var(--text);
  background: var(--warning-soft);
}

/* Navigation and app frame */
.sidebar,
.topbar,
.site-header,
.site-footer,
.legal-header,
.legal-footer {
  border-color: var(--border);
  background: color-mix(in srgb, var(--surface-1) 92%, transparent);
}

.sidebar {
  background: var(--surface-1);
}

.nav button {
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  color: var(--text-soft);
}

.nav button:hover {
  color: var(--text);
  border-color: var(--border);
  background: var(--surface-2);
}

.nav button.is-active {
  color: var(--accent);
  border-color: var(--accent-border);
  background: var(--accent-soft);
}

.feedback-launcher {
  border-color: var(--border);
  color: var(--text-soft);
  background: var(--surface-2);
}

.feedback-launcher:hover {
  border-color: var(--accent-border);
  color: var(--accent);
  background: var(--accent-soft);
}

.cloud-sync-status {
  border-radius: var(--radius-control);
}

.content:has(#dashboard.is-active) {
  background: transparent;
}

.auth-screen,
.setup-screen {
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--accent-soft) 72%, transparent), transparent 42%),
    var(--surface-page);
}

.dashboard-quick-bar,
.dashboard-section-card,
.dashboard-widget,
.dashboard-summary-card {
  border-color: var(--border);
  background: var(--surface-1);
}

.dashboard-action-menu summary,
.dashboard-action-menu-popover button {
  color: var(--text-soft);
  background: var(--surface-1);
}

.dashboard-action-menu-popover {
  border-color: var(--border);
  box-shadow: var(--shadow-md);
}

.dashboard-action-menu-popover button:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

/* Settings-only theme control */
.settings-appearance-card {
  grid-column: 1 / -1;
}

.appearance-setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.appearance-setting-copy {
  display: grid;
  gap: 4px;
}

.appearance-setting-copy strong {
  font-size: 0.95rem;
}

.appearance-setting-copy span {
  color: var(--text-muted);
  font-size: 0.86rem;
}

.theme-choices {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(92px, 1fr));
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface-2);
}

.theme-choice {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid transparent;
  color: var(--text-soft);
  background: transparent;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 820;
  cursor: pointer;
}

.theme-choice:hover {
  color: var(--text);
  background: var(--surface-3);
}

.theme-choice[aria-pressed="true"] {
  color: var(--accent);
  border-color: var(--accent-border);
  background: var(--accent-soft);
  box-shadow: var(--shadow-sm);
}

/* Marketing and legal surfaces */
.hero,
main,
.section {
  background: var(--surface-page);
}

.section-muted {
  border-color: var(--border);
  background: var(--surface-2);
}

.quick-features li,
.dashboard-mockup,
.mock-content,
.stat-card,
.jobs-panel,
.phone-screen,
.feature-card,
.step-card,
.industry-chip,
.cta-card,
.site-footer {
  background: var(--surface-1);
}

.dashboard-mockup {
  border-color: var(--border-strong);
  border-radius: var(--radius-modal);
}

.phone-mockup {
  border-radius: 18px;
}

.phone-screen {
  border-radius: 13px;
}

.feature-card,
.step-card,
.quick-features li,
.industry-chip {
  box-shadow: none;
}

.feature-card:hover,
.step-card:hover,
.quick-features li:hover,
.industry-chip:hover,
.card:hover {
  border-color: var(--border-strong);
}

.legal-card p,
.legal-card ul {
  color: var(--text-soft);
}

.support-form input,
.support-form select,
.support-form textarea {
  border-color: var(--border-strong);
  border-radius: var(--radius-control);
  color: var(--text);
  background: var(--surface-1);
}

.support-form input:focus,
.support-form select:focus,
.support-form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

/* Dark-theme hardening
   These rules intentionally sit at the end of the cascade and use important
   only for surface/text colours. Some of the original responsive app rules
   use ID selectors, which otherwise allow white mobile cards to win. */
html[data-theme="dark"] body {
  --text: #f4f7f5;
  --text-soft: #f4f7f5;
  --text-muted: #f4f7f5;
}

html[data-theme="dark"] body :is(
  .card,
  .dashboard-quick-bar,
  .dashboard-summary-card,
  .dashboard-section-card,
  .dashboard-widget,
  .summary-card,
  .metric-card,
  .gauge-card,
  .report-card,
  .export-card,
  .onboarding-card,
  .customer-card,
  .history-row,
  .customer-result,
  .part-card,
  .picker-part,
  .mobile-card,
  .invoice-form-card,
  .totals-panel,
  .invoice-review,
  .modal-card,
  .customize-panel,
  .customer-form-panel > .customer-form-inner,
  .part-drawer,
  .toast,
  .legal-card,
  .feature-card,
  .step-card,
  .industry-chip,
  .cta-card,
  .quick-features li,
  .dashboard-mockup,
  .mock-content,
  .stat-card,
  .jobs-panel,
  .phone-screen
) {
  color: var(--text) !important;
  border-color: var(--border) !important;
  background: var(--surface-1) !important;
}

html[data-theme="dark"] body :is(
  .form-section,
  .subsection,
  .advanced-settings,
  .tax-line,
  #settingsTaxLines .tax-line,
  .readonly-field,
  .billing-status,
  .dashboard-invoice-head,
  .dashboard-action-menu summary,
  .dashboard-action-menu-popover,
  .dashboard-action-menu-popover button,
  .email-suggestions,
  .quick-customer,
  .asset-picker,
  .customer-preview,
  .line-item,
  .job-card,
  .settings-tax-note,
  .job-save-row,
  .workflow-list li,
  .browser-bar,
  .mock-sidebar,
  .quote-box,
  .message-box,
  .drawer-actions,
  .tax-default-list div
) {
  color: var(--text) !important;
  border-color: var(--border) !important;
  background: var(--surface-2) !important;
}

html[data-theme="dark"] body :is(.sidebar-close, .mobile-menu) {
  color: var(--text) !important;
  border-color: var(--border) !important;
  background: var(--surface-1) !important;
}

html[data-theme="dark"] body .goal-bar {
  background: var(--surface-3) !important;
}

html[data-theme="dark"] body .cloud-sync-status.is-error {
  color: var(--danger) !important;
  border-color: color-mix(in srgb, var(--danger) 40%, var(--border)) !important;
  background: var(--danger-soft) !important;
}

html[data-theme="dark"] body :is(
  .modal-backdrop,
  .customize-backdrop,
  .customer-form-panel,
  .drawer-backdrop
) {
  background: var(--overlay) !important;
}

html[data-theme="dark"] body :is(
  h1,
  h2,
  h3,
  .widget-value,
  .dashboard-summary-card strong,
  .metric-card strong,
  .summary-card strong,
  .report-card strong,
  .gauge-value strong,
  .stat-value,
  .customer-card h3,
  .part-card h3,
  .picker-part h3,
  .billing-status strong,
  .line-total,
  .total-row.grand,
  .tax-preview strong
) {
  color: var(--accent) !important;
}

html[data-theme="dark"] body :is(
  p,
  label,
  li,
  td,
  th,
  small,
  .muted,
  .fine-print,
  .panel-head p,
  .dashboard-section-head p,
  .dashboard-summary-card span,
  .dashboard-summary-card small,
  .metric-card span,
  .summary-card span,
  .report-card span,
  .dashboard-invoice-cell,
  .dashboard-invoice-cell small,
  .dashboard-attention-main span,
  .customer-meta,
  .customer-notes,
  .part-cell,
  .part-more-cell,
  .catalog-field-label,
  .total-row,
  .quote-line,
  .message-box p,
  .appearance-setting-copy span,
  .legal-updated,
  .legal-footer-inner
) {
  color: var(--text) !important;
}

html[data-theme="dark"] body :is(.button-primary, .filter-buttons button.is-active, .period-tabs button.is-active) {
  color: #ffffff !important;
}

html[data-theme="dark"] body :is(.status-paid, .badge-done, .status-pill, .cloud-sync-status.is-saving) {
  color: var(--accent) !important;
}

html[data-theme="dark"] body :is(.status-unpaid, .status-overdue, .badge-overdue, .cloud-sync-status.is-error) {
  color: var(--danger) !important;
}

html[data-theme="dark"] body :is(.status-draft, .status-void, .status-partially-paid, .badge-quote) {
  color: var(--text) !important;
}

html[data-theme="dark"] body :is(.invoice-preview, .invoice-lines) {
  color: var(--text) !important;
  border-color: var(--border) !important;
  background: var(--surface-1) !important;
}

html[data-theme="dark"] body .invoice-line-head {
  color: var(--accent) !important;
  border-color: var(--border) !important;
  background: var(--surface-2) !important;
}

html[data-theme="dark"] body :is(
  .invoice-business strong,
  .invoice-customer,
  .invoice-line strong,
  .invoice-meta strong,
  .invoice-summary-row strong
) {
  color: var(--text) !important;
}

html[data-theme="dark"] body :is(
  .invoice-title,
  .invoice-summary-row.total,
  .invoice-summary-row.total strong
) {
  color: var(--accent) !important;
}

html[data-theme="dark"] body :is(
  .invoice-business span,
  .invoice-number,
  .invoice-label,
  .invoice-meta,
  .invoice-line,
  .invoice-summary-row,
  .invoice-preview-foot p
) {
  color: var(--text) !important;
}

/* Dashboard statuses stay compact even when responsive cell rules make other
   spans block-level. Solid fills keep Paid and Unpaid readable at a glance. */
.dashboard-invoice-status .status {
  position: relative;
  isolation: isolate;
  display: inline-flex;
  width: fit-content;
  min-width: 64px;
  max-width: 112px;
  min-height: 26px;
  padding: 3px 9px;
  align-items: center;
  justify-content: center;
  justify-self: end;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  background-clip: padding-box;
}

.dashboard-invoice-status .status .status-label {
  position: relative;
  z-index: 1;
  display: inline-block;
  color: inherit;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  -webkit-text-fill-color: currentColor;
}

.dashboard-invoice-status .status-paid {
  color: #ffffff !important;
  border: 1px solid #247a55;
  background: #176a49 !important;
}

.dashboard-invoice-status :is(.status-unpaid, .status-overdue) {
  color: #ffffff !important;
  border: 1px solid #b8583c;
  background: #963f29 !important;
}

.dashboard-invoice-status :is(.status-paid, .status-unpaid, .status-overdue) .status-label {
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
}

/* One visual container per card. Form sections remain useful layout groups,
   but no longer draw a second rounded card inside the outer panel. */
.card .form-section {
  padding: 18px 20px 20px !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

.card .form-section + .form-section {
  border-top: 1px solid var(--border) !important;
}

.card form > .form-section:first-child,
.card > .form-section:first-child,
.card .panel-head + .form-section {
  border-top: 0 !important;
}

/* Invoice creation is intentionally linear: build the document first, review
   totals second, then continue to the saved-invoice list. */
#invoices .invoice-builder {
  grid-template-columns: minmax(0, 1fr);
  gap: 26px;
}

#invoices .invoice-form-card,
#invoices .totals-panel,
#invoices .invoice-review,
#invoices .saved-invoices {
  width: 100%;
}

#invoices #invoiceForm {
  gap: 0;
}

#invoices #invoiceForm > [data-workflow-label] {
  position: relative;
  padding-top: 48px !important;
}

#invoices #invoiceForm > [data-workflow-label]::before {
  content: attr(data-workflow-label);
  position: absolute;
  top: 18px;
  left: 20px;
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.09em;
  line-height: 1;
  text-transform: uppercase;
}

#invoices #invoiceForm > [data-workflow-label] + [data-workflow-label] {
  border-top: 1px solid var(--border) !important;
}

#invoices .totals-panel {
  position: static;
  top: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.72fr);
  overflow: hidden;
}

#invoices .totals-panel > .panel-head,
#invoices .totals-panel > .totals-actions {
  grid-column: 1 / -1;
}

#invoices .totals-panel > .totals-box {
  align-self: start;
  margin: 20px 10px 20px 20px;
}

#invoices .totals-panel > .payment-controls {
  align-content: start;
  padding: 20px 20px 20px 10px;
}

#invoices .totals-panel > .totals-actions {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 18px 20px 20px;
  border-top: 1px solid var(--border);
}

#invoices .invoice-review,
#invoices .saved-invoices {
  margin-top: 26px;
}

@media (max-width: 900px) {
  #invoices .totals-panel {
    grid-template-columns: 1fr;
  }

  #invoices .totals-panel > .panel-head,
  #invoices .totals-panel > .totals-actions {
    grid-column: 1;
  }

  #invoices .totals-panel > .totals-box {
    margin: 18px 18px 10px;
  }

  #invoices .totals-panel > .payment-controls {
    padding: 10px 18px 18px;
  }

  #invoices .totals-panel > .totals-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .card .form-section {
    padding: 16px !important;
  }

  #invoices #invoiceForm > [data-workflow-label] {
    padding-top: 43px !important;
  }

  #invoices #invoiceForm > [data-workflow-label]::before {
    top: 16px;
    left: 16px;
  }

  #invoices .totals-panel > .totals-actions {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media (max-width: 720px) {
  .appearance-setting {
    align-items: stretch;
    flex-direction: column;
  }

  .theme-choices {
    width: 100%;
  }

  .modal-card,
  .customize-panel,
  .customer-form-panel > .customer-form-inner {
    border-radius: var(--radius-card);
  }
}

/* Simplified app navigation */
.nav .nav-create-invoice {
  margin-bottom: 4px;
  color: #ffffff;
  border: 1px solid #0f4f35;
  background: #0f4f35;
  box-shadow: 0 1px 2px rgba(10, 53, 37, 0.18);
}

.nav .nav-create-invoice:hover {
  color: #ffffff;
  background: #0a3d2a;
}

html[data-theme="dark"] .nav .nav-create-invoice {
  border-color: #287d59;
  background: #287d59;
}

.nav-more {
  display: grid;
}

.nav-more > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 12px;
  border-radius: var(--radius-control);
  color: var(--text-soft);
  font-weight: 780;
  cursor: pointer;
  list-style: none;
}

.nav-more > summary::-webkit-details-marker {
  display: none;
}

.nav-more > summary:hover,
.nav-more.has-active-item > summary {
  color: var(--accent);
  background: var(--accent-soft);
}

.nav-more-chevron {
  width: 17px;
  height: 17px;
  margin-left: auto;
  transition: transform var(--transition-fast);
}

.nav-more[open] .nav-more-chevron {
  transform: rotate(180deg);
}

.nav-more-items {
  display: grid;
  gap: 4px;
  padding: 5px 0 0 13px;
}

.nav-more-items button {
  min-height: 42px;
  font-size: 0.92rem;
}

/* Progressive disclosure without introducing nested cards */
.form-more {
  border-top: 1px solid var(--border);
}

.form-more > summary,
.workflow-optional > summary,
.settings-optional > summary {
  color: var(--accent);
  font-weight: 800;
  cursor: pointer;
}

.form-more > summary {
  padding: 13px 0 2px;
}

.form-more-content,
.workflow-optional-content {
  display: grid;
  gap: 14px;
  padding-top: 14px;
}

.workflow-optional > summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  font-size: 1rem;
  list-style-position: inside;
}

.workflow-optional > summary span {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.settings-optional > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  list-style: none;
}

.settings-optional > summary::-webkit-details-marker {
  display: none;
}

.settings-optional > summary span {
  display: grid;
  gap: 4px;
}

.settings-optional > summary small {
  color: var(--text-muted);
  font-weight: 600;
}

.settings-optional > summary svg {
  width: 18px;
  transition: transform var(--transition-fast);
}

.settings-optional[open] > summary svg {
  transform: rotate(180deg);
}

/* Clearer Settings and Reports structure */
.settings-group-heading {
  grid-column: 1 / -1;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-top: 10px;
  padding: 14px 2px 0;
  border-top: 1px solid var(--border);
}

.settings-group-heading:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.settings-group-heading span {
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.settings-group-heading h2,
.settings-group-heading p {
  margin: 0;
}

.settings-group-heading h2 {
  margin-top: 3px;
  font-size: 1.05rem;
}

.settings-group-heading p {
  max-width: 480px;
  color: var(--text-muted);
  font-size: 0.84rem;
  text-align: right;
}

.reports-export-heading {
  margin-top: 26px;
}

.reports-export-grid {
  grid-template-columns: minmax(0, 1fr);
  margin-top: 12px;
}

.reports-export-card .actions {
  margin-top: 16px;
}

.reports-locked-note {
  display: none;
  margin-bottom: 18px;
  padding: 18px 20px;
  color: var(--text-soft);
}

body.billing-locked #reportsInsights {
  display: none;
}

body.billing-locked .reports-locked-note {
  display: block;
}

/* Calmer saved-invoice actions */
.invoice-list-actions {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
}

.invoice-list-actions > .mini-button.is-primary {
  color: #ffffff;
  border-color: #0f4f35;
  background: #0f4f35;
}

.invoice-list-menu {
  position: relative;
}

.invoice-list-menu > summary {
  list-style: none;
}

.invoice-list-menu > summary::-webkit-details-marker {
  display: none;
}

.invoice-list-menu-items {
  position: absolute;
  z-index: 8;
  top: calc(100% + 6px);
  right: 0;
  display: grid;
  width: max-content;
  min-width: 150px;
  gap: 5px;
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface-1);
  box-shadow: var(--shadow-md);
}

.invoice-list-menu-items .mini-button {
  justify-content: flex-start;
  width: 100%;
}

#dashboard .dashboard-summary-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.expense-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.expense-page {
  align-items: start;
  grid-template-columns: minmax(300px, 0.82fr) minmax(420px, 1.18fr);
}

.expense-form-card,
.expense-list-card {
  min-width: 0;
}

#expenseForm {
  display: grid;
  gap: 14px;
}

.expense-calculation {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  color: var(--text-soft);
  background: var(--surface-2);
  font-size: 0.86rem;
}

.expense-calculation span,
.receipt-status {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.receipt-status {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.expense-tools {
  display: grid;
  grid-template-columns: minmax(110px, 0.35fr) minmax(200px, 1fr);
  gap: 12px;
}

.expense-export-actions {
  margin: 14px 0;
}

.expense-list {
  display: grid;
  gap: 10px;
}

.expense-card {
  display: grid;
  gap: 12px;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface-2);
  transition: border-color var(--transition-fast), transform var(--transition-fast), background-color var(--transition-fast);
}

.expense-card:hover {
  border-color: var(--border-strong);
  background: var(--surface-3);
  transform: translateY(-1px);
}

.expense-card-main,
.expense-card-footer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.expense-card h3,
.expense-card p {
  margin: 0;
}

.expense-card h3 {
  margin-top: 3px;
  font-size: 1rem;
}

.expense-card p,
.expense-card-date,
.expense-card-amount span,
.expense-receipt-indicator {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.expense-card-amount {
  display: grid;
  flex: 0 0 auto;
  gap: 3px;
  text-align: right;
}

.expense-card-amount strong {
  color: var(--accent);
  font-size: 1.08rem;
}

.expense-card-footer {
  align-items: center;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.expense-receipt-indicator {
  overflow-wrap: anywhere;
}

.expense-tax-note {
  margin-top: 16px;
}

@media (max-width: 720px) {
  .settings-group-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  .settings-group-heading p {
    text-align: left;
  }

  .workflow-optional > summary {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }

  .invoice-list-actions {
    justify-content: flex-start;
  }

  .invoice-list-menu-items {
    right: auto;
    left: 0;
  }

  #invoices .totals-panel > .totals-actions {
    position: sticky;
    bottom: 0;
    z-index: 4;
    background: var(--surface-1);
    box-shadow: 0 -10px 24px color-mix(in srgb, var(--surface-page) 80%, transparent);
  }

  .expense-summary-grid,
  .expense-page,
  .expense-tools {
    grid-template-columns: minmax(0, 1fr);
  }

  .expense-card-main,
  .expense-card-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .expense-card-amount {
    text-align: left;
  }

  .expense-card-footer .actions,
  .expense-export-actions {
    width: 100%;
  }

  .expense-card-footer .button,
  .expense-card-footer .mini-button,
  .expense-export-actions .button {
    flex: 1 1 auto;
  }
}
