:root {
  --bg:      #0d1117;
  --chrome:  #080c10;
  --panel:   #161b22;
  --panel2:  #21262d;
  --line:    #30363d;
  --text:    #c9d1d9;
  --muted:   #8b949e;
  --accent:  #1f6feb;
  --accent2: #58a6ff;
  --good:    #3fb950;
  --warn:    #d29922;
  --bad:     #f85149;
  --pink:    #bc8cff;
  --teal:    #39d353;
  --sidebar-w: 224px;
  --header-h: 52px;
}

@view-transition {
  navigation: auto;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Inter","Space Grotesk","Segoe UI",system-ui,sans-serif;
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent2); text-decoration: none; }
a:hover { color: #a5b4fc; }

* { scrollbar-width: thin; scrollbar-color: var(--panel2) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--panel2);
  border: 2px solid var(--bg);
  border-radius: 8px;
}
*::-webkit-scrollbar-thumb:hover { background: var(--line); }
*::-webkit-scrollbar-corner { background: transparent; }

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--chrome);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 0 10px 12px;
  z-index: 10;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--header-h);
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  margin: 0 -10px 10px;
}
.brand-logo {
  width: 34px; height: 34px;
  object-fit: contain;
  background: #000;
  border-radius: 8px;
  padding: 2px;
}
.brand-name {
  font-size: 17px; font-weight: 800;
  letter-spacing: 1.5px; color: #fff;
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px;
  color: var(--muted); font-weight: 500; font-size: 14px;
  transition: background .13s, color .13s;
  text-decoration: none;
}
.nav-item:hover { background: var(--panel2); color: var(--text); }
.nav-item.active {
  background: rgba(31,111,235,.15);
  color: var(--accent2);
  border-left: 2px solid var(--accent);
  padding-left: 10px;
}
.nav-ico { width: 18px; text-align: center; flex-shrink: 0; opacity: .75; }
.nav-label { flex: 1; min-width: 0; }

/* Chevron inside nav item */
.nav-chevron {
  width: 20px; height: 20px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 4px; color: var(--muted); font-size: 11px;
  transition: transform .18s ease, color .12s, background .12s;
  cursor: pointer;
}
.nav-chevron:hover { background: var(--panel2); color: var(--text); }
.nav-chevron.open { transform: rotate(90deg); color: var(--accent2); }

/* Sub-list with guide line */
.nav-sub-list {
  position: relative;
  padding: 2px 0 4px 28px;
  display: flex; flex-direction: column; gap: 1px;
}
.nav-sub-list::before {
  content: ''; position: absolute;
  left: 19px; top: 4px; bottom: 4px;
  width: 1px; background: #3e3e42;
}
.nav-sub-item {
  display: block; padding: 5px 10px; font-size: 12.5px; color: var(--muted);
  border-radius: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: background .1s, color .1s; text-decoration: none;
}
.nav-sub-item:hover { background: var(--panel2); color: var(--text); }
.nav-sub-item.current { color: var(--text); background: #2d333b; }
.nav-sub-item.muted-item { color: #484f58; cursor: default; font-size: 11.5px; }

/* Sidebar status lampochkas (semaphore for projects).
   Yellow  = something running / queued / deploying
   Cyan    = task awaits operator input (CLI asked a question)
   Green   = completed task ready for review
   Red     = failed / timeout
   Gray    = idle (default; visually muted) */
.nav-lamp {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: transparent; margin-left: 6px; flex-shrink: 0; vertical-align: middle;
}
.nav-lamp.idle         { background: transparent; }
.nav-lamp.completed    { background: var(--good); }
.nav-lamp.awaits_input { background: #38bdf8; }
.nav-lamp.running, .nav-lamp.queued, .nav-lamp.deploying {
  background: var(--warn); animation: nav-lamp-pulse 1.4s infinite;
}
.nav-lamp.failed, .nav-lamp.timeout { background: var(--bad); }
@keyframes nav-lamp-pulse { 0%,100%{ opacity:1 } 50%{ opacity:.35 } }

.nav-item .nav-lamp { margin-left: auto; margin-right: 4px; }
.nav-sub-item { display: flex !important; align-items: center; gap: 6px; }
.nav-sub-item .nav-lamp { margin-left: auto; }
.sidebar-foot { margin-top: auto; padding: 8px; font-size: 11.5px; color: var(--muted); }

/* ── Shell ───────────────────────────────────────────────── */
.shell {
  margin-left: var(--sidebar-w);
  height: 100vh;
  max-width: 1820px;
  display: flex;
  flex-direction: column;
}
/* shell-header and sidebar .brand share --header-h so their bottom borders align */
.shell-header {
  flex: 0 0 var(--header-h);
  height: var(--header-h);
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: var(--chrome);
  z-index: 5;
}
.shell-header h1 { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -.3px; }
.shell-header .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.shell-header .breadcrumbs { color: var(--muted); font-size: 11px; margin-bottom: 2px; }
.shell-header .repo-info { font-size: 11px; color: var(--muted); margin-top: 1px; }
.shell-body {
  flex: 1;
  min-height: 0;
  padding: 18px 22px;
  overflow-y: auto;
}

/* ── Common ──────────────────────────────────────────────── */
.muted { color: var(--muted); font-size: 13px; }
.title { font-size: 17px; font-weight: 700; }
.box {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  height: 36px; border-radius: 8px;
  border: 1px solid var(--line);
  padding: 0 14px;
  background: var(--panel2); color: var(--text);
  cursor: pointer; transition: .15s;
  font-size: 14px; font-family: inherit;
  font-weight: 500;
}
.btn:hover { background: #30363d; border-color: #8b949e; }
.btn.primary {
  background: #238636; border-color: #2ea043;
  color: #fff; font-weight: 600;
}
.btn.primary:hover { background: #2ea043; border-color: #3fb950; }
.btn.danger { background: #21262d; border-color: #f8514933; color: #f85149; }
.btn.danger:hover { background: #2d1b1b; border-color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--panel2); border-color: var(--line); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.pill {
  display: inline-block; border: 1px solid var(--line);
  border-radius: 999px; padding: 2px 9px;
  font-size: 11.5px; color: var(--muted);
}

/* ── Page header (legacy, keep for compat) ───────────────── */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ── Form ────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 160px; }
.field label { font-size: 11px; color: var(--muted); letter-spacing: .5px; text-transform: uppercase; font-weight: 600; }
.field input, .field select, .field textarea {
  border-radius: 8px; border: 1px solid var(--line);
  background: #010409; color: var(--text);
  padding: 9px 12px; font-size: 14px; font-family: inherit;
  transition: border-color .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31,111,235,.3);
}
.field textarea { min-height: 80px; resize: vertical; }

/* ── Modal ───────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  display: none; align-items: center; justify-content: center;
  z-index: 100; backdrop-filter: blur(6px);
}
.modal-backdrop.open { display: flex; }
.modal {
  width: min(520px, 94vw); max-height: 86vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 22px;
  box-shadow: 0 32px 80px rgba(0,0,0,.8);
}
.modal h2 { margin: 0 0 16px; font-size: 16px; font-weight: 700; }
.modal .row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

/* ── Toast ───────────────────────────────────────────────── */
.toast {
  position: fixed; right: 20px; bottom: 20px;
  background: var(--panel); border: 1px solid var(--line);
  padding: 12px 16px; border-radius: 10px; font-size: 14px;
  z-index: 200; max-width: 400px;
  box-shadow: 0 12px 40px rgba(0,0,0,.6);
  opacity: 0; transition: opacity .2s ease; pointer-events: none;
  color: var(--text);
}
.toast.show { opacity: 1; }
.toast.err  { border-color: #5a2a35; color: #fca5a5; }
.toast.ok   { border-color: #1a5230; color: #86efac; }
.toast.warn { border-color: #5a420a; color: #fde68a; }

@media (max-width: 820px) {
  body { height: auto; overflow: auto; }
  .sidebar { position: static; width: 100%; border-right: 0; border-bottom: 1px solid var(--line); }
  .shell { margin-left: 0; height: auto; min-height: 100vh; }
  .shell-header { position: static; }
  .shell-body { overflow: visible; }
  .brand { padding-bottom: 8px; margin-bottom: 6px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
}
