/* Discipline tracker — visual language matched to Lucid Trading's dashboard */
:root {
  --bg: #0a0a0a;
  --panel: #121212;
  --cell: #0d0d0d;
  --raise: #1a1a1a;
  --line: #222222;
  --line-2: #2c2c2c;
  --line-soft: #1a1a1a;

  --text: #f5f5f5;
  --label: #a3a3a8;
  --muted: #8a8a8f;
  --dim: #5f5f64;

  --green: #86efac;
  --green-bg: #1b2a21;
  --green-line: #3b6a4b;
  --red: #ef6b64;
  --red-bg: #2a1616;
  --red-line: #6e2b28;
  --yellow: #f0c95c;
  --yellow-bg: #29230f;
  --yellow-line: #6d5a22;
  --blue: #7fa9ea;

  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Segoe UI", Roboto, system-ui, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, Consolas, monospace;

  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.mono { font-family: var(--mono); }
.dim { color: var(--dim); }
.muted { color: var(--muted); }

/* ---------- status tones ---------- */
.s-green  { --c: var(--green);  --c-bg: var(--green-bg);  --c-line: var(--green-line); }
.s-yellow { --c: var(--yellow); --c-bg: var(--yellow-bg); --c-line: var(--yellow-line); }
.s-red    { --c: var(--red);    --c-bg: var(--red-bg);    --c-line: var(--red-line); }
.s-open   { --c: var(--text);   --c-bg: var(--cell);      --c-line: var(--line-2); }

/* ---------- layout ---------- */
#app { max-width: 1240px; margin: 0 auto; padding: 12px 16px 64px; }
.grid-top { display: grid; gap: 16px; grid-template-columns: 1fr; }
.stack { display: grid; gap: 16px; align-content: start; }
@media (min-width: 1000px) {
  #app { padding: 20px 28px 80px; }
  .grid-top { grid-template-columns: minmax(380px, 440px) 1fr; }
}
.section-gap { margin-top: 16px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
}
@media (max-width: 600px) { .card { padding: 16px; border-radius: 14px; } }

.label {
  font: 600 12px/1.2 var(--sans);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--label);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 6px 0 16px; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.mark { width: 12px; height: 12px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(134,239,172,.12); }
.top-right { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; color: var(--label);
}
.icon-btn:hover { color: var(--text); border-color: #3a3a3a; }
.icon-btn svg { width: 18px; height: 18px; }
.sync {
  display: inline-flex; align-items: center; gap: 8px;
  font: 500 12px var(--mono); color: var(--muted);
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 999px; padding: 8px 12px;
}
.sync .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); }
.sync.t-green .dot { background: var(--green); }
.sync.t-yellow { color: var(--yellow); } .sync.t-yellow .dot { background: var(--yellow); }
.sync.t-red { color: var(--red); } .sync.t-red .dot { background: var(--red); }

.banner {
  display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  border: 1px solid var(--line-2); background: var(--panel); border-radius: 12px;
  padding: 12px 16px; margin-bottom: 16px; font-size: 14px; color: var(--label);
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--raise); border: 1px solid var(--line-2); border-radius: 10px;
  padding: 10px 14px; font-weight: 600; font-size: 14px; color: var(--text);
  transition: border-color .12s, background .12s;
}
.btn:hover:not(:disabled) { border-color: #3d3d3d; }
.btn:disabled { opacity: .45; }
.btn-primary { background: var(--green-bg); border-color: var(--green-line); color: var(--green); }
.btn-primary:hover:not(:disabled) { border-color: var(--green); }
.btn-danger { color: var(--red); }
.btn-danger:hover:not(:disabled) { border-color: var(--red-line); }
.btn-ghost { background: transparent; }
.btn-lg { min-height: 58px; font-size: 16px; padding: 14px 16px; border-radius: 12px; }
.btn kbd {
  font: 600 11px var(--mono); padding: 2px 6px; border-radius: 5px;
  border: 1px solid currentColor; opacity: .5;
}
@media (hover: none) { .btn kbd { display: none; } }
.linkish { background: none; border: 0; padding: 0; color: var(--label); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }
.linkish:hover { color: var(--text); }

/* ---------- day panel ---------- */
.day-date { font: 600 15px var(--mono); margin-top: 6px; }
.scorebox { display: flex; align-items: baseline; gap: 8px; flex-wrap: nowrap; white-space: nowrap; }
.scorebox .big { font: 700 34px/1 var(--sans); color: var(--c); letter-spacing: -.02em; }
.scorebox .of { font: 500 14px var(--mono); color: var(--muted); }
.pill {
  display: inline-block; font: 700 12px/1 var(--mono); padding: 6px 8px; border-radius: 7px;
  background: var(--c-bg); border: 1px solid var(--c-line); color: var(--c);
}
.s-open .pill, .pill.s-open { border-style: dashed; color: var(--label); }
.cap-note { margin-top: 10px; font-size: 13px; color: var(--c); }

.log-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.trades-row { display: flex; align-items: center; justify-content: space-between; margin-top: 18px; }
.trades { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip {
  display: inline-flex; align-items: baseline; gap: 4px;
  background: var(--c-bg); border: 1px solid var(--c-line); border-radius: 9px;
  padding: 8px 11px; font-size: 13px;
}
.chip-val { font: 700 16px var(--sans); color: var(--c); }
.empty-note { font-size: 13px; color: var(--muted); margin-top: 10px; }

.group-label { margin: 22px 0 10px; }
.checks { display: grid; gap: 8px; }
.check {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--cell); border: 1px solid var(--line); border-radius: 11px;
  padding: 13px 14px; min-height: 52px; transition: background .12s, border-color .12s;
}
.check:hover { border-color: var(--line-2); }
.check .box {
  flex: none; width: 22px; height: 22px; border-radius: 6px; border: 1.5px solid #4a4a4f;
  display: grid; place-items: center;
}
.check .box svg { width: 14px; height: 14px; opacity: 0; }
.check .txt { flex: 1; font-size: 14.5px; }
.check .pts { font: 600 13px var(--mono); color: var(--muted); white-space: nowrap; }
.check .hint { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.check.on { background: var(--green-bg); border-color: var(--green-line); }
.check.on .box { background: var(--green); border-color: var(--green); }
.check.on .box svg { opacity: 1; color: #0b1a10; }
.check.on .pts { color: var(--green); }

.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; background: var(--cell); border: 1px solid var(--line); border-radius: 11px; }
.seg button {
  background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 10px 6px; min-height: 44px;
  font-weight: 600; font-size: 14px; color: var(--muted);
}
.seg button.on { background: var(--raise); border-color: var(--line-2); color: var(--text); }
.seg button.on.s-yellow, .seg button.on.s-red { background: var(--c-bg); border-color: var(--c-line); color: var(--c); }
.seg-hint { font-size: 12.5px; color: var(--muted); margin-top: 8px; }

details.extra { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
details.extra summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; }
details.extra summary::-webkit-details-marker { display: none; }
details.extra summary::before { content: "+"; font: 600 14px var(--mono); color: var(--muted); width: 12px; }
details.extra[open] summary::before { content: "−"; }
.field { display: grid; gap: 6px; margin-top: 12px; }
.field > span { font-size: 13px; color: var(--label); }
.input, textarea.input, select.input {
  width: 100%; background: var(--cell); border: 1px solid var(--line-2); border-radius: 10px;
  padding: 11px 12px; font-size: 15px; color: var(--text);
}
textarea.input { resize: vertical; min-height: 72px; }
.input:focus { border-color: #4a4a50; outline: none; }
.input.mono { font-family: var(--mono); }

.panel-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line);
}
.breakdown { font: 500 12.5px/1.6 var(--mono); color: var(--muted); }
.breakdown b { color: var(--text); font-weight: 600; }
.stale-note {
  margin-top: 14px; font-size: 13px; color: var(--label); display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  border: 1px dashed var(--line-2); border-radius: 10px; padding: 10px 12px;
}

/* ---------- chart ---------- */
.legend { display: flex; gap: 22px; flex-wrap: wrap; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
#chart { margin-top: 12px; min-height: 220px; }
#chart svg { display: block; width: 100%; height: auto; }
#chart .axis { font: 500 12px var(--sans); fill: var(--muted); }
.empty { display: grid; place-items: center; min-height: 200px; color: var(--muted); font-size: 14px; text-align: center; padding: 20px; }

/* ---------- progress ---------- */
.track { position: relative; height: 8px; border-radius: 4px; margin-top: 8px; }
.track .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: var(--c); }
.track .tick { position: absolute; top: -6px; width: 1px; height: 20px; background: var(--label); }
.track .tick-label { position: absolute; top: 18px; transform: translateX(-50%); font: 600 11px var(--mono); letter-spacing: .1em; color: var(--label); }
.track-ends { display: flex; justify-content: space-between; margin-top: 30px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.track-ends .v { font: 600 17px var(--mono); }
.track-ends .l { margin-left: 8px; }
.stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; padding-top: 20px; }
.stat .v { font: 700 28px/1.1 var(--sans); letter-spacing: -.01em; }
.stat .l { margin-top: 8px; }
.stat.center { text-align: center; } .stat.center .v { color: var(--green); }
.stat.right { text-align: right; }
@media (max-width: 600px) { .stat .v { font-size: 22px; } }

/* ---------- calendar ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.cal-head-left { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.tabs { display: inline-flex; padding: 4px; gap: 4px; background: var(--cell); border: 1px solid var(--line); border-radius: 12px; }
.tabs button { background: transparent; border: 0; border-radius: 8px; padding: 9px 18px; font-weight: 600; font-size: 15px; color: var(--label); }
.tabs button.on { background: var(--raise); color: var(--text); }
.month-nav { display: flex; align-items: center; gap: 14px; }
.month-nav .mlabel { font: 700 16px var(--mono); min-width: 160px; text-align: center; }
.month-nav .icon-btn { width: 46px; height: 46px; }

.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; }
.cal .dow { background: var(--cell); border-radius: 8px; padding: 14px 0; text-align: center; }
.cal-cell {
  position: relative; min-height: 118px; border-radius: 11px;
  background: var(--c-bg, var(--cell)); border: 1px solid var(--c-line, var(--line));
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 4px 10px;
  color: var(--text); text-align: center;
}
button.cal-cell:hover { border-color: #3d3d3d; }
button.cal-cell.s-green:hover { border-color: var(--green); }
button.cal-cell.s-red:hover { border-color: var(--red); }
button.cal-cell.s-yellow:hover { border-color: var(--yellow); }
.cal-cell.blank { background: var(--cell); border-color: var(--line-soft); }
.cal-cell.future { opacity: .45; }
.cal-cell.s-open.has-data { border-style: dashed; }
.cal-cell.is-today { box-shadow: inset 0 0 0 1px var(--blue); }
.cal-cell .dnum { font: 700 19px var(--sans); }
.cal-cell .val { font: 700 22px var(--sans); color: var(--c); letter-spacing: -.01em; }
.cal-cell .sub { font: 500 13px var(--mono); color: var(--c); opacity: .8; }
.cal-cell .open-tag { font: 500 12px var(--mono); color: var(--muted); }
.cal-cell .flag { position: absolute; top: 8px; right: 8px; width: 14px; height: 14px; color: var(--c); }
.cal-cell .dotline { display: inline-flex; align-items: center; gap: 6px; }
.cal-cell .dotline i { width: 7px; height: 7px; border-radius: 50%; background: var(--dc, var(--dim)); }
.cal-note { font-size: 13px; color: var(--muted); margin: -6px 0 14px; }
@media (max-width: 700px) {
  .cal { gap: 5px; }
  .cal .dow { padding: 9px 0; font-size: 10px; letter-spacing: .08em; }
  .cal-cell { min-height: 66px; padding: 8px 2px; gap: 3px; border-radius: 8px; }
  .cal-cell .dnum { font-size: 13px; }
  .cal-cell .val { font-size: 14px; }
  .cal-cell .sub, .cal-cell .open-tag { display: none; }
  .cal-cell .flag { top: 4px; right: 4px; width: 10px; height: 10px; }
  .month-nav .mlabel { min-width: 130px; font-size: 14px; }
  .month-nav .icon-btn { width: 40px; height: 40px; }
  .tabs button { padding: 8px 14px; font-size: 14px; }
}

/* ---------- adherence ---------- */
.adh { display: grid; gap: 4px 36px; margin-top: 16px; }
@media (min-width: 900px) { .adh { grid-template-columns: 1fr 1fr; } }
.adh-row { display: grid; grid-template-columns: 1fr auto; gap: 6px 14px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.adh-name { font-size: 14px; }
.adh-name .mono { color: var(--muted); font-size: 12px; margin-left: 6px; }
.adh-val { font: 600 14px var(--mono); color: var(--c); text-align: right; }
.adh-val .dim { font-weight: 500; font-size: 12px; margin-left: 6px; }
.adh-bar { grid-column: 1 / -1; height: 5px; border-radius: 3px; background: var(--raise); overflow: hidden; }
.adh-bar i { display: block; height: 100%; background: var(--c); border-radius: 3px; }

/* ---------- history table ---------- */
.tbl-wrap { overflow-x: auto; margin-top: 16px; border: 1px solid var(--line); border-radius: 12px; }
table.tbl { width: 100%; border-collapse: collapse; font: 13.5px var(--mono); }
.tbl th {
  font: 600 12px var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--label);
  text-align: left; padding: 15px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.tbl td { padding: 15px 12px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
.tbl tbody tr { cursor: pointer; }
.tbl tbody tr:hover td { background: #151515; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tag { font: 600 12px var(--mono); padding: 5px 9px; border-radius: 6px; background: var(--raise); border: 1px solid var(--line-2); color: var(--label); }
.badge { font: 700 12px var(--mono); padding: 5px 8px; border-radius: 6px; border: 1px solid var(--c-line); background: var(--c-bg); color: var(--c); }
.badge.s-open { border-style: dashed; color: var(--label); }
.tc { color: var(--c); }
.more-row { text-align: center; margin-top: 14px; }

/* ---------- modal ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.66);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fade .14s ease-out;
}
.sheet {
  width: 100%; max-width: 560px; max-height: calc(100vh - 40px); overflow: auto;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 18px; padding: 22px;
  animation: rise .18s ease-out;
}
.sheet.wide { max-width: 760px; }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.sheet-title { font: 700 20px var(--sans); letter-spacing: -.01em; }
.sheet-sub { font-size: 13.5px; color: var(--muted); margin-top: 4px; }
.sheet-foot { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 22px; }
.sheet-foot .spacer { flex: 1; }
.sheet .card { border: 0; padding: 0; background: transparent; }
@media (max-width: 600px) {
  .overlay { align-items: flex-end; padding: 0; }
  .sheet { max-width: none; border-radius: 18px 18px 0 0; max-height: 92vh; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
  .sheet-foot .btn { flex: 1; }
  .sheet-foot .spacer { display: none; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(12px); opacity: .6; } }
@media (prefers-reduced-motion: reduce) { .overlay, .sheet { animation: none; } }

/* settings */
.set-section { margin-top: 24px; }
.set-section h3 { margin: 0 0 4px; }
.set-help { font-size: 13px; color: var(--muted); margin: 4px 0 12px; }
.rule-row { display: grid; grid-template-columns: 1fr 70px 150px 40px; gap: 8px; margin-bottom: 8px; }
.rule-row .icon-btn { width: 100%; height: 100%; min-height: 42px; }
@media (max-width: 600px) {
  .rule-row { grid-template-columns: 1fr 64px 40px; padding-bottom: 10px; border-bottom: 1px solid var(--line-soft); }
  .rule-row .r-name { grid-column: 1 / -1; }
  .rule-row .r-scope { grid-column: 1 / 2; grid-row: 2; }
  .rule-row .r-pts { grid-row: 2; }
  .rule-row .r-del { grid-row: 2; }
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.inline-preview { font: 500 12px var(--mono); color: var(--muted); }
.seg.two { grid-template-columns: 1fr 1fr; }
.data-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.err { color: var(--red); font-size: 13px; margin-top: 10px; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 60; display: flex; align-items: center; gap: 14px;
  background: #1c1c1c; border: 1px solid var(--line-2); border-radius: 12px; padding: 12px 14px 12px 16px;
  font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.5); animation: rise .16s ease-out; max-width: calc(100vw - 32px);
}
.toast button { background: none; border: 0; color: var(--green); font-weight: 700; padding: 4px 6px; }
@media (max-width: 600px) {
  .toast { top: calc(12px + env(safe-area-inset-top)); bottom: auto; }
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
