:root {
  --bg: #f3f5f8;
  --panel: #ffffff;
  --line: #dde5ee;
  --line-strong: #c9d4e2;
  --text: #152337;
  --muted: #66758c;
  --primary: #1f6feb;
  --primary-soft: #e9f1ff;
  --success: #198754;
  --success-soft: #eaf8f1;
  --warning: #b7791f;
  --warning-soft: #fff6e6;
  --danger: #c93a4a;
  --danger-soft: #fff0f2;
  --neutral: #5c6b81;
  --neutral-soft: #eef2f7;
  --shadow: 0 12px 26px rgba(17, 29, 48, 0.06);
  --radius: 18px;
  --sidebar: 500px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  margin: 0;
  min-height: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input { font: inherit; }
a { color: inherit; text-decoration: none; }

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

.sidebar {
  background: #f7f9fc;
  border-right: 1px solid var(--line);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
  min-height: 100vh;
}

.brand { display: flex; gap: 12px; align-items: center; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px; background: var(--primary); color: white;
  display: grid; place-items: center; font-weight: 800; letter-spacing: -0.03em; flex: 0 0 auto;
}
.brand h1 { margin: 0; font-size: 24px; letter-spacing: -0.03em; }
.brand p { margin: 4px 0 0; font-size: 13px; line-height: 1.45; color: var(--muted); }

.upload-compact {
  background: white;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  display: grid;
  gap: 10px;
  box-shadow: var(--shadow);
}
.upload-compact-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.upload-compact-head strong {
  font-size: 14px;
  letter-spacing: -0.01em;
}
.upload-compact-note {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
}
.upload-trigger {
  width: 100%;
  justify-content: center;
}

.side-section {
  display: flex; flex-direction: column; gap: 12px; min-height: 0; flex: 1;
}
.side-title {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 800;
}

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.filter-row { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-btn {
  border: 1px solid var(--line-strong); background: white; color: var(--muted); border-radius: 999px;
  padding: 8px 12px; cursor: pointer; font-size: 11.5px; line-height: 1; font-weight: 800;
  min-height: 34px; white-space: nowrap; display: inline-flex; align-items: center; justify-content: center;
}
.filter-btn.active {
  color: var(--primary); border-color: #b9d1ff; background: #f7fbff; box-shadow: inset 0 0 0 1px #d7e5ff;
}

.range-box {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 8px;
  padding: 10px; border: 1px solid var(--line); border-radius: 14px; background: white;
}
.range-box input {
  width: 100%; min-width: 0; border: 1px solid var(--line-strong); background: white; color: var(--text);
  border-radius: 10px; padding: 9px 10px; min-height: 38px;
}
.range-box input.input-error { border-color: var(--danger); }
.range-error {
  grid-column: 1 / -1; color: var(--danger); font-size: 12px; margin: 0; padding: 0 2px;
}
.page-meta-inline {
  margin-left: auto; font-size: 12px; color: var(--muted); align-self: center; white-space: nowrap;
}

.btn {
  border: 1px solid var(--line-strong); background: white; color: var(--text); border-radius: 14px;
  padding: 10px 14px; cursor: pointer; font-weight: 700; transition: 0.16s ease;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; min-width: 0;
}
.btn:hover, .filter-btn:hover, .mini-btn:hover, .batch-main:hover { border-color: #aac1e7; }
.btn-primary {
  background: var(--primary); border-color: var(--primary); color: white; box-shadow: 0 10px 22px rgba(31, 111, 235, 0.18);
}
.btn-danger { background: white; color: var(--danger); border-color: #efc4cb; }
.btn:disabled, .mini-btn:disabled { opacity: 0.48; cursor: not-allowed; box-shadow: none; }

.batch-list {
  display: flex; flex-direction: column; gap: 8px; overflow-y: auto; overflow-x: hidden;
  padding-right: 2px; min-height: 0; flex: 1 1 auto;
}

.batch-main {
  border: 1px solid var(--line); background: white; border-radius: 14px; padding: 12px 14px; cursor: pointer;
  transition: 0.16s ease; display: grid; gap: 6px; text-align: left; width: 100%; min-width: 0;
}
.batch-main.active {
  border-color: #b9d1ff; background: #f7fbff; box-shadow: inset 0 0 0 1px #d7e5ff;
}
.batch-name {
  font-size: 14px; line-height: 1.35; font-weight: 800; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.batch-meta {
  color: var(--muted); font-size: 12px; line-height: 1.45; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.pagination-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 6px;
}
.pagination-meta { font-size: 12px; color: var(--muted); }
.pagination-actions { display: flex; gap: 8px; }
.pagination-actions .btn { min-height: 36px; padding: 8px 12px; font-size: 13px; }

.chip, .stat-pill {
  white-space: nowrap;
  display: inline-flex; align-items: center; gap: 7px; border-radius: 999px; padding: 6px 10px;
  font-size: 12px; font-weight: 700; white-space: nowrap;
}
.chip.info, .stat-pill.info { background: var(--primary-soft); color: var(--primary); }
.chip.success, .stat-pill.success { background: var(--success-soft); color: var(--success); }
.chip.warning, .stat-pill.warning { background: var(--warning-soft); color: var(--warning); }
.chip.danger, .stat-pill.danger { background: var(--danger-soft); color: var(--danger); }
.chip.neutral, .stat-pill.neutral { background: var(--neutral-soft); color: var(--neutral); }

.main { padding: 24px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.overview-card { display: grid; gap: 14px; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; min-width: 0;
}

.section-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.section-head h3 { margin: 0; font-size: 20px; letter-spacing: -0.02em; }
.section-head p { margin: 6px 0 0; color: var(--muted); font-size: 14px; line-height: 1.55; max-width: 760px; }

.metrics-card { display: grid; gap: 14px; }
.grid-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.metric-tile {
  border: 1px solid var(--line); border-radius: 16px; padding: 14px; background: #fbfcfe;
}
.metric-label { color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; font-size: 11px; font-weight: 800; }
.metric-value { margin-top: 10px; font-size: 30px; font-weight: 800; letter-spacing: -0.04em; }
.metric-foot { margin-top: 6px; font-size: 12px; color: var(--muted); line-height: 1.4; }

.content-col { display: grid; gap: 16px; min-width: 0; overflow: hidden; }
.batch-header { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.batch-header h3 { margin: 0; font-size: 20px; letter-spacing: -0.02em; }
.batch-header p { margin: 6px 0 0; font-size: 14px; line-height: 1.55; color: var(--muted); }
.subtle-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.batch-level-actions { display: grid; gap: 8px; justify-items: end; }
.batch-level-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 800; }

.divider { height: 1px; background: var(--line); margin: 18px 0 14px; }
.selection-bar { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.selection-bar h4 { margin: 0; font-size: 16px; }
.selection-bar p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.table-wrap { overflow-x: auto; overflow-y: visible; border: 1px solid var(--line); border-radius: 16px; width: 100%; }
table { width: 100%; min-width: 1040px; border-collapse: collapse; background: white; }
thead th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: #7b8ba2;
  background: #fbfcfe; padding: 14px 16px; border-bottom: 1px solid var(--line);
}
tbody td { padding: 14px 16px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
.cell-muted { color: var(--muted); font-size: 13px; line-height: 1.45; }
.status-stack { display: grid; gap: 8px; }
.inline-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.mini-btn {
  border: 1px solid var(--line-strong); border-radius: 10px; background: white; padding: 7px 10px; font-size: 12px;
  font-weight: 700; cursor: pointer; min-height: 32px;
}
.empty-note { color: var(--muted); font-size: 13px; line-height: 1.55; }
.footer { color: var(--muted); text-align: center; font-size: 13px; padding-top: 4px; }

.toast {
  position: fixed; right: 22px; bottom: 22px; min-width: 260px; max-width: 460px; background: #17263a; color: white;
  padding: 14px 16px; border-radius: 14px; box-shadow: 0 14px 32px rgba(12, 21, 34, 0.24); opacity: 0;
  transform: translateY(8px); pointer-events: none; transition: 0.2s ease; font-size: 13px; line-height: 1.5; z-index: 20;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); }

@media (max-width: 1180px) {
  .grid-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); min-height: auto; }
  .main { padding: 18px; }
  .batch-list { max-height: 360px; }
}
@media (max-width: 640px) {
  .grid-metrics { grid-template-columns: 1fr; }
  .range-box { grid-template-columns: 1fr; }
}

/* ── Login overlay ── */
.login-overlay {
  position: fixed; inset: 0;
  background: var(--bg);
  display: grid; place-items: center;
  z-index: 1000;
}
.login-card {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 36px 32px;
  width: 100%; max-width: 380px;
  box-shadow: var(--shadow);
}
.login-field {
  display: grid; gap: 6px;
  margin-bottom: 14px;
}
.login-field label {
  font-size: 13px; font-weight: 600; color: var(--text);
}
.login-field input {
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: border-color 0.15s;
}
.login-field input:focus { border-color: var(--primary); }
.login-error {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 10px;
}
