:root {
  --bg: #f8f8f8;
  --panel: #ffffff;
  --panel-muted: #fbfbfb;
  --line: #e5e5e5;
  --line-strong: #d4d4d4;
  --text: #111111;
  --muted: #666666;
  --muted-strong: #404040;
  --green: #3ecf8e;
  --green-dark: #148b5b;
  --red: #d92d20;
  --amber: #b7791f;
  --blue: #2563eb;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.14);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 49px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
}

.brand,
.top-actions,
.org-switch,
.toolbar,
.search-box,
.input-action,
.split-inputs,
.form-actions {
  display: flex;
  align-items: center;
}

[data-lucide] {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.brand {
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 19px;
  height: 19px;
  background: linear-gradient(135deg, #3ecf8e 0 50%, transparent 50%), linear-gradient(45deg, #1f9c67 0 50%, transparent 50%);
  clip-path: polygon(48% 0, 100% 0, 58% 46%, 86% 46%, 22% 100%, 42% 56%, 0 56%);
}

.slash {
  color: #b7b7b7;
}

.org-switch {
  height: 32px;
  gap: 8px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-weight: 600;
}

.project-size {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  height: 19px;
  padding: 0 7px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  color: var(--muted-strong);
  background: #fff;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  line-height: 1;
  letter-spacing: 0;
  text-transform: uppercase;
}

.top-actions {
  gap: 8px;
}

.search-box {
  gap: 8px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
}

.icon-button {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #fff;
  color: var(--muted-strong);
}

.avatar {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 999px;
  background: #050505;
  color: #fff;
}

.shell {
  display: grid;
  grid-template-columns: 207px minmax(0, 1fr);
  min-height: calc(100vh - 49px);
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #f7f7f7;
  padding: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  padding: 0 10px;
  color: var(--muted-strong);
  text-decoration: none;
  border-radius: 6px;
}

.nav-item.active {
  background: #ededed;
  color: var(--text);
  font-weight: 600;
}

.nav-item.muted:hover {
  background: #f0f0f0;
}

.content {
  padding: 48px 32px 80px;
}

.projects-view {
  max-width: 1168px;
  margin: 0 auto;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 52px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  font-weight: 650;
}

.page-head p,
.field-help,
.project-meta,
.detail-muted,
.empty-state,
.event-time {
  color: var(--muted);
}

.toolbar {
  gap: 8px;
  margin-bottom: 16px;
}

.search-box {
  width: 284px;
}

.select-control,
.form-row input,
.form-row select {
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
}

.select-control {
  padding: 0 30px 0 10px;
}

.toolbar-spacer {
  flex: 1;
}

.view-toggle {
  border: 0;
  background: transparent;
}

.view-toggle.active {
  color: var(--text);
}

.primary-button,
.secondary-button {
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border-radius: 7px;
  border: 1px solid transparent;
  font-weight: 550;
}

.primary-button {
  background: var(--green);
  border-color: #2ebc7f;
  color: #06140d;
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.secondary-button {
  background: #fff;
  border-color: var(--line-strong);
  color: var(--text);
}

.compact-button {
  height: 28px;
  padding: 0 9px;
  font-size: 12px;
}

.projects-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.project-card {
  min-height: 176px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 16px;
  padding: 24px 20px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  text-align: left;
}

.project-card:hover {
  border-color: #c9c9c9;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.04);
}

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

.project-title {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  font-weight: 650;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  color: var(--muted-strong);
  background: #fff;
  font-size: 12px;
}

.status-pill.healthy {
  color: var(--green-dark);
  border-color: #a9e8ca;
  background: #ecfff6;
}

.status-pill.failed {
  color: var(--red);
  border-color: #f2b8b5;
  background: #fff5f4;
}

.status-pill.done {
  color: var(--green-dark);
  border-color: #a9e8ca;
  background: #ecfff6;
}

.status-pill.running {
  color: #7c3aed;
  border-color: #ddd6fe;
  background: #f5f3ff;
}

.status-pill.pending {
  color: var(--muted-strong);
  border-color: var(--line-strong);
  background: #f7f7f7;
}

.status-pill.skipped {
  color: #6f5800;
  border-color: #ead68b;
  background: #fffbe6;
}

.status-pill.provisioning,
.status-pill.starting,
.status-pill.queued {
  color: var(--amber);
  border-color: #f0d19c;
  background: #fffaf0;
}

.status-pill.stopped {
  color: var(--blue);
  border-color: #bfd0ff;
  background: #f4f7ff;
}

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

.card-actions a,
.card-actions button {
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  text-decoration: none;
}

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

.card-actions .danger-action {
  color: var(--red);
  border-color: #f2b8b5;
  background: #fffafa;
}

.empty-state {
  grid-column: 1 / -1;
  display: grid;
  place-items: center;
  min-height: 220px;
  border: 1px dashed var(--line-strong);
  border-radius: 7px;
  background: #fff;
  text-align: center;
}

.modal-shell.hidden,
.detail-panel.hidden {
  display: none;
}

.modal-shell {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: start center;
  overflow: auto;
  padding: 40px 16px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.24);
}

.create-card {
  position: relative;
  z-index: 1;
  width: min(672px, 100%);
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  box-shadow: var(--shadow);
}

.create-intro {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 16px;
  border-bottom: 1px solid var(--line);
}

.create-intro h2 {
  margin-bottom: 4px;
  font-size: 16px;
}

.create-intro p {
  color: var(--muted-strong);
  line-height: 1.35;
}

.form-row {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.form-row > label {
  padding-top: 8px;
  color: var(--text);
}

.form-row input,
.form-row select {
  width: 100%;
  padding: 0 12px;
}

.field-help {
  margin-top: 9px;
  line-height: 1.45;
}

.input-action {
  gap: 8px;
}

.input-action button {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
}

.split-inputs {
  gap: 8px;
}

.form-error {
  margin: 16px;
  padding: 10px 12px;
  border: 1px solid #f2b8b5;
  border-radius: 7px;
  color: var(--red);
  background: #fff5f4;
}

.form-success {
  margin: 16px;
  padding: 10px 12px;
  border: 1px solid #a9e8ca;
  border-radius: 7px;
  color: var(--green-dark);
  background: #ecfff6;
}

.form-actions {
  justify-content: flex-end;
  gap: 8px;
  padding: 16px;
}

.hidden {
  display: none;
}

.detail-panel {
  position: fixed;
  top: 49px;
  right: 0;
  z-index: 30;
  width: min(520px, 100vw);
  height: calc(100vh - 49px);
  overflow: auto;
  border-left: 1px solid var(--line);
  background: #fff;
  box-shadow: -20px 0 50px rgba(0, 0, 0, 0.08);
}

.detail-inner {
  padding: 22px;
}

.detail-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.detail-head h2 {
  font-size: 18px;
}

.detail-section {
  padding: 18px 0;
  border-top: 1px solid var(--line);
}

.detail-section h3 {
  margin-bottom: 12px;
  font-size: 13px;
  text-transform: uppercase;
  color: var(--muted);
}

.kv {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 10px;
  margin: 8px 0;
}

.kv span:first-child {
  color: var(--muted);
}

.kv code {
  word-break: break-all;
}

.steps {
  display: grid;
  gap: 8px;
}

.connect-panel {
  display: grid;
  gap: 14px;
}

.command-group {
  display: grid;
  gap: 7px;
}

.command-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 650;
}

.code-block {
  max-height: 190px;
  margin: 0;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #101214;
  color: #f5f5f5;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
}

.prompt-block {
  max-height: 280px;
}

.connect-meta {
  display: grid;
  gap: 2px;
}

.inline-error {
  margin: 0;
}

.step-row,
.event-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
}

.event-row {
  grid-template-columns: minmax(0, 1fr);
}

.event-time {
  font-size: 12px;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #f8f8f8;
}

.login-shell {
  width: min(392px, 100%);
}

.login-card {
  display: grid;
  gap: 16px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.08);
}

.login-brand {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding-bottom: 8px;
}

.login-brand h1 {
  font-size: 20px;
}

.login-brand p {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.4;
}

.login-card label {
  display: grid;
  gap: 7px;
}

.login-card label span {
  font-weight: 550;
}

.login-card input {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
}

.login-card .form-error {
  margin: 0;
}

.login-card .primary-button {
  width: 100%;
  height: 38px;
}

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .content {
    padding: 32px 16px 64px;
  }

  .projects-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .view-toggle {
    display: none;
  }

  .toolbar {
    flex-wrap: wrap;
  }

  .search-box,
  .select-control,
  .primary-button {
    width: 100%;
  }

  .projects-grid {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .form-row > label {
    padding-top: 0;
  }

  .split-inputs,
  .input-action {
    flex-direction: column;
    align-items: stretch;
  }
}
