:root {
  --bg: #0f1419;
  --card: #182029;
  --card2: #1f2933;
  --line: #2a3541;
  --text: #e6edf3;
  --muted: #8b98a5;
  --green: #2fbf71;
  --red: #ef5b5b;
  --amber: #f2b33d;
  --accent: #3fa7d6;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.error { color: var(--red); min-height: 1.2em; font-size: 14px; }
a { color: var(--accent); }

.loading { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--bg); color: var(--muted); z-index: 50; }

/* Login */
.login-box { max-width: 360px; margin: 0 auto; padding: calc(64px + var(--safe-t)) 24px 24px; text-align: center; }
.login-logo { width: 72px; height: 72px; border-radius: 18px; }
.login-box h1 { margin: 12px 0 4px; font-size: 26px; }
.login-box form { margin: 28px 0 16px; display: flex; flex-direction: column; gap: 10px; }
input, select { width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font-size: 16px; }
.btn-primary { padding: 13px; border: 0; border-radius: 10px; background: var(--accent); color: #fff;
  font-size: 16px; font-weight: 600; }
.btn-secondary { padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card2); color: var(--text); font-size: 15px; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; gap: 8px; align-items: center;
  padding: calc(10px + var(--safe-t)) 14px 10px; background: rgba(15,20,25,.95);
  border-bottom: 1px solid var(--line); backdrop-filter: blur(8px); }
.topbar select { flex: 1; font-weight: 600; }
.icon-btn { width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font-size: 20px; }
.demo-banner { background: #3a2f12; color: var(--amber); text-align: center; padding: 6px; font-size: 13px; }

main { padding: 14px 14px calc(84px + var(--safe-b)); max-width: 640px; margin: 0 auto; }

/* Tab bar */
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: flex;
  background: rgba(15,20,25,.97); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
.tabbar button { flex: 1; background: none; border: 0; color: var(--muted); padding: 8px 0 10px;
  font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tabbar button span { font-size: 20px; line-height: 1.2; }
.tabbar button.active { color: var(--accent); }

/* Cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.hero .label { color: var(--muted); font-size: 13px; }
.hero .big { font-size: 30px; font-weight: 700; letter-spacing: -.5px; margin: 2px 0 6px; }
.hero .row { display: flex; gap: 16px; flex-wrap: wrap; font-size: 15px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; }
.tile .k { color: var(--muted); font-size: 12px; }
.tile .v { font-size: 19px; font-weight: 650; margin-top: 2px; }
.tile .s { color: var(--muted); font-size: 12px; }
.section-title { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 18px 2px 8px; }

.chart svg { width: 100%; height: 150px; display: block; }

.list .item { display: flex; justify-content: space-between; align-items: center; padding: 10px 2px;
  border-bottom: 1px solid var(--line); gap: 10px; }
.list .item:last-child { border-bottom: 0; }
.list .l1 { font-weight: 600; }
.list .l2 { color: var(--muted); font-size: 12px; }
.list .r { text-align: right; font-weight: 650; white-space: nowrap; }

.sync { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 6px 2px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.dot.ok { background: var(--green); } .dot.warn { background: var(--amber); } .dot.bad { background: var(--red); }

/* Calendar */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-head h2 { margin: 0; font-size: 19px; }
.cal-head button { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font-size: 18px; }
.target { margin-bottom: 12px; }
.target .bar { height: 8px; background: var(--card2); border-radius: 6px; overflow: hidden; margin: 8px 0 6px; }
.target .bar i { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
.badge-stop { display: inline-block; background: #143d29; color: var(--green); border: 1px solid #1f6a45;
  padding: 6px 10px; border-radius: 999px; font-weight: 700; font-size: 13px; margin-top: 4px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-grid .dow { text-align: center; color: var(--muted); font-size: 11px; padding-bottom: 2px; }
.day { min-height: 54px; background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  padding: 4px 3px; display: flex; flex-direction: column; justify-content: space-between; cursor: pointer; }
.day.empty { background: transparent; border-color: transparent; cursor: default; }
.day .d { font-size: 11px; color: var(--muted); }
.day .p { font-size: 11px; font-weight: 700; text-align: right; overflow: hidden; }
.day.win { background: #13281d; border-color: #1f5a3a; }
.day.loss { background: #2d1719; border-color: #6a2a2e; }
.day.today { outline: 2px solid var(--accent); outline-offset: -2px; }
.day.sel { box-shadow: 0 0 0 2px var(--amber) inset; }

/* Today / rules */
.today-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0;
  border-bottom: 1px solid var(--line); }
.today-row:last-child { border-bottom: 0; }
.pill { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.pill.ok { background: #143d29; color: var(--green); }
.pill.stop { background: #45191c; color: #ff8a8a; }
.pill.wait { background: #3a2f12; color: var(--amber); }
.pill.off { background: var(--card2); color: var(--muted); }
.today-big .pill { font-size: 14px; padding: 6px 12px; }

/* Journal */
.j-entry { cursor: pointer; }
.j-top { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }
.j-main { font-weight: 650; margin: 4px 0 2px; }
.j-notes { color: var(--muted); font-size: 13px; margin-top: 4px; overflow: hidden; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { background: var(--card2); border: 1px solid var(--line); color: var(--muted); padding: 2px 8px;
  border-radius: 999px; font-size: 12px; }
.q { display: inline-block; min-width: 22px; text-align: center; border-radius: 6px; font-size: 12px; font-weight: 800; padding: 1px 5px; }
.q.A { background: #143d29; color: var(--green); } .q.B { background: #3a2f12; color: var(--amber); }
.q.C { background: #45191c; color: #ff8a8a; }
.thumbs { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.thumbs img { width: 72px; height: 54px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); background: var(--card2); }
.mini-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.mini-table th { color: var(--muted); font-weight: 500; font-size: 12px; text-align: right; padding: 4px 2px; }
.mini-table th:first-child, .mini-table td:first-child { text-align: left; }
.mini-table td { text-align: right; padding: 6px 2px; border-top: 1px solid var(--line); }
.clickable { cursor: pointer; }

/* Sheet (editor) */
.sheet { position: fixed; inset: 0; z-index: 30; background: var(--bg); overflow-y: auto;
  padding: calc(12px + var(--safe-t)) 14px calc(24px + var(--safe-b)); }
.sheet-inner { max-width: 640px; margin: 0 auto; }
.sheet h2 { font-size: 19px; margin: 4px 0 14px; }
.field { margin-bottom: 12px; }
.field label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
textarea { width: 100%; min-height: 110px; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font: inherit; font-size: 16px; resize: vertical; }
.seg { display: flex; gap: 6px; }
.seg button { flex: 1; padding: 11px 0; border-radius: 10px; border: 1px solid var(--line); background: var(--card);
  color: var(--text); font-size: 15px; font-weight: 600; }
.seg button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.seg button.on.sell { background: var(--red); border-color: var(--red); }
.seg button.on.buy { background: var(--green); border-color: var(--green); }
.shot { position: relative; display: inline-block; }
.shot button { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; border: 0;
  background: var(--red); color: #fff; font-size: 13px; line-height: 22px; padding: 0; }
.sheet-actions { display: flex; gap: 8px; margin-top: 16px; }
.sheet-actions button { flex: 1; }
.btn-danger { padding: 10px 14px; border: 1px solid #6a2a2e; border-radius: 10px; background: #2d1719; color: #ff8a8a; font-size: 15px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.grid2 .field { margin-bottom: 0; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.check input { width: auto; }

/* Onboarding */
.onb-dots { display: flex; gap: 6px; margin: 4px 0 14px; }
.onb-dots i { flex: 1; height: 4px; border-radius: 4px; background: var(--card2); }
.onb-dots i.on { background: var(--amber); }
.onb-hero { width: 100%; height: 200px; object-fit: cover; object-position: 50% 22%; border-radius: 14px; border: 1px solid var(--line); margin-bottom: 14px; }
.choice { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 4px; }
.choice button { text-align: left; padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--text); font-size: 15px; }
.choice button b { display: block; font-size: 16px; margin-bottom: 2px; }
.choice button.on { border-color: var(--amber); box-shadow: 0 0 0 1px var(--amber) inset; }
.check-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; font-size: 14px; }
.check-row .box { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line); flex: none; display: flex; align-items: center; justify-content: center; font-size: 12px; }
.check-row.done .box { background: var(--green); border-color: var(--green); color: #0f1419; }
.check-row.done span:not(.box) { color: var(--muted); text-decoration: line-through; }

/* Settings */
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0;
  border-bottom: 1px solid var(--line); }
.set-row:last-child { border-bottom: 0; }
.set-row input { width: 96px; text-align: right; }
.inline { display: flex; gap: 8px; align-items: center; }
