/* Reset + base ------------------------------------------------------------ */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--color-light);
  color: var(--color-dark);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  min-height: 100vh;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-heading);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 0.5em;
  color: var(--color-dark);
}

h1 { font-size: 1.8rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }

a {
  color: var(--accent-blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
.btn {
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: 0.95rem;
  background: var(--accent-orange);
  color: var(--color-light);
  border: 0;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
}

button:hover,
.btn:hover {
  background: #c0653f;
}

button:active,
.btn:active {
  transform: translateY(1px);
}

.btn--ghost {
  background: transparent;
  color: var(--color-dark);
  border: 1px solid var(--color-mid-gray);
}

.btn--ghost:hover {
  background: var(--color-light-gray);
}

input[type="text"],
input[type="password"],
input[type="file"],
input[type="email"],
textarea,
select {
  font: inherit;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--color-mid-gray);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--color-dark);
  width: 100%;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--accent-blue);
  outline-offset: 1px;
}

/* Layout ------------------------------------------------------------------- */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: var(--color-dark);
  color: var(--color-light);
  border-bottom: 3px solid var(--accent-orange);
}

.app-header__brand {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--color-light);
}

.app-header__brand a {
  color: var(--color-light);
  text-decoration: none;
}

.app-header__nav {
  display: flex;
  gap: 1rem;
  align-items: center;
  font-family: var(--font-heading);
  font-size: 0.9rem;
}

.app-header__nav a {
  color: var(--color-light-gray);
}

.app-header__nav .user {
  color: var(--color-mid-gray);
}

.app-header__logout {
  display: inline;
}

.app-header__logout button {
  background: transparent;
  color: var(--color-light-gray);
  border: 1px solid var(--color-mid-gray);
  font-size: 0.85rem;
  padding: 0.3rem 0.7rem;
}

.app-header__logout button:hover {
  background: var(--accent-orange);
  border-color: var(--accent-orange);
  color: var(--color-light);
}

.app-main {
  flex: 1;
  padding: 1.5rem 2rem 3rem;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

.crumbs {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  color: var(--color-mid-gray);
  margin-bottom: 1rem;
}

.crumbs a {
  color: var(--color-mid-gray);
}

.crumbs a:hover {
  color: var(--accent-blue);
}

.crumbs__sep {
  margin: 0 0.4rem;
  color: var(--color-mid-gray);
}

/* Cards / grids ------------------------------------------------------------ */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.card {
  background: #fff;
  border: 1px solid var(--color-light-gray);
  border-radius: var(--radius-md);
  padding: 1rem 1.1rem;
  text-decoration: none;
  color: var(--color-dark);
  display: block;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
}

.card:hover {
  border-color: var(--accent-blue);
  box-shadow: var(--shadow-md);
  text-decoration: none;
}

.card__title {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1rem;
  margin: 0 0 0.4rem;
}

.card__meta {
  color: var(--color-mid-gray);
  font-size: 0.85rem;
}

.empty {
  color: var(--color-mid-gray);
  padding: 2rem;
  text-align: center;
  border: 1px dashed var(--color-light-gray);
  border-radius: var(--radius-md);
}

/* Symbol grid (chips) ------------------------------------------------------ */
.symbol-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.6rem;
}

.symbol-chip {
  background: #fff;
  border: 1px solid var(--color-light-gray);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.8rem;
  text-decoration: none;
  color: var(--color-dark);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  transition: border-color 0.1s ease, transform 0.05s ease;
}

.symbol-chip:hover {
  border-color: var(--accent-blue);
  text-decoration: none;
}

.symbol-chip__sym {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1rem;
}

.symbol-chip__pnl {
  font-size: 0.85rem;
  color: var(--color-mid-gray);
}

.symbol-chip__pnl--win { color: var(--accent-green); }
.symbol-chip__pnl--loss { color: var(--accent-orange); }

/* Login -------------------------------------------------------------------- */
.login-shell {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 2rem 1rem;
  background:
    radial-gradient(circle at 20% 10%, rgba(217, 119, 87, 0.08), transparent 40%),
    radial-gradient(circle at 80% 90%, rgba(106, 155, 204, 0.08), transparent 40%),
    var(--color-light);
}

/* Split the leftover vertical space 1:2 above:below, so the card sits a third
   of the way down instead of centred. Doing it with flex ratios rather than a
   fixed top offset keeps it correct at any viewport height and whatever the
   card's own height happens to be -- the error banner makes it taller. On a
   viewport too short to fit, both spacers collapse to zero and the page
   scrolls normally. */
.login-shell::before {
  content: "";
  flex: 1 1 0;
}

.login-shell::after {
  content: "";
  flex: 2 1 0;
}

.login-card {
  width: min(380px, 92vw);
  background: #fff;
  border: 1px solid var(--color-light-gray);
  border-radius: var(--radius-lg);
  padding: 2rem 2rem 1.5rem;
  box-shadow: var(--shadow-md);
}

.login-card h1 {
  margin-top: 0;
  font-size: 1.4rem;
}

/* The wordmark replaces the heading text. It stays an <h1> so the page keeps
   its heading for screen readers and search -- the img's alt supplies the
   name. The width/height attributes on the img give the browser the intrinsic
   ratio up front, so the card does not jump as the image loads. */
.login-logo {
  margin: 0;
}

.login-logo img {
  display: block;
  width: min(240px, 100%);
  height: auto;
  margin: 0 auto;
}

.login-error {
  background: rgba(217, 119, 87, 0.12);
  border: 1px solid rgba(217, 119, 87, 0.4);
  color: var(--color-dark);
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.login-card label {
  display: block;
  font-family: var(--font-heading);
  font-size: 0.85rem;
  margin: 0.7rem 0 0.25rem;
}

.login-card .btn {
  width: 100%;
  margin-top: 1rem;
}

/* Chart page --------------------------------------------------------------- */
.chart-panel {
  background: #fff;
  border: 1px solid var(--color-light-gray);
  border-radius: var(--radius-md);
  padding: 0.5rem;
  min-height: 520px;
}

.chart-panel--full {
  width: 100%;
}

.day-summary-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 2rem;
  background: #fff;
  border: 1px solid var(--color-light-gray);
  border-radius: var(--radius-md);
  padding: 0.7rem 1rem;
  margin-bottom: 1rem;
  align-items: baseline;
}

.day-summary-bar .stat {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.day-summary-bar .stat__label {
  font-family: var(--font-heading);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-mid-gray);
  font-weight: 600;
}

.day-summary-bar .stat__value {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  color: var(--color-dark);
}

.chart-container {
  width: 100%;
  height: 460px;
  position: relative;
}

.chart-marker-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 5;
}

.chart-marker-label {
  position: absolute;
  font-family: var(--font-heading);
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: 0.02em;
  text-align: center;
  white-space: nowrap;
}

.chart-marker-label__qty,
.chart-marker-label__tag {
  display: block;
}

.chart-marker-label__tag {
  font-weight: 500;
  font-size: 0.62rem;
  opacity: 0.9;
}

.equity-container {
  width: 100%;
  height: 140px;
  margin-top: 0.5rem;
  border-top: 1px solid var(--color-light-gray);
  padding-top: 0.5rem;
}

.day-summary {
  background: #fff;
  border: 1px solid var(--color-light-gray);
  border-radius: var(--radius-md);
  padding: 1rem;
}

.day-summary h3 {
  margin-top: 0;
}

.day-summary dl {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem 1rem;
  font-size: 0.92rem;
}

.day-summary dt {
  color: var(--color-mid-gray);
}

.day-summary dd {
  margin: 0;
  font-family: var(--font-heading);
  font-weight: 500;
  text-align: right;
}

.pnl--win { color: var(--accent-green); }
.pnl--loss { color: var(--accent-orange); }

.bar-size-pill {
  display: inline-block;
  background: var(--color-light-gray);
  color: var(--color-dark);
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
  font-size: 0.78rem;
  font-family: var(--font-heading);
  margin-left: 0.5rem;
  vertical-align: middle;
  position: relative;
  top: -0.12em;
  line-height: 1.25;
}

@media (max-width: 900px) {
  .chart-layout {
    grid-template-columns: 1fr;
  }
}

/* Symbols-of-the-day chart ------------------------------------------------- */
.day-chart-panel {
  background: #fff;
  border: 1px solid var(--color-light-gray);
  border-radius: var(--radius-md);
  padding: 0.5rem;
  margin-bottom: 1rem;
}

.day-chart-container {
  width: 100%;
  height: 320px;
}

.run-chart-label-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 10;
}

.run-chart-monday-label {
  position: absolute;
  bottom: 4px;
  transform: translateX(-50%);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: bold;
  color: var(--color-dark);
  background: var(--color-light);
  padding: 0 3px;
  pointer-events: none;
  white-space: nowrap;
}

.run-chart-monday-line {
  position: absolute;
  top: 0;
  height: calc(100% - 22px);  /* stop above the time axis area */
  width: 1px;
  background: var(--color-light-gray);
  pointer-events: none;
}

/* Symbols-of-the-day table ------------------------------------------------- */
.symbols-table-wrap {
  overflow-x: auto;
  background: #fff;
  border: 1px solid var(--color-light-gray);
  border-radius: var(--radius-md);
}

.symbols-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
}

.symbols-table thead th {
  text-align: left;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-mid-gray);
  padding: 0.7rem 1rem;
  background: var(--color-light-gray);
  border-bottom: 1px solid var(--color-mid-gray);
  white-space: nowrap;
}

.symbols-table tbody td,
.symbols-table tfoot td {
  padding: 0.3rem 1rem;
  border-bottom: 1px solid var(--color-light-gray);
  white-space: nowrap;
  line-height: 1.3;
}

.symbols-table tbody tr:hover {
  background: rgba(106, 155, 204, 0.08);
}

.symbols-table .num {
  text-align: right;
}

.symbols-table tbody .num {
  font-family: var(--font-heading);
  font-weight: 500;
}

.symbols-table__sym {
  font-family: var(--font-heading);
  font-weight: 600;
  color: var(--color-dark);
}

.symbols-table__sym:hover {
  color: var(--accent-blue);
  text-decoration: none;
}

.symbols-table tbody tr.row--win td:first-child {
  border-left: 3px solid var(--accent-green);
}

.symbols-table tbody tr.row--loss td:first-child {
  border-left: 3px solid var(--accent-orange);
}

.symbols-table tfoot td {
  border-top: 2px solid var(--color-mid-gray);
  border-bottom: 0;
  font-family: var(--font-heading);
  font-weight: 700;
  background: var(--color-light-gray);
}

.num-pct {
  font-weight: 500;
  color: var(--color-mid-gray);
  margin-left: 0.25rem;
}

/* Trades table ------------------------------------------------------------- */
.trades-heading {
  margin-top: 2rem;
}

.trades-table-wrap {
  overflow-x: auto;
  background: #fff;
  border: 1px solid var(--color-light-gray);
  border-radius: var(--radius-md);
}

.trades-table {
  width: 100%;
  min-width: 1080px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
}

.trades-table thead th {
  text-align: left;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-mid-gray);
  padding: 0.7rem 1.15rem;
  background: var(--color-light-gray);
  border-bottom: 1px solid var(--color-mid-gray);
  position: sticky;
  top: 0;
  white-space: nowrap;
}

.trades-table tbody td {
  padding: 0.55rem 1.15rem;
  border-bottom: 1px solid var(--color-light-gray);
  white-space: nowrap;
}

.trades-table tbody tr:last-child td {
  border-bottom: 0;
}

.trades-table tbody tr:hover {
  background: rgba(106, 155, 204, 0.08);
}

.trades-table .num {
  text-align: right;
  font-family: var(--font-heading);
}

.trades-table tbody .num {
  font-weight: 500;
}

/* Column dividers grouping into [#/Side/Qty] | [Entry] | [Exit] | [P&L]. */
.trades-table th:nth-child(4),
.trades-table td:nth-child(4),
.trades-table th:nth-child(7),
.trades-table td:nth-child(7),
.trades-table th:nth-child(10),
.trades-table td:nth-child(10) {
  padding-left: 1.6rem;
  border-left: 1px solid var(--color-light-gray);
}

/* Tighten the time → price gap (cols 4→5 and 7→8). */
.trades-table th:nth-child(4),
.trades-table td:nth-child(4),
.trades-table th:nth-child(7),
.trades-table td:nth-child(7) {
  padding-right: 0.45rem;
}

.trades-table th:nth-child(5),
.trades-table td:nth-child(5),
.trades-table th:nth-child(8),
.trades-table td:nth-child(8) {
  padding-left: 0.45rem;
}

.side-pill {
  display: inline-block;
  font-family: var(--font-heading);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
}

.side-pill--long {
  background: rgba(120, 140, 93, 0.18);
  color: var(--accent-green);
}

.side-pill--short {
  background: rgba(217, 119, 87, 0.18);
  color: var(--accent-orange);
}

.tag {
  font-family: var(--font-heading);
  font-size: 0.82rem;
  color: var(--color-dark);
  background: var(--color-light-gray);
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-sm);
}

.row--win td:first-child {
  border-left: 3px solid var(--accent-green);
}

.row--loss td:first-child {
  border-left: 3px solid var(--accent-orange);
}

/* Analysis tab ------------------------------------------------------------- */
.tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--color-light-gray);
  margin-bottom: 1.25rem;
}

.tab {
  padding: 0.55rem 1rem;
  font-family: var(--font-heading);
  font-size: 0.92rem;
  color: var(--color-mid-gray);
  border-bottom: 2px solid transparent;
  text-decoration: none;
  margin-bottom: -1px;
}

.tab.is-active {
  color: var(--color-dark);
  border-bottom-color: var(--accent-orange);
}

.upload-form {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin: 1rem 0 1.5rem;
}

.upload-form input[type="file"] {
  width: auto;
  flex: 1;
}

.analysis-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.analysis-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border: 1px solid var(--color-light-gray);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.9rem;
  gap: 1rem;
}

.analysis-row__title {
  font-family: var(--font-heading);
  font-weight: 500;
}

.analysis-row__meta {
  color: var(--color-mid-gray);
  font-size: 0.82rem;
}

.analysis-row__delete {
  background: transparent;
  border: 1px solid var(--color-mid-gray);
  color: var(--color-mid-gray);
  padding: 0.25rem 0.55rem;
  font-size: 0.78rem;
}

.analysis-row__delete:hover {
  background: var(--accent-orange);
  color: var(--color-light);
  border-color: var(--accent-orange);
}

.analysis-frame {
  width: 100%;
  height: calc(100vh - 220px);
  border: 1px solid var(--color-light-gray);
  border-radius: var(--radius-md);
  background: #fff;
}
