:root {
  --bg: #0b1020;
  --surface: #121a2f;
  --surface-2: #18233e;
  --border: #22304f;
  --text: #e8eefc;
  --muted: #93a4c7;
  --accent: #4f8cff;
  --accent-hover: #3b76e8;
  --ok: #2ecc71;
  --amber: #f5a623;
  --danger: #ff5c73;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  font-size: 14px;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { margin: 0 0 4px 0; font-size: 1.35rem; }
h3 { margin: 0 0 10px 0; font-size: 1rem; }
.muted { color: var(--muted); margin: 0; }
.small { font-size: 0.82rem; }
.hidden { display: none !important; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 1.05rem; }
.brand-badge {
  margin-left: 8px; padding: 2px 8px; font-size: 0.72rem; font-weight: 600;
  border-radius: 999px; background: rgba(79,140,255,0.18); color: var(--accent);
}
.topbar-right { display: flex; align-items: center; gap: 12px; font-size: 0.86rem; color: var(--muted); }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-right: 6px; }

.tabs {
  display: flex; gap: 4px; padding: 0 24px;
  background: var(--surface); border-bottom: 1px solid var(--border); overflow-x: auto;
}
.tab {
  padding: 10px 14px; font-size: 0.9rem; color: var(--muted);
  border-bottom: 2px solid transparent; white-space: nowrap; text-decoration: none !important;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

.container { max-width: 1320px; margin: 20px auto 48px auto; padding: 0 20px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.panel-head h3 { margin: 0; }

.grid-kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); gap: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.card-label { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.card-value { margin-top: 6px; font-size: 1.5rem; font-weight: 700; }
.card-sub { margin-top: 4px; font-size: 0.8rem; color: var(--muted); }

.progress-track { height: 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; margin: 8px 0; }
.progress-fill { height: 100%; background: var(--accent); transition: width 0.25s ease; }
.progress-green { background: var(--ok); }

.action-bar { display: flex; flex-wrap: wrap; gap: 10px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; font-size: 0.86rem; font-weight: 600; color: #fff;
  background: var(--accent); border: 1px solid transparent; border-radius: 7px; cursor: pointer;
}
.btn:hover:not(:disabled) { background: var(--accent-hover); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); border-color: var(--accent); }
.btn-danger { background: rgba(255,92,115,0.16); color: #ff9aa8; border-color: rgba(255,92,115,0.4); }
.btn-sm { padding: 5px 10px; font-size: 0.78rem; }

.badge {
  display: inline-block; padding: 2px 8px; font-size: 0.74rem; font-weight: 600;
  border-radius: 999px; border: 1px solid transparent; white-space: nowrap;
}
.badge-green { background: rgba(46,204,113,0.16); color: #67e89b; border-color: rgba(46,204,113,0.35); }
.badge-blue { background: rgba(79,140,255,0.18); color: #8cb6ff; border-color: rgba(79,140,255,0.35); }
.badge-amber { background: rgba(245,166,35,0.16); color: #ffca6b; border-color: rgba(245,166,35,0.35); }
.badge-red { background: rgba(255,92,115,0.16); color: #ff9aa8; border-color: rgba(255,92,115,0.35); }
.badge-muted { background: var(--surface-2); color: var(--muted); border-color: var(--border); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.span-2 { grid-column: span 2; }
.field { margin-bottom: 10px; }
.form-grid .field { margin-bottom: 0; }
.field label { display: block; margin-bottom: 5px; font-size: 0.8rem; color: var(--muted); }
input, select, textarea {
  width: 100%; padding: 8px 10px; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 7px; font-size: 0.88rem; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
input[type="checkbox"] { width: auto; }
.check-label { display: inline-flex !important; align-items: center; gap: 8px; cursor: pointer; color: var(--text) !important; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-form select, .inline-form input { width: auto; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 0.76rem; text-transform: uppercase; }
tr:hover td { background: rgba(255,255,255,0.02); }
.log-pre {
  margin: 6px 0 0 0; padding: 8px 10px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; font-family: ui-monospace, monospace; font-size: 0.76rem; white-space: pre-wrap; color: var(--muted);
}

.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.filter-bar select, .filter-bar input { width: auto; min-width: 135px; }
.split-pane { display: grid; grid-template-columns: 390px minmax(0, 1fr); gap: 16px; align-items: start; }
.pane-list { display: flex; flex-direction: column; gap: 8px; max-height: 78vh; overflow-y: auto; padding-right: 4px; }
.lead-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 12px; cursor: pointer;
}
.lead-item:hover { border-color: var(--accent); }
.lead-item.active { border-color: var(--accent); background: var(--surface-2); }
.lead-item-top { display: flex; justify-content: space-between; align-items: start; gap: 8px; font-weight: 600; }
.lead-item-meta { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }

.pill-bar { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  padding: 6px 12px; border-radius: 999px; font-size: 0.82rem; font-weight: 600; cursor: pointer;
  background: var(--surface); color: var(--muted); border: 1px solid var(--border);
}
.pill.active { background: rgba(79,140,255,0.18); color: var(--text); border-color: var(--accent); }

.warn-box {
  margin-top: 8px; padding: 8px 10px; border-radius: 7px; font-size: 0.82rem;
  background: rgba(245,166,35,0.15); border: 1px solid rgba(245,166,35,0.45); color: #ffca6b;
}
.error {
  margin-bottom: 14px; padding: 10px 12px; background: rgba(255,92,115,0.12);
  border: 1px solid rgba(255,92,115,0.4); color: #ff9aa8; border-radius: 7px; font-size: 0.875rem;
}
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 26px; }

#toast-container {
  position: fixed; right: 20px; bottom: 20px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px; max-width: 360px;
}
.toast {
  padding: 10px 14px; border-radius: 8px; font-size: 0.86rem; font-weight: 500;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
}
.toast-ok { border-color: rgba(46,204,113,0.5); }
.toast-err { border-color: rgba(255,92,115,0.55); color: #ff9aa8; }

@media (max-width: 960px) {
  .grid-2, .split-pane, .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .pane-list { max-height: none; }
}
