:root {
  color-scheme: light dark;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #1a2230;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1420;
    --surface: #171f2e;
    --text: #e5e9f0;
    --muted: #94a3b8;
    --border: #2a3344;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, Segoe UI, Roboto, sans-serif; background: var(--bg); color: var(--text); }
.view { min-height: 100vh; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
h1 { margin: 0 0 4px; font-size: 1.4rem; }
h2 { margin: 0 0 12px; font-size: 1.05rem; }
.muted { color: var(--muted); font-size: 0.9rem; }
.error { color: var(--danger); font-size: 0.9rem; }

.login-card { max-width: 360px; margin: 10vh auto; display: flex; flex-direction: column; gap: 10px; }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; }
input, button { font: inherit; }
input[type=text], input[type=password], input:not([type]) {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; background: transparent; color: var(--text);
}
button {
  padding: 8px 14px; border-radius: 6px; border: none; background: var(--primary); color: #fff; cursor: pointer;
}
button:hover { background: var(--primary-hover); }
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
button.danger { background: var(--danger); }

.topbar { display: flex; align-items: center; gap: 16px; padding: 12px 20px; background: var(--surface); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.brand { font-weight: 700; letter-spacing: 0.02em; }
.nav-links { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.nav-btn { background: transparent; color: var(--muted); border: 1px solid transparent; }
.nav-btn.active { background: var(--bg); color: var(--text); border-color: var(--border); }

main { padding: 20px; max-width: 1200px; margin: 0 auto; }
.tab[hidden] { display: none; }
.grid { display: grid; gap: 16px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid.two-col { grid-template-columns: 1fr 1fr; }
@media (max-width: 800px) { .grid.two-col { grid-template-columns: 1fr; } }

.stat { text-align: center; }
.stat-value { display: block; font-size: 1.8rem; font-weight: 700; }
.stat-label { color: var(--muted); font-size: 0.85rem; }

.toolbar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; align-items: center; }
.toolbar input { flex: 1; min-width: 160px; }

.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table th, .data-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.data-table th { color: var(--muted); font-weight: 600; }
.table-scroll { overflow-x: auto; max-height: 400px; overflow-y: auto; }

.button-link { display: inline-block; padding: 8px 14px; border-radius: 6px; border: 1px solid var(--border); color: var(--text); text-decoration: none; }

.progress-bar { height: 10px; background: var(--border); border-radius: 6px; overflow: hidden; margin-bottom: 8px; }
.progress-fill { height: 100%; background: var(--primary); width: 0%; transition: width 0.3s; }

.badge { padding: 2px 8px; border-radius: 999px; font-size: 0.75rem; }
.badge.success { background: color-mix(in srgb, var(--success) 20%, transparent); color: var(--success); }
.badge.failed { background: color-mix(in srgb, var(--danger) 20%, transparent); color: var(--danger); }
.badge.pending, .badge.processing { background: color-mix(in srgb, var(--muted) 20%, transparent); color: var(--muted); }

.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; }
.modal-overlay[hidden] { display: none; }
.modal { max-width: 420px; width: 90%; }
#modal-body { display: flex; flex-direction: column; gap: 12px; }
#modal-body label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
