/* TRADSAVI - layout + theme layer (loads AFTER style.css) */

/* ---------- Light theme ---------- */
[data-theme="light"] {
  --bg: #f3f5fb; --bg-soft: #eef1f8;
  --panel: #ffffff; --panel-2: #f1f4fa; --panel-hover: #e8ecf6;
  --border: #dde3ef; --border-light: #c9d2e4;
  --text: #0f172a; --text-soft: #334155; --text-muted: #64748b;
  --shadow: 0 20px 50px rgba(30, 41, 80, 0.12);
}
[data-theme="light"] body { background: var(--bg); }
[data-theme="light"] .auth-screen { background: var(--bg); }
[data-theme="light"] .auth-card { background: #fff; }
[data-theme="light"] .topbar { background: rgba(255,255,255,.88); background-image: none; border-bottom: 1px solid var(--border); }
[data-theme="light"] .field input:focus,
[data-theme="light"] .field select:focus,
[data-theme="light"] .field textarea:focus { background: #fff; }
[data-theme="light"] .card { box-shadow: 0 6px 22px rgba(30,41,80,.06); }
[data-theme="light"] .calendar-day.day-win .calendar-number,
[data-theme="light"] .calendar-day.day-win .calendar-trades { color: #15803d; }
[data-theme="light"] .calendar-day.day-loss .calendar-number,
[data-theme="light"] .calendar-day.day-loss .calendar-trades { color: #b91c1c; }
[data-theme="light"] .btn.secondary { background: #fff; }
[data-theme="light"] .field input[readonly] { background: var(--panel-2); }

/* ---------- Shell: left sidebar ---------- */
.app { padding-left: 248px; padding-bottom: 30px; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 248px; z-index: 60;
  display: flex; flex-direction: column; gap: 6px;
  padding: 18px 14px; overflow-y: auto;
  background: var(--panel); border-right: 1px solid var(--border);
}
.side-brand { padding: 2px 2px 16px; }
.side-brand img, .logo-wide {
  display: block; width: 100%; max-height: 64px; object-fit: contain; border-radius: 10px;
}
.logo-wide { max-height: 70px; }
.auth-brand { display: block; }

.sidebar .tabs {
  display: flex; flex-direction: column; width: auto; margin: 0; padding: 0; gap: 4px;
  background: none; border: 0; overflow: visible;
}
.sidebar .tab {
  flex: none; min-width: 0; display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; font-size: 14px; text-align: left;
}
.sidebar .tab i { font-style: normal; width: 18px; text-align: center; font-size: 15px; }

.side-quick-label {
  margin: 18px 6px 4px; font-size: 11px; font-weight: 700;
  letter-spacing: .08em; color: var(--text-muted);
}
.side-quick { display: flex; flex-direction: column; gap: 8px; }
.side-quick .btn { width: 100%; justify-content: flex-start; min-height: 40px; cursor: pointer; }
.side-foot { margin-top: auto; padding: 18px 6px 0; font-size: 12px; line-height: 1.6; color: var(--text-muted); }

/* ---------- Top bar ---------- */
.topbar { padding: 12px 28px; gap: 16px; }
.top-search {
  flex: 1; max-width: 440px; height: 42px; padding: 0 14px;
  color: var(--text); background: var(--bg-soft);
  border: 1px solid var(--border); border-radius: 10px; outline: none;
}
.top-search:focus { border-color: var(--primary); }
.top-right { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.icon-btn {
  display: none; width: 40px; height: 40px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
}
.user-chip { display: flex; align-items: center; gap: 10px; padding-left: 12px; border-left: 1px solid var(--border); }
.user-chip strong { display: block; font-size: 13px; line-height: 1.2; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip span { font-size: 11px; color: var(--text-muted); }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; font-weight: 800;
}

.tab-panel, .footer { width: auto; max-width: none; margin-left: 28px; margin-right: 28px; }
.tab-panel { margin-top: 24px; }

/* ---------- Dashboard ---------- */
.stat-sub { margin-top: 7px; font-size: 11px; color: var(--text-muted); }
.stat-sub.positive { color: var(--green); }
.link-btn { border: 0; background: none; padding: 0; color: var(--primary-light); font-size: 11px; font-weight: 700; }
.dash-main { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 20px; margin-bottom: 20px; }
.dash-side { display: flex; flex-direction: column; gap: 20px; }
.equity-chart svg { width: 100%; height: auto; display: block; }
.equity-chart .grid { stroke: var(--border); stroke-dasharray: 3 5; }
.equity-chart .axis { fill: var(--text-muted); font-size: 11px; font-weight: 600; }
.best { display: flex; justify-content: space-between; gap: 12px; }
.best span { display: block; font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.best strong { font-size: 16px; }
.best .accent { color: var(--primary-light); }
.table-wrap { overflow-x: auto; }
.table-wrap .breakdown-table td, .table-wrap .breakdown-table th { padding: 11px 12px; }

/* ---------- Responsive ---------- */
@media (max-width: 1150px) { .dash-main { grid-template-columns: 1fr; } }

@media (max-width: 900px) {
  .app { padding-left: 0; }
  .sidebar { transform: translateX(-100%); transition: transform .25s ease; }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow); }
  body.nav-open::after { content: ""; position: fixed; inset: 0; z-index: 55; background: rgba(0,0,0,.45); }
  .icon-btn { display: block; }
  .topbar { padding: 12px 16px; flex-direction: row; align-items: center; }
  .top-search { display: none; }
  .tab-panel, .footer { margin-left: 16px; margin-right: 16px; }
  .user-chip div:last-child { display: none; }
  .user-chip { border-left: 0; padding-left: 0; }
}

/* ---------- Tradsavi logo (image) ---------- */
.side-brand img, .logo-wide img { display: block; width: 100%; height: auto; max-height: none; border-radius: 14px; background: #070707; }
.logo-wide { max-width: 300px; max-height: none; margin: 0 auto 10px; }
.top-mark { display: none; width: 36px; height: 36px; border-radius: 9px; }
@media (max-width: 900px) { .top-mark { display: block; } }

/* Transparent logo: dark-theme and light-theme versions, no background tile */
.side-brand img, .logo-wide img { display: block; width: 100%; height: auto; max-height: none; border-radius: 0; background: none; }
.logo-light { display: none !important; }
[data-theme="light"] .logo-dark { display: none !important; }
[data-theme="light"] .logo-light { display: block !important; }
.side-brand { padding: 8px 6px 20px; }

/* Dashboard date range + smaller search */
.topbar { flex-wrap: wrap; row-gap: 10px; }
.top-search { flex: 0 1 180px; max-width: 180px; }
.date-range { display: flex; align-items: center; gap: 8px; }
.date-range label { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; color: var(--text-muted); }
.date-range input { height: 42px; padding: 0 8px; font-size: 12px; color: var(--text); background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px; color-scheme: dark; }
[data-theme="light"] .date-range input { color-scheme: light; }
@media (max-width: 900px) { .date-range { order: 5; flex-basis: 100%; flex-wrap: wrap; } }

/* Analytics + Settings */
.verdict { padding: 18px 20px; border-radius: 12px; border: 1px solid var(--border); background: var(--panel); margin-bottom: 20px; }
.verdict h3 { font-size: 17px; margin-bottom: 6px; }
.verdict p { color: var(--text-soft); font-size: 13px; }
.verdict.ok { background: rgba(34,197,94,.10); border-color: rgba(34,197,94,.4); }
.verdict.bad { background: rgba(239,68,68,.10); border-color: rgba(239,68,68,.4); }
.verdict .rules { list-style: none; margin-top: 12px; display: grid; gap: 6px; font-size: 13px; color: var(--text-soft); }
.verdict .rules em { color: var(--text-muted); font-style: normal; }
.bar { height: 10px; border-radius: 99px; background: var(--bg-soft); overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--green)); }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.day-checks { display: flex; flex-wrap: wrap; gap: 8px; }
.day-checks label { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 9px; font-size: 12px; color: var(--text-soft); cursor: pointer; }
.day-checks input { width: auto; height: auto; }
.danger-card { border-color: rgba(239,68,68,.45); }
@media (max-width: 900px) { .settings-grid { grid-template-columns: 1fr; } }

/* ---------- Calendar: make today's date number readable in light mode ---------- */
[data-theme="light"] .calendar-day.today:not(.day-win):not(.day-loss) .calendar-number,
[data-theme="light"] .calendar-day.is-today:not(.day-win):not(.day-loss) .calendar-number,
[data-theme="light"] .calendar-day.current:not(.day-win):not(.day-loss) .calendar-number,
[data-theme="light"] .calendar-day.current-day:not(.day-win):not(.day-loss) .calendar-number {
  color: #0f172a;
  font-weight: 800;
}

/* ---------- Shell: left sidebar ---------- */
.app { padding-left: 248px; padding-bottom: 30px; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 248px; z-index: 60;
  display: flex; flex-direction: column; gap: 6px;
  padding: 18px 14px; overflow-y: auto;
  background: var(--panel); border-right: 1px solid var(--border);
}
.side-brand { padding: 2px 2px 16px; }
.side-brand img, .logo-wide {
  display: block; width: 100%; max-height: 64px; object-fit: contain; border-radius: 10px;
}
.logo-wide { max-height: 70px; }
.auth-brand { display: block; }

.sidebar .tabs {
  display: flex; flex-direction: column; width: auto; margin: 0; padding: 0; gap: 4px;
  background: none; border: 0; overflow: visible;
}
.sidebar .tab {
  flex: none; min-width: 0; display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; font-size: 14px; text-align: left;
}
.sidebar .tab i { font-style: normal; width: 18px; text-align: center; font-size: 15px; }

.side-quick-label {
  margin: 18px 6px 4px; font-size: 11px; font-weight: 700;
  letter-spacing: .08em; color: var(--text-muted);
}
.side-quick { display: flex; flex-direction: column; gap: 8px; }
.side-quick .btn { width: 100%; justify-content: flex-start; min-height: 40px; cursor: pointer; }
.side-foot { margin-top: auto; padding: 18px 6px 0; font-size: 12px; line-height: 1.6; color: var(--text-muted); }

/* ---------- Top bar ---------- */
.topbar { padding: 12px 28px; gap: 16px; }
.top-search {
  flex: 1; max-width: 440px; height: 42px; padding: 0 14px;
  color: var(--text); background: var(--bg-soft);
  border: 1px solid var(--border); border-radius: 10px; outline: none;
}
.top-search:focus { border-color: var(--primary); }
.top-right { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.icon-btn {
  display: none; width: 40px; height: 40px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
}
.user-chip { display: flex; align-items: center; gap: 10px; padding-left: 12px; border-left: 1px solid var(--border); }
.user-chip strong { display: block; font-size: 13px; line-height: 1.2; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip span { font-size: 11px; color: var(--text-muted); }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; font-weight: 800;
}

.tab-panel, .footer { width: auto; max-width: none; margin-left: 28px; margin-right: 28px; }
.tab-panel { margin-top: 24px; }

/* ---------- Dashboard ---------- */
.stat-sub { margin-top: 7px; font-size: 11px; color: var(--text-muted); }
.stat-sub.positive { color: var(--green); }
.link-btn { border: 0; background: none; padding: 0; color: var(--primary-light); font-size: 11px; font-weight: 700; }
.dash-main { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 20px; margin-bottom: 20px; }
.dash-side { display: flex; flex-direction: column; gap: 20px; }
.equity-chart svg { width: 100%; height: auto; display: block; }
.equity-chart .grid { stroke: var(--border); stroke-dasharray: 3 5; }
.equity-chart .axis { fill: var(--text-muted); font-size: 11px; font-weight: 600; }
.best { display: flex; justify-content: space-between; gap: 12px; }
.best span { display: block; font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.best strong { font-size: 16px; }
.best .accent { color: var(--primary-light); }
.table-wrap { overflow-x: auto; }
.table-wrap .breakdown-table td, .table-wrap .breakdown-table th { padding: 11px 12px; }

/* ---------- Responsive ---------- */
@media (max-width: 1150px) { .dash-main { grid-template-columns: 1fr; } }

@media (max-width: 900px) {
  .app { padding-left: 0; }
  .sidebar { transform: translateX(-100%); transition: transform .25s ease; }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow); }
  body.nav-open::after { content: ""; position: fixed; inset: 0; z-index: 55; background: rgba(0,0,0,.45); }
  .icon-btn { display: block; }
  .topbar { padding: 12px 16px; flex-direction: row; align-items: center; }
  .top-search { display: none; }
  .tab-panel, .footer { margin-left: 16px; margin-right: 16px; }
  .user-chip div:last-child { display: none; }
  .user-chip { border-left: 0; padding-left: 0; }
}

/* ---------- Tradsavi logo (image) ---------- */
.side-brand img, .logo-wide img { display: block; width: 100%; height: auto; max-height: none; border-radius: 14px; background: #070707; }
.logo-wide { max-width: 300px; max-height: none; margin: 0 auto 10px; }
.top-mark { display: none; width: 36px; height: 36px; border-radius: 9px; }
@media (max-width: 900px) { .top-mark { display: block; } }

/* Transparent logo: dark-theme and light-theme versions, no background tile */
.side-brand img, .logo-wide img { display: block; width: 100%; height: auto; max-height: none; border-radius: 0; background: none; }
.logo-light { display: none !important; }
[data-theme="light"] .logo-dark { display: none !important; }
[data-theme="light"] .logo-light { display: block !important; }
.side-brand { padding: 8px 6px 20px; }

/* Dashboard date range + smaller search */
.topbar { flex-wrap: wrap; row-gap: 10px; }
.top-search { flex: 0 1 180px; max-width: 180px; }
.date-range { display: flex; align-items: center; gap: 8px; }
.date-range label { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; color: var(--text-muted); }
.date-range input { height: 42px; padding: 0 8px; font-size: 12px; color: var(--text); background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px; color-scheme: dark; }
[data-theme="light"] .date-range input { color-scheme: light; }
@media (max-width: 900px) { .date-range { order: 5; flex-basis: 100%; flex-wrap: wrap; } }

/* Analytics + Settings */
.verdict { padding: 18px 20px; border-radius: 12px; border: 1px solid var(--border); background: var(--panel); margin-bottom: 20px; }
.verdict h3 { font-size: 17px; margin-bottom: 6px; }
.verdict p { color: var(--text-soft); font-size: 13px; }
.verdict.ok { background: rgba(34,197,94,.10); border-color: rgba(34,197,94,.4); }
.verdict.bad { background: rgba(239,68,68,.10); border-color: rgba(239,68,68,.4); }
.verdict .rules { list-style: none; margin-top: 12px; display: grid; gap: 6px; font-size: 13px; color: var(--text-soft); }
.verdict .rules em { color: var(--text-muted); font-style: normal; }
.bar { height: 10px; border-radius: 99px; background: var(--bg-soft); overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--green)); }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.day-checks { display: flex; flex-wrap: wrap; gap: 8px; }
.day-checks label { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 9px; font-size: 12px; color: var(--text-soft); cursor: pointer; }
.day-checks input { width: auto; height: auto; }
.danger-card { border-color: rgba(239,68,68,.45); }
@media (max-width: 900px) { .settings-grid { grid-template-columns: 1fr; } }