:root {
  --bg: #f4f6f9; --surface: #fff; --surface-2: #eef1f5; --line: #dfe4eb;
  --text: #17202b; --muted: #5d6b7c;
  --accent: #215caf; --accent-soft: #e4ecf8; --on-accent: #fff;
  --green: #2e7d4f; --green-soft: #e2f2e8; --amber: #a86a00; --amber-soft: #fbf0d9;
  --red: #b7352d; --red-soft: #fbe7e5;
  --radius: 12px; --shadow: 0 1px 2px rgb(16 24 40 / .06), 0 1px 6px rgb(16 24 40 / .04);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141a; --surface: #182029; --surface-2: #212b36; --line: #2c3845;
    --text: #e8edf3; --muted: #9aa8b8;
    --accent: #6ea4ee; --accent-soft: #1d2f48; --on-accent: #0b1420;
    --green: #5fc48a; --green-soft: #17301f; --amber: #e2ac4a; --amber-soft: #33280f;
    --red: #f0847b; --red-soft: #3a1c1a; --shadow: none;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.55rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; }
h3 { font-size: .98rem; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); } .small { font-size: .82rem; margin-top: 10px; }
.pos { color: var(--green); } .neg { color: var(--red); } .warn-text { color: var(--amber); }
small { font-size: .8rem; }

/* ---- shell ---- */
.sidebar { position: fixed; inset: 0 auto 0 0; width: 224px; background: var(--surface); border-right: 1px solid var(--line); padding: 20px 12px; display: flex; flex-direction: column; gap: 20px; z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; padding: 0 8px; }
.logo { width: 28px; height: 28px; border-radius: 8px; background: var(--accent) linear-gradient(transparent 28%, var(--on-accent) 28% 38%, transparent 38% 47%, var(--on-accent) 47% 57%, transparent 57% 66%, var(--on-accent) 66% 76%, transparent 76%) no-repeat 7px 0 / 14px 100%; }
nav { display: flex; flex-direction: column; gap: 2px; }
nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; color: var(--muted); text-decoration: none; font-weight: 500; }
nav a:hover { background: var(--surface-2); color: var(--text); }
nav a.on { background: var(--accent-soft); color: var(--accent); }
nav a:first-child { font-weight: 650; margin-bottom: 8px; }
nav svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sync { margin-top: auto; align-self: flex-start; font-size: .78rem; padding: 3px 10px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.sync.ok { background: var(--green-soft); color: var(--green); }
.sync.warn, .sync.local { background: var(--amber-soft); color: var(--amber); }
main { margin-left: 224px; padding: 28px clamp(16px, 3vw, 40px) 60px; max-width: 1500px; display: flex; flex-direction: column; gap: 18px; outline: none; }
.loading { color: var(--muted); padding: 40px 0; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head.wrap { flex-wrap: wrap; }
.link { font-size: .88rem; text-decoration: none; white-space: nowrap; }
.sub-head { margin: 16px 0 8px; font-size: .86rem; color: var(--muted); font-weight: 600; display: flex; justify-content: space-between; gap: 8px; }
.sub-head .muted { font-weight: 400; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.two-col.inner { gap: 28px; }

.btn { border: 1px solid var(--line); background: var(--surface); padding: 8px 14px; border-radius: 9px; font-weight: 550; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { padding: 5px 10px; font-size: .84rem; }
.btn.ghost { border-color: transparent; background: none; }
.btn.danger { color: var(--red); }
.icon-btn { border: 0; background: none; width: 30px; height: 30px; border-radius: 8px; color: var(--muted); flex: none; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; padding: 7px 12px; border-right: 1px solid var(--line); font-weight: 500; }
.seg button:last-child { border-right: 0; }
.seg button:hover { background: var(--surface-2); }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.seg.filter { align-self: flex-start; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; text-align: left; box-shadow: var(--shadow); }
button.stat:hover { border-color: var(--accent); }
.stat > span { font-size: .82rem; color: var(--muted); }
.stat > b { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.stat > small { color: var(--muted); }
.stat .bar { margin-top: 4px; }
.bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.bar.green i { background: var(--green); } .bar.amber i { background: var(--amber); } .bar.red i { background: var(--red); }
.alert { background: var(--accent-soft); border-radius: var(--radius); padding: 12px 16px; }
.alert.warn { background: var(--amber-soft); }
.alert .sess-list { margin-top: 10px; }
.empty { text-align: center; padding: 28px 16px; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); display: grid; gap: 14px; justify-items: center; }
.empty p { max-width: 52ch; }
.tag { font-size: .72rem; font-weight: 650; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.tag.study { background: var(--accent-soft); color: var(--accent); }
.tag.sports { background: var(--green-soft); color: var(--green); }
.tag.personal { background: var(--amber-soft); color: var(--amber); }

/* ---- weekly plan ---- */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.day { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); min-height: 260px; display: flex; flex-direction: column; min-width: 0; scroll-margin-top: 12px; }
.day.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.day > header { display: flex; align-items: baseline; gap: 6px; padding: 10px 6px 6px 12px; }
.day .dow { font-weight: 700; } .day.today .dow { color: var(--accent); }
.day .dnum { color: var(--muted); font-size: .84rem; flex: 1; }
.day.past .items { opacity: .72; }
.items { padding: 0 6px 8px; display: flex; flex-direction: column; gap: 5px; }
.none { color: var(--muted); font-size: .82rem; padding: 4px 6px; }
.item { --c: var(--accent); display: flex; align-items: flex-start; gap: 6px; background: color-mix(in srgb, var(--c) 11%, var(--surface)); border-left: 3px solid var(--c); border-radius: 7px; padding: 6px 6px 6px 8px; min-width: 0; }
.item.sport { --c: var(--green); } .item.todo { --c: var(--muted); } .item.goal { --c: var(--amber); } .item.event { --c: #7a5cc4; }
.item.deadline { background: var(--c); border-left-color: var(--c); }
.item.deadline .item-body, .item.deadline .sub { color: #fff; }
.item-body { border: 0; background: none; padding: 0; text-align: left; display: grid; gap: 1px; min-width: 0; flex: 1; }
.item .time { font-size: .74rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.item .title { font-weight: 600; font-size: .88rem; overflow-wrap: anywhere; }
.item .sub { font-size: .76rem; color: var(--muted); overflow-wrap: anywhere; }
.item.done .title, .item.skipped .title { text-decoration: line-through; opacity: .65; }
.item .title span { display: inline-block; text-decoration: none; }
.item.skipped { --c: var(--muted); }
.item.late .sub { color: var(--amber); font-weight: 600; }
.check { width: 20px; height: 20px; flex: none; border-radius: 6px; border: 1.5px solid var(--muted); background: var(--surface); font-size: .78rem; line-height: 1; padding: 0; margin-top: 1px; color: var(--on-accent); }
.check.on { background: var(--green); border-color: var(--green); }
.goal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.goal-mini { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 12px; text-align: left; display: grid; gap: 6px; justify-items: start; }
.goal-mini .bar { width: 100%; } .goal-mini small { color: var(--muted); }
.goal-mini:hover, .goal-row:hover, .row:not(.static):hover, .sess:hover { background: var(--surface-2); }

/* ---- study ---- */
.course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.course { background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--c); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 10px; box-shadow: var(--shadow); }
.course header, .course footer { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: .84rem; color: var(--muted); }
.meta b { color: var(--text); }
.dots { color: var(--c, var(--accent)); letter-spacing: 1px; font-size: .7rem; } .dots i { color: var(--line); font-style: normal; }
.balance { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; background: var(--surface-2); border-radius: 9px; padding: 10px; }
.balance div { display: grid; } .balance small { color: var(--muted); font-size: .72rem; } .balance b { font-variant-numeric: tabular-nums; }
.balance .neg b { color: var(--red); } .balance .pos b { color: var(--green); }
.plan-day { padding: 10px 0; border-top: 1px solid var(--line); }
.plan-day:first-of-type { border-top: 0; padding-top: 0; }
.plan-day header { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.plan-day header .muted { flex: 1; }
.sess-list { display: grid; gap: 5px; }
.sess-wrap { display: grid; grid-template-columns: 56px 1fr; align-items: center; gap: 6px; }
.sess { --c: var(--accent); display: grid; grid-template-columns: 96px 1fr auto; gap: 8px; align-items: center; text-align: left; border: 0; border-left: 3px solid var(--c); background: color-mix(in srgb, var(--c) 9%, var(--surface)); border-radius: 7px; padding: 7px 10px; width: 100%; }
.sess .time { font-variant-numeric: tabular-nums; font-size: .82rem; color: var(--muted); }
.sess .title { font-weight: 600; overflow-wrap: anywhere; } .sess .sub { font-size: .82rem; color: var(--muted); }
.sess.done .sub { color: var(--green); font-weight: 600; } .sess.skipped .title { text-decoration: line-through; opacity: .6; }
.avail { display: grid; gap: 14px; }
fieldset { border: 0; padding: 0; margin: 0; } legend { font-size: .84rem; font-weight: 600; margin-bottom: 6px; padding: 0; }
.wd-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.wd-grid label { display: grid; gap: 3px; text-align: center; font-size: .78rem; color: var(--muted); }
.wd-grid input { text-align: center; padding: 8px 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { background: var(--surface-2); border-radius: 99px; padding: 3px 4px 3px 10px; font-size: .84rem; display: inline-flex; align-items: center; gap: 4px; }
.chip button { border: 0; background: none; color: var(--muted); border-radius: 99px; width: 22px; height: 22px; padding: 0; }

/* ---- goals ---- */
.goal-list { display: grid; gap: 6px; }
.goal-row { display: grid; grid-template-columns: auto minmax(0, 1.4fr) minmax(60px, 1fr) auto; gap: 12px; align-items: center; border: 1px solid var(--line); background: var(--surface); border-radius: 9px; padding: 10px 12px; text-align: left; }
.goal-row small { color: var(--muted); white-space: nowrap; } .goal-row.done b { text-decoration: line-through; opacity: .65; }
.goal-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 12px; }
.goal { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 10px; box-shadow: var(--shadow); align-content: start; }
.goal header { display: flex; gap: 6px; align-items: center; } .goal header .icon-btn { margin-left: auto; }
.goal footer { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: .86rem; }
.goal.done h3 { text-decoration: line-through; opacity: .65; }
.stepper { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; flex: none; }
.stepper button { border: 0; background: none; width: 32px; height: 28px; font-weight: 700; } .stepper button:hover { background: var(--surface-2); }

/* ---- budget ---- */
.stat.big > b { font-size: 1.6rem; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; background: var(--surface-2); border-radius: 10px; padding: 12px 14px; }
.kpis div { display: grid; } .kpis small { color: var(--muted); } .kpis b { font-size: 1.08rem; font-variant-numeric: tabular-nums; }
.rows { display: grid; gap: 2px; } .rows.compact { max-height: 340px; overflow: auto; }
.row { display: flex; gap: 10px; align-items: center; border: 0; background: none; text-align: left; padding: 8px; border-radius: 8px; width: 100%; }
.row .grow { flex: 1; display: grid; min-width: 0; } .row small { color: var(--muted); }
.amt { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; display: grid; justify-items: end; }
.amt.income { color: var(--green); } .amt.expense { color: var(--red); }
.cat { display: grid; grid-template-columns: minmax(80px, 130px) 1fr auto; gap: 10px; align-items: center; padding: 5px 0; font-size: .9rem; }
.cat b { font-variant-numeric: tabular-nums; font-weight: 600; }
.trend { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; height: 150px; margin-top: 16px; }
.tcol { display: grid; grid-template-rows: 1fr auto; gap: 4px; text-align: center; font-size: .74rem; color: var(--muted); }
.tbars { display: flex; align-items: flex-end; justify-content: center; gap: 2px; border-bottom: 1px solid var(--line); }
.tbars i { width: min(14px, 40%); border-radius: 3px 3px 0 0; min-height: 1px; }
.tbars .in, .legend .in::before { background: var(--green); } .tbars .out, .legend .out::before { background: var(--red); }
.legend { display: flex; gap: 16px; font-size: .8rem; color: var(--muted); margin-top: 8px; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }

/* ---- sports ---- */
.train { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.train-day { display: grid; gap: 6px; align-content: start; }
.train-day header { display: grid; padding: 0 2px 2px; } .train-day.today header b { color: var(--accent); }
.rest { border: 1px dashed var(--line); background: none; border-radius: 8px; padding: 10px 6px; color: var(--muted); font-size: .8rem; }
.rest:hover { border-color: var(--accent); color: var(--accent); }
.spark { display: flex; align-items: flex-end; gap: 5px; height: 34px; margin-top: 4px; }
.spark i { flex: 1; max-width: 26px; background: var(--green); border-radius: 3px; opacity: .55; } .spark i:last-child { opacity: 1; }

/* ---- forms & dialog ---- */
input:not([type=checkbox]):not([type=range]), select, textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); min-width: 0; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
input[type=range] { width: 100%; accent-color: var(--accent); }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { grid-column: 1 / -1; display: grid; gap: 4px; align-content: start; } .field.half { grid-column: auto; }
.field > span { font-size: .84rem; font-weight: 600; } .field small { color: var(--muted); }
.field.check { grid-template-columns: auto 1fr; align-items: center; gap: 8px; } .field.check input { order: -1; }
.field output { font-size: .84rem; color: var(--muted); }
.modal { border: 0; border-radius: 14px; padding: 0; width: min(520px, calc(100vw - 24px)); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgb(0 0 0 / .3); }
.modal::backdrop { background: rgb(10 16 24 / .5); }
.modal form { padding: 18px 20px; display: grid; gap: 14px; }
.modal header { display: flex; justify-content: space-between; align-items: center; }
.modal .intro { color: var(--muted); }
.modal footer { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
.spacer { flex: 1; }
.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 99px; font-size: .9rem; z-index: 50; box-shadow: 0 6px 20px rgb(0 0 0 / .25); max-width: calc(100vw - 32px); }

/* ---- tablet & phone ---- */
@media (max-width: 1180px) {
  .week { grid-template-columns: repeat(4, minmax(0, 1fr)); } .day { min-height: 150px; }
  .train { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 899px) {
  .sidebar { width: auto; padding: 0; border: 0; display: block; }
  .brand, .long { display: none; }
  nav { flex-direction: row; flex: 1; justify-content: space-around; }
  nav a { flex-direction: column; gap: 2px; font-size: .68rem; padding: 6px 4px; flex: 1; text-align: center; }
  nav a:first-child { margin: 0; }
  .sync { position: absolute; top: 10px; right: 12px; margin: 0; }
  .sidebar { position: static; } nav { position: fixed; inset: auto 0 0 0; z-index: 5; background: var(--surface); border-top: 1px solid var(--line); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
  main { margin: 0; padding: 18px 16px calc(96px + env(safe-area-inset-bottom)); }
  .page-head { padding-right: 84px; } .page-head .head-actions { margin-right: -84px; }
  .two-col { grid-template-columns: minmax(0, 1fr); }
  .week, .train { grid-template-columns: minmax(0, 1fr); }
  .day { min-height: 0; } .day .items { padding-bottom: 10px; }
  .train-day { grid-template-columns: 92px 1fr; align-items: start; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } .stat.big { grid-column: 1 / -1; }
  .goal-row { grid-template-columns: auto minmax(0, 1fr); } .goal-row .bar { grid-column: 1 / -1; } .goal-row small { grid-column: 1 / -1; }
  .sess { grid-template-columns: 88px 1fr auto; }
  .balance small { font-size: .68rem; }
  .modal footer .btn { flex: 1 1 auto; }
}
