body {
  font-family: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Noto Sans", "Noto Sans CJK SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  margin: 0;
  background: #f3f4f6;
  color: #111827;
}

.container {
  max-width: 1280px;
  margin: 24px auto;
  padding: 0 16px;
}

.card {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  border: 1px solid #e5e7eb;
  padding: 16px;
  margin-bottom: 16px;
}

h1,
h2,
h3 {
  margin-top: 0;
  font-weight: 700;
}

.header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

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

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

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

.stat-card {
  margin-bottom: 0;
}

.stat-label {
  color: #6b7280;
  font-size: 13px;
}

.stat-value {
  margin-top: 4px;
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
}

.stat-danger .stat-value {
  color: #b91c1c;
}

input,
select,
textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
}

button {
  box-sizing: border-box;
  padding: 9px 12px;
  border-radius: 8px;
  background: #2563eb;
  color: white;
  border: none;
  cursor: pointer;
  width: auto;
  white-space: nowrap;
}

button.secondary {
  background: #4b5563;
}

.table-wrap {
  overflow: auto;
  max-width: 100%;
}

.output-wrap {
  max-height: 420px;
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.table th,
.table td {
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
  padding: 8px;
  font-size: 13px;
  vertical-align: top;
}

.table.sticky-head thead th {
  position: sticky;
  top: 0;
  z-index: 6;
  background: #ffffff;
  box-shadow: inset 0 -1px 0 #e5e7eb;
}

.table.compact-table th,
.table.compact-table td {
  padding: 6px 8px;
  font-size: 13px;
  line-height: 1.25;
  box-sizing: border-box;
}

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

.table tbody tr:nth-child(even) {
  background: #f8fafc;
}

.table tbody tr:hover {
  background: #eef2ff;
}

.refs-cell {
  min-width: 260px;
}

.refs-cell code {
  font-size: 12px;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge.ok {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.badge.warn {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
}

.badge.error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.badge.neutral {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

.upload-grid {
  display: grid;
  gap: 10px;
}

.upload-item {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 10px;
  background: #fbfcfe;
  display: grid;
  gap: 8px;
}

.upload-title {
  font-weight: 700;
}

.upload-controls {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.flash {
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 10px;
}

.flash.success {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.flash.error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.muted {
  color: #6b7280;
}

code {
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 1px 5px;
}

@media (max-width: 1000px) {
  .grid-2,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .upload-controls {
    grid-template-columns: 1fr;
  }
}

/* ---------------- Night mode ---------------- */
body.dark {
  background: #0b1220;
  color: #e5e7eb;
}

body.dark .muted {
  color: #94a3b8;
}

body.dark .card {
  background: #0f172a;
  border-color: #1f2937;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

body.dark input,
body.dark select,
body.dark textarea {
  background: #0b1220;
  color: #e5e7eb;
  border-color: #334155;
}

body.dark .table th,
body.dark .table td {
  border-bottom: 1px solid rgba(148, 163, 184, 0.35);
}

body.dark .table.sticky-head thead th {
  background: #0f172a;
  box-shadow: inset 0 -1px 0 rgba(148, 163, 184, 0.35);
}

body.dark .table tbody tr:nth-child(odd) {
  background: rgba(15, 23, 42, 0.9);
}

body.dark .table tbody tr:nth-child(even) {
  background: rgba(2, 6, 23, 0.55);
}

body.dark .table tbody tr:hover {
  background: rgba(30, 41, 59, 0.85);
}

body.dark code {
  background: rgba(15, 23, 42, 0.75);
  border-color: #334155;
}

body.dark .upload-item {
  background: rgba(15, 23, 42, 0.9);
  border-color: #334155;
}
