:root {
  color-scheme: light;
  --bg: #f4f2ed;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --ink: #1d2723;
  --muted: #69746e;
  --line: #d9ddd4;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --accent-soft: #d9f2ee;
  --blue: #2f5f9f;
  --blue-soft: #e5eef9;
  --loss: #b42318;
  --loss-soft: #fbe7e4;
  --win: #157347;
  --win-soft: #dff3e7;
  --warn: #a15c00;
  --warn-soft: #fff1d6;
  --shadow: 0 14px 45px rgba(29, 39, 35, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 20px;
  background: #14211d;
}

.login-screen[hidden] {
  display: none;
}

.login-card {
  display: grid;
  gap: 24px;
  width: min(100%, 440px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
  padding: 26px;
}

.login-card .brand {
  color: var(--ink);
}

.login-card .brand span,
.login-copy {
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 12px;
}

.login-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
}

.login-error {
  min-height: 20px;
  margin-bottom: 0;
  color: var(--loss);
  font-size: 0.9rem;
  font-weight: 750;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.app-shell.is-locked {
  filter: blur(3px);
  pointer-events: none;
  user-select: none;
}

.sidebar {
  background: #14211d;
  color: #f5f7f2;
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--accent);
  font-weight: 800;
}

.brand span,
.sidebar-note p {
  display: block;
  color: #b8c7bf;
  font-size: 0.84rem;
  line-height: 1.4;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #dfe8e3;
  padding: 10px 12px;
  text-align: left;
}

.nav-item:hover,
.nav-item.is-active {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  color: #9ce1d8;
  font-weight: 800;
}

.sidebar-note {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.sidebar-note span {
  color: #9ce1d8;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sidebar-note strong {
  display: block;
  margin-top: 4px;
}

.main-panel {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.9rem, 2.5vw, 2.7rem);
  line-height: 1.05;
}

h2 {
  margin-bottom: 0;
  font-size: 1.15rem;
}

h3 {
  margin-bottom: 6px;
  font-size: 1rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.save-status {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted);
  padding: 5px 10px;
  font-size: 0.8rem;
  font-weight: 800;
}

.save-status[data-tone="good"] {
  border-color: #a8dec1;
  background: var(--win-soft);
  color: var(--win);
}

.save-status[data-tone="danger"] {
  border-color: #f0b0a9;
  background: var(--loss-soft);
  color: var(--loss);
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 9px 14px;
  font-weight: 750;
}

.primary-button {
  background: var(--accent);
  color: #ffffff;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.secondary-button,
.ghost-button {
  background: var(--surface-strong);
  color: var(--ink);
  border-color: var(--line);
}

.ghost-button {
  background: transparent;
}

.view {
  display: none;
}

.view.is-visible {
  display: block;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.metric-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-card {
  padding: 16px;
}

.metric-card span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 1.65rem;
  line-height: 1;
}

.metric-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.content-grid,
.checklist-layout,
.calculator-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.75fr);
  gap: 14px;
  margin-bottom: 14px;
}

.panel {
  padding: 18px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.trade-controls {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(140px, 0.75fr);
  gap: 10px;
  min-width: min(100%, 420px);
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.chart-wrap {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(29, 39, 35, 0.05) 1px, transparent 1px),
    linear-gradient(rgba(29, 39, 35, 0.05) 1px, transparent 1px), #fbfaf6;
  background-size: 56px 48px;
}

#equity-chart {
  display: block;
  width: 100%;
  height: 240px;
}

.behavior-list,
.warning-stack,
.result-grid {
  display: grid;
  gap: 10px;
}

.behavior-item,
.warning-item,
.result-item {
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  padding: 12px;
}

.behavior-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.behavior-item strong,
.result-item strong {
  display: block;
}

.behavior-item span,
.result-item span,
.warning-item p {
  color: var(--muted);
  font-size: 0.86rem;
}

.warning-item.warning {
  border-color: #f2c98e;
  background: var(--warn-soft);
}

.warning-item.danger {
  border-color: #f0b0a9;
  background: var(--loss-soft);
}

.warning-item.good {
  border-color: #a8dec1;
  background: var(--win-soft);
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
}

.profit {
  color: var(--win);
  font-weight: 800;
}

.loss {
  color: var(--loss);
  font-weight: 800;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(0, 1.35fr);
  gap: 14px;
  align-items: start;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 10px 11px;
}

textarea {
  min-height: 82px;
  resize: vertical;
}

.trade-list {
  display: grid;
  gap: 10px;
}

.trade-card {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 12px;
  text-align: left;
}

.trade-card.is-selected,
.trade-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.trade-card-top,
.trade-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.trade-card-bottom {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.86rem;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  padding: 4px 9px;
  font-size: 0.78rem;
  font-weight: 800;
}

.tag.warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.tag.loss {
  background: var(--loss-soft);
  color: var(--loss);
}

.tag.win {
  background: var(--win-soft);
  color: var(--win);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 320px;
  color: var(--muted);
  text-align: center;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.detail-grid,
.quick-log-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field-stack {
  display: grid;
  gap: 6px;
}

.field-stack span,
.calculator-form label {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 750;
}

.data-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 11px;
}

.screenshot-zone {
  display: grid;
  gap: 12px;
  margin: 16px 0;
}

.upload-box {
  border: 1px dashed #9aa59f;
  border-radius: 8px;
  background: #fbfaf6;
  padding: 16px;
}

.screenshot-preview {
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.quick-log-grid {
  margin-top: 10px;
}

.quick-log-grid label,
.calculator-form label {
  display: grid;
  gap: 6px;
}

.full-row {
  grid-column: 1 / -1;
}

.checklist-form,
.calculator-form {
  display: grid;
  gap: 12px;
}

.check-row {
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 12px;
}

.check-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.check-row.caution {
  background: #fffaf0;
}

.result-panel {
  min-height: 360px;
}

@media (max-width: 1050px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    padding: 18px;
  }

  .nav-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .nav-item {
    justify-content: center;
  }

  .sidebar-note {
    display: none;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content-grid,
  .split-layout,
  .checklist-layout,
  .calculator-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .main-panel {
    padding: 18px;
  }

  .topbar,
  .detail-header,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .trade-controls {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .topbar-actions,
  .topbar-actions button {
    width: 100%;
  }

  .nav-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .nav-item {
    min-height: 42px;
    padding: 8px;
    font-size: 0.9rem;
  }

  .metric-grid,
  .detail-grid,
  .quick-log-grid {
    grid-template-columns: 1fr;
  }
}
