:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel2: #1e222b;
  --border: #2a2f3a;
  --text: #e5e7eb;
  --muted: #8b93a3;
  --accent: #4f8cff;
  --accent2: #22c55e;
  --danger: #ef4444;
  --warn: #f59e0b;
  font-family: -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
}
.login-box {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 32px;
  border-radius: 12px;
  width: 300px;
  text-align: center;
}
.login-box h1 { font-size: 18px; margin-bottom: 20px; }
.login-box input {
  width: 100%;
  padding: 10px;
  margin-bottom: 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
}
.login-box button {
  width: 100%;
  padding: 10px;
  border-radius: 6px;
  border: none;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 600;
}
.error { color: var(--danger); font-size: 13px; }

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h1 { font-size: 16px; margin: 0; white-space: nowrap; }
.tabs { display: flex; gap: 6px; flex: 1; }
.tab-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
.tab-btn.active { background: var(--accent); color: white; border-color: var(--accent); }
.logout { color: var(--muted); font-size: 13px; text-decoration: none; }
.logout:hover { color: var(--text); }

main { padding: 24px; max-width: 1200px; margin: 0 auto; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}
.card h2 { font-size: 15px; margin: 0 0 12px; }
.hint { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 0 0 12px; }

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

button {
  background: var(--panel2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: white; font-weight: 600; }
button.secondary { background: var(--panel2); border-color: var(--accent2); color: var(--accent2); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

select, input[type=text] {
  background: var(--panel2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
}
input[type=text] { flex: 1; min-width: 200px; }

.debug-box {
  background: #0a0c10;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-size: 12px;
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: #9fe6a0;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.tile {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.tile img {
  width: 100%;
  height: 220px;
  object-fit: cover;
  background: #0a0c10;
}
.tile .tile-body { padding: 10px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.tile .tile-title { font-size: 13px; font-weight: 600; line-height: 1.3; }
.tile .tile-meta { font-size: 11px; color: var(--muted); }
.tile-actions { margin-top: auto; display: flex; gap: 6px; }
.tile-actions button { flex: 1; font-size: 12px; padding: 7px; }
.tile.queued { border-color: var(--accent2); }
.tile.queued .tile-actions button {
  background: rgba(34, 197, 94, 0.12);
  border-color: var(--accent2);
  color: var(--accent2);
}
.tile.queued .tile-actions button:hover {
  background: rgba(239, 68, 68, 0.12);
  border-color: var(--danger);
  color: var(--danger);
}
.tile input[type=checkbox] { transform: scale(1.2); margin-right: 4px; }

.progress-wrap { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.progress-bar {
  flex: 1;
  height: 10px;
  background: var(--panel2);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.progress-fill { height: 100%; width: 0%; background: var(--accent2); transition: width 0.2s; }
#progressText { font-size: 12px; color: var(--muted); white-space: nowrap; }

.queue-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.queue-table th, .queue-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.queue-table th { color: var(--muted); font-weight: 600; font-size: 12px; }
.status-pending { color: var(--muted); }
.status-running { color: var(--warn); }
.status-ok { color: var(--accent2); }
.status-error { color: var(--danger); }
.small-btn { padding: 4px 8px; font-size: 11px; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: min(800px, 92vw);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
}
.modal-body {
  margin: 0;
  border: none;
  border-radius: 0;
  max-height: none;
  flex: 1;
  overflow: auto;
  padding: 16px;
}

#toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
}
.toast-msg {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  min-width: 220px;
}
.toast-msg.error { border-left-color: var(--danger); }
.toast-msg.success { border-left-color: var(--accent2); }
