﻿:root {
  color-scheme: light;
  --bg: #f2f4fa;
  --surface: #fff;
  --border: #e0e5ef;
  --ink: #17223d;
  --muted: #53617a;
  --accent: #4555d5;
  --accent-deep: #3644ba;
  --loss: #a82449;
  --shadow: 0 1px 2px #18284a08, 0 8px 24px #27386808;
  --chart-axis: #a4afc2;
  --chart-loss: #e36c75;
  --chart-gain: #4a5cdb;
  --chart-overlay: #986100;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101424;
  --surface: #191f34;
  --border: #303a54;
  --ink: #f0f2ff;
  --muted: #b7c2dc;
  --accent: #5867e5;
  --accent-deep: #4e5cd9;
  --shadow: 0 2px 5px #0002, 0 8px 24px #0002;
  --chart-axis: #657293;
  --chart-loss: #f4919d;
  --chart-gain: #919bff;
  --chart-overlay: #ffca76;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
.screen-private [data-panel], .screen-private #account-picker, .screen-private #status,
.screen-private #sync, .screen-private .workspace-nav, .screen-private #dashboard-error { display:none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font: .95rem/1.5 "Segoe UI", system-ui, sans-serif; }
h1, h2 { margin: 0; line-height: 1.2; letter-spacing: -.025em; }
h2 { font-size: 1.1rem; }
p { margin: .65rem 0; }
.muted, #status { color: var(--muted); font-size: .86rem; }
.wrap { width: min(72rem, calc(100% - 2rem)); margin: auto; }

.workspace { display: grid; grid-template-columns: 15rem minmax(0, 1fr); min-height: 100dvh; }
.workspace-content { min-width: 0; }
.sidebar {
  position: sticky; top: 0; height: 100dvh; padding: 1.7rem 1rem;
  background: linear-gradient(165deg, #171b38, #101529 68%);
  border-right: 1px solid #242c50;
}
.brand {
  display: flex; gap: .7rem; align-items: center; margin: 0 .6rem 2.3rem;
  color: #fff; text-decoration: none; font-size: 1.36rem; font-weight: 750; letter-spacing: -.045em;
}
.brand-mark {
  width: 2rem; height: 2rem; flex: 0 0 auto; border-radius: .64rem;
  background: linear-gradient(145deg, #a69bff, #5968ef);
  box-shadow: 0 3px 14px #7772ff66; position: relative;
}
.brand-mark::after {
  content: ""; position: absolute; inset: .58rem .48rem .6rem;
  border-left: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(-38deg);
}
.workspace-nav { display: grid; gap: .35rem; }
.workspace-nav a {
  display: flex; gap: .65rem; align-items: center; padding: .67rem .75rem;
  color: #c1cae5; text-decoration: none; border: 1px solid transparent;
  border-radius: .62rem; font-weight: 600; white-space: nowrap;
}
.nav-icon { display: inline-grid; place-items: center; width: 1.4rem; color: #adb9fd; font-size: 1.15rem; line-height: 1; }
.workspace-nav a[aria-current] { color: #fff; background: #303968; border-color: #49548a; }
.workspace-nav a:hover:not([aria-current]) { color: #fff; background: #252c4b; }
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .7rem 1.2rem;
  padding: 1.2rem clamp(1rem, 3vw, 2.8rem); background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: clamp(1.65rem, 3vw, 2.15rem); letter-spacing: -.05em; }
.header-actions, .section-head, .account-picker, .history-pages { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem; }
.section-head { justify-content: space-between; margin-bottom: .8rem; }
.dashboard-content { width: min(100%, 92rem); padding: 1.55rem clamp(1rem, 3vw, 2.8rem) 3rem; margin: auto; }
.account-picker {
  width: fit-content; max-width: 100%; padding: .45rem .55rem .45rem .8rem; margin-bottom: 1.35rem;
  border: 1px solid var(--border); border-radius: .75rem; background: var(--surface); box-shadow: var(--shadow);
}
.account-picker select { max-width: 100%; background-color: #f1f3fd; border-color: transparent; font-weight: 650; }

.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .9rem; }
.metrics > div {
  min-width: 0; min-height: 7.55rem; padding: clamp(.8rem, 2vw, 1.3rem);
  border: 1px solid var(--border); border-radius: .95rem; background: var(--surface); box-shadow: var(--shadow);
}
.metrics span { display: block; color: var(--muted); font-size: .86rem; font-weight: 600; }
.metrics strong { display: block; margin-top: .3rem; font-size: clamp(1.3rem, 3vw, 2.35rem); line-height: 1.14; letter-spacing: -.05em; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.performance-metrics > div:first-child { color: #fff; border-color: #4b55ce; background: linear-gradient(125deg, #353fba, #5967ed); }
.performance-metrics > div:first-child span { color: #f1f2ff; }
[data-tone="loss"] { color: #ffe0e6; }
#win-rate-meter { display: block; width: 100%; height: .48rem; margin-top: .65rem; accent-color: var(--accent); border: 0; border-radius: 1rem; overflow: hidden; }
#win-rate-meter::-webkit-progress-bar { background: #e8edfb; }
#win-rate-meter::-webkit-progress-value { background: #5768e2; }
#win-rate-meter::-moz-progress-bar { background: #5768e2; }

.performance-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); align-items: start; gap: .95rem; margin-top: .95rem; }
.performance-grid.single-widget { grid-template-columns:minmax(0,1fr); }
.widget-picker { display:grid; gap:.3rem; padding:.6rem; border:1px solid var(--border); background:var(--surface); border-radius:.6rem; }
.widget-picker button { margin-top:.35rem; }
.chart-overlay-label::before { content:""; display:inline-block; width:.9rem; border-top:2px solid var(--chart-overlay); margin-right:.4rem; vertical-align:middle; }
.performance-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric-caption { display: block; margin-top: .45rem; color: #eef0ff; }
.performance-chart, .ai-review {
  min-width: 0; padding: clamp(.95rem, 2vw, 1.3rem); border: 1px solid var(--border);
  border-radius: .95rem; background: var(--surface); box-shadow: var(--shadow);
}
.ai-review { margin-top: .95rem; background: linear-gradient(145deg, #eeedff, #fff 70%); border-color: #d8dcf6; }
.ai-review h2 { color: #303d9a; }
.ai-review p:empty { display: none; }
.ai-review button { margin-top: .4rem; }
#ai-result { white-space: pre-wrap; overflow-wrap: anywhere; }
.chart { margin: .4rem 0 0; }
.dashboard-content .analytics { margin-top: 1rem; }
.analytics details, .ai-review details { margin-top: .7rem; }
.checkbox-label { display: flex; align-items: center; gap: .45rem; margin-top: .5rem; }
.checkbox-label input { min-height: auto; }
#ai-saved p { white-space: pre-wrap; overflow-wrap: anywhere; }
.calendar-grid { table-layout: fixed; min-width: 35rem; }
.calendar-grid th, .calendar-grid td { padding: .48rem .35rem; text-align: center; }
.calendar-grid th:last-child { width: 16%; }
.calendar-grid td { height: 4.25rem; vertical-align: top; border-right: 1px solid var(--border); }
.calendar-grid strong, .calendar-grid small { display: block; }
.calendar-grid .calendar-outside { background: var(--bg); opacity: .55; }
.calendar-grid .calendar-week { background: var(--bg); }
.calendar-grid small + small, #calendar-totals { color: var(--muted); }
.calendar-grid small + small { font-size: .72rem; }
.calendar-drill { width:100%; padding:0; border:0; background:transparent; color:inherit; font-weight:inherit; }
.calendar-drill:hover:not(:disabled) { background:transparent; text-decoration:underline; text-underline-offset:.17em; }
.weekday-section { margin:0 0 1rem; }
.weekday-section h3 { margin:0 0 .6rem; font-size:1rem; }
.weekday-section h3 span { margin-left:.35rem; font-weight:400; }
.weekday-highlights { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:.6rem; }
.weekday-highlights button { display:grid; text-align:left; gap:.22rem; align-content:start; padding:.65rem .8rem; }
.weekday-highlights strong { font-size:1.1rem; }
.calendar-grid [data-result="gain"] { color: #12674b; background: #e5f7ef; }
.calendar-grid [data-result="loss"] { color: #942547; background: #fce9ee; }
[data-theme="dark"] .calendar-grid [data-result="gain"] { color: #a1eed1; background: #1c3d36; }
[data-theme="dark"] .calendar-grid [data-result="loss"] { color: #ffc4d5; background: #46283c; }
.chart canvas { display: block; width: 100%; height: clamp(11rem, 25vh, 17rem); margin: .6rem 0; }
#performance-empty { padding: 1.25rem .75rem; border-radius: .6rem; background: #f4f6fc; }
#performance-method { margin-top: 1rem; }

.filters { display: flex; flex-wrap: wrap; align-items: end; gap: .65rem; margin-bottom: .9rem; }
label { display: grid; gap: .3rem; color: var(--muted); font-size: .86rem; font-weight: 600; }
input, select, textarea, button {
  font: inherit; padding: .52rem .7rem; border: 1px solid #cfd7e8; border-radius: .58rem;
}
input, select, textarea { color: var(--ink); background: var(--surface); min-width: 0; }
button, input, select { min-height: 2.65rem; }
button { background: var(--accent); border-color: var(--accent); color: #fff; cursor: pointer; font-weight: 650; }
button:hover:not(:disabled) { background: var(--accent-deep); }
button.secondary { background: var(--surface); border-color: #cfd7e8; color: var(--ink); }
button.secondary:hover:not(:disabled) { background: #edf0fc; border-color: #aebaea; }
button:disabled { opacity: .52; cursor: default; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 2px solid #6475f4; outline-offset: 2px; }
summary { cursor: pointer; font-weight: 600; }
.history-pages { margin-top: .8rem; }
.table {
  overflow: auto; margin: .45rem 0; background: var(--surface);
  border: 1px solid var(--border); border-radius: .75rem; box-shadow: var(--shadow);
}
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: .65rem .8rem; text-align: left; border-bottom: 1px solid #e8ecf5; white-space: nowrap; }
th { color: var(--muted); background: #f2f5fc; font-size: .83rem; font-weight: 700; }
tbody tr:nth-child(even) { background: #f8faff; }
tbody tr:hover { background: #eef2fd; }
tr:last-child td { border-bottom: 0; }
td.empty { white-space: normal; color: var(--muted); }
td button { min-height: 2.2rem; padding: .3rem .55rem; }

dialog {
  background: var(--surface); color: var(--ink); border: 1px solid var(--border);
  border-radius: 1rem; width: min(34rem, calc(100% - 1.6rem)); max-height: calc(100dvh - 1.6rem);
  padding: clamp(1rem, 3vw, 1.5rem); overflow: auto; box-shadow: 0 20px 65px #10152e45;
}
dialog::backdrop { background: #11193699; }
dialog h2 { font-size: 1.35rem; }
dialog label { margin-top: .8rem; }
textarea { width: 100%; resize: vertical; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .55rem; }
.trade-details { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .4rem .8rem; }
.trade-details dt { color: var(--muted); }
.trade-details dd { margin: 0; overflow-wrap: anywhere; }
.exit-level { display:grid; grid-template-columns:1fr 1fr auto; align-items:end; gap:.5rem; margin:.5rem 0; }
.exit-level input { width:100%; }
.exit-level strong { grid-column:1 / -1; }
.trade-tag-fields { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:.25rem .75rem; margin-bottom:.75rem; }
.trade-tag-fields select { width:100%; }
.tag-chips { display:flex; flex-wrap:wrap; gap:.35rem; margin-top:.35rem; }
.tag-chip { min-height:1.8rem; padding:.14rem .45rem; border-radius:1rem; font-size:.8rem; max-width:100%; overflow-wrap:anywhere; }
.record-attachments { margin:1rem 0; padding-top:.75rem; border-top:1px solid var(--border); }
.record-attachments input { width:100%; }
.record-attachments ul { padding-left:1.2rem; }
.record-attachments li { margin:.4rem 0; overflow-wrap:anywhere; }
.record-attachments li button { margin-left:.5rem; min-height:1.8rem; padding:.12rem .4rem; }
.record-attachments a { color:var(--ink); text-decoration:underline; text-underline-offset:.2em; }
.record-attachments img { display:block; max-width:100%; max-height:24rem; object-fit:contain; margin:.4rem 0; }
.trade-candles { display:block; width:100%; height:14rem; border:1px solid var(--border); border-radius:.45rem; }
#trade-market-chart .filters { margin-top:.65rem; }
#economic-form { margin-top:.8rem; }
.journal-layout { display:grid; grid-template-columns:minmax(12rem, .65fr) minmax(0, 2fr); gap:1rem; align-items:start; }
.journal-inputs { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:.65rem; margin-bottom:.75rem; }
.journal-list { display:grid; gap:.4rem; margin-top:.65rem; }
.journal-list button { text-align:left; overflow-wrap:anywhere; }
.journal-consistency { margin-top:1rem; }
.journal-heatmap { display:grid; grid-template-rows:repeat(7, 1rem); grid-auto-flow:column; grid-auto-columns:1rem; gap:.28rem; width:max-content; padding:.65rem; }
.journal-heatmap span { background:var(--bg); border:1px solid var(--border); border-radius:.2rem; }
.journal-heatmap span[data-level="1"] { background:var(--chart-gain); opacity:.6; }
.journal-heatmap span[data-level="2"] { background:var(--chart-gain); }
.cross-grid span { display:block; padding:.2rem .35rem; border-radius:.3rem; }
.cross-grid [data-result="gain"] { background:#e5f7ef; color:#12674b; }
.cross-grid [data-result="loss"] { background:#fce9ee; color:#942547; }
[data-theme="dark"] .cross-grid [data-result="gain"] { background:#1c3d36; color:#a1eed1; }
[data-theme="dark"] .cross-grid [data-result="loss"] { background:#46283c; color:#ffc4d5; }
@media (max-width:62rem) { .journal-layout { grid-template-columns:1fr; } }
@media (max-width:37rem) { .journal-inputs { grid-template-columns:1fr; } .workspace .workspace-nav { grid-template-columns:repeat(3,minmax(0,1fr)); } }
@media (max-width:32rem) { .trade-tag-fields { grid-template-columns:1fr; } }
#trade-form fieldset { min-width:0; border:1px solid var(--border); border-radius:.65rem; }
#import-file { overflow-wrap: anywhere; }
.login-card { max-width: 26rem; margin: 12vh auto; padding: 1.6rem; background: var(--surface); border: 1px solid var(--border); border-radius: 1rem; box-shadow: var(--shadow); }
.login-card button { margin-top: 1rem; }

[data-theme="dark"] .account-picker select,
[data-theme="dark"] #performance-empty,
[data-theme="dark"] th { background: #232c47; }
[data-theme="dark"] .ai-review { background: linear-gradient(145deg, #2c3057, var(--surface) 75%); border-color: var(--border); }
[data-theme="dark"] .ai-review h2 { color: #c6ccff; }
[data-theme="dark"] #win-rate-meter::-webkit-progress-bar { background: #333e62; }
[data-theme="dark"] #win-rate-meter::-webkit-progress-value { background: var(--chart-gain); }
[data-theme="dark"] #win-rate-meter::-moz-progress-bar { background: var(--chart-gain); }
[data-theme="dark"] input, [data-theme="dark"] select, [data-theme="dark"] textarea,
[data-theme="dark"] button.secondary, [data-theme="dark"] th, [data-theme="dark"] td { border-color: var(--border); }
[data-theme="dark"] tbody tr:nth-child(even) { background: #1e263d; }
[data-theme="dark"] tbody tr:hover, [data-theme="dark"] button.secondary:hover:not(:disabled) { background: #2b3657; }
#theme-toggle[aria-pressed="true"] { border-color: #7b88fb; }

@media (max-width: 68rem) {
  .workspace { grid-template-columns: 12rem minmax(0, 1fr); }
  .performance-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 48rem) {
  .workspace { display: block; }
  .sidebar { z-index: 2; height: auto; padding: .6rem .65rem .45rem; border: 0; }
  .brand { margin: 0 .25rem .45rem; font-size: 1.12rem; }
  .brand-mark { width: 1.55rem; height: 1.55rem; }
  .brand-mark::after { inset: .44rem .36rem .45rem; }
  .workspace-nav { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .18rem; padding: .15rem .15rem .35rem; }
  .workspace-nav a { flex-direction: column; justify-content: center; gap: .3rem; padding: .45rem .1rem; font-size: clamp(.65rem, 2.2vw, .82rem); text-align: center; white-space: normal; }
  .nav-icon { width: 1rem; font-size: .9rem; }
  .topbar, .dashboard-content { padding-inline: .85rem; }
  .dashboard-content { padding-top: .95rem; }
  .topbar button { font-size: .83rem; }
}
@media (max-width: 32rem) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; }
  .metrics > div { min-height: 5.4rem; }
  .metrics > div:first-child { grid-column: 1 / -1; }
  .performance-metrics > div:first-child { grid-column: auto; }
  .metrics > div:first-child strong { font-size: 1.85rem; }
  .filters label { flex: 1 1 8rem; min-width: 0; }
  .filters input, .filters select { width: 100%; min-width: 0; }
}
