:root {
  --bg: #0c1118;
  --bg-2: #101820;
  --card: #131c27;
  --line: #243244;
  --text: #e7eef8;
  --muted: #8ea0b5;
  --accent: #4c8dff;
  --accent-2: #8b7cff;
  --ok: #3dce9a;
  --warn: #e2b340;
  --danger: #ff6b7a;
  --shadow: 0 10px 30px rgba(0, 0, 0, .25);
  --sidebar: 248px;
  --radius: 12px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Segoe UI", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }

.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar);
  background: #0a0f15;
  border-right: 1px solid var(--line);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 16px; }
.brand img { width: 36px; height: 36px; }
.brand strong { display: block; letter-spacing: .04em; }
.brand span, .muted, .help { color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 6px; }
.nav a, .icon-btn, .btn, .text-btn {
  display: inline-flex; align-items: center; gap: 10px;
}
.nav a {
  color: var(--muted);
  padding: 9px 10px;
  border-radius: 9px;
}
.nav a.active, .nav a:hover { color: var(--text); background: #172232; }
.nav a.active { box-shadow: inset 2px 0 0 var(--accent); }
.sidebar-foot { margin-top: auto; padding: 12px 8px 4px; font-size: 12px; color: var(--muted); }
.main { flex: 1; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(12, 17, 24, .92);
  position: sticky; top: 0; z-index: 5;
}
.search { flex: 1; display: flex; }
.search input, .field input:not([type="checkbox"]), .field select, .field textarea {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 11px;
}
.search input:focus, .field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid rgba(76, 141, 255, .45);
  border-color: var(--accent);
}
.content { padding: 28px 32px 40px; }
.page-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-end; margin-bottom: 22px; }
.page-head h1, .card h2, .auth-card h1 { margin: 0 0 6px; font-weight: 620; letter-spacing: -.02em; }
.page-head .muted { margin: 0; }
h1 { font-size: 1.6rem; }
.dash { display: flex; flex-direction: column; gap: 22px; }
.grid { display: grid; gap: 18px; }
.kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cols-2 { grid-template-columns: minmax(0, 1.2fr) minmax(280px, .9fr); }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
}
.card h2 { margin-bottom: 14px; }
.kpi { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; min-height: 138px; }
.kpi strong { display: block; font-size: 1.85rem; line-height: 1.1; margin: 0; }
.kpi em { font-style: normal; color: var(--muted); font-size: .85rem; }
.kpi .help { margin-top: auto; line-height: 1.45; }
.stat-list { display: grid; gap: 10px; margin-top: 16px; }
.stat-list p {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  margin: 0; padding: 12px 14px; background: var(--bg-2); border-radius: 10px;
}
.card > .empty, .card > .badge { margin-top: 4px; }
.card > .help { margin: 10px 0 0; }
.btn {
  background: var(--accent);
  color: #06101d;
  border: 0;
  border-radius: 9px;
  padding: 9px 13px;
  font-weight: 650;
  cursor: pointer;
}
.btn.secondary, .text-btn { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid #5a3038; }
.btn:hover { filter: brightness(1.08); }
.icon-btn {
  background: transparent; border: 1px solid var(--line); color: var(--text);
  border-radius: 9px; padding: 8px; cursor: pointer; position: relative;
}
.icon { width: 18px; height: 18px; }
.badge {
  display: inline-flex; align-items: center;
  border-radius: 999px; padding: 2px 8px; font-size: 12px;
  border: 1px solid var(--line); color: var(--muted);
}
.badge-success, .badge-active, .badge-connected { color: var(--ok); border-color: #1e6b52; }
.badge-failed, .badge-error, .badge-disabled { color: var(--danger); border-color: #6a3038; }
.badge-queued, .badge-draft, .badge-not_configured, .badge-preview { color: var(--warn); border-color: #6d5820; }
.badge-running, .badge-inactive { color: var(--accent); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; letter-spacing: .04em; text-transform: uppercase; }
.filters, .inline-form, .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field span { display: flex; align-items: center; gap: 10px; }
.field.grow { flex: 1; }
.help { font-size: .85rem; }
.alert, .empty {
  border: 1px dashed var(--line); border-radius: 10px; padding: 12px 14px; color: var(--muted);
}
.alert.error { color: var(--danger); border-color: #6a3038; }
.alert.info { color: #c9d7ff; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 20; }
.toast {
  background: #182333; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; min-width: 240px; max-width: 420px; box-shadow: var(--shadow);
}
.toast.success { border-color: #1e6b52; }
.toast.error { border-color: #6a3038; }
.market-body { min-height: 100vh; }
.market-bar, .market, .market-foot { width: min(1080px, calc(100% - 48px)); margin-left: auto; margin-right: auto; }
.market-bar { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 22px 0; }
.market-bar .brand { padding: 0; color: inherit; }
.market { display: flex; flex-direction: column; gap: 28px; padding-bottom: 28px; }
.market-hero { max-width: 720px; padding: 18px 0 8px; }
.eyebrow { margin: 0 0 12px; color: var(--accent); font-size: .85rem; letter-spacing: .04em; text-transform: uppercase; }
.market-hero h1 { font-size: clamp(2.1rem, 5vw, 3.4rem); line-height: 1.12; margin: 0 0 16px; }
.lead { margin: 0; color: var(--muted); font-size: 1.05rem; max-width: 62ch; }
.market-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; margin-top: 26px; }
.market-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.market-grid p, .market-contact p, .market-reasons p { margin: 0; color: var(--muted); }
.market-why { display: flex; flex-direction: column; gap: 18px; }
.market-why > h2 { margin: 0; font-size: 1.45rem; }
.market-reasons { grid-template-columns: 1fr 1fr; }
.market-reasons h2 { margin-bottom: 10px; font-size: 1.05rem; }
.market-contact { display: flex; justify-content: space-between; align-items: center; gap: 24px; }
.market-contact h2 { margin-bottom: 8px; }
.market-foot { padding: 8px 0 32px; color: var(--muted); font-size: .85rem; }
a.btn { text-decoration: none; }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(460px, 100%); }
.auth-card .mark { width: 48px; height: 48px; }
.chart { width: 100%; height: 160px; }
.bar-row { display: flex; align-items: flex-end; gap: 6px; height: 140px; margin-bottom: 22px; }
.bar { flex: 1; background: #1d4f93; border-radius: 5px 5px 0 0; min-height: 2px; position: relative; }
.bar span { position: absolute; left: 50%; bottom: -18px; transform: translateX(-50%); font-size: 10px; color: var(--muted); }
.builder { display: grid; grid-template-columns: 210px 1fr 280px; gap: 12px; min-height: 640px; }
.palette, .inspector { border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: #101820; }
.palette button, .node-port {
  width: 100%; text-align: left; background: #172232; color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin-bottom: 6px; cursor: pointer;
}
.canvas-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 12px; background:
  linear-gradient(#1a2533 1px, transparent 1px), linear-gradient(90deg, #1a2533 1px, transparent 1px);
  background-size: 24px 24px; background-color: #0e1620; }
.canvas { position: relative; width: 1400px; height: 760px; }
.node {
  position: absolute; width: 220px; background: #152131; border: 1px solid #345074;
  border-radius: 10px; padding: 8px;
}
.node.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.node header { display: flex; justify-content: space-between; gap: 6px; cursor: grab; font-size: .92rem; }
.node .type { color: var(--muted); font-size: 12px; }
.ports { display: flex; justify-content: space-between; gap: 6px; margin-top: 8px; }
.ports button { width: auto; margin: 0; padding: 4px 6px; font-size: 12px; }
.links { margin-top: 8px; font-size: 13px; }
.menu-btn { display: none; }
.dot { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; background: var(--danger); border-radius: 99px; }
.pre {
  white-space: pre-wrap; word-break: break-word; background: #0d141c; border-radius: 8px; padding: 10px;
  border: 1px solid var(--line); font-family: Consolas, monospace; font-size: 12px;
}
.steps { display: flex; flex-direction: column; gap: 8px; }
.step { border-left: 2px solid var(--line); padding-left: 10px; }
.pager { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.hidden { display: none; }
.guide h3 { margin: 16px 0 6px; font-size: 1rem; }
.guide ol, .guide ul { margin: 6px 0 0; padding-left: 1.2rem; }
.guide li + li { margin-top: 6px; }
.guide code { font-family: Consolas, monospace; font-size: .92em; color: var(--accent); }

@media (max-width: 1100px) {
  .kpis, .cols-2, .builder, .market-grid, .market-reasons { grid-template-columns: 1fr; }
  .market-contact { flex-direction: column; align-items: flex-start; }
  .canvas { width: 980px; }
}
@media (max-width: 860px) {
  .menu-btn { display: inline-flex; }
  .sidebar { position: fixed; z-index: 30; transform: translateX(-105%); transition: transform .18s ease; }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::before { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 25; }
  .topbar, .content { padding-left: 14px; padding-right: 14px; }
  .page-head { flex-direction: column; align-items: stretch; }
  .market-bar, .market, .market-foot { width: min(1080px, calc(100% - 32px)); }
  .market-grid, .market-contact, .market-reasons { grid-template-columns: 1fr; display: grid; }
  .market-contact { align-items: start; }
}
@media print {
  .sidebar, .topbar, .no-print, .toasts { display: none !important; }
  body, .card, .content { background: white; color: black; }
  .card { border-color: #ccc; }
}
