:root {
  --bg: #0f1115;
  --bg-soft: #161a22;
  --bg-elev: #1c2230;
  --border: #2a3142;
  --text: #e6e9ef;
  --text-dim: #98a2b3;
  --accent: #ff6b35;
  --accent-soft: rgba(255, 107, 53, 0.15);
  --green: #2ecc71;
  --yellow: #f1c40f;
  --red: #e74c3c;
  --blue: #3aa0ff;
  --radius: 10px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
}

#app { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 20px 18px;
  border-bottom: 1px solid var(--border);
}
.brand-logo { font-size: 26px; }
.brand-title { font-weight: 700; letter-spacing: 0.2px; }
.brand-sub { color: var(--text-dim); font-size: 12px; }

.nav { padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: 0.15s;
}
.nav-item:hover { background: var(--bg-elev); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item span:first-child { width: 18px; text-align: center; }

.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
}
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-ok { background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot-bad { background: var(--red); }
.dot-unknown { background: var(--yellow); }

/* ---------- Content ---------- */
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 17, 21, 0.8);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h1 { font-size: 20px; margin: 0; }
.view { padding: 24px 28px 60px; max-width: 1180px; }

/* ---------- Banner ---------- */
.banner {
  margin: 14px 28px 0;
  padding: 14px 18px;
  border-radius: var(--radius);
  background: rgba(231, 76, 60, 0.14);
  border: 1px solid var(--red);
  border-left: 4px solid var(--red);
  color: #ffb3a7;
  font-size: 13.5px;
  line-height: 1.55;
}
.banner strong { color: #ffd9d2; }

/* ---------- Project cards ---------- */
.project-card { padding: 0; overflow: hidden; }
.project-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 20px;
}
.project-head-main { min-width: 0; }
.project-title { font-size: 15px; font-weight: 700; margin-bottom: 6px; word-break: break-word; }
.project-actions { display: flex; gap: 8px; flex-shrink: 0; flex-wrap: wrap; }
.project-body { padding: 4px 20px 20px; border-top: 1px solid var(--border); }
.project-body h3:first-child { margin-top: 14px; }

/* ---------- Cards & grids ---------- */
.card {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
}
.card h2 { margin: 0 0 4px; font-size: 16px; }
.card h3 { margin: 18px 0 10px; font-size: 14px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; }
.card .hint { color: var(--text-dim); font-size: 12.5px; margin: 0 0 16px; }

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; color: var(--text-dim); }
.field .sub { font-size: 11.5px; color: #6b7688; }

input, select, textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 9px 11px;
  font-size: 13.5px;
  font-family: inherit;
  width: 100%;
  transition: 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; min-height: 80px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.check input { width: auto; }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  cursor: pointer;
  transition: 0.15s;
  font-family: inherit;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-ghost { background: transparent; }
.btn-danger { background: rgba(231, 76, 60, 0.15); border-color: var(--red); color: #ff8a7a; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.row-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 16px; }

/* ---------- Table ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--text-dim); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
tr:hover td { background: rgba(255, 255, 255, 0.015); }
td.mono, .mono { font-family: "Cascadia Mono", Consolas, monospace; font-size: 12px; }
.truncate { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
}
.badge-running { background: rgba(58, 160, 255, 0.16); color: var(--blue); }
.badge-succeeded { background: rgba(46, 204, 113, 0.16); color: var(--green); }
.badge-failed { background: rgba(231, 76, 60, 0.16); color: var(--red); }
.badge-cancelled { background: rgba(241, 196, 15, 0.16); color: var(--yellow); }
.badge-pending { background: rgba(152, 162, 179, 0.16); color: var(--text-dim); }

/* ---------- Stats ---------- */
.stat { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stat .value { font-size: 26px; font-weight: 700; }
.stat .label { color: var(--text-dim); font-size: 12.5px; margin-top: 2px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; flex-wrap: wrap; }
.tab {
  background: transparent; border: none; border-bottom: 2px solid transparent;
  color: var(--text-dim); padding: 10px 14px; cursor: pointer; font-size: 13.5px; font-family: inherit;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ---------- Log console ---------- */
.console {
  background: #0a0c10;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  height: 440px;
  overflow-y: auto;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.6;
}
.console .line { white-space: pre-wrap; word-break: break-word; }
.console .ts { color: #566074; margin-right: 8px; }
.console .info { color: #c7d0dd; }
.console .success { color: var(--green); }
.console .warn { color: var(--yellow); }
.console .error { color: #ff8a7a; }
.console .debug { color: #5b6474; }

/* ---------- Misc ---------- */
.hidden { display: none !important; }
.empty { color: var(--text-dim); text-align: center; padding: 30px; }
.spinner {
  width: 15px; height: 15px; border: 2px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  display: inline-block; animation: spin 0.8s linear infinite;
  vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 999;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  padding: 13px 18px; border-radius: 8px; box-shadow: var(--shadow);
  opacity: 0; transform: translateY(12px); transition: 0.25s; pointer-events: none;
  max-width: 380px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-left-color: var(--red); }
.toast.success { border-left-color: var(--green); }

.modal {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6);
  display: flex; align-items: center; justify-content: center; z-index: 998;
}
.modal-box {
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px; max-width: 560px; width: 90%;
  box-shadow: var(--shadow); max-height: 80vh; overflow: auto;
}

.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tag {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 6px; padding: 4px 9px; font-size: 12px;
}
button.tag-insert {
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  transition: 0.15s;
}
button.tag-insert:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

/* ---------- Built-in sheet grid ---------- */
.grid-table { border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.grid-table th, .grid-table td {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 0;
  vertical-align: top;
}
.grid-table thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--bg-elev);
  color: var(--text-dim);
  text-align: center;
  padding: 6px 4px;
  font-size: 11.5px;
  min-width: 120px;
}
.grid-table th.rownum, .grid-table td.rownum {
  position: sticky; left: 0; z-index: 1;
  background: var(--bg-elev);
  color: var(--text-dim);
  text-align: center;
  width: 46px; min-width: 46px;
  font-size: 11.5px;
  padding: 6px 4px;
}
.grid-table thead th.rownum { z-index: 3; }
.grid-table td.cell {
  min-width: 120px;
  max-width: 320px;
  padding: 7px 9px;
  font-size: 12.5px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  outline: none;
  cursor: text;
}
.grid-table td.cell:hover { background: rgba(255, 255, 255, 0.02); }
.grid-table td.cell:focus {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 2px var(--accent);
}
.grid-table td.rowdel {
  width: 40px; min-width: 40px;
  text-align: center;
  background: var(--bg-soft);
}
.grid-table td.rowdel .btn { padding: 1px 8px; line-height: 1.3; }

