* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #00d4ff;
  --primary-dark: #00b8d4;
  --primary-glow: rgba(0, 212, 255, 0.15);
  --bg-dark: #0a0e17;
  --bg-darker: #06080f;
  --bg-card: #111827;
  --bg-input: #0f172a;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #475569;
  --border: #1e293b;
  --border-light: rgba(30, 41, 59, 0.5);
  --danger: #ef4444;
  --success: #22c55e;
}

html {
  scrollbar-width: none;
}

html::-webkit-scrollbar {
  display: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

/* Connect Page */
#ssh-connect-page {
  min-height: 100vh;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  padding: 0 24px;
  background: var(--bg-darker);
  border-bottom: 1px solid var(--border);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
}

.header-brand .icon {
  color: var(--primary);
  font-size: 16px;
}

.header-status {
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 10px;
  background: var(--bg-card);
  border-radius: 6px;
  border: 1px solid var(--border);
}

.main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  gap: 16px;
}

.main h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

/* Form */
.form {
  width: 100%;
  max-width: 480px;
  background: var(--bg-card);
  padding: 20px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row .field:first-child {
  flex: 2;
}

.form-row .field:last-child {
  flex: 1;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.field input,
.field textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--primary);
}

.field input::placeholder,
.field textarea::placeholder {
  color: var(--text-muted);
}

.field textarea {
  font-family: 'SF Mono', 'Menlo', monospace;
  font-size: 12px;
  resize: vertical;
}

.auth-switch {
  display: flex;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
}

.auth-switch button {
  flex: 1;
  padding: 8px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
}

.auth-switch button.active {
  background: var(--primary);
  color: var(--bg-dark);
  font-weight: 600;
}

.btn-submit {
  width: 100%;
  padding: 11px;
  background: var(--primary);
  color: var(--bg-dark);
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 4px;
}

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

.btn-submit:disabled {
  background: var(--text-muted);
  cursor: not-allowed;
}

/* Queue */
.queue {
  text-align: center;
  padding: 14px;
  background: rgba(0, 212, 255, 0.05);
  border: 1px solid rgba(0, 212, 255, 0.2);
  border-radius: 10px;
}

.queue::before {
  content: '';
  display: block;
  width: 24px;
  height: 24px;
  margin: 0 auto 8px;
  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); }
}

.queue p {
  font-size: 13px;
  color: var(--text-secondary);
}

/* History */
.history {
  width: 100%;
  max-width: 480px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.history-title {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.history-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.history-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 16px;
  color: var(--text-muted);
  font-size: 13px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.2s;
}

.history-item:hover {
  border-color: var(--primary);
}

.history-item .info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.history-item .icon {
  font-size: 14px;
  flex-shrink: 0;
}

.history-item .text {
  min-width: 0;
}

.history-item .name {
  display: block;
  font-size: 12px;
  font-family: monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item .port {
  font-size: 11px;
  color: var(--text-muted);
}

.history-item .del {
  width: 20px;
  height: 20px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
  flex-shrink: 0;
}

.history-item:hover .del {
  opacity: 1;
}

.history-item .del:hover {
  color: var(--danger);
}

/* Terminal Page */
#terminal-page {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 40px;
  padding: 0 12px;
  background: var(--bg-darker);
  border-bottom: 1px solid var(--border);
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toolbar-brand {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
}

.toolbar-brand .icon {
  color: var(--primary);
}

.toolbar-sep {
  width: 1px;
  height: 14px;
  background: var(--border);
}

.toolbar-info {
  font-size: 12px;
  color: var(--text-secondary);
  font-family: monospace;
}

.toolbar-right {
  display: flex;
  gap: 4px;
}

.toolbar-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
}

.toolbar-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
}

.toolbar-btn.danger:hover {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

#terminal {
  flex: 1;
  background: #0d1117;
}

.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 22px;
  padding: 0 12px;
  background: var(--bg-darker);
  border-top: 1px solid var(--border);
}

.status-connected {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--success);
}

.status-connected::before {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--success);
  border-radius: 50%;
}

.status-error {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--danger);
}

.status-error::before {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--danger);
  border-radius: 50%;
}

.status-size {
  font-size: 11px;
  color: var(--text-muted);
  font-family: monospace;
}

/* Error Toast */
.toast {
  position: fixed;
  top: 60px;
  right: 20px;
  z-index: 1000;
  display: flex;
  gap: 10px;
  padding: 14px 16px;
  background: #1c1017;
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  animation: slideIn 0.3s ease;
  max-width: 360px;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.toast-hide {
  animation: slideOut 0.3s ease forwards;
}

@keyframes slideOut {
  to { transform: translateX(100%); opacity: 0; }
}

.toast-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(239, 68, 68, 0.2);
  color: var(--danger);
  border-radius: 50%;
  font-size: 11px;
  font-weight: bold;
  flex-shrink: 0;
}

.toast-body {
  flex: 1;
  min-width: 0;
}

.toast-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--danger);
  margin-bottom: 2px;
}

.toast-msg {
  font-size: 12px;
  color: var(--text-secondary);
  word-break: break-all;
}

.toast-close {
  width: 18px;
  height: 18px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
}

.toast-close:hover {
  color: var(--text-secondary);
}

/* Animations */
.fade-in {
  animation: fadeIn 0.4s ease;
}

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

/* Responsive */
@media (max-width: 480px) {
  .main {
    padding: 16px;
  }

  .form {
    padding: 16px;
  }

  .toast {
    right: 12px;
    left: 12px;
    max-width: none;
  }
}
