:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #182033;
  --muted: #6b7280;
  --border: #e6e8ef;
  --green: #15975b;
  --red: #d84b4b;
  --purple: #7257d6;
  --green-soft: #edf9f2;
  --red-soft: #fff0f0;
  --purple-soft: #f3f0ff;
  --shadow: 0 18px 45px rgba(27, 39, 71, .07);
}
* { box-sizing: border-box; }
body { margin: 0; background: #f5f7fb; color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
a { color: var(--purple); text-decoration: none; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 26px; min-height: 74px; padding: 0 38px; background: rgba(255,255,255,.86); border-bottom: 1px solid rgba(230,232,239,.8); backdrop-filter: blur(16px); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 800; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; background: var(--purple); color: white; font-size: 13px; }
.nav { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.nav a { padding: 10px 12px; border-radius: 8px; color: #4b5563; font-size: 14px; font-weight: 650; }
.nav a:hover { background: var(--purple-soft); color: var(--purple); }
.userbar { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; }
.page { width: min(1480px, 94vw); margin: 36px auto 70px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: 38px; line-height: 1.05; letter-spacing: 0; }
h2 { font-size: 18px; margin-bottom: 18px; }
h3 { margin: 20px 0 10px; color: #4b5563; font-size: 13px; text-transform: uppercase; }
p { color: var(--muted); line-height: 1.55; }
.page-head, .section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.button, button { border: 0; border-radius: 8px; padding: 11px 15px; font-weight: 750; cursor: pointer; font: inherit; }
.button.primary { background: #7357d8; color: white; box-shadow: 0 14px 30px rgba(114,87,214,.22); }
.button.ghost { background: #f3f4f8; color: #374151; }
.link-button { background: transparent; color: var(--purple); padding: 0; }
.panel, .auth-card, .stat, .admin-tile { background: rgba(255,255,255,.92); border: 1px solid rgba(222,226,237,.9); border-radius: 12px; box-shadow: var(--shadow); }
.panel { padding: 24px; margin-bottom: 24px; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; }
.stats-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat { padding: 18px; }
.stat span, .score-box span, .streak span { display: block; color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.stat strong { font-size: 23px; }
.positive { color: var(--green); }
.negative { color: var(--red); }
.calendar-panel { padding: 20px; }
.calendar-controls { display: flex; gap: 8px; }
select, input, textarea { width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 11px 12px; background: white; color: var(--text); font: inherit; }
textarea { min-height: 96px; resize: vertical; }
label { display: grid; gap: 7px; color: #4b5563; font-size: 14px; font-weight: 650; }
.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.cal-weekday { color: var(--muted); font-size: 12px; font-weight: 800; padding: 0 4px 6px; text-align: right; }
.cal-cell { min-height: 118px; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left; padding: 12px; border: 1px solid var(--border); background: #fff; color: var(--text); border-radius: 8px; }
.cal-cell b { align-self: flex-end; }
.cal-cell span { font-weight: 800; }
.cal-cell small { color: var(--muted); }
.cal-cell em { margin-top: auto; font-style: normal; color: var(--purple); font-weight: 800; }
.cal-cell.gain { background: var(--green-soft); }
.cal-cell.loss { background: var(--red-soft); }
.cal-cell.neutral { background: var(--purple-soft); }
.cal-cell.muted { background: transparent; box-shadow: none; }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 22px; align-items: start; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.score-box { position: sticky; top: 90px; }
.score-box strong { display: block; font-size: 30px; }
.score-box b { display: block; margin: 10px 0; font-size: 42px; color: var(--purple); }
.checklist { display: grid; gap: 10px; }
.check-row { grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; min-height: 48px; padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.check-row em { color: var(--muted); font-size: 12px; font-style: normal; }
.check-row.done { background: var(--green-soft); border-color: #b9e7cc; }
.read-only .check-row { display: flex; justify-content: space-between; }
.overview-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.overview-grid span { display: grid; gap: 5px; padding: 12px; border-radius: 8px; background: #f8f9fc; color: var(--muted); font-size: 13px; }
.overview-grid b { color: var(--text); font-size: 16px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 12px; border-bottom: 1px solid var(--border); text-align: left; font-size: 14px; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; }
tbody tr:hover { background: #fafbff; }
.table-wrap { overflow-x: auto; }
.sidebar .panel { margin-bottom: 18px; }
.streak strong { display: block; color: var(--purple); font-size: 58px; line-height: 1; }
.badges, .tag-list { display: flex; flex-wrap: wrap; gap: 9px; }
.badges span, .tag-list label { padding: 8px 10px; border-radius: 8px; background: var(--purple-soft); color: var(--purple); font-size: 13px; }
.auth-wrap { min-height: calc(100vh - 140px); display: grid; place-items: center; }
.auth-card { width: min(440px, 92vw); padding: 32px; display: grid; gap: 16px; }
.hint { color: var(--muted); font-size: 13px; }
.flash { padding: 13px 15px; border-radius: 8px; margin-bottom: 16px; border: 1px solid var(--border); }
.flash.success { background: var(--green-soft); color: var(--green); }
.flash.error { background: var(--red-soft); color: var(--red); }
.admin-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.admin-tile { padding: 22px; display: grid; gap: 8px; color: var(--text); }
.admin-tile span { color: var(--muted); }
.filters { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.inline { display: flex; align-items: center; gap: 8px; }
.inline input { width: auto; }
.bar { display: grid; gap: 6px; margin-bottom: 12px; }
.bar b { display: block; min-width: 30px; padding: 6px 8px; border-radius: 8px; background: var(--purple-soft); color: var(--purple); }
.modal[hidden] { display: none; }
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(18,24,38,.38); }
.modal-card { width: min(720px, 96vw); max-height: 86vh; overflow: auto; padding: 24px; border-radius: 8px; background: white; box-shadow: 0 30px 80px rgba(0,0,0,.18); position: relative; }
.modal-close { position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; padding: 0; background: #f3f4f8; }
.modal-trades { display: grid; gap: 10px; margin-top: 16px; }
.trade-mini { display: grid; gap: 4px; padding: 12px; border: 1px solid var(--border); border-radius: 8px; color: var(--text); }
.trade-mini span { color: var(--muted); }
.trade-mini em { color: var(--purple); font-style: normal; }

.eyebrow {
  display: inline-flex;
  margin-bottom: 12px;
  color: var(--purple);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.analytics-shell {
  display: grid;
  gap: 26px;
}
.analytics-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 30px;
  align-items: end;
  padding: 34px 36px;
  border: 1px solid rgba(224,228,238,.9);
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 24px 70px rgba(27,39,71,.07);
}
.analytics-hero p {
  max-width: 640px;
  margin-bottom: 0;
  font-size: 18px;
}
.hero-score {
  padding: 22px;
  border-left: 1px solid var(--border);
}
.hero-score span,
.metric-strip span,
.strategy-name span,
.strategy-values span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.hero-score strong {
  display: block;
  margin: 7px 0;
  color: var(--purple);
  font-size: 48px;
  line-height: 1;
}
.hero-score em {
  color: var(--green);
  font-style: normal;
  font-weight: 750;
}
.metric-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border: 1px solid rgba(224,228,238,.9);
  border-radius: 14px;
  background: rgba(255,255,255,.82);
  overflow: hidden;
}
.metric-strip div {
  padding: 20px 24px;
  border-right: 1px solid var(--border);
}
.metric-strip div:last-child {
  border-right: 0;
}
.metric-strip strong {
  display: block;
  margin-top: 9px;
  font-size: 28px;
  line-height: 1;
}
.analytics-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 26px;
  align-items: start;
}
.analysis-board,
.mistake-board {
  padding: 30px 32px;
  border: 1px solid rgba(224,228,238,.9);
  border-radius: 16px;
  background: rgba(255,255,255,.9);
  box-shadow: 0 22px 60px rgba(27,39,71,.06);
}
.analysis-board .section-head,
.mistake-board .section-head {
  margin-bottom: 22px;
}
.analysis-board .section-head p,
.mistake-board .section-head p {
  margin-bottom: 0;
}
.strategy-list {
  display: grid;
  gap: 10px;
}
.strategy-row {
  display: grid;
  grid-template-columns: 230px minmax(160px, 1fr) 170px;
  gap: 22px;
  align-items: center;
  min-height: 76px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.strategy-row:last-child {
  border-bottom: 0;
}
.strategy-name {
  display: grid;
  gap: 6px;
}
.strategy-name strong {
  font-size: 17px;
}
.strategy-meter {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf0f6;
}
.strategy-meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #7357d8;
}
.strategy-values {
  display: grid;
  grid-template-columns: 1fr;
  justify-items: end;
  gap: 7px;
}
.strategy-values strong {
  font-size: 18px;
}
.mistake-list {
  display: grid;
  gap: 18px;
}
.mistake-pill {
  display: grid;
  gap: 9px;
}
.mistake-pill > span {
  font-size: 17px;
  font-weight: 750;
}
.mistake-pill div {
  position: relative;
  height: 34px;
  overflow: hidden;
  border-radius: 8px;
  background: #f1eefc;
}
.mistake-pill b {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #dcd4fb;
}
.mistake-pill em {
  position: absolute;
  left: 12px;
  top: 6px;
  color: var(--purple);
  font-style: normal;
  font-weight: 900;
}
@media (max-width: 1100px) {
  .dashboard-grid, .two-col { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .score-box { position: static; }
  .sidebar { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
  .analytics-hero,
  .analytics-grid { grid-template-columns: 1fr; }
  .hero-score { border-left: 0; border-top: 1px solid var(--border); padding-left: 0; }
  .metric-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .metric-strip div:nth-child(3) { border-right: 0; }
  .strategy-row { grid-template-columns: 190px minmax(120px, 1fr) 140px; }
}
@media (max-width: 760px) {
  .topbar { align-items: flex-start; flex-direction: column; padding: 14px; gap: 10px; }
  .page { width: min(100% - 24px, 1440px); margin-top: 18px; }
  .page-head, .section-head { align-items: stretch; flex-direction: column; }
  .stats-grid, .form-grid, .overview-grid, .admin-grid, .filters, .sidebar { grid-template-columns: 1fr; }
  .calendar { gap: 4px; }
  .cal-cell { min-height: 86px; padding: 8px; font-size: 12px; }
  .cal-weekday { text-align: center; }
  .nav { width: 100%; }
  .analytics-hero,
  .analysis-board,
  .mistake-board { padding: 22px; border-radius: 12px; }
  .metric-strip { grid-template-columns: 1fr; }
  .metric-strip div { border-right: 0; border-bottom: 1px solid var(--border); }
  .metric-strip div:last-child { border-bottom: 0; }
  .strategy-row { grid-template-columns: 1fr; gap: 10px; }
  .strategy-values { justify-items: start; }
}

/* Dashboard: cleaner workspace, fewer visible boxes. */
.dashboard-grid .content-main {
  padding: 30px;
  border: 1px solid rgba(230, 232, 239, .9);
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 22px 55px rgba(27, 39, 71, .06);
}
.dashboard-grid .page-head {
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
}
.dashboard-grid .stats-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0;
  padding: 2px 0 24px;
  border-bottom: 1px solid var(--border);
}
.dashboard-grid .stat {
  padding: 10px 18px;
  border: 0;
  border-right: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.dashboard-grid .stat:first-child {
  padding-left: 0;
}
.dashboard-grid .stat:last-child {
  border-right: 0;
}
.dashboard-grid .stat span {
  margin-bottom: 6px;
  font-size: 12px;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.dashboard-grid .stat strong {
  font-size: 24px;
}
.dashboard-grid .calendar-panel,
.dashboard-grid .content-main > .panel {
  padding: 26px 0 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.dashboard-grid .calendar-panel {
  margin-bottom: 28px;
}
.dashboard-grid .section-head {
  margin-bottom: 18px;
}
.dashboard-grid .calendar {
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}
.dashboard-grid .cal-weekday {
  padding: 12px 12px;
  border-bottom: 1px solid var(--border);
  background: #fafbfe;
  text-align: left;
}
.dashboard-grid .cal-cell {
  min-height: 124px;
  border: 0;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  box-shadow: none;
}
.dashboard-grid .cal-cell:nth-child(7n) {
  border-right: 0;
}
.dashboard-grid .cal-cell:hover {
  background: #fafbff;
}
.dashboard-grid .cal-cell.gain { background: #e9f8ef; }
.dashboard-grid .cal-cell.loss { background: #fff0f0; }
.dashboard-grid .cal-cell.neutral { background: #f0ecff; }
.dashboard-grid .cal-cell.muted {
  background: #fbfcff;
}
.dashboard-grid .sidebar {
  display: grid;
  gap: 18px;
  align-content: start;
}
.dashboard-grid .sidebar .panel {
  margin: 0;
  border: 0;
  border-left: 3px solid var(--border);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.dashboard-grid .sidebar .streak {
  border-left-color: var(--purple);
  background: #f3f0ff;
}
.dashboard-grid .badges span {
  background: #fff;
  border: 1px solid #e7e0ff;
}
.dashboard-grid table th,
.dashboard-grid table td {
  padding-left: 0;
}
@media (max-width: 1100px) {
  .dashboard-grid .stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: 14px; }
  .dashboard-grid .stat:nth-child(3n) { border-right: 0; }
  .dashboard-grid .sidebar { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 760px) {
  .dashboard-grid .content-main { padding: 20px; border-radius: 12px; }
  .dashboard-grid .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid .stat:nth-child(3n) { border-right: 1px solid var(--border); }
  .dashboard-grid .stat:nth-child(2n) { border-right: 0; }
  .dashboard-grid .calendar { border-radius: 10px; }
  .dashboard-grid .cal-weekday { padding: 9px 7px; font-size: 11px; }
  .dashboard-grid .cal-cell { min-height: 82px; }
  .dashboard-grid .sidebar { grid-template-columns: 1fr; }
}
