/* ===========================================================================
   Agent Builder — modern dark UI
   =========================================================================== */
:root {
  --bg: #0e1117;
  --bg-2: #151b24;
  --panel: #1a212c;
  --panel-2: #20293566;
  --border: #2a3340;
  --border-2: #364152;
  --text: #e6edf3;
  --muted: #8b97a7;
  --primary: #6366f1;
  --primary-2: #818cf8;
  --primary-ghost: #6366f126;
  --success: #22c55e;
  --danger: #ef4444;
  --warn: #f59e0b;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 30px -10px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 600px at 80% -10%, #1b2740 0%, var(--bg) 55%) fixed;
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  font-size: 14px;
}
code, .webhook-url, .tool-name, .tool-url { font-family: "JetBrains Mono", monospace; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 18px; margin: 0; }
h3 { font-size: 15px; margin: 0; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
a { color: var(--primary-2); }

/* --- Buttons --------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 9px 15px; font-size: 13.5px; font-weight: 600; cursor: pointer;
  transition: .15s ease; font-family: inherit; white-space: nowrap;
}
.btn-sm { padding: 7px 12px; font-size: 12.5px; }
.btn-xs { padding: 4px 9px; font-size: 11.5px; border-radius: 7px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-2); }
.btn-secondary { background: var(--panel); color: var(--text); border-color: var(--border-2); }
.btn-secondary:hover { border-color: var(--primary); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: #ffffff0d; color: var(--text); }
.btn-danger { background: var(--danger) !important; color: #fff !important; }
.btn-danger-text { color: #f87171; }
.btn-danger-text:hover { background: #ef444418; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* --- Login ----------------------------------------------------------------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card {
  width: 360px; background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 30px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 12px;
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.login-brand h1 { font-size: 19px; }
.login-brand p { color: var(--muted); font-size: 12.5px; }
.logo-dot {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), #a855f7);
  box-shadow: 0 0 18px #6366f180; flex: none;
  display: grid; place-items: center;
}
.logo-dot svg { width: 64%; height: 64%; display: block; filter: drop-shadow(0 1px 1px #0003); }
.login-card .field-label { margin-top: 6px; }
.login-card .btn { margin-top: 10px; }

/* --- Layout ---------------------------------------------------------------- */
.layout { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar {
  background: #0c1016; border-right: 1px solid var(--border);
  padding: 18px 14px; display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.side-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; padding: 6px 8px 16px; }
.side-brand .logo-dot { width: 26px; height: 26px; border-radius: 8px; }
.side-section { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 14px 10px 6px; }
.side-tenants { display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  width: 100%; text-align: left; background: transparent; border: none; color: var(--text);
  padding: 9px 11px; border-radius: 9px; cursor: pointer; font-size: 13.5px; font-family: inherit;
}
.nav-item:hover { background: #ffffff0a; }
.nav-item.active { background: var(--primary-ghost); color: var(--primary-2); font-weight: 600; }
.nav-sub { font-size: 11px; color: var(--muted); }

.main-col { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 26px; border-bottom: 1px solid var(--border); background: #0e131bcc; backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 5;
}
.crumbs { font-weight: 600; }
.top-right { display: flex; align-items: center; gap: 12px; }
.user-chip { font-size: 12.5px; color: var(--muted); background: var(--panel); border: 1px solid var(--border); padding: 5px 11px; border-radius: 20px; }

/* Language switcher (EN / ES) */
.lang-switch { display: inline-flex; border: 1px solid var(--border-2); border-radius: 8px; overflow: hidden; }
.lang-opt {
  background: transparent; color: var(--muted); border: none; padding: 5px 10px;
  font-size: 11.5px; font-weight: 700; cursor: pointer; font-family: inherit; transition: .15s;
}
.lang-opt:hover { color: var(--text); background: #ffffff0d; }
.lang-opt.active { background: var(--primary); color: #fff; }
.login-top { display: flex; justify-content: flex-end; }
.content { padding: 26px; max-width: 1180px; width: 100%; }

/* --- Page head ------------------------------------------------------------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 22px; gap: 16px; }
.page-head p { margin-top: 5px; }

/* --- Cards ----------------------------------------------------------------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; }
.card {
  background: linear-gradient(180deg, var(--panel), #161d27);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 18px;
  display: flex; flex-direction: column; gap: 13px; transition: .15s;
}
.card:hover { border-color: var(--border-2); transform: translateY(-1px); }
.card-top { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 40px; height: 40px; border-radius: 11px; flex: none; display: grid; place-items: center;
  font-weight: 700; background: linear-gradient(135deg, #6366f1, #a855f7); color: #fff;
}
.avatar.agent { background: linear-gradient(135deg, #0ea5e9, #6366f1); font-size: 18px; }
.card-title-wrap { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.card-title-wrap h3 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { font-size: 11px; color: var(--muted); }
.card-desc { color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.status-dot.on { background: var(--success); box-shadow: 0 0 8px var(--success); }
.status-dot.off { background: #475569; }

.kv { display: flex; flex-wrap: wrap; gap: 7px; }
.pill { font-size: 11.5px; padding: 4px 10px; border-radius: 20px; border: 1px solid var(--border-2); white-space: nowrap; }
.pill.ok { color: #86efac; border-color: #22c55e44; background: #22c55e14; }
.pill.off { color: #fca5a5; border-color: #ef444433; background: #ef444410; }
.pill.neutral { color: var(--muted); background: #ffffff08; }

.webhook-row { display: flex; align-items: center; gap: 8px; background: #0c1016; border: 1px solid var(--border); border-radius: 9px; padding: 8px 10px; }
.webhook-label { font-size: 11px; color: var(--muted); flex: none; }
.webhook-url { font-size: 11.5px; color: var(--primary-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.card-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }

/* --- Data table ------------------------------------------------------------ */
.table-wrap {
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow-x: auto; overflow-y: hidden;   /* scroll wide tables instead of clipping */
  background: linear-gradient(180deg, var(--panel), #161d27); box-shadow: var(--shadow);
}
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 13px 18px; text-align: left; vertical-align: middle; }
.data-table thead th {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); background: #0e131b66; border-bottom: 1px solid var(--border);
}
.data-table tbody td { border-bottom: 1px solid var(--border); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr.row-click { cursor: pointer; transition: background .15s; }
.data-table tbody tr.row-click:hover { background: #ffffff07; }
.col-center { text-align: center; }
.col-actions { text-align: right; width: 1%; white-space: nowrap; }

.t-ident { display: flex; align-items: center; gap: 12px; min-width: 0; }
.t-ident-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.t-name { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-user { font-size: 11.5px; color: var(--muted); }
.avatar.sm { width: 34px; height: 34px; border-radius: 9px; font-size: 14px; }

.count-badge {
  display: inline-grid; place-items: center; min-width: 26px; height: 24px; padding: 0 8px;
  border-radius: 7px; font-size: 12.5px; font-weight: 600; color: var(--text);
  background: #ffffff0d; border: 1px solid var(--border-2);
}

.wh-cell { display: flex; align-items: center; gap: 9px; }
.wh-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.wh-dot.on { background: var(--success); box-shadow: 0 0 7px var(--success); }
.wh-dot.off { background: #475569; }
.wh-url { font-size: 11.5px; color: var(--primary-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 360px; }

.status-cell { display: inline-flex; align-items: center; gap: 8px; }
.status-label { font-size: 12.5px; color: var(--muted); }

.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px;
  border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer; transition: .15s;
}
.icon-btn:hover { background: #ffffff0d; color: var(--text); border-color: var(--border-2); }
.icon-btn.danger:hover { color: #f87171; background: #ef444418; border-color: #ef444433; }
.icon-btn svg { display: block; }

/* --- Filters bar (calls report) -------------------------------------------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters .input { width: auto; }
.filter-date { display: flex; flex-direction: column; gap: 2px; }

/* --- Call detail ----------------------------------------------------------- */
.call-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 24px; }
.meta-item { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.meta-label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.meta-val { font-size: 13.5px; word-break: break-word; }
.section-title { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.transcript { display: flex; flex-direction: column; gap: 8px; max-height: 50vh; overflow-y: auto; }
.ev { padding: 8px 12px; border-radius: 10px; border: 1px solid var(--border); background: #0c1016; }
.ev-role { display: block; font-size: 11px; font-weight: 700; color: var(--muted); margin-bottom: 2px; }
.ev-text { font-size: 13px; line-height: 1.45; white-space: pre-wrap; }
.ev-user { border-left: 3px solid var(--primary); }
.ev-agent { border-left: 3px solid var(--success); }
.ev-tool { border-left: 3px solid var(--warn); }
.ev-tool .ev-text { font-family: "JetBrains Mono", monospace; font-size: 11.5px; color: var(--muted); }

/* --- Empty state ----------------------------------------------------------- */
.empty { text-align: center; padding: 50px 20px; color: var(--muted); border: 1px dashed var(--border-2); border-radius: var(--radius); grid-column: 1 / -1; }
.empty-icon { font-size: 34px; opacity: .5; margin-bottom: 8px; }
.empty h3 { margin-bottom: 5px; color: var(--text); }

/* --- Forms / fields -------------------------------------------------------- */
/* align-content:start keeps fields packed at the top with their natural spacing.
   Without it, short tabs stretched their rows to fill the panel height (which is
   sized to the tallest tab), leaving the fields far too separated vertically. */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-content: start; }
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field-full { grid-column: 1 / -1; }
.field-label { display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; color: #c3ccd8; }
/* Toggle as a settings-style row: label left, switch right, in a subtle card. */
.field-toggle {
  flex-direction: row; align-items: center; justify-content: space-between; gap: 14px;
  background: #0c1016; border: 1px solid var(--border); border-radius: 10px; padding: 0 14px; min-height: 46px;
}
.field-toggle .field-label { margin: 0; }
.field-toggle .switch { flex: none; }
.field-hint { font-weight: 400; color: var(--muted); }
.field-error { margin-top: 5px; font-size: 12px; color: #f3a3a3; }
.input.invalid { border-color: #b35454; }
.input.valid { border-color: #3f7d52; }
.input {
  width: 100%; background: #0c1016; border: 1px solid var(--border-2); color: var(--text);
  border-radius: 9px; padding: 10px 12px; font-size: 13.5px; font-family: inherit; transition: .15s;
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ghost); }
.textarea { resize: vertical; line-height: 1.5; }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238b97a7'%3E%3Cpath d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }

/* Switch */
.switch { position: relative; display: inline-flex; width: 44px; height: 25px; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: #364152; border-radius: 20px; transition: .2s; }
.slider::before { content: ""; position: absolute; height: 19px; width: 19px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(19px); }

/* Range */
.range-wrap { display: flex; align-items: center; gap: 12px; }
.range { flex: 1; accent-color: var(--primary); }
.range-val { font-family: "JetBrains Mono", monospace; font-size: 12.5px; color: var(--primary-2); min-width: 38px; text-align: right; }

/* --- Info icon / tooltip --------------------------------------------------- */
.info-wrap { position: relative; display: inline-flex; }
.info-icon {
  width: 15px; height: 15px; border-radius: 50%; border: 1px solid var(--border-2);
  display: grid; place-items: center; font-size: 10px; font-style: italic; font-weight: 700;
  color: var(--muted); cursor: help; font-family: Georgia, serif;
}
.info-icon:hover { border-color: var(--primary); color: var(--primary-2); }
.info-pop {
  position: absolute; top: 22px; left: -8px; z-index: 50; width: 260px;
  background: #0b0f15; border: 1px solid var(--border-2); border-radius: 10px; padding: 11px 13px;
  box-shadow: var(--shadow); display: none; flex-direction: column; gap: 8px;
}
/* When a tooltip would spill off the right edge, open it leftward instead. */
.info-pop.pop-left { left: auto; right: -8px; }
.info-wrap:hover .info-pop, .info-icon:focus + .info-pop { display: flex; }
.info-pop-text { font-size: 12px; line-height: 1.5; color: #cdd6e1; font-weight: 400; }
.info-pop-link { font-size: 11.5px; font-weight: 600; cursor: pointer; }

/* Full help box (opened from "Learn more"): structured, readable docs */
.doc-box { font-size: 14px; line-height: 1.72; color: #d4dce6; }
.doc-box > :first-child { margin-top: 0; }
.doc-box > :last-child { margin-bottom: 0; }
.doc-box p { margin: 0 0 13px; }
/* Subtitles / section labels */
.doc-box .doc-h {
  margin: 20px 0 9px; font-size: 11.5px; font-weight: 700; letter-spacing: .055em;
  text-transform: uppercase; color: #7dd3fc;
  padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.doc-box .doc-h:first-child { margin-top: 0; }
/* Bullet lists with hanging indent + colored markers */
.doc-box .doc-list { list-style: none; margin: 0 0 13px; padding: 0; }
.doc-box .doc-list li { position: relative; padding-left: 18px; margin: 0 0 7px; }
.doc-box .doc-list li:last-child { margin-bottom: 0; }
.doc-box .doc-list li::before { content: "•"; position: absolute; left: 2px; top: -1px; color: var(--primary-2); font-weight: 700; }
.doc-box .doc-list li.doc-sub { padding-left: 34px; color: #b6c1cf; }
.doc-box .doc-list li.doc-sub::before { content: "–"; left: 20px; color: var(--muted); }
/* Inline code / example blocks */
.doc-box .doc-code {
  background: #0d1420; border: 1px solid #243044; border-radius: 8px;
  padding: 9px 12px; margin: 4px 0 13px; font-size: 12.5px; line-height: 1.55;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #cbe3d2; white-space: pre; overflow-x: auto;
}
.doc-box code { background: rgba(125,211,252,.12); color: #bfe1f5; padding: 1px 5px; border-radius: 5px; font-size: 12.5px; }

/* --- Modal ----------------------------------------------------------------- */
.overlay {
  position: fixed; inset: 0; background: #06080ccc; backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 24px; z-index: 100; opacity: 0; transition: .15s;
}
.overlay.show { opacity: 1; }
.modal {
  width: 540px; max-width: 100%; max-height: 90vh; background: var(--bg-2);
  border: 1px solid var(--border-2); border-radius: 16px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
}
.modal-wide { width: min(960px, 94vw); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-x { background: none; border: none; color: var(--muted); font-size: 24px; cursor: pointer; line-height: 1; }
.modal-x:hover { color: var(--text); }
.modal-body { padding: 22px; overflow-y: auto; overflow-x: clip; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border); background: #12171f; }
.confirm-text { line-height: 1.5; }

/* --- System-instructions assistant ----------------------------------------- */
.assistant-btn { color: var(--primary-2); }
.analyze-btn { color: var(--primary-2); }
.overlay-stack { z-index: 120; }   /* sits above the agent-editor modal */
.lbl-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* Instructions quality badge */
.qa-badge {
  font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px; cursor: pointer;
  border: 1px solid var(--border-2); background: #ffffff08; color: var(--muted); font-family: inherit;
}
.qa-badge.qa-green { color: #86efac; border-color: #22c55e44; background: #22c55e14; }
.qa-badge.qa-amber { color: #fcd34d; border-color: #f59e0b40; background: #f59e0b14; }
.qa-badge.qa-red { color: #fca5a5; border-color: #ef444433; background: #ef444410; }
.qa-badge.qa-analyzing { color: var(--muted); cursor: default; }
.qa-badge.qa-stale { opacity: .55; border-style: dashed; }
.qa-slot { display: inline-flex; align-items: center; gap: 6px; }
.qa-rerun { padding: 3px 9px; font-size: 11px; }
/* Highlighted (amber) when the analysis is outdated, to invite a refresh. */
.qa-rerun-stale { color: #fcd34d; border-color: #f59e0b66; background: #f59e0b1a; font-weight: 700; }

/* Analysis recommendations */
.rec-summary { display: flex; flex-direction: column; align-items: flex-start; }
.rec-list { display: flex; flex-direction: column; gap: 8px; }
.rec-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: #0c1016; }
.rec-chip { flex: none; font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 6px; text-transform: uppercase; letter-spacing: .03em; }
.rec-chip.rec-good { color: #86efac; background: #22c55e1a; }
.rec-chip.rec-weak { color: #fcd34d; background: #f59e0b1a; }
.rec-chip.rec-missing { color: #fca5a5; background: #ef44441a; }
.rec-area { font-weight: 600; font-size: 13px; }
.ps-list { display: flex; flex-direction: column; gap: 6px; }
.ps-row {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 10px; background: #0c1016; cursor: pointer;
}
.ps-row:hover { border-color: var(--border-2); }
.ps-row input { margin-top: 3px; flex: none; }
.ps-title { font-weight: 600; color: var(--text); font-size: 13px; }
.ps-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.ps-card {
  border: 1px solid var(--border); border-radius: 11px; padding: 12px 14px; margin-bottom: 12px;
  background: #0c1016; display: flex; flex-direction: column; gap: 8px;
}
.ps-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ps-card .ps-title { font-family: "JetBrains Mono", monospace; color: var(--primary-2); }
.ps-doc { line-height: 1.5; }

/* --- New-agent chooser + wizard -------------------------------------------- */
.chooser { display: grid; gap: 12px; }
.chooser-card {
  text-align: left; background: #0c1016; border: 1px solid var(--border-2); border-radius: 12px;
  padding: 16px; cursor: pointer; transition: .15s; display: flex; flex-direction: column; gap: 6px; font-family: inherit;
}
.chooser-card:hover { border-color: var(--primary); background: #ffffff08; }
.chooser-head { display: flex; align-items: center; gap: 10px; }
.chooser-title { font-size: 15px; font-weight: 700; color: var(--text); }

.wiz-steps { display: flex; gap: 8px; margin-bottom: 18px; }
.wiz-step {
  display: flex; align-items: center; gap: 8px; flex: 1; padding: 8px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: #0c1016; color: var(--muted); font-size: 12.5px; font-weight: 600;
}
.wiz-step.active { border-color: var(--primary); color: var(--text); background: var(--primary-ghost); }
.wiz-step.done { color: #86efac; border-color: #22c55e44; }
.wiz-num { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: #ffffff12; font-size: 11px; flex: none; }
.wiz-step.active .wiz-num { background: var(--primary); color: #fff; }
.wiz-step.done .wiz-num { background: #22c55e; color: #06240f; }

/* --- Tabs ------------------------------------------------------------------ */
.tabbar { display: flex; flex-wrap: wrap; gap: 2px 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab {
  background: none; border: none; color: var(--muted); padding: 8px 11px; cursor: pointer;
  font-size: 13px; font-weight: 600; font-family: inherit; border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary-2); border-bottom-color: var(--primary); }

/* Stack all panes in one grid cell so the box sizes to the tallest pane and
   never changes height when switching tabs. Inactive panes are hidden with
   visibility (which keeps their footprint) rather than display:none. */
.tab-panes { display: grid; }
.tab-panes > * { grid-area: 1 / 1; }
.tab-panes > .pane-hidden { visibility: hidden; }

/* --- Tools ----------------------------------------------------------------- */
.tools-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.tool-list { display: flex; flex-direction: column; gap: 9px; }
.tool-row { background: #0c1016; border: 1px solid var(--border); border-radius: 11px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.tool-row-main { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.tool-name { font-size: 13px; color: var(--primary-2); }
.method-badge { font-size: 10.5px; font-weight: 700; background: var(--primary-ghost); color: var(--primary-2); padding: 2px 7px; border-radius: 5px; }
.tool-url { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-desc { font-size: 12px; color: var(--muted); }
.tool-row-actions { display: flex; gap: 5px; }
.notice { background: #f59e0b14; border: 1px solid #f59e0b40; color: #fcd34d; padding: 12px 14px; border-radius: 10px; font-size: 13px; }

/* --- Toasts ---------------------------------------------------------------- */
.toast-host { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast {
  background: var(--panel); border: 1px solid var(--border-2); border-left: 3px solid var(--primary);
  color: var(--text); padding: 12px 16px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow);
  opacity: 0; transform: translateX(20px); transition: .25s; min-width: 220px;
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }

/* --- Responsive ------------------------------------------------------------ */
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .form-grid { grid-template-columns: 1fr; }
}
