/* LaneBot dashboard -- giao diện sáng, xanh lá làm màu chủ đạo (mobile-first) */
:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-border: #e2e6ea;
  --text: #1f2933;
  --text-dim: #6b7785;
  --accent: #1b7f2f;
  --accent-soft: rgba(27, 127, 47, 0.1);
  --accent-strong: #146823;
  --long: #1b8a3a;
  --short: #d6291f;
  --warn: #c98a12;
  --danger: #d6291f;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.35;
  padding-bottom: 62px; /* chừa chỗ cho thanh điều hướng dưới */
}
.hidden { display: none !important; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  padding: 7px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--panel-border);
}
.brand { display: flex; align-items: center; gap: 5px; font-weight: 700; font-size: 15px; white-space: nowrap; }
.brand-mark { color: var(--accent); }
.brand-accent { color: var(--accent); }
.bot-chip {
  background: var(--accent); color: #fff; border-radius: 6px;
  padding: 2px 8px; font-size: 11px; font-weight: 600;
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.balance-chip {
  background: var(--accent-soft); color: var(--accent-strong);
  border: 0; border-radius: 7px; padding: 4px 10px;
  font-weight: 700; font-size: 13px; cursor: pointer; font-family: var(--font-ui);
}
.icon-btn {
  background: transparent; border: 0; font-size: 20px; cursor: pointer;
  color: var(--text); padding: 2px 6px; line-height: 1;
}
.menu-wrap { position: relative; }
.menu-dropdown {
  position: absolute; right: 0; top: 36px; min-width: 200px;
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12); padding: 6px; z-index: 40;
}
.menu-email { padding: 8px 10px; font-size: 12px; color: var(--text-dim); word-break: break-all; border-bottom: 1px solid var(--panel-border); margin-bottom: 4px; }
.menu-dropdown button {
  display: block; width: 100%; text-align: left; background: transparent; border: 0;
  padding: 10px; font-size: 14px; border-radius: 6px; cursor: pointer; color: var(--text);
}
.menu-dropdown button:hover { background: var(--bg); }

/* ---------- Content ---------- */
.content { padding: 10px; max-width: 1200px; margin: 0 auto; }
.tab { display: none; }
.tab.active { display: block; }
.tab-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.tab-header h1 { font-size: 17px; margin: 0; }

/* ---------- Filters ---------- */
.filters { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 8px; }
.filters label { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--text-dim); }
.select, .filters input, .modal-body input, .modal-body select, .modal-body label select {
  width: 100%; padding: 6px 8px; border: 1px solid var(--panel-border); border-radius: 7px;
  background: var(--panel); color: var(--text); font-size: 13px; font-family: var(--font-ui);
}
.summary-row { display: flex; align-items: center; gap: 8px; margin: 4px 0 8px; font-weight: 600; font-size: 13px; }
.summary-sep { color: var(--panel-border); }
.bookmark-filter { background: transparent; border: 0; font-weight: 600; font-size: 13px; cursor: pointer; color: var(--text); font-family: var(--font-ui); }
.bookmark-filter.on { color: var(--warn); }

/* ---------- Buttons ---------- */
.btn-primary {
  background: var(--accent); color: #fff; border: 0; border-radius: 8px;
  padding: 8px 14px; font-weight: 600; font-size: 13px; cursor: pointer; font-family: var(--font-ui);
}
.btn-primary:hover { background: var(--accent-strong); }
.btn-ghost {
  background: transparent; color: var(--text); border: 1px solid var(--panel-border);
  border-radius: 7px; padding: 6px 12px; font-size: 12.5px; cursor: pointer; font-family: var(--font-ui);
}
.btn-ghost:hover { background: var(--bg); }
.btn-danger-text { background: transparent; border: 0; color: var(--danger); cursor: pointer; font-size: 13px; padding: 4px 6px; font-family: var(--font-ui); }
.btn-danger {
  background: var(--danger); color: #fff; border: 0; border-radius: 8px; padding: 8px 14px;
  font-weight: 600; font-size: 13px; cursor: pointer; font-family: var(--font-ui);
}

/* ---------- Coin groups ---------- */
.lane-group { background: var(--panel); border: 1px solid var(--panel-border); border-radius: 9px; margin-bottom: 7px; overflow: visible; }
.lane-group-header { display: flex; align-items: center; gap: 6px; padding: 7px 10px; }
.group-caret { color: var(--accent); font-size: 16px; width: 18px; display: inline-block; text-align: center; }
.group-symbol-pill {
  border: 1px solid var(--panel-border); background: var(--bg); border-radius: 8px;
  padding: 3px 10px; font-weight: 700; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.group-count { color: var(--text-dim); font-weight: 500; font-size: 12px; margin-left: 4px; }
.star-btn { background: transparent; border: 0; font-size: 17px; cursor: pointer; color: #c9ced4; padding: 0 4px; line-height: 1; }
.star-btn.on { color: #e5a91a; }
.group-menu-wrap { position: relative; }
.group-menu-btn { background: transparent; border: 0; font-size: 18px; cursor: pointer; color: var(--accent); padding: 0 6px; font-weight: 700; }
.group-menu-dropdown {
  position: absolute; left: 0; top: 28px; min-width: 120px; z-index: 20;
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12); padding: 4px;
}
.group-menu-dropdown button {
  display: block; width: 100%; text-align: left; background: transparent; border: 0;
  padding: 9px 10px; font-size: 14px; cursor: pointer; border-radius: 6px; color: var(--text);
}
.group-menu-dropdown button:hover { background: var(--bg); }
.lane-group-body { border-top: 1px solid var(--panel-border); }

/* ---------- Tables ---------- */
.panel { background: var(--panel); border: 1px solid var(--panel-border); border-radius: 10px; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; min-width: 760px; }
.data-table th {
  text-align: center; font-size: 11px; font-weight: 700; padding: 7px 6px;
  border-bottom: 1px solid var(--panel-border); white-space: nowrap; color: var(--text);
}
.data-table td { text-align: center; padding: 7px 6px; font-size: 12.5px; border-bottom: 1px solid var(--panel-border); font-variant-numeric: tabular-nums; white-space: nowrap; }
.data-table tr:last-child td { border-bottom: 0; }
.empty-row td { color: var(--text-dim); padding: 24px; }
.act-cell { display: flex; align-items: center; justify-content: center; gap: 8px; }
.icon-act { background: transparent; border: 0; cursor: pointer; font-size: 15px; padding: 2px; line-height: 1; }
.icon-act.edit { color: var(--accent); }
.icon-act.del { color: var(--danger); }
.side-long { color: var(--long); font-weight: 700; }
.side-short { color: var(--short); font-weight: 700; }
.dim { color: var(--text-dim); }

.row-checkbox { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

.dir-badge { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 700; }
.dir-badge.long { background: rgba(27,138,58,0.12); color: var(--long); }
.dir-badge.short { background: rgba(214,41,31,0.12); color: var(--short); }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: #b8c0c8; }
.status-dot.open { background: var(--long); }
.status-dot.pending { background: var(--warn); }

/* ---------- Toggle ---------- */
.toggle { position: relative; display: inline-block; width: 34px; height: 19px; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider { position: absolute; inset: 0; background: #b8c0c8; border-radius: 22px; cursor: pointer; transition: background 0.15s; }
.toggle-slider::before { content: ""; position: absolute; width: 13px; height: 13px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform 0.15s; }
.toggle input:checked + .toggle-slider { background: var(--accent); }
  .toggle input:checked + .toggle-slider::before { transform: translateX(15px); }

/* ---------- Positions list ---------- */
.pos-list { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.pos-card { background: var(--panel); border: 1px solid var(--panel-border); border-radius: 9px; padding: 10px; }
.pos-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.pos-symbol { font-weight: 700; font-size: 14px; }
.pos-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px 10px; font-size: 12.5px; margin-bottom: 10px; }
.pos-grid .k { color: var(--text-dim); font-size: 11.5px; }
.pos-empty { background: var(--panel); border: 1px dashed var(--panel-border); border-radius: 10px; padding: 28px; text-align: center; color: var(--text-dim); }

/* ---------- FAB ---------- */
.fab-stack { position: fixed; right: 12px; bottom: 70px; display: flex; flex-direction: column; gap: 10px; z-index: 25; }
.fab {
  position: relative; width: 44px; height: 44px; border-radius: 11px; border: 0;
  background: var(--accent); color: #fff; font-size: 22px; cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25); font-family: var(--font-ui);
}
.fab-badge {
  position: absolute; top: -6px; right: -6px; background: var(--danger); color: #fff;
  border-radius: 10px; font-size: 11px; min-width: 20px; height: 20px; line-height: 20px; padding: 0 5px; font-weight: 700;
}

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; background: var(--panel); border-top: 1px solid var(--panel-border);
  padding-bottom: env(safe-area-inset-bottom);
}
.bnav-item {
  flex: 1; background: transparent; border: 0; padding: 6px 4px 5px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; color: var(--text-dim); position: relative; font-family: var(--font-ui);
}
.bnav-item.active { color: var(--accent); font-weight: 700; }
.bnav-ico { font-size: 17px; line-height: 1; }
.bnav-badge { position: absolute; top: 4px; left: calc(50% + 12px); background: var(--danger); color: #fff; border-radius: 10px; font-size: 10.5px; min-width: 18px; height: 18px; line-height: 18px; padding: 0 5px; }

/* ---------- Modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,32,0.5); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 12px; }
.modal { background: var(--panel); border-radius: 12px; width: 100%; max-width: 440px; max-height: 92vh; overflow-y: auto; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--panel-border); }
.modal-head h2 { margin: 0; font-size: 15px; }
.modal-x { background: transparent; border: 0; font-size: 26px; cursor: pointer; color: var(--text-dim); line-height: 1; }
.modal-body { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.modal-body label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-dim); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.error-banner { background: #fdecea; color: var(--danger); border-radius: 8px; padding: 10px 12px; font-size: 13px; }


.balance-chip.err { background: #fdecea; color: var(--danger); }

/* ---------- Bulk modal ---------- */
.bulk-count { margin: 0; font-weight: 600; font-size: 13px; }
.radio-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 6px; border: 1px solid var(--panel-border); border-radius: 8px; padding: 10px; }
.modal-body .radio-grid label { flex-direction: row; align-items: center; gap: 6px; font-size: 13px; color: var(--text); }
.radio-grid input { width: auto; accent-color: var(--accent); }
.bulk-head, .bulk-row { display: grid; grid-template-columns: 28px 1.3fr 0.6fr 1fr; gap: 6px; align-items: center; }
.bulk-head { font-size: 12px; font-weight: 600; margin-bottom: 6px; }
.bulk-row { margin-bottom: 6px; }
.bulk-row select, .bulk-row input { width: 100%; padding: 6px 6px; font-size: 13px; }
.bulk-note { margin: 0; font-size: 12px; color: var(--text-dim); }

/* ---------- Mobile ---------- */
@media (max-width: 768px) {
  .filters { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Strategy form (kiểu nhãn nổi trên viền) ---------- */
.info-btn { width: 18px; height: 18px; border-radius: 50%; border: 0; background: #555; color: #fff; font-size: 11px; font-weight: 700; cursor: pointer; vertical-align: middle; margin-left: 4px; }
.info-box { background: var(--bg); border: 1px solid var(--panel-border); border-radius: 8px; padding: 8px 10px; font-size: 12px; max-height: 38vh; overflow-y: auto; }
.info-box p { margin: 0 0 5px; }
.strategy-form { gap: 12px; }
.fl { position: relative; }
.fl > label { position: absolute; top: -7px; left: 8px; background: var(--panel); padding: 0 4px; font-size: 11px; color: var(--text-dim); z-index: 1; pointer-events: none; }
.fl input, .fl select { width: 100%; padding: 9px 8px; border: 1px solid var(--panel-border); border-radius: 7px; background: var(--panel); color: var(--text); font-size: 13px; font-family: var(--font-ui); }
.fl input:focus, .fl select:focus { outline: none; border-color: var(--accent); }
.fl-row { display: grid; gap: 8px; }
.fl-row.two { grid-template-columns: 1fr 1fr; }
.fl-row.three { grid-template-columns: 1fr 1fr 1fr; }
.fl-prefix { display: flex; align-items: center; border: 1px solid var(--panel-border); border-radius: 7px; background: var(--panel); padding-left: 8px; padding-right: 8px; gap: 4px; }
.fl-prefix:focus-within { border-color: var(--accent); }
.fl-prefix input { border: 0; padding: 9px 2px; min-width: 0; }
.fl-prefix input:focus { outline: none; }
.fl-prefix span { color: var(--text-dim); font-size: 12px; white-space: nowrap; }
.switch-row { display: flex; justify-content: space-around; align-items: center; padding: 2px 0; }
.switch-item { display: flex; flex-direction: column; align-items: center; gap: 5px; font-size: 12.5px; color: var(--text-dim); }
.btn-blue { background: #1976d2; color: #fff; border: 0; border-radius: 7px; padding: 8px 12px; font-weight: 600; font-size: 12.5px; cursor: pointer; font-family: var(--font-ui); }
.modal-actions .btn-ghost { background: #e6e8eb; border: 0; }
.lane-group.starred { border-left: 3px solid #e5a91a; }
