:root {
  --bg: #0b1220;
  --panel: #152238;
  --card: #1b2c47;
  --fg: #f8fafc;
  --muted: #b7c7db;
  --gold: #f8cf78;
  --green: #4ade80;
  --red: #fb7185;
  --cyan: #38bdf8;
  --purple: #c084fc;
  --line: #304766;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: 'Segoe UI', Tahoma, system-ui, -apple-system, sans-serif;
  direction: rtl;
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  max-width: 1560px;
  margin: 0 auto;
  padding: 10px 12px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 4px;
  border-bottom: 1px solid var(--line);
}

.brand {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--gold);
  letter-spacing: 0.4px;
}

.header-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}

.pill {
  padding: 5px 10px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.82rem;
  background: var(--panel);
  border: 1px solid var(--line);
}
.pill.safe { background: #113626; color: var(--green); border-color: #1f5c3e; }
.pill.warn { background: #3b2d12; color: var(--gold); border-color: #6b5220; }
.pill.danger { background: #3b1721; color: var(--red); border-color: #6d283a; }
.pill.cyan { color: var(--cyan); }

.controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.row label {
  font-size: 0.85rem;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

input[type="text"], input[type="number"], select {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px 10px;
  font-size: 0.9rem;
  outline: none;
}
input:focus, select:focus { border-color: var(--gold); }
.grow { flex: 1 1 240px; min-width: 180px; }
.num-sm { width: 76px; text-align: center; }
.num-md { width: 96px; text-align: center; }

button {
  background: var(--line);
  color: var(--fg);
  border: none;
  border-radius: 7px;
  padding: 8px 13px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
button:hover { opacity: 0.92; }
button:active { transform: scale(0.98); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.accent { background: var(--gold); color: var(--bg); font-weight: 800; }
button.danger { background: #4c1d29; color: var(--red); }
button.success { background: #14442e; color: var(--green); }

.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: auto;
  max-height: 360px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  white-space: nowrap;
}
thead th {
  position: sticky;
  top: 0;
  background: var(--line);
  color: var(--fg);
  padding: 9px 8px;
  text-align: center;
  cursor: pointer;
  z-index: 2;
}
tbody td {
  padding: 8px 8px;
  text-align: center;
  border-bottom: 1px solid rgba(48, 71, 102, 0.45);
}
tbody tr { cursor: pointer; }
tbody tr:hover { background: rgba(56, 189, 248, 0.08); }
tbody tr.selected { background: #244b73; }
tr.tag-buy { color: var(--green); }
tr.tag-wait { color: var(--gold); }
tr.tag-sell { color: var(--red); }
tr.tag-err { color: var(--muted); }

.mentor-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mentor-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.mentor-title { color: var(--gold); font-weight: 800; font-size: 1.05rem; }

.badges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 8px;
}
.badge-card {
  padding: 10px 12px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.88rem;
  line-height: 1.4;
}
.badge-buy { background: #113626; color: var(--green); border: 1px solid #1e5b3f; }
.badge-stop { background: #3b1721; color: var(--red); border: 1px solid #6b2638; }
.badge-plan { background: var(--card); color: var(--gold); border: 1px solid var(--line); }

.coach-text {
  background: var(--bg);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.92rem;
  line-height: 1.55;
  border: 1px solid rgba(48, 71, 102, 0.6);
}

.checks-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.83rem;
  color: var(--muted);
  padding: 4px 2px;
}
.chk-ok { color: var(--green); font-weight: 600; }
.chk-no { color: var(--red); }

.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--line);
}
.tab-btn {
  background: transparent;
  color: var(--muted);
  border-radius: 8px 8px 0 0;
  padding: 9px 14px;
}
.tab-btn.active {
  background: var(--line);
  color: var(--fg);
}
.tab-pane { display: none; }
.tab-pane.active { display: block; }

.chart-container {
  position: relative;
  width: 100%;
  height: 360px;
  background: var(--bg);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
}
canvas#chartCanvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.status-bar {
  font-size: 0.84rem;
  color: var(--muted);
  padding: 8px 12px;
  background: var(--panel);
  border-radius: 8px;
  border: 1px solid var(--line);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 10, 20, 0.78);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 14px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  width: 100%;
  max-width: 720px;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  font-weight: 800;
  color: var(--gold);
}
.modal-body {
  padding: 14px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.picker-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 6px;
  max-height: 46vh;
  overflow-y: auto;
}
.picker-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: var(--bg);
  border-radius: 6px;
  font-size: 0.84rem;
  cursor: pointer;
}

@media (max-width: 700px) {
  .brand { font-size: 1.05rem; }
  .chart-container { height: 280px; }
  button { padding: 7px 10px; font-size: 0.82rem; }
}

.auth-gate {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at top, #152238 0%, #0b1220 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
}
.auth-logo {
  text-align: center;
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--gold);
}
.auth-sub {
  text-align: center;
  font-size: 0.84rem;
  color: var(--cyan);
  margin-bottom: 4px;
}
.auth-card label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.86rem;
  color: var(--muted);
}
.auth-err {
  min-height: 18px;
  font-size: 0.83rem;
  color: var(--red);
  text-align: center;
  font-weight: 600;
}
.auth-foot {
  text-align: center;
  font-size: 0.78rem;
  color: var(--muted);
}
