/* Daily Report Card - light theme, mobile first, no build step. */

@font-face {
  font-family: 'Inter Variable';
  src: url('fonts/InterVariable.woff2') format('woff2-variations'),
       url('fonts/InterVariable.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #f4f5f7;
  --border: #e5e7eb;
  --border-strong: #cbd1d9;
  --text: #15171c;
  --muted: #6b7280;
  --accent: #1f6feb;
  --accent-text: #ffffff;
  --shadow: 0 1px 2px rgba(15,17,28,0.04), 0 1px 1px rgba(15,17,28,0.03);
  --radius: 10px;
  --gap: 12px;

  /* Grade palette: bright, sequential, clearly distinct hues.
     Mid-tones (lime, yellow) flip to dark text for readability. */
  --grade-9-10: #16a34a; /* green-600  — best days */
  --grade-7-8:  #a3e635; /* lime-400   — good */
  --grade-5-6:  #facc15; /* yellow-400 — meh */
  --grade-3-4:  #f97316; /* orange-500 — bad */
  --grade-1-2:  #dc2626; /* red-600    — worst */
  --grade-none: #d6d9df;
  --grade-text-dark: #15171c;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter Variable', 'Inter', ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-feature-settings: 'cv11', 'ss01';
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
small { font-size: 13px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
mark { background: #fff3a8; color: inherit; padding: 0 2px; border-radius: 3px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 8px; border-radius: 8px;
  color: var(--text);
  text-decoration: none;
}
.brand:hover { background: var(--surface-2); text-decoration: none; }
.brand-mark {
  display: inline-flex; gap: 2px;
  padding: 4px; border-radius: 6px;
  background: var(--surface-2);
  line-height: 0;
}
.brand-cell {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 2px;
}
.brand-cell.c1 { background: var(--grade-9-10); }
.brand-cell.c2 { background: var(--grade-7-8);  }
.brand-cell.c3 { background: var(--grade-3-4);  }
.brand-text {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.015em;
  font-feature-settings: 'cv11', 'ss01';
  white-space: nowrap;
}
@media (max-width: 480px) {
  /* Don't crowd the nav on small phones */
  .brand-text { display: none; }
}
.navtabs { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.navtabs a {
  color: var(--text); padding: 6px 10px; border-radius: 6px;
  font-size: 14px;
}
.navtabs a.active { background: var(--surface-2); font-weight: 600; }
.navtabs a:hover { background: var(--surface-2); text-decoration: none; }
.logout-form { margin: 0; }
.linkish {
  background: none; border: 0; color: var(--muted);
  cursor: pointer; padding: 6px 8px; font: inherit;
}
.linkish:hover { color: var(--text); }

/* ---------- Layout ---------- */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 14px;
  padding-bottom: 80px;
}
.topbar { padding: 10px 14px; }
.card-section { margin: 18px 0; }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 8px;
}
.section-head h2 { margin: 0; font-size: 18px; }

/* ---------- Buttons ---------- */
.btn-primary, .btn-secondary {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 10px 16px;
  border: 1px solid transparent; border-radius: var(--radius);
  font: inherit; font-weight: 600; cursor: pointer;
  background: var(--accent); color: var(--accent-text);
  text-decoration: none;
}
.btn-primary:hover { filter: brightness(1.05); text-decoration: none; }
.btn-secondary {
  background: var(--surface); color: var(--text); border-color: var(--border);
}
.btn-secondary:hover { background: var(--surface-2); }
.btn-primary.big, .btn-secondary.big { width: 100%; min-height: 56px; font-size: 17px; }
.btn-icon {
  width: 36px; height: 36px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; font-size: 18px; line-height: 1; color: var(--muted);
}
.btn-icon:hover { color: var(--text); background: var(--surface-2); }

/* ---------- Auth ---------- */
.auth {
  max-width: 380px; margin: 32px auto; padding: 0 16px;
}
.auth h1 { margin-top: 0; }
.auth form { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.auth label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.auth input[type=email],
.auth input[type=text],
.auth input[type=password] {
  font: inherit; font-size: 16px;
  padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text);
}
.auth input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.auth .check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.auth .error {
  padding: 10px 12px; border-radius: 8px;
  background: #fdecec; color: #7a1f24; border: 1px solid #f5c2c5;
}
.info {
  padding: 12px 14px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border);
}
.info code { background: var(--surface-2); padding: 1px 6px; border-radius: 4px; font-size: 13px; }

/* ---------- Grade chips & calendar ---------- */
.grade-chip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 8px;
  font-weight: 700; color: white;
  background: var(--grade-none);
}
.big-link {
  display: flex; align-items: center; gap: 12px;
  padding: 14px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); color: inherit;
  text-decoration: none; box-shadow: var(--shadow);
}
.big-link:hover { text-decoration: none; background: var(--surface-2); }
.big-link strong { display: block; font-weight: 600; }
.big-link small { display: block; }

.cal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px; box-shadow: var(--shadow);
}
.cal-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-row + .cal-row { margin-top: 4px; }
.cal-head { font-size: 12px; color: var(--muted); text-align: center; padding-bottom: 6px; }
.cal-head span { padding: 2px 0; }
.cal-cell {
  aspect-ratio: 1 / 1;
  position: relative;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  background: var(--grade-none); text-decoration: none;
  font-size: 13px;
  overflow: hidden;
}
.cal-day {
  position: absolute; top: 4px; left: 6px;
  font-size: 11px; font-weight: 600; opacity: 0.85;
  line-height: 1;
}
.cal-grade {
  font-size: 17px; font-weight: 700;
  line-height: 1;
}
.cal-pnl {
  position: absolute; bottom: 4px; right: 6px;
  font-size: 10px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  opacity: 0.85;
}
.cal-cell.empty { background: transparent; pointer-events: none; }
.cal-cell.none { background: var(--surface-2); color: var(--muted); font-weight: 500; }
.cal-cell.none .cal-day { color: var(--muted); opacity: 1; font-weight: 500; }
.cal-cell.today { outline: 2px solid var(--accent); outline-offset: 1px; }
.cal-cell.draft { box-shadow: inset 0 0 0 2px rgba(255,255,255,0.6); }
.cal-cell:hover { text-decoration: none; filter: brightness(1.06); }
.cal-legend {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px;
  font-size: 12px;
}
.legend-label { color: var(--muted); font-weight: 600; }
.cal-legend > span {
  padding: 2px 8px; border-radius: 12px; font-weight: 600;
}
.cal-legend > .legend-label { color: var(--muted); background: transparent; padding-left: 0; font-weight: 600; }
.cal-legend > .bucket-9-10 { background: var(--grade-9-10); color: white; }
.cal-legend > .bucket-7-8  { background: var(--grade-7-8);  color: var(--grade-text-dark); }
.cal-legend > .bucket-5-6  { background: var(--grade-5-6);  color: var(--grade-text-dark); }
.cal-legend > .bucket-3-4  { background: var(--grade-3-4);  color: white; }
.cal-legend > .bucket-1-2  { background: var(--grade-1-2);  color: white; }
.cal-legend > .bucket-none { color: var(--muted); background: var(--surface-2); }

/* Buckets — colors above, plus a dark-text override on the bright mid-tones. */
.bucket-9-10 { background: var(--grade-9-10); color: white; }
.bucket-7-8  { background: var(--grade-7-8);  color: var(--grade-text-dark); }
.bucket-5-6  { background: var(--grade-5-6);  color: var(--grade-text-dark); }
.bucket-3-4  { background: var(--grade-3-4);  color: white; }
.bucket-1-2  { background: var(--grade-1-2);  color: white; }
.bucket-none { background: var(--grade-none); color: var(--muted); }

/* Calendar cells inherit bucket text color, so the day number / grade /
   pnl all flip together on lime + yellow days. */
.cal-cell.bucket-7-8 .cal-pnl,
.cal-cell.bucket-5-6 .cal-pnl { color: var(--grade-text-dark); opacity: 0.7; }

/* ---------- Recent list ---------- */
.recent { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.recent li a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); color: inherit; text-decoration: none;
}
.recent li a:hover { background: var(--surface-2); }
.recent li a strong { display: block; font-weight: 600; }
.recent li a small { display: block; }
.snippet { color: var(--text); font-size: 14px; }

/* ---------- Card form ---------- */
.card-nav {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-top: 8px;
}
.card-nav h1 { font-size: 18px; margin: 0; text-align: center; flex: 1; }
.nav-arrow {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); font-size: 22px; line-height: 1;
}
.nav-arrow:hover { background: var(--surface-2); text-decoration: none; }
.save-status {
  text-align: center; color: var(--muted); font-size: 13px; margin: 4px 0 8px;
  min-height: 18px;
}
.save-status.saved { color: var(--grade-9-10); }
.save-status.saving { color: var(--accent); }
.save-status.error { color: var(--grade-1-2); }

details.block {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); margin: 12px 0; overflow: hidden;
  box-shadow: var(--shadow);
}
details.block summary {
  list-style: none; cursor: pointer;
  padding: 14px 16px; font-weight: 700; font-size: 16px;
  display: flex; align-items: baseline; justify-content: space-between;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
details.block summary::-webkit-details-marker { display: none; }
details.block .block-meta {
  font-size: 12px; font-weight: 500; color: var(--muted);
}
details.block .block-body { padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 14px; }

.field { display: flex; flex-direction: column; gap: 8px; border: 0; padding: 0; margin: 0; }
.field .lbl, .field legend.lbl {
  font-size: 13px; font-weight: 600; color: var(--muted); padding: 0;
}
.field textarea,
.field input[type=text],
.field input[type=number] {
  font: inherit; font-size: 16px;
  padding: 10px 12px;
  border-radius: 8px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text);
  resize: vertical;
}
.field textarea:focus,
.field input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Grade input — two rows of 5 */
.grade-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.grade-btn {
  height: 52px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit; font-size: 17px; font-weight: 700;
  cursor: pointer;
}
.grade-btn[aria-pressed="true"] { border-color: transparent; }
.grade-btn:hover { background: var(--surface-2); }
.grade-btn[aria-pressed="true"].bucket-9-10 { background: var(--grade-9-10); color: white; }
.grade-btn[aria-pressed="true"].bucket-7-8  { background: var(--grade-7-8);  color: var(--grade-text-dark); }
.grade-btn[aria-pressed="true"].bucket-5-6  { background: var(--grade-5-6);  color: var(--grade-text-dark); }
.grade-btn[aria-pressed="true"].bucket-3-4  { background: var(--grade-3-4);  color: white; }
.grade-btn[aria-pressed="true"].bucket-1-2  { background: var(--grade-1-2);  color: white; }

/* Tickers */
.tickers-field { gap: 10px; }
.tickers-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.ticker-row {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px; display: flex; flex-direction: column; gap: 8px;
}
.ticker-head {
  display: grid; grid-template-columns: 1fr 1fr 36px; gap: 8px; align-items: center;
}
.ticker-symbol, .ticker-pnl {
  font: inherit; font-size: 16px; padding: 10px 12px;
  border-radius: 8px; border: 1px solid var(--border); background: var(--surface);
}
.ticker-symbol { text-transform: uppercase; font-weight: 700; }
.ticker-pnl { font-variant-numeric: tabular-nums; }
.ticker-row textarea {
  font: inherit; font-size: 16px;
  padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface);
  min-height: 64px;
}
.thumbs { display: flex; flex-wrap: wrap; gap: 6px; }
.thumb {
  position: relative; display: block; width: 96px; height: 64px;
  border-radius: 6px; overflow: hidden; background: #000;
  border: 1px solid var(--border);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-x {
  position: absolute; top: 2px; right: 2px;
  width: 22px; height: 22px; border-radius: 50%; border: 0;
  background: rgba(0,0,0,0.6); color: white; cursor: pointer;
  font-size: 14px; line-height: 22px; padding: 0;
}
.thumb-x:hover { background: rgba(0,0,0,0.8); }

.add-screenshot {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--muted);
  padding: 8px 10px; border: 1px dashed var(--border-strong);
  border-radius: 8px; cursor: pointer; background: var(--surface);
  align-self: flex-start;
}
.add-screenshot:hover { color: var(--text); background: var(--surface-2); }
.ticker-row.drop-target { outline: 2px dashed var(--accent); outline-offset: 2px; }

.form-actions { margin: 24px 0 0; display: flex; flex-direction: column; gap: 8px; }
.btn-danger {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 38px; padding: 8px 14px;
  border: 1px solid var(--grade-1-2); border-radius: var(--radius);
  font: inherit; font-weight: 600; cursor: pointer;
  background: var(--surface); color: var(--grade-1-2);
}
.btn-danger:hover { background: var(--grade-1-2); color: white; }
.small-action { align-self: center; margin-top: 16px; font-size: 13px; }

/* ---------- Search ---------- */
.search-form {
  display: flex; gap: 8px; margin: 12px 0 18px;
}
.search-form input[type=search] {
  flex: 1; font: inherit; font-size: 16px;
  padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface);
}

/* ---------- Stats ---------- */
.stats { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.stats li {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px; font-size: 14px; color: var(--muted);
}
.stats li strong { color: var(--text); font-size: 18px; display: block; }

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,0.85);
  display: none; align-items: center; justify-content: center; z-index: 100;
  padding: 16px;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 100%; max-height: 100%; box-shadow: 0 4px 30px rgba(0,0,0,0.6); }
.lightbox-close {
  position: absolute; top: 12px; right: 12px;
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(255,255,255,0.15); color: white; border: 0;
  font-size: 20px; cursor: pointer;
}

/* ---------- Footer ---------- */
.footer {
  text-align: center; padding: 32px 16px 24px;
  color: var(--muted); font-size: 12px;
  display: flex; flex-direction: column; gap: 4px; align-items: center;
}

/* ---------- Desktop tweaks ---------- */
@media (min-width: 720px) {
  .container { padding: 20px 24px 80px; }
  .stats { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 1024px) {
  .container { max-width: 1040px; padding: 24px 32px 96px; }
  .topbar { padding: 12px 24px; }
  /* Bigger calendar cells when there's room to read them. */
  .cal-day { top: 6px; left: 8px; font-size: 12px; }
  .cal-grade { font-size: 22px; }
  .cal-pnl { font-size: 11px; bottom: 6px; right: 8px; }
  /* Readable textareas — cap at a reasonable line length even in a wide layout. */
  .field textarea { max-width: 820px; }
  /* Trade rows fit more horizontally. */
  .ticker-head { grid-template-columns: 1fr 180px 44px; }
}
@media (min-width: 1280px) {
  .container { max-width: 1180px; }
}

@media (prefers-reduced-motion: no-preference) {
  .save-status { transition: color 150ms ease; }
}
