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

:root {
  --bg: #0B0E11;
  --panel: #12161cd9;
  --panel-solid: #12161c;
  --panel-raised: #171c23;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #E7ECF2;
  --text-muted: #7D8896;
  --text-faint: #4A5561;
  --accent: #3ED598;
  --accent-dim: rgba(62, 213, 152, 0.14);
  --warn: #F5A623;
  --warn-dim: rgba(245, 166, 35, 0.14);
  --danger: #E5484D;
  --danger-dim: rgba(229, 72, 77, 0.14);
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  min-height: 100vh;
}

body {
  background-image:
    radial-gradient(ellipse 900px 500px at 15% -10%, rgba(62, 213, 152, 0.06), transparent),
    radial-gradient(ellipse 700px 500px at 100% 0%, rgba(245, 166, 35, 0.04), transparent);
  background-attachment: fixed;
}

a { color: inherit; }

button {
  font-family: var(--font-ui);
  cursor: pointer;
}

::selection {
  background: var(--accent-dim);
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; }

/* ---------- Login ---------- */

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  backdrop-filter: blur(20px);
}

.login-mark {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 6px;
}

.login-card h1 {
  font-size: 20px;
  margin: 0 0 22px 0;
  font-weight: 600;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.field input, .field textarea, .field select {
  width: 100%;
  background: var(--panel-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-ui);
  outline: none;
  transition: border-color 0.15s ease;
}

.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--accent);
}

.field textarea {
  font-family: var(--font-mono);
  font-size: 13px;
  resize: vertical;
  min-height: 72px;
}

.btn {
  border: 1px solid var(--border-strong);
  background: var(--panel-raised);
  color: var(--text);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 500;
  transition: border-color 0.15s ease, background 0.15s ease;
}

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

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #04140D;
}

.btn-primary:hover {
  background: #4fe3a8;
  border-color: #4fe3a8;
}

.btn-block { width: 100%; }

.error-text {
  color: var(--danger);
  font-size: 13px;
  margin-top: 4px;
  min-height: 18px;
}

/* ---------- Dashboard shell ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 14, 17, 0.85);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.brand-title {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-faint);
}

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

.stat-strip {
  display: flex;
  gap: 0;
  padding: 18px 28px 4px 28px;
  flex-wrap: wrap;
}

.stat {
  flex: 1;
  min-width: 130px;
  padding: 14px 18px;
  border-right: 1px solid var(--border);
}

.stat:last-child { border-right: none; }

.stat-value {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 600;
  line-height: 1;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.stat-value.online { color: var(--accent); }
.stat-value.stopped { color: var(--text-faint); }
.stat-value.errored { color: var(--danger); }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px 6px 28px;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-dropdown {
  position: relative;
}

.filter-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.filter-menu {
  position: fixed;
  min-width: 160px;
  background: var(--panel-solid);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 6px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  z-index: 100;
  display: none;
}

.filter-menu.open { display: block; }

.filter-option {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-muted);
}

.filter-option:hover { background: var(--panel-raised); color: var(--text); }
.filter-option.active { color: var(--accent); }

.bot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
  padding: 14px 28px 40px 28px;
}

.bot-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  backdrop-filter: blur(16px);
  transition: border-color 0.15s ease;
}

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

.bot-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.bot-name {
  font-weight: 600;
  font-size: 14.5px;
  word-break: break-word;
}

.bot-script {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 3px;
  word-break: break-all;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  font-family: var(--font-mono);
  text-transform: lowercase;
}

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

.status-online { background: var(--accent-dim); color: var(--accent); }
.status-online .status-dot { background: var(--accent); box-shadow: 0 0 6px var(--accent); }

.status-stopped { background: rgba(125, 136, 150, 0.14); color: var(--text-muted); }
.status-stopped .status-dot { background: var(--text-faint); }

.status-errored { background: var(--danger-dim); color: var(--danger); }
.status-errored .status-dot { background: var(--danger); box-shadow: 0 0 6px var(--danger); }

.status-launching { background: var(--warn-dim); color: var(--warn); }
.status-launching .status-dot { background: var(--warn); }

.bot-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 14px 0;
}

.metric-block .metric-value {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
}

.metric-block .metric-label {
  font-size: 10.5px;
  color: var(--text-faint);
  margin-top: 2px;
}

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

.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.btn-danger-outline {
  background: transparent;
  border-color: rgba(229, 72, 77, 0.35);
  color: var(--danger);
}

.btn-danger-outline:hover { border-color: var(--danger); background: var(--danger-dim); }

.log-panel {
  margin-top: 14px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  display: none;
}

.log-panel.open { display: block; }

.log-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}

.log-tab {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  background: var(--panel-raised);
  border: 1px solid transparent;
}

.log-tab.active {
  color: var(--text);
  border-color: var(--border-strong);
}

.log-output {
  background: #05070A;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.6;
  color: #B7C2CC;
  max-height: 220px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.log-line-err { color: #F0919A; }

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

.empty-state .empty-title {
  font-size: 15px;
  color: var(--text);
  margin-bottom: 6px;
  font-weight: 600;
}

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

.input-with-button input { flex: 1; min-width: 0; }
.input-with-button .btn { flex-shrink: 0; }

.detect-line {
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.6;
}

.detect-line code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  background: var(--panel-raised);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
}

.detect-muted { color: var(--text-faint); }
.detect-warn { color: var(--warn); }

.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font-size: 12.5px;
  text-decoration: underline;
  cursor: pointer;
}

.candidate-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.chip {
  background: var(--panel-raised);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 11.5px;
  font-family: var(--font-mono);
  color: var(--text);
}

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

/* ---------- Browse modal ---------- */

.browse-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -48%);
  width: 520px;
  max-width: 92vw;
  max-height: 78vh;
  background: var(--panel-solid);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  z-index: 220;
  padding: 20px;
  display: none;
  flex-direction: column;
}

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

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

.browse-title {
  font-weight: 600;
  font-size: 15px;
}

.browse-path-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.browse-path-input {
  flex: 1;
  min-width: 0;
  background: var(--panel-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12.5px;
  outline: none;
}

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

.browse-list {
  flex: 1;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--panel-raised);
  min-height: 200px;
}

.browse-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.browse-item:last-child { border-bottom: none; }
.browse-item:hover { background: rgba(255, 255, 255, 0.04); }
.browse-item.is-dir { cursor: pointer; }
.browse-item.is-file { cursor: pointer; color: var(--text-muted); }
.browse-item.is-file:hover { color: var(--text); }

.browse-icon {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
  width: 16px;
  text-align: center;
}

.browse-empty {
  padding: 24px 12px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
}

.browse-footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
}

/* ---------- Slide-over panel ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 10, 0.6);
  backdrop-filter: blur(2px);
  z-index: 200;
  display: none;
}

.overlay.open { display: block; }

.slideover {
  position: fixed;
  top: 0;
  right: -420px;
  width: 400px;
  max-width: 92vw;
  height: 100%;
  background: var(--panel-solid);
  border-left: 1px solid var(--border-strong);
  z-index: 201;
  padding: 24px;
  overflow-y: auto;
  transition: right 0.22s ease;
}

.slideover.open { right: 0; }

.slideover h2 {
  font-size: 16px;
  margin: 0 0 4px 0;
}

.slideover .sub {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.checkbox-row input { width: auto; }
.checkbox-row label { margin: 0; font-size: 13px; color: var(--text); }

.slideover-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--panel-solid);
  border: 1px solid var(--border-strong);
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 13px;
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.toast-error { border-color: rgba(229, 72, 77, 0.5); color: #F0919A; }
.toast.toast-ok { border-color: rgba(62, 213, 152, 0.5); color: var(--accent); }

@media (max-width: 640px) {
  .topbar { padding: 14px 16px; }
  .stat-strip, .toolbar, .bot-grid { padding-left: 16px; padding-right: 16px; }
  .bot-metrics { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Websites (hub + portal) ---------- */

a.btn {
  display: inline-block;
  text-decoration: none;
}

.section-label {
  padding: 22px 28px 0 28px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.site-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 28px 0 28px;
}

.site-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-decoration: none;
  font-size: 13.5px;
  transition: border-color 0.15s ease;
}

.site-chip:hover { border-color: var(--border-strong); }

.site-chip-name { font-weight: 500; }

.site-chip-path {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-faint);
}

.site-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-faint);
}

.site-dot.is-up { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.site-dot.is-down { background: var(--danger); }

.login-back {
  display: block;
  margin-top: 14px;
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  text-align: center;
}

.login-back:hover { color: var(--text); }

.portal {
  max-width: 880px;
  margin: 0 auto;
  padding: 56px 20px 48px 20px;
}

.portal-mark {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.portal h1 {
  font-size: 28px;
  font-weight: 600;
  margin: 8px 0 6px 0;
}

.portal-sub {
  color: var(--text-muted);
  font-size: 14.5px;
  margin: 0 0 30px 0;
}

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

.portal-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.portal-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.portal-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.portal-card-name {
  font-size: 15.5px;
  font-weight: 600;
}

.portal-card-desc {
  color: var(--text-muted);
  font-size: 13.5px;
  line-height: 1.45;
  flex: 1;
}

.portal-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-faint);
}

.portal-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-muted);
}

.portal-card.is-manager { border-style: dashed; }

/* ---------- Bots on the portal ---------- */

.site-dot.is-warn { background: var(--warn); }

.btn-warn {
  background: var(--warn-dim);
  border-color: rgba(245, 166, 35, 0.45);
  color: var(--warn);
}

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

.btn:disabled { opacity: 0.55; cursor: default; }

.portal-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 44px 0 4px 0;
}

.portal-section {
  font-size: 20px;
  font-weight: 600;
  margin: 0;
}

.portal-note {
  color: var(--text-muted);
  font-size: 13.5px;
  margin-bottom: 14px;
  min-height: 18px;
}

.bot-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bot-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.bot-row.needs-restart { border-color: rgba(245, 166, 35, 0.35); }

.bot-row-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.bot-row-main {
  flex: 1;
  min-width: 0;
}

.bot-row-name {
  font-weight: 600;
  font-size: 14px;
}

.bot-row-meta {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-faint);
  margin-top: 3px;
  overflow-wrap: anywhere;
}

.restart-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--warn-dim);
  color: var(--warn);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  vertical-align: 1px;
}

.section-hint {
  margin-left: 8px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-faint);
  opacity: 0.8;
}

.available-grid {
  padding-bottom: 0;
}

.available-card {
  border-style: dashed;
}

.available-card .bot-actions {
  margin-top: 14px;
}

.bot-stale {
  margin-top: 10px;
  font-size: 12px;
  color: var(--warn);
  overflow-wrap: anywhere;
}
