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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-hover: #222632;
  --border: #2a2e3a;
  --text: #e4e6ed;
  --text-dim: #8b8fa3;
  --accent: #6c8cff;
  --green: #34d399;
  --amber: #fbbf24;
  --red: #f87171;
  --radius: 10px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

header {
  padding: 24px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 16px;
}

header h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

header h1 span {
  color: var(--text-dim);
  font-weight: 400;
}

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

.search-input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 12px;
  color: var(--text);
  font-size: 14px;
  width: 200px;
  outline: none;
  transition: border-color .2s;
}

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

.filter-btn, .action-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 14px;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
}

.filter-btn:hover, .action-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.filter-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.action-btn {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 500;
}

.action-btn:hover { opacity: .85; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  padding: 24px 32px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform .15s, box-shadow .15s;
  display: flex;
  flex-direction: column;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,.3);
}

.card-img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  object-position: top;
  display: block;
  background: var(--border);
}

.card-placeholder {
  width: 100%;
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  font-weight: 700;
  color: rgba(255,255,255,.15);
}

/* Screenshot hover icon */
.card-visual {
  position: relative;
}

.btn-screenshot-icon {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s, background .15s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}

.card:hover .btn-screenshot-icon { opacity: 1; }
.btn-screenshot-icon:hover { background: rgba(0,0,0,.8); }
.btn-screenshot-icon:disabled { opacity: 0 !important; cursor: not-allowed; }
.card:hover .btn-screenshot-icon:disabled { opacity: .3 !important; }

.card-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.status-dots {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.running { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.stopped { background: var(--text-dim); }
.status-dot.starting { background: var(--amber); animation: pulse 1s infinite; }
.status-dot.stopping { background: var(--amber); }
.status-dot.error { background: var(--red); }

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

.card-name {
  font-size: 15px;
  font-weight: 600;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badges-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(108,140,255,.15);
  color: var(--accent);
  font-weight: 500;
}

.badge.db { background: rgba(52,211,153,.12); color: var(--green); }
.badge.fe { background: rgba(251,191,36,.12); color: var(--amber); }

.card-path {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
}

.card-actions button, .card-actions a {
  flex: 1;
  padding: 7px 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: all .15s;
  display: inline-block;
}

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

.card-actions .btn-start { color: var(--green); border-color: rgba(52,211,153,.3); }
.card-actions .btn-start:hover { background: rgba(52,211,153,.1); }
.card-actions .btn-stop { color: var(--red); border-color: rgba(248,113,113,.3); }
.card-actions .btn-stop:hover { background: rgba(248,113,113,.1); }
.card-actions .btn-docs { color: var(--accent); border-color: rgba(108,140,255,.3); }
.card-actions .btn-docs:hover { background: rgba(108,140,255,.1); }
.card-actions .btn-open { color: var(--amber); border-color: rgba(251,191,36,.3); }
.card-actions .btn-open:hover { background: rgba(251,191,36,.1); }

.card-actions button:disabled {
  opacity: .4;
  cursor: not-allowed;
}

.stats {
  color: var(--text-dim);
  font-size: 13px;
}

/* Logs modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 100;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 90%;
  max-width: 700px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  cursor: pointer;
}

.modal-body {
  padding: 16px;
  overflow-y: auto;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-dim);
  white-space: pre-wrap;
  word-break: break-all;
}

@media (max-width: 640px) {
  header { padding: 16px; }
  .grid { padding: 16px; gap: 14px; }
  .grid { grid-template-columns: 1fr; }
}
