/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0f0f1a;
  --bg2:      #161625;
  --card:     #1c1c2e;
  --card2:    #22223b;
  --border:   #2a2a4a;
  --text:     #e2e2f0;
  --text-muted:#8888aa;
  --accent:   #7c3aed;
  --accent2:  #a855f7;
  --green:    #22c55e;
  --red:      #ef4444;
  --yellow:   #eab308;
  --blue:     #3b82f6;
  --sidebar-w: 240px;
  --radius:   12px;
  --shadow:   0 4px 20px rgba(0,0,0,.4);
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Auth Pages ───────────────────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at top left, #1a0a2e 0%, #0f0f1a 60%);
  padding: 20px;
}

.auth-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 22px;
  font-weight: 800;
  color: var(--accent2);
  margin-bottom: 24px;
}
.auth-logo i { font-size: 28px; }

.auth-title { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.auth-sub   { color: var(--text-muted); margin-bottom: 28px; }
.auth-footer{ text-align: center; margin-top: 20px; color: var(--text-muted); font-size: 13px; }

/* ── Form elements ─────────────────────────────────────────────────────────── */
.form-group    { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-group label { font-size: 13px; font-weight: 500; color: var(--text); }
.form-row      { display: grid; grid-template-columns: repeat(auto-fit,minmax(160px,1fr)); gap: 14px; }

input[type="text"],input[type="email"],input[type="password"],
input[type="number"],input[type="time"],select,textarea {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 14px;
  font-size: 14px;
  width: 100%;
  transition: border-color .2s;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
select option { background: var(--card); }

.input-icon { position: relative; }
.input-icon i:first-child {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none;
}
.input-icon input { padding-left: 36px; }
.eye-btn {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 4px;
}
.eye-btn:hover { color: var(--text); }

.hint { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border-radius: 8px; font-size: 14px; font-weight: 600;
  border: none; cursor: pointer; transition: all .2s; white-space: nowrap;
}
.btn-primary  { background: var(--accent);  color: #fff; }
.btn-primary:hover { background: var(--accent2); transform: translateY(-1px); }
.btn-success  { background: var(--green);   color: #000; }
.btn-success:hover { filter: brightness(1.1); }
.btn-danger   { background: var(--red);     color: #fff; }
.btn-danger:hover  { filter: brightness(1.1); }
.btn-outline  {
  background: transparent; border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent2); }
.btn-full { width: 100%; }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-xs { padding: 4px 10px; font-size: 12px; }
.btn-spinner, .hidden { display: none !important; }

/* ── App Layout ───────────────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: width .25s;
  overflow: hidden;
}
.sidebar.collapsed { width: 60px; }
.sidebar.collapsed .sidebar-brand span,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .user-name,
.sidebar.collapsed .user-email { display: none; }

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 16px;
  font-size: 18px; font-weight: 800; color: var(--accent2);
  border-bottom: 1px solid var(--border);
}
.sidebar-brand i { font-size: 22px; min-width: 28px; text-align: center; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 8px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 8px;
  color: var(--text-muted); font-size: 13px; font-weight: 500;
  transition: all .2s; margin-bottom: 2px;
}
.nav-item i { min-width: 18px; text-align: center; font-size: 15px; }
.nav-item:hover { background: var(--card); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-divider { border: none; border-top: 1px solid var(--border); margin: 8px 4px; }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
}
.user-pill  { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.user-name  { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logout-btn {
  color: var(--text-muted); padding: 6px; border-radius: 6px; flex-shrink: 0;
}
.logout-btn:hover { color: var(--red); text-decoration: none; }

/* ── Main Content ─────────────────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ── Topbar ───────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex; align-items: center; gap: 16px;
}
.hamburger { background: none; border: none; color: var(--text-muted); font-size: 18px; cursor: pointer; }
.topbar-title { font-size: 16px; font-weight: 600; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.status-pill {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 12px; border-radius: 20px;
  font-size: 12px; font-weight: 600;
}
.status-running { background: rgba(34,197,94,.15); color: var(--green); }
.status-stopped { background: rgba(239,68,68,.12);  color: var(--red); }
.pulse {
  width: 8px; height: 8px; border-radius: 50%;
  background: currentColor;
}
.status-running .pulse { animation: pulse 1.4s infinite; }
@keyframes pulse {
  0%,100% { opacity:1; transform:scale(1); }
  50%      { opacity:.4; transform:scale(1.4); }
}

/* ── Global alert ─────────────────────────────────────────────────────────── */
.global-alert {
  padding: 12px 24px;
  font-size: 13px; font-weight: 500;
}
.alert-success { background: rgba(34,197,94,.15); color: var(--green); }
.alert-error   { background: rgba(239,68,68,.15); color: var(--red); }
.alert-warn    { background: rgba(234,179,8,.15);  color: var(--yellow); }
.alert-info    { background: rgba(59,130,246,.15); color: var(--blue); }

.alert { border-radius: 8px; padding: 12px 16px; font-size: 13px; margin-bottom: 0; }

/* ── Sections ─────────────────────────────────────────────────────────────── */
.section { display: none; padding: 24px; }
.section.active { display: block; }
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.section-header h2 { font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.section-hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 600; font-size: 13px;
}
.config-card { padding: 24px; }

/* ── Stat Cards ───────────────────────────────────────────────────────────── */
.cards-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px,1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex; align-items: center; gap: 16px;
}
.stat-icon {
  width: 46px; height: 46px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.stat-icon.green  { background: rgba(34,197,94,.15);  color: var(--green); }
.stat-icon.blue   { background: rgba(59,130,246,.15);  color: var(--blue); }
.stat-icon.purple { background: rgba(124,58,237,.15);  color: var(--accent2); }
.stat-icon.red    { background: rgba(239,68,68,.15);   color: var(--red); }
.stat-label { font-size: 12px; color: var(--text-muted); }
.stat-value { font-size: 20px; font-weight: 700; }

/* ── Tables ───────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  background: var(--bg2);
  padding: 10px 14px;
  text-align: left;
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  color: var(--text-muted); white-space: nowrap;
}
.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px; white-space: nowrap;
}
.data-table tr:hover td { background: rgba(255,255,255,.02); }
.empty-row { text-align: center; color: var(--text-muted); padding: 30px !important; }

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 600;
}
.badge-green  { background: rgba(34,197,94,.2);  color: var(--green); }
.badge-red    { background: rgba(239,68,68,.2);  color: var(--red); }
.badge-blue   { background: rgba(59,130,246,.2);  color: var(--blue); }
.badge-purple { background: rgba(124,58,237,.2);  color: var(--accent2); }
.badge-yellow { background: rgba(234,179,8,.2);   color: var(--yellow); }
.badge-gray   { background: rgba(136,136,170,.2); color: var(--text-muted); }
.badge-required { font-size: 11px; background: rgba(239,68,68,.15); color: var(--red); padding: 1px 6px; border-radius: 4px; margin-left: 4px; }

/* ── Terminal / Logs ──────────────────────────────────────────────────────── */
.terminal {
  background: #080812;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  height: calc(100vh - 220px);
  overflow-y: auto;
  padding: 16px;
  font-family: 'JetBrains Mono','Fira Code',monospace;
  font-size: 12.5px;
  line-height: 1.7;
}
.log-line      { color: #c8c8d8; }
.log-error     { color: #ff6b6b; }
.log-warn      { color: #ffd93d; }
.log-success   { color: #6bcb77; }
.log-order     { color: #74c0fc; }

/* ── Toggle switch ────────────────────────────────────────────────────────── */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; }
.switch input { opacity:0; width:0; height:0; }
.slider {
  position: absolute; inset:0; background: var(--border);
  border-radius: 24px; transition: .3s; cursor: pointer;
}
.slider::before {
  content:''; position:absolute; height:18px; width:18px; left:3px; bottom:3px;
  background:#fff; border-radius:50%; transition:.3s;
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(18px); }

.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; gap: 10px;
}

/* ── Plans / Subscription ─────────────────────────────────────────────────── */
.plans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px,1fr));
  gap: 20px;
  margin-top: 20px;
}
.plan-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 22px;
  display: flex; flex-direction: column; gap: 14px;
  transition: transform .2s;
}
.plan-card:hover { transform: translateY(-3px); }
.plan-card.featured { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.plan-badge  { font-size: 11px; font-weight: 700; color: var(--accent2); text-transform: uppercase; letter-spacing:.06em; }
.plan-price  { font-size: 32px; font-weight: 800; }
.plan-price span { font-size: 14px; color: var(--text-muted); font-weight: 400; }
.plan-name   { font-size: 14px; color: var(--text-muted); margin-top: -10px; }
.plan-features { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.plan-features li { font-size: 13px; display: flex; align-items: center; gap: 8px; }
.plan-features li i { color: var(--green); font-size: 12px; }

/* ── License banner ───────────────────────────────────────────────────────── */
.license-banner {
  padding: 12px 20px;
  border-radius: 8px;
  margin-bottom: 20px;
  display: flex; align-items: center; gap: 10px;
  font-size: 13px;
}
.license-active  { background: rgba(34,197,94,.12); border: 1px solid rgba(34,197,94,.3); color: var(--green); }
.license-expired { background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.3); color: var(--red); }

/* ── Group cards ──────────────────────────────────────────────────────────── */
.group-card { margin-bottom: 14px; }
.group-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.group-header h4 { font-size: 15px; display: flex; align-items: center; gap: 8px; color: var(--accent2); }

/* ── Lot distribution table ───────────────────────────────────────────────── */
.instrument-section { margin-top: 16px; }
.section-label { font-size: 12px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }

.lot-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.lot-table th {
  background: var(--bg2); color: var(--text-muted); font-size: 11px;
  font-weight: 600; text-transform: uppercase; padding: 6px 8px;
  border: 1px solid var(--border); text-align: center;
}
.lot-table th:first-child { text-align: left; }
.lot-table td {
  border: 1px solid var(--border); padding: 4px 6px; text-align: center; vertical-align: middle;
}
.inst-row:hover td { background: rgba(124,58,237,.08); }
.inst-name-cell { font-size: 12px; font-weight: 700; color: var(--accent2); text-align: left !important;
  padding-left: 10px !important; white-space: nowrap; }
.script-sym { color: var(--accent) !important; }
.lot-input { width: 52px; text-align: center; padding: 4px 6px; font-size: 13px;
  font-weight: 600; background: var(--bg); border: 1px solid var(--border);
  border-radius: 5px; color: var(--text); }
.lot-input:focus { border-color: var(--accent); outline: none; }
.lot-total { color: var(--accent2); }
.lot-target { color: var(--text-muted); }
.lot-hint { font-size: 11px; color: var(--text-muted); margin-top: 6px; }

/* Equity scripts */
.equity-scripts-section { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 14px; }
.equity-scripts-header { display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px; font-size: 13px; font-weight: 600; color: var(--text-muted); }
.equity-empty { font-size: 12px; color: var(--text-muted); padding: 8px 0; }

/* ── Filter row ───────────────────────────────────────────────────────────── */
.filter-row { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.filter-btn {
  padding: 6px 14px; border-radius: 6px; border: 1px solid var(--border);
  background: transparent; color: var(--text-muted); font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all .2s;
}
.filter-btn:hover, .filter-btn.active {
  background: var(--accent); border-color: var(--accent); color: #fff;
}

/* ── Misc ─────────────────────────────────────────────────────────────────── */
.text-green { color: var(--green); }
.text-red   { color: var(--red); }
.text-muted { color: var(--text-muted); }
.mt-10 { margin-top: 10px; }
.mt-20 { margin-top: 20px; }
.mb-10 { margin-bottom: 10px; }
.mb-20 { margin-bottom: 20px; }

.empty-state {
  text-align: center;
  padding: 48px;
  color: var(--text-muted);
}
.empty-state i { font-size: 40px; margin-bottom: 12px; display: block; }

.lic-active {
  text-align: center; padding: 32px 0;
}

h4 { font-size: 14px; font-weight: 600; color: var(--text-muted); margin-bottom: 14px; }

/* ── Bot checklist ────────────────────────────────────────────────────────── */
.checklist-card {
  background: rgba(234,179,8,.08);
  border: 1px solid rgba(234,179,8,.3);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
}
.checklist-title {
  font-size: 13px; font-weight: 600; color: var(--yellow);
  margin-bottom: 12px; display: flex; align-items: center; gap: 8px;
}
.checklist-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 6px;
  font-size: 13px; cursor: pointer; margin-bottom: 4px;
  transition: background .15s;
}
.checklist-item:hover { background: rgba(255,255,255,.05); }
.checklist-item.done { color: var(--green); }
.checklist-item.pending { color: var(--text); }
.checklist-item.done i { color: var(--green); }
.checklist-item.pending i { color: var(--red); }
.checklist-fix { margin-left:auto; font-size:11px; color:var(--accent2); font-weight:600; }

/* ── Telegram auth ────────────────────────────────────────────────────────── */
.tg-status-box {
  padding: 12px 16px; border-radius: 8px; font-size: 13px;
  display: flex; align-items: center; gap: 10px; margin-bottom: 16px;
}
.tg-auth-ok      { background: rgba(34,197,94,.12); color: var(--green); border: 1px solid rgba(34,197,94,.3); }
.tg-auth-pending { background: rgba(234,179,8,.1);  color: var(--yellow); border: 1px solid rgba(234,179,8,.3); }

.step-badge {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff; border-radius: 6px;
  font-size: 11px; font-weight: 700; padding: 2px 8px; margin-right: 8px;
}
h4 { display: flex; align-items: center; }

/* ── Scrollbar ────────────────────────────────────────────────────────────── */
::-webkit-scrollbar        { width: 6px; height: 6px; }
::-webkit-scrollbar-track  { background: var(--bg); }
::-webkit-scrollbar-thumb  { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar .sidebar-brand span, .sidebar .nav-item span,
  .sidebar .user-name, .sidebar .user-email { display: none; }
  .main-content { margin-left: 60px; }
  .cards-row { grid-template-columns: 1fr 1fr; }
}

.toggle-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.toggle-label input { width: auto; }
