:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-2: #243044;
  --border: #2d3a4f;
  --text: #e8edf4;
  --text-muted: #8b9cb3;
  --primary: #ff6900;
  --primary-hover: #ff8533;
  --success: #3dd68c;
  --error: #f87171;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.header {
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, #1a2332 0%, #0f1419 100%);
}

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

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

.layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  padding: 1.25rem 2rem 2rem;
  min-height: calc(100vh - 90px);
}

@media (max-width: 960px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

.config-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  align-items: stretch;
}

@media (max-width: 1100px) {
  .config-row {
    grid-template-columns: 1fr;
  }
}

#server-section {
  display: flex;
  flex-direction: column;
}

#server-section .actions-column {
  margin-top: auto;
  flex-direction: column;
}

#server-section .actions-column .btn {
  width: 100%;
}

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

.card h2 {
  margin: 0 0 1rem;
  font-size: 1.05rem;
  font-weight: 600;
}

.hint {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0 0 1rem;
  line-height: 1.5;
}

.login-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.tab {
  flex: 1;
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.15s;
}

.tab:hover {
  color: var(--text);
  border-color: var(--primary);
}

.tab.active {
  background: rgba(255, 105, 0, 0.15);
  border-color: var(--primary);
  color: var(--primary);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

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

input,
select {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
}

.actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.btn {
  padding: 0.6rem 1.1rem;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s;
}

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

.btn.primary:hover {
  background: var(--primary-hover);
}

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

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

.btn.small {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.qr-area {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 220px;
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

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

.qr-image {
  max-width: 220px;
  max-height: 220px;
  border-radius: 8px;
}

.captcha-image {
  display: block;
  max-height: 60px;
  margin-bottom: 0.75rem;
  border-radius: 4px;
}

.login-link {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--primary);
  font-size: 0.9rem;
  word-break: break-all;
}

.login-url-display {
  margin: 0 0 1rem;
  color: var(--text-muted);
  font-size: 0.75rem;
  word-break: break-all;
  line-height: 1.4;
}

.status {
  margin: 0.75rem 0 0;
  font-size: 0.85rem;
  min-height: 1.2em;
}

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

.status.success {
  color: var(--success);
}

.status.error {
  color: var(--error);
}

.hidden {
  display: none !important;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  background: var(--primary);
  color: #fff;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  vertical-align: middle;
}

.device-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 480px;
  overflow-y: auto;
}

.device-item {
  padding: 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.device-item:hover,
.device-item.selected {
  border-color: var(--primary);
}

.device-item h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}

.device-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.2rem 0.75rem;
  font-size: 0.8rem;
}

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

.device-meta dd {
  margin: 0;
  word-break: break-all;
}

.json-card {
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 500px;
}

.json-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.json-header h2 {
  margin: 0;
}

.json-output {
  flex: 1;
  margin: 0;
  padding: 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: auto;
  font-family: "Cascadia Code", "Fira Code", Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.panel-right .card {
  height: 100%;
}
