:root {
  color-scheme: light;
  --bg: #eef3f8;
  --panel: #ffffff;
  --line: #d8e1ec;
  --text: #101828;
  --muted: #64748b;
  --primary: #1f5eff;
  --primary-dark: #1749c8;
  --success: #0f766e;
  --warning: #b45309;
  --danger: #b42318;
  --shadow: 0 16px 38px rgba(15, 23, 42, 0.08);
  --soft-shadow: 0 8px 22px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, #f8fbff 0, var(--bg) 280px),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px clamp(18px, 4vw, 46px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset;
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(10px);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 27px;
  line-height: 1.2;
}

h2 {
  font-size: 18px;
  line-height: 1.3;
}

.layout {
  display: grid;
  gap: 20px;
  padding: 24px clamp(18px, 4vw, 46px) 44px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.single-panel {
  border-left: 4px solid #1f5eff;
}

.batch-panel {
  border-left: 4px solid #0f766e;
}

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

.panel-heading p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.split {
  align-items: center;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #f8fafc;
  white-space: nowrap;
}

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

.logout-link {
  text-decoration: none;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #98a2b3;
}

.status-pill.ready .dot {
  background: var(--success);
}

.status-pill.error .dot {
  background: var(--danger);
}

.query-form,
.action-row,
.control-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 160px;
}

.field span,
.field-panel-title {
  color: #344054;
  font-size: 13px;
  font-weight: 650;
}

.grow {
  flex: 1 1 320px;
}

.page-field {
  width: 110px;
  min-width: 110px;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid #cfd7e3;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  border: 1px solid #cfd7e3;
  border-radius: 8px;
  background: #fff;
  color: #243047;
  padding: 8px 14px;
  cursor: pointer;
  transition: 0.15s ease;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
}

.button svg {
  width: 17px;
  height: 17px;
}

.button:hover:not(:disabled) {
  border-color: #9fb0c6;
  background: #f8fafc;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.button.primary:hover:not(:disabled) {
  border-color: var(--primary-dark);
  background: var(--primary-dark);
}

.button.success {
  border-color: var(--success);
  background: var(--success);
  color: #fff;
}

.button.ghost {
  background: #f8fafc;
}

.message {
  min-height: 22px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

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

.table-shell {
  width: 100%;
  margin-top: 12px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid #ecf0f5;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

th {
  background: #f6f8fb;
  color: #344054;
  font-size: 13px;
  font-weight: 700;
  position: sticky;
  top: 0;
}

tbody tr:hover td {
  background: #f9fbff;
}

td {
  color: #263348;
  font-size: 13px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.status-badge.success {
  background: #dff7ef;
  color: #0f766e;
}

.status-badge.notFound {
  background: #fff2cc;
  color: #92400e;
}

.status-badge.failed {
  background: #fee2e2;
  color: #b42318;
}

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

.batch-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(320px, 1.1fr);
  gap: 16px;
}

.upload-zone {
  position: relative;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  min-height: 176px;
  border: 1px dashed #94a3b8;
  border-radius: 10px;
  background: linear-gradient(180deg, #fbfdff, #f7fafc);
  color: var(--muted);
  text-align: center;
  transition: 0.15s ease;
}

.upload-zone:hover {
  border-color: var(--primary);
  background: #f8fbff;
}

.upload-zone svg {
  width: 32px;
  height: 32px;
  color: var(--primary);
}

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

.upload-zone input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.controls {
  display: grid;
  gap: 14px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #344054;
  font-size: 14px;
}

.toggle input,
.field-panel input {
  width: auto;
  min-height: auto;
}

.field-panel {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-top: 18px;
  padding: 12px;
  border: 1px solid #e3e8ef;
  border-radius: 10px;
  background: #fbfcfe;
}

.field-panel label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #344054;
  font-size: 13px;
}

.action-row {
  margin-top: 16px;
}

.progress-wrap {
  margin-top: 16px;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  color: var(--muted);
  font-size: 13px;
}

.progress-track {
  height: 10px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e9eef5;
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 0.2s ease;
}

.batch-table {
  max-height: 560px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.stat-card {
  display: grid;
  gap: 5px;
  padding: 14px 16px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--soft-shadow);
}

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

.stat-card strong {
  color: #111827;
  font-size: 24px;
  line-height: 1.1;
}

.stat-card.good {
  border-color: #b7e4d9;
  background: #f3fbf8;
}

.stat-card.warn {
  border-color: #f5d59a;
  background: #fffaf0;
}

.stat-card.bad {
  border-color: #fecaca;
  background: #fff7f7;
}

.table-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--soft-shadow);
}

.table-toolbar > div {
  display: grid;
  gap: 4px;
}

.table-toolbar strong {
  font-size: 15px;
}

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

.compact-field {
  min-width: 150px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  display: none;
  max-width: min(420px, calc(100vw - 40px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  color: #263348;
}

.toast.show {
  display: block;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.login-panel h1 {
  margin-bottom: 4px;
}

@media (max-width: 820px) {
  .topbar,
  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .batch-grid {
    grid-template-columns: 1fr;
  }

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

  .table-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  .button {
    width: 100%;
  }

  .query-form .button,
  .action-row .button {
    flex: 1 1 180px;
  }
}

@media (min-width: 1180px) {
  .layout {
    grid-template-columns: minmax(360px, 0.75fr) minmax(720px, 1.45fr);
    align-items: start;
  }

  .single-panel {
    position: sticky;
    top: 104px;
  }
}
