/* ═══════════════════════════════════════════
   DESIGN TOKENS
═══════════════════════════════════════════ */
:root {
  --color-bg:         #f5f6fa;
  --color-surface:    #ffffff;
  --color-surface-2:  #f0f2f8;
  --color-surface-3:  #e8eaf0;
  --color-border:     #e2e5ef;
  --color-border-2:   #d0d4e4;
  --color-text:       #0f1117;
  --color-text-2:     #4a5068;
  --color-text-3:     #8891aa;
  --color-accent:     #5b6cf9;
  --color-accent-h:   #4757e8;
  --color-accent-rgb: 91, 108, 249;
  --color-success:    #10b981;
  --color-warning:    #f59e0b;
  --color-danger:     #ef4444;
  --color-info:       #3b82f6;
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm: 0 2px 6px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.10), 0 2px 8px rgba(0,0,0,0.06);
  --sidebar-w: 240px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
}

[data-theme="dark"] {
  --color-bg:         #0e1018;
  --color-surface:    #161923;
  --color-surface-2:  #1e2230;
  --color-surface-3:  #252a3a;
  --color-border:     #2a3045;
  --color-border-2:   #343a52;
  --color-text:       #e8ecf8;
  --color-text-2:     #9aa0bc;
  --color-text-3:     #5a6080;
  --shadow-sm: 0 2px 6px rgba(0,0,0,0.25);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.35);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.45);
}

/* ═══════════════════════════════════════════
   RESET & BASE
═══════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  font-size: 14px;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.2s, color 0.2s;
}
a { color: inherit; text-decoration: none; }
svg { flex-shrink: 0; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border-2); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-3); }

h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.3px; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 13px; font-weight: 600; }
h4 { font-size: 13px; font-weight: 600; color: var(--color-text-2); }

/* ═══════════════════════════════════════════
   FORM ELEMENTS
═══════════════════════════════════════════ */
input[type="text"],
input[type="password"],
input[type="number"],
input[type="datetime-local"],
input[type="url"],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(var(--color-accent-rgb), 0.12);
}
select { cursor: pointer; }
.input-group { display: flex; flex-direction: column; gap: 6px; }
.input-group label { font-size: 13px; font-weight: 500; color: var(--color-text-2); }
.checkbox-group { flex-direction: row; align-items: center; }
.checkbox-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; color: var(--color-text); }
.checkbox-label input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--color-accent); }

/* ═══════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════ */
button {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 9px 18px; border: none; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; font-family: inherit; cursor: pointer;
  transition: all 0.15s; white-space: nowrap;
}
button:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--color-accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--color-accent-h); }
.btn-secondary { background: var(--color-surface-2); color: var(--color-text); border: 1.5px solid var(--color-border); }
.btn-secondary:hover:not(:disabled) { background: var(--color-surface-3); }
.btn-danger { background: rgba(239,68,68,0.1); color: var(--color-danger); border: 1.5px solid rgba(239,68,68,0.3); }
.btn-danger:hover:not(:disabled) { background: var(--color-danger); color: #fff; }
.btn-full { width: 100%; }
.icon-btn { padding: 7px; background: var(--color-surface-2); border: 1.5px solid var(--color-border); border-radius: var(--radius-sm); color: var(--color-text-2); }
.icon-btn:hover { background: var(--color-surface-3); color: var(--color-text); }
.action-btn { padding: 6px 8px; background: var(--color-surface-2); color: var(--color-text-2); border: 1.5px solid var(--color-border); border-radius: var(--radius-sm); font-size: 13px; }
.action-btn:hover { background: var(--color-accent); color: #fff; border-color: var(--color-accent); }
.action-btn.danger:hover { background: var(--color-danger); border-color: var(--color-danger); }

/* ═══════════════════════════════════════════
   MESSAGES
═══════════════════════════════════════════ */
.error-msg { font-size: 13px; color: var(--color-danger); padding: 8px 12px; border-radius: var(--radius-sm); background: rgba(239,68,68,0.08); display: none; }
.error-msg:not(:empty) { display: block; }
.success-msg { font-size: 13px; color: var(--color-success); padding: 8px 12px; border-radius: var(--radius-sm); background: rgba(16,185,129,0.08); display: none; }
.success-msg:not(:empty) { display: block; }

/* ═══════════════════════════════════════════
   LAYOUT
═══════════════════════════════════════════ */
.screen { min-height: 100vh; }
#mainScreen { display: flex; height: 100vh; overflow: hidden; }

/* LOGIN */
#loginScreen { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-container { width: 400px; padding: 40px; background: var(--color-surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); border: 1px solid var(--color-border); }
.login-logo { width: 64px; height: 64px; background: linear-gradient(135deg, var(--color-accent), var(--color-accent-h)); border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; margin: 0 auto 20px; }
.login-logo svg { stroke: #fff; }
.login-container h1 { text-align: center; font-size: 24px; margin-bottom: 6px; }
.login-subtitle { text-align: center; color: var(--color-text-3); font-size: 14px; margin-bottom: 28px; }
.login-container form { display: flex; flex-direction: column; gap: 16px; }

/* SIDEBAR */
.sidebar { width: var(--sidebar-w); min-width: var(--sidebar-w); background: var(--color-surface); border-right: 1px solid var(--color-border); display: flex; flex-direction: column; overflow: hidden; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px 14px; border-bottom: 1px solid var(--color-border); }
.brand-icon { width: 34px; height: 34px; background: linear-gradient(135deg, var(--color-accent), var(--color-accent-h)); border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.brand-icon svg { stroke: #fff; }
.brand-name { font-size: 15px; font-weight: 700; letter-spacing: -0.2px; }
.sidebar-user { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--color-border); }
.user-avatar { width: 28px; height: 28px; background: var(--color-surface-2); border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; border: 1px solid var(--color-border); }
.user-avatar svg { stroke: var(--color-text-2); }
.user-name { flex: 1; font-size: 13px; font-weight: 500; color: var(--color-text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-menu { list-style: none; padding: 8px 0; flex: 1; overflow-y: auto; }
.nav-menu li { display: flex; align-items: center; gap: 10px; padding: 9px 16px; margin: 1px 8px; border-radius: var(--radius-sm); cursor: pointer; color: var(--color-text-2); font-size: 14px; font-weight: 500; transition: all 0.15s; }
.nav-menu li svg { stroke: currentColor; flex-shrink: 0; }
.nav-menu li:hover { color: var(--color-text); background: var(--color-surface-2); }
.nav-menu li.active { color: var(--color-accent); background: rgba(var(--color-accent-rgb), 0.1); }
.logout-btn { margin: 8px; background: transparent; color: var(--color-danger); border: 1.5px solid rgba(239,68,68,0.3); font-size: 13px; padding: 8px 16px; justify-content: flex-start; }
.logout-btn:hover { background: rgba(239,68,68,0.08); border-color: var(--color-danger); }
.logout-btn svg { stroke: currentColor; }

/* CONTENT */
.content { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
.tab-content { display: none; flex: 1; flex-direction: column; padding: 24px; gap: 20px; }
.tab-content.active { display: flex; }

/* PAGE HEADER */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-title h1 { font-size: 22px; margin-bottom: 2px; }
.page-subtitle { font-size: 13px; color: var(--color-text-3); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.search-input { min-width: 220px; width: auto; }
.filter-select { min-width: 140px; width: auto; }

/* TABLE */
.table-container { background: var(--color-surface); border-radius: var(--radius-md); border: 1px solid var(--color-border); box-shadow: var(--shadow-sm); overflow: auto; flex: 1; }
table { width: 100%; border-collapse: collapse; }
thead { position: sticky; top: 0; z-index: 10; background: var(--color-surface-2); }
th { padding: 11px 14px; text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--color-text-3); border-bottom: 1px solid var(--color-border); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--color-border); font-size: 13px; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--color-surface-2); }
.row-actions { display: flex; align-items: center; gap: 4px; }

/* BADGES */
.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; letter-spacing: 0.2px; }
.badge.active    { background: rgba(16,185,129,0.12); color: #059669; }
.badge.stopped   { background: rgba(239,68,68,0.1);   color: #dc2626; }
.badge.inactive  { background: rgba(148,163,184,0.15);color: #64748b; }
.badge.waiting   { background: rgba(245,158,11,0.12); color: #d97706; }
.badge.successful{ background: rgba(16,185,129,0.12); color: #059669; }
.badge.canceled  { background: rgba(148,163,184,0.15);color: #64748b; }
.badge.failed    { background: rgba(239,68,68,0.1);   color: #dc2626; }
.badge.pending   { background: rgba(245,158,11,0.12); color: #d97706; }
.badge.error     { background: rgba(239,68,68,0.1);   color: #dc2626; }
.badge.completed { background: rgba(16,185,129,0.12); color: #059669; }

/* STAT CARDS */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.stat-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 18px 20px; box-shadow: var(--shadow-xs); transition: box-shadow 0.2s; }
.stat-card:hover { box-shadow: var(--shadow-sm); }
.stat-card.highlight { border-left: 3px solid var(--color-accent); }
.stat-card h3 { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--color-text-3); margin-bottom: 8px; }
.stat-card .value { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; color: var(--color-text); line-height: 1.1; }
.stat-card .subvalue { font-size: 12px; color: var(--color-text-3); margin-top: 4px; }

/* CHARTS */
.charts-container { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.chart-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 18px 20px; box-shadow: var(--shadow-xs); min-height: 240px; display: flex; flex-direction: column; }
.chart-card.full-width { grid-column: 1 / -1; min-height: 200px; }
.chart-card h4 { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--color-text-3); margin-bottom: 14px; }
canvas { max-height: 220px !important; flex: 1; }
.chart-card.full-width canvas { max-height: 180px !important; }

/* PAGINATION */
.pagination { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-top: 1px solid var(--color-border); background: var(--color-surface-2); }
.pagination-info { font-size: 13px; color: var(--color-text-3); }
.pagination-controls { display: flex; gap: 4px; align-items: center; }
.pagination-controls button { padding: 6px 10px; background: var(--color-surface); color: var(--color-text-2); border: 1px solid var(--color-border); border-radius: var(--radius-sm); font-size: 13px; }
.pagination-controls button:hover:not(:disabled) { background: var(--color-accent); color: #fff; border-color: var(--color-accent); }
.page-input { width: 60px !important; text-align: center; padding: 6px 8px !important; }

/* MODAL */
.modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 1000; backdrop-filter: blur(4px); align-items: center; justify-content: center; padding: 20px; }
.modal.active { display: flex; }
.modal-content { background: var(--color-surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); border: 1px solid var(--color-border); width: 100%; max-width: 900px; max-height: 90vh; overflow: hidden; display: flex; flex-direction: column; }
.modal.fullscreen .modal-content { max-width: 95vw; max-height: 95vh; width: 1400px; }
.modal.wide .modal-content { max-width: 1100px; }
.modal-header { padding: 18px 24px; border-bottom: 1px solid var(--color-border); display: flex; justify-content: space-between; align-items: center; background: var(--color-surface-2); gap: 12px; }
.modal-header h2 { font-size: 16px; flex: 1; }
.modal-header-actions { display: flex; gap: 8px; }
.modal-close { width: 30px; height: 30px; padding: 0; background: transparent; border: none; color: var(--color-text-3); font-size: 20px; border-radius: var(--radius-sm); line-height: 1; }
.modal-close:hover { background: var(--color-surface-3); color: var(--color-text); }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--color-border); display: flex; gap: 8px; justify-content: flex-end; background: var(--color-surface-2); }

/* LOADING & EMPTY */
.loading { display: flex; align-items: center; justify-content: center; padding: 60px 20px; color: var(--color-text-3); font-size: 14px; gap: 10px; }
.loading::before { content: ''; width: 20px; height: 20px; border: 2px solid var(--color-border-2); border-top-color: var(--color-accent); border-radius: 50%; animation: spin 0.7s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }
.error { display: flex; align-items: center; justify-content: center; padding: 5px 20px; color: var(--color-danger); font-size: 14px; }

/* SETTINGS */
.settings-container { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; align-items: start; }
.settings-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); overflow: hidden; box-shadow: var(--shadow-xs); }
.settings-card-header { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--color-border); background: var(--color-surface-2); }
.settings-card-header svg { stroke: var(--color-accent); }
.settings-card-header h2 { font-size: 15px; }
.settings-card form { display: flex; flex-direction: column; gap: 14px; padding: 20px; }

/* EXPAND ROWS */
.expand-btn { cursor: pointer; user-select: none; color: var(--color-text-3); font-size: 12px; }
.sub-row td { background: var(--color-surface-2); padding-left: 40px; }
.sub-row-2 td { background: var(--color-surface-3); padding-left: 64px; }

/* CLICKABLE */
.clickable { color: var(--color-accent); cursor: pointer; text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 2px; }
.clickable:hover { text-decoration-style: solid; }

/* EDIT FORM */
.edit-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; color: var(--color-text-3); }
.form-group.full-width { grid-column: 1 / -1; }

/* FILE UPLOAD */
.file-upload { border: 2px dashed var(--color-border-2); border-radius: var(--radius-md); padding: 32px 20px; text-align: center; cursor: pointer; transition: all 0.15s; color: var(--color-text-3); }
.file-upload:hover { border-color: var(--color-accent); color: var(--color-text); background: rgba(var(--color-accent-rgb), 0.03); }
.file-upload input[type="file"] { display: none; }

/* DB VIEW */
.db-view { display: flex; flex-direction: column; height: 100%; }
.db-header { padding: 0 0 16px; }
.db-controls { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* INFO BANNER */
.info-banner { background: rgba(var(--color-accent-rgb), 0.06); border: 1px solid rgba(var(--color-accent-rgb), 0.2); border-left: 3px solid var(--color-accent); border-radius: var(--radius-sm); padding: 12px 16px; font-size: 13px; color: var(--color-text-2); line-height: 1.6; display: flex; gap: 10px; align-items: flex-start; }
.info-banner svg { stroke: var(--color-accent); margin-top: 1px; flex-shrink: 0; }

/* SECTION TITLE */
.section-title { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; color: var(--color-text); margin: 24px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--color-border); }
.section-title svg { stroke: var(--color-accent); width: 18px; height: 18px; }

/* HBAR */
.hbar-list { display: flex; flex-direction: column; gap: 10px; }
.hbar-item { display: flex; flex-direction: column; gap: 4px; }
.hbar-label { display: flex; justify-content: space-between; font-size: 13px; color: var(--color-text-2); }
.hbar-label .hbar-value { font-weight: 600; color: var(--color-text); }
.hbar-track { height: 6px; background: var(--color-surface-3); border-radius: 3px; overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--color-accent), var(--color-accent-h)); transition: width 0.4s ease; }

/* STATS TABLE */
.stats-table { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); overflow: hidden; box-shadow: var(--shadow-xs); }

/* ═══════════════════════════════════════════
   JSON EDITOR (n8n style)
═══════════════════════════════════════════ */
.json-editor {
  background: var(--color-surface-2);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 13px;
}

.json-editor-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--color-surface-3);
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
}

.json-editor-toolbar .je-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-3);
  flex: 1;
}

.json-editor-toolbar button {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 4px;
}

.json-editor-tabs {
  display: flex;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-2);
}

.json-editor-tab {
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  font-family: inherit;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}
.json-editor-tab.active { color: var(--color-accent); border-bottom-color: var(--color-accent); }
.json-editor-tab:hover:not(.active) { color: var(--color-text-2); background: var(--color-surface-3); }

/* Tree view */
.json-tree-view {
  padding: 12px;
  min-height: 80px;
}

.json-node {
  position: relative;
  margin: 2px 0;
}

.json-node-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.1s;
  min-height: 30px;
}
.json-node-header:hover { background: var(--color-surface-3); }

.json-node-toggle {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--color-text-3);
  font-size: 10px;
  transition: transform 0.15s;
}
.json-node-toggle.open { transform: rotate(90deg); }
.json-node-toggle.leaf { visibility: hidden; }

.json-node-key {
  color: var(--color-accent);
  font-weight: 500;
}

.json-node-sep { color: var(--color-text-3); }

.json-node-value {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.json-node-value.type-string  { color: #10b981; }
.json-node-value.type-number  { color: #f59e0b; }
.json-node-value.type-boolean { color: #8b5cf6; }
.json-node-value.type-null    { color: var(--color-text-3); font-style: italic; }
.json-node-value.type-object  { color: var(--color-text-3); }
.json-node-value.type-array   { color: var(--color-text-3); }

.json-node-actions {
  display: none;
  gap: 3px;
  margin-left: auto;
  flex-shrink: 0;
}
.json-node-header:hover .json-node-actions { display: flex; }

.json-node-actions button {
  padding: 2px 6px;
  font-size: 11px;
  border-radius: 3px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text-2);
}
.json-node-actions button:hover { background: var(--color-accent); color: #fff; border-color: var(--color-accent); }
.json-node-actions button.del:hover { background: var(--color-danger); border-color: var(--color-danger); }

.json-node-children {
  padding-left: 20px;
  border-left: 1px dashed var(--color-border);
  margin-left: 14px;
  display: none;
}
.json-node-children.open { display: block; }

/* Inline edit */
.json-inline-edit {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  background: var(--color-surface);
  border: 1.5px solid var(--color-accent);
  border-radius: var(--radius-sm);
  margin: 2px 0;
}
.json-inline-edit input, .json-inline-edit select {
  padding: 3px 6px;
  font-size: 12px;
  border: 1px solid var(--color-border);
  border-radius: 3px;
  font-family: inherit;
  background: var(--color-surface-2);
}
.json-inline-edit input.key-input { width: 120px; color: var(--color-accent); }
.json-inline-edit input.val-input { flex: 1; }
.json-inline-edit .type-select { width: 80px; }
.json-inline-edit button { padding: 3px 8px; font-size: 11px; }

/* Add node button */
.json-add-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--color-accent);
  background: rgba(var(--color-accent-rgb), 0.06);
  border: 1px dashed rgba(var(--color-accent-rgb), 0.4);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  margin: 4px 0;
  width: 100%;
  justify-content: center;
}
.json-add-btn:hover { background: rgba(var(--color-accent-rgb), 0.12); border-style: solid; }

/* Raw textarea mode */
.json-raw-editor {
  display: none;
  padding: 0;
}
.json-raw-editor textarea {
  border: none;
  border-radius: 0;
  min-height: 200px;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 12px;
  resize: vertical;
  background: var(--color-surface-2);
  color: var(--color-text);
  line-height: 1.6;
}
.json-raw-editor textarea:focus { box-shadow: none; }

/* Drag handle */
.json-drag-handle {
  cursor: grab;
  color: var(--color-text-3);
  padding: 0 2px;
  opacity: 0;
  transition: opacity 0.15s;
  font-size: 12px;
}
.json-node-header:hover .json-drag-handle { opacity: 1; }
.json-node.dragging { opacity: 0.4; }
.json-node.drag-over > .json-node-header { background: rgba(var(--color-accent-rgb), 0.15); }

/* ═══════════════════════════════════════════
   BOT EDITOR
═══════════════════════════════════════════ */
.bot-editor {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.bot-editor-section {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.bot-editor-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--color-surface-3);
  border-bottom: 1px solid var(--color-border);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-2);
}
.bot-editor-section-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.bot-editor-full {
  grid-column: 1 / -1;
}

/* MODEL CARD */
.model-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: box-shadow 0.15s;
}
.model-card:hover { box-shadow: var(--shadow-sm); }
.model-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
}
.model-avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--color-surface-2);
  flex-shrink: 0;
  border: 1px solid var(--color-border);
}
.model-avatar-placeholder {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--color-accent), var(--color-accent-h));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
}
.model-info { flex: 1; min-width: 0; }
.model-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-tech { font-size: 12px; color: var(--color-text-3); font-family: monospace; }
.model-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* UI BLOCK CARD */
.ui-block-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 12px;
}
.ui-block-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--color-surface-2);
  border-bottom: 1px solid var(--color-border);
}
.ui-block-name { font-weight: 600; font-size: 14px; flex: 1; }
.ui-block-card-body { padding: 16px; }

/* ENDPOINT CARD similar */
.endpoint-row-detail {
  padding: 16px;
  background: var(--color-surface-2);
  border-top: 1px solid var(--color-border);
  display: none;
}
.endpoint-row-detail.open { display: block; }
.curl-preview {
  background: var(--color-surface-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: monospace;
  font-size: 12px;
  overflow-x: auto;
  white-space: pre-wrap;
  color: var(--color-text-2);
  max-height: 200px;
  overflow-y: auto;
}

/* ROLE CARD */
.role-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.role-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
}
.role-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--color-surface-2);
  flex-shrink: 0;
  border: 1px solid var(--color-border);
}
.role-avatar-placeholder {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #8b5cf6, #6d28d9);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
  font-weight: 700;
}

/* ═══════════════════════════════════════════
   VERSIONS EDITOR (for models)
═══════════════════════════════════════════ */
.version-item {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 8px;
  position: relative;
  cursor: grab;
}
.version-item:active { cursor: grabbing; }
.version-item.dragging { opacity: 0.4; box-shadow: var(--shadow-md); }
.version-item.drag-over { border-color: var(--color-accent); background: rgba(var(--color-accent-rgb), 0.04); }
.version-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.version-drag-icon { color: var(--color-text-3); flex-shrink: 0; }
.version-label-input { flex: 1; font-weight: 500; }
.version-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.version-add-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 10px; font-size: 13px;
  background: rgba(var(--color-accent-rgb), 0.06);
  border: 1.5px dashed rgba(var(--color-accent-rgb), 0.4);
  border-radius: var(--radius-sm);
  color: var(--color-accent);
  cursor: pointer; transition: all 0.15s;
}
.version-add-btn:hover { background: rgba(var(--color-accent-rgb), 0.12); border-style: solid; }

/* ═══════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════ */
@media (max-width: 900px) {
  .bot-editor { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 100%; }
  #mainScreen { flex-direction: column; height: auto; overflow: auto; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--color-border); }
  .nav-menu { display: flex; overflow-x: auto; padding: 4px 8px; gap: 2px; }
  .nav-menu li { flex-direction: column; padding: 8px 12px; gap: 4px; font-size: 11px; text-align: center; min-width: 60px; margin: 0; }
  .content { overflow: auto; }
  .tab-content { padding: 16px; }
  .page-header { flex-direction: column; }
  .toolbar { width: 100%; }
  .search-input, .filter-select { width: 100%; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .settings-container { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════
   BALANCES
═══════════════════════════════════════════ */
.balances-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  align-items: start;
}
.balance-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.balance-card:hover { box-shadow: var(--shadow-sm); }
.balance-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
}
.balance-card-icon {
  font-size: 24px;
  line-height: 1;
  flex-shrink: 0;
}
.balance-card-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
}
.balance-card-value {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--color-text);
  line-height: 1.1;
}
.balance-card-value.loading {
  font-size: 14px;
  font-weight: 400;
  color: var(--color-text-3);
  display: flex;
  align-items: center;
  gap: 8px;
}
.balance-card-value.loading::before {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid var(--color-border-2);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
.balance-card-status {
  font-size: 12px;
  color: var(--color-text-3);
}
.balance-card-status.ok { color: var(--color-success); }
.balance-card-status.error { color: var(--color-danger); }
.balance-card-status.no-token { color: var(--color-warning); }
.balance-card .btn-secondary {
  font-size: 12px;
  padding: 6px 12px;
  align-self: flex-start;
}
.balance-card.status-ok { border-left: 3px solid var(--color-success); }
.balance-card.status-error { border-left: 3px solid var(--color-danger); }
.balance-card.status-no_token { border-left: 3px solid var(--color-warning); }
.balance-card.status-not_supported { border-left: 3px solid var(--color-border-2); }

/* ═══ TRENDS ═══ */
.subtab-switcher { display:flex;border:1px solid var(--color-border);border-radius:var(--radius-sm);overflow:hidden; }
.subtab-switcher button { padding:6px 16px;font-size:13px;border:none;background:transparent;cursor:pointer;color:var(--color-text-2);transition:all .15s; }
.subtab-switcher button.active { background:var(--color-accent);color:#fff; }

.trends-layout { display:flex;gap:16px;flex:1;min-height:0;overflow:hidden; }
.trends-main { flex:1;min-width:0;overflow-y:auto;display:flex;flex-direction:column;gap:12px; }
.trends-side { width:360px;flex-shrink:0;border-left:1px solid var(--color-border);background:var(--color-surface);overflow-y:auto;display:flex;flex-direction:column;transition:width .2s; }
.trends-side:not(.open) { width:0;overflow:hidden;border:none; }
.side-panel-header { display:flex;align-items:center;justify-content:space-between;padding:14px 16px 10px;border-bottom:1px solid var(--color-border);position:sticky;top:0;background:var(--color-surface);z-index:2; }
.side-panel-header h3 { margin:0;font-size:15px; }
.side-panel-close { background:none;border:none;font-size:20px;cursor:pointer;color:var(--color-text-3);line-height:1; }
.side-panel-body { padding:14px 16px;flex:1; }

.reorder-hint { display:flex;align-items:center;gap:8px;padding:8px 12px;background:rgba(91,108,249,0.08);border:1px solid rgba(91,108,249,0.2);border-radius:var(--radius-sm);font-size:12px;color:var(--color-text-2); }

.trends-grid { display:grid;grid-template-columns:repeat(auto-fill,minmax(180px,1fr));gap:12px;padding:4px 2px; }

.trend-card { background:var(--color-surface-2);border:1px solid var(--color-border);border-radius:var(--radius-md);overflow:hidden;display:flex;flex-direction:column;transition:box-shadow .15s,opacity .25s,transform .25s;position:relative; }
.trend-card:hover { box-shadow:0 2px 12px rgba(0,0,0,.12); }
.trend-card.dragging { opacity:.4;box-shadow:0 4px 20px rgba(0,0,0,.2); }
.trend-card.drag-over { outline:2px solid var(--color-accent); }

.trend-drag-handle { position:absolute;top:6px;left:6px;cursor:grab;color:rgba(255,255,255,.8);font-size:16px;z-index:2;text-shadow:0 1px 3px rgba(0,0,0,.5);line-height:1; }

.trend-card-media { width:100%;aspect-ratio:1;background:var(--color-surface-3);overflow:hidden;position:relative; }
.trend-card-thumb { width:100%;height:100%;object-fit:cover;display:block; }
video.trend-card-thumb { width:100%;height:100%;object-fit:cover; }
.trend-card-file { display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;padding:12px;color:var(--color-text-3);width:100%;height:100%;box-sizing:border-box; }
.trend-file-url { font-size:10px;word-break:break-all;text-align:center;max-height:60px;overflow:hidden;color:var(--color-accent); }

.trend-card-footer { padding:8px 10px 4px;display:flex;flex-direction:column;gap:2px; }
.trend-card-name { font-size:12px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis; }
.trend-priority-badge { font-size:10px;background:rgba(91,108,249,.15);color:var(--color-accent);border-radius:3px;padding:1px 5px;flex-shrink:0; }

.trend-card-actions { display:flex;gap:4px;padding:6px 8px 8px;flex-wrap:wrap; }
.trend-card-video-wrap {
  position: relative;
}

.trend-card-video-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.trend-video-badge {
  position: absolute;
  bottom: 6px;
  left: 6px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 4px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.btn-sm { padding:4px 8px;font-size:11px;border-radius:var(--radius-sm);border:1px solid var(--color-border);background:var(--color-surface);cursor:pointer;color:var(--color-text-1);transition:all .15s;white-space:nowrap; }
.btn-sm:hover { background:var(--color-surface-2); }
.btn-sm.btn-success { border-color:rgba(16,185,129,.4);color:var(--color-success,#10b981);background:rgba(16,185,129,.08); }
.btn-sm.btn-success:hover { background:rgba(16,185,129,.18); }
.btn-sm.btn-danger { border-color:rgba(239,68,68,.4);color:var(--color-danger,#ef4444);background:rgba(239,68,68,.08); }
.btn-sm.btn-danger:hover { background:rgba(239,68,68,.18); }
.btn-sm.btn-warn { border-color:rgba(245,158,11,.4);color:#f59e0b;background:rgba(245,158,11,.08); }
.btn-sm.btn-warn:hover { background:rgba(245,158,11,.18); }

/* Side panel preview */
.preview-section { margin-bottom:16px;border-bottom:1px solid var(--color-border);padding-bottom:14px; }
.preview-section:last-child { border-bottom:none; }
.preview-section-title { font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.05em;color:var(--color-text-3);margin-bottom:8px; }
.preview-prompt-row { display:flex;flex-direction:column;gap:6px; }
.preview-prompt-text { font-size:13px;color:var(--color-text-1);white-space:pre-wrap;word-break:break-word;background:var(--color-surface-2);border-radius:var(--radius-sm);padding:8px;max-height:120px;overflow-y:auto; }
.preview-toggle-row { display:flex;align-items:center;gap:6px;cursor:pointer; }

.preview-media-item { background:var(--color-surface-2);border:1px solid var(--color-border);border-radius:var(--radius-sm);padding:10px;margin-bottom:8px; }
.preview-media-header { display:flex;align-items:center;justify-content:space-between;margin-bottom:8px; }
.preview-ref-desc { font-size:11px;padding:2px 7px;border-radius:3px;font-weight:600; }
.ref-show { background:rgba(239,68,68,.1);color:#ef4444; }
.ref-hidden { background:rgba(148,163,184,.15);color:var(--color-text-3); }
.ref-replace { background:rgba(245,158,11,.1);color:#f59e0b; }
.ref-optional { background:rgba(16,185,129,.1);color:#10b981; }
.preview-media-thumb { margin-bottom:8px; }
.preview-media-controls { display:flex;gap:14px;margin-bottom:6px; }
.preview-ref-summary { font-size:11px;color:var(--color-text-3); }
.preview-result-media { margin-bottom:8px; }
.ref-disclaimer { background:rgba(245,158,11,.1);border:1px solid rgba(245,158,11,.3);border-radius:var(--radius-sm);padding:8px 10px;font-size:12px;color:#f59e0b;margin-top:6px; }

.sp-input { width:100%;box-sizing:border-box; }
.sp-save-btn { margin-top:4px; }

/* Toast */
.trends-toast { position:fixed;bottom:24px;left:50%;transform:translateX(-50%);background:var(--color-surface);border:1px solid var(--color-border);border-radius:var(--radius-md);padding:10px 20px;font-size:13px;box-shadow:0 4px 20px rgba(0,0,0,.15);z-index:999;animation:fadeIn .3s; }

/* ═══════════════════════════════════════════
   EXPENSES BLOCK
═══════════════════════════════════════════ */
.expenses-block {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
  margin-bottom: 16px;
}
.expenses-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--color-surface-2);
  border-bottom: 1px solid var(--color-border);
  gap: 12px;
  flex-wrap: wrap;
}

/* ═══════════════════════════════════════════
   REQS CHART
═══════════════════════════════════════════ */
.rqc-container {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-xs);
  margin-bottom: 16px;
  position: relative;
}

.rqc-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rqc-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: center;
  font-size: 12px;
  color: var(--color-text-2);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--color-border);
}

.rqc-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.rqc-legend-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.rqc-status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 2px solid #888;
  background: transparent;
  flex-shrink: 0;
}

.rqc-legend-sep {
  width: 1px;
  height: 16px;
  background: var(--color-border);
  margin: 0 4px;
}

.rqc-canvas-wrap {
  position: relative;
  width: 100%;
}

.rqc-canvas {
  display: block;
  width: 100%;
  border-radius: var(--radius-sm);
}

.rqc-x-labels {
  display: flex;
  justify-content: space-between;
  padding: 0 44px 0 44px;
}

.rqc-x-label {
  font-size: 10px;
  color: var(--color-text-3);
  text-align: center;
  flex: 1;
  white-space: nowrap;
}

/* Tooltips */
.rqc-tooltip,
.rqc-point-tooltip {
  position: absolute;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 12px;
  color: var(--color-text);
  box-shadow: var(--shadow-md);
  pointer-events: none;
  z-index: 10;
  line-height: 1.6;
  max-width: 220px;
  white-space: nowrap;
}

.rqc-pct {
  font-weight: 700;
  color: var(--color-success);
}

.rqc-pt-model {
  font-weight: 600;
  color: var(--color-accent);
  display: block;
  font-size: 11px;
}

.rqc-pt-id {
  font-size: 10px;
  color: var(--color-text-3);
  display: block;
}

.rqc-pt-status {
  font-size: 11px;
  font-weight: 600;
}

.rqc-st-completed { color: #10b981; }
.rqc-st-error     { color: #ef4444; }
.rqc-st-pending   { color: #f59e0b; }

/* ── Req Detail Modal ─────────────────────────────────── */
.rqd-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.rqd-section {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.rqd-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--color-text-3);
  padding: 10px 14px;
  background: var(--color-surface-3);
  border-bottom: 1px solid var(--color-border);
}

.rqd-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0;
  padding: 4px 0;
}

.rqd-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--color-border);
}

.rqd-field:last-child { border-bottom: none; }
.rqd-field-full { grid-column: 1 / -1; }

.rqd-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--color-text-3);
}

.rqd-value {
  font-size: 13px;
  color: var(--color-text);
  word-break: break-all;
}

.rqd-value.mono { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 12px; }
.rqd-value.accent { color: var(--color-accent); }
.rqd-value.small { font-size: 11px; }
.rqd-value.rqd-error {
  color: var(--color-danger);
  background: rgba(239,68,68,0.06);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
}

/* Debug section */
.rqd-section-debug { }

.rqd-debug-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.rqd-debug-block {
  border-bottom: 1px solid var(--color-border);
  padding: 12px 14px;
}
.rqd-debug-block:last-child { border-bottom: none; }

.rqd-debug-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-3);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 6px;
}

.rqd-debug-code {
  background: var(--color-surface-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 11px;
  color: var(--color-text-2);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 240px;
  overflow-y: auto;
  margin: 0;
  line-height: 1.5;
}

/* ═══════════════════════════════════════════
   WITHDRAWALS
═══════════════════════════════════════════ */
.wdr-type-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(91, 108, 249, 0.1);
  color: var(--color-accent);
  letter-spacing: 0.2px;
}

.wdr-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.wdr-detail-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-border);
}

.wdr-detail-row:nth-last-child(-n+2):not(.wdr-detail-full) {
  border-bottom: none;
}

.wdr-detail-full {
  grid-column: 1 / -1;
}

.wdr-dl {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--color-text-3);
}

.wdr-dv {
  font-size: 13px;
  color: var(--color-text);
  word-break: break-all;
}

.wdr-dv.mono {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
}

/* ═══════════════════════════════════════════
   WITHDRAWAL CREATE — USER SEARCH
═══════════════════════════════════════════ */
.cw-user-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 20;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  max-height: 220px;
  overflow-y: auto;
  margin-top: 4px;
}
.cw-user-result-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid var(--color-border);
}
.cw-user-result-item:last-child { border-bottom: none; }
.cw-user-result-item:hover { background: var(--color-surface-2); }
.cw-uid { font-family: 'SF Mono', 'Fira Code', monospace; color: var(--color-text-3); font-size: 12px; }
.cw-uname { color: var(--color-accent); font-weight: 500; }
.cw-uname2 { color: var(--color-text-2); }
.cw-user-result-empty { padding: 10px 12px; font-size: 12px; color: var(--color-text-3); }

/* ═══════════════════════════════════════════
   PROMPT EDITOR (подсветка переменных {var})
═══════════════════════════════════════════ */
.prompt-editor { display: flex; flex-direction: column; gap: 6px; }

.prompt-editor-toolbar { display: flex; justify-content: flex-end; }

.prompt-editor-insert-btn {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: var(--radius-sm);
  background: rgba(16, 185, 129, 0.1);
  color: #059669;
  border: 1px solid rgba(16, 185, 129, 0.3);
  cursor: pointer;
}
.prompt-editor-insert-btn:hover { background: rgba(16, 185, 129, 0.18); }

.prompt-editor-wrap {
  position: relative;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  overflow: hidden;
}
.prompt-editor-wrap:focus-within {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(var(--color-accent-rgb), 0.12);
}

.prompt-editor-highlight,
.prompt-editor-textarea {
  margin: 0;
  padding: 10px 12px;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
  border: none;
  width: 100%;
  box-sizing: border-box;
  /* ВАЖНО: скроллбар скрыт у ОБОИХ элементов одинаково.
     Если у textarea скроллбар видимый (нативный), а у highlight скрытый,
     то в момент появления скролла у textarea "съедается" часть ширины
     под скроллбар, а у highlight — нет. Из-за этого ширина строки
     расходится и текст в подложке/в textarea начинает по-разному
     переноситься (word-wrap), что и выглядит как "уезжающий" вниз
     курсор/выделение. Поэтому скроллбар прячем у обоих одинаково. */
  overflow: auto;
  scrollbar-width: none;
}
.prompt-editor-highlight::-webkit-scrollbar,
.prompt-editor-textarea::-webkit-scrollbar {
  display: none;
}

.prompt-editor-highlight {
  position: absolute;
  inset: 0;
  color: var(--color-text);
  pointer-events: none;
  background: transparent;
  z-index: 1;
}

.prompt-editor-textarea {
  position: relative;
  z-index: 2;
  display: block;
  min-height: 90px;
  resize: none;
  color: transparent;
  caret-color: var(--color-text);
  background: transparent;
  outline: none;
}
.prompt-editor-textarea::placeholder { color: var(--color-text-3); }
.prompt-editor-textarea::selection { background: rgba(var(--color-accent-rgb), 0.35); }

.var-pill {
  border-radius: 4px;
  padding: 0 2px;
  font-weight: 600;
}
.var-pill.var-valid {
  background: rgba(16, 185, 129, 0.16);
  color: #059669;
}
.var-pill.var-invalid {
  background: rgba(245, 158, 11, 0.16);
  color: #b45309;
  border: 1px dashed rgba(245, 158, 11, 0.5);
}

.prompt-editor-varlist {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: 11px;
}
.prompt-editor-varlist-label {
  color: var(--color-text-3);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .3px;
  margin-right: 2px;
}
.var-chip {
  font-family: 'SF Mono', 'Fira Code', monospace;
  background: rgba(16, 185, 129, 0.1);
  color: #059669;
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 11px;
}
.prompt-editor-novars {
  color: var(--color-text-3);
  font-size: 11px;
  font-style: italic;
}
