:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f0f3f9;
  --border: #e2e6ee;
  --text: #1b2333;
  --text-muted: #6b7280;
  --accent: #2563eb;
  --accent-soft: #e8efff;
  --ok: #16a34a;
  --ok-soft: #e8f8ee;
  --warn: #b45309;
  --warn-soft: #fef3e2;
  --danger: #dc2626;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10131b;
    --surface: #171b26;
    --surface-2: #1e2330;
    --border: #2a2f3d;
    --text: #e7eaf1;
    --text-muted: #9aa1b1;
    --accent: #5b8def;
    --accent-soft: #1c2a49;
    --ok: #4ade80;
    --ok-soft: #123423;
    --warn: #fbbf24;
    --warn-soft: #3a2a10;
    --danger: #f87171;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 10px rgba(0, 0, 0, 0.25);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  line-height: 1.5;
  padding-bottom: 3rem;
}

.wrap {
  max-width: 920px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 0;
}

header.app-header {
  padding: 0.5rem 0 1.25rem;
}

header.app-header h1 {
  font-size: 1.5rem;
  margin: 0 0 0.35rem;
}

header.app-header p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.card h2 {
  font-size: 1.05rem;
  margin: 0 0 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card h2 .badge {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
}

.field {
  margin-bottom: 0.9rem;
}

.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--text-muted);
}

select, input[type="file"] {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.88rem;
  background: var(--surface-2);
  transition: border-color 0.15s, background 0.15s;
}

.dropzone.drag-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.file-picked {
  margin-top: 0.6rem;
  font-size: 0.85rem;
  color: var(--text);
}

button {
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  border-radius: 10px;
  border: none;
  padding: 0.65rem 1.1rem;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.05s;
}

button:active { transform: scale(0.98); }

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) { opacity: 0.92; }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-danger-ghost {
  background: transparent;
  color: var(--danger);
  border: 1px solid transparent;
  padding: 0.3rem 0.6rem;
  font-size: 0.82rem;
}

.btn-danger-ghost:hover { background: rgba(220, 38, 38, 0.08); }

.status-msg {
  margin-top: 0.75rem;
  font-size: 0.88rem;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  display: none;
}

.status-msg.show { display: block; }

.status-msg.ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.status-msg.error {
  background: var(--warn-soft);
  color: var(--warn);
}

.progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.9rem;
}

.progress-count {
  font-weight: 700;
  font-size: 1.05rem;
}

.progress-bar-track {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  margin-bottom: 1rem;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.2s ease;
}

.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip {
  font-size: 0.82rem;
  padding: 0.32rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: var(--surface-2);
  white-space: nowrap;
}

.chip.done {
  color: var(--ok);
  background: var(--ok-soft);
  border-color: transparent;
  font-weight: 600;
}

.chip.done::before {
  content: "✓ ";
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

thead th {
  text-align: right;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 0.4rem;
  white-space: nowrap;
}

thead th:first-child, tbody td:first-child {
  text-align: left;
}

tbody td {
  padding: 0.55rem 0.4rem;
  border-bottom: 1px solid var(--border);
  text-align: right;
  white-space: nowrap;
}

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

.table-scroll {
  overflow-x: auto;
}

.empty-hint {
  color: var(--text-muted);
  font-size: 0.88rem;
  text-align: center;
  padding: 1rem 0;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.9rem;
}

.stat-tile {
  background: var(--surface-2);
  border-radius: 12px;
  padding: 1rem;
  text-align: center;
}

.stat-tile .stat-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.stat-tile .stat-value {
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.summary-warn {
  margin-top: 0.9rem;
  font-size: 0.85rem;
  color: var(--warn);
  background: var(--warn-soft);
  border-radius: 10px;
  padding: 0.6rem 0.75rem;
}

.card-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.upload-actions {
  display: flex;
  gap: 0.6rem;
}

footer.app-footer {
  max-width: 920px;
  margin: 0 auto;
  padding: 0.5rem 1.25rem 2rem;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-align: center;
}

@media (max-width: 560px) {
  .summary-grid { grid-template-columns: 1fr; }
  thead th, tbody td { font-size: 0.82rem; }
}
