:root {
  --bg: #06090f;
  --bg-elev: #0f1624;
  --bg-elev-2: #162235;
  --line: #2a3a53;
  --line-strong: #3a5275;
  --text: #edf4ff;
  --muted: #9fb4d2;
  --brand: #4f8cff;
  --brand-2: #345fce;
  --success: #2dd4bf;
  --danger: #fb7185;
  --warning: #f6c453;
  --radius: 14px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 500px at 20% -10%, rgba(79, 140, 255, 0.18), transparent 55%),
    radial-gradient(700px 500px at 100% 0, rgba(57, 99, 216, 0.2), transparent 60%),
    var(--bg);
  color: var(--text);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.app-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.4rem;
  border-bottom: 1px solid var(--line);
  background: rgba(6, 9, 15, 0.85);
  backdrop-filter: blur(14px);
}

.kicker {
  margin: 0 0 0.2rem;
  color: var(--brand);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  font-weight: 700;
}

h1, h2, h3 { margin: 0; }

h1 {
  font-size: 1.5rem;
  line-height: 1.2;
  font-weight: 700;
}

.subtitle {
  margin: 0.3rem 0 0;
  color: var(--muted);
  max-width: 740px;
}

.muted { color: var(--muted); }

.auth-panel {
  min-width: 330px;
  display: grid;
  gap: 0.45rem;
}

.auth-panel label {
  color: var(--muted);
  font-size: 0.84rem;
}

.auth-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.45rem;
}

.layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 1rem;
  padding: 1rem;
}

.sidebar {
  display: grid;
  align-content: start;
  gap: 0.9rem;
}

.workspace {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 0.85rem;
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(22, 34, 53, 0.95), rgba(16, 24, 38, 0.94));
  box-shadow: var(--shadow);
  padding: 0.95rem;
  display: grid;
  gap: 0.7rem;
}

.stack { gap: 0.8rem; }

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
}

.hint {
  color: var(--muted);
  font-size: 0.83rem;
}

.badge {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 0.22rem 0.65rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
}

.stat {
  border: 1px solid var(--line);
  background: rgba(8, 12, 19, 0.55);
  border-radius: 10px;
  padding: 0.5rem;
  display: grid;
  gap: 0.2rem;
}

.stat .label {
  font-size: 0.75rem;
  color: var(--muted);
}

.stat strong {
  font-size: 1.05rem;
  font-weight: 650;
}

input, textarea, select, button {
  width: 100%;
  font: inherit;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0b1220;
  color: var(--text);
  padding: 0.58rem 0.72rem;
  outline: none;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(79, 140, 255, 0.2);
}

button {
  background: linear-gradient(180deg, var(--brand), var(--brand-2));
  border-color: var(--brand);
  cursor: pointer;
  color: #f8fbff;
  font-weight: 600;
  transition: transform 120ms ease, filter 120ms ease;
}

button:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

button.secondary {
  background: #0b1220;
  border-color: var(--line-strong);
  color: #dbe7ff;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(15, 22, 36, 0.9);
  padding: 0.6rem;
}

.tab {
  width: auto;
  background: #0b1220;
  border-color: var(--line);
  color: var(--muted);
}

.tab.active {
  background: linear-gradient(180deg, rgba(79, 140, 255, 0.2), rgba(79, 140, 255, 0.08));
  border-color: var(--brand);
  color: var(--text);
}

.panel {
  display: none;
  gap: 0.85rem;
}

.panel.active {
  display: grid;
}

.form {
  display: grid;
  gap: 0.58rem;
  max-width: 900px;
}

.row-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
}

.row-form input,
.row-form select,
.row-form button {
  width: auto;
  min-width: 180px;
}

.row-form.compact select {
  min-width: 220px;
}

.row-form.compact button {
  min-width: 130px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0.75rem;
}

.slug {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  color: var(--muted);
  font-size: 0.78rem;
  padding: 0.18rem 0.42rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  width: fit-content;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.actions button {
  width: auto;
}

.run-btn {
  background: linear-gradient(180deg, rgba(45, 212, 191, 0.18), rgba(45, 212, 191, 0.07));
  border-color: rgba(45, 212, 191, 0.6);
  color: #d6fffa;
}

.run-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.label-mini {
  font-size: 0.8rem;
  color: var(--muted);
}

.wf-input {
  width: 100%;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  padding: 0.62rem;
  vertical-align: top;
}

th {
  color: #c4d6f3;
  background: rgba(8, 12, 19, 0.65);
}

a {
  color: #8fb8ff;
}

.run-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem 0.75rem;
  background: rgba(8, 12, 19, 0.55);
  margin-bottom: 0.6rem;
}

.status.running { color: var(--warning); font-weight: 700; }
.status.success { color: var(--success); font-weight: 700; }
.status.error { color: var(--danger); font-weight: 700; }
.err-line { color: var(--danger); margin-top: 0.35rem; }
.ok-line { color: var(--success); margin-top: 0.35rem; }

.connection-status {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.65rem;
  background: rgba(8, 12, 19, 0.45);
}

.connection-grid {
  list-style: none;
  margin: 0 0 0.5rem;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.4rem 0.7rem;
}

.connection-grid li {
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.4rem 0.55rem;
  background: rgba(11, 18, 31, 0.55);
}

.connection-grid .ok {
  color: var(--success);
}

.connection-grid .bad {
  color: var(--danger);
}

.mini-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.mini-actions button {
  min-width: 110px;
}

pre {
  margin: 0.5rem 0 0;
  background: #070b14;
  border: 1px solid #1f2d44;
  border-radius: 10px;
  padding: 0.55rem;
  overflow: auto;
  max-height: 220px;
  font-size: 0.74rem;
}

.guide {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--muted);
  display: grid;
  gap: 0.35rem;
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  max-width: 500px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  background: #0f1724;
  color: var(--text);
  z-index: 100;
  box-shadow: var(--shadow);
}

.toast.err {
  border-color: var(--danger);
}

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .auth-panel {
    width: 100%;
    min-width: 0;
  }
}
