/* ═══════════════════════════════════════════════════════════
   YANTRA — COMPONENT LIBRARY
   Har screen SIRF in components se banegi.
   Naya button/spacing chahiye? Yahan add karo, page pe nahi.
   ═══════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--t-body);
  color: var(--text);
  background: var(--canvas-bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: var(--r-sm); }
::selection { background: var(--primary-soft-2); }

/* SVG default — har icon 16px, component apne hisaab se override karta hai */
svg { width: 16px; height: 16px; flex: none; vertical-align: -3px; }

/* scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--r-full); border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); background-clip: content-box; }

/* ── 1. BUTTON — 3 type, bas ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  height: var(--btn-h); padding: 0 var(--s3);
  font-family: inherit; font-size: var(--t-body); font-weight: var(--w-semi);
  border-radius: var(--r); border: 1px solid transparent;
  cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
  text-decoration: none;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; flex: none; }

.btn-primary { background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-xs); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }

.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-hover); }

.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-hover); color: var(--text); }

.btn-sm { height: var(--btn-h-sm); padding: 0 var(--s2); font-size: var(--t-micro); }
.btn-icon { width: var(--btn-h); padding: 0; }
.btn-icon.btn-sm { width: var(--btn-h-sm); }
.btn-wa { background: var(--wa); color: #fff; }
.btn-danger { background: var(--error); color: #fff; }

/* ── 2. INPUT / SELECT ── */
.input, .select, .textarea {
  width: 100%; height: var(--btn-h); padding: 0 var(--s3);
  font-family: inherit; font-size: var(--t-body); color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r); transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; padding: var(--s2) var(--s3); resize: vertical; min-height: 72px; line-height: 1.55; }
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.select { appearance: none; padding-right: var(--s6); cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right var(--s3) center; }
.field { display: flex; flex-direction: column; gap: var(--s2); }
.label { font-size: var(--t-micro); font-weight: var(--w-semi); color: var(--text-2); letter-spacing: .02em; }
.hint { font-size: var(--t-micro); color: var(--text-muted); }

.input-search { position: relative; }
.input-search .input { padding-left: 34px; }
.input-search svg { position: absolute; left: var(--s3); top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--text-faint); pointer-events: none; }

/* ── 3. CARD ── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
}
.card-pad { padding: var(--s5); }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  padding: var(--s4) var(--s5); border-bottom: 1px solid var(--border);
}
.card-title { font-size: var(--t-head); font-weight: var(--w-semi); margin: 0; }
.card-body { padding: var(--s5); }

/* ── 4. PILL / CHIP / BADGE ── */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 var(--s2);
  font-size: var(--t-micro); font-weight: var(--w-semi);
  border-radius: var(--r-full); white-space: nowrap;
}
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.pill-plain::before { display: none; }
.pill-success { background: var(--success-soft); color: var(--success); }
.pill-error { background: var(--error-soft); color: var(--error); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-info { background: var(--info-soft); color: var(--info); }
.pill-muted { background: var(--surface-2); color: var(--text-muted); }
.pill-primary { background: var(--primary-soft-2); color: var(--primary); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 var(--s2) 0 var(--s2);
  font-size: var(--t-micro); font-weight: var(--w-med);
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r-sm); color: var(--text-2); cursor: pointer;
  transition: .15s;
}
.chip:hover { background: var(--surface-hover); }
.chip.active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }

/* ── 5. TABLE — dense, B2B ── */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--t-body); }
.table th {
  text-align: left; font-size: var(--t-micro); font-weight: var(--w-semi);
  color: var(--text-muted); letter-spacing: .04em; text-transform: uppercase;
  padding: 0 var(--s4); height: 38px; white-space: nowrap;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 1;
}
.table td { padding: 0 var(--s4); height: var(--row-h); border-bottom: 1px solid var(--border); color: var(--text-2); vertical-align: middle; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--surface-hover); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .cell-strong { color: var(--text); font-weight: var(--w-med); }
.table .cell-num { font-variant-numeric: tabular-nums; }
.table .cell-actions { text-align: right; white-space: nowrap; }
.table .cell-actions .btn { opacity: 0; transition: opacity .12s; }
.table tbody tr:hover .cell-actions .btn { opacity: 1; }
.table-checkbox { width: 40px; }

/* ── 6. CHECKBOX / TOGGLE ── */
.cb { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.toggle { position: relative; display: inline-block; width: 34px; height: 20px; flex: none; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle span { position: absolute; inset: 0; background: var(--border-strong); border-radius: var(--r-full); cursor: pointer; transition: .18s; }
.toggle span::before { content: ''; position: absolute; width: 14px; height: 14px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .18s; box-shadow: var(--shadow-xs); }
.toggle input:checked + span { background: var(--success); }
.toggle input:checked + span::before { transform: translateX(14px); }

/* ── 7. TABS ── */
.tabs { display: flex; gap: var(--s5); border-bottom: 1px solid var(--border); }
.tab {
  position: relative; padding: var(--s3) 0; background: none; border: 0;
  font-family: inherit; font-size: var(--t-body); font-weight: var(--w-med);
  color: var(--text-muted); cursor: pointer; transition: color .15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); font-weight: var(--w-semi); }
.tab.active::after { content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--primary); border-radius: 2px 2px 0 0; }

/* ── 8. EMPTY STATE ── */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: var(--s6) var(--s5); gap: var(--s3); }
.empty-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: var(--r-lg); background: var(--primary-soft); color: var(--primary); }
.empty-icon svg { width: 22px; height: 22px; }
.empty h4 { margin: 0; font-size: var(--t-head); font-weight: var(--w-semi); }
.empty p { margin: 0; color: var(--text-muted); max-width: 380px; }

/* ── 9. MODAL / DRAWER ── */
.overlay { position: fixed; inset: 0; background: rgba(16, 24, 40, .45); backdrop-filter: blur(2px); z-index: 100; display: none; }
.overlay.open { display: block; }
.modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(560px, calc(100vw - 32px)); max-height: 84vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-xl); box-shadow: var(--shadow-lg); z-index: 101; display: none;
}
.modal.open { display: block; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: var(--s4) var(--s5); border-bottom: 1px solid var(--border); }
.modal-title { font-size: var(--t-head); font-weight: var(--w-semi); margin: 0; }
.modal-body { padding: var(--s5); }
.modal-foot { display: flex; justify-content: flex-end; gap: var(--s2); padding: var(--s4) var(--s5); border-top: 1px solid var(--border); }

/* ── 10. TOAST ── */
.toasts { position: fixed; right: var(--s5); bottom: var(--s5); display: flex; flex-direction: column; gap: var(--s2); z-index: 200; }
.toast {
  display: flex; align-items: center; gap: var(--s2);
  padding: var(--s3) var(--s4); min-width: 260px;
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--success);
  border-radius: var(--r); box-shadow: var(--shadow-lg);
  font-weight: var(--w-med); animation: toastIn .22s ease-out;
}
.toast.err { border-left-color: var(--error); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── 11. AVATAR ── */
.avatar {
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  font-size: var(--t-micro); font-weight: var(--w-semi);
  background: var(--primary-soft-2); color: var(--primary);
}
.avatar-lg { width: 40px; height: 40px; font-size: var(--t-body); }

/* ── 12. SKELETON ── */
.skel { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-hover) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: skel 1.3s infinite; border-radius: var(--r-sm); }
@keyframes skel { to { background-position: -200% 0; } }

/* ── 13. PROGRESS ── */
.bar { height: 6px; background: var(--surface-2); border-radius: var(--r-full); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--primary); border-radius: var(--r-full); transition: width .4s; }

/* ── 14. TOOLTIP ── */
[data-tip] { position: relative; }
[data-tip]:hover::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--surface); font-size: var(--t-micro); font-weight: var(--w-med);
  padding: 5px var(--s2); border-radius: var(--r-sm); white-space: nowrap; z-index: 60; pointer-events: none;
}

/* ── 15. MENU (dropdown) ── */
.menu {
  position: absolute; min-width: 180px; padding: var(--s1);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--shadow-lg); z-index: 90; display: none;
}
.menu.open { display: block; }
.menu button {
  display: flex; align-items: center; gap: var(--s2); width: 100%;
  padding: var(--s2) var(--s3); background: none; border: 0; border-radius: var(--r-sm);
  font-family: inherit; font-size: var(--t-body); color: var(--text-2); text-align: left; cursor: pointer;
}
.menu button:hover { background: var(--surface-hover); color: var(--text); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: var(--s1) 0; }

/* ── 16. KPI TILE ── */
.kpi { position: relative; overflow: hidden; padding: var(--s4) var(--s5); }
.kpi::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px; background: var(--primary); opacity: .8; }
.kpi .k { font-size: var(--t-micro); font-weight: var(--w-semi); color: var(--text-muted); letter-spacing: .06em; text-transform: uppercase; }
.kpi .v { font-family: var(--font-display); font-size: var(--t-big); font-weight: var(--w-bold); color: var(--text); line-height: 1.15; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: var(--t-micro); color: var(--text-muted); margin-top: 2px; }
.kpi.money::before { background: var(--success); }
.kpi.money .v { color: var(--success); }
.kpi.bad::before { background: var(--error); }

/* ── 17. LIST ROW (inbox/timeline) ── */
.lrow {
  display: flex; gap: var(--s3); padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--border); cursor: pointer; transition: background .12s;
}
.lrow:hover { background: var(--surface-hover); }
.lrow.active { background: var(--primary-soft); box-shadow: inset 2px 0 0 var(--primary); }
.lrow .lmain { flex: 1; min-width: 0; }
.lrow .lname { font-weight: var(--w-semi); color: var(--text); display: flex; align-items: center; gap: var(--s2); }
.lrow .lprev { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.lrow .lmeta { font-size: var(--t-micro); color: var(--text-faint); white-space: nowrap; }

/* ── 18. SECTION HEADER ── */
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s4); }
.sec-title { font-size: var(--t-head); font-weight: var(--w-semi); margin: 0; }

/* ── 19. DIVIDER + UTILITIES ── */
.hr { border: 0; border-top: 1px solid var(--border); margin: var(--s4) 0; }
.row { display: flex; align-items: center; gap: var(--s3); }
.row-tight { display: flex; align-items: center; gap: var(--s2); }
.col { display: flex; flex-direction: column; gap: var(--s3); }
.spacer { flex: 1; }
.grid { display: grid; gap: var(--s4); }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.strong { color: var(--text); font-weight: var(--w-semi); }
.mono { font-family: var(--font-mono); font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.hide { display: none !important; }

/* ── 20. NODE (canvas) — compact, config right panel me ── */
.node {
  position: absolute; width: 236px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r-lg); box-shadow: var(--shadow-node);
  cursor: grab; user-select: none; transition: box-shadow .15s, border-color .15s, transform .06s;
}
.node:active { cursor: grabbing; }
.node:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.node.selected { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft), var(--shadow); }
.node-top { display: flex; align-items: center; gap: var(--s2); padding: var(--s3); }
.node-ico { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none; color: #fff; box-shadow: 0 2px 6px -1px rgba(16,24,40,.20); }
.node-ico svg { width: 15px; height: 15px; }
.node-txt { min-width: 0; flex: 1; }
.node-kind { font-size: 10px; font-weight: var(--w-bold); letter-spacing: .08em; text-transform: uppercase; }
.node-name { font-weight: var(--w-semi); color: var(--text); font-size: var(--t-body); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.node-foot { display: flex; align-items: center; gap: 6px; padding: 0 var(--s3) var(--s3); font-size: var(--t-micro); color: var(--text-muted); }
.node-app { display: inline-flex; align-items: center; gap: 4px; padding: 2px 6px; background: var(--surface-2); border-radius: var(--r-sm); font-weight: var(--w-med); }

.node.trigger .node-kind { color: var(--node-trigger); }
.node.action .node-kind { color: var(--node-action); }
.node.logic .node-kind { color: var(--node-logic); }
.node.ai .node-kind { color: var(--node-ai-a); }
.node.err .node-kind { color: var(--node-error); }

/* run state on node */
.node .runstate { position: absolute; top: -7px; right: -7px; width: 18px; height: 18px; border-radius: 50%; display: none; place-items: center; border: 2px solid var(--surface); }
.node.ok .runstate { display: grid; background: var(--success); }
.node.fail .runstate { display: grid; background: var(--error); }
.node .runstate svg { width: 9px; height: 9px; color: #fff; }
.node.fail { border-color: var(--error); }

/* connector dots */
.node .port { position: absolute; width: 9px; height: 9px; border-radius: 50%; background: var(--surface); border: 2px solid var(--edge); left: 50%; transform: translateX(-50%); }
.node .port.in { top: -5px; }
.node .port.out { bottom: -5px; }
.node:hover .port { border-color: var(--primary); }

/* ── 21. BANNER — one line the user can act on ── */
.banner {
  display: flex; gap: var(--s3); align-items: flex-start;
  padding: var(--s3) var(--s4); border-radius: var(--r);
  font-size: var(--t-body); line-height: 1.45;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2);
}
.banner svg { flex: none; margin-top: 1px; }
.banner b { color: var(--text); }
.banner-error { background: var(--error-soft); border-color: var(--error); color: var(--error); }
.banner-error b { color: var(--error); }
.banner-info  { background: var(--info-soft);  border-color: var(--info);  color: var(--info); }
.banner-info b { color: var(--info); }
.banner-warn  { background: var(--warn-soft);  border-color: var(--warn);  color: var(--warn); }

/* ── 22. KEY / VALUE ROW ── */
.kv { display: flex; align-items: baseline; gap: var(--s4); justify-content: space-between; }
.kv .k { font-size: var(--t-micro); color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; flex: none; }
.kv .v { font-size: var(--t-body); color: var(--text); text-align: right; min-width: 0; overflow-wrap: anywhere; }

/* ── 23. SPINNER — for buttons that are actually waiting ── */
.spinner {
  display: inline-block; width: 13px; height: 13px; vertical-align: -2px;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin .65s linear infinite; margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 24. PLAN CARD ── */
.plan-list { list-style: none; padding: 0; margin: var(--s2) 0 var(--s4); display: flex; flex-direction: column; gap: var(--s2); }
.plan-list li { display: flex; gap: var(--s2); align-items: flex-start; font-size: var(--t-micro); color: var(--text-2); }
.plan-list li svg { flex: none; color: var(--primary); margin-top: 1px; }
.plan-best { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

/* ── 25. PICK ROW — a choice you can read before you make it ── */
.pickrow {
  display: flex; align-items: flex-start; gap: var(--s3);
  padding: var(--s3); border: 1px solid var(--border); border-radius: var(--r);
  background: var(--surface); cursor: pointer; font-size: var(--t-body); color: var(--text);
  transition: border-color .12s, background .12s;
}
.pickrow:hover { border-color: var(--border-strong); background: var(--surface-2); }
.pickrow input[type="radio"] { margin-top: 3px; accent-color: var(--primary); flex: none; }
.pickrow:has(input:checked), .pickrow.on { border-color: var(--primary); background: var(--primary-soft); }
.pickrow b { font-weight: var(--w-semi); }

/* ── 26. TEMPLATE STEP STRIP ── */
.tstep { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; font-size: var(--t-micro); color: var(--text-2); }
.tstep-n { display: inline-flex; align-items: center; gap: 4px; background: var(--surface-2); border: 1px solid var(--border);
           padding: 2px var(--s2); border-radius: var(--r-full); white-space: nowrap; }
.tstep-n svg { width: 12px; height: 12px; }
.tstep i { color: var(--text-muted); font-style: normal; }
.tflow { display: flex; flex-direction: column; gap: var(--s2); }
.tflow-step { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s3);
              border: 1px solid var(--border); border-radius: var(--r); background: var(--surface-2); font-size: var(--t-body); }
.tflow-ic { width: 26px; height: 26px; border-radius: var(--r-sm); display: grid; place-items: center; color: #fff; flex: none; }
.tflow-ic svg { width: 14px; height: 14px; }
