:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #1c2430;
  --border: #2a3441;
  --text: #e6edf3;
  --muted: #8b97a6;
  --accent: #f5a623;
  --green: #3fb950;
  --red: #f85149;
  --blue: #58a6ff;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }

button {
  cursor: pointer;
  font: inherit;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  background: var(--panel-2);
  color: var(--text);
  transition: filter 0.15s, background 0.15s;
}
button:hover { filter: brightness(1.15); }
button.primary { background: var(--accent); color: #1a1206; font-weight: 600; }
button.ghost { background: transparent; border: 1px solid var(--border); }

input, select, textarea {
  font: inherit;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); }

.error { color: var(--red); font-size: 0.85rem; min-height: 1.1em; }

/* ---- Login ---- */
.login-screen {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
  background: radial-gradient(circle at 50% 0%, #1a2230, var(--bg));
}
.login-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 16px; padding: 40px; width: 100%; max-width: 380px;
  text-align: center;
}
.logo {
  font-size: 2rem; letter-spacing: 1px; font-weight: 800;
  color: var(--accent); margin-bottom: 4px; line-height: 1.1;
}
.tagline { color: var(--muted); margin-bottom: 24px; }
.login-card form { display: flex; gap: 10px; margin-bottom: 12px; }
.login-card .hint { color: var(--muted); font-size: 0.8rem; }

/* ---- Topbar ---- */
.topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 12px 24px; background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: 0.5px; color: var(--accent); font-size: 1.15rem; white-space: nowrap; }
.brand-logo { height: 36px; width: 36px; object-fit: contain; background: #fff; border-radius: 8px; padding: 3px; flex-shrink: 0; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tab { background: transparent; color: var(--muted); }
.tab.active { background: var(--panel-2); color: var(--text); }
.user-box { display: flex; align-items: center; gap: 10px; }
#current-user { color: var(--accent); font-weight: 600; }

.content { max-width: 1100px; margin: 0 auto; padding: 24px; }
.view-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px; flex-wrap: wrap; gap: 12px;
}
.filter { display: flex; align-items: center; gap: 8px; }
.filter label { color: var(--muted); font-size: 0.9rem; }
.filter select { width: auto; }

/* ---- Calendar ---- */
.cal-nav { display: flex; align-items: center; gap: 14px; }
.cal-nav h2 { min-width: 200px; text-align: center; }
.cal-nav button { padding: 4px 14px; font-size: 1.2rem; }
.weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 6px; margin-bottom: 6px;
}
.weekdays span { text-align: center; color: var(--muted); font-size: 0.8rem; font-weight: 600; }
.calendar-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px;
}
.cal-cell {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; min-height: 92px; padding: 6px;
  display: flex; flex-direction: column; gap: 4px;
  cursor: pointer; transition: border-color 0.15s;
}
.cal-cell:hover { border-color: var(--accent); }
.cal-cell.empty { background: transparent; border: none; cursor: default; }
.cal-cell.today { border-color: var(--blue); }
.cal-cell .day-num { font-size: 0.8rem; color: var(--muted); }
.cal-cell .day-pnl { font-weight: 700; font-size: 0.95rem; }
.cal-cell .day-count { font-size: 0.72rem; color: var(--muted); margin-top: auto; }
.pnl-pos { color: var(--green); }
.pnl-neg { color: var(--red); }
.day-dots { display: flex; flex-wrap: wrap; gap: 3px; }
.dot { width: 7px; height: 7px; border-radius: 50%; }

/* ---- Feed ---- */
.feed-list { display: flex; flex-direction: column; gap: 12px; }
.trade-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 16px; display: flex; gap: 14px;
  cursor: pointer;
}
.trade-card:hover { border-color: var(--accent); }
.trade-thumb {
  width: 84px; height: 84px; border-radius: 8px; object-fit: cover;
  background: var(--panel-2); flex-shrink: 0;
}
.trade-main { flex: 1; min-width: 0; }
.trade-row1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sym { font-weight: 700; font-size: 1.05rem; }
.badge {
  font-size: 0.72rem; padding: 2px 8px; border-radius: 20px;
  background: var(--panel-2); color: var(--muted);
}
.badge.long { color: var(--green); }
.badge.short { color: var(--red); }
.trade-meta { color: var(--muted); font-size: 0.82rem; margin-top: 2px; }
.trade-notes { color: var(--text); font-size: 0.88rem; margin-top: 6px; opacity: 0.85;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trade-pnl { font-weight: 800; font-size: 1.1rem; text-align: right; white-space: nowrap; }
.by { color: var(--blue); }

/* ---- Traders ---- */
.traders-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.trader-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 18px; text-align: center; cursor: pointer;
}
.trader-card:hover { border-color: var(--accent); }
.avatar {
  width: 56px; height: 56px; border-radius: 50%; margin: 0 auto 10px;
  background: var(--accent); color: #1a1206; font-weight: 800; font-size: 1.4rem;
  display: flex; align-items: center; justify-content: center;
}
.trader-card .name { font-weight: 600; }
.trader-card .stats { color: var(--muted); font-size: 0.82rem; margin-top: 6px; }

/* ---- Modal ---- */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 100;
}
.modal-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 16px; padding: 26px; width: 100%; max-width: 460px;
  max-height: 90vh; overflow-y: auto;
}
.modal-card h3 { margin-bottom: 16px; }
#trade-form { display: flex; flex-direction: column; gap: 12px; }
#trade-form label { display: flex; flex-direction: column; gap: 5px; font-size: 0.85rem; color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

.detail-img { width: 100%; border-radius: 10px; margin: 12px 0; cursor: zoom-in; }
.detail-grid { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 0.9rem; }
.detail-grid .k { color: var(--muted); }
.empty-msg { color: var(--muted); text-align: center; padding: 40px; }

@media (max-width: 640px) {
  .cal-cell { min-height: 64px; }
  .topbar { gap: 10px; }
  .trade-thumb { width: 60px; height: 60px; }
}

/* ---- Screenshot drop / paste zone ---- */
.ss-drop {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 96px;
  margin-top: 4px;
  padding: 12px;
  text-align: center;
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.ss-drop:hover, .ss-drop:focus { border-color: var(--accent); outline: none; }
.ss-hint { color: var(--muted); font-size: 0.85rem; }
.ss-preview { max-width: 100%; max-height: 220px; border-radius: 6px; display: block; }
.ss-clear {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  padding: 0;
  line-height: 1;
  font-size: 1.1rem;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
}
.ss-clear:hover { background: var(--red); }

/* ---- Admin ---- */
.admin-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 1px;
  border-radius: 4px;
  background: var(--accent);
  color: #1a1206;
  vertical-align: middle;
}
.trader-card { position: relative; }
.trader-del {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  padding: 0;
  line-height: 1;
  font-size: 1rem;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
}
.trader-del:hover { background: var(--red); color: #fff; border-color: var(--red); }

/* ---- Trades stats bar ---- */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.stats-bar:empty { display: none; }
.stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.stat-label { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-val { font-size: 1.15rem; font-weight: 700; }

/* ---- Brief (embedded site) ---- */
.brief-wrap { display: flex; flex-direction: column; }
#brief-frame {
  width: 100%;
  height: calc(100vh - 150px);
  min-height: 480px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}
.brief-fallback { color: var(--muted); font-size: 0.85rem; margin-top: 8px; }
.brief-fallback a { color: var(--blue); }

/* ---- Account growth chart ---- */
.growth-wrap { margin-top: 24px; }
.growth-title { margin-bottom: 12px; color: var(--text); }
.growth-canvas-box {
  position: relative;
  height: 300px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}

/* ---- Account tab ---- */
.account-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.account-card label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 0.9rem; }
.account-card button { align-self: flex-start; }

/* ---- Trade form rows (Open/Close/Lots/SL/TP) ---- */
.form-row { display: flex; gap: 10px; }
.form-row label { flex: 1; }

/* ---- Screenshot lightbox ---- */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 200;
}
.lightbox img {
  max-width: 95vw;
  max-height: 95vh;
  object-fit: contain;
  border-radius: 8px;
  cursor: zoom-in;
  transition: transform 0.08s ease-out;
}
.lightbox img.zoomed { cursor: zoom-out; }

/* ---- App footer ---- */
.app-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 24px 16px 32px;
  border-top: 1px solid var(--border);
  margin-top: 24px;
}
