:root {
  --bg-dark: #0a0d14;
  --bg-card: #121722;
  --bg-card-hover: #171d2b;
  --bg-card-expanded: #151a26;
  --border: #1f2738;
  --border-focus: #3b82f6;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --accent: #8b5cf6;
  --text-main: #f1f5f9;
  --text-muted: #8492a6;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg-dark);
  color: var(--text-main);
  line-height: 1.5;
  user-select: none;
  overflow-x: hidden;
}

.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 24px 32px;
  max-width: 1040px;
  margin: 0 auto;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-box {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #2563eb, #8b5cf6);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.3);
}

.app-title {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.domain-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: #60a5fa;
  margin-top: 2px;
}

.pulse-indicator {
  width: 8px;
  height: 8px;
  background: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--success);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.proxy-badge {
  background: #151a26;
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.badge-val {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: #38bdf8;
}

/* Sub bar */
.sub-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 20px 0 16px;
  gap: 16px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 14px;
  flex: 1;
  max-width: 400px;
  color: var(--text-muted);
  transition: border-color 0.2s;
}

.search-box:focus-within {
  border-color: var(--border-focus);
}

.search-box input {
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 14px;
  width: 100%;
  outline: none;
}

.stats-counter {
  font-size: 13px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* MCP List & Accordion */
.mcp-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mcp-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.2s ease;
}

.mcp-item:hover {
  border-color: #2e3b52;
}

.mcp-item.expanded {
  background: var(--bg-card-expanded);
  border-color: #3b4d6b;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.mcp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  cursor: pointer;
  user-select: none;
}

.mcp-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.port-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #475569;
  flex-shrink: 0;
  transition: background 0.3s;
}

.port-status-dot.online {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.port-status-dot.offline {
  background: #64748b;
}

.mcp-name-label {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.mcp-url-badge {
  font-family: var(--font-mono);
  font-size: 13px;
  color: #93c5fd;
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.25);
  padding: 4px 10px;
  border-radius: 6px;
}

.mcp-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.port-tag {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  background: #1a2130;
  padding: 4px 8px;
  border-radius: 6px;
}

.chevron-icon {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  transition: transform 0.25s ease;
}

.mcp-item.expanded .chevron-icon {
  transform: rotate(180deg);
  color: var(--primary);
}

/* Accordion Foldout Body */
.mcp-body {
  display: none;
  padding: 0 20px 20px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
  animation: fadeIn 0.2s ease;
}

.mcp-item.expanded .mcp-body {
  display: block;
}

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

.foldout-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 16px;
}

.foldout-cell {
  background: #0f131c;
  border: 1px solid #1a2233;
  padding: 12px 14px;
  border-radius: 8px;
}

.cell-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.cell-value {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-main);
  word-break: break-all;
}

.foldout-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed #1e2638;
}

.actions-left, .actions-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  border: none;
  outline: none;
  transition: all 0.2s ease;
}

.btn-primary {
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #fff;
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #1d4ed8, #2563eb);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.45);
}

.btn-secondary {
  background: #1a2233;
  color: var(--text-main);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: #232c40;
  border-color: #334155;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: #ef4444;
}

.btn-icon {
  background: #1a2233;
  border: 1px solid var(--border);
  color: var(--text-main);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: background 0.2s;
}

.btn-icon:hover {
  background: #253047;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 100;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: #131722;
  border: 1px solid #232d42;
  border-radius: 14px;
  width: 90%;
  max-width: 480px;
  padding: 24px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  transform: translateY(12px);
  transition: transform 0.2s ease;
}

.modal-overlay.active .modal-card {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-header h3 {
  font-size: 17px;
  font-weight: 700;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 10px 14px;
  background: #0b0e14;
  border: 1px solid #202838;
  border-radius: 8px;
  color: var(--text-main);
  font-size: 14px;
  outline: none;
  font-family: var(--font-sans);
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: var(--primary);
}

.input-with-action {
  display: flex;
  gap: 8px;
}

.form-hint {
  display: block;
  font-size: 11px;
  color: #64748b;
  margin-top: 5px;
}

.url-preview-box {
  background: #090c12;
  border: 1px solid #1c2333;
  border-radius: 8px;
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: #38bdf8;
  word-break: break-all;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1e293b;
  border: 1px solid #334155;
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 200;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}
