:root {
  --bg: #f3f5fa;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: #dbeafe;
  --danger: #dc2626;
  --ok: #059669;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.07);
  --font:
    ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.25;
}
h1 {
  font-size: 20px;
}
h2 {
  font-size: 18px;
}
h3 {
  font-size: 15px;
  margin-top: 8px;
}
p {
  margin: 0;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}
.error {
  color: var(--danger);
  font-size: 13px;
}

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

input:focus,
select:focus,
button:focus-visible,
a:focus-visible,
.drop-zone:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.25);
  outline-offset: 2px;
}

input[type="text"],
input[type="password"],
input[type="search"],
input[type="number"],
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

input::placeholder {
  color: #94a3b8;
}

/* ---------- login ---------- */

.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(900px 420px at 15% -5%, #dbeafe 0%, transparent 60%),
    radial-gradient(700px 380px at 95% 15%, #ccfbf1 0%, transparent 55%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border-radius: 22px;
  padding: 34px 30px 24px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(226, 232, 240, 0.8);
}

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

.brand-mark {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 26px;
  font-weight: 700;
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.3);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 24px;
}

.login-foot {
  margin-top: 18px;
  text-align: center;
  font-size: 12px;
}

/* ---------- top bar / tabs ---------- */

.topbar {
  background: #0f172a;
  color: #fff;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar .brand-mark {
  width: 38px;
  height: 38px;
  flex-basis: 38px;
  border-radius: 11px;
  font-size: 21px;
}

.topbar h1 {
  font-size: 18px;
}
.topbar .muted {
  color: #94a3b8;
}

.tabs {
  max-width: 1200px;
  margin: 20px auto 0;
  padding: 0 24px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
}

.tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 8px 18px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}

.tab:hover {
  background: #e9eef8;
  color: var(--text);
}
.tab.active {
  background: #0f172a;
  color: #fff;
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.18);
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 24px 56px;
}

.tab-panel {
  display: none;
}
.tab-panel.active {
  display: block;
}

/* ---------- layout ---------- */

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

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(226, 232, 240, 0.7);
}

.card + .card {
  margin-top: 20px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.detail-head {
  align-items: flex-start;
}

/* ---------- buttons ---------- */

.button,
button.primary,
button.ghost,
button.mini {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 8px 14px;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    transform 0.05s ease;
  white-space: nowrap;
}

.button:hover,
button.ghost:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}
.button:active,
button:active {
  transform: translateY(1px);
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
button.primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}
button.primary:disabled {
  opacity: 0.6;
  cursor: wait;
}

button.ghost {
  background: transparent;
}

button.on-dark {
  background: transparent;
  border-color: #334155;
  color: #e2e8f0;
}
button.on-dark:hover {
  background: #1e293b;
  border-color: #475569;
}

button.mini,
.mini {
  padding: 3px 9px;
  font-size: 12px;
  border-radius: 7px;
}

.button.small {
  padding: 6px 11px;
  font-size: 13px;
  border-radius: 8px;
}

button.danger {
  color: var(--danger);
  border-color: #fecaca;
  background: #fff5f5;
}
button.danger:hover {
  background: #fee2e2;
  border-color: #fca5a5;
}

/* ---------- upload ---------- */

.drop-zone {
  border: 2px dashed #cbd5e1;
  border-radius: 14px;
  padding: 26px 16px;
  text-align: center;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    background 0.15s ease;
  background: #fbfdff;
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--accent);
  background: #eff6ff;
}

.drop-icon {
  font-size: 26px;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 8px;
}
.drop-zone p {
  margin: 4px 0;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.row label {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}
.row select {
  flex: 1;
  min-width: 140px;
}

.upload-queue {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.queue-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 11px;
  background: #fbfdff;
}

.queue-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  margin-bottom: 7px;
}

.queue-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-pct {
  color: var(--muted);
  flex: 0 0 auto;
}

.progress {
  height: 6px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #2563eb, #0ea5e9);
  border-radius: 999px;
  transition: width 0.15s linear;
}

/* ---------- file list ---------- */

.search-row {
  display: flex;
  gap: 8px;
  flex: 1;
  justify-content: flex-end;
  min-width: 220px;
}

.search-row input {
  max-width: 240px;
}

.file-list {
  display: flex;
  flex-direction: column;
}

.file-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 2px;
  border-bottom: 1px solid #eef2f7;
  min-width: 0;
}

.file-row:last-child {
  border-bottom: none;
}

.file-icon {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.file-meta {
  flex: 1;
  min-width: 0;
}

.file-name {
  font-weight: 600;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 1px;
}

.file-actions {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
}

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

/* ---------- pickup / batches ---------- */

.pickup-card {
  margin-bottom: 20px;
}

.pickup-form {
  display: flex;
  gap: 10px;
  margin: 14px 0 10px;
  max-width: 520px;
}

.pickup-form input {
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 600;
}

.batch-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.batch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfdff;
  flex-wrap: wrap;
}

.batch-main {
  min-width: 0;
  flex: 1;
}
.batch-title {
  font-weight: 600;
  font-size: 14px;
  word-break: break-all;
}
.batch-sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}
.batch-actions {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.code-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.code-line code {
  background: #0f172a;
  color: #e2e8f0;
  padding: 3px 9px;
  border-radius: 7px;
  letter-spacing: 2px;
  font-size: 13px;
}

/* ---------- admin ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat {
  background: var(--card);
  border: 1px solid rgba(226, 232, 240, 0.7);
  border-radius: 14px;
  padding: 15px 16px;
  box-shadow: var(--shadow);
}

.stat-label {
  color: var(--muted);
  font-size: 12px;
}
.stat-value {
  font-size: 23px;
  font-weight: 700;
  margin-top: 2px;
}
.stat-sub {
  color: var(--muted);
  font-size: 11px;
  margin-top: 3px;
}

.bar {
  height: 7px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 9px;
}

.bar-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #2563eb, #0ea5e9);
  border-radius: 999px;
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.settings-form label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  color: #334155;
}

.settings-form h3 {
  margin: 6px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

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

label.check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

label.check input {
  width: auto;
}

#settings-msg {
  min-height: 18px;
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  background: #0f172a;
  color: #fff;
  padding: 11px 20px;
  border-radius: 12px;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.28);
  z-index: 100;
  max-width: min(90vw, 560px);
  font-size: 14px;
  text-align: center;
}

/* ---------- mobile ---------- */

@media (max-width: 840px) {
  .panel-grid {
    grid-template-columns: 1fr;
  }
  .topbar {
    padding: 13px 16px;
  }
  main {
    padding: 16px 14px 48px;
  }
  .tabs {
    padding: 0 14px;
    margin-top: 14px;
  }
  .card {
    padding: 16px;
  }
  h2 {
    font-size: 17px;
  }
  .search-row {
    width: 100%;
    justify-content: stretch;
  }
  .search-row input {
    max-width: none;
    flex: 1;
  }
  .card-head {
    align-items: flex-start;
  }
  .row-2 {
    grid-template-columns: 1fr;
  }
  .batch-row {
    align-items: flex-start;
  }
  .batch-actions {
    width: 100%;
  }
  .file-row {
    flex-wrap: wrap;
  }
  .file-actions {
    width: 100%;
    justify-content: flex-end;
  }
  .pickup-form {
    flex-direction: column;
  }
  .pickup-form button {
    width: 100%;
  }
  .detail-head {
    flex-direction: column;
  }
  .detail-head .row {
    width: 100%;
  }
}
