/* market_bot admin panel */
:root {
  --bg: #0f1117;
  --card: #1a1d27;
  --border: #2a2f3d;
  --text: #e8eaef;
  --muted: #9aa3b5;
  --accent: #5b8def;
  --ok: #3ecf8e;
  --warn: #f0b429;
  --bad: #f07178;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px;
  background: var(--card);
  border-right: 1px solid var(--border);
  padding: 1rem;
  flex-shrink: 0;
}
.sidebar h1 { font-size: 1rem; margin: 0 0 1rem; color: var(--muted); }
.sidebar nav a {
  display: block;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  color: var(--text);
  margin-bottom: 0.2rem;
}
.sidebar nav a.active, .sidebar nav a:hover {
  background: #252a38;
  text-decoration: none;
}
.main { flex: 1; padding: 1.25rem 1.5rem; max-width: 1400px; }
h2 { margin-top: 0; font-size: 1.35rem; }
.muted { color: var(--muted); font-size: 0.9rem; }
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
}
.card .val { font-size: 1.5rem; font-weight: 600; }
.card .lbl { color: var(--muted); font-size: 0.8rem; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
th, td {
  border-bottom: 1px solid var(--border);
  padding: 0.55rem 0.5rem;
  text-align: left;
  vertical-align: top;
}
th { color: var(--muted); font-weight: 500; }
.badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 0.75rem;
  background: #2a3144;
}
.badge.on { background: #1e3d2f; color: var(--ok); }
.badge.connecting { background: #3d3520; color: #e6c04a; }
.badge.err { background: #3d2020; color: var(--bad); }
.badge.off { background: #2a2d35; color: var(--muted, #888); }
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
}
input, select, textarea, button {
  font: inherit;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  padding: 0.45rem 0.65rem;
}
button, .btn {
  cursor: pointer;
  background: #2a3550;
  border-color: #3a4a6a;
}
button:hover, .btn:hover { background: #354366; }
button.danger { background: #4a2a2a; border-color: #6a3a3a; }
button.primary { background: #2a4060; border-color: var(--accent); }
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  .grid-2 { grid-template-columns: 1fr; }
}
.section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 1rem;
}
.section h3 { margin: 0 0 0.75rem; font-size: 1rem; }
.login-wrap {
  max-width: 360px;
  margin: 15vh auto;
  padding: 2rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.login-wrap h2 { text-align: center; }
.error { color: var(--bad); margin-bottom: 0.75rem; }
.flash { padding: 0.5rem 0.75rem; border-radius: 6px; margin-bottom: 0.75rem; }
.flash.ok { background: #1e3d2f; }
.flash.bad { background: #3d2a2a; }
.chat-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 0.75rem;
  min-height: 420px;
}
.chat-list {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: auto;
  max-height: 480px;
}
.chat-list button {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
}
.chat-list button.active { background: #252a38; }
.chat-list button.pin { font-weight: 600; color: var(--accent); }
.messages {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  overflow: auto;
  max-height: 360px;
  font-size: 0.85rem;
}
.msg { margin-bottom: 0.65rem; padding-bottom: 0.5rem; border-bottom: 1px solid #222836; }
.msg.out { color: #b8c9f0; }
.msg .meta { color: var(--muted); font-size: 0.75rem; }
.send-row { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.send-row input { flex: 1; }
pre.progress { white-space: pre-wrap; font-size: 0.85rem; color: var(--muted); }
.settings-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 1rem 0;
}
.settings-nav a {
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.85rem;
}
.settings-nav a:hover { background: #252a38; text-decoration: none; }
.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.field { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.85rem; }
.field span { color: var(--muted); }
.field.block { margin-bottom: 0.75rem; }
.field input, .field textarea { width: 100%; }
.geo-add-row { display: flex; gap: 0.5rem; margin-bottom: 0.75rem; }
table.compact td, table.compact th { padding: 0.4rem 0.35rem; }
.mono { font-family: ui-monospace, monospace; font-size: 0.82rem; }
.path-list { margin: 0.25rem 0 0.75rem; padding-left: 1.2rem; color: var(--muted); font-size: 0.85rem; }
.env-readonly-title { margin: 1.25rem 0 0.5rem; font-size: 0.95rem; color: var(--muted); font-weight: 500; }
.tiny { font-size: 0.78rem; }
.env-field-grid {
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  align-items: stretch;
}
.env-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-height: 100%;
}
.env-field-label {
  color: var(--muted);
  min-height: 2.75rem;
  line-height: 1.35;
}
.env-field-label code {
  color: var(--text);
  font-size: 0.78rem;
}
.env-field input,
.env-field select {
  width: 100%;
  min-height: 2.35rem;
  box-sizing: border-box;
}
.field-hint {
  min-height: 1.05rem;
  line-height: 1.05rem;
}
#env-form > .primary {
  margin-top: 0.5rem;
}
table.kv th {
  width: 38%;
  color: var(--muted);
  font-weight: 500;
  vertical-align: top;
}
.bad-text { color: var(--bad); }
.ok-text { color: var(--good, #3a9d4b); }
.event-actions { margin: 1rem 0; }
.profit-pos { color: var(--ok); }
.profit-neg { color: var(--bad); }
.status-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}
.status-row select { min-width: 10rem; }

/* account pipeline stepper */
.pipeline {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}
.pipeline-macro,
.pipeline-micro-row {
  display: flex;
  align-items: stretch;
  gap: 0;
  overflow-x: auto;
  padding-bottom: 0.35rem;
  scrollbar-width: thin;
}
.pipe-step,
.pipe-micro {
  flex: 0 0 auto;
  min-width: 5.5rem;
  max-width: 8.5rem;
  padding: 0.5rem 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #151820;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}
.pipe-micro {
  min-width: 4.8rem;
  max-width: 7.5rem;
  padding: 0.4rem 0.45rem;
  font-size: 0.78rem;
}
.pipe-emoji { font-size: 1.1rem; line-height: 1.2; }
.pipe-micro .pipe-emoji { font-size: 0.95rem; }
.pipe-label {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.2;
  word-break: break-word;
}
.pipe-hint {
  font-size: 0.65rem;
  color: var(--warn);
  line-height: 1.15;
}
.pipe-connector,
.pipe-micro-connector {
  flex: 0 0 1.1rem;
  align-self: center;
  height: 2px;
  background: var(--border);
  margin: 0 -0.1rem;
}
.pipe-done {
  border-color: #2a4a38;
  background: #152219;
}
.pipe-done .pipe-label { color: #7dcea0; }
.pipe-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(91, 141, 239, 0.25);
  background: #1a2438;
}
.pipe-active .pipe-label { color: var(--text); font-weight: 600; }
.pipe-hold {
  border-color: #5a4a22;
  background: #241f14;
}
.pipe-hold .pipe-label { color: var(--warn); }
.pipe-error {
  border-color: #5a2a2a;
  background: #2a1818;
}
.pipe-error .pipe-label { color: var(--bad); }
.pipe-pending {
  opacity: 0.55;
}
.pipe-skipped {
  opacity: 0.4;
  border-style: dashed;
}
.pipeline-micro {
  margin-top: 0.75rem;
  padding: 0.65rem 0.7rem;
  border-radius: 8px;
  background: #12151c;
  border: 1px solid var(--border);
}
.pipeline-micro-title {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.45rem;
}
.sales-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.65rem;
}
.sales-grid .card .val { font-size: 1.25rem; }
.sales-sub { margin-top: 0.25rem; font-size: 0.78rem; color: var(--muted); }
.subsection-title {
  margin: 1.25rem 0 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}
.subsection-title:first-of-type { margin-top: 0.35rem; }
.create-form label { display: block; margin-bottom: 0.65rem; font-size: 0.88rem; }
.create-form input[type="text"],
.create-form input[type="number"],
.create-form input[type="file"],
.create-form select,
.create-form textarea { width: 100%; margin-top: 0.25rem; box-sizing: border-box; }
.btn-upload {
  display: inline-block;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
}
.compact-table { font-size: 0.85rem; }
.compact-table th, .compact-table td { padding: 0.45rem 0.4rem; }
