:root {
  color-scheme: light;
  /* Clarity light palette: warm finance paper, ink text, and one restrained audit mark. */
  --finance-canvas: #edecea;
  --finance-surface: #faf9f6;
  --finance-control: #ece9de;
  --finance-ink: #232220;
  --finance-muted: #6a6663;
  --finance-line: #d7d2ce;
  --background: 48 26% 92%;
  --foreground: 82 9.6% 13%;
  --card: 48 26% 98%;
  --card-foreground: 82 9.6% 13%;
  --popover: 48 26% 98%;
  --popover-foreground: 82 9.6% 13%;
  --primary: 84 25% 46%;
  --primary-foreground: 48 26% 100%;
  --secondary: 48 26% 88%;
  --secondary-foreground: 82 9.6% 13%;
  --muted: 48 26% 88%;
  --muted-foreground: 82 9.2% 41%;
  --accent: 84 25% 46%;
  --accent-foreground: 48 26% 100%;
  --destructive: 354 58% 44%;
  --destructive-foreground: 48 26% 100%;
  --border: 50 14% 80%;
  --input: 50 14% 74%;
  --ring: 84 25% 46%;
  --radius: 0.45rem;
  --shadow: 0 18px 44px rgb(36 35 31 / 0.10);
  --soft: 0 8px 22px rgb(36 35 31 / 0.07);
  --section-gap: 18px;
  --card-radius: 14px;
  --slate: hsl(82 14% 11%);
  --muted-text: hsl(82 9.2% 41%);
  --line: hsl(var(--border));
  --blue: hsl(84 25% 59%);
  --purple: hsl(84 25% 58%);
  --teal: hsl(84 25% 40%);
  --orange: hsl(38 92% 50%);
  --red: hsl(346 77% 50%);
  --green: hsl(160 84% 35%);
  --status-info: 84 25% 42%;
  --status-success: 160 84% 30%;
  --status-danger: 346 77% 46%;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --background: 82 14% 4%;
  --foreground: 48 26% 91%;
  --card: 82 14% 7%;
  --card-foreground: 48 26% 91%;
  --popover: 82 14% 7%;
  --popover-foreground: 48 26% 91%;
  --primary: 84 25% 70%;
  --primary-foreground: 82 14% 4%;
  --secondary: 82 14% 17%;
  --secondary-foreground: 48 26% 91%;
  --muted: 82 14% 17%;
  --muted-foreground: 50 14% 64%;
  --accent: 84 25% 70%;
  --accent-foreground: 82 14% 4%;
  --destructive: 346 77% 62%;
  --destructive-foreground: 82 14% 4%;
  --border: 82 14% 17%;
  --input: 82 14% 17%;
  --ring: 84 25% 70%;
  --shadow: 0 18px 48px rgb(0 0 0 / 0.35);
  --soft: 0 12px 32px rgb(0 0 0 / 0.26);
  --slate: hsl(48 26% 91%);
  --muted-text: hsl(50 14% 64%);
  --status-info: 84 25% 72%;
  --status-success: 151 72% 62%;
  --status-danger: 356 100% 76%;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  text-rendering: optimizeLegibility;
}
a { color: inherit; }
.app-container { max-width: 1640px; margin: 0 auto; padding: 20px 18px 26px; }
.dfm-footer { color: hsl(var(--muted-foreground)); text-align: center; padding: 18px; font-size: 13px; }
.legal-links { display: inline-flex; gap: 10px; margin-left: 8px; flex-wrap: wrap; justify-content: center; }
.legal-links a { color: hsl(var(--primary)); font-weight: 800; }
.legal-document pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: normal;
  overflow-wrap: anywhere;
  color: hsl(var(--foreground));
  font: 500 14px/1.65 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}
.legal-editor-grid {
  grid-template-columns: minmax(260px, .45fr) minmax(0, 1.55fr);
}
.legal-doc-list {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}
.legal-editor-panel {
  min-height: 660px;
}
.legal-editor-textarea {
  min-height: 560px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 14px;
  line-height: 1.55;
  resize: vertical;
}

/* shadcn-style app shell */
.eyebrow {
  display: block;
  color: hsl(var(--muted-foreground));
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.inline { display: inline-flex; align-items: center; min-width: 0; margin: 0; }
.theme-toggle {
  min-width: 78px;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid hsl(var(--border));
  border-radius: 999px;
  padding: 6px 9px;
  background: hsl(var(--secondary) / .72);
  color: hsl(var(--foreground));
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.theme-toggle:hover { border-color: hsl(var(--primary) / .45); }
.theme-toggle:focus-visible { outline: 3px solid hsl(var(--ring) / .28); outline-offset: 2px; }
.theme-toggle-track {
  width: 30px;
  height: 16px;
  flex: 0 0 30px;
  display: flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px;
  background: hsl(var(--muted-foreground) / .34);
}
.theme-toggle-thumb {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: hsl(var(--card));
  box-shadow: 0 1px 4px rgb(15 23 42 / .25);
  transform: translateX(0);
  transition: transform .18s ease, background .18s ease;
}
html[data-theme="dark"] .theme-toggle-track { background: hsl(var(--primary) / .62); }
html[data-theme="dark"] .theme-toggle-thumb {
  background: hsl(var(--primary-foreground));
  transform: translateX(14px);
}
.theme-toggle-label { min-width: 25px; text-align: left; }

/* Sonner-like flash toasts */
.sonner-toaster {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 90;
  display: grid;
  gap: 8px;
  width: min(420px, calc(100vw - 28px));
}
.sonner-toast, .dfm-alert {
  border: 1px solid hsl(var(--border));
  background: hsl(var(--popover));
  color: hsl(var(--popover-foreground));
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  font-size: 14px;
  transition: opacity .2s ease, transform .2s ease;
}
.sonner-toast.success, .dfm-alert.success { border-color: hsl(160 84% 39% / .25); background: hsl(151 81% 96%); color: hsl(160 84% 24%); }
.sonner-toast.danger, .dfm-alert.danger { border-color: hsl(346 77% 50% / .25); background: hsl(356 100% 97%); color: hsl(346 77% 36%); }
.sonner-toast.warning, .dfm-alert.warning { border-color: hsl(38 92% 50% / .3); background: hsl(48 100% 96%); color: hsl(32 95% 32%); }
.sonner-toast.info, .dfm-alert.info { border-color: hsl(84 25% 59% / .25); background: hsl(48 26% 97%); color: hsl(84 25% 40%); }
html[data-theme="dark"] .sonner-toast.success, html[data-theme="dark"] .dfm-alert.success { background: hsl(160 84% 12% / .65); color: hsl(151 81% 88%); }
html[data-theme="dark"] .sonner-toast.danger, html[data-theme="dark"] .dfm-alert.danger { background: hsl(346 77% 16% / .65); color: hsl(356 100% 90%); }
html[data-theme="dark"] .sonner-toast.warning, html[data-theme="dark"] .dfm-alert.warning { background: hsl(38 92% 15% / .65); color: hsl(48 100% 88%); }
html[data-theme="dark"] .sonner-toast.info, html[data-theme="dark"] .dfm-alert.info { background: hsl(82 14% 18% / .65); color: hsl(48 26% 90%); }

/* Card, panel, and section primitives */
.data-panel,
.panel,
.login-card,
.empty-state,
.working-card,
.info-card,
.tip-grid article {
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  box-shadow: var(--soft);
}
.lease-export-card {
  min-width: 290px;
  align-self: center;
  display: grid;
  justify-items: start;
  gap: 8px;
  padding: 16px 18px;
  border: 1px solid hsl(var(--border) / .78);
  border-radius: 16px;
  background:
    linear-gradient(135deg, hsl(var(--card)), hsl(var(--muted) / .32)),
    hsl(var(--card));
  box-shadow: 0 14px 34px hsl(var(--foreground) / .07);
}
.lease-export-card span {
  color: hsl(var(--accent));
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.lease-export-card small {
  color: hsl(var(--muted-foreground));
  font-size: 12px;
  line-height: 1.35;
}
.lease-export-link {
  appearance: none;
  border: 0;
  border-bottom: 1px solid currentColor;
  background: transparent;
  color: hsl(var(--foreground));
  cursor: pointer;
  font: inherit;
  font-size: 20px;
  font-weight: 850;
  line-height: 1.15;
  padding: 0 0 3px;
  text-decoration: none;
  transition: color .16s ease, transform .16s ease, border-color .16s ease;
}
.lease-export-link:hover,
.lease-export-link:focus-visible {
  color: hsl(var(--accent));
  border-color: hsl(var(--accent));
  outline: none;
  transform: translateX(2px);
}
.data-panel, .panel, .login-card, .empty-state { border-radius: 16px; padding: 15px; margin-bottom: 14px; }
.data-panel h2, .panel h2 { color: hsl(var(--foreground)); font-size: 17px; margin: 0 0 8px; }
.data-panel h2.lease-dashboard-heading { font-weight: 850; }
.mini-table th.two-line-header { text-align: center; }
.mini-table th.two-line-header span { display: block; line-height: 1.25; text-align: center; }
.login-card { max-width: 420px; margin: 42px auto; }
.login-card h1 { margin: 7px 0; font-size: 26px; }
.simple-card .muted, .data-panel p, .accent-panel p { color: hsl(var(--muted-foreground)); line-height: 1.45; }
.empty-state { text-align: center; padding: 38px; }
.empty-state h2 { margin: 0 0 6px; font-size: 22px; }
.empty-state p, .empty-line { color: hsl(var(--muted-foreground)); }
.intro-experience {
  --pointer-x: 50%;
  --pointer-y: 12%;
  position: relative;
  isolation: isolate;
}
.intro-experience:before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(circle at var(--pointer-x) var(--pointer-y), hsl(84 25% 70% / .18), transparent 22rem),
    radial-gradient(circle at calc(100% - var(--pointer-x)) 18%, hsl(160 84% 39% / .10), transparent 19rem);
  transition: background .12s linear;
}
.intro-reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity .65s ease, transform .65s ease;
}
.intro-reveal.revealed {
  opacity: 1;
  transform: translateY(0);
}
.accent-list span:before { background: hsl(160 84% 39%); }
@keyframes orbitSpin {
  to { transform: rotate(360deg); }
}
@keyframes introDrift {
  from { transform: translateX(-8%) translateY(-4%) scale(1); }
  to { transform: translateX(8%) translateY(5%) scale(1.08); }
}
.compact-empty { padding: 24px; }
.accent-panel { background: linear-gradient(135deg, hsl(var(--card)), hsl(var(--muted) / .6)); }
.panel-title-row, .dashboard-section-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.dashboard-section-title { margin: 18px 0 10px; }
.dashboard-section-title h2 { color: hsl(var(--foreground)); font-size: 18px; margin: 0; }
.dashboard-section-title p, .panel-title-row small { color: hsl(var(--muted-foreground)); margin: 0; font-size: 13px; }
/* Button primitive */
.primary, .secondary, .danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  min-height: 34px;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 750;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  white-space: normal;
  overflow-wrap: anywhere;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .15s ease;
}
.primary {
  background: hsl(var(--primary));
  border-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}
.secondary {
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  border-color: hsl(var(--border));
}
.danger {
  background: hsl(346 77% 50% / .10);
  color: hsl(346 77% 42%);
  border-color: hsl(346 77% 50% / .24);
}
.primary:hover, .secondary:hover, .danger:hover { transform: translateY(-1px); }
.small { min-height: 28px; padding: 6px 9px; font-size: 12px; }
.big { min-height: 38px; padding: 9px 14px; font-size: 14px; }
.actions, .dfm-card-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 13px; min-width: 0; }
.actions > *, .dfm-card-actions > *, .module-toolbar > * { flex: 0 1 auto; min-width: 0; }
.compact-actions { margin-top: 11px; }
.data-panel .form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
  margin: 12px 0;
}
.data-panel .form-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.data-panel .dfm-input-group { display: grid; gap: 6px; }
.admin-detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, .55fr);
  gap: 14px;
  align-items: start;
}
.admin-detail-permissions { max-height: none; }
.prepaid-period-form,
.prepaid-entry-grid,
.prepaid-permission-grid {
  display: grid;
  gap: 12px;
  align-items: end;
}
.prepaid-period-form { grid-template-columns: repeat(4, minmax(160px, 1fr)); }
.prepaid-entry-grid { grid-template-columns: repeat(4, minmax(150px, 1fr)); }
.prepaid-permission-grid { grid-template-columns: repeat(9, minmax(110px, 1fr)); }
.prepaid-period-form label,
.prepaid-entry-grid label,
.prepaid-permission-grid label {
  display: grid;
  gap: 6px;
  color: hsl(var(--muted-foreground));
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .04em;
}
.prepaid-entry-grid .span-2 { grid-column: span 2; }
.inline-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.inline-action-row form { margin: 0; }
.prepaid-register-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}
.danger-link {
  border: 0;
  background: transparent;
  color: hsl(var(--destructive));
  font: inherit;
  font-weight: 800;
  padding: 0;
  cursor: pointer;
}
.danger-link:hover { text-decoration: underline; }
.lease-period-picker {
  padding: 12px;
  border: 1px solid hsl(var(--border) / .7);
  border-radius: 16px;
  background:
    linear-gradient(135deg, hsl(var(--card)) 0%, hsl(var(--muted) / .38) 100%),
    hsl(var(--card));
  box-shadow: 0 12px 30px hsl(var(--foreground) / .06);
}
.lease-picker-field {
  position: relative;
  padding: 10px;
  border: 1px solid hsl(var(--border) / .58);
  border-radius: 13px;
  background: hsl(var(--background) / .66);
  transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}
.lease-picker-field:hover,
.lease-picker-field:focus-within {
  border-color: hsl(var(--accent) / .45);
  box-shadow: 0 10px 22px hsl(var(--foreground) / .07);
  transform: translateY(-1px);
}
.lease-picker-field label {
  color: hsl(var(--accent));
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.lease-picker-field input,
.lease-picker-field select {
  width: 100%;
  min-height: 40px;
  border: 0;
  border-radius: 10px;
  background: hsl(var(--muted) / .42);
  color: hsl(var(--foreground));
  font-size: 16px;
  font-weight: 800;
  padding: 8px 10px;
}
.lease-picker-field input:focus,
.lease-picker-field select:focus {
  outline: 2px solid hsl(var(--accent) / .28);
  outline-offset: 2px;
}
.lease-picker-field input[type="date"] {
  color-scheme: light;
  cursor: pointer;
}
[data-theme="dark"] .lease-picker-field input[type="date"] {
  color-scheme: dark;
}
.lease-picker-field input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: .72;
  padding: 4px;
  border-radius: 8px;
  background-color: hsl(var(--card) / .75);
}
.lease-picker-field input[type="date"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
  background-color: hsl(var(--accent) / .14);
}
.lease-input-table input,
.lease-input-table select {
  width: 100%;
  min-width: 96px;
  padding: 7px 8px;
  border-radius: 8px;
}
.lease-input-table th,
.lease-input-table td { vertical-align: middle; }
.lease-input-table input[readonly],
.lease-input-table select:disabled {
  cursor: default;
  opacity: 1;
  color: hsl(var(--foreground));
  background: hsl(var(--muted) / .28);
  border-color: hsl(var(--border) / .62);
}
.lease-input-table tr:not(.is-editing) input[readonly],
.lease-input-table tr:not(.is-editing) select:disabled {
  box-shadow: none;
}
.lease-row-actions {
  display: grid;
  gap: 7px;
  justify-items: start;
  min-width: 58px;
}
.lease-row-actions .text-command {
  line-height: 1.15;
}
.danger-command {
  color: hsl(var(--status-danger));
}
.mini-table .total-row td {
  font-weight: 850;
  background: hsl(var(--muted) / .55);
}
[data-tone="success"] { color: hsl(var(--status-success)); }
[data-tone="error"] { color: hsl(var(--status-danger)); }
[data-tone="info"] { color: hsl(var(--status-info)); }
.ask-control-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: stretch;
}
.ask-control-input { min-height: 42px; }
.ask-control-answer {
  min-height: 230px;
  margin-top: 12px;
  white-space: pre-wrap;
}
.ask-control-sources { margin-top: 10px; }
.ask-example-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.ask-example {
  min-height: 42px;
  justify-content: flex-start;
  text-align: left;
}
/* Inputs, Selects, Tabs, Skeleton */
.form, .upload-form { display: grid; gap: 12px; }
label { display: grid; gap: 6px; color: hsl(var(--foreground)); font-weight: 700; }
input, select, textarea, .compact-select, .column-search-input {
  font: inherit;
  min-width: 0;
  border: 1px solid hsl(var(--input));
  border-radius: 10px;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  padding: 9px 10px;
  outline: none;
}
input:focus, select:focus, textarea:focus, .column-search-input:focus {
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsl(var(--ring) / .14);
}
.erp-download-board {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, .55fr);
  gap: 16px;
  align-items: start;
}
.erp-source-toolbar {
  margin-top: -4px;
  margin-bottom: 14px;
}
.erp-setup-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
}
.erp-setup-steps span {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 34px;
  border: 1px solid hsl(var(--border));
  border-radius: 999px;
  background: hsl(var(--muted) / .35);
  color: hsl(var(--foreground));
  padding: 6px 12px 6px 7px;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}
.erp-setup-steps b {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  font-size: 12px;
  line-height: 1;
}
.erp-import-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
  gap: 16px;
  align-items: start;
}
.erp-import-main,
.erp-import-side {
  display: grid;
  gap: 14px;
}
.erp-step-panel {
  border: 1px solid hsl(var(--border));
  border-radius: 14px;
  background: hsl(var(--card));
  padding: 14px;
}
.erp-period-panel {
  display: grid;
  grid-template-columns: 190px max-content;
  align-items: end;
  gap: 14px;
  width: fit-content;
  max-width: 100%;
  padding: 12px 14px;
}
.erp-period-panel .erp-step-title {
  margin-bottom: 0;
}
.erp-step-title {
  display: grid;
  gap: 3px;
  margin-bottom: 10px;
}
.erp-step-title span {
  color: hsl(var(--muted-foreground));
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.erp-step-title h3 {
  margin: 0;
  color: hsl(var(--foreground));
  font-size: 17px;
  font-weight: 850;
}
.erp-period-compact {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 10px;
  max-width: none;
}
.erp-period-compact label {
  margin: 0;
}
.erp-period-mode-field {
  flex: 0 0 210px;
}
#erp-month-field {
  flex: 0 0 190px;
}
.erp-period-range {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 10px;
}
.erp-period-range label {
  flex: 0 0 212px;
}
.erp-period-compact select,
.erp-period-compact input {
  min-height: 40px;
}
.compact-title-row { margin-bottom: 8px; }
.compact-title-row h2 { margin: 0; font-size: 1rem; }
.erp-report-list,
.erp-download-status-card {
  border: 1px solid hsl(var(--border));
  border-radius: 14px;
  background: hsl(var(--card));
  padding: 14px;
}
.erp-company-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 10px;
}
.erp-account-filter-panel {
  border: 1px solid hsl(var(--border));
  border-radius: 14px;
  background: hsl(var(--muted) / .24);
  padding: 12px 14px;
}
.erp-advanced-panel summary {
  cursor: pointer;
  color: hsl(var(--foreground));
  font-size: 14px;
  font-weight: 850;
}
.erp-advanced-panel[open] summary {
  margin-bottom: 10px;
}
.erp-control-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 8px 0 12px;
}
.erp-control-option {
  align-items: flex-start;
  border: 1px solid hsl(var(--border));
  border-radius: 10px;
  background: hsl(var(--background) / .72);
  padding: 10px;
}
.erp-control-option span {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.erp-control-option small {
  color: hsl(var(--muted-foreground));
  font-weight: 650;
  line-height: 1.35;
}
.erp-selected-gl-controls {
  display: grid;
  gap: 10px;
}
.erp-account-filter-panel textarea {
  min-height: 92px;
  resize: vertical;
}
.erp-report-options {
  display: grid;
  gap: 8px;
}
.erp-report-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) max-content;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid hsl(var(--border));
  border-radius: 10px;
  background: hsl(var(--background) / .62);
}
.erp-report-row.has-actions {
  grid-template-columns: 18px minmax(0, 1fr) minmax(112px, max-content) max-content;
}
.erp-report-row:hover {
  border-color: hsl(var(--ring) / .42);
  background: hsl(var(--muted) / .36);
}
.erp-report-row.muted-row {
  opacity: .72;
  background: hsl(var(--muted) / .24);
}
.erp-report-row.muted-row input {
  cursor: not-allowed;
}
.erp-report-row.muted-row:hover {
  border-color: hsl(var(--border));
}
.erp-report-row span {
  min-width: 0;
  font-weight: 800;
}
.erp-report-name {
  display: grid;
  gap: 2px;
}
.erp-report-name b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.erp-report-name small {
  color: hsl(var(--muted-foreground));
  font-size: 12px;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.erp-report-row em {
  border: 1px solid hsl(var(--border));
  border-radius: 999px;
  padding: 4px 8px;
  background: hsl(var(--muted) / .46);
  color: hsl(var(--muted-foreground));
  font-size: .76rem;
  font-style: normal;
  font-weight: 850;
  white-space: nowrap;
}
.danger-text {
  color: hsl(var(--destructive));
}
.erp-report-manager {
  margin-top: 12px;
  border: 1px solid hsl(var(--border));
  border-radius: 10px;
  background: hsl(var(--muted) / .24);
  padding: 10px;
}
.erp-report-manager summary {
  cursor: pointer;
  color: hsl(var(--foreground));
  font-weight: 850;
}
.erp-report-manager-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.erp-report-manager-grid select {
  min-width: 0;
}
.erp-download-status-card {
  display: grid;
  gap: 10px;
}
.erp-download-status-card h2 {
  margin: 0;
}
.erp-download-status-card p {
  margin: 0;
  color: hsl(var(--muted-foreground));
}
.erp-control-alert {
  display: grid;
  gap: 4px;
  margin: 12px 0;
  padding: 12px 14px;
  border: 1px solid hsl(var(--destructive) / .28);
  border-radius: 10px;
  background: hsl(var(--destructive) / .08);
  color: hsl(var(--foreground));
}
.erp-control-alert strong {
  font-size: .92rem;
}
.erp-control-alert span,
.erp-control-alert small {
  color: hsl(var(--muted-foreground));
  font-weight: 650;
}
@media (max-width: 920px) {
  .erp-setup-steps,
.erp-period-panel,
.erp-import-layout {
    grid-template-columns: 1fr;
  }
  .erp-period-compact {
    max-width: none;
  }
  .erp-download-board {
    grid-template-columns: 1fr;
  }
  .erp-report-row.has-actions,
.erp-report-manager-grid {
    grid-template-columns: 1fr;
  }
}
.smart-date-input {
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.smart-date-picker {
  position: fixed;
  z-index: 2000;
  width: min(284px, calc(100vw - 24px));
  padding: 9px;
  border: 1px solid hsl(var(--border));
  border-radius: 13px;
  background: hsl(var(--popover));
  color: hsl(var(--popover-foreground));
  box-shadow: 0 18px 46px hsl(var(--foreground) / .16);
}
.smart-date-picker[hidden] { display: none; }
.smart-date-head {
  display: grid;
  grid-template-columns: 30px 1fr 78px 30px;
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
}
.smart-date-head button,
.smart-date-foot button {
  min-height: 28px;
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  background: hsl(var(--muted) / .58);
  color: hsl(var(--foreground));
  font-size: 12px;
  font-weight: 850;
  cursor: pointer;
}
.smart-date-head select {
  min-height: 30px;
  padding: 5px 7px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 800;
}
.smart-date-weekdays,
.smart-date-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.smart-date-weekdays span {
  color: hsl(var(--muted-foreground));
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .06em;
  text-align: center;
  text-transform: uppercase;
}
.smart-date-days {
  margin-top: 4px;
}
.smart-date-day {
  min-height: 28px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: hsl(var(--foreground));
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}
.smart-date-day:hover {
  background: hsl(var(--primary) / .12);
}
.smart-date-day.is-outside {
  color: hsl(var(--muted-foreground) / .55);
}
.smart-date-day.is-today {
  box-shadow: inset 0 0 0 1px hsl(var(--primary) / .55);
}
.smart-date-day.is-selected {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}
.smart-date-foot {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  margin-top: 8px;
}
.smart-date-foot button {
  flex: 1;
}
html[data-theme="light"] .smart-date-picker {
  background:
    linear-gradient(180deg, hsl(48 26% 99%), hsl(48 26% 97%)),
    hsl(var(--popover));
  border-color: hsl(50 14% 78%);
  box-shadow: 0 18px 44px hsl(82 13.2% 18% / .14);
}
html[data-theme="dark"] .smart-date-picker {
  box-shadow: 0 18px 44px hsl(82 6% 0% / .32);
}
.two-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tabs { display: inline-flex; padding: 3px; border: 1px solid hsl(var(--border)); border-radius: 10px; background: hsl(var(--muted)); }
.tab, .pill-row span, .heading-chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid hsl(var(--border));
  border-radius: 999px;
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  font-size: 12px;
  font-weight: 750;
}
.tab { padding: 5px 9px; }
@keyframes skeleton { to { background-position-x: -200%; } }

/* Badges and KPI cards */
.muted-text { color: var(--muted-text); }
button:disabled {
  cursor: wait;
  opacity: .68;
}
.detailed-strip { grid-template-columns: repeat(6, minmax(0, 1fr)); }
/* Working cards and module pages */
.working-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.working-card {
  border-radius: 16px;
  padding: 15px;
  min-height: 310px;
  display: flex;
  flex-direction: column;
}
.working-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.working-card h3 { color: hsl(var(--foreground)); font-size: 16px; font-weight: 800; margin: 11px 0 5px; }
.working-card p { color: hsl(var(--muted-foreground)); margin: 0; min-height: 44px; }
.pill-row { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 0; }
.pill-row span { padding: 5px 8px; }
.micro-meta {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 6px;
  align-items: start;
  margin-top: 8px;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--muted) / .55);
  border-radius: 12px;
  padding: 7px 8px;
}
.micro-meta b { color: hsl(var(--muted-foreground)); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.micro-meta span { color: hsl(var(--foreground)); font-size: 12px; line-height: 1.28; }
.working-stats { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; min-width: 0; }
.working-stats span {
  flex: 1 1 110px;
  min-width: 0;
  border: 1px solid hsl(var(--border));
  border-radius: 12px;
  background: hsl(var(--muted) / .55);
  color: hsl(var(--muted-foreground));
  padding: 7px 8px;
  font-size: 12px;
  overflow-wrap: anywhere;
}
.working-stats b { display: block; color: hsl(var(--foreground)); font-size: 13.5px; }
.calculation-progress {
  margin-top: 9px;
  min-height: 34px;
  border: 1px solid hsl(var(--border));
  border-radius: 12px;
  background: hsl(var(--muted) / .45);
  color: hsl(var(--muted-foreground));
  padding: 8px 9px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}
.progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.progress-copy {
  display: block;
  min-height: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.progress-elapsed {
  flex: 0 0 auto;
  border-radius: 999px;
  background: hsl(var(--foreground) / .08);
  color: hsl(var(--foreground));
  padding: 2px 7px;
  font-size: 12px;
  font-weight: 850;
}
.progress-track {
  display: block;
  position: relative;
  height: 8px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: hsl(var(--border) / .62);
}
.progress-fill {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  border-radius: inherit;
  background: hsl(var(--muted-foreground) / .55);
  will-change: left;
}
.calculation-progress.pending {
  border-color: hsl(var(--border));
  background: hsl(var(--muted) / .38);
}
.calculation-progress.pending .progress-fill {
  width: 0;
}
.calculation-progress.in-progress {
  border-color: hsl(84 25% 70% / .32);
  background: hsl(84 25% 70% / .12);
  color: hsl(var(--foreground));
}
.calculation-progress.in-progress .progress-fill {
  width: 32%;
  left: -35%;
  background: linear-gradient(90deg, hsl(84 25% 70%), hsl(84 25% 52%), hsl(84 25% 70%));
  background-size: 220% 100%;
  animation: progressRun 1.15s linear infinite;
}
.calculation-progress.failed {
  border-color: hsl(346 77% 50% / .3);
  background: hsl(346 77% 50% / .1);
  color: hsl(346 77% 40%);
  cursor: help;
}
.calculation-progress.failed .progress-fill {
  width: 100%;
  background: hsl(346 77% 50%);
}
.calculation-progress.ready {
  border-color: hsl(160 84% 39% / .3);
  background: hsl(160 84% 39% / .1);
  color: hsl(160 84% 30%);
}
.calculation-progress.ready .progress-fill {
  width: 100%;
  background: hsl(160 84% 39%);
}
@keyframes progressRun {
  0% { left: -35%; background-position: 0% 50%; }
  100% { left: 110%; background-position: 220% 50%; }
}
html[data-theme="dark"] .calculation-progress.failed { color: hsl(356 100% 88%); }
html[data-theme="dark"] .calculation-progress.ready { color: hsl(151 81% 86%); }
.module-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  min-width: 0;
  border: 1px solid hsl(var(--border));
  border-radius: 14px;
  background: hsl(var(--card));
  padding: 8px;
  margin-bottom: 14px;
  box-shadow: var(--soft);
}
.period-calc-form {
  display: flex;
  gap: 10px;
  align-items: end;
  flex-wrap: wrap;
}
.period-calc-form label {
  display: grid;
  gap: 5px;
  min-width: 160px;
  color: hsl(var(--muted-foreground));
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.fg-period-panel {
  margin-bottom: 14px;
}
.accent-blue { border-top: 4px solid hsl(var(--primary)); }
.accent-teal { border-top: 4px solid hsl(160 84% 39%); }
.accent-purple { border-top: 4px solid hsl(84 25% 58%); }
.accent-orange { border-top: 4px solid hsl(38 92% 50%); }
.accent-red { border-top: 4px solid hsl(346 77% 50%); }

/* Tables */
.table-wrap {
  overflow: auto;
  max-height: 360px;
  border: 1px solid hsl(var(--border));
  border-radius: 12px;
  background: hsl(var(--card));
}
.mini-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: hsl(var(--card));
  font-size: 13px;
}
.mini-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
  font-weight: 800;
  text-align: left;
  padding: 8px;
  border-bottom: 1px solid hsl(var(--border));
  white-space: nowrap;
}
.mini-table td {
  padding: 7px 8px;
  border-bottom: 1px solid hsl(var(--border));
  color: hsl(var(--foreground));
  white-space: nowrap;
}
.mini-table tbody tr:nth-child(even) { background: hsl(var(--muted) / .35); }

.document-preview-frame {
  width: 100%;
  min-height: 620px;
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  background: hsl(var(--card));
}
.document-preview-image {
  display: block;
  width: 100%;
  max-height: 720px;
  object-fit: contain;
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  background: hsl(var(--card));
}
.pi-text-preview {
  max-height: 420px;
  overflow: auto;
  white-space: pre-wrap;
}
.upload-files-table-wrap { max-height: none; }
.upload-files-table {
  min-width: 820px;
  table-layout: fixed;
}
.upload-files-table .upload-file-select { width: 46px; }
.upload-files-table .upload-file-report { width: 28%; }
.upload-files-table .upload-file-company { width: 24%; }
.upload-files-table .upload-file-period { width: 22%; }
.upload-files-table .upload-file-status { width: 16%; }
.upload-files-table .upload-file-action { width: 90px; }
.upload-files-table th:nth-child(1),
.upload-files-table td:nth-child(1),
.upload-files-table th:nth-child(5),
.upload-files-table td:nth-child(5),
.upload-files-table th:nth-child(6),
.upload-files-table td:nth-child(6) { text-align: center; }
.upload-files-table th:nth-child(5),
.upload-files-table td:nth-child(5) { text-align: left; }
.upload-files-table td {
  height: 42px;
  vertical-align: middle;
}
.upload-files-table tr.source-review-row {
  background: hsl(38 58% 96%);
}
.upload-files-table tr.source-review-row td {
  border-bottom-color: hsl(50 14% 82%);
}
.upload-source-review-note {
  display: block;
  margin-top: 5px;
  color: hsl(24 75% 34%);
  font-size: 14px;
  line-height: 1.35;
  white-space: normal;
}
html[data-theme="dark"] .upload-files-table tr.source-review-row {
  background: hsl(38 70% 12% / .38);
}
html[data-theme="dark"] .upload-files-table tr.source-review-row td {
  border-bottom-color: hsl(82 14% 28%);
}
html[data-theme="dark"] .upload-source-review-note {
  color: hsl(36 86% 78%);
}
.source-history-table tr.source-review-row {
  background: hsl(38 58% 96%);
  box-shadow: inset 2px 0 0 hsl(24 75% 42%);
}
.source-history-table tr.source-review-row td {
  border-bottom-color: hsl(50 14% 82%);
}
.source-control-summary-grid span small {
  display: block;
  margin-top: 4px;
  color: hsl(var(--muted-foreground));
  font-size: 13px;
  font-weight: 700;
}
.source-filter-actions {
  justify-content: flex-start;
}
.source-review-alert {
  border-color: hsl(24 65% 50% / .28);
  background: hsl(38 58% 97%);
}
.source-period-warning {
  margin: 10px 0 12px;
  border: 1px solid hsl(38 70% 45% / .34);
  border-radius: 8px;
  background: hsl(38 58% 96%);
  color: hsl(82 14% 28%);
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 800;
}
.source-conflict-panel {
  border-color: hsl(82 14% 50% / .22);
}
.source-history-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.source-history-actions form {
  margin: 0;
}
html[data-theme="dark"] .source-history-table tr.source-review-row {
  background: hsl(38 70% 12% / .38);
  box-shadow: inset 2px 0 0 hsl(36 86% 58%);
}
html[data-theme="dark"] .source-history-table tr.source-review-row td {
  border-bottom-color: hsl(82 14% 28%);
}
html[data-theme="dark"] .source-review-alert {
  background: hsl(38 70% 12% / .28);
  border-color: hsl(36 70% 48% / .28);
}
html[data-theme="dark"] .source-period-warning {
  background: hsl(38 70% 12% / .38);
  border-color: hsl(36 70% 48% / .3);
  color: hsl(36 78% 78%);
}
.upload-files-table .upload-file-name-cell {
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.4;
}
.upload-files-table td:nth-child(3),
.upload-files-table td:nth-child(4) { color: hsl(var(--muted-foreground)); }
.erp-target-progress-table {
  min-width: 1460px;
}
.erp-target-progress-table th,
.erp-target-progress-table td {
  vertical-align: middle;
}
.erp-target-progress-table th:nth-child(1),
.erp-target-progress-table td:nth-child(1) {
  width: 210px;
  text-align: left;
}
.erp-target-progress-table th:nth-child(2),
.erp-target-progress-table td:nth-child(2) {
  width: 190px;
  text-align: left;
}
.erp-target-progress-table th:nth-child(3),
.erp-target-progress-table td:nth-child(3) {
  width: 170px;
  text-align: left;
}
.erp-target-progress-table th:nth-child(4),
.erp-target-progress-table td:nth-child(4),
.erp-target-progress-table th:nth-child(5),
.erp-target-progress-table td:nth-child(5),
.erp-target-progress-table th:nth-child(6),
.erp-target-progress-table td:nth-child(6),
.erp-target-progress-table th:nth-child(7),
.erp-target-progress-table td:nth-child(7),
.erp-target-progress-table th:nth-child(8),
.erp-target-progress-table td:nth-child(8) {
  width: 130px;
  text-align: center;
}
.erp-target-progress-table th:nth-child(9),
.erp-target-progress-table td:nth-child(9) {
  width: 160px;
  text-align: center;
}
.erp-target-progress-table th:nth-child(10),
.erp-target-progress-table td:nth-child(10) {
  width: 90px;
  text-align: center;
}
.erp-target-progress-table td:nth-child(1),
.erp-target-progress-table td:nth-child(2) {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
  line-height: 1.35;
}
.erp-target-progress-table td:nth-child(3),
.erp-target-progress-table td:nth-child(4),
.erp-target-progress-table td:nth-child(5),
.erp-target-progress-table td:nth-child(6),
.erp-target-progress-table td:nth-child(7),
.erp-target-progress-table td:nth-child(8),
.erp-target-progress-table td:nth-child(10) {
  white-space: nowrap;
}
.erp-downloaded-files-table {
  min-width: 1080px;
}
.erp-downloaded-files-table th:nth-child(1),
.erp-downloaded-files-table td:nth-child(1) {
  width: 190px;
  text-align: left;
}
.erp-downloaded-files-table th:nth-child(2),
.erp-downloaded-files-table td:nth-child(2) {
  width: 210px;
  text-align: left;
}
.erp-downloaded-files-table th:nth-child(3),
.erp-downloaded-files-table td:nth-child(3) {
  width: 180px;
  text-align: left;
}
.erp-downloaded-files-table th:nth-child(4),
.erp-downloaded-files-table td:nth-child(4) {
  width: 110px;
  text-align: center;
}
.erp-downloaded-files-table th:nth-child(5),
.erp-downloaded-files-table td:nth-child(5) {
  width: 280px;
  text-align: left;
}
.erp-downloaded-files-table th:nth-child(6),
.erp-downloaded-files-table td:nth-child(6) {
  width: 150px;
  text-align: left;
}
.erp-downloaded-files-table td:nth-child(1),
.erp-downloaded-files-table td:nth-child(2),
.erp-downloaded-files-table td:nth-child(5),
.erp-downloaded-files-table td:nth-child(6) {
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.35;
}
.erp-downloaded-files-table td:nth-child(3),
.erp-downloaded-files-table td:nth-child(4) {
  white-space: nowrap;
}
.upload-delete-selected-form { margin: 0; }
.upload-delete-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 12px 8px 2px;
}
.table-link { color: hsl(var(--primary)); font-weight: 800; text-decoration: underline; text-underline-offset: 2px; }
.rr-company-table-wrap { max-height: 58vh; }
.rr-company-table th:first-child,
.rr-company-table td:first-child { width: 150px; text-align: left; }
.factory-select {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 92px;
  font-weight: 800;
  color: hsl(var(--foreground));
}
.factory-select input { width: 16px; height: 16px; }
.factory-select span { font-size: 12px; }
.modal-panel {
  width: min(760px, 100%);
  max-height: min(84vh, 820px);
  overflow: auto;
  border: 1px solid hsl(var(--border));
  border-radius: 16px;
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  box-shadow: 0 26px 80px rgb(15 23 42 / .28);
  padding: 16px;
}
.lease-schedule-modal { width: min(1180px, 100%); }
.lease-schedule-link,
.text-command {
  border: 0;
  background: transparent;
  color: hsl(var(--accent));
  font: inherit;
  font-weight: 800;
  padding: 0;
  cursor: pointer;
  text-align: left;
}
.lease-schedule-link:hover,
.text-command:hover { text-decoration: underline; }
.lease-schedule-table input {
  width: 100%;
  min-width: 112px;
  border: 1px solid hsl(var(--border));
  border-radius: 10px;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  padding: 7px 9px;
}
.rr-modal-body h2 { margin: 0 0 8px; font-size: 16px; }
.dense-table-wrap { max-height: 420px; }
.dense-table { font-size: 13px; }
.dense-table th { font-size: 12px; padding: 7px; }
.dense-table td { padding: 6px 7px; }
.wide-admin-table { max-height: 520px; }
.admin-table { font-size: 12px; }
.admin-table th, .admin-table td { padding: 6px; }
.admin-table small { color: hsl(var(--muted-foreground)); font-size: 11px; }
.sop-bucket-table {
  table-layout: fixed;
}
.sop-bucket-table th:first-child,
.sop-bucket-table td:first-child {
  width: 32%;
}
.sop-bucket-table th:nth-child(2),
.sop-bucket-table td:nth-child(2) {
  width: 34%;
}
.sop-bucket-table th:nth-child(3),
.sop-bucket-table td:nth-child(3) {
  width: 34%;
}
.sop-bucket-table th,
.sop-bucket-table td {
  vertical-align: middle;
}
.sop-bucket-table th:nth-child(3),
.sop-bucket-table td:nth-child(3),
.sop-bucket-table .sop-number-cell,
.sop-bucket-table .sop-end-cell {
  text-align: right;
}
.sop-bucket-table th:nth-child(2),
.sop-bucket-table td:nth-child(2) {
  text-align: center;
}
.sop-bucket-table .sop-text-cell {
  color: hsl(var(--foreground));
}
.sop-bucket-table input[type="number"] {
  display: inline-block;
  width: 96px;
  max-width: 100%;
  height: 34px;
  margin: 0;
  padding: 6px 8px;
  text-align: right;
  box-sizing: border-box;
}

/* Forms and mapping */
.dropzone {
  border: 1px dashed hsl(var(--primary) / .35);
  border-radius: 16px;
  background: hsl(var(--primary) / .06);
  padding: 26px;
  text-align: center;
  place-items: center;
}
.dropzone strong { font-size: 18px; }
.dropzone span, .form-note { color: hsl(var(--muted-foreground)); font-weight: 500; }
.dropzone input { border: 0; background: transparent; }
.upload-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 14px;
  align-items: stretch;
}
.upload-file-stage,
.upload-next-card {
  display: grid;
  gap: 12px;
}
.upload-context-strip {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) 80px 150px auto;
  gap: 8px;
  align-items: center;
}
.upload-context-strip span {
  display: grid;
  gap: 2px;
  min-height: 44px;
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  background: hsl(var(--muted) / .18);
  padding: 8px 10px;
}
.upload-context-strip b {
  min-width: 0;
  color: hsl(var(--foreground));
  font-size: 14px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.upload-context-strip small {
  color: hsl(var(--muted-foreground));
  font-size: 12px;
  font-weight: 850;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.upload-context-strip > a {
  justify-self: end;
  white-space: nowrap;
}
.upload-dropzone-large {
  min-height: 138px;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) max-content;
  align-items: center;
  gap: 14px;
  text-align: left;
  border-style: solid;
  border-color: hsl(var(--border));
  background: hsl(var(--card));
  padding: 18px;
  border-radius: 10px;
  transition: border-color .16s ease, background .16s ease, transform .16s ease;
  cursor: pointer;
}
.upload-dropzone-large:hover,
.upload-dropzone-large:focus-within {
  border-color: hsl(var(--primary) / .65);
  background: hsl(var(--muted) / .28);
  transform: translateY(-1px);
}
.upload-drop-icon {
  display: inline-grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid hsl(var(--primary) / .25);
  border-radius: 10px;
  background: hsl(var(--primary) / .08);
  color: hsl(var(--primary));
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .04em;
}
.upload-drop-text {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.upload-drop-text strong {
  color: hsl(var(--foreground));
  font-size: 17px;
  line-height: 1.2;
}
.upload-drop-text span {
  color: hsl(var(--muted-foreground));
  font-size: 13px;
  line-height: 1.4;
}
.upload-browse-btn {
  /* Neutral Tabler .btn (see dfm-theme.css); the form's submit button is the one primary action. */
  white-space: nowrap;
}

.batch-control-table b {
  color: hsl(var(--foreground));
}

.batch-control-table small {
  display: block;
  color: hsl(var(--muted-foreground));
  line-height: 1.35;
}

.batch-create-form {
  max-width: none;
}

.active-batch-panel {
  padding-bottom: 14px;
}

.compact-batch-panel {
  padding: 14px 18px;
}

.compact-batch-panel .panel-title-row {
  margin-bottom: 10px;
  padding-bottom: 8px;
}

.active-source-strip {
  display: grid;
  grid-template-columns: minmax(260px, 1.6fr) repeat(5, minmax(112px, 1fr)) auto;
  align-items: center;
  gap: 8px;
}

.active-source-strip span {
  display: grid;
  gap: 2px;
  min-height: 46px;
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  background: hsl(var(--muted) / .16);
  padding: 8px 10px;
}

.active-source-strip b {
  min-width: 0;
  color: hsl(var(--foreground));
  font-size: 15px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.active-source-strip small {
  color: hsl(var(--muted-foreground));
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
}

.active-source-strip > a {
  justify-self: end;
  white-space: nowrap;
}

.compact-batch-panel .compact-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 12px;
}

.compact-batch-panel .three-fields {
  grid-template-columns: 170px 220px minmax(220px, 320px);
  gap: 10px;
}

.compact-batch-panel .two-fields {
  max-width: 440px;
}

.compact-batch-panel .compact-actions {
  align-self: end;
  padding: 0 0 1px;
}

.batch-create-form :is(input, select) {
  min-height: 42px;
}

.batch-control-table th,
.batch-control-table td {
  vertical-align: top;
}

.batch-control-table td:first-child b {
  display: block;
  margin-bottom: 5px;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.25;
}

.batch-control-table {
  min-width: 980px;
  table-layout: fixed;
}

.batch-control-table th:nth-child(1),
.batch-control-table td:nth-child(1) {
  width: 42%;
}

.batch-control-table th:nth-child(2),
.batch-control-table td:nth-child(2) {
  width: 14%;
  text-align: center;
}

.batch-control-table th:nth-child(3),
.batch-control-table td:nth-child(3) {
  width: 26%;
}

.batch-control-table th:nth-child(4),
.batch-control-table td:nth-child(4) {
  width: 18%;
  text-align: center;
}

.batch-control-table .batch-actions-cell {
  display: flex;
  gap: 10px;
  justify-content: flex-start;
  align-items: flex-start;
  flex-wrap: wrap;
}

.batch-control-table .batch-actions-cell b {
  flex: 1 1 260px;
  min-width: 0;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.batch-control-table .active-batch-row {
  background: hsl(var(--primary) / 0.08);
}

.batch-source-review-card {
  display: grid;
  gap: 10px;
  padding: 14px 18px;
}

.batch-source-review-list,
.batch-source-conflict-list {
  display: grid;
  gap: 8px;
}

.batch-source-review-list article,
.batch-source-conflict-list article {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  background: hsl(var(--card));
  padding: 10px 12px;
  box-shadow: inset 2px 0 0 hsl(82 14% 48%);
}

.batch-source-review-list b,
.batch-source-conflict-list b {
  display: block;
  color: hsl(var(--foreground));
  font-size: 15px;
  line-height: 1.25;
}

.batch-source-review-list small,
.batch-source-conflict-list small,
.batch-source-review-list em,
.batch-source-conflict-list em {
  display: block;
  margin-top: 3px;
  color: hsl(var(--muted-foreground));
  font-size: 13px;
  font-style: normal;
  font-weight: 700;
  line-height: 1.35;
}

.batch-source-review-list em {
  color: hsl(24 75% 34%);
}

.batch-source-review-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.batch-source-review-actions form {
  margin: 0;
}

.batch-metric {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  min-width: 86px;
  padding: 5px 12px;
  border: 1px solid hsl(var(--border));
  border-radius: 999px;
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  font-size: 14px;
  font-weight: 850;
}

.batch-readiness {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.batch-readiness > span:last-child {
  color: hsl(var(--muted-foreground));
  font-size: 14px;
  font-weight: 700;
}

.readiness-list {
  display: grid;
  gap: 8px;
}

.readiness-item {
  border: 1px solid hsl(var(--border));
  border-radius: 10px;
  background: hsl(var(--card));
  overflow: hidden;
}

.readiness-item summary {
  position: relative;
  display: grid;
  grid-template-columns: minmax(220px, .8fr) minmax(360px, 1.25fr) max-content;
  gap: 14px;
  align-items: center;
  min-height: 58px;
  padding: 10px 12px 10px 42px;
  cursor: pointer;
  list-style: none;
}

.readiness-item summary::-webkit-details-marker {
  display: none;
}

.readiness-item summary::before {
  content: ">";
  position: absolute;
  left: 12px;
  top: 50%;
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid hsl(var(--border));
  color: hsl(var(--muted-foreground));
  font-size: 13px;
  line-height: 1;
  transform: translateY(-50%) rotate(0deg);
  transition: transform .16s ease;
}

.readiness-item[open] summary::before {
  transform: translateY(-50%) rotate(90deg);
}

.readiness-title {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  color: hsl(var(--foreground));
  font-weight: 900;
  line-height: 1.25;
}

.readiness-metrics {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.readiness-metrics span {
  border: 1px solid hsl(var(--border));
  border-radius: 999px;
  background: hsl(var(--muted) / .38);
  color: hsl(var(--muted-foreground));
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.readiness-metrics b {
  color: hsl(var(--foreground));
}

.readiness-detail-grid {
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(0, .9fr) minmax(0, 1.2fr);
  gap: 10px;
  padding: 0 12px 12px;
  border-top: 1px solid hsl(var(--border));
  background: hsl(var(--muted) / .22);
}

.readiness-detail-grid article {
  padding-top: 10px;
}

.readiness-detail-grid b {
  display: block;
  margin-bottom: 5px;
  color: hsl(var(--foreground));
}

.readiness-detail-grid p {
  margin: 0 0 5px;
  color: hsl(var(--muted-foreground));
  line-height: 1.45;
}

.readiness-item.ready summary {
  background: hsl(151 81% 96% / .42);
}

.readiness-item.missing-files summary,
.readiness-item.period-review summary,
.readiness-item.duplicate-review summary {
  background: hsl(38 70% 45% / .08);
}

.working-source-lines-card {
  display: grid;
  gap: 12px;
}

.working-readiness-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 11px;
  border-bottom: 1px solid hsl(var(--border));
}

.working-readiness-head h2 {
  margin-bottom: 4px;
}

.working-readiness-head small {
  color: hsl(var(--muted-foreground));
  font-size: 14px;
  font-weight: 650;
}

.working-readiness-totals {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.working-readiness-totals span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 5px 10px;
  border: 1px solid hsl(var(--border));
  border-radius: 999px;
  background: hsl(var(--muted) / .16);
  color: hsl(var(--muted-foreground));
  font-size: 13px;
  font-weight: 750;
}

.working-readiness-totals b {
  color: hsl(var(--foreground));
}

.working-source-lines {
  display: grid;
  overflow: visible;
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  background: hsl(var(--card));
  box-shadow: inset 0 1px 0 hsl(48 26% 100% / .65);
}

.working-source-line {
  display: grid;
  grid-template-columns: minmax(300px, 520px) 330px 260px 140px;
  justify-content: start;
  column-gap: 22px;
  align-items: center;
  min-height: 44px;
  padding: 8px 14px;
  border-bottom: 1px solid hsl(var(--border));
}

.working-source-line:last-child {
  border-bottom: 0;
}

.working-source-header {
  min-height: 34px;
  padding-top: 7px;
  padding-bottom: 7px;
  background: hsl(var(--muted) / .26);
}

.working-source-header span {
  color: hsl(var(--muted-foreground));
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.working-source-line.ready {
  background: hsl(var(--card));
  box-shadow: inset 2px 0 0 hsl(154 28% 40%);
}

.working-source-line.missing-files,
.working-source-line.source-review,
.working-source-line.period-review,
.working-source-line.duplicate-review {
  background: hsl(var(--card));
  box-shadow: inset 2px 0 0 hsl(82 14% 48%);
}

.working-source-line b {
  min-width: 0;
  color: hsl(var(--foreground));
  font-size: 14px;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.working-source-line span:not(.dfm-status) {
  color: hsl(var(--muted-foreground));
  font-size: 13px;
  font-weight: 750;
  white-space: nowrap;
}

.source-coverage {
  display: grid;
  grid-template-columns: 42px 220px;
  align-items: center;
  gap: 8px;
}

.source-coverage strong {
  color: hsl(var(--foreground));
  font-size: 13px;
  font-weight: 900;
}

.source-coverage i {
  display: block;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: hsl(var(--muted));
}

.source-coverage u {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: hsl(82 14% 48%);
  text-decoration: none;
}

.working-source-line.ready .source-coverage u {
  background: hsl(154 32% 40%);
}

.source-exceptions {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex-wrap: wrap;
}

.source-hover-cell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  max-width: 100%;
  min-height: 24px;
  padding: 3px 9px;
  border: 1px solid hsl(var(--border));
  border-radius: 999px;
  background: hsl(var(--muted) / .14);
  font-size: 13px;
  font-weight: 800;
}

.source-hover-cell.has-issues {
  color: hsl(82 14% 31%) !important;
  background: hsl(48 26% 96%);
  border-color: hsl(82 14% 48% / .24);
  cursor: help;
}

.source-clear-text {
  color: hsl(var(--muted-foreground));
  font-size: 13px;
  font-weight: 700;
}

.source-hover-cell em {
  position: absolute;
  z-index: 50;
  left: 0;
  top: calc(100% + 8px);
  display: none;
  width: max-content;
  max-width: min(520px, 70vw);
  padding: 10px 11px;
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  background: hsl(var(--popover));
  color: hsl(var(--popover-foreground));
  box-shadow: 0 16px 32px hsl(var(--foreground) / .16);
  font-style: normal;
  font-size: 13px;
  line-height: 1.35;
  white-space: normal;
}

.source-hover-cell:hover em,
.source-hover-cell:focus em {
  display: block;
}

.working-source-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  color: hsl(var(--muted-foreground));
  font-size: 14px;
  font-weight: 700;
}

.working-source-footer a {
  color: hsl(var(--accent));
  font-weight: 850;
  text-decoration: none;
}

.working-source-footer a:hover {
  text-decoration: underline;
}

html[data-theme="dark"] .working-source-line.ready {
  background: hsl(var(--card));
  box-shadow: inset 2px 0 0 hsl(154 30% 54%);
}

html[data-theme="dark"] .working-source-line.missing-files,
html[data-theme="dark"] .working-source-line.source-review,
html[data-theme="dark"] .working-source-line.period-review,
html[data-theme="dark"] .working-source-line.duplicate-review {
  background: hsl(var(--card));
  box-shadow: inset 2px 0 0 hsl(50 14% 58%);
}

html[data-theme="dark"] .source-hover-cell.has-issues {
  background: hsl(82 14% 15% / .56);
  border-color: hsl(50 14% 58% / .3);
  color: hsl(50 14% 78%) !important;
}

.batch-attach-notice {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px;
  margin-bottom: 12px;
  border: 1px solid hsl(var(--border));
  border-radius: 12px;
  background: hsl(var(--muted) / 0.38);
}

.batch-attach-notice span:not(.dfm-status) {
  font-family: var(--font-mono);
  color: hsl(var(--foreground));
}
.upload-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.upload-selected-files {
  min-height: 38px;
  border: 1px solid hsl(var(--border));
  border-radius: 10px;
  background: hsl(var(--muted) / .25);
  color: hsl(var(--muted-foreground));
  padding: 11px 12px;
  font-size: 13px;
  font-weight: 750;
  overflow-wrap: anywhere;
}
.upload-next-card {
  border: 1px solid hsl(var(--border));
  border-radius: 10px;
  background: hsl(var(--muted) / .18);
  padding: 14px;
  align-content: start;
}
.upload-next-card h3 {
  margin: 0;
  color: hsl(var(--foreground));
  font-size: 17px;
  line-height: 1.25;
}
.upload-next-card label {
  margin: 0;
}
.upload-next-card .two-fields {
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.upload-next-card :is(input, select) {
  min-height: 42px;
}
.upload-next-card .primary.big {
  width: 100%;
  margin-top: 2px;
}
.tip-grid, .info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin: 24px 0 22px; }
.info-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tip-grid article, .info-card { border-radius: 14px; padding: 16px 16px 14px; }
.tip-grid b, .info-card b { display: block; color: hsl(var(--foreground)); font-size: 13px; margin-bottom: 9px; }
.tip-grid span, .info-card span { display: block; color: hsl(var(--muted-foreground)); font-size: 13px; line-height: 1.58; }
.info-card { border-left: 4px solid hsl(160 84% 39%); }
.info-card:nth-child(2n) { border-left-color: hsl(38 92% 50%); }
.info-card:nth-child(3n) { border-left-color: hsl(84 25% 58%); }
.info-card em {
  display: inline-flex;
  margin-top: 14px;
  border-radius: 999px;
  background: hsl(160 84% 39% / .1);
  color: hsl(160 84% 30%);
  padding: 4px 7px;
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.readiness-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.readiness-grid span {
  border: 1px solid hsl(var(--border));
  border-radius: 12px;
  background: hsl(var(--muted) / .55);
  color: hsl(var(--muted-foreground));
  padding: 8px;
}
.readiness-grid b { color: hsl(var(--foreground)); }
.current-account-setup-form {
  gap: 14px;
}
.ca-period-grid,
.ca-reco-pair-grid {
  display: grid;
  gap: 12px;
}
.ca-period-grid {
  grid-template-columns: repeat(2, minmax(180px, 1fr));
}
.ca-reco-pair-grid {
  grid-template-columns: minmax(0, 1fr) 52px minmax(0, 1fr);
  align-items: end;
}
.ca-company-picker {
  min-width: 0;
}
.ca-flow-arrow {
  display: grid;
  place-items: center;
  min-height: 42px;
  border: 1px solid hsl(var(--border));
  border-radius: 10px;
  background: hsl(var(--muted) / .52);
  color: hsl(var(--muted-foreground));
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}
.ca-setup-actions,
.ca-result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.ca-selected-pair {
  display: grid;
  gap: 4px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid hsl(var(--border));
  border-radius: 12px;
  background: hsl(var(--muted) / .36);
}
.ca-selected-pair span {
  color: hsl(var(--muted-foreground));
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}
.ca-selected-pair strong {
  color: hsl(var(--foreground));
  font-size: 17px;
}
.ca-selected-pair small {
  color: hsl(var(--muted-foreground));
}
.ca-selected-pair .inline {
  margin-top: 4px;
}
.ca-result-panel .prepaid-permission-grid {
  margin-top: 0;
}
.ca-export-form {
  display: grid;
  gap: 12px;
  margin-top: 10px;
}
.ca-export-grid {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 58px minmax(240px, 1fr);
  gap: 12px;
  align-items: stretch;
}
.ca-pair-panel {
  min-width: 0;
  margin: 0;
  padding: 12px;
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  background: hsl(var(--background) / .58);
}
.ca-pair-panel legend {
  padding: 0 6px;
  color: hsl(var(--muted-foreground));
  font-size: 13px;
  font-weight: 850;
  line-height: 1.25;
}
.ca-choice-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  max-height: 236px;
  overflow: auto;
  padding-right: 4px;
}
.ca-choice {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 44px;
  padding: 8px 9px;
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  background: hsl(var(--muted) / .28);
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease, box-shadow .16s ease;
}
.ca-choice:hover {
  border-color: hsl(var(--primary) / .42);
  background: hsl(var(--primary) / .06);
}
.ca-choice input {
  accent-color: hsl(var(--primary));
}
.ca-choice span {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.ca-choice strong {
  color: hsl(var(--foreground));
  font-size: 14px;
  font-weight: 750;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ca-choice small {
  color: hsl(var(--muted-foreground));
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}
.ca-choice:has(input:checked) {
  border-color: hsl(var(--primary) / .62);
  background: hsl(var(--primary) / .10);
  box-shadow: inset 3px 0 0 hsl(var(--primary));
}
.ca-export-arrow {
  display: grid;
  place-items: center;
  align-self: center;
  min-height: 42px;
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  background: hsl(var(--muted) / .44);
  color: hsl(var(--muted-foreground));
  font-size: 13px;
  font-weight: 850;
  text-transform: uppercase;
}
.ca-export-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding-top: 2px;
}
.ca-export-footer span {
  color: hsl(var(--muted-foreground));
  font-size: 13px;
  font-weight: 750;
}
.ca-detail-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}
.ca-detail-head .panel-title-row {
  min-width: 0;
}
.ca-detail-head .ca-result-actions {
  justify-content: flex-end;
  flex-wrap: nowrap;
}
.ca-detail-head .ca-result-actions > * {
  width: auto;
}
.erp-primary-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.erp-primary-actions > * {
  flex: 1 1 220px;
}
.erp-result-panel {
  overflow: hidden;
}
.erp-status-overview {
  margin-top: 14px;
}
.erp-result-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid hsl(var(--border));
  padding-bottom: 14px;
  margin-bottom: 14px;
}
.erp-result-head h2 {
  margin: 4px 0 0;
}
.erp-result-head-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}
.erp-run-chip {
  display: inline-flex;
  align-items: center;
  max-width: 360px;
  min-height: 34px;
  border: 1px solid hsl(var(--border));
  border-radius: 999px;
  background: hsl(var(--muted) / .72);
  color: hsl(var(--muted-foreground));
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.erp-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.erp-summary-card {
  position: relative;
  min-height: 94px;
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  background: hsl(var(--card));
  padding: 14px 15px;
  box-shadow: var(--soft);
  overflow: hidden;
}
.erp-summary-card:before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: hsl(var(--muted-foreground) / .42);
}
.erp-summary-card.ready:before { background: hsl(var(--status-success)); }
.erp-summary-card.pending:before { background: hsl(38 92% 50%); }
.erp-summary-card.failed:before { background: hsl(var(--status-danger)); }
.erp-summary-card.neutral:before { background: hsl(var(--status-info)); }
.erp-summary-card span,
.erp-summary-card small {
  display: block;
  color: hsl(var(--muted-foreground));
}
.erp-summary-card span {
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.erp-summary-card strong {
  display: block;
  margin: 6px 0 4px;
  color: hsl(var(--foreground));
  font-size: 28px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.erp-summary-card small {
  font-size: 13px;
  line-height: 1.35;
}
.erp-result-toolbar {
  display: flex;
  justify-content: flex-end;
  margin: 2px 0 14px;
}
.erp-status-list-panel {
  overflow: hidden;
}
.erp-status-run-list {
  display: grid;
  gap: 14px;
}
.erp-status-run-card {
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-md);
  background: hsl(var(--card));
  box-shadow: var(--shadow-sm);
  padding: 16px;
}
.erp-status-run-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
  margin-bottom: 12px;
}
.erp-status-run-head h3 {
  margin: 3px 0 4px;
  font-size: 20px;
  line-height: 1.25;
}
.erp-status-run-head p {
  margin: 0;
  color: hsl(var(--muted-foreground));
  font-size: 15px;
}
.erp-status-run-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.erp-status-report-list {
  margin-top: 14px;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.erp-status-report-header,
.erp-status-report-row {
  display: grid;
  grid-template-columns: minmax(260px, 1.5fr) minmax(190px, .8fr) 80px 150px;
  gap: 14px;
  align-items: center;
}
.erp-status-report-header {
  padding: 10px 14px;
  background: hsl(var(--muted) / .55);
  color: hsl(var(--muted-foreground));
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.erp-status-report-row {
  min-height: 58px;
  padding: 10px 14px;
  border-top: 1px solid hsl(var(--border));
}
.erp-status-report-row strong {
  display: block;
  font-size: 15px;
  line-height: 1.35;
}
.erp-status-report-row small {
  display: block;
  margin-top: 3px;
  color: hsl(var(--muted-foreground));
  font-size: 13px;
  line-height: 1.35;
}
.erp-status-report-progress span {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.erp-report-section-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.erp-report-section-chip {
  min-height: 76px;
  border: 1px solid hsl(var(--border));
  border-left: 3px solid hsl(82 14% 49%);
  border-radius: var(--radius-sm);
  background: hsl(var(--muted) / .28);
  padding: 11px 12px;
}
.erp-report-section-chip.ready {
  border-left-color: hsl(var(--status-success));
  background: hsl(var(--status-success) / .08);
}
.erp-report-section-chip.in-progress {
  border-left-color: hsl(84 25% 52%);
  background: hsl(48 26% 96% / .75);
}
.erp-report-section-chip.failed {
  border-left-color: hsl(var(--destructive));
  background: hsl(var(--destructive) / .06);
}
.erp-report-section-chip strong,
.erp-report-section-chip span,
.erp-report-section-chip small {
  display: block;
}
.erp-report-section-chip strong {
  min-height: 34px;
  font-size: 14px;
  line-height: 1.35;
}
.erp-report-section-chip span {
  margin-top: 5px;
  font-size: 18px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.erp-report-section-chip small {
  margin-top: 2px;
  color: hsl(var(--muted-foreground));
  font-size: 13px;
  font-weight: 800;
}
.erp-current-processing-panel {
  margin-top: 14px;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-sm);
  background: hsl(var(--background) / .55);
  overflow: hidden;
}
.erp-current-processing-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  border-bottom: 1px solid hsl(var(--border));
}
.erp-current-processing-head h4 {
  margin: 0;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.erp-current-processing-head small,
.erp-current-empty {
  color: hsl(var(--muted-foreground));
}
.erp-current-empty {
  margin: 0;
  padding: 14px;
}
.erp-current-processing-list {
  display: grid;
}
.erp-current-processing-item {
  display: grid;
  grid-template-columns: minmax(260px, 1.3fr) minmax(180px, .8fr) 110px;
  gap: 14px;
  align-items: center;
  min-height: 62px;
  padding: 12px 14px;
  border-top: 1px solid hsl(var(--border));
}
.erp-current-processing-item:first-child {
  border-top: 0;
}
.erp-current-processing-item strong,
.erp-current-processing-item span {
  display: block;
  font-size: 15px;
  line-height: 1.35;
}
.erp-current-processing-item small {
  display: block;
  margin-top: 3px;
  color: hsl(var(--muted-foreground));
  font-size: 13px;
  line-height: 1.35;
}
.erp-current-processing-item b {
  justify-self: end;
  min-width: 86px;
  border: 1px solid hsl(var(--border));
  border-radius: 999px;
  padding: 7px 10px;
  background: hsl(var(--card));
  color: hsl(84 25% 35%);
  font-size: 14px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
html[data-theme="dark"] .erp-report-section-chip.in-progress {
  background: hsl(82 14% 18% / .42);
}
html[data-theme="dark"] .erp-current-processing-item b {
  color: hsl(48 26% 88%);
}
.erp-status-list-table th,
.erp-status-list-table td {
  vertical-align: middle;
}
.erp-status-list-table td:first-child strong,
.erp-status-progress-cell strong {
  display: block;
  font-size: 15px;
  line-height: 1.35;
}
.erp-status-list-table td:first-child small,
.erp-status-list-table td:nth-child(5) small,
.erp-status-progress-cell small {
  display: block;
  margin-top: 3px;
  color: hsl(var(--muted-foreground));
  font-size: 13px;
  line-height: 1.35;
}
.erp-status-progress-cell {
  min-width: 190px;
}
.erp-status-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  white-space: nowrap;
}
.erp-live-summary {
  margin-bottom: 10px;
}
.erp-live-progress {
  height: 9px;
  border: 1px solid hsl(var(--border));
  border-radius: 999px;
  background: hsl(var(--muted) / .55);
  overflow: hidden;
}
.erp-live-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, hsl(var(--accent)), hsl(var(--status-success)));
  transition: width .3s ease;
}
@media (max-width: 900px) {
  .erp-status-run-head,
.erp-status-report-header,
.erp-status-report-row,
.erp-current-processing-item {
    grid-template-columns: 1fr;
  }
  .erp-status-run-actions {
    justify-content: flex-start;
  }
  .erp-current-processing-item b {
    justify-self: start;
  }
}
.erp-live-copy {
  margin: 8px 0 12px;
}
.erp-final-results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 10px;
}
.erp-final-results-head h2 {
  margin: 0;
}
.erp-final-result-table {
  min-width: 760px;
}
.erp-final-result-table th:nth-child(1),
.erp-final-result-table td:nth-child(1) {
  width: 260px;
  text-align: left;
}
.erp-final-result-table th:nth-child(2),
.erp-final-result-table td:nth-child(2) {
  width: 360px;
  text-align: left;
}
.erp-final-result-table th:nth-child(3),
.erp-final-result-table td:nth-child(3),
.erp-final-result-table th:nth-child(4),
.erp-final-result-table td:nth-child(4) {
  width: 120px;
  text-align: center;
}
.erp-final-result-table td:nth-child(1),
.erp-final-result-table td:nth-child(2) {
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.35;
}
.erp-step-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
.erp-step {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 42px;
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  background: hsl(var(--secondary) / .7);
  padding: 9px 10px;
}
.erp-step small {
  min-width: 0;
  color: hsl(var(--muted-foreground));
  font-size: 13px;
  font-weight: 750;
  line-height: 1.2;
}
.erp-step b {
  flex: 0 0 auto;
  color: hsl(var(--foreground));
  font-size: 13px;
  font-weight: 900;
}
.erp-step.ready {
  border-color: hsl(var(--status-success) / .30);
  background: hsl(var(--status-success) / .075);
}
.erp-step.in-progress,
.erp-step.partial {
  border-color: hsl(var(--status-info) / .34);
  background: hsl(var(--status-info) / .085);
}
.erp-step.failed,
.erp-step.missing {
  border-color: hsl(var(--status-danger) / .30);
  background: hsl(var(--status-danger) / .075);
}
.erp-step.pending {
  border-color: hsl(38 92% 50% / .28);
  background: hsl(38 92% 50% / .075);
}
.two-panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fg-dashboard-main-grid { align-items: start; }
.fg-export-panel {
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
}
.fg-export-panel .panel-title-row h2 { margin-bottom: 0; }
.fg-export-panel .pill-row { margin: 0; }
.fg-export-panel .secondary {
  align-self: flex-start;
  max-width: 100%;
  white-space: normal;
}
.sales-visual-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.sales-donut-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.sales-donut-card {
  min-height: 112px;
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid hsl(var(--border));
  border-radius: 12px;
  background: hsl(var(--muted) / .36);
}
.sales-donut-ring {
  --pct: 0;
  position: relative;
  width: 78px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background:
    conic-gradient(hsl(160 84% 39%) calc(min(max(var(--pct), 0), 100) * 1%), hsl(var(--border)) 0);
}
.sales-donut-ring::after {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: inherit;
  background: hsl(var(--card));
  box-shadow: inset 0 0 0 1px hsl(var(--border));
}
.sales-donut-ring span {
  position: relative;
  z-index: 1;
  color: hsl(var(--foreground));
  font-size: 14px;
  font-weight: 850;
}
.sales-donut-card strong,
.sales-rank-row strong {
  display: block;
  color: hsl(var(--foreground));
  font-size: 14px;
  font-weight: 850;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sales-donut-card b {
  display: block;
  color: hsl(160 84% 28%);
  font-size: 15px;
  margin-top: 3px;
}
.sales-donut-card small,
.sales-rank-row small {
  color: hsl(var(--muted-foreground));
  font-size: 12px;
}
.sales-rank-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.sales-rank-list {
  display: grid;
  gap: 9px;
}
.sales-rank-row {
  min-width: 0;
  padding-bottom: 8px;
  border-bottom: 1px solid hsl(var(--border));
}
.sales-rank-row:last-child { border-bottom: 0; padding-bottom: 0; }
.sales-rank-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.sales-rank-top span {
  flex: 0 0 auto;
  color: hsl(var(--foreground));
  font-size: 13px;
  font-weight: 800;
}
.sales-bar-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: hsl(var(--muted));
  margin: 6px 0 4px;
}
.sales-bar-track i {
  --pct: 0;
  display: block;
  width: calc(min(max(var(--pct), 0), 100) * 1%);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, hsl(84 25% 40%), hsl(84 25% 59%));
}
.fg-batch-dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr); gap: 12px; margin-bottom: 12px; }
.fg-batch-card { min-height: 230px; }
.wide-left { grid-template-columns: 1.35fr .65fr; }
.mapping-panel, .mapping-form { display: grid; gap: 14px; overflow: visible; }
.mapping-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; overflow: visible; }
.map-row {
  display: grid;
  grid-template-columns: 190px 1fr;
  align-items: center;
  gap: 10px;
  border: 1px solid hsl(var(--border));
  border-radius: 12px;
  background: hsl(var(--muted) / .45);
  padding: 8px;
  overflow: visible;
}
.map-row span { font-size: 13px; }
.map-row b { color: hsl(var(--destructive)); margin-left: 3px; }
.template-apply-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
  border: 1px solid hsl(var(--border));
  border-radius: 14px;
  background: hsl(var(--muted) / .35);
  padding: 12px;
}
.template-apply-row select { min-width: 260px; }
.column-search-note {
  margin: 10px 0 12px;
  padding: 10px 12px;
  border: 1px solid hsl(var(--primary) / .2);
  background: hsl(var(--primary) / .07);
  color: hsl(var(--foreground));
  border-radius: 12px;
  font-size: 12px;
}
.column-global-search {
  display: grid;
  grid-template-columns: minmax(240px, 420px) 1fr;
  gap: 10px;
  align-items: end;
  border: 1px solid hsl(var(--border));
  border-radius: 14px;
  background: hsl(var(--muted) / .45);
  padding: 12px;
}
.column-global-search span {
  color: hsl(var(--muted-foreground));
  font-size: 13px;
  line-height: 1.35;
}
.column-picker { position: relative; min-width: 0; width: 100%; }
.column-options {
  display: none;
  position: absolute;
  z-index: 80;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  max-height: 320px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  background: hsl(var(--popover));
  border: 1px solid hsl(var(--border));
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 5px;
}
.column-options.open { display: block; }
.column-option {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: hsl(var(--foreground));
  padding: 7px 9px;
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.column-option:hover, .column-option:focus { background: hsl(var(--primary) / .08); color: hsl(var(--primary)); outline: none; }
.muted-option { color: hsl(var(--muted-foreground)); cursor: default; }
.match-option { background: hsl(160 84% 39% / .1); color: hsl(160 84% 30%); font-weight: 750; }
.column-section-label {
  position: sticky;
  top: 0;
  z-index: 1;
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  padding: 6px 8px;
  margin: 3px 0;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.muted-label { background: hsl(38 92% 50% / .08); border-color: hsl(38 92% 50% / .2); }
.column-hint, .inline-help { color: hsl(var(--muted-foreground)); font-size: 11px; }
.heading-chip-wrap { display: flex; flex-wrap: wrap; gap: 6px; max-height: 300px; overflow: auto; padding: 4px 2px; }
.heading-chip { max-width: 260px; padding: 5px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mapping-table td:first-child { max-width: 360px; overflow: hidden; text-overflow: ellipsis; }
.assignment-table-wrap { max-height: 66vh; overflow: auto; border-radius: 14px; }
.requirement-table textarea { min-width: 220px; width: 100%; resize: vertical; }
.requirement-table .tiny-input { min-width: 130px; }
.requirement-table select { min-width: 120px; }
.audit-dashboard-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.audit-stream-card { padding: 18px; border-top: 5px solid hsl(160 84% 39%); }
.audit-stream-card:nth-child(2n) { border-top-color: hsl(84 25% 58%); }
.audit-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.audit-card-head h2 { font-size: 22px; margin: 2px 0 0; }
.audit-card-head strong { font-size: 30px; color: hsl(var(--foreground)); line-height: 1; }
.audit-detail-grid { display: grid; grid-template-columns: 1fr 0.85fr; gap: 10px; align-items: start; }
.audit-pending-title { margin-top: 14px; }
.three-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.audit-card-settings { margin-bottom: 12px; }
.audit-card-actions { margin: 12px 0; }
.audit-entry-card { display: block; text-decoration: none; }
.audit-entry-card:hover { transform: translateY(-1px); box-shadow: 0 18px 36px hsl(82 14% 11% / .12); }
.assignment-table th { position: sticky; top: 0; z-index: 3; }
.sticky-action-row {
  position: sticky;
  bottom: 0;
  border-top: 1px solid hsl(var(--border));
  background: hsl(var(--card) / .96);
  padding: 12px 0 2px;
  backdrop-filter: blur(8px);
}

/* Admin */
.admin-grid { display: grid; grid-template-columns: 1.2fr .8fr; gap: 12px; }
.developer-control-grid {
  grid-template-columns: minmax(420px, 1.08fr) minmax(360px, .92fr);
  align-items: stretch;
}
.developer-control-grid > .panel,
.developer-control-grid > .developer-control-side,
.developer-control-side > .panel {
  height: 100%;
}
.developer-control-grid .admin-create-panel,
.developer-controls-panel {
  display: flex;
  flex-direction: column;
}
.developer-control-grid .admin-create-panel form,
.developer-controls-panel .developer-control-block:last-child {
  flex: 1 1 auto;
}
.developer-control-side {
  display: grid;
  gap: 12px;
  min-width: 0;
}
.developer-side-panel {
  margin: 0;
}
.developer-controls-panel {
  gap: 12px;
}
.developer-control-block {
  display: grid;
  gap: 9px;
  padding-top: 10px;
  border-top: 1px solid hsl(var(--border));
}
.developer-control-block:first-of-type {
  padding-top: 0;
  border-top: 0;
}
.developer-control-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.developer-control-heading h3 {
  margin: 0;
  color: hsl(var(--foreground));
  font-size: 15px;
  line-height: 1.2;
}
.developer-control-heading small {
  color: hsl(var(--muted-foreground));
  font-size: 13px;
}
.developer-side-permissions {
  grid-template-columns: 1fr;
  gap: 6px;
  padding: 10px;
  border-radius: 8px;
}
.developer-control-grid .permission-box {
  border-radius: 8px;
}
.developer-control-grid .admin-create-panel .permission-box {
  align-content: start;
  flex: 1 1 auto;
  padding-top: 14px;
  padding-bottom: 14px;
}
.developer-control-grid .admin-create-panel button.primary,
.developer-control-block button.primary {
  align-self: center;
  width: auto;
  min-width: 220px;
}
.developer-line-notes {
  display: grid;
  gap: 5px;
  color: hsl(var(--muted-foreground));
  font-size: 13px;
  line-height: 1.38;
}
.developer-line-notes p {
  margin: 0;
}
.developer-line-notes b {
  color: hsl(var(--foreground));
}
.developer-side-panel .primary {
  min-height: 32px;
}
.compact-form { gap: 10px; }
.switch-row { display: flex; gap: 10px; flex-wrap: wrap; }
.check {
  display: inline-flex !important;
  align-items: center;
  gap: 6px;
  color: hsl(var(--foreground));
  font-size: 13px;
  font-weight: 700;
}
.check input { padding: 0; }
.permission-box {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  border: 1px solid hsl(var(--border));
  border-radius: 14px;
  background: hsl(var(--muted) / .45);
  padding: 12px;
}
.permission-title {
  grid-column: 1 / -1;
  color: hsl(var(--muted-foreground));
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.clean-list, .micro-list { margin: 7px 0 0; padding-left: 17px; color: hsl(var(--muted-foreground)); line-height: 1.6; font-size: 13px; }
.tiny-input { width: 105px; padding: 6px 7px !important; border-radius: 8px !important; font-size: 12px !important; }
.developer-api-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.developer-api-grid article,
.developer-api-details > div {
  border: 1px solid hsl(var(--border));
  border-radius: 14px;
  background: hsl(var(--muted) / .42);
  padding: 12px;
}
.developer-api-grid span {
  display: block;
  color: hsl(var(--muted-foreground));
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.developer-api-grid strong {
  display: block;
  color: hsl(var(--foreground));
  font-size: 20px;
  margin: 6px 0 3px;
  overflow-wrap: anywhere;
}
.developer-api-grid small,
.developer-api-details span {
  display: block;
  color: hsl(var(--muted-foreground));
  line-height: 1.4;
}
.developer-api-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.developer-api-details b {
  display: block;
  color: hsl(var(--foreground));
  margin-bottom: 7px;
}
.checklist-panel { border-left: 4px solid hsl(var(--primary)); }
.qa-panel { border-left: 4px solid hsl(84 25% 59%); }
.qa-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}
.qa-answer {
  margin: 10px 0 0;
  white-space: pre-wrap;
  border: 1px solid hsl(var(--border));
  border-radius: 12px;
  background: hsl(var(--muted) / .42);
  color: hsl(var(--foreground));
  padding: 11px 12px;
  min-height: 72px;
  max-height: 260px;
  overflow: auto;
  font: 13px/1.55 "Trebuchet MS", Arial, sans-serif;
}
@media (max-width: 1300px) {
  .detailed-strip, .principal-info-grid, .info-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detailed-working-grid, .working-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sales-visual-grid, .sales-rank-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .wide-left { grid-template-columns: 1fr; }
  .readiness-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .developer-api-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1050px) {
  .admin-grid, .admin-detail-grid, .two-panel-grid, .two-fields, .three-fields, .tip-grid, .fg-batch-dashboard-grid, .audit-dashboard-grid, .audit-detail-grid { grid-template-columns: 1fr; }
  .ca-reco-pair-grid { grid-template-columns: 1fr; }
  .ca-flow-arrow { min-height: 34px; }
  .data-panel .form-grid.four.lease-period-picker,
.prepaid-period-form,
.prepaid-entry-grid,
.prepaid-permission-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .permission-box { grid-template-columns: 1fr; }
  .developer-api-details { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .mapping-grid { grid-template-columns: 1fr; }
  .map-row, .template-apply-row, .column-global-search { grid-template-columns: 1fr; }
  .qa-form { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app-container { padding: 12px; }
  .ca-period-grid { grid-template-columns: 1fr; }
  .ca-detail-head { grid-template-columns: 1fr; }
  .ca-detail-head .ca-result-actions { justify-content: stretch; flex-wrap: wrap; }
  .ca-detail-head .ca-result-actions > * { width: 100%; }
  .ca-setup-actions > *,
.ca-result-actions > * { width: 100%; }
  .data-panel .form-grid.four.lease-period-picker,
.prepaid-period-form,
.prepaid-entry-grid,
.prepaid-permission-grid { grid-template-columns: 1fr; }
  .prepaid-entry-grid .span-2 { grid-column: auto; }
  .dashboard-section-title { display: block; }
  .lease-export-card { min-width: 0; margin-top: 14px; }
  .actions > *, .dfm-card-actions > *, .module-toolbar > *, .actions .primary, .actions .secondary, .actions .danger, .dfm-card-actions .primary, .dfm-card-actions .secondary, .dfm-card-actions .danger, .module-toolbar .primary, .module-toolbar .secondary, .module-toolbar .danger { width: 100%; }
  .actions, .dfm-card-actions, .module-toolbar { align-items: stretch; }
  .working-grid, .info-grid, .readiness-grid, .sales-visual-grid, .sales-rank-grid, .sales-donut-grid, .ask-example-grid, .ask-control-form { grid-template-columns: 1fr; }
  .developer-api-grid { grid-template-columns: 1fr; }
  .micro-meta { grid-template-columns: 1fr; }
  .mini-table { font-size: 12px; }
  .sonner-toaster { left: 14px; right: 14px; bottom: 14px; width: auto; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .intro-reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* shadcn primitive aliases for server-rendered Jinja components. */
.sh-input, .sh-select { min-width: 0; border: 1px solid hsl(var(--input)); border-radius: 10px; background: hsl(var(--background)); color: hsl(var(--foreground)); padding: 9px 10px; font: inherit; outline: none; }
.separator { height: 1px; width: 100%; background: hsl(var(--border)); margin: 12px 0; }
.tabs { display: inline-flex; padding: 3px; border: 1px solid hsl(var(--border)); border-radius: 10px; background: hsl(var(--muted)); }
.tab { display: inline-flex; align-items: center; border-radius: 8px; padding: 5px 9px; color: hsl(var(--muted-foreground)); font-weight: 750; }

/* Principal dashboard export/cleanup actions must render as matching controls. */

/* Lease working surface */
.lease-workspace {
  --lease-accent: hsl(160 84% 39%);
  --lease-accent-2: hsl(38 92% 50%);
}
.lease-workspace .subtitle {
  color: hsl(var(--muted-foreground));
  line-height: 1.55;
}
.lease-workspace .review-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.lease-workspace .metric,
.lease-workspace .review-card {
  border: 1px solid hsl(var(--border));
  border-radius: 12px;
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  box-shadow: var(--soft);
  padding: 13px;
}
.lease-workspace .metric span,
.lease-workspace .review-card span {
  display: block;
  color: hsl(var(--muted-foreground));
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.lease-workspace .metric strong,
.lease-workspace .review-card strong {
  display: block;
  margin-top: 5px;
  color: hsl(var(--foreground));
  font-size: 22px;
}
.lease-workspace .wizard-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
.lease-workspace .wizard-nav {
  position: sticky;
  top: 92px;
  border: 1px solid hsl(var(--border));
  border-radius: 16px;
  background: hsl(var(--card));
  padding: 14px;
  box-shadow: var(--soft);
}
.lease-workspace .nav-title,
.lease-workspace .sub-block-title {
  color: hsl(var(--muted-foreground));
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.lease-workspace .step-pill {
  width: 100%;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: hsl(var(--foreground));
  padding: 10px;
  text-align: left;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
.lease-workspace .step-pill:hover,
.lease-workspace .step-pill.active {
  border-color: hsl(var(--primary) / .20);
  background: hsl(var(--primary) / .08);
}
.lease-workspace .step-no {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
  font-weight: 850;
}
.lease-workspace .step-pill.active .step-no {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}
.lease-workspace .step-copy strong {
  display: block;
  color: hsl(var(--foreground));
}
.lease-workspace .step-copy span,
.lease-workspace .side-list {
  color: hsl(var(--muted-foreground));
  font-size: 14px;
  line-height: 1.5;
}
.lease-workspace .panel,
.lease-workspace .side-card {
  border: 1px solid hsl(var(--border));
  border-radius: 16px;
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  padding: 16px;
  box-shadow: var(--soft);
}
.lease-workspace .panel { min-height: 570px; }
.lease-workspace .side-card {
  margin-top: 14px;
  border-left: 4px solid var(--lease-accent-2);
  background: hsl(var(--muted) / .28);
}
.lease-workspace .side-card h3 {
  margin: 0 0 8px;
  color: hsl(var(--foreground));
  font-size: 15px;
}
.lease-workspace .side-list {
  margin: 0;
  padding-left: 18px;
}
.lease-workspace .section-head,
.lease-workspace .lease-toolbar,
.lease-workspace .footer-actions {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.lease-workspace .section-head h2 {
  margin: 5px 0 6px;
  color: hsl(var(--foreground));
  font-size: 20px;
}
.lease-workspace .ws-tag,
.lease-workspace .pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid hsl(var(--border));
  border-radius: 999px;
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 850;
}
.lease-workspace .form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.lease-workspace .form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.lease-workspace .dfm-input-group { display: grid; gap: 6px; }
.lease-workspace .hint,
.lease-workspace .upload-panel p {
  color: hsl(var(--muted-foreground));
  font-size: 13px;
  line-height: 1.45;
}
.lease-workspace .info-strip {
  margin-top: 14px;
  border: 1px solid hsl(var(--primary) / .20);
  border-radius: 12px;
  background: hsl(var(--primary) / .07);
  color: hsl(var(--foreground));
  padding: 11px 12px;
  font-size: 14px;
  line-height: 1.45;
}
.lease-workspace .upload-panel {
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  gap: 12px;
  border: 1px solid hsl(var(--border));
  border-left: 4px solid var(--lease-accent);
  border-radius: 14px;
  background: hsl(var(--card));
  padding: 14px;
  margin-bottom: 14px;
}
.lease-workspace .upload-actions,
.lease-workspace .upload-actions-row,
.lease-workspace .upload-mode,
.lease-workspace .dfm-card-actions,
.lease-workspace .footer-actions .right {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.lease-workspace .upload-actions { flex-direction: column; justify-content: center; }
.lease-workspace .upload-mode label {
  display: inline-flex;
  grid-auto-flow: column;
  align-items: center;
  gap: 6px;
  color: hsl(var(--muted-foreground));
  font-size: 13px;
}
.lease-workspace .upload-mode input { width: auto; }
.lease-workspace .upload-status,
.lease-workspace #statusMessage {
  min-height: 18px;
  color: hsl(var(--muted-foreground));
  font-size: 14px;
  font-weight: 850;
}
.lease-workspace .lease-toolbar,
.lease-workspace .sub-block,
.lease-workspace .lease-card {
  border: 1px solid hsl(var(--border));
  border-radius: 14px;
  background: hsl(var(--muted) / .34);
  padding: 12px;
}
.lease-workspace .lease-card {
  margin-bottom: 12px;
  overflow: hidden;
  padding: 0;
}
.lease-workspace .lease-card-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--card));
}
.lease-workspace .lease-title {
  display: flex;
  gap: 10px;
  align-items: center;
}
.lease-workspace .lease-badge {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: hsl(var(--primary) / .10);
  color: hsl(var(--primary));
  font-weight: 900;
}
.lease-workspace .lease-card h3,
.lease-workspace .upload-panel h3 {
  margin: 0 0 4px;
  color: hsl(var(--foreground));
  font-size: 16px;
}
.lease-workspace .lease-card p { margin: 0; color: hsl(var(--muted-foreground)); font-size: 13px; }
.lease-workspace .lease-body { padding: 12px; }
.lease-workspace .sub-block { margin-bottom: 10px; background: hsl(var(--card)); }
.lease-workspace .step-section { display: none; }
.lease-workspace .step-section.active { display: block; }
.lease-workspace .summary-box { display: none; margin-top: 14px; }
.lease-workspace .scrollable-table {
  overflow: auto;
  max-height: 450px;
  border: 1px solid hsl(var(--border));
  border-radius: 12px;
  background: hsl(var(--card));
}
.lease-workspace #bulkUploadPreview { margin-top: 12px; max-height: 260px; }
.lease-workspace table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: hsl(var(--card));
  font-size: 13px;
}
.lease-workspace th,
.lease-workspace td {
  padding: 8px;
  border-bottom: 1px solid hsl(var(--border));
  color: hsl(var(--foreground));
  text-align: right;
  white-space: nowrap;
}
.lease-workspace th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: hsl(var(--muted));
  font-weight: 850;
}
.lease-workspace td:first-child,
.lease-workspace th:first-child,
.lease-workspace td:nth-child(2),
.lease-workspace th:nth-child(2) { text-align: left; }
.lease-workspace .ws-modal {
  width: min(1050px, 100%);
  max-height: 88vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid hsl(var(--border));
  border-radius: 16px;
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  box-shadow: var(--soft);
}
.lease-workspace .ws-modal-header,
.lease-workspace .ws-modal-footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 14px;
  border-bottom: 1px solid hsl(var(--border));
}
.lease-workspace .ws-modal-footer {
  justify-content: flex-end;
  border-top: 1px solid hsl(var(--border));
  border-bottom: 0;
}
.lease-workspace .ws-modal-body { padding: 14px; overflow: auto; }
.lease-workspace .payment-input { width: 130px; }

@media (max-width: 1050px) {
  .lease-workspace .wizard-shell,
.lease-workspace .upload-panel { grid-template-columns: 1fr; }
  .lease-workspace .wizard-nav { position: static; }
}
@media (max-width: 760px) {
  .lease-workspace .review-grid,
.lease-workspace .form-grid,
.lease-workspace .form-grid.three { grid-template-columns: 1fr; }
  .lease-workspace .section-head,
.lease-workspace .lease-toolbar,
.lease-workspace .footer-actions,
.lease-workspace .lease-card-header { flex-direction: column; align-items: stretch; }
  .lease-workspace .footer-actions .right > *,
.lease-workspace .upload-actions-row > * { width: 100%; }
}
/* Light theme foundation: neutral surfaces keep attention on finance data and controls. */
html,
body {
  background: hsl(var(--background)) !important;
}
.data-panel,
.panel,
.login-card,
.empty-state,
.working-card,
.info-card,
.tip-grid article {
  background: hsl(var(--card)) !important;
}

html[data-theme="dark"],
html[data-theme="dark"] body {
  background: hsl(var(--background)) !important;
}
html[data-theme="dark"] .data-panel,
html[data-theme="dark"] .panel,
html[data-theme="dark"] .login-card,
html[data-theme="dark"] .empty-state,
html[data-theme="dark"] .working-card,
html[data-theme="dark"] .info-card,
html[data-theme="dark"] .tip-grid article {
  background: hsl(var(--card) / .94) !important;
}

/* Light mode converts the dashboard's intentionally dark showcase surfaces too. */

/* Revenue Reversal dashboard polish */
/* Shared RR workspace alignment keeps summary, factory, nonfactory, and company pages on one grid rhythm. */
.rr-workspace {
  display: grid;
  gap: 14px;
}
.rr-workspace > * {
  margin-top: 0;
  margin-bottom: 0;
}
.rr-workspace .data-panel,
.rr-workspace .working-card,
.rr-workspace .info-card {
  min-width: 0;
}
.rr-workspace .module-toolbar,
.rr-workspace .actions,
.rr-page-actions {
  align-items: stretch;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.rr-workspace .module-toolbar > a,
.rr-workspace .module-toolbar > form,
.rr-workspace .actions > a,
.rr-workspace .actions > button,
.rr-workspace .actions > form,
.rr-page-actions > a,
.rr-page-actions > button,
.rr-page-actions > form {
  display: inline-flex;
  align-items: stretch;
}
.rr-workspace .module-toolbar > a,
.rr-workspace .module-toolbar button,
.rr-workspace .actions > a,
.rr-workspace .actions > button,
.rr-workspace .actions button,
.rr-page-actions > a,
.rr-page-actions > button,
.rr-page-actions button {
  min-height: 36px;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.rr-page-actions > a,
.rr-page-actions > button,
.rr-page-actions > form {
  flex: 0 1 180px;
}
.rr-page-actions form button {
  width: 100%;
}
.rr-control-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, .95fr);
  gap: 14px;
  align-items: stretch;
}
.rr-control-card {
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
  min-height: 176px;
}
.rr-setup-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 12px;
  align-items: end;
}
.rr-setup-row .dfm-input-group,
.rr-search-actions .sh-input {
  min-width: 0;
}
.rr-setup-row button {
  min-width: 128px;
}
.rr-rule-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  margin-top: 13px;
}
.rr-rule-list span,
.rr-history-list div {
  border: 1px solid hsl(var(--border));
  border-radius: 12px;
  background: hsl(var(--secondary) / .55);
  color: hsl(var(--muted-foreground));
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.35;
}
.rr-rule-list span {
  display: flex;
  min-height: 72px;
  flex-direction: column;
  justify-content: space-between;
}
.rr-rule-list b {
  display: block;
  margin-top: 4px;
  color: hsl(var(--foreground));
  font-size: 15px;
}
.rr-history-highlight {
  border: 1px solid hsl(84 25% 58% / .24);
  border-left: 4px solid hsl(84 25% 58%);
  border-radius: 14px;
  padding: 12px 14px;
  background:
    linear-gradient(135deg, hsl(84 25% 58% / .10), transparent 58%),
    hsl(var(--secondary) / .35);
}
.rr-history-highlight span,
.rr-history-highlight small {
  display: block;
  color: hsl(var(--muted-foreground));
  font-size: 14px;
}
.rr-history-highlight strong {
  display: block;
  margin: 4px 0;
  color: hsl(var(--foreground));
  font-size: 26px;
}
.rr-history-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}
.rr-history-list div {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) minmax(110px, auto) minmax(74px, auto);
  gap: 10px;
  align-items: center;
}
.rr-history-list b {
  color: hsl(var(--foreground));
}
.rr-history-list a {
  color: hsl(var(--primary));
  font-weight: 800;
  text-decoration: none;
  justify-self: end;
}
.rr-history-actions {
  margin-top: 12px;
}
.rr-search-card {
  margin-bottom: 0;
}
.rr-search-card .panel-title-row,
.rr-save-export-panel .panel-title-row {
  margin-bottom: 10px;
}
.rr-search-actions {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 10px;
  align-items: stretch;
  margin-top: 0;
}
.rr-branch-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.rr-branch-card {
  min-height: 0;
  height: auto;
  padding: 20px;
}
.rr-branch-card .working-top {
  margin-bottom: 12px;
}
.rr-branch-card h3 {
  margin: 0 0 8px;
  font-size: 22px;
  line-height: 1.2;
}
.rr-branch-card p {
  flex: 0 0 auto;
  min-height: 0;
  margin: 0 0 16px;
  line-height: 1.35;
}
.rr-branch-card .working-stats {
  margin-top: 0;
  margin-bottom: 12px;
}
.rr-branch-card .working-stats span {
  padding: 8px 10px;
  line-height: 1.2;
}
.rr-branch-card .working-stats b {
  margin-top: 3px;
  font-size: 14px;
}
.rr-branch-card .dfm-card-actions {
  grid-template-columns: 1fr;
  margin-top: 0;
  padding-top: 0;
}
.rr-branch-card .dfm-card-actions a {
  min-height: 40px;
  padding-top: 12px;
  padding-bottom: 12px;
}
.rr-branch-card.factory-card {
  border-top-color: hsl(160 84% 39%);
}
.rr-branch-card.nonfactory-card {
  border-top-color: hsl(38 92% 50%);
}
.rr-save-export-panel {
  border-left: 4px solid hsl(84 25% 58%);
  margin-bottom: 0;
}
.rr-final-actions {
  align-items: center;
  margin-bottom: 12px;
  gap: 10px;
}
.rr-final-actions form {
  display: inline-flex;
  margin: 0;
}
.rr-final-actions > *,
.rr-final-actions button {
  min-width: 148px;
}
.rr-export-tabs {
  margin-top: 8px;
  align-items: center;
}
.rr-export-tabs span {
  min-height: 28px;
  background: hsl(var(--secondary) / .68);
}
.rr-reason-grid {
  margin-top: 0;
  align-items: stretch;
}
.rr-detail-workspace > .actions,
.rr-detail-workspace > .module-toolbar {
  margin-top: 0;
}
.rr-detail-workspace .accent-panel {
  display: grid;
  gap: 12px;
  align-items: start;
}
.rr-detail-workspace .accent-panel .pill-row {
  margin: 0;
}
.rr-detail-workspace .accent-panel > a {
  justify-self: start;
  min-width: 148px;
}
.rr-company-filter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
}
.rr-company-form .panel-title-row {
  align-items: center;
}
/* Keep checkbox, label text, and company names on the same row baseline in the RR classification table. */
.rr-company-table th,
.rr-company-table td {
  vertical-align: middle;
}
.factory-select {
  min-height: 28px;
}
.factory-select input {
  flex: 0 0 auto;
}
.rr-company-form .actions {
  justify-content: flex-end;
  margin-top: 14px;
}
.rr-company-form .actions > * {
  min-width: 180px;
}
.rr-invoice-grid {
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(360px, 1.1fr);
  gap: 14px;
  align-items: stretch;
}
.rr-invoice-grid .data-panel {
  margin-bottom: 0;
}
.rr-invoice-workspace .readiness-grid {
  height: calc(100% - 42px);
}
.rr-history-workspace .data-panel {
  margin-bottom: 0;
}
.rr-sop-form {
  display: grid;
  gap: 14px;
}
.rr-sop-form > .panel {
  margin-bottom: 0;
}
.rr-sop-form .two-fields {
  gap: 12px;
  margin-bottom: 12px;
}
.rr-sop-form .wide-admin-table + .wide-admin-table {
  margin-top: 12px;
}
.rr-footer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.rr-footer-actions > * {
  min-width: 150px;
}
.rr-google-workspace .data-panel {
  margin-bottom: 0;
}
.rr-google-workspace > .data-panel:nth-of-type(1),
.rr-google-workspace > .data-panel:nth-of-type(3),
.rr-google-workspace > .data-panel:nth-of-type(4) {
  display: grid;
  gap: 12px;
  align-content: start;
}
.rr-google-workspace .form {
  display: grid;
  gap: 12px;
}
.rr-google-workspace .form button,
.rr-google-workspace .inline button {
  justify-self: start;
  min-width: 150px;
}

@media (max-width: 1100px) {
  .rr-control-grid,
.rr-rule-list,
.rr-branch-grid {
    grid-template-columns: 1fr;
  }
  .rr-setup-row,
.rr-search-actions,
.rr-history-list div,
.rr-company-filter-grid,
.rr-invoice-grid {
    grid-template-columns: 1fr;
  }
  .rr-history-list a {
    justify-self: stretch;
  }
  .rr-setup-row button,
.rr-search-actions button,
.rr-final-actions > *,
.rr-final-actions button,
.rr-detail-workspace .accent-panel > a,
.rr-page-actions > *,
.rr-page-actions button,
.rr-company-form .actions > *,
.rr-footer-actions > *,
.rr-google-workspace .form button,
.rr-google-workspace .inline button {
    width: 100%;
  }
  .rr-company-form .actions,
.rr-footer-actions {
    justify-content: stretch;
  }
}

/* Light theme refinement: finance-led hierarchy and restrained interaction across every workspace. */
html[data-theme="light"] {
  --shadow: 0 1px 1px hsl(82 10% 12% / .055), 0 18px 42px hsl(82 10% 12% / .105);
  --soft: 0 1px 1px hsl(82 10% 12% / .04), 0 8px 19px hsl(82 10% 12% / .072);
}
html[data-theme="light"] body {
  background: var(--finance-canvas) !important;
}
/* The ledger edge is the light theme's signature: it marks the active working without decorative clutter. */
html[data-theme="light"] .intro-experience:before {
  display: none;
}
html[data-theme="light"] .data-panel,
html[data-theme="light"] .panel,
html[data-theme="light"] .login-card,
html[data-theme="light"] .empty-state,
html[data-theme="light"] .working-card,
html[data-theme="light"] .info-card,
html[data-theme="light"] .tip-grid article,
html[data-theme="light"] .lease-workspace .metric,
html[data-theme="light"] .lease-workspace .review-card,
html[data-theme="light"] .lease-workspace .panel,
html[data-theme="light"] .lease-workspace .wizard-nav,
html[data-theme="light"] .lease-workspace .side-card {
  background: var(--finance-surface);
  border-color: hsl(var(--border) / .9);
  border-radius: 8px;
  box-shadow: var(--soft);
}
html[data-theme="light"] :is(.data-panel, .panel, .working-card, .info-card) {
  box-shadow: inset 0 1px 0 hsl(48 26% 100% / .86), var(--soft);
}
html[data-theme="light"] .accent-panel {
  background: hsl(var(--card));
}
html[data-theme="light"] .working-card {
  border-top-width: 2px;
}
html[data-theme="light"] :is(.working-card h3, .data-panel h2, .panel h2, .dashboard-section-title h2) {
  letter-spacing: 0;
  font-weight: 600;
}
html[data-theme="light"] .data-panel h2.lease-dashboard-heading {
  font-weight: 850;
}
html[data-theme="light"] :is(.working-stats b) {
  font-variant-numeric: tabular-nums lining-nums;
}
html[data-theme="light"] .working-card {
  border-top-color: hsl(var(--primary) / .50);
}

html[data-theme="light"] .theme-toggle {
  transition: background .16s ease, border-color .16s ease, box-shadow .16s ease, color .16s ease, transform .16s ease;
}
html[data-theme="light"] .column-options,
html[data-theme="light"] .modal-panel,
html[data-theme="light"] .lease-workspace .ws-modal {
  border-color: hsl(var(--border));
  border-radius: 8px;
  box-shadow: var(--shadow);
}
html[data-theme="light"] .theme-toggle {
  background: var(--finance-control);
  border-color: hsl(var(--border));
  box-shadow: inset 0 1px 0 hsl(48 26% 100% / .9), 0 1px 2px hsl(var(--foreground) / .04);
}
html[data-theme="light"] .theme-toggle:hover {
  transform: translateY(-1px);
  border-color: hsl(var(--foreground) / .22);
  box-shadow: 0 4px 12px hsl(var(--foreground) / .08);
}

html[data-theme="light"] .primary,
html[data-theme="light"] .secondary,
html[data-theme="light"] .danger {
  border: 0;
  background: transparent;
  box-shadow: none;
  color: hsl(var(--foreground));
  transition: background .14s ease, color .14s ease;
}
html[data-theme="light"] :is(.primary) {
  color: hsl(var(--primary));
}
html[data-theme="light"] :is(.danger) {
  color: hsl(var(--destructive));
}
html[data-theme="light"] .primary:hover,
html[data-theme="light"] .secondary:hover,
html[data-theme="light"] .danger:hover {
  background: hsl(var(--foreground) / .055);
  color: hsl(var(--primary));
  box-shadow: none;
  transform: none;
}
html[data-theme="light"] :is(.danger):hover {
  background: hsl(var(--destructive) / .085);
  color: hsl(var(--destructive));
}
html[data-theme="light"] .primary:active,
html[data-theme="light"] .secondary:active,
html[data-theme="light"] .danger:active,
html[data-theme="light"] .theme-toggle:active {
  transform: translateY(0);
  box-shadow: none;
}
html[data-theme="light"] :is(.primary, .secondary):active {
  background: hsl(var(--primary) / .14);
}
html[data-theme="light"] :is(.primary, .secondary, .danger):disabled {
  border: 0;
  background: transparent;
  box-shadow: none;
  color: hsl(var(--muted-foreground));
}
/* Card commands keep their grid position, but only the command text owns the hover target. */
html[data-theme="light"] :is(a, button, summary, input, select, textarea):focus-visible {
  outline: 3px solid hsl(var(--ring) / .20);
  outline-offset: 2px;
}

html[data-theme="light"] input,
html[data-theme="light"] select,
html[data-theme="light"] textarea,
html[data-theme="light"] .compact-select,
html[data-theme="light"] .column-search-input,
html[data-theme="light"] .sh-input,
html[data-theme="light"] .sh-select {
  background: hsl(48 26% 98%);
  border-color: hsl(var(--input));
  border-radius: 6px;
  box-shadow: inset 0 1px 1px hsl(var(--foreground) / .035), 0 1px 0 hsl(48 26% 100% / .75);
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
html[data-theme="light"] input:hover,
html[data-theme="light"] select:hover,
html[data-theme="light"] textarea:hover,
html[data-theme="light"] .compact-select:hover,
html[data-theme="light"] .column-search-input:hover,
html[data-theme="light"] .sh-input:hover,
html[data-theme="light"] .sh-select:hover {
  border-color: hsl(var(--foreground) / .20);
}
html[data-theme="light"] input:focus,
html[data-theme="light"] select:focus,
html[data-theme="light"] textarea:focus,
html[data-theme="light"] .column-search-input:focus,
html[data-theme="light"] .sh-input:focus,
html[data-theme="light"] .sh-select:focus {
  background: hsl(48 26% 99%);
  border-color: hsl(var(--primary) / .56);
  box-shadow: 0 0 0 3px hsl(var(--ring) / .10), 0 5px 14px hsl(var(--foreground) / .06);
}

html[data-theme="light"] .table-wrap,
html[data-theme="light"] .assignment-table-wrap,
html[data-theme="light"] .lease-workspace .scrollable-table {
  background: hsl(48 26% 98%);
  border-color: hsl(var(--border));
  border-radius: 6px;
  box-shadow: 0 1px 2px hsl(var(--foreground) / .035), 0 8px 18px hsl(var(--foreground) / .045);
}
html[data-theme="light"] :is(.mini-table, .lease-workspace table) {
  background: hsl(48 26% 98%);
}
html[data-theme="light"] :is(.mini-table th, .lease-workspace th) {
  background: hsl(48 26% 88%);
  color: hsl(var(--foreground));
  border-bottom-color: hsl(var(--border));
}
html[data-theme="light"] .mini-table td {
  border-bottom-color: hsl(50 14% 84%);
}
html[data-theme="light"] .mini-table tbody tr:nth-child(even) {
  background: hsl(48 26% 95%);
}
html[data-theme="light"] .mini-table tbody tr,
html[data-theme="light"] .lease-workspace tbody tr {
  transition: background .12s ease, box-shadow .12s ease;
}
html[data-theme="light"] .mini-table tbody tr:hover,
html[data-theme="light"] .lease-workspace tbody tr:hover {
  background: hsl(84 25% 46% / .055);
  box-shadow: inset 2px 0 0 hsl(var(--primary) / .62);
}
html[data-theme="light"] .mini-table th,
html[data-theme="light"] .lease-workspace th {
  box-shadow: inset 0 -1px 0 hsl(var(--foreground) / .07), inset 0 1px 0 hsl(48 26% 100% / .72);
}

html[data-theme="light"] .dropzone {
  background: hsl(48 26% 98%);
  border-color: hsl(var(--input));
  box-shadow: inset 0 0 0 1px hsl(48 26% 100% / .7);
  transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}
html[data-theme="light"] .dropzone:hover,
html[data-theme="light"] .dropzone:focus-within {
  border-color: hsl(var(--foreground) / .24);
  box-shadow: inset 0 0 0 1px hsl(var(--foreground) / .04), 0 7px 18px hsl(var(--foreground) / .06);
}

@media (hover: hover) and (pointer: fine) {
  html[data-theme="light"] .working-card,
html[data-theme="light"] .info-card,
html[data-theme="light"] .tip-grid article,
html[data-theme="light"] .rr-history-list div,
html[data-theme="light"] .lease-workspace .metric,
html[data-theme="light"] .lease-workspace .review-card {
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
  }
  html[data-theme="light"] .working-card:hover,
html[data-theme="light"] .info-card:hover,
html[data-theme="light"] .tip-grid article:hover,
html[data-theme="light"] .rr-history-list div:hover,
html[data-theme="light"] .lease-workspace .metric:hover,
html[data-theme="light"] .lease-workspace .review-card:hover {
    border-color: hsl(var(--primary) / .24);
    box-shadow: inset 0 1px 0 hsl(48 26% 100% / .92), 0 2px 4px hsl(var(--foreground) / .04), 0 11px 24px hsl(var(--foreground) / .075);
    transform: translateY(-1px);
  }
}

@media (prefers-reduced-motion: reduce) {
  html[data-theme="light"] *,
html[data-theme="light"] *:before,
html[data-theme="light"] *:after {
    scroll-behavior: auto;
    transition-duration: .01ms;
    animation-duration: .01ms;
    animation-iteration-count: 1;
  }
}

/* Light theme color pass: measured module colors make the workspace easier to scan without changing layout or logic. */
html[data-theme="light"] {
  --clarity-blue: 84 25% 42%;
  --clarity-teal: 84 25% 34%;
  --clarity-forest: 145 32% 34%;
  --clarity-gold: 39 72% 44%;
  --clarity-plum: 82 14% 42%;
  --clarity-rose: 351 45% 46%;
  --clarity-slate: 82 12.3% 32%;
}
html[data-theme="light"] .accent-blue { border-top-color: hsl(var(--clarity-blue)); }
html[data-theme="light"] .accent-teal { border-top-color: hsl(var(--clarity-teal)); }
html[data-theme="light"] .accent-purple { border-top-color: hsl(var(--clarity-plum)); }
html[data-theme="light"] .accent-orange { border-top-color: hsl(var(--clarity-gold)); }
html[data-theme="light"] .accent-red { border-top-color: hsl(var(--clarity-rose)); }

html[data-theme="light"] .data-panel,
html[data-theme="light"] .panel {
  background:
    linear-gradient(180deg, hsl(48 26% 99%), hsl(48 26% 98%)) padding-box,
    linear-gradient(135deg, hsl(var(--clarity-teal) / .26), hsl(var(--border)), hsl(var(--clarity-gold) / .20)) border-box;
  border-color: transparent;
}
html[data-theme="light"] .panel-title-row {
  border-bottom: 1px solid hsl(var(--clarity-teal) / .14);
  padding-bottom: 8px;
}
html[data-theme="light"] .eyebrow,
html[data-theme="light"] .dashboard-section-title p,
html[data-theme="light"] .panel-title-row small {
  color: hsl(var(--primary));
}
html[data-theme="light"] .primary:hover,
html[data-theme="light"] .secondary:hover {
  background: linear-gradient(90deg, hsl(var(--clarity-teal) / .10), hsl(var(--clarity-gold) / .10));
  color: hsl(var(--primary));
}
html[data-theme="light"] :is(.table-link, .rr-history-list a, .legal-links a) {
  color: hsl(var(--clarity-plum));
}
html[data-theme="light"] :is(.mini-table th, .lease-workspace th) {
  background: linear-gradient(90deg, hsl(var(--clarity-teal) / .12), hsl(48 26% 88%), hsl(var(--clarity-gold) / .11));
}
html[data-theme="light"] .mini-table tbody tr:hover,
html[data-theme="light"] .lease-workspace tbody tr:hover {
  background: hsl(var(--clarity-teal) / .07);
  box-shadow: inset 2px 0 0 hsl(var(--clarity-teal) / .68);
}

/* Light theme readability pass: lift tiny captions and table labels without changing dark-theme density. */
html[data-theme="light"] :is(
  small,
  .eyebrow,
  .dfm-footer,
  .dashboard-section-title p,
  .panel-title-row small,
  .rr-history-highlight small,
  .sales-donut-card small,
  .sales-rank-row small
) {
  font-size: 14px;
  line-height: 1.45;
}
html[data-theme="light"] :is(
  .tab,
  .pill-row span,
  .heading-chip,
  .micro-meta b,
  .working-stats span,
  .progress-copy,
  .column-hint,
  .inline-help,
  .factory-select span
) {
  font-size: 13.5px;
  line-height: 1.35;
}
html[data-theme="light"] :is(
  .micro-meta span,
  .working-stats b,
  .tip-grid span,
  .info-card span,
  .clean-list,
  .micro-list,
  .lease-workspace .lease-card p
) {
  font-size: 14px;
  line-height: 1.45;
}
html[data-theme="light"] :is(
  .small,
  .mini-table,
  .dense-table,
  .admin-table
) {
  font-size: 13.5px;
}
html[data-theme="light"] :is(
  .mini-table th,
  .dense-table th,
  .admin-table small,
  .tiny-input
) {
  font-size: 13px;
}

/* Light theme polish pass: quiet depth, sharper hierarchy, and warmer finance-paper surfaces. */
html[data-theme="light"] {
  --finance-canvas: #f2f0e8;
  --finance-surface: #fffdf8;
  --finance-control: #ebe8dd;
  --finance-line: #cfcac4;
  --shadow: 0 1px 1px hsl(82 13.2% 16% / .045), 0 16px 34px hsl(82 13.2% 16% / .085);
  --soft: 0 1px 1px hsl(82 13.2% 16% / .035), 0 9px 22px hsl(82 13.2% 16% / .06);
}
html[data-theme="light"] :is(.data-panel, .panel, .working-card, .info-card) {
  border-color: hsl(50 14% 78% / .82);
  box-shadow: inset 0 1px 0 hsl(48 26% 100% / .92), 0 1px 2px hsl(82 13.2% 16% / .035), 0 10px 24px hsl(82 13.2% 16% / .06);
}
html[data-theme="light"] .working-card {
  background:
    linear-gradient(180deg, hsl(48 26% 99%), hsl(48 26% 97%)) padding-box,
    linear-gradient(135deg, hsl(var(--primary) / .18), hsl(50 14% 78% / .8)) border-box;
}
html[data-theme="light"] .working-card .micro-meta,
html[data-theme="light"] .working-card .working-stats span,
html[data-theme="light"] .calculation-progress {
  background: hsl(48 26% 93% / .72);
  border-color: hsl(50 14% 78% / .74);
}
html[data-theme="light"] .working-card h3,
html[data-theme="light"] .data-panel h2,
html[data-theme="light"] .panel h2 {
  color: hsl(82 10% 12%);
}
html[data-theme="light"] :is(.eyebrow, .dashboard-section-title p, .panel-title-row small, .micro-meta b, .working-stats span) {
  color: hsl(var(--primary));
}
html[data-theme="light"] :is(.primary, .secondary, .danger) {
  border-radius: 8px;
}
html[data-theme="light"] :is(.primary, .secondary):hover {
  background: hsl(var(--primary) / .075);
  box-shadow: inset 0 -1px 0 hsl(var(--primary) / .26);
}
html[data-theme="light"] .danger:hover {
  background: hsl(var(--destructive) / .08);
  box-shadow: inset 0 -1px 0 hsl(var(--destructive) / .28);
}
html[data-theme="light"] input,
html[data-theme="light"] select,
html[data-theme="light"] textarea,
html[data-theme="light"] .sh-input,
html[data-theme="light"] .sh-select {
  background: hsl(48 26% 99%);
  border-color: hsl(50 14% 74%);
}
html[data-theme="light"] .table-wrap,
html[data-theme="light"] .assignment-table-wrap,
html[data-theme="light"] .lease-workspace .scrollable-table {
  border-color: hsl(50 14% 76%);
  box-shadow: inset 0 1px 0 hsl(48 26% 100% / .86), 0 10px 22px hsl(82 13.2% 16% / .055);
}
html[data-theme="light"] :is(.mini-table th, .lease-workspace th) {
  background: linear-gradient(90deg, hsl(48 26% 88%), hsl(48 26% 91%));
  color: hsl(82 10% 15%);
}
html[data-theme="light"] .mini-table tbody tr:nth-child(even) {
  background: hsl(48 26% 96%);
}
html[data-theme="light"] .mini-table tbody tr:hover,
html[data-theme="light"] .lease-workspace tbody tr:hover {
  background: hsl(var(--primary) / .055);
  box-shadow: inset 2px 0 0 hsl(var(--primary) / .62);
}
@media (hover: hover) and (pointer: fine) {
  html[data-theme="light"] :is(.working-card, .data-panel, .panel, .info-card):hover {
    border-color: hsl(var(--primary) / .26);
    box-shadow: inset 0 1px 0 hsl(48 26% 100% / .94), 0 2px 4px hsl(82 13.2% 16% / .035), 0 14px 30px hsl(82 13.2% 16% / .08);
  }
}

/* Principal dashboard summary is a single metric bar, separate from module KPI cards. */

/* Individual working dashboards use the same segregated metric structure as
   the principal dashboard while preserving each dashboard's metric count. */

/* Dashboard polish: subtle depth and tighter hierarchy without changing workflows. */
.working-card,
.data-panel,
.panel,
.empty-state {
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease, background-color .18s ease;
}

.dashboard-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 18px 0 10px;
}

.dashboard-section-title h2 {
  letter-spacing: -.01em;
}

.working-card {
  gap: 2px;
  border-radius: 18px;
}

.working-card h3 {
  letter-spacing: -.005em;
}

.working-card .micro-meta,
.working-card .working-stats span,
.calculation-progress {
  border-radius: 14px;
}

@media (hover: hover) and (pointer: fine) {
  .working-card:hover,
.data-panel:hover,
.panel:hover {
    transform: translateY(-1px);
  }
}

html[data-theme="light"] .working-card {
  background:
    linear-gradient(180deg, hsl(48 26% 99%) 0%, hsl(48 26% 97%) 100%),
    hsl(var(--card));
  box-shadow: inset 0 1px 0 hsl(48 26% 100% / .95), 0 16px 34px hsl(82 13.2% 18% / .07);
}

html[data-theme="light"] .working-card .micro-meta,
html[data-theme="light"] .working-card .working-stats span,
html[data-theme="light"] .calculation-progress {
  background: hsl(48 26% 95% / .72);
  border-color: hsl(50 14% 78%);
}

html[data-theme="dark"] .working-card {
  background:
    linear-gradient(180deg, hsl(82 14% 10% / .96), hsl(82 14% 8% / .96)),
    hsl(var(--card));
  box-shadow: inset 0 1px 0 hsl(48 26% 100% / .06), 0 18px 42px hsl(82 6% 0% / .22);
}

html[data-theme="dark"] .working-card .micro-meta,
html[data-theme="dark"] .working-card .working-stats span,
html[data-theme="dark"] .calculation-progress {
  background: hsl(82 14% 16% / .64);
  border-color: hsl(var(--border) / .82);
}

/* Premium date fields: the app-wide fast picker keeps native date values, while
   this icon makes the text field read as an intentional calendar control. */
.smart-date-input,
html[data-theme="light"] .smart-date-input,
html[data-theme="dark"] .smart-date-input,
.lease-picker-field .smart-date-input,
.lease-input-table .smart-date-input,
.sh-input.smart-date-input {
  padding-right: 38px;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23857465' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 2v4'/%3E%3Cpath d='M16 2v4'/%3E%3Crect x='3' y='4' width='18' height='18' rx='3'/%3E%3Cpath d='M3 10h18'/%3E%3Cpath d='M8 14h.01'/%3E%3Cpath d='M12 14h.01'/%3E%3Cpath d='M16 14h.01'/%3E%3Cpath d='M8 18h.01'/%3E%3Cpath d='M12 18h.01'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px 16px;
}

html[data-theme="dark"] .smart-date-input,
html[data-theme="dark"] .lease-picker-field .smart-date-input,
html[data-theme="dark"] .lease-input-table .smart-date-input,
html[data-theme="dark"] .sh-input.smart-date-input {
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23aab6d3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 2v4'/%3E%3Cpath d='M16 2v4'/%3E%3Crect x='3' y='4' width='18' height='18' rx='3'/%3E%3Cpath d='M3 10h18'/%3E%3Cpath d='M8 14h.01'/%3E%3Cpath d='M12 14h.01'/%3E%3Cpath d='M16 14h.01'/%3E%3Cpath d='M8 18h.01'/%3E%3Cpath d='M12 18h.01'/%3E%3C/svg%3E");
}

.smart-date-input:hover {
  background-position: right 10px center;
}

/* Automatic PI Booking */
.pi-control-grid,
.pi-review-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr);
  gap: 14px;
  align-items: start;
}

.pi-upload-panel .actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.pi-document-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(420px, .9fr);
  gap: 18px;
  align-items: stretch;
  border-top: 4px solid hsl(160 84% 39%);
}

.pi-document-title h2 {
  margin: 4px 0 6px;
  font-size: 22px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.pi-document-title p,
.pi-document-title small {
  display: block;
  margin: 0;
  color: hsl(var(--muted-foreground));
  overflow-wrap: anywhere;
}

.pi-document-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  overflow: hidden;
  background: hsl(var(--muted) / .28);
}

.pi-document-stats article {
  display: grid;
  gap: 6px;
  min-height: 82px;
  padding: 12px;
  border-left: 1px solid hsl(var(--border));
}

.pi-document-stats article:first-child {
  border-left: 0;
}

.pi-document-stats span,
.pi-field-grid span {
  color: hsl(var(--muted-foreground));
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.pi-document-stats strong {
  color: hsl(var(--foreground));
  font-size: 18px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.pi-invoice-table-wrap {
  max-height: none;
  border-radius: 8px;
}

.pi-invoice-table {
  min-width: 1120px;
  table-layout: fixed;
  font-size: 13px;
}

.pi-invoice-table th,
.pi-invoice-table td {
  vertical-align: top;
}

.pi-invoice-table th:nth-child(1),
.pi-invoice-table td:nth-child(1) { width: 42px; text-align: center; }
.pi-invoice-table th:nth-child(2),
.pi-invoice-table td:nth-child(2) { width: 142px; }
.pi-invoice-table th:nth-child(3),
.pi-invoice-table td:nth-child(3) { width: 90px; }
.pi-invoice-table th:nth-child(4),
.pi-invoice-table td:nth-child(4) { width: 430px; }
.pi-invoice-table th:nth-child(5),
.pi-invoice-table td:nth-child(5),
.pi-invoice-table th:nth-child(6),
.pi-invoice-table td:nth-child(6),
.pi-invoice-table th:nth-child(7),
.pi-invoice-table td:nth-child(7),
.pi-invoice-table th:nth-child(8),
.pi-invoice-table td:nth-child(8) { width: 100px; }
.pi-invoice-table th:nth-child(9),
.pi-invoice-table td:nth-child(9) { width: 142px; }

.pi-invoice-table .numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum", "lnum";
}

.pi-service-cell {
  white-space: normal !important;
  overflow-wrap: anywhere;
  line-height: 1.42;
  color: hsl(var(--foreground));
}

.pi-field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.pi-field-grid article {
  min-height: 86px;
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  padding: 11px;
  background: hsl(var(--muted) / .22);
}

.pi-field-grid strong {
  display: block;
  margin: 6px 0;
  color: hsl(var(--foreground));
  font-size: 15px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.pi-field-grid small {
  color: hsl(var(--muted-foreground));
}

.pi-evidence-panel {
  position: sticky;
  top: 86px;
}

.pi-document-frame {
  min-height: 520px;
  max-height: 68vh;
}

.pi-document-image {
  max-height: 620px;
}

.pi-debug-panel summary {
  cursor: pointer;
  color: hsl(var(--foreground));
  font-size: 16px;
  font-weight: 850;
}

.pi-debug-block {
  margin-top: 14px;
}

.pi-debug-block h3 {
  margin: 0 0 8px;
  color: hsl(var(--foreground));
  font-size: 15px;
}

.pi-erp-panel {
  border-top: 4px solid hsl(38 92% 50%);
}

.pi-erp-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.pi-erp-form label {
  display: grid;
  gap: 6px;
  color: hsl(var(--muted-foreground));
  font-size: 13px;
  font-weight: 800;
}

.pi-erp-form .sh-input {
  min-width: 0;
}

.pi-duplicate-check {
  align-self: center;
  min-height: 40px;
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  padding: 9px 10px;
  background: hsl(var(--muted) / .22);
  color: hsl(var(--foreground)) !important;
  font-size: 13px !important;
}

.pi-erp-actions {
  display: grid;
  gap: 6px;
}

.pi-erp-actions small,
.pi-posting-runs h3 {
  color: hsl(var(--muted-foreground));
}

.pi-posting-runs {
  margin-top: 16px;
}

.pi-posting-runs h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

html[data-theme="light"] .pi-document-stats,
html[data-theme="light"] .pi-field-grid article {
  background: hsl(48 26% 96% / .72);
}

@media (max-width: 1120px) {
  .pi-control-grid,
.pi-review-layout,
.pi-document-summary {
    grid-template-columns: 1fr;
  }

  .pi-evidence-panel {
    position: static;
  }
}

@media (max-width: 760px) {
  .pi-upload-panel .actions,
.pi-document-stats,
.pi-field-grid,
.pi-erp-form {
    grid-template-columns: 1fr;
  }

  .pi-document-stats article,
.pi-document-stats article:first-child {
    border-left: 0;
    border-top: 1px solid hsl(var(--border));
  }

  .pi-document-stats article:first-child {
    border-top: 0;
  }

  .pi-document-frame {
    min-height: 420px;
  }
}

/* UI quality hardening: preserve current dark/light themes while preventing enterprise-data layout failures. */
:is(.data-panel, .panel, .working-card, .info-card, .module-toolbar, .actions, .dfm-card-actions, .form, .upload-form, .compact-form, .table-wrap, .modal-panel, .lease-workspace) {
  min-width: 0;
}

:is(.data-panel, .panel, .working-card, .info-card, .modal-panel) > * {
  min-width: 0;
}

:is(h1, h2, h3, h4, p, small, label, .micro-meta, .panel-title-row, .dashboard-section-title, .progress-copy, .empty-line, .qa-answer, .pi-debug-block) {
  overflow-wrap: break-word;
  word-break: normal;
}

img, svg, canvas, video {
  max-width: 100%;
}

.primary,
.secondary,
.danger,
.lease-export-link {
  gap: 7px;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: auto;
}

.small,
.mini-table .small,
.table-wrap .primary,
.table-wrap .secondary,
.table-wrap .danger {
  white-space: nowrap;
}

button:disabled,
.primary:disabled,
.secondary:disabled,
.danger:disabled {
  cursor: not-allowed;
  transform: none;
}

:is(.primary, .secondary, .danger, .theme-toggle, summary):focus-visible,
:is(input, select, textarea, .compact-select, .column-search-input, .sh-input, .sh-select):focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}

:is(input, select, textarea, .compact-select, .column-search-input, .sh-input, .sh-select) {
  width: 100%;
  max-width: 100%;
  text-overflow: ellipsis;
}

:is(select, .compact-select, .sh-select) {
  padding-right: 32px;
}

:is(input[type="checkbox"], input[type="radio"]) {
  width: auto;
  min-width: 16px;
  flex: 0 0 auto;
}

:is(.two-fields, .three-fields, .form-grid, .prepaid-period-form, .prepaid-entry-grid, .prepaid-permission-grid, .pi-erp-form, .pi-field-grid, .pi-document-summary, .erp-download-board, .admin-grid, .admin-detail-grid, .two-panel-grid, .mapping-grid, .readiness-grid, .working-grid, .info-grid) > * {
  min-width: 0;
}

.panel-title-row {
  align-items: flex-start;
}

.panel-title-row > * {
  min-width: 0;
}

.table-wrap {
  max-width: 100%;
  overscroll-behavior: contain;
}

.mini-table {
  min-width: max-content;
}

.mini-table th,
.mini-table td {
  vertical-align: top;
  line-height: 1.35;
}

.source-history-table .source-file-name,
.assignment-table td:first-child,
.mapping-table td:first-child,
.upload-files-table .upload-file-name-cell,
.mini-table td.description,
.mini-table td.remarks {
  min-width: 220px;
  max-width: 440px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.source-history-table td:first-child {
  max-width: 210px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.source-advanced-filters {
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  padding: 10px 12px;
}

.source-advanced-filters summary,
.source-row-details summary {
  color: hsl(var(--primary));
  cursor: pointer;
  font-weight: 800;
}

.source-row-details {
  margin-top: 4px;
}

.source-row-details small {
  color: hsl(var(--muted-foreground));
}

.assignment-search-form {
  margin: 0 0 10px;
}

.assignment-table select {
  min-width: 190px;
}

.compact-actions,
.module-toolbar,
.inline-action-row,
.prepaid-register-actions,
.pi-erp-actions,
.erp-company-actions {
  row-gap: 8px;
}

.modal-panel {
  width: min(960px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow: auto;
}

.sonner-toast,
.dfm-alert {
  overflow-wrap: break-word;
  word-break: normal;
}

@media (max-width: 1050px) {
  .data-panel .form-grid,
.data-panel .form-grid.four,
.erp-download-board,
.pi-document-summary,
.pi-erp-form {
    grid-template-columns: 1fr;
  }

  .ca-export-grid {
    grid-template-columns: 1fr;
  }

  .ca-export-arrow {
    min-height: 34px;
  }

  .erp-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .erp-step-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  body {
    font-size: 14px;
  }

  .app-container {
    width: 100%;
    max-width: 100%;
  }

  .panel-title-row {
    display: grid;
    gap: 6px;
  }

  .erp-result-head {
    display: grid;
  }

  .erp-result-head-actions {
    justify-content: flex-start;
  }

  .erp-summary-grid,
.erp-step-grid {
    grid-template-columns: 1fr;
  }

  .erp-control-switch {
    grid-template-columns: 1fr;
  }

  .erp-result-toolbar {
    justify-content: stretch;
  }

  .erp-result-toolbar > *,
.erp-result-toolbar button {
    width: 100%;
  }

  .small,
.mini-table .small {
    white-space: normal;
  }

  .primary,
.secondary,
.danger {
    min-height: 36px;
  }

  .table-wrap {
    border-radius: 8px;
  }

  .source-history-table .source-file-name,
.assignment-table td:first-child,
.mapping-table td:first-child,
.upload-files-table .upload-file-name-cell {
    min-width: 180px;
    max-width: 300px;
  }

  .ca-choice-list {
    grid-template-columns: 1fr;
    max-height: 260px;
  }

  .ca-export-footer {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 380px) {
  .app-container {
    padding: 10px;
  }

  .data-panel,
.panel {
    padding-left: 14px;
    padding-right: 14px;
  }
}

/* Final enterprise UI pass: controlled density, readable finance tables, and cleaner ERP workflows. */
.app-container {
  width: min(100%, 1640px);
}

.panel,
.data-panel,
.empty-state {
  border-radius: 10px;
}

.module-toolbar,
.erp-primary-actions,
.erp-result-toolbar,
.compact-actions,
.dfm-card-actions,
.actions {
  align-items: center;
}

.module-toolbar > :is(a, button, form),
.erp-primary-actions > :is(a, button, form),
.erp-result-toolbar > :is(a, button, form) {
  min-width: 0;
}

.panel-title-row h2,
.dashboard-section-title h2,
.erp-final-results-head h2 {
  line-height: 1.16;
}

.readiness-grid span,
.working-stats span,
.micro-meta,
.calculation-progress {
  border-radius: 8px;
}

.table-wrap {
  border-radius: 8px;
}

.mini-table {
  table-layout: auto;
  font-variant-numeric: tabular-nums;
}

.mini-table th,
.mini-table td {
  padding: 8px 10px;
  vertical-align: middle;
}

.mini-table th {
  white-space: nowrap;
}

.mini-table td {
  max-width: 520px;
}

.mini-table :is(th.num, td.num),
.mini-table :is(th.amount, td.amount),
.amount,
.numeric,
.number {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.mini-table td:not(.num):not(.amount):not(.numeric):not(.number) {
  white-space: normal;
  overflow-wrap: anywhere;
}

.mini-table td.num,
.mini-table td.amount,
.mini-table td.numeric,
.mini-table td.number {
  white-space: nowrap;
}

.dense-table-wrap {
  max-height: 460px;
}

.source-lineage-panel {
  padding-top: 12px;
  padding-bottom: 12px;
}

.source-lineage-summary {
  margin: 4px 0 10px;
}

.source-lineage-summary a {
  color: inherit;
  text-decoration: none;
}

.source-lineage-summary a:hover {
  text-decoration: underline;
}

.source-lineage-details {
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  background: hsl(var(--muted) / .22);
  padding: 8px 10px;
}

.source-lineage-details summary {
  cursor: pointer;
  font-weight: 850;
}

.source-lineage-details .table-wrap {
  margin-top: 8px;
}

.erp-download-board {
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, .45fr);
}

.erp-report-list,
.erp-download-status-card,
.erp-account-filter-panel,
.erp-report-manager {
  border-radius: 10px;
}

.erp-report-row,
.erp-report-row.has-actions {
  grid-template-columns: 20px minmax(220px, 1fr) minmax(118px, max-content) max-content;
  min-height: 46px;
  border-radius: 8px;
}

.erp-report-row:not(.has-actions) {
  grid-template-columns: 20px minmax(220px, 1fr) minmax(118px, max-content);
}

.erp-report-name b {
  white-space: normal;
  line-height: 1.25;
}

.erp-report-name small {
  max-width: 100%;
}

.erp-download-status-card {
  position: sticky;
  top: 92px;
}

.erp-summary-grid {
  gap: 12px;
}

.erp-summary-card {
  min-height: 86px;
  border-radius: 8px;
}

.erp-summary-card strong {
  font-size: 26px;
}

.erp-result-toolbar {
  flex-wrap: wrap;
  gap: 8px;
}

.erp-live-progress {
  height: 10px;
}

.erp-run-chip {
  border-radius: 8px;
}

.erp-final-result-table {
  min-width: 840px;
  table-layout: fixed;
}

.erp-final-result-table th:nth-child(1),
.erp-final-result-table td:nth-child(1) {
  width: 30%;
}

.erp-final-result-table th:nth-child(2),
.erp-final-result-table td:nth-child(2) {
  width: 42%;
}

.erp-final-result-table th:nth-child(3),
.erp-final-result-table td:nth-child(3) {
  width: 16%;
}

.erp-final-result-table th:nth-child(4),
.erp-final-result-table td:nth-child(4) {
  width: 12%;
}

.erp-final-result-table td:nth-child(3),
.erp-final-result-table td:nth-child(4) {
  text-align: center;
}

.erp-target-progress-table {
  min-width: 1500px;
  table-layout: fixed;
}

.erp-target-progress-table th:nth-child(1),
.erp-target-progress-table td:nth-child(1) {
  width: 220px;
}

.erp-target-progress-table th:nth-child(2),
.erp-target-progress-table td:nth-child(2) {
  width: 210px;
}

.erp-target-progress-table th:nth-child(3),
.erp-target-progress-table td:nth-child(3) {
  width: 170px;
}

.erp-target-progress-table td:nth-child(1),
.erp-target-progress-table td:nth-child(2) {
  white-space: normal;
  overflow-wrap: anywhere;
}

.source-history-table {
  min-width: 1320px;
  table-layout: fixed;
}

.source-history-table th:nth-child(1),
.source-history-table td:nth-child(1) {
  width: 170px;
}

.source-history-table th:nth-child(2),
.source-history-table td:nth-child(2) {
  width: 230px;
}

.source-history-table th:nth-child(3),
.source-history-table td:nth-child(3) {
  width: 180px;
}

.source-history-table th:nth-child(8),
.source-history-table td:nth-child(8) {
  width: 330px;
}

.source-history-table th:nth-child(9),
.source-history-table td:nth-child(9) {
  width: 190px;
}

.assignment-table {
  min-width: 1180px;
  table-layout: fixed;
}

.assignment-table th:nth-child(1),
.assignment-table td:nth-child(1) {
  width: 310px;
}

.assignment-table th:nth-child(4),
.assignment-table td:nth-child(4),
.assignment-table th:nth-child(5),
.assignment-table td:nth-child(5) {
  width: 190px;
}

.assignment-table td:first-child b {
  display: block;
  white-space: normal;
  overflow-wrap: anywhere;
}

.ca-reco-pair-grid,
.ca-export-grid {
  gap: 12px;
}

.ca-choice-list {
  border-radius: 8px;
}

.ca-result-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

@media (max-width: 1050px) {
  .erp-download-status-card {
    position: static;
  }
}

@media (max-width: 760px) {
  .upload-workspace {
    grid-template-columns: 1fr;
  }
  .upload-context-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .upload-context-strip > a {
    justify-self: start;
  }
  .upload-dropzone-large {
    grid-template-columns: 46px minmax(0, 1fr);
  }
  .upload-browse-btn {
    grid-column: 1 / -1;
    width: 100%;
  }

  .erp-report-row,
.erp-report-row.has-actions,
.erp-report-row:not(.has-actions) {
    grid-template-columns: 20px minmax(0, 1fr);
  }

  .erp-report-row em,
.erp-report-row button {
    grid-column: 2;
    justify-self: start;
  }

  .upload-next-card .two-fields,
.upload-context-strip {
    grid-template-columns: 1fr;
  }

  .mini-table td {
    max-width: 320px;
  }

  .source-lineage-summary {
    grid-template-columns: 1fr;
  }
}

/* ERP source import: compact workflow and period controls. */
.erp-setup-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.erp-setup-steps span {
  width: 100%;
  min-height: 52px;
  border-radius: 10px;
  padding: 10px 14px;
  justify-content: flex-start;
  overflow: hidden;
  text-overflow: ellipsis;
}
.erp-step-panel.erp-period-panel {
  justify-self: start;
  width: auto;
  max-width: 100%;
  display: inline-grid;
  grid-template-columns: 150px max-content;
  align-items: end;
}
.erp-step-panel.erp-period-panel .erp-period-compact {
  width: auto;
  max-width: none;
}
.erp-step-panel.erp-period-panel .erp-period-mode-field,
.erp-step-panel.erp-period-panel .erp-period-range label {
  flex-basis: 190px;
}
@media (max-width: 920px) {
  .upload-workspace {
    grid-template-columns: 1fr;
  }
  .upload-context-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .upload-context-strip > a {
    justify-self: start;
  }
  .erp-setup-steps {
    grid-template-columns: 1fr;
  }
  .erp-step-panel.erp-period-panel {
    display: grid;
    grid-template-columns: 1fr;
    justify-self: stretch;
    width: 100%;
  }
  .erp-step-panel.erp-period-panel .erp-period-mode-field,
.erp-step-panel.erp-period-panel .erp-period-range label,
.erp-step-panel.erp-period-panel #erp-month-field {
    flex: 1 1 180px;
  }
}

/* ERP period panel final alignment: full-width like other steps, with larger controls. */
.erp-step-panel.erp-period-panel {
  justify-self: stretch;
  width: 100%;
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  align-items: start;
  padding: 16px 18px;
}
.erp-step-panel.erp-period-panel .erp-step-title {
  align-self: start;
  padding-top: 2px;
}
.erp-step-panel.erp-period-panel .erp-period-compact {
  align-items: start;
  width: 100%;
  gap: 12px;
}
.erp-step-panel.erp-period-panel .erp-period-mode-field {
  flex-basis: 230px;
}
.erp-step-panel.erp-period-panel .erp-period-range label {
  flex-basis: 230px;
}
.erp-step-panel.erp-period-panel #erp-month-field {
  flex-basis: 230px;
}
.erp-step-panel.erp-period-panel select,
.erp-step-panel.erp-period-panel input {
  min-height: 50px;
  font-size: 15px;
  padding-left: 14px;
  padding-right: 14px;
}

@media (max-width: 980px) {
  .compact-batch-panel .compact-form,
.compact-batch-panel .three-fields {
    grid-template-columns: 1fr;
  }

  .compact-batch-panel .two-fields {
    max-width: none;
  }

  .active-source-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .active-source-strip > a {
    justify-self: start;
  }

  .batch-source-review-list article,
.batch-source-conflict-list article {
    grid-template-columns: 1fr;
  }

  .batch-source-review-actions {
    justify-content: flex-start;
  }

  .readiness-item summary {
    grid-template-columns: 1fr max-content;
  }

  .readiness-metrics {
    grid-column: 1 / -1;
  }

  .readiness-detail-grid {
    grid-template-columns: 1fr;
  }

  .working-source-lines {
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .working-source-line {
    min-width: 1180px;
  }

}

@media (max-width: 680px) {
  .active-source-strip {
    grid-template-columns: 1fr;
  }
}

/* Navigation menus: readable width, grouped Workings, and clear separation from the page. */
