:root {
  color-scheme: light;
  --navy-950: #0a1f3d;
  --navy-900: #0f2f5f;
  --navy-800: #16457e;
  --slate-950: #111827;
  --slate-800: #1f2937;
  --slate-700: #334155;
  --slate-600: #475569;
  --slate-500: #64748b;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50: #f8fafc;
  --white: #ffffff;
  --teal: #0f766e;
  --emerald: #047857;
  --amber: #b45309;
  --red: #b91c1c;
  --purple: #6d28d9;
  --blue: #1d4ed8;
  --border: #d7dee8;
  --shadow: 0 16px 35px rgba(15, 23, 42, 0.08);
  --radius: 8px;
  --sidebar: 280px;
  --sidebar-collapsed: 86px;
  --topbar: 72px;
  --focus: 0 0 0 3px rgba(29, 78, 216, 0.25);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--slate-50);
}

body {
  margin: 0;
  color: var(--slate-800);
  background: var(--slate-50);
  font-size: 16px;
  line-height: 1.5;
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a,
input,
select,
textarea,
summary {
  outline: none;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  box-shadow: var(--focus);
}

a {
  color: var(--navy-800);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
  color: var(--navy-900);
  white-space: nowrap;
}

.icon {
  width: 1.15em;
  height: 1.15em;
  flex: 0 0 auto;
  vertical-align: -0.18em;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: 100vh;
}

.app-shell.is-collapsed {
  grid-template-columns: var(--sidebar-collapsed) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  height: 100vh;
  color: #dbeafe;
  background: var(--navy-950);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--topbar);
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius);
  background: #123d73;
  color: #ffffff;
  font-weight: 800;
}

.brand-lockup strong,
.brand-lockup small {
  display: block;
}

.brand-lockup small {
  color: #bfdbfe;
}

.sidebar nav,
.mobile-drawer nav {
  display: grid;
  gap: 4px;
  padding: 12px;
}

.sidebar nav {
  overflow-y: auto;
  scrollbar-width: thin;
}

.sidebar nav a,
.mobile-drawer nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: inherit;
  font-weight: 650;
  text-decoration: none;
}

.sidebar nav a:hover,
.sidebar nav a.active,
.mobile-drawer nav a:hover,
.mobile-drawer nav a.active {
  background: rgba(255, 255, 255, 0.1);
}

.sidebar-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: auto 12px 14px;
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.06);
  color: #dbeafe;
  cursor: pointer;
}

.is-collapsed .sidebar span:not(.brand-mark),
.is-collapsed .sidebar small,
.is-collapsed .sidebar strong,
.is-collapsed .sidebar-toggle span {
  display: none;
}

.is-collapsed .brand-lockup,
.is-collapsed .sidebar nav a,
.is-collapsed .sidebar-toggle {
  justify-content: center;
}

.app-main {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: var(--topbar);
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
}

.topbar-title {
  min-width: 0;
  flex: 1;
}

.topbar-title span,
.breadcrumb,
.field small,
.summary-copy small,
.panel-head p,
.page-heading p,
.last-updated,
.applied-filters {
  color: var(--slate-600);
}

.topbar-title strong {
  display: block;
  color: var(--slate-950);
  font-size: 1.08rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.connection-state,
.alert-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--slate-700);
  font-weight: 650;
}

.alert-pill {
  color: var(--red);
  text-decoration: none;
}

#main-content {
  width: min(100%, 1600px);
  margin: 0 auto;
  padding: 24px;
}

#main-content:focus {
  outline: none;
}

.page-heading,
.profile-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.page-heading h1,
.profile-header h1 {
  margin: 0;
  color: var(--slate-950);
  font-size: clamp(1.65rem, 2vw, 2.15rem);
  line-height: 1.15;
  letter-spacing: 0;
}

.breadcrumb {
  margin: 0 0 4px;
  font-weight: 700;
}

.page-actions,
.action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.btn,
.icon-btn,
.row-actions button,
.row-actions a,
.data-table button,
.mobile-card-actions button,
.mobile-card-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 750;
  line-height: 1.1;
  text-decoration: none;
  cursor: pointer;
}

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

.btn-secondary {
  border-color: var(--border);
  background: var(--white);
  color: var(--navy-900);
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--slate-700);
}

.btn:disabled,
button:disabled,
.btn.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

.icon-btn {
  width: 44px;
  padding: 0;
  border-color: var(--border);
  background: var(--white);
  color: var(--slate-700);
}

.menu-button {
  display: none;
}

.panel,
.summary-card,
.state-card,
.mobile-record-card,
.report-preview {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.panel-head h2,
.form-section-heading h2,
.state-card h2 {
  margin: 0;
  color: var(--slate-950);
  font-size: 1.05rem;
  letter-spacing: 0;
}

.panel-head p,
.form-section-heading p {
  margin: 4px 0 0;
}

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

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

.summary-card {
  display: flex;
  gap: 12px;
  min-height: 126px;
  padding: 16px;
  color: inherit;
  text-decoration: none;
}

.summary-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: var(--radius);
  background: #e0f2fe;
  color: var(--navy-900);
}

.summary-copy span,
.summary-copy small,
.summary-copy em {
  display: block;
}

.summary-copy span {
  font-weight: 750;
}

.summary-copy strong {
  display: block;
  margin: 6px 0 4px;
  color: var(--slate-950);
  font-size: 1.5rem;
  line-height: 1.1;
}

.summary-copy em {
  color: var(--emerald);
  font-style: normal;
  font-weight: 750;
}

.control-panel,
.list-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
}

.table-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin: 14px 0 0;
}

.table-pagination span {
  color: var(--slate-600);
  font-size: 0.9rem;
  font-weight: 750;
}

.control-panel label,
.list-toolbar label,
.filter-grid label,
.mapping-grid label {
  display: grid;
  gap: 5px;
  color: var(--slate-600);
  font-size: 0.9rem;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius);
  background: var(--white);
  color: var(--slate-900);
  padding: 10px 12px;
}

textarea {
  min-height: 100px;
  resize: vertical;
}

input[readonly] {
  background: var(--slate-100);
  color: var(--slate-600);
}

.search-input {
  position: relative;
  flex: 1 1 300px;
}

.search-input .icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--slate-500);
}

.search-input input {
  padding-left: 38px;
  padding-right: 48px;
}

.search-input button {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
}

.filter-details,
.column-details {
  position: relative;
}

summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--navy-900);
  font-weight: 750;
  cursor: pointer;
}

.filter-grid,
.column-toggles {
  position: absolute;
  z-index: 30;
  right: 0;
  top: calc(100% + 8px);
  display: grid;
  width: min(720px, calc(100vw - 36px));
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: var(--shadow);
}

.column-toggles {
  width: 300px;
  grid-template-columns: 1fr;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-chips button {
  min-height: 34px;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  background: #eff6ff;
  color: var(--navy-900);
  cursor: pointer;
}

.result-count {
  margin: 0 0 0 auto;
  color: var(--slate-600);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 16px;
}

.dashboard-table-card {
  overflow: hidden;
  padding: 0;
}

.dashboard-table-card .panel-head {
  min-height: 76px;
  margin: 0;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
  background: #fbfdff;
}

.dashboard-table-wrap {
  max-height: 320px;
  overflow: auto;
}

.dashboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.dashboard-table th,
.dashboard-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.dashboard-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef4fb;
  color: var(--slate-700);
  font-size: 0.76rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.dashboard-table tr:last-child td {
  border-bottom: 0;
}

.dashboard-table tbody tr:nth-child(odd) {
  background: #fbfdff;
}

.dashboard-table tbody tr:hover {
  background: #f0f7ff;
}

.dashboard-table .is-right {
  text-align: right;
}

.dashboard-row-label {
  color: var(--slate-950);
  font-weight: 800;
}

.dashboard-metric {
  display: grid;
  min-width: 128px;
  gap: 6px;
  justify-items: end;
}

.dashboard-metric strong {
  color: var(--slate-950);
  font-variant-numeric: tabular-nums;
}

.metric-track {
  display: block;
  width: min(150px, 100%);
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--slate-100);
}

.metric-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--navy-800);
}

.dashboard-empty {
  display: grid;
  min-height: 148px;
  place-items: center;
  padding: 18px;
  color: var(--slate-600);
  text-align: center;
}

.attention-type {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  background: #fee2e2;
  color: var(--red);
  font-size: 0.82rem;
  font-weight: 850;
  white-space: nowrap;
}

.count-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--slate-100);
  color: var(--slate-700);
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
}

.chart-card {
  min-height: 320px;
}

.bar-chart {
  display: flex;
  align-items: end;
  gap: 10px;
  height: 205px;
  padding: 12px 4px 0;
}

.bar-item {
  display: grid;
  flex: 1;
  align-items: end;
  min-width: 28px;
  height: 100%;
  gap: 7px;
}

.bar-item span {
  display: block;
  min-height: 8px;
  border-radius: 6px 6px 0 0;
  background: var(--navy-800);
}

.bar-item small {
  color: var(--slate-600);
  text-align: center;
  writing-mode: vertical-rl;
}

.line-chart {
  width: 100%;
  height: 220px;
  color: var(--teal);
}

.line-chart circle {
  fill: var(--navy-900);
}

.donut-wrap {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
}

.donut-chart {
  width: 180px;
  height: 180px;
  transform: rotate(-90deg);
}

.donut-chart circle {
  fill: none;
  stroke-width: 14;
  stroke: var(--navy-800);
}

.donut-chart text {
  transform: rotate(90deg);
  transform-origin: 50% 50%;
  text-anchor: middle;
  font-weight: 800;
  fill: var(--slate-950);
}

.donut-1 {
  stroke: var(--teal) !important;
}

.donut-2 {
  stroke: var(--amber) !important;
}

.donut-3 {
  stroke: var(--red) !important;
}

.donut-4 {
  stroke: var(--purple) !important;
}

.donut-wrap ul,
.attention-list,
.error-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.donut-wrap li,
.attention-list li,
.error-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--slate-50);
}

.legend-dot,
.status-dot {
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 999px;
  background: currentColor;
}

.chart-empty {
  display: grid;
  min-height: 200px;
  place-items: center;
  color: var(--slate-600);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--slate-50);
}

.quick-actions {
  margin-bottom: 18px;
}

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

.attention-list li {
  align-items: flex-start;
  flex-direction: column;
}

.attention-list span {
  color: var(--red);
  font-weight: 800;
}

.attention-list em {
  color: var(--slate-600);
  font-style: normal;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 800;
  white-space: nowrap;
}

.status-success {
  background: #dcfce7;
  color: #166534;
}

.status-danger {
  background: #fee2e2;
  color: #991b1b;
}

.status-warning {
  background: #fef3c7;
  color: #92400e;
}

.status-info {
  background: #dbeafe;
  color: #1e40af;
}

.status-review {
  background: #e0f2fe;
  color: #075985;
}

.status-purple {
  background: #ede9fe;
  color: #5b21b6;
}

.status-neutral {
  background: var(--slate-100);
  color: var(--slate-700);
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
}

.data-table {
  width: 100%;
  min-width: 1050px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.92rem;
}

.data-table th,
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #eef4fb;
  color: var(--slate-700);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.data-table th:first-child,
.data-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: inherit;
}

.data-table th:first-child {
  z-index: 3;
  background: #eef4fb;
}

.data-table th[data-col="actions"],
.data-table td[data-col="actions"] {
  position: sticky;
  right: 0;
  z-index: 2;
  min-width: 148px;
  background: inherit;
  box-shadow: -10px 0 14px -14px rgba(15, 23, 42, 0.72);
}

.data-table th[data-col="actions"] {
  z-index: 4;
  background: #eef4fb;
}

.data-table td[data-col="actions"] {
  background: var(--white);
}

.data-table tbody tr:nth-child(odd) td[data-col="actions"] {
  background: #fbfdff;
}

.data-table tbody tr:hover td[data-col="actions"] {
  background: #f0f7ff;
}

.data-table tbody tr:nth-child(odd) {
  background: #fbfdff;
}

.data-table tbody tr:hover {
  background: #f0f7ff;
}

.data-table th button {
  min-height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-transform: inherit;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.row-actions a,
.row-actions button,
.data-table button {
  min-height: 34px;
  padding: 6px 9px;
  border-color: var(--border);
  background: var(--white);
  color: var(--navy-800);
}

.mobile-record-list {
  display: none;
}

.mobile-record-card {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.mobile-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.mobile-card-head h3 {
  margin: 0;
  color: var(--slate-950);
  font-size: 1rem;
}

.mobile-card-head p {
  margin: 2px 0 0;
  color: var(--slate-600);
}

.mobile-record-card dl,
.detail-panel dl,
.report-preview dl,
.comparison-drawer dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.mobile-record-card dt,
.detail-panel dt {
  color: var(--slate-600);
  font-size: 0.82rem;
  font-weight: 800;
}

.mobile-record-card dd,
.detail-panel dd {
  margin: 0;
  color: var(--slate-950);
  font-weight: 750;
}

.mobile-card-actions {
  display: flex;
  gap: 8px;
}

.record-form,
.wizard,
.archive-grid {
  display: grid;
  gap: 18px;
}

.form-section {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 20px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: var(--shadow);
}

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

.field {
  display: grid;
  gap: 6px;
  color: var(--slate-700);
  font-weight: 750;
}

.field span b {
  color: var(--red);
  padding-left: 2px;
}

.span-2 {
  grid-column: 1 / -1;
}

.field-error,
[data-import-file-error] {
  min-height: 1.2em;
  color: var(--red);
  font-size: 0.86rem;
  font-style: normal;
}

[aria-invalid="true"] {
  border-color: var(--red);
}

.error-summary {
  padding: 14px;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  background: #fef2f2;
  color: var(--red);
}

.error-summary ul {
  margin-bottom: 0;
}

.file-upload {
  display: grid;
  min-height: 132px;
  place-items: center;
  gap: 6px;
  padding: 16px;
  border: 1px dashed #94a3b8;
  border-radius: var(--radius);
  background: var(--slate-50);
  color: var(--slate-700);
  text-align: center;
  cursor: pointer;
}

.file-upload input {
  max-width: 280px;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  z-index: 10;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.profile-header {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: var(--shadow);
}

.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.tabs button {
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--slate-700);
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
}

.tabs button.active {
  background: var(--navy-900);
  color: #ffffff;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

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

.read-only-panel {
  background: #f8fbff;
}

.timeline-panel {
  margin-top: 16px;
}

.timeline {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline li {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  gap: 10px;
  align-items: center;
}

.timeline li span {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--navy-800);
}

.timeline time {
  color: var(--slate-600);
}

.progress-panel,
.allocation-panel,
.warning-panel,
.effect-preview {
  margin-bottom: 16px;
}

.progress-meter {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--slate-100);
}

.progress-meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
}

.allocation-summary,
.warning-text,
.amount-warning {
  color: var(--red);
  font-weight: 800;
}

.comparison-drawer,
.mobile-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 50;
  width: min(480px, 100vw);
  height: 100vh;
  padding: 18px;
  overflow: auto;
  border-left: 1px solid var(--border);
  background: var(--white);
  box-shadow: -20px 0 45px rgba(15, 23, 42, 0.16);
  transform: translateX(110%);
  transition: transform 160ms ease;
}

.mobile-drawer {
  left: 0;
  right: auto;
  width: min(360px, calc(100vw - 48px));
  color: #dbeafe;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  border-left: 0;
  background: var(--navy-950);
  box-shadow: 20px 0 45px rgba(15, 23, 42, 0.16);
  transform: translateX(-110%);
}

.mobile-drawer .icon-btn {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: #dbeafe;
}

.comparison-drawer.open,
.drawer-open .mobile-drawer {
  transform: translateX(0);
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

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

.compare-grid section {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--slate-50);
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: none;
  background: rgba(15, 23, 42, 0.45);
}

.drawer-open .drawer-backdrop {
  display: block;
}

.upload-workspace {
  margin-bottom: 18px;
}

.report-preview {
  padding: 18px;
}

.print-header {
  display: none;
  text-align: center;
}

.signature-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 28px;
  margin-top: 40px;
}

.signature-grid span {
  padding-top: 18px;
  border-top: 1px solid var(--slate-700);
  text-align: center;
  font-weight: 750;
}

.wizard-steps {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.wizard-steps li {
  display: grid;
  gap: 6px;
  align-content: start;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--slate-600);
  font-size: 0.84rem;
  font-weight: 750;
}

.wizard-steps span {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 999px;
  background: var(--slate-100);
  color: var(--slate-700);
}

.wizard-steps .active,
.wizard-steps .done {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: var(--navy-900);
}

.wizard-steps .active span,
.wizard-steps .done span {
  background: var(--navy-900);
  color: #ffffff;
}

.wizard-panel {
  min-height: 300px;
}

.choice-list,
.mapping-grid,
.import-stats {
  display: grid;
  gap: 12px;
}

.choice-list label {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--slate-800);
  font-weight: 700;
}

.choice-list input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--navy-900);
}

.choice-list span {
  min-width: 0;
  overflow-wrap: anywhere;
}

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

.import-stats {
  grid-template-columns: auto 1fr auto 1fr;
  align-items: center;
  width: fit-content;
  margin-bottom: 12px;
}

.import-stats strong {
  color: var(--navy-900);
  font-size: 1.6rem;
}

.success-state,
.placeholder-box {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius);
  background: #f0fdf4;
  color: #166534;
}

.placeholder-box {
  border-color: var(--border);
  background: var(--slate-50);
  color: var(--slate-700);
}

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

.archive-section article {
  display: grid;
  gap: 6px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.archive-section article:last-child {
  border-bottom: 0;
}

.state-card {
  display: grid;
  place-items: center;
  min-height: 190px;
  padding: 24px;
  text-align: center;
}

.loading-skeleton {
  display: grid;
  gap: 10px;
}

.loading-skeleton span {
  height: 18px;
  border-radius: 999px;
  background: linear-gradient(90deg, #e2e8f0, #f8fafc, #e2e8f0);
  background-size: 220% 100%;
  animation: shimmer 1.3s linear infinite;
}

@keyframes shimmer {
  to {
    background-position: -220% 0;
  }
}

.toast-region {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  display: grid;
  gap: 10px;
  width: min(380px, calc(100vw - 36px));
}

.toast {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--navy-900);
  color: #ffffff;
  box-shadow: var(--shadow);
  font-weight: 750;
}

.toast-warning {
  background: var(--amber);
}

.toast-danger {
  background: var(--red);
}

[hidden] {
  display: none !important;
}

@media (max-width: 1280px) {
  .summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

@media (max-width: 1180px) and (min-width: 1041px) {
  .app-shell {
    grid-template-columns: var(--sidebar-collapsed) minmax(0, 1fr);
  }

  .sidebar span:not(.brand-mark),
  .sidebar small,
  .sidebar strong,
  .sidebar-toggle span {
    display: none;
  }

  .brand-lockup,
  .sidebar nav a,
  .sidebar-toggle {
    justify-content: center;
  }
}

@media (max-width: 1040px) {
  .app-shell,
  .app-shell.is-collapsed {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .menu-button {
    display: inline-flex;
  }

  .mobile-drawer {
    display: block;
  }

  .topbar {
    padding: 10px 14px;
  }

  .topbar-title span {
    display: none;
  }

  #main-content {
    padding: 18px 14px 96px;
  }

  .summary-grid,
  .dashboard-grid,
  .detail-grid,
  .archive-grid {
    grid-template-columns: 1fr;
  }

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

  .form-section {
    grid-template-columns: 1fr;
  }

  .wizard-steps {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

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

  .topbar-actions .btn,
  .connection-state {
    display: none;
  }

  .page-heading,
  .profile-header {
    display: grid;
  }

  .page-actions,
  .action-row,
  .sticky-actions,
  .mobile-card-actions {
    width: 100%;
  }

  .page-actions .btn,
  .action-row .btn,
  .sticky-actions .btn,
  .sticky-actions button,
  .mobile-card-actions .btn,
  .mobile-card-actions button {
    flex: 1 1 auto;
  }

  .summary-grid,
  .summary-grid.compact,
  .action-grid,
  .form-grid,
  .mapping-grid,
  .compare-grid,
  .signature-grid {
    grid-template-columns: 1fr;
  }

  .control-panel,
  .list-toolbar {
    align-items: stretch;
  }

  .control-panel label,
  .list-toolbar label,
  .filter-details,
  .column-details,
  .search-input {
    width: 100%;
  }

  .filter-grid {
    position: fixed;
    inset: 0;
    z-index: 60;
    width: 100vw;
    height: 100vh;
    overflow: auto;
    grid-template-columns: 1fr;
    align-content: start;
    border-radius: 0;
  }

  .table-wrap {
    display: none;
  }

  .mobile-record-list {
    display: grid;
    gap: 12px;
  }

  .mobile-record-card dl,
  .detail-panel dl {
    grid-template-columns: 1fr;
  }

  .donut-wrap {
    grid-template-columns: 1fr;
  }

  .bar-chart {
    overflow-x: auto;
  }

  .bar-item {
    min-width: 44px;
  }

  .wizard-steps {
    display: flex;
    overflow-x: auto;
  }

  .wizard-steps li {
    min-width: 140px;
  }

  .toast-region {
    bottom: 84px;
  }
}

@media (max-width: 420px) {
  .mobile-drawer {
    width: min(320px, calc(100vw - 36px));
    padding: 14px;
  }

  .topbar-title strong {
    max-width: 190px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .summary-card {
    min-height: 112px;
  }

  .summary-copy strong {
    font-size: 1.25rem;
  }
}

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

@media print {
  body {
    background: #ffffff;
  }

  .sidebar,
  .topbar,
  .page-actions,
  .list-toolbar,
  .control-panel,
  .tabs,
  .sticky-actions,
  .toast-region,
  .btn,
  button,
  .mobile-drawer,
  .drawer-backdrop {
    display: none !important;
  }

  .app-shell,
  .app-shell.is-collapsed {
    display: block;
  }

  #main-content {
    width: 100%;
    max-width: none;
    padding: 0;
  }

  .panel,
  .summary-card,
  .report-preview {
    break-inside: avoid;
    box-shadow: none;
  }

  .print-header {
    display: block;
    margin-bottom: 18px;
  }

  .table-wrap {
    display: block;
    overflow: visible;
    border: 0;
  }

  .data-table {
    min-width: 0;
    font-size: 10pt;
  }

  .data-table th,
  .data-table td {
    padding: 6px;
  }

  .data-table th:first-child,
  .data-table td:first-child {
    position: static;
  }
}
