:root {
  --bg: #f2f5f7;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --ink: #182230;
  --ink-strong: #0f172a;
  --muted: #5b6472;
  --muted-2: #8892a2;
  --line: #dfe5eb;
  --line-strong: #cbd5e1;
  --primary: #0f766e;
  --primary-hover: #115e59;
  --primary-soft: #e0f2f1;
  --primary-softer: #eef8f7;
  --blue: #2563eb;
  --blue-soft: #e8f0fe;
  --amber: #b45309;
  --amber-soft: #fff7e6;
  --red: #d92d20;
  --red-hover: #b42318;
  --red-soft: #feeceb;
  --green: #15803d;
  --ring: rgba(15, 118, 110, 0.24);
  --topbar-bg: rgba(255, 255, 255, 0.82);
  --filter-bg: rgba(255, 255, 255, 0.9);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.09);
  --radius-panel: 8px;
  --radius-control: 6px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, Arial, sans-serif;
  font-size: 15.5px;
  line-height: 1.55;
}

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

button,
summary,
select,
input[type="checkbox"],
.drop-zone {
  cursor: pointer;
}

button:focus-visible,
summary:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.drop-zone:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

::selection {
  background: var(--primary-soft);
  color: var(--ink-strong);
}

.app-shell {
  max-width: 1480px;
  margin: 0 auto;
  padding: 20px 22px 48px;
}

.topbar {
  position: relative;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 18px;
  margin-bottom: 14px;
  background: var(--topbar-bg);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  backdrop-filter: blur(18px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-sm), inset 0 -1px 0 rgba(15, 23, 42, 0.04);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(15, 118, 110, 0.24);
}

.brand-mark svg {
  width: 21px;
  height: 21px;
}

.brand h1 {
  margin: 0;
  font-size: 23px;
  line-height: 1.25;
  color: var(--ink-strong);
  letter-spacing: 0;
}

.brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13.5px;
}

.meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 13px;
}

.version-chip {
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.kb-switch {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  background: rgba(15, 23, 42, 0.05);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 8px;
}

.kb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 6px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color 160ms ease-out, color 160ms ease-out, box-shadow 160ms ease-out, transform 120ms ease-out;
}

.kb-btn svg {
  width: 15px;
  height: 15px;
}

.kb-btn:hover {
  background: rgba(255, 255, 255, 0.75);
  color: var(--ink);
}

.kb-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(15, 118, 110, 0.24);
}

.kb-btn:active {
  transform: translateY(1px);
}

#wecomUser {
  color: var(--primary);
  font-weight: 600;
}

main {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tab-bar {
  display: flex;
  gap: 6px;
  width: fit-content;
  max-width: 100%;
  padding: 4px;
  background: rgba(15, 23, 42, 0.045);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 10px;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 42px;
  padding: 8px 18px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  transition: background-color 160ms ease-out, color 160ms ease-out, box-shadow 160ms ease-out, transform 120ms ease-out;
}

.tab-btn svg {
  width: 17px;
  height: 17px;
}

.tab-btn:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
}

.tab-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(15, 118, 110, 0.28);
}

.tab-btn:active {
  transform: translateY(1px);
}

.tab-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tab-panel[hidden] {
  display: none;
}

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

.stat-card,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-sm);
}

.stat-card {
  position: relative;
  padding: 14px 16px;
  overflow: hidden;
}

.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--primary);
}

.stat-card .value {
  font-size: 27px;
  font-weight: 700;
  line-height: 1.15;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.stat-card .label {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.chart-launch {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  width: 100%;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  color: inherit;
  cursor: pointer;
  text-align: left;
  transition: border-color 160ms ease-out, box-shadow 160ms ease-out, transform 120ms ease-out;
}

.chart-launch:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.chart-launch:active {
  transform: translateY(1px) scale(0.995);
}

.chart-launch-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
}

.chart-launch-icon svg {
  width: 21px;
  height: 21px;
}

.chart-launch-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chart-launch-text strong {
  color: var(--ink-strong);
  font-size: 16px;
  letter-spacing: 0;
}

.chart-launch-text span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.chart-launch-arrow {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--muted);
  transition: background-color 160ms ease-out, color 160ms ease-out, transform 120ms ease-out;
}

.chart-launch:hover .chart-launch-arrow {
  background: var(--primary-soft);
  color: var(--primary);
}

.chart-launch-arrow svg {
  width: 17px;
  height: 17px;
}

.device-chart {
  display: grid;
  gap: 6px;
}

.chart-row {
  display: grid;
  grid-template-columns: minmax(96px, 150px) minmax(120px, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-control);
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
  transition: background-color 160ms ease-out, transform 120ms ease-out;
}

.chart-row:hover,
.chart-row.active {
  background: var(--primary-softer);
}

.chart-row:active {
  transform: translateY(1px);
}

.chart-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-strong);
  font-size: 14px;
  font-weight: 600;
}

.chart-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e9edf2;
}

.chart-bar {
  display: block;
  height: 100%;
  width: var(--bar);
  border-radius: 999px;
  background: var(--primary);
  transition: width 300ms ease-out, background-color 160ms ease-out;
}

.chart-row:hover .chart-bar,
.chart-row.active .chart-bar {
  background: var(--primary-hover);
}

.chart-count {
  min-width: 34px;
  color: var(--ink-strong);
  font-size: 14px;
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.chart-pct {
  min-width: 42px;
  color: var(--muted);
  font-size: 12.5px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.chart-empty {
  padding: 22px 12px;
  color: var(--muted);
  font-size: 14.5px;
  text-align: center;
}

.chart-overlay {
  width: min(920px, calc(100vw - 32px));
  max-height: min(88vh, 900px);
  padding: 0;
  margin: auto;
  border: 0;
  background: transparent;
  color: var(--ink);
  overflow: visible;
}

.chart-overlay::backdrop {
  background: rgba(10, 16, 24, 0.5);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

.chart-overlay[open] {
  animation: overlay-in 220ms ease-out;
}

.chart-overlay.closing {
  animation: overlay-out 160ms ease-in forwards;
}

.chart-overlay[open] .chart-dialog-card {
  animation: card-in 220ms ease-out;
}

.chart-overlay.closing .chart-dialog-card {
  animation: card-out 160ms ease-in forwards;
}

.chart-dialog-card {
  width: 100%;
  max-height: inherit;
  overflow: auto;
  padding: 22px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  box-shadow: 0 24px 70px rgba(10, 16, 24, 0.24);
}

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

.chart-dialog-header h2 {
  margin: 0;
  color: var(--ink-strong);
  font-size: 21px;
  letter-spacing: 0;
}

.chart-dialog-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.device-chart-large {
  display: grid;
  gap: 12px;
}

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

.chart-summary-item {
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface-soft);
}

.chart-summary-item .value {
  color: var(--primary);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.chart-summary-item .label {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12.5px;
}

.chart-overlay .chart-row {
  grid-template-columns: minmax(120px, 190px) 1fr auto auto;
  gap: 14px;
  padding: 12px 10px;
}

.chart-overlay .chart-label {
  font-size: 15px;
}

.chart-overlay .chart-track {
  height: 12px;
}

.chart-overlay .chart-count {
  min-width: 42px;
  font-size: 17px;
}

.chart-overlay .chart-pct {
  min-width: 52px;
  font-size: 14px;
}

.filters-panel {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 14px;
  background: var(--filter-bg);
  -webkit-backdrop-filter: blur(16px) saturate(170%);
  backdrop-filter: blur(16px) saturate(170%);
  box-shadow: var(--shadow-sm), 0 6px 18px rgba(15, 23, 42, 0.06);
}

.search-box {
  position: relative;
  display: block;
}

.search-box .field-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  width: 17px;
  height: 17px;
  color: var(--muted-2);
  pointer-events: none;
  transform: translateY(-50%);
}

input,
select,
textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: #fff;
  color: var(--ink);
  font-size: 15px;
  outline: none;
  transition: border-color 160ms ease-out, box-shadow 160ms ease-out, background-color 160ms ease-out;
}

input,
select {
  min-height: 42px;
}

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

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

.filter-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.filter-grid label,
.resource-filters label,
.resource-form-grid label,
.edit-form label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
}

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

.resource-filters .search-box {
  margin-top: 5px;
}

.cases-panel,
.resources-panel,
.add-panel {
  padding: 16px;
}

.cases-panel h2,
.resources-panel h2 {
  margin: 0 0 6px;
  font-size: 18px;
  color: var(--ink-strong);
  letter-spacing: 0;
}

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

.panel-title p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

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

[hidden] {
  display: none !important;
}

.ghost-btn,
.primary-btn,
.danger-btn,
.file-download,
.link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: var(--radius-control);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 160ms ease-out, border-color 160ms ease-out, color 160ms ease-out, transform 120ms ease-out, box-shadow 160ms ease-out;
}

.ghost-btn,
.file-download {
  min-height: 38px;
  padding: 7px 13px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 14.5px;
}

.ghost-btn svg,
.primary-btn svg,
.danger-btn svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.ghost-btn:hover,
.file-download:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-softer);
}

.ghost-btn:active,
.primary-btn:active,
.danger-btn:active,
.file-download:active,
.tab-btn:active,
.link-btn:active {
  transform: translateY(1px) scale(0.99);
}

.primary-btn {
  min-width: 110px;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
  font-size: 15px;
  box-shadow: 0 1px 2px rgba(15, 118, 110, 0.2);
}

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

.primary-btn.loading {
  cursor: wait;
  opacity: 0.85;
}

.primary-btn.loading::before {
  content: '';
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
}

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

.danger-btn {
  min-height: 38px;
  padding: 7px 13px;
  border: 1px solid var(--red);
  background: var(--red);
  color: #fff;
  font-size: 14.5px;
}

.danger-btn:hover,
#exitExportMode:hover {
  background: var(--red-hover);
  border-color: var(--red-hover);
  color: #fff;
}

.link-btn {
  min-height: 26px;
  padding: 2px 8px;
  border: 0;
  background: transparent;
  color: var(--primary);
  font-size: 13px;
}

.link-btn:hover {
  background: var(--primary-soft);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.link-btn.danger-text {
  color: var(--red);
}

.link-btn.danger-text:hover {
  background: var(--red-soft);
}

.add-panel summary {
  display: flex;
  align-items: center;
  gap: 12px;
  list-style: none;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink-strong);
}

.add-panel summary::-webkit-details-marker {
  display: none;
}

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

.summary-icon {
  width: 18px;
  height: 18px;
  color: var(--primary);
  transition: transform 180ms ease-out;
}

.add-panel[open] .summary-icon {
  transform: rotate(45deg);
}

.add-panel summary span:last-child {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.add-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.add-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: stretch;
  margin-top: 14px;
}

textarea {
  min-height: 96px;
  padding: 10px;
  resize: vertical;
}

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

.resource-form-grid .span-2 {
  grid-column: span 2;
}

.resource-form-grid .primary-btn {
  align-self: end;
}

.staged-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.staged-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.staged-item {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--surface-soft);
}

.staged-item-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.staged-file {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}

.staged-file svg {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  margin-top: 2px;
  color: var(--primary);
}

.staged-file-title {
  min-width: 0;
}

.staged-file strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-strong);
  font-size: 14.5px;
}

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

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 160ms ease-out, background-color 160ms ease-out, color 160ms ease-out, transform 120ms ease-out;
}

.icon-btn svg {
  width: 16px;
  height: 16px;
}

.icon-btn:hover {
  border-color: var(--red);
  background: var(--red-soft);
  color: var(--red);
}

.icon-btn:active {
  transform: translateY(1px) scale(0.98);
}

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

.staged-grid label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
}

.staged-grid .span-2 {
  grid-column: span 2;
}

.staged-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}

.drop-zone {
  display: grid;
  place-items: center;
  min-height: 88px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-control);
  background: var(--surface-soft);
  color: var(--muted);
  text-align: center;
  padding: 12px;
  font-size: 14.5px;
  transition: border-color 160ms ease-out, background-color 160ms ease-out, color 160ms ease-out;
}

.drop-zone.dragover,
.drop-zone:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-hover);
}

.file-preview {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.file-download {
  min-height: 28px;
  padding: 3px 9px;
  font-size: 13.5px;
}

.status-ok {
  color: var(--green);
}

.status-error {
  color: var(--red);
}

.table-wrap {
  max-height: 68vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

table {
  width: 100%;
  min-width: 1320px;
  border-collapse: separate;
  border-spacing: 0;
  font-variant-numeric: tabular-nums;
}

#casesTable {
  table-layout: fixed;
}

#casesTable th:nth-child(1),
#casesTable td:nth-child(1) {
  width: 36px;
}

#casesTable th:nth-child(2),
#casesTable td:nth-child(2) {
  width: 110px;
}

#casesTable th:nth-child(3),
#casesTable td:nth-child(3) {
  width: 110px;
}

#casesTable th:nth-child(4),
#casesTable td:nth-child(4) {
  width: 130px;
}

#casesTable th:nth-child(5),
#casesTable td:nth-child(5) {
  width: 190px;
}

#casesTable th:nth-child(6),
#casesTable td:nth-child(6),
#casesTable th:nth-child(7),
#casesTable td:nth-child(7),
#casesTable th:nth-child(8),
#casesTable td:nth-child(8) {
  width: 120px;
}

#casesTable th:nth-child(9),
#casesTable td:nth-child(9) {
  width: 110px;
}

#casesTable th:nth-child(6),
#casesTable td:nth-child(6),
#casesTable th:nth-child(7),
#casesTable td:nth-child(7) {
  width: auto;
}

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: rgba(248, 250, 252, 0.94);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0;
}

td {
  font-size: 14.5px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  word-break: break-word;
}

tbody tr {
  transition: background-color 120ms ease-out;
}

tbody tr:hover {
  background: var(--primary-softer);
}

tbody tr.selected {
  background: var(--primary-soft);
}

tbody tr.selected:hover {
  background: #d4eeec;
}

tbody tr.custom-row {
  background: var(--amber-soft);
}

tbody tr.custom-row:hover,
tbody tr.custom-row.selected {
  background: #ffefcf;
}

tbody tr:last-child td {
  border-bottom: 0;
}

th.case-checkbox,
td.case-checkbox,
th.resource-checkbox,
td.resource-checkbox {
  width: 36px;
}

table:not(.export-mode) th.case-checkbox,
table:not(.export-mode) td.case-checkbox,
table:not(.export-resource-mode) th.resource-checkbox,
table:not(.export-resource-mode) td.resource-checkbox {
  display: none;
}

th input[type="checkbox"],
td input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--primary);
}

.type-badge {
  display: inline-block;
  max-width: 100%;
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--blue-soft);
  color: #1d4ed8;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.supplement-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
}

.view-case {
  margin-left: 6px;
}

.empty-cell {
  padding: 28px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 14.5px;
}

.empty-cell span {
  display: block;
  margin-bottom: 12px;
}

td a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
  overflow-wrap: anywhere;
}

.supplement-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.supplement-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface-soft);
}

.supplement-item header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 13px;
}

.supplement-item p {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.detail-overlay {
  width: min(720px, calc(100vw - 32px));
  max-height: min(86vh, 880px);
  padding: 0;
  margin: auto;
  border: 0;
  background: transparent;
  color: var(--ink);
  overflow: visible;
}

.detail-overlay::backdrop {
  background: rgba(10, 16, 24, 0.46);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

.detail-overlay[open] {
  animation: overlay-in 220ms ease-out;
}

.detail-overlay.closing {
  animation: overlay-out 160ms ease-in forwards;
}

.detail-overlay[open] .detail-card {
  animation: card-in 220ms ease-out;
}

.detail-overlay.closing .detail-card {
  animation: card-out 160ms ease-in forwards;
}

.detail-card {
  width: 100%;
  max-height: inherit;
  overflow: auto;
  padding: 20px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  box-shadow: 0 22px 60px rgba(10, 16, 24, 0.22);
}

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.detail-header h2 {
  margin: 0;
  font-size: 20px;
  color: var(--ink-strong);
  letter-spacing: 0;
}

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

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

.edit-form .span-2 {
  grid-column: span 2;
}

.detail-list {
  display: grid;
  gap: 0;
  margin: 0;
}

.detail-list div {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 14px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.detail-list div:last-child {
  border-bottom: 0;
}

.detail-list dt {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.detail-list dd {
  margin: 0;
  font-size: 16.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.table-wrap::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.table-wrap::-webkit-scrollbar-track {
  background: #eef1f4;
}

.table-wrap::-webkit-scrollbar-thumb {
  background: #c6cfd8;
  border-radius: 5px;
}

.table-wrap::-webkit-scrollbar-thumb:hover {
  background: #a9b5c1;
}

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

@keyframes overlay-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes overlay-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes card-out {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(6px) scale(0.985);
  }
}

@media (prefers-reduced-transparency: reduce) {
  .topbar,
  .filters-panel,
  th {
    background: var(--surface);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

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

  .detail-overlay[open],
  .detail-overlay.closing,
  .detail-overlay[open] .detail-card,
  .detail-overlay.closing .detail-card {
    animation: none !important;
  }
}

@media (max-width: 900px) {
  .app-shell {
    padding: 14px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .tab-bar {
    width: 100%;
  }

  .tab-btn {
    flex: 1 1 0;
  }

  .filter-grid,
  .resource-filters {
    grid-template-columns: 1fr;
  }

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

  .panel-title {
    flex-direction: column;
  }

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

  .ghost-btn,
  .primary-btn,
  .danger-btn,
  .file-download {
    min-height: 44px;
  }
}

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

  .meta {
    flex-wrap: wrap;
  }

  .kb-switch {
    width: 100%;
  }

  .kb-btn {
    flex: 1 1 0;
  }

  .resource-form-grid,
  .staged-grid,
  .edit-form {
    grid-template-columns: 1fr;
  }

  .resource-form-grid .span-2,
  .staged-grid .span-2,
  .edit-form .span-2 {
    grid-column: span 1;
  }

  .detail-overlay {
    width: calc(100vw - 20px);
  }

  .chart-overlay {
    width: calc(100vw - 20px);
  }

  .chart-dialog-card {
    padding: 16px;
  }

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

  .chart-overlay .chart-row {
    grid-template-columns: minmax(76px, 1fr) 1fr auto;
    gap: 8px;
  }

  .chart-overlay .chart-pct {
    display: none;
  }

  .detail-header {
    flex-direction: column;
  }

  .detail-list div {
    grid-template-columns: 1fr;
    gap: 4px;
  }

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

  .meta {
    width: 100%;
    justify-content: space-between;
  }
}

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

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

.account-btn {
  min-height: 32px;
  padding: 5px 10px;
  font-size: 13px;
}

.account-name {
  color: var(--ink-strong);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.role-badge {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.role-badge.admin {
  background: var(--amber-soft);
  color: var(--amber);
}

.auth-overlay {
  width: min(460px, calc(100vw - 32px));
}

.auth-card {
  padding: 22px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  margin: 14px 0 8px;
  padding: 3px;
  background: rgba(15, 23, 42, 0.05);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 8px;
}

.auth-tab {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}

.auth-tab.active {
  background: #fff;
  color: var(--ink-strong);
  box-shadow: var(--shadow-sm);
}

.auth-form {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.auth-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13.5px;
}

.auth-form input,
.role-select {
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  background: #fff;
  color: var(--ink);
  font-size: 14.5px;
}

.auth-form input:focus {
  border-color: var(--primary);
  outline: 2px solid var(--ring);
  outline-offset: 0;
}

.auth-message {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.auth-message.error {
  color: var(--red);
}

.auth-message.ok {
  color: var(--green);
}

.user-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.user-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface-soft);
}

.user-meta {
  display: grid;
  min-width: 0;
}

.user-meta strong {
  overflow: hidden;
  color: var(--ink-strong);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-meta span {
  overflow: hidden;
  color: var(--muted);
  font-size: 12.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.role-select {
  min-height: 34px;
  padding: 4px 8px;
  font-size: 13.5px;
}

@media (max-width: 560px) {
  .user-row {
    grid-template-columns: 1fr;
  }

  .account-area,
  .account-info {
    flex-wrap: wrap;
  }
}

.row-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 26px;
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
  transition: background-color 160ms ease-out, border-color 160ms ease-out, color 160ms ease-out, transform 120ms ease-out;
}

.row-action-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-softer);
}

.row-action-btn.danger {
  color: var(--red);
}

.row-action-btn.danger:hover {
  border-color: var(--red);
  background: var(--red-soft);
  color: var(--red-hover);
}

.row-action-btn.file-download {
  min-height: 26px;
  padding: 3px 10px;
  font-size: 13px;
}

.row-action-btn:active {
  transform: translateY(1px) scale(0.99);
}

@media (max-width: 640px) {
  .table-wrap {
    max-height: none;
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  #casesTable,
  #resourcesTable {
    min-width: 0;
    table-layout: auto;
  }

  #casesTable thead,
  #resourcesTable thead {
    display: none;
  }

  #casesTable tbody,
  #resourcesTable tbody {
    display: grid;
    gap: 10px;
  }

  #casesTable tbody tr,
  #resourcesTable tbody tr {
    display: grid;
    gap: 7px;
    padding: 13px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-panel);
    background: #fff;
    box-shadow: var(--shadow-sm);
  }

  #casesTable td,
  #resourcesTable td {
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr);
    align-items: start;
    gap: 10px;
    padding: 0;
    border: 0;
    width: auto !important;
    font-size: 14px;
    line-height: 1.5;
  }

  #casesTable td::before,
  #resourcesTable td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 600;
    padding-top: 2px;
  }

  #casesTable td:nth-child(2)::before {
    content: '日期';
  }

  #casesTable td:nth-child(3)::before {
    content: '编号';
  }

  #casesTable td:nth-child(4)::before {
    content: '设备大类';
  }

  #casesTable td:nth-child(5)::before {
    content: '工作类型';
  }

  #casesTable td:nth-child(6)::before {
    content: '故障现象';
  }

  #casesTable td:nth-child(7)::before {
    content: '解决方案';
  }

  #casesTable td:nth-child(8)::before {
    content: '提案人';
  }

  #casesTable td:nth-child(9)::before {
    content: '操作';
  }

  #resourcesTable td:nth-child(2)::before {
    content: '日期';
  }

  #resourcesTable td:nth-child(3)::before {
    content: '分类';
  }

  #resourcesTable td:nth-child(4)::before {
    content: '设备大类';
  }

  #resourcesTable td:nth-child(5)::before {
    content: '资料名称';
  }

  #resourcesTable td:nth-child(6)::before {
    content: '内容/链接';
  }

  #resourcesTable td:nth-child(7)::before {
    content: '备注';
  }

  #resourcesTable td:nth-child(8)::before {
    content: '文件';
  }

  #resourcesTable td:nth-child(9)::before {
    content: '操作';
  }

  #casesTable td:first-child::before,
  #resourcesTable td:first-child::before {
    content: none;
  }

  #casesTable td:last-child,
  #resourcesTable td:last-child {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
  }

  #casesTable td:last-child::before,
  #resourcesTable td:last-child::before {
    margin-right: auto;
  }

  #casesTable td.case-checkbox,
  #resourcesTable td.resource-checkbox {
    display: none !important;
  }

  #casesTable.export-mode td.case-checkbox,
  #casesTable.case-delete-mode td.case-checkbox,
  #resourcesTable.export-resource-mode td.resource-checkbox,
  #resourcesTable.resource-delete-mode td.resource-checkbox {
    display: flex !important;
  }

  #casesTable .empty-cell,
  #resourcesTable .empty-cell {
    display: block;
    padding: 14px;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius-panel);
    background: #fff;
    text-align: center;
  }

  #casesTable .empty-cell::before,
  #resourcesTable .empty-cell::before {
    content: none;
  }

  #casesTable .type-badge,
  #resourcesTable .type-badge {
    margin: 0;
  }

  #casesTable td a,
  #resourcesTable td a,
  #casesTable td .link-btn,
  #resourcesTable td .link-btn {
    word-break: break-all;
  }
}
