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

:root {
  --bg: #09090b;
  --surface: #0f0f10;
  --surface-2: #18181b;
  --surface-3: #27272a;
  --border: #1f1f23;
  --border-hover: #2a2a30;
  --text: #fafafa;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --success: #22c55e;
  --warning: #eab308;
  --danger: #ef4444;
  --radius: 8px;
  --radius-sm: 6px;
  --radius-xs: 4px;
  --transition: 120ms ease;
}

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection { background: var(--text); color: var(--bg); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #3f3f46; }

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 50;
}

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

.logo-mark {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-mark svg { width: 16px; height: 16px; color: var(--bg); stroke: var(--bg); }

.logo-text { display: flex; flex-direction: column; line-height: 1; }
.logo-text h1 { font-size: 0.938rem; font-weight: 600; letter-spacing: -0.01em; }
.logo-text span {
  font-size: 0.688rem;
  color: var(--text-muted);
  margin-top: 3px;
  font-weight: 400;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--text);
  color: var(--bg);
  border: 1px solid var(--text);
  border-radius: var(--radius-sm);
  font-size: 0.813rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity var(--transition);
  font-family: inherit;
  height: 34px;
}

.btn-primary:hover { opacity: 0.85; }
.btn-primary:active { opacity: 0.75; }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-full { width: 100%; justify-content: center; height: 38px; }

.header-actions { display: flex; align-items: center; gap: 8px; }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}

.btn-icon:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-hover); }
.btn-icon.hidden { display: none; }

.docker-warning {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  color: var(--warning);
  font-size: 0.813rem;
}

.docker-warning svg { flex-shrink: 0; }
.docker-warning.hidden { display: none; }

main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

.page-title { margin-bottom: 24px; }
.page-title h2 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}
.page-title p { font-size: 0.875rem; color: var(--text-muted); }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  margin-bottom: 24px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--transition);
}

.stat:hover { border-color: var(--border-hover); }

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-label .stat-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.stat-value {
  font-size: 1.375rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--text);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 12px;
}

.db-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  transition: border-color var(--transition);
}

.db-card:hover { border-color: var(--border-hover); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 10px;
}

.card-type {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.813rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.card-type-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.card-type-icon svg { width: 16px; height: 16px; }

.card-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  font-size: 0.688rem;
  font-weight: 500;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  white-space: nowrap;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.card-status.running { color: var(--success); }
.card-status.creating { color: var(--warning); }
.card-status.creating .status-dot { animation: pulse 1.5s infinite; }
.card-status.stopped { color: var(--text-muted); }
.card-status.error { color: var(--danger); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.card-name {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 12px;
  letter-spacing: -0.01em;
  color: var(--text);
}

.card-url {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  margin-bottom: 12px;
}

.card-url code {
  flex: 1;
  font-family: ui-monospace, 'SF Mono', Menlo, Monaco, 'Cascadia Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  user-select: all;
  padding: 4px 6px;
}

.url-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.url-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.url-btn.copied {
  color: var(--success);
}

.card-meta {
  display: flex;
  gap: 12px;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 14px;
  font-family: ui-monospace, 'SF Mono', Menlo, Monaco, 'Cascadia Mono', monospace;
}

.card-meta span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.card-meta span:not(:first-child)::before {
  content: '';
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-muted);
  opacity: 0.6;
  margin-right: 6px;
}

.card-actions {
  display: flex;
  gap: 6px;
}

.card-actions button {
  flex: 1;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.813rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  height: 32px;
}

.card-actions button:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-hover);
}

.card-actions .btn-delete {
  flex: 0 0 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.card-actions .btn-delete:hover {
  background: var(--surface-2);
  color: var(--danger);
  border-color: var(--border-hover);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
  animation: fadeIn 150ms ease;
}

.modal-overlay.hidden { display: none; }

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

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 520px;
  max-width: 100%;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  animation: slideUp 180ms ease;
}

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

.modal-header h2 {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}

.modal-header p {
  font-size: 0.813rem;
  color: var(--text-muted);
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-xs);
  transition: all var(--transition);
  flex-shrink: 0;
}

.modal-close:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-hover);
}

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

.form-group label {
  display: block;
  font-size: 0.813rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}

.label-hint {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-left: 4px;
}

.form-group input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition);
  height: 36px;
}

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

.form-group input::placeholder {
  color: var(--text-muted);
}

.type-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.type-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  color: var(--text-secondary);
  position: relative;
}

.type-card svg { width: 22px; height: 22px; }

.type-card:hover {
  border-color: var(--border-hover);
  color: var(--text);
  background: var(--surface-2);
}

.type-card.selected {
  border-color: var(--text);
  color: var(--text);
  background: var(--surface-2);
}

.type-name {
  font-size: 0.75rem;
  font-weight: 500;
}

.type-desc {
  font-size: 0.625rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.3;
}

.empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 80px 20px;
  color: var(--text-muted);
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.empty-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.empty-icon svg { width: 24px; height: 24px; }

.empty-state h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.empty-state p {
  font-size: 0.813rem;
  max-width: 320px;
  line-height: 1.5;
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-sm);
  font-size: 0.813rem;
  font-weight: 500;
  z-index: 200;
  animation: toastIn 180ms ease;
}

.toast.hidden { display: none; }
.toast.error { color: var(--danger); }
.toast.success { color: var(--success); }

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

.spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

.login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 24px;
}

.login-overlay.hidden { display: none; }

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  width: 100%;
  max-width: 380px;
  animation: slideUp 180ms ease;
}

.login-header {
  text-align: center;
  margin-bottom: 20px;
}

.login-header svg {
  color: var(--text-muted);
  margin-bottom: 12px;
}

.login-header h2 {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}

.login-header p {
  font-size: 0.813rem;
  color: var(--text-muted);
}

.login-error {
  padding: 8px 12px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 0.75rem;
  margin-bottom: 12px;
}

.login-error.hidden { display: none; }

@media (max-width: 768px) {
  header { padding: 12px 16px; }
  main { padding: 20px 16px 40px; }
  .page-title h2 { font-size: 1.25rem; }
  .grid { grid-template-columns: 1fr; }
  .type-grid { grid-template-columns: repeat(2, 1fr); }
  .stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .stat-value { font-size: 1.25rem; }
  .modal { padding: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
