:root {
  --bg: #111317;
  --panel: #1a1f26;
  --panel-2: #212833;
  --line: #2f3946;
  --text: #eef3f8;
  --muted: #a8b3c2;
  --accent: #60a5fa;
  --accent-2: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 18px;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: radial-gradient(circle at top, rgba(96, 165, 250, 0.1), transparent 25%), var(--bg); color: var(--text); font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif; }
a { color: inherit; text-decoration: none; }
code, pre { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; }
body { min-height: 100vh; }

.shell { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 20px; min-height: 100vh; padding: 20px; }
.sidebar, .content { min-width: 0; }
.panel { background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent), var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.sidebar { display: grid; gap: 16px; align-content: start; }
.brand { font-size: 1.4rem; font-weight: 700; letter-spacing: 0.02em; }
.small { font-size: 0.84rem; }
.muted { color: var(--muted); }
.topbar, .status-panel, .nav, .run-panel, .settings-panel, .history-list-panel, .detail-panel, .browser-list-panel, .preview-panel { padding: 18px; }
.nav-link { display: block; padding: 12px 14px; border-radius: 12px; color: var(--muted); }
.nav-link.active, .nav-link:hover { background: var(--panel-2); color: var(--text); }
.status-panel pre, .detail-panel pre, .history-card pre, .preview-panel pre { background: #0d1117; border: 1px solid #202733; border-radius: 12px; padding: 12px; white-space: pre-wrap; word-break: break-word; overflow: auto; }
.button { display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 12px; padding: 10px 14px; cursor: pointer; font-weight: 600; }
.button-primary { background: linear-gradient(135deg, #60a5fa, #3b82f6); color: white; }
.button-secondary { background: transparent; color: var(--text); border-color: var(--line); }
.full-width { width: 100%; }
.stack-form { display: grid; gap: 14px; }
.compact-form label span, .stack-form label span { display: block; margin-bottom: 6px; font-size: 0.9rem; color: var(--muted); }
input[type="text"], input[type="password"], input[type="number"], select, textarea { width: 100%; border-radius: 12px; border: 1px solid var(--line); background: #0f141b; color: var(--text); padding: 12px; }
textarea { resize: vertical; min-height: 180px; }
.flash { border-radius: 14px; padding: 12px 14px; margin-bottom: 16px; }
.flash-success { background: rgba(34, 197, 94, 0.12); border: 1px solid rgba(34, 197, 94, 0.35); }
.flash-error { background: rgba(239, 68, 68, 0.12); border: 1px solid rgba(239, 68, 68, 0.35); }
.content { display: grid; gap: 16px; align-content: start; }
.topbar { display: flex; justify-content: space-between; gap: 16px; align-items: start; }
.meta-grid { display: grid; grid-template-columns: repeat(2, minmax(120px, 1fr)); gap: 12px; }
.meta-label { display: block; color: var(--muted); font-size: 0.82rem; margin-bottom: 4px; }
.grid { display: grid; gap: 16px; }
.two-up { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.history-layout, .browser-layout { grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); }
.history-row, .file-row, .history-card { display: grid; gap: 6px; border: 1px solid var(--line); border-radius: 14px; padding: 12px; background: rgba(255,255,255,0.02); }
.history-row.active, .file-row:hover { border-color: var(--accent); background: rgba(96, 165, 250, 0.08); }
.history-snippet { color: var(--muted); font-size: 0.9rem; }
.history-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.status-badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 10px; text-transform: uppercase; font-size: 0.72rem; letter-spacing: 0.06em; }
.status-ok { background: rgba(34, 197, 94, 0.18); color: #86efac; }
.status-error { background: rgba(239, 68, 68, 0.18); color: #fca5a5; }
.status-timeout { background: rgba(245, 158, 11, 0.18); color: #fcd34d; }
.file-table { display: grid; gap: 10px; }
.file-row { grid-template-columns: 56px minmax(0, 1fr) 170px 120px; align-items: center; }
.browser-header { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.simple-list { margin: 0; padding-left: 18px; display: grid; gap: 8px; }
.detail-grid { margin-bottom: 16px; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 18px; }
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login-card { width: min(460px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 28px; box-shadow: var(--shadow); }
.hint { margin-top: 12px; color: var(--muted); }

@media (max-width: 1100px) {
  .shell { grid-template-columns: 1fr; }
  .topbar, .browser-header { flex-direction: column; }
  .two-up, .history-layout, .browser-layout, .settings-grid { grid-template-columns: 1fr; }
  .file-row { grid-template-columns: 56px minmax(0, 1fr); }
}

/* Restore top navbar */
body {
  padding-top: 58px;
}

.top-nav-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 58px;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  background: rgba(17, 19, 23, 0.95);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.top-nav-left {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.top-nav-brand {
  font-size: 0.92rem;
  font-weight: 700;
}

.top-nav-repo {
  font-size: 0.76rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
}

.top-nav-links a {
  font-size: 0.78rem;
  color: var(--muted);
  text-decoration: none;
  padding: 6px 8px;
  border-radius: 8px;
}

.top-nav-links a:hover,
.top-nav-links a.active {
  color: var(--text);
  background: rgba(96, 165, 250, 0.14);
}
