:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-soft: #f8fbff;
  --line: #e3e9f5;
  --line-strong: #d5deee;
  --text: #0b1533;
  --muted: #65708a;
  --subtle: #8a96ad;
  --blue: #236dff;
  --blue-dark: #1350db;
  --blue-soft: #eaf2ff;
  --purple: #7b4df3;
  --purple-soft: #f0ebff;
  --teal: #16b7a1;
  --teal-soft: #e8f8f5;
  --red: #e83d46;
  --red-soft: #fff0f1;
  --orange: #f28a24;
  --orange-soft: #fff4e8;
  --shadow: 0 14px 36px rgba(26, 45, 88, 0.08);
  --side-width: 220px;
  --top-height: 82px;
  font-family: "Inter", "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  width: var(--side-width);
  padding: 22px 16px;
  background: rgba(255, 255, 255, 0.95);
  border-right: 1px solid var(--line);
  box-shadow: 10px 0 28px rgba(36, 55, 92, 0.04);
}

.side-nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  min-height: 54px;
  padding: 0 14px;
  color: #35415c;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  transition: background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.nav-item svg,
.icon-button svg,
.search-box svg,
.date-range svg,
.user-chip svg,
.action-icon svg,
.rail-head svg,
.empty-icon svg,
.settings-icon svg,
.file-list svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-item:hover {
  color: var(--blue);
  background: var(--blue-soft);
}

.nav-item.active {
  color: var(--blue);
  background: linear-gradient(90deg, rgba(35, 109, 255, 0.14), rgba(255, 255, 255, 0.88));
  box-shadow: inset 4px 0 0 var(--blue);
}

.workspace {
  min-height: 100vh;
  margin-left: var(--side-width);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 44px minmax(260px, 1fr) minmax(280px, 360px) 44px auto;
  gap: 16px;
  align-items: center;
  height: var(--top-height);
  padding: 16px 30px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  color: #18233d;
  background: #fff;
  border: 1px solid transparent;
  border-radius: 8px;
}

.icon-button:hover {
  color: var(--blue);
  border-color: var(--line);
  background: var(--panel-soft);
}

.search-box {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-width: 0;
  height: 48px;
  padding: 0 14px;
  color: var(--subtle);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
}

.search-box:focus-within {
  color: var(--blue);
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(35, 109, 255, 0.12);
}

.search-box input {
  width: 100%;
  min-width: 0;
  color: var(--text);
  border: 0;
  outline: 0;
  background: transparent;
}

.shortcut {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 9px;
  color: var(--subtle);
  background: #f0f3f8;
  border-radius: 6px;
  white-space: nowrap;
}

.date-range {
  display: grid;
  grid-template-columns: minmax(112px, 1fr) auto minmax(112px, 1fr) 22px;
  gap: 8px;
  align-items: center;
  min-width: 0;
  height: 48px;
  padding: 0 12px;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
}

.date-range input {
  min-width: 0;
  color: var(--text);
  border: 0;
  outline: 0;
  background: transparent;
}

.user-chip {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-width: 150px;
}

.avatar {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  color: #fff;
  font-weight: 700;
  background: #152b5b;
  border: 3px solid #dbe7ff;
  border-radius: 50%;
}

.user-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.user-copy strong,
.user-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-copy strong {
  font-size: 14px;
}

.user-copy small {
  color: var(--muted);
  font-size: 12px;
}

.main-view {
  padding: 28px 30px 36px;
}

.page-title {
  margin: 0 0 22px;
  font-size: 24px;
  font-weight: 800;
}

.inline-alert {
  margin: 0 0 16px;
  padding: 12px 14px;
  color: #b4232b;
  background: var(--red-soft);
  border: 1px solid #ffd2d6;
  border-radius: 8px;
}

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

.content-stack,
.right-rail {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
}

.card,
.kpi-card,
.rail-card,
.action-bar {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(224, 231, 242, 0.92);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.kpi-card {
  display: grid;
  min-height: 132px;
  grid-template-columns: minmax(0, 1fr) 54px;
  gap: 14px;
  padding: 20px;
}

.kpi-copy {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.kpi-label,
.section-title,
.rail-title {
  font-weight: 800;
}

.kpi-value {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 5px;
  color: #071232;
  font-size: 30px;
  font-weight: 800;
  line-height: 1;
}

.kpi-unit {
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}

.kpi-delta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
}

.delta-up {
  color: #f02835;
}

.delta-down {
  color: #087a66;
}

.delta-neutral {
  color: var(--muted);
}

.kpi-icon,
.recent-icon,
.empty-icon {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border-radius: 8px;
}

.tone-blue {
  color: var(--blue);
  background: var(--blue-soft);
}

.tone-purple {
  color: var(--purple);
  background: var(--purple-soft);
}

.tone-teal {
  color: var(--teal);
  background: var(--teal-soft);
}

.tone-red {
  color: var(--red);
  background: var(--red-soft);
}

.tone-orange {
  color: var(--orange);
  background: var(--orange-soft);
}

.card {
  padding: 20px;
  min-width: 0;
}

.card-head,
.rail-head,
.table-toolbar,
.panel-tabs {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-head {
  margin-bottom: 16px;
}

.section-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 18px;
}

.info-dot {
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  color: var(--subtle);
  font-size: 12px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
}

.segmented {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.segment-button {
  min-width: 42px;
  height: 38px;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
}

.segment-button.active {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
}

.date-preset-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(26, 45, 88, 0.05);
}

.date-preset-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.date-preset-copy strong {
  font-size: 14px;
}

.date-preset-copy span {
  color: var(--muted);
  font-size: 12px;
}

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

.date-preset {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 11px;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
}

.date-preset svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.date-preset.active,
.date-preset:hover {
  color: var(--blue);
  background: var(--blue-soft);
  border-color: rgba(35, 109, 255, 0.28);
}

.comparison-kind-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.kind-card {
  display: grid;
  gap: 5px;
  min-height: 72px;
  padding: 14px;
  text-align: left;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
}

.kind-card span {
  color: var(--muted);
  font-size: 12px;
}

.kind-card.active {
  color: var(--blue);
  background: var(--blue-soft);
  border-color: rgba(35, 109, 255, 0.34);
  box-shadow: 0 10px 24px rgba(35, 109, 255, 0.08);
}

.chart-stage {
  position: relative;
  width: 100%;
  min-height: 312px;
  overflow: visible;
}

.trend-svg,
.bars-svg {
  display: block;
  width: 100%;
  height: 312px;
}

.trend-svg {
  touch-action: manipulation;
}

.trend-point {
  cursor: pointer;
  transition: fill 160ms ease, stroke 160ms ease, r 160ms ease;
}

.trend-point.active {
  fill: var(--blue);
  stroke: #fff;
  r: 7;
}

.trend-hover-line {
  stroke: rgba(35, 109, 255, 0.58);
  stroke-width: 1.5;
  stroke-dasharray: 4 5;
  pointer-events: none;
}

.trend-tooltip {
  position: absolute;
  z-index: 6;
  min-width: 132px;
  padding: 10px 12px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(26, 45, 88, 0.14);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 12px));
  transition: opacity 120ms ease, transform 120ms ease;
}

.trend-tooltip.visible {
  opacity: 1;
}

.trend-tooltip.below {
  transform: translate(-50%, 12px);
}

.trend-tooltip strong,
.trend-tooltip span {
  display: block;
  white-space: nowrap;
}

.trend-tooltip strong {
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--muted);
}

.trend-tooltip span {
  font-size: 16px;
  font-weight: 800;
}

.axis-label {
  color: var(--muted);
  font-size: 12px;
}

.chart-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

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

.comparison-layout {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 18px;
}

.comparison-tabs {
  display: grid;
  align-self: stretch;
  background: #f6f9ff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.comparison-tabs button {
  min-height: 62px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-left: 3px solid transparent;
}

.comparison-tabs button.active {
  color: var(--blue);
  background: #eef5ff;
  border-left-color: var(--blue);
  font-weight: 700;
}

.rail-card {
  padding: 18px;
}

.rail-head {
  margin-bottom: 14px;
}

.rail-title {
  margin: 0;
  font-size: 17px;
}

.rail-link {
  color: var(--blue);
  font-size: 13px;
  border: 0;
  background: transparent;
}

.recent-list,
.tag-list,
.status-list,
.reminder-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.recent-item {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 8px;
  gap: 12px;
  align-items: center;
  min-height: 52px;
}

.recent-icon {
  width: 44px;
  height: 44px;
}

.recent-copy {
  min-width: 0;
}

.recent-copy strong,
.recent-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-copy strong {
  font-size: 14px;
}

.recent-copy span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.dot {
  width: 7px;
  height: 7px;
  background: var(--teal);
  border-radius: 50%;
}

.tag {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  text-align: left;
  font-weight: 700;
}

.tag-button {
  cursor: pointer;
}

.tag-button:hover,
.tag-button:focus-visible,
.tag-button.active {
  outline: 0;
  box-shadow: inset 0 0 0 2px currentColor;
}

.tag span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-copy,
.status-copy,
.reminder-copy {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.signature {
  margin-top: 12px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
  text-align: center;
}

.status-item,
.reminder-item {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding-top: 2px;
}

.status-icon,
.reminder-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
}

.status-icon svg,
.reminder-icon svg,
.kpi-icon svg,
.recent-icon svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.history-card {
  padding-bottom: 16px;
}

.table-toolbar {
  margin-bottom: 14px;
}

.mini-search {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  width: min(280px, 100%);
  height: 40px;
  padding: 0 12px;
  color: var(--subtle);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
}

.mini-search svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.mini-search input {
  min-width: 0;
  color: var(--text);
  border: 0;
  outline: 0;
  background: transparent;
}

.table-wrap {
  width: 100%;
  min-width: 0;
  overflow-x: auto;
}

.history-table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
}

.history-card .history-table {
  min-width: min(620px, 100%);
  table-layout: fixed;
}

.history-card .history-table th,
.history-card .history-table td {
  overflow: hidden;
  text-overflow: ellipsis;
}

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

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

.history-card .history-table th:nth-child(4),
.history-card .history-table td:nth-child(4) {
  width: 118px;
}

.history-card .history-table th:nth-child(5),
.history-card .history-table td:nth-child(5) {
  width: 92px;
}

.history-card .history-table th:nth-child(6),
.history-card .history-table td:nth-child(6) {
  width: 72px;
}

.history-table th,
.history-table td {
  height: 48px;
  padding: 0 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.history-table th {
  color: #3e4a63;
  background: #f5f7fb;
  font-size: 13px;
  font-weight: 700;
}

.select-col,
.select-cell {
  width: 44px;
  text-align: center;
}

.history-table tbody tr {
  cursor: pointer;
}

.history-table tbody tr:hover,
.history-table tbody tr.selected-row {
  background: #f7faff;
}

.sortable-header {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
  font: inherit;
  font-weight: 800;
}

.sortable-header.active {
  color: var(--blue);
}

.history-table td {
  color: #34405a;
  font-size: 14px;
}

.title-cell {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-card .title-cell {
  max-width: none;
  white-space: normal;
}

.title-cell strong,
.title-cell small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.abnormal-reason {
  margin-top: 4px;
  color: #d72632;
  font-size: 12px;
  font-weight: 700;
  white-space: normal;
}

.title-cell .abnormal-reason {
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
}

.abnormal-panel {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding: 12px;
  color: #d72632;
  background: #fff0f1;
  border: 1px solid rgba(215, 38, 50, 0.18);
  border-radius: 8px;
}

.abnormal-panel strong {
  font-size: 14px;
}

.abnormal-panel ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
  color: #34405a;
  font-size: 13px;
  line-height: 1.5;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 6px;
  font-weight: 700;
}

.status-imported,
.status-completed,
.status-reviewed {
  color: #087a66;
  background: #e8f8f5;
}

.status-processing,
.status-pending {
  color: #c96903;
  background: #fff4e8;
}

.status-abnormal,
.status-failed,
.status-error {
  color: #d72632;
  background: #fff0f1;
}

.action-group {
  display: inline-flex;
  gap: 8px;
}

.action-icon {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  color: #273452;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.action-icon:hover {
  color: var(--blue);
  border-color: var(--blue);
}

.table-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 14px;
}

.bulk-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
  padding: 10px 12px;
  color: var(--blue);
  background: var(--blue-soft);
  border: 1px solid rgba(35, 109, 255, 0.18);
  border-radius: 8px;
}

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

.pagination {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.page-button {
  min-width: 34px;
  height: 34px;
  color: #35415c;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
}

.page-button.active {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
}

.action-bar {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 14px;
  padding: 16px;
}

.primary-action,
.secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 58px;
  padding: 0 18px;
  color: var(--text);
  border: 0;
  border-radius: 8px;
  background: #f8fafc;
  font-size: 18px;
  font-weight: 800;
  white-space: nowrap;
}

.primary-action {
  color: #fff;
  background: linear-gradient(135deg, var(--blue), #7d43ec);
}

.secondary-action:hover {
  color: var(--blue);
  background: #eef5ff;
}

.primary-action svg,
.secondary-action svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

.report-group {
  display: grid;
  gap: 16px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(224, 231, 242, 0.92);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.report-date-group {
  display: grid;
  gap: 12px;
}

.date-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}

.date-heading strong {
  color: var(--text);
  font-size: 16px;
}

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

.report-card {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(160px, 0.7fr) auto;
  gap: 14px;
  align-items: center;
  min-height: 92px;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.report-card-main,
.report-card-metrics {
  min-width: 0;
}

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

.report-card-main h3 {
  margin-top: 8px;
  overflow: hidden;
  color: var(--text);
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.report-card-main p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.report-card-metrics {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.report-card-metrics strong {
  color: var(--text);
}

.report-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
}

.compact-action {
  min-height: 44px;
  padding: 0 14px;
  font-size: 14px;
}

.history-filters {
  padding-bottom: 18px;
}

.history-active-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 10px 12px;
  color: #d72632;
  background: #fff0f1;
  border: 1px solid rgba(215, 38, 50, 0.18);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
}

.history-active-filter span,
.history-active-filter em {
  color: var(--muted);
  font-style: normal;
  font-weight: 600;
}

.history-active-filter .rail-link {
  margin-left: auto;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
}

.filter-field {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.filter-field input,
.filter-field select {
  width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0 11px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  outline: 0;
}

.filter-field input:focus,
.filter-field select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(35, 109, 255, 0.12);
}

.filter-field-wide {
  grid-column: span 2;
}

.detail-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  margin-bottom: 16px;
  padding: 22px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(224, 231, 242, 0.92);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.detail-title-block {
  min-width: 0;
}

.detail-title-block h2,
.detail-title-block p {
  margin: 0;
}

.detail-title-block h2 {
  margin-top: 10px;
  font-size: 22px;
}

.detail-title-block p {
  margin-top: 6px;
  color: var(--muted);
}

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

.detail-grid > .card:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.file-list,
.event-list,
.summary-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.file-list a {
  display: grid;
  grid-template-columns: 22px minmax(110px, 0.4fr) minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 42px;
  color: var(--text);
}

.file-list small {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.payload-code {
  max-height: 360px;
  margin: 14px 0 0;
  padding: 14px;
  overflow: auto;
  color: #1d2945;
  background: #f6f9ff;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.6;
}

.event-list li {
  padding: 12px;
  background: #f8fbff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.event-list strong,
.event-list span {
  display: inline-block;
  margin-right: 8px;
}

.event-list span {
  color: var(--muted);
  font-size: 13px;
}

.event-list p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.payload-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(11, 21, 51, 0.22);
}

.payload-preview {
  position: fixed;
  top: 98px;
  right: 28px;
  z-index: 55;
  display: grid;
  gap: 12px;
  width: min(520px, calc(100vw - 56px));
  max-height: calc(100vh - 126px);
  padding: 20px;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(24, 35, 61, 0.22);
}

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

.auth-mode .sidebar,
.auth-mode .topbar {
  display: none;
}

.auth-mode .workspace {
  margin-left: 0;
}

.auth-mode .main-view {
  min-height: 100vh;
  padding: 0;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  background: #f4f7fb;
}

.auth-panel {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid #d8e1ec;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 16px 40px rgba(25, 42, 70, 0.08);
}

.auth-kicker {
  margin: 0 0 8px;
  color: #50657f;
  font-size: 13px;
}

.auth-form {
  display: grid;
  gap: 16px;
}

.auth-form label {
  display: grid;
  gap: 6px;
  color: #25364d;
  font-size: 14px;
}

.auth-form input {
  min-height: 40px;
  border: 1px solid #cbd6e2;
  border-radius: 6px;
  padding: 8px 10px;
}

.auth-form button,
.admin-form button,
.admin-table button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  padding: 8px 12px;
  background: #1f6feb;
  color: #ffffff;
  cursor: pointer;
}

.auth-error {
  min-height: 20px;
  margin: 0;
  color: #b42318;
}

.chip-logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid #cbd6e2;
  border-radius: 6px;
  background: #ffffff;
  color: #25364d;
  padding: 6px 12px;
  white-space: nowrap;
}

.admin-shell {
  display: grid;
  gap: 20px;
  color: #1e2a3a;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-grid {
  display: grid;
  gap: 20px;
}

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

.admin-panel {
  border: 1px solid #d8e1ec;
  border-radius: 8px;
  padding: 20px;
  background: #ffffff;
}

.admin-table td select[data-semantic-key] {
  width: 100%;
  min-height: 36px;
  border: 1px solid #cbd6e2;
  border-radius: 6px;
  padding: 6px 8px;
  background: #ffffff;
}

.admin-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
}

.admin-form input,
.admin-form select {
  min-height: 38px;
  border: 1px solid #cbd6e2;
  border-radius: 6px;
  padding: 8px 10px;
}

.admin-table-wrap {
  overflow-x: auto;
  border: 1px solid #d8e1ec;
  border-radius: 8px;
  background: #ffffff;
}

.admin-table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  border-bottom: 1px solid #e5edf5;
  padding: 10px;
  text-align: left;
}

.settings-item {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 16px;
  min-height: 128px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(224, 231, 242, 0.92);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.settings-icon {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border-radius: 8px;
}

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

.settings-item h2 {
  font-size: 15px;
}

.settings-item strong {
  display: block;
  margin-top: 10px;
  overflow-wrap: anywhere;
  font-size: 18px;
}

.settings-item p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.6;
}

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

.comparison-controls {
  padding-bottom: 18px;
}

.comparison-column {
  display: grid;
  gap: 14px;
  min-width: 0;
  padding: 18px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(224, 231, 242, 0.92);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.kpi-grid-compact {
  grid-template-columns: repeat(2, minmax(140px, 1fr));
}

.comparison-delta-table {
  min-width: 780px;
}

.object-delta-table {
  min-width: 1120px;
  table-layout: fixed;
}

.object-delta-table th:nth-child(1),
.object-delta-table td:nth-child(1) {
  width: 112px;
}

.object-delta-table th:nth-child(2),
.object-delta-table td:nth-child(2) {
  width: 360px;
}

.object-delta-table th:nth-child(3),
.object-delta-table td:nth-child(3),
.object-delta-table th:nth-child(4),
.object-delta-table td:nth-child(4) {
  width: 124px;
}

.object-delta-table th:nth-child(5),
.object-delta-table td:nth-child(5) {
  width: 150px;
}

.object-delta-table th:nth-child(6),
.object-delta-table td:nth-child(6),
.object-delta-table th:nth-child(7),
.object-delta-table td:nth-child(7) {
  width: 125px;
}

.history-table td.object-name-cell {
  max-width: none;
  min-width: 0;
  overflow: hidden;
  white-space: normal;
  font-weight: 700;
}

.object-name-text,
.object-id-text {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.object-id-text {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.object-flow-cell,
.muted-arrow {
  color: var(--muted);
}

.comparison-empty {
  display: grid;
  gap: 12px;
  min-height: 132px;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.comparison-empty p {
  margin: 0;
}

.search-panel {
  position: fixed;
  top: 74px;
  left: calc(var(--side-width) + 24px);
  z-index: 45;
  width: min(520px, calc(100vw - var(--side-width) - 48px));
  max-height: min(560px, calc(100vh - 96px));
  padding: 14px;
  overflow: auto;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(24, 35, 61, 0.22);
}

.search-panel-head,
.search-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.search-panel-head {
  margin-bottom: 10px;
}

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

.search-result {
  width: 100%;
  min-height: 62px;
  padding: 10px 12px;
  text-align: left;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.search-result:hover {
  border-color: rgba(35, 109, 255, 0.32);
  background: var(--blue-soft);
}

.search-result span:first-child {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.search-result strong,
.search-result small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-result small {
  color: var(--muted);
}

.notification-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(11, 21, 51, 0.18);
}

.notification-drawer {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 51;
  display: grid;
  align-content: start;
  gap: 16px;
  width: min(430px, 100vw);
  padding: 22px;
  overflow: auto;
  background: #fff;
  border-left: 1px solid var(--line);
  box-shadow: -20px 0 60px rgba(24, 35, 61, 0.24);
}

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

.notification-card {
  display: grid;
  gap: 4px;
  min-height: 84px;
  padding: 14px;
  border-radius: 8px;
}

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

.notification-section {
  display: grid;
  gap: 10px;
}

.notification-section h3 {
  margin: 0;
  font-size: 15px;
}

.notification-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  padding: 10px 12px;
  text-align: left;
  color: var(--text);
  background: #f8fbff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.notification-item span {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.notification-item small {
  color: var(--muted);
}

.notification-item svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.summary-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 14px;
  align-items: center;
  min-height: 58px;
  padding: 12px;
  background: #f8fbff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.summary-row strong,
.summary-row span {
  display: block;
}

.summary-row span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.compact-list .summary-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.inline-empty {
  display: grid;
  min-height: 88px;
  place-items: center;
  color: var(--muted);
  background: #f8fbff;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  text-align: center;
}

.empty-state,
.loading-state {
  display: grid;
  min-height: calc(100vh - var(--top-height) - 64px);
  place-items: center;
  text-align: center;
}

.empty-panel,
.loading-state {
  width: min(560px, 100%);
  padding: 34px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.empty-panel {
  display: grid;
  justify-items: center;
  gap: 14px;
}

.empty-panel h1,
.empty-panel p,
.loading-state p {
  margin: 0;
}

.empty-panel h1 {
  font-size: 24px;
}

.empty-panel p {
  color: var(--muted);
  line-height: 1.7;
}

.loader {
  display: inline-block;
  width: 30px;
  height: 30px;
  border: 3px solid #dce6f5;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 60;
  max-width: min(360px, calc(100vw - 44px));
  padding: 12px 14px;
  color: #fff;
  background: #18233d;
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(24, 35, 61, 0.22);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1180px) {
  .topbar {
    grid-template-columns: 44px minmax(220px, 1fr) minmax(240px, 320px) 44px;
  }

  .user-chip {
    display: none;
  }

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

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

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

@media (max-width: 920px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar {
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    height: auto;
  }

  .date-range {
    grid-column: 2 / 4;
  }

  .comparison-layout {
    grid-template-columns: 1fr;
  }

  .comparison-shell,
  .detail-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .detail-grid > .card:last-child:nth-child(odd) {
    grid-column: auto;
  }

  .detail-hero,
  .report-card {
    grid-template-columns: minmax(0, 1fr);
  }

  .report-actions {
    justify-content: flex-start;
  }

  .filter-grid,
  .comparison-kind-grid,
  .settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .comparison-tabs {
    grid-template-columns: repeat(3, 1fr);
  }

  .comparison-tabs button {
    min-height: 44px;
    border-left: 0;
    border-bottom: 3px solid transparent;
  }

  .comparison-tabs button.active {
    border-bottom-color: var(--blue);
  }
}

@media (max-width: 760px) {
  :root {
    --side-width: 210px;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 180ms ease;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .workspace {
    margin-left: 0;
  }

  .main-view {
    padding: 18px 14px 26px;
  }

  .topbar {
    gap: 10px;
    padding: 12px 14px;
  }

  .shortcut {
    display: none;
  }

  .date-range {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    padding-right: 10px;
  }

  .date-range svg {
    display: none;
  }

  .kpi-grid,
  .right-rail,
  .action-bar,
  .filter-grid,
  .comparison-kind-grid,
  .settings-grid,
  .kpi-grid-compact {
    grid-template-columns: minmax(0, 1fr);
  }

  .date-preset-bar,
  .bulk-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .search-panel {
    top: 68px;
    left: 14px;
    width: calc(100vw - 28px);
  }

  .filter-field-wide {
    grid-column: auto;
  }

  .report-group,
  .detail-hero,
  .settings-item,
  .comparison-column {
    padding: 16px;
  }

  .payload-preview {
    top: 74px;
    right: 14px;
    width: calc(100vw - 28px);
    max-height: calc(100vh - 88px);
  }

  .kpi-card {
    min-height: 118px;
  }

  .page-title {
    font-size: 22px;
  }
}

@media (max-width: 520px) {
  .topbar {
    grid-template-columns: 40px minmax(0, 1fr);
  }

  .topbar > .icon-button:not(.nav-toggle) {
    display: none;
  }

  .date-range {
    grid-column: 1 / -1;
  }

  .search-box {
    height: 44px;
  }

  .kpi-card {
    grid-template-columns: minmax(0, 1fr) 48px;
    padding: 16px;
  }

  .kpi-icon,
  .recent-icon,
  .empty-icon {
    width: 48px;
    height: 48px;
  }

  .card,
  .rail-card {
    padding: 16px;
  }

  .card-head,
  .table-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .segmented {
    width: 100%;
  }

  .segment-button {
    flex: 1;
  }

  .primary-action,
  .secondary-action {
    min-height: 52px;
    font-size: 16px;
  }

  .summary-row,
  .file-list a {
    grid-template-columns: minmax(0, 1fr);
  }
}
