:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --border: #2d3150;
  --text: #e2e8f0;
  --text-muted: #8892a4;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --ok: #22c55e;
  --warn: #f59e0b;
  --error: #ef4444;
  --ok-bg: rgba(34, 197, 94, 0.1);
  --warn-bg: rgba(245, 158, 11, 0.1);
  --error-bg: rgba(239, 68, 68, 0.1);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  min-height: 100vh;
}

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

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

.logo { font-size: 24px; }

h1 { font-size: 18px; font-weight: 600; line-height: 1.2; }
.subtitle { font-size: 12px; color: var(--text-muted); }

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

.nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.nav a {
  text-decoration: none;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
}

.nav a.active, .nav a:hover {
  color: var(--text);
  border-color: #42506a;
  background: rgba(124, 140, 255, 0.12);
}

select, button {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  padding: 6px 12px;
  cursor: pointer;
  transition: border-color 0.15s;
}

select:focus, button:focus { outline: none; border-color: var(--accent); }
button:hover { border-color: var(--accent-hover); }

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

.status-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
  margin-bottom: 20px;
  font-size: 13px;
  color: var(--text-muted);
}

.status-bar.hidden { display: none; }

.summary-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  text-align: center;
}

.summary-card.ok { border-color: rgba(34,197,94,0.3); }
.summary-card.warn { border-color: rgba(245,158,11,0.3); }
.summary-card.error { border-color: rgba(239,68,68,0.3); }

.summary-number {
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
}

.summary-card.ok .summary-number { color: var(--ok); }
.summary-card.warn .summary-number { color: var(--warn); }
.summary-card.error .summary-number { color: var(--error); }
.summary-label { font-size: 12px; color: var(--text-muted); }

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

.loading {
  grid-column: 1/-1;
  text-align: center;
  color: var(--text-muted);
  padding: 60px;
}

.plugin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 0.15s;
}

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

.plugin-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.plugin-emoji { font-size: 28px; flex-shrink: 0; }

.plugin-info { flex: 1; min-width: 0; }
.plugin-name { font-size: 15px; font-weight: 600; }
.plugin-category { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 2px; }

.plugin-description { font-size: 13px; color: var(--text-muted); line-height: 1.5; }

.plugin-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 20px;
}

.status-badge.ok { background: var(--ok-bg); color: var(--ok); }
.status-badge.error { background: var(--error-bg); color: var(--error); }
.status-badge.warn { background: var(--warn-bg); color: var(--warn); }
.status-badge.inactive { background: var(--surface2); color: var(--text-muted); }
.status-badge.planned { background: var(--surface2); color: var(--text-muted); }

.plugin-meta { font-size: 11px; color: var(--text-muted); }

.plugin-actions { display: flex; gap: 8px; margin-top: 4px; }

.btn {
  flex: 1;
  padding: 7px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  transition: all 0.15s;
}

.btn:hover { border-color: var(--accent); color: var(--accent-hover); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Method badge */
.method-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* Modal */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.7); }
.modal-content { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; width: 480px; max-width: 95vw; max-height: 90vh; overflow-y: auto; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px 16px; border-bottom: 1px solid var(--border); }
.modal-header h2 { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 20px; cursor: pointer; padding: 0 4px; line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px 24px; }

.modal-section { margin-bottom: 20px; }
.modal-section h3 { font-size: 13px; font-weight: 600; margin-bottom: 8px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.modal-section p { font-size: 13px; color: var(--text-muted); line-height: 1.5; margin-bottom: 12px; }

.oauth-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  color: #333;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.oauth-btn:hover { background: #f5f5f5; }
.oauth-btn-google { }

.instances-list { display: flex; flex-direction: column; gap: 4px; }
.instance-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--surface2);
  border-radius: 6px;
  font-size: 13px;
}

.deployed-badge { font-size: 11px; color: var(--ok); }

@media (max-width: 640px) {
  .summary-row { grid-template-columns: repeat(2, 1fr); }
  .plugins-grid { grid-template-columns: 1fr; }
  main { padding: 16px; }
}
