:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --border: #2d3a4d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --primary: #58a6ff;
  --primary-hover: #79b8ff;
  --error: #f85149;
  --success: #3fb950;
  --warning: #d29922;
  --agent-bg: #1e2d3d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem;
}

#app {
  width: 100%;
  max-width: 600px;
}

.wide-card {
  max-width: none;
}

@media (min-width: 960px) {
  #app:has(#step-review:not(.hidden)) {
    max-width: 1100px;
  }
}

/* ------------------------------------------------------------------ */
/* Card                                                                */
/* ------------------------------------------------------------------ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
}

.center-card {
  text-align: center;
}

/* ------------------------------------------------------------------ */
/* Typography                                                          */
/* ------------------------------------------------------------------ */

h1 {
  margin: 0 0 0.25rem 0;
  font-size: 1.5rem;
  font-weight: 600;
}

h2 {
  margin: 0 0 0.5rem 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.subtitle {
  margin: 0 0 1.5rem 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.intro {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin: 0 0 1.25rem 0;
}

.text-muted {
  color: var(--text-muted);
}

/* ------------------------------------------------------------------ */
/* Login card (mysterious console)                                    */
/* ------------------------------------------------------------------ */

.login-card {
  position: relative;
  overflow: hidden;
}

.login-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top left, rgba(88, 166, 255, 0.12), transparent 55%);
  opacity: 0.8;
  pointer-events: none;
}

.login-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.login-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), #a371f7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  color: var(--bg);
  box-shadow: 0 0 18px rgba(88, 166, 255, 0.35);
}

.login-title-block {
  display: flex;
  flex-direction: column;
}

.login-title {
  margin: 0;
  font-size: 1.3rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.login-subtitle {
  margin: 0.15rem 0 0 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  font-style: italic;
}

.login-meta {
  margin: 0 0 1.25rem 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.login-form label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Console-style intro text on login */

.login-console {
  margin-bottom: 1.5rem;
  padding: 0.9rem 1rem;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(45, 58, 77, 0.9);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.85rem;
  line-height: 1.6;
}

.console-line {
  margin: 0.1rem 0;
}

.console-line.faint {
  color: var(--text-muted);
}

.console-cursor {
  margin-top: 0.45rem;
  color: var(--primary);
}

.cursor-blink {
  display: inline-block;
  margin-left: 4px;
  animation: cursorBlink 1.1s steps(2, start) infinite;
}

@keyframes cursorBlink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

.subtitle {
  margin: 0 0 1.5rem 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.intro {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin: 0 0 1.25rem 0;
}

.text-muted {
  color: var(--text-muted);
}

/* ------------------------------------------------------------------ */
/* Header row                                                          */
/* ------------------------------------------------------------------ */

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.25rem;
}

.header-row h1 {
  margin: 0;
}

/* ------------------------------------------------------------------ */
/* Form elements                                                       */
/* ------------------------------------------------------------------ */

label {
  display: block;
  margin: 1rem 0 0.35rem 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

input[type="password"],
input[type="file"],
select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font-size: 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
}

input[type="file"] {
  padding: 0.5rem;
}

/* ------------------------------------------------------------------ */
/* Buttons                                                             */
/* ------------------------------------------------------------------ */

button,
a.button {
  display: inline-block;
  margin-top: 1.25rem;
  padding: 0.65rem 1.25rem;
  font-size: 1rem;
  font-weight: 500;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

button:disabled,
button.busy {
  opacity: 0.7;
  cursor: not-allowed;
}

button.primary,
a.button.primary {
  background: var(--primary);
  color: var(--bg);
}

button.primary:hover:not(:disabled),
a.button.primary:hover {
  background: var(--primary-hover);
}

button.secondary {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

button.secondary:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

#login-btn,
#btn-weiter,
#btn-review {
  width: 100%;
}

a.button.primary {
  margin-top: 0.5rem;
}

/* ------------------------------------------------------------------ */
/* Error / status                                                      */
/* ------------------------------------------------------------------ */

.error {
  color: var(--error);
  font-size: 0.9rem;
  margin: 0.5rem 0 0 0;
}

.status-msg {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin: 0.5rem 0 0 0;
}

.next-step {
  margin: 1rem 0 0 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ------------------------------------------------------------------ */
/* Spinner                                                             */
/* ------------------------------------------------------------------ */

.spinner {
  width: 40px;
  height: 40px;
  margin: 1.5rem auto 0;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ------------------------------------------------------------------ */
/* Agent Feed (loading phase)                                          */
/* ------------------------------------------------------------------ */

.agent-feed {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.agent-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.agent-messages {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 80px;
}

.agent-msg {
  font-size: 0.95rem;
  color: var(--text);
  line-height: 1.5;
  animation: fadeIn 0.3s ease-out;
}

.agent-msg.muted {
  color: var(--text-muted);
  font-size: 0.9rem;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.typing-indicator {
  display: inline-flex;
  gap: 4px;
  padding: 4px 0;
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typingDot 1.2s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
  0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
  30% { opacity: 1; transform: scale(1); }
}

/* Progress bar */
.agent-progress {
  margin-top: 1.25rem;
}

.progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  width: 0%;
  transition: width 0.5s ease;
}

/* ------------------------------------------------------------------ */
/* Agent comment (summary phase)                                       */
/* ------------------------------------------------------------------ */

.agent-comment {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  background: var(--agent-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--text);
}

.agent-comment::before {
  content: "F";
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--bg);
  font-weight: 700;
  font-size: 0.8rem;
}

/* ------------------------------------------------------------------ */
/* Summary                                                             */
/* ------------------------------------------------------------------ */

.summary-stats {
  margin: 0 0 1.25rem 0;
}

.summary-big {
  font-size: 1.1rem;
  margin: 0 0 0.75rem 0;
}

.summary-detail {
  margin: 0;
  padding-left: 1.25rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.summary-detail li {
  margin: 0.25rem 0;
}

.summary-intro {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0 0 1.25rem 0;
}

/* ------------------------------------------------------------------ */
/* Review header & footer                                              */
/* ------------------------------------------------------------------ */

.review-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.review-intro {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0.25rem 0 0 0;
}

.review-counter {
  font-size: 0.9rem;
  color: var(--text-muted);
  white-space: nowrap;
  margin: 0;
}

.review-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: 1.25rem;
}

.review-footer .primary {
  margin-top: 0;
}

.review-footer .secondary {
  margin-top: 0;
}

/* ------------------------------------------------------------------ */
/* Unmatched (collapsible list)                                        */
/* ------------------------------------------------------------------ */

.unmatched-section {
  margin-top: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.unmatched-toggle {
  width: 100%;
  padding: 0.6rem 1rem;
  text-align: left;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}

.unmatched-toggle:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}

.unmatched-toggle::before {
  content: "\25B6";
  font-size: 0.7rem;
  transition: transform 0.2s;
}

.unmatched-toggle[aria-expanded="true"]::before {
  transform: rotate(90deg);
}

.unmatched-list {
  max-height: 320px;
  overflow-y: auto;
  padding: 0.5rem 1rem 0.75rem;
  background: rgba(0, 0, 0, 0.15);
  border-top: 1px solid var(--border);
}

.unmatched-list.collapsed {
  display: none;
}

.unmatched-row {
  font-size: 0.85rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}

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

.unmatched-oz {
  font-family: monospace;
  font-weight: 500;
  color: var(--text);
  margin-right: 0.5rem;
}

/* ------------------------------------------------------------------ */
/* Enriched note                                                       */
/* ------------------------------------------------------------------ */

.enriched-note {
  background: rgba(63, 185, 80, 0.1);
  border: 1px solid rgba(63, 185, 80, 0.3);
  border-radius: 8px;
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  color: var(--success);
  margin-bottom: 1rem;
}

/* ------------------------------------------------------------------ */
/* Review table                                                        */
/* ------------------------------------------------------------------ */

.table-wrap {
  overflow-x: auto;
  margin: 0 -0.5rem;
}

.review-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  min-width: 640px;
}

.review-table th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  white-space: nowrap;
}

.review-table td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.review-table .col-pos {
  width: 90px;
  font-family: monospace;
  white-space: nowrap;
}

.review-table .col-title {
  min-width: 160px;
}

.review-table .col-match {
  min-width: 160px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.review-table .col-conf {
  width: 80px;
  text-align: center;
  white-space: nowrap;
}

.review-table .col-action {
  width: 80px;
  text-align: center;
}

/* Group header row */
.group-header td {
  padding: 0.75rem 0.75rem 0.45rem;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--primary);
  border-bottom: 1px solid var(--border);
  background: rgba(88, 166, 255, 0.06);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ------------------------------------------------------------------ */
/* Confidence badges                                                   */
/* ------------------------------------------------------------------ */

.conf-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
}

.conf-high {
  background: rgba(63, 185, 80, 0.15);
  color: var(--success);
}

.conf-mid {
  background: rgba(210, 153, 34, 0.15);
  color: var(--warning);
}

.conf-low {
  background: rgba(248, 81, 73, 0.12);
  color: var(--error);
}

/* ------------------------------------------------------------------ */
/* Checkbox styling                                                    */
/* ------------------------------------------------------------------ */

.toggle-accept {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--primary);
}

/* ------------------------------------------------------------------ */
/* View management                                                     */
/* ------------------------------------------------------------------ */

.view {
  display: block;
}

.view.hidden {
  display: none;
}

.hidden {
  display: none !important;
}
