@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

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

:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface-hover: #1a1a1a;
  --border: #222;
  --border-hover: #333;
  --text: #e5e5e5;
  --text-secondary: #a3a3a3;
  --text-dim: #737373;
  --accent: #f97316;
  --accent-dim: rgba(249, 115, 22, 0.1);
  --green: #22c55e;
  --green-dim: rgba(34, 197, 94, 0.12);
  --blue: #3b82f6;
  --blue-dim: rgba(59, 130, 246, 0.1);
  --purple: #a855f7;
  --purple-dim: rgba(168, 85, 247, 0.1);
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.1);
  --yellow: #eab308;
  --yellow-dim: rgba(234, 179, 8, 0.1);
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(0,0,0,0.3);
  --sidebar-width: 220px;
  --sidebar-collapsed: 56px;
}

[data-theme="light"] {
  --bg: #f5f5f4;
  --surface: #ffffff;
  --surface-hover: #fafaf9;
  --border: #e7e5e4;
  --border-hover: #d6d3d1;
  --text: #1c1917;
  --text-secondary: #57534e;
  --text-dim: #a8a29e;
  --accent: #ea580c;
  --accent-dim: rgba(234, 88, 12, 0.08);
  --green: #16a34a;
  --green-dim: rgba(22, 163, 74, 0.08);
  --blue: #2563eb;
  --blue-dim: rgba(37, 99, 235, 0.08);
  --purple: #9333ea;
  --purple-dim: rgba(147, 51, 234, 0.08);
  --red: #dc2626;
  --red-dim: rgba(220, 38, 38, 0.08);
  --yellow: #ca8a04;
  --yellow-dim: rgba(202, 138, 4, 0.08);
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background 0.2s, color 0.2s;
}

/* ===== AUTH PAGES ===== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 380px;
  padding: 2.5rem 2rem;
  animation: authFadeIn 0.4s ease;
}

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

.auth-card h1 {
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 0.25rem;
}

.auth-card .subtitle {
  color: var(--text-dim);
  font-size: 0.8125rem;
  margin-bottom: 2rem;
}

.auth-card .form-group {
  margin-bottom: 1rem;
}

.auth-card label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 0.375rem;
}

.auth-card input {
  width: 100%;
  padding: 0.625rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 0.8125rem;
  transition: border-color 0.15s;
  outline: none;
}

.auth-card input:focus {
  border-color: var(--accent);
}

.auth-card input::placeholder {
  color: var(--text-dim);
}

.auth-btn {
  width: 100%;
  padding: 0.6875rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  margin-top: 0.5rem;
}

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

.auth-error {
  background: var(--red-dim);
  color: var(--red);
  font-size: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  display: none;
}

.auth-error.visible { display: block; }

.auth-footer {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.75rem;
  color: var(--text-dim);
}

.auth-footer a {
  color: var(--accent);
  text-decoration: none;
}

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width 0.25s ease, transform 0.25s ease;
  z-index: 100;
  overflow: hidden;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
  min-height: 60px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-brand h2 {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  transition: opacity 0.2s;
}

.sidebar.collapsed .sidebar-brand h2 {
  opacity: 0;
  width: 0;
}

.sidebar-collapse-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
  flex-shrink: 0;
}

.sidebar-collapse-btn:hover { color: var(--text); }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0.5rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.625rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.12s;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  margin-bottom: 0.125rem;
}

.nav-item:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
}

.nav-item-icon {
  width: 20px;
  text-align: center;
  flex-shrink: 0;
  font-size: 0.875rem;
}

.nav-item-label {
  transition: opacity 0.2s;
}

.sidebar.collapsed .nav-item-label {
  opacity: 0;
  width: 0;
}

.sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.5rem;
  font-size: 0.75rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-user-email {
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 0.2s;
}

.sidebar.collapsed .sidebar-user-email {
  opacity: 0;
  width: 0;
}

.logout-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0.5rem;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-family: 'Inter', sans-serif;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
  overflow: hidden;
}

.logout-btn:hover { color: var(--red); background: var(--red-dim); }

.logout-btn .logout-label {
  transition: opacity 0.2s;
}

.sidebar.collapsed .logout-label {
  opacity: 0;
  width: 0;
}

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-left: var(--sidebar-width);
  padding: 2rem 1.5rem 4rem;
  transition: margin-left 0.25s ease;
  min-height: 100vh;
}

.main-content.sidebar-collapsed {
  margin-left: var(--sidebar-collapsed);
}

.container {
  max-width: 680px;
  margin: 0 auto;
}

/* ===== HEADER ===== */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0.375rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

header .left h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

header .left p {
  color: var(--text-dim);
  font-size: 0.8125rem;
  margin-top: 0.125rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.theme-toggle {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.375rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0;
  transition: all 0.2s;
}

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

.theme-btn {
  width: 32px;
  height: 28px;
  border: none;
  background: none;
  border-radius: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  transition: all 0.2s;
  color: var(--text-dim);
}

.theme-btn.active {
  background: var(--accent-dim);
  color: var(--accent);
}

/* ===== SEARCH ===== */
.search-bar {
  margin-bottom: 1.75rem;
}

.search-input {
  width: 100%;
  padding: 0.625rem 0.875rem 0.625rem 2.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 0.8125rem;
  outline: none;
  transition: border-color 0.15s;
}

.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text-dim); }

.search-wrapper {
  position: relative;
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
}

.search-icon svg { width: 15px; height: 15px; }

.search-clear {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0.25rem;
  display: none;
  align-items: center;
}

.search-clear.visible { display: flex; }
.search-clear:hover { color: var(--text); }
.search-clear svg { width: 14px; height: 14px; }

/* ===== SECTIONS ===== */
.section {
  margin-bottom: 2rem;
}

.section.hidden { display: none; }

.section-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.625rem;
  padding-left: 0.125rem;
}

.section-meta {
  margin-left: auto;
  font-size: 0.625rem;
  color: var(--text-dim);
}

.section-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.section-count {
  font-size: 0.625rem;
  font-weight: 500;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.0625rem 0.4375rem;
}

/* ===== CARDS ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: visible;
  box-shadow: var(--shadow);
  transition: background 0.2s, border-color 0.2s;
}

.card.empty-card { display: none; }

.item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0.875rem;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
  cursor: pointer;
  gap: 0.5rem;
}

.item:last-child { border-bottom: none; }
.item:hover { background: var(--surface-hover); }
.item.filtered-out { display: none; }

.item-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  min-width: 0;
}

.item-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9375rem;
  flex-shrink: 0;
}

.item-info { min-width: 0; flex: 1; }

.item-name {
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.125rem;
}

.item-cmd {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6875rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-tag {
  font-size: 0.5625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.0625rem 0.375rem;
  border-radius: 3px;
  flex-shrink: 0;
}

.tag-app { background: var(--accent-dim); color: var(--accent); }
.tag-infra { background: var(--blue-dim); color: var(--blue); }
.tag-ssh { background: var(--purple-dim); color: var(--purple); }
.tag-url { background: var(--green-dim); color: var(--green); }
.tag-dns { background: var(--yellow-dim); color: var(--yellow); }
.tag-purple { background: var(--purple-dim); color: var(--purple); }
.tag-key { background: var(--red-dim); color: var(--red); }

/* ===== COPY BUTTONS ===== */
.copy-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  padding: 0.3125rem 0.5rem;
  font-size: 0.6875rem;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.3125rem;
  white-space: nowrap;
}

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

.copy-btn.copied {
  border-color: var(--green);
  color: var(--green);
  background: var(--green-dim);
}

.copy-btn svg { width: 13px; height: 13px; }

/* Instant tooltip */
.has-tooltip {
  position: relative;
}
.has-tooltip::before {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%) translateY(2px);
  background: #0b0b0b;
  color: #fff;
  font-size: 0.625rem;
  font-weight: 500;
  line-height: 1;
  padding: 0.375rem 0.5rem;
  border-radius: 7px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .08s ease, transform .08s ease;
  z-index: 30;
}
.has-tooltip::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: calc(100% + 3px);
  transform: translateX(-50%) translateY(2px);
  border: 5px solid transparent;
  border-top-color: #0b0b0b;
  opacity: 0;
  pointer-events: none;
  transition: opacity .08s ease, transform .08s ease;
  z-index: 30;
}
.has-tooltip:hover::before,
.has-tooltip:hover::after,
.has-tooltip:focus-visible::before,
.has-tooltip:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== SERVER GRID ===== */
.server-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.server-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem 0.875rem 1rem;
  box-shadow: var(--shadow);
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
}

.server-card:hover { border-color: var(--border-hover); }
.server-card.filtered-out { display: none; }

.server-name {
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 0.375rem;
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.server-name .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}

.server-name .dot.shared {
  background: var(--yellow);
}

.server-detail {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6875rem;
  color: var(--text-dim);
  min-height: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding: 0.125rem 0;
}
.server-detail:last-of-type {
  border-bottom: none;
}

.server-detail .label {
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 0.625rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ===== MINI COPY ===== */
.mini-copy {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0.125rem;
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  transition: color 0.12s;
}

.mini-copy:hover { color: var(--text); }
.mini-copy.copied { color: var(--green); }
.mini-copy svg { width: 11px; height: 11px; }

/* ===== API KEYS ===== */
.key-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6875rem;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.15s;
}

.key-value:hover { color: var(--text-secondary); }

.key-value.revealed {
  color: var(--accent);
  word-break: break-all;
  white-space: normal;
}

/* ===== FOOTER ===== */
.footer {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.6875rem;
  margin-top: 3rem;
  opacity: 0.4;
}

/* ===== OVERLAY ===== */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
}

.sidebar-overlay.visible { display: block; }

/* ===== MOBILE ===== */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .sidebar.collapsed {
    width: var(--sidebar-width);
  }

  .sidebar-collapse-btn { display: none; }

  .main-content {
    margin-left: 0;
  }

  .main-content.sidebar-collapsed {
    margin-left: 0;
  }

  .mobile-menu-btn {
    display: flex;
  }
}

@media (max-width: 480px) {
  .main-content { padding: 1.5rem 1rem 3rem; }
  .server-grid { grid-template-columns: 1fr; }
  .item-cmd { max-width: 160px; }
}

/* ===== NO RESULTS ===== */
.no-results {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-dim);
  font-size: 0.8125rem;
  display: none;
}

.no-results.visible { display: block; }

/* Server panel button */
.server-panel-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin-top: 0.625rem;
  margin-bottom: 0.375rem;
  padding: 0.3125rem 0.625rem;
  font-size: 0.6875rem;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: all 0.15s;
  opacity: 0.8;
}
.server-panel-btn:hover {
  opacity: 1;
  background: var(--accent);
  color: var(--bg);
}

/* Live server stats */
.server-live-stats {
  margin-top: auto;
  padding-top: 0.75rem;
}
.stat-row {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}
.stat-item {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.stat-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.5625rem;
  font-weight: 600;
  color: var(--text-dim);
  width: 28px;
  flex-shrink: 0;
}
.stat-bar {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.stat-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.5s ease;
}
.stat-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.5625rem;
  font-weight: 500;
  color: var(--text-secondary);
  width: 28px;
  text-align: right;
  flex-shrink: 0;
}
.stat-sep {
  color: var(--text-dim);
  font-size: 0.625rem;
  line-height: 1;
  flex-shrink: 0;
}
.stat-uptime {
  font-size: 0.5625rem;
  color: var(--text-dim);
  margin-top: 0.25rem;
}
