:root {
  color-scheme: light;
  --page: #f4f7f6;
  --surface: #ffffff;
  --text: #17201e;
  --muted: #77837f;
  --border: #e8edeb;
  --green: #14845f;
  --green-soft: #e7f4ee;
  --red: #c74d4d;
  --red-soft: #f8ebeb;
  --teal: #187d6b;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--page); }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.app-shell {
  width: min(100%, 560px);
  min-height: 100vh;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 16px calc(12px + env(safe-area-inset-bottom));
}
.topbar {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 9px; font-size: 17px; letter-spacing: -.2px; }
.brand-mark, .account-icon, .welcome-icon {
  display: grid;
  place-items: center;
  color: var(--teal);
  background: #e5f2ef;
}
.brand-mark { width: 30px; height: 30px; border-radius: 10px; font-size: 21px; font-weight: 700; }
.top-actions { display: flex; gap: 5px; }
.icon-button {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #24302c;
  font-size: 22px;
}
.icon-button:active, .round-button:active { background: #e8eeec; }
.login-view { padding-top: 15px; }
.welcome { margin: 0 4px 20px; }
.welcome-icon {
  width: 52px;
  height: 52px;
  border-radius: 17px;
  margin-bottom: 14px;
  font-size: 28px;
}
.welcome h1 { margin: 0; font-size: 27px; letter-spacing: -.7px; }
.welcome p { margin: 8px 0 0; color: var(--muted); font-size: 14px; line-height: 1.45; }
.surface {
  border: 1px solid rgba(25, 45, 38, .035);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(30, 50, 43, .035);
}
.login-form { padding: 18px; display: grid; gap: 9px; }
.login-form label { margin-top: 2px; font-size: 13px; font-weight: 600; }
.login-form input, .account-select-wrap select {
  width: 100%;
  min-height: 47px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fbfcfc;
  color: var(--text);
  font-size: 16px;
  outline: none;
}
.login-form input:focus, .account-select-wrap select:focus {
  border-color: #5ea895;
  box-shadow: 0 0 0 3px rgba(24, 125, 107, .12);
}
.primary-button {
  min-height: 49px;
  margin-top: 6px;
  border: 0;
  border-radius: 13px;
  background: var(--teal);
  color: #fff;
  font-weight: 650;
}
.primary-button:disabled { opacity: .65; }
.privacy-note { margin: 2px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.error-message { margin: 3px 0 0; color: var(--red); font-size: 13px; line-height: 1.45; }
.setup-note { margin-top: 13px; padding: 16px 18px; }
.setup-note h2 { margin: 0 0 9px; font-size: 15px; }
.setup-note ol { margin: 0; padding-left: 20px; color: #5d6a66; font-size: 12px; line-height: 1.65; }
.setup-note a { display: inline-block; margin-top: 10px; color: var(--teal); font-size: 13px; font-weight: 600; text-decoration: none; }

.account-row { display: flex; align-items: center; gap: 12px; padding: 11px 13px; }
.account-icon {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 14px;
  font-size: 23px;
  font-weight: 700;
}
.account-select-wrap { min-width: 0; flex: 1; }
.account-select-wrap label { display: block; margin-bottom: 3px; color: var(--muted); font-size: 10px; }
.account-select-wrap select {
  min-height: 27px;
  padding: 0 21px 0 0;
  border: 0;
  background-color: transparent;
  font-size: 14px;
  font-weight: 650;
}
.account-meta { margin: 3px 0 0; color: var(--muted); font-size: 10px; }
.month-nav {
  display: grid;
  grid-template-columns: 38px 1fr 38px;
  align-items: center;
  margin: 12px 0 10px;
  text-align: center;
}
.month-nav h1 { margin: 0; font-size: 17px; font-weight: 700; text-transform: capitalize; }
.round-button {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: var(--surface);
  color: #25322e;
  font-size: 27px;
  line-height: 1;
}
.month-summary {
  min-height: 81px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  margin-bottom: 11px;
}
.month-summary p { margin: 0; color: var(--muted); font-size: 12px; }
.month-summary strong { display: block; margin-top: 5px; font-size: 23px; letter-spacing: -.45px; }
.month-summary strong.profit { color: var(--green); }
.month-summary strong.loss { color: var(--red); }
.trend-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--green);
  background: var(--green-soft);
  font-size: 20px;
}
.trend-icon.loss { color: var(--red); background: var(--red-soft); }
.calendar-surface { padding: 11px 10px 9px; }
.weekdays, .calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); column-gap: 3px; }
.weekdays { margin-bottom: 4px; }
.weekdays span {
  height: 21px;
  display: grid;
  place-items: center;
  color: #7b8783;
  font-size: 10px;
  font-weight: 650;
}
.calendar-grid { row-gap: 4px; }
.calendar-blank { height: 45px; }
.day-button {
  min-width: 0;
  height: 45px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 4px 0 2px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
}
.day-button:focus-visible { outline: 2px solid var(--teal); outline-offset: 1px; }
.day-button.selected { border-color: var(--teal); background: #e8f4f1; }
.day-number { font-size: 11px; line-height: 13px; }
.day-button.selected .day-number { font-weight: 700; }
.day-value {
  min-height: 12px;
  max-width: 100%;
  overflow: hidden;
  color: var(--green);
  font-size: 9px;
  font-weight: 650;
  line-height: 11px;
  white-space: nowrap;
}
.day-value.loss { color: var(--red); }
.calendar-legend {
  min-height: 22px;
  margin: 4px 2px 0;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 10px;
}
.calendar-legend span { display: inline-flex; align-items: center; gap: 4px; }
.legend-dot { width: 7px; height: 7px; display: inline-block; border-radius: 50%; }
.profit-dot { background: var(--green); }
.loss-dot { background: var(--red); }
.calendar-legend .last-fetched { margin-left: auto; color: #929d99; font-size: 9px; }
.day-details { margin-top: 11px; padding: 13px 14px; }
.details-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 9px; }
.details-heading h2 { margin: 0; font-size: 14px; }
.details-heading strong { font-size: 12px; }
.details-heading strong.profit { color: var(--green); }
.details-heading strong.loss { color: var(--red); }
.trade-row {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid #edf0ef;
}
.trade-copy { min-width: 0; }
.trade-symbol { font-size: 13px; font-weight: 650; }
.trade-meta { margin-top: 4px; color: var(--muted); font-size: 10px; white-space: nowrap; }
.trade-pnl { font-size: 12px; font-weight: 650; white-space: nowrap; }
.trade-pnl.profit { color: var(--green); }
.trade-pnl.loss { color: var(--red); }
.no-trades { padding: 11px 0 4px; color: var(--muted); font-size: 12px; }
.history-note { margin-top: 5px; color: #929d99; font-size: 10px; }
.app-status { padding: 11px 4px 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.app-status p { margin: 2px 0; }
.app-status #sync-status { font-weight: 600; }
.app-footer { padding: 14px 2px 3px; color: #96a19d; text-align: center; font-size: 10px; }

@media (max-width: 370px) {
  .app-shell { padding-right: 11px; padding-left: 11px; }
  .calendar-grid { column-gap: 1px; }
  .day-button { height: 41px; }
  .day-value { font-size: 8px; }
}
