:root {
  --bg: #0f1419;
  --card: #1a2332;
  --border: #2a3544;
  --text: #e8edf4;
  --muted: #8899aa;
  --primary: #e94560;
  --primary-hover: #ff5577;
  --success: #00b894;
  --danger: #e74c3c;
  --warning: #f39c12;
  --accent: #0f3460;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* Login */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f1419 0%, #1a2332 50%, #0f3460 100%);
}

.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.login-card .logo { font-size: 3rem; margin-bottom: 0.5rem; }
.login-card h1 { font-size: 1.5rem; margin-bottom: 0.25rem; }
.login-card .subtitle { color: var(--muted); font-size: 0.9rem; margin-bottom: 1.5rem; }
.error-msg { color: var(--danger); font-size: 0.9rem; margin-bottom: 1rem; padding: 0.5rem; background: rgba(231,76,60,0.1); border-radius: 6px; }

.login-card label {
  display: block;
  text-align: left;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
  margin-top: 0.75rem;
}

.login-card input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}

.login-card input:focus {
  outline: none;
  border-color: var(--primary);
}

.login-card .btn { width: 100%; margin-top: 1.5rem; }

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left { display: flex; align-items: center; gap: 0.75rem; }
.logo-sm { font-size: 1.5rem; }
.header h1 { font-size: 1.1rem; font-weight: 600; }
.header-right { display: flex; align-items: center; gap: 1rem; }

/* Layout */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
}

.card-success {
  border-color: var(--success);
  background: linear-gradient(135deg, #1a2332, #0d2a22);
}

.card h2 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  color: var(--text);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.section-header h2 { margin-bottom: 0; }

.route-info { color: var(--muted); font-size: 0.9rem; }
.hint { color: var(--muted); font-size: 0.85rem; margin-bottom: 0.75rem; }

/* Form */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
}

.field { position: relative; }
.field label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.35rem; }

.field input, .field select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
}

.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--primary);
}

.field-btn { display: flex; align-items: flex-end; }

.suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0 0 8px 8px;
  list-style: none;
  max-height: 200px;
  overflow-y: auto;
  z-index: 50;
  display: none;
}

.suggestions li {
  padding: 0.5rem 0.85rem;
  cursor: pointer;
  font-size: 0.9rem;
}

.suggestions li:hover { background: var(--accent); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1.25rem;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover:not(:disabled) { background: #00d4a8; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #ff6b5b; }

.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.85rem; }

.badge {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  border-radius: 20px;
  font-size: 0.8rem;
  background: var(--accent);
  color: var(--muted);
}

.badge.active { background: var(--success); color: white; }
.badge.scanning { background: var(--warning); color: #1a1a1a; }

/* Trains */
.trains-list { display: flex; flex-direction: column; gap: 0.5rem; }

.train-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.train-item:hover { border-color: var(--primary); }
.train-item.selected { border-color: var(--success); background: rgba(0,184,148,0.08); }
.train-item.sold-out { opacity: 0.6; }

.train-item input[type=checkbox] {
  width: 18px;
  height: 18px;
  accent-color: var(--success);
}

.train-time { font-size: 1.1rem; font-weight: 600; min-width: 120px; }
.train-no { color: var(--muted); font-size: 0.85rem; min-width: 80px; }
.train-seats { margin-left: auto; font-size: 0.85rem; }
.train-seats.available { color: var(--success); }
.train-seats.sold-out { color: var(--danger); }

/* Settings */
.settings-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.field-inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.field-inline input, .field-inline select {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}

.action-row { display: flex; gap: 0.75rem; flex-wrap: wrap; }

/* Log */
.log-panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  max-height: 280px;
  overflow-y: auto;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 0.82rem;
}

.log-entry { padding: 0.15rem 0; }
.log-entry.success { color: var(--success); }
.log-entry.error { color: var(--danger); }
.log-entry.warning { color: var(--warning); }
.log-entry.grab { color: #74b9ff; }
.log-entry.info { color: var(--muted); }

/* VNC */
.vnc-frame {
  width: 100%;
  height: 500px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 1rem 0;
  background: #000;
}

#vnc-link { margin-top: 0.5rem; }
