:root {
  --bg: #F4F6FA; --surface: #FFFFFF; --surface-alt: #EEF1F7; --border: #E1E5EE; --text: #1F2430; --muted: #5E6678;
  --primary: #3D6BFF; --primary-hover: #2F55D6; --on-primary: #fff; --task: #3D6BFF; --event: #8A5CF6; --income: #12915A; --expense: #D63A40; --warning: #B7740A;
  --side-bg: #1B2138; --side-text: #C6CCE0; --side-active: #2B335A; --shadow: 0 2px 10px rgba(20, 30, 60, .08);
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #151824; --surface: #1E2233; --surface-alt: #262B40; --border: #333A54; --text: #E7E9F2; --muted: #A2A9C4;
  --primary: #6A8CFF; --primary-hover: #7C99FF; --on-primary: #0E1220; --task: #6A8CFF; --event: #A889F8; --income: #3ECF8E; --expense: #F26B70; --warning: #F7B955;
  --side-bg: #10131F; --side-text: #9AA1BD; --side-active: #262B40; --shadow: 0 2px 10px rgba(0, 0, 0, .4);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
body.modal-open, body.locked { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
[hidden] { display: none !important; }

#app { display: flex; min-height: 100vh; min-height: 100dvh; }
.content { flex: 1; min-width: 0; padding: calc(12px + var(--safe-t)) 16px calc(150px + var(--safe-b)); max-width: 1100px; margin: 0 auto; width: 100%; }
.view { display: flex; flex-direction: column; gap: 12px; }
.view-title { font-size: 1.35rem; margin: 4px 0; }
.section-title { font-size: 1.15rem; margin-top: 12px; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; }
.pos { color: var(--income); } .neg { color: var(--expense); } .warn { color: var(--warning); }
.grow { flex: 1; min-width: 0; }

/* Навигация */
.sidebar { display: none; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--surface); border-top: 1px solid var(--border); padding-bottom: var(--safe-b); z-index: 20; }
.tab { flex: 1; border: 0; background: none; padding: 8px 2px 6px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .72rem; color: var(--muted); min-height: 52px; }
.tab .ti { font-size: 1.3rem; line-height: 1; }
.tab.active { color: var(--primary); font-weight: 600; }
.fabs { position: fixed; right: 14px; bottom: calc(66px + var(--safe-b)); display: flex; flex-direction: column; gap: 10px; z-index: 19; }
.fab { width: 56px; height: 56px; border-radius: 50%; border: 0; font-size: 1.6rem; box-shadow: 0 4px 14px rgba(0, 0, 0, .3); display: grid; place-items: center; }
.fab.mic { background: var(--primary); color: var(--on-primary); }
.fab.plus { background: var(--surface); color: var(--primary); border: 2px solid var(--primary); font-size: 2rem; }
.alert { border: 1px solid var(--warning); background: var(--surface-alt); color: var(--warning); border-radius: 10px; padding: 8px 12px; width: 100%; text-align: left; margin-bottom: 8px; font-weight: 600; }

@media (min-width: 900px) {
  .sidebar { display: flex; flex-direction: column; gap: 6px; width: 240px; flex: none; background: var(--side-bg); color: var(--side-text); padding: 16px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
  .tabbar { display: none; }
  .content { padding: 20px 28px 100px; }
  .fabs { bottom: 24px; right: 24px; }
  .fab.plus { display: none; }
  .brand { display: flex; align-items: center; gap: 10px; color: #fff; margin-bottom: 8px; }
  .brand small { display: block; color: var(--side-text); font-size: .75rem; }
  .logo { width: 38px; height: 38px; border-radius: 10px; background: #3D6BFF; display: grid; place-items: center; font-weight: 700; color: #fff; }
  .nav-btn { display: flex; gap: 10px; align-items: center; background: none; border: 0; color: var(--side-text); padding: 10px 12px; border-radius: 10px; text-align: left; }
  .nav-btn:hover { background: var(--side-active); } .nav-btn.active { background: var(--side-active); color: #fff; font-weight: 600; }
  .sidebar .btn { background: var(--side-active); color: #fff; border-color: transparent; }
  .sidebar .btn.primary { background: #3D6BFF; }
}

/* Кнопки и поля */
.btn { border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 10px 14px; min-height: 44px; font-weight: 500; }
.btn:hover { background: var(--surface-alt); }
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); font-weight: 600; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { color: var(--expense); border-color: var(--expense); }
.btn.small { min-height: 36px; padding: 6px 10px; } .btn.icon { min-width: 44px; font-size: 1.3rem; padding: 6px; }
.btn.wide { width: 100%; } .btn.left { text-align: left; } .btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { border: 0; background: none; font-size: 1.2rem; padding: 8px; min-width: 44px; min-height: 44px; border-radius: 50%; }
input[type=text], input[type=number], input[type=date], input[type=time], input[type=password], select, textarea {
  width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; min-height: 44px; }
textarea { resize: vertical; }
input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--primary); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; } .row.nowrap { flex-wrap: nowrap; } .row.end { justify-content: flex-end; } .row.space { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.field { display: flex; flex-direction: column; gap: 4px; } .field.inline { flex-direction: row; align-items: center; gap: 8px; } .field.inline input { width: 80px; }
.lbl { font-size: .8rem; color: var(--muted); font-weight: 600; }
.check { display: flex; align-items: center; gap: 8px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; } .toolbar input[type=date] { width: auto; }
.seg { display: inline-flex; background: var(--surface-alt); border-radius: 12px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg-btn { border: 0; background: none; padding: 8px 12px; border-radius: 10px; min-height: 40px; }
.seg-btn.active { background: var(--primary); color: var(--on-primary); font-weight: 600; }
.mic-btn { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface-alt); font-size: 1.1rem; }
.mic-btn.rec, .mic-big.rec { background: var(--expense); color: #fff; animation: pulse 1.1s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 10px rgba(214, 58, 64, .2); } }
@media (prefers-reduced-motion: reduce) { .mic-btn.rec, .mic-big.rec { animation: none; } }

/* Модальные окна */
.overlay { position: fixed; inset: 0; background: rgba(10, 14, 28, .55); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--surface); width: 100%; max-width: 560px; max-height: 92vh; max-height: 92dvh; overflow-y: auto; border-radius: 18px 18px 0 0; padding: 12px 16px calc(16px + var(--safe-b)); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; position: sticky; top: -12px; background: var(--surface); padding-top: 4px; z-index: 1; }
@media (min-width: 700px) { .overlay { align-items: center; } .sheet { border-radius: 18px; } }
.form { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.confirm { display: flex; flex-direction: column; gap: 14px; }
#toasts { position: fixed; left: 12px; right: 12px; bottom: calc(80px + var(--safe-b)); display: flex; flex-direction: column; gap: 8px; z-index: 80; pointer-events: none; align-items: center; }
.toast { pointer-events: auto; background: #20263d; color: #fff; padding: 10px 14px; border-radius: 12px; display: flex; gap: 12px; align-items: center; max-width: 520px; box-shadow: 0 4px 16px rgba(0, 0, 0, .35); }
.toast-act { background: none; border: 0; color: #9db4ff; font-weight: 700; padding: 4px 6px; }

/* Голос */
.voice { display: flex; flex-direction: column; gap: 10px; }
.mic-big { width: 88px; height: 88px; border-radius: 50%; border: 0; background: var(--primary); color: var(--on-primary); font-size: 2.2rem; }
.voice-status { min-height: 1.4em; text-align: center; color: var(--muted); }
.preview dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; } .preview dt { color: var(--muted); } .preview dd { margin: 0; font-weight: 600; }
.preview-title { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chip { padding: 2px 8px; border-radius: 999px; font-size: .8rem; background: var(--surface-alt); }
.chip.type-expense { color: var(--expense); } .chip.type-income { color: var(--income); } .chip.type-event { color: var(--event); } .chip.type-task { color: var(--task); }
.answer { font-size: 1.1rem; font-weight: 600; }
.examples ul { padding-left: 18px; color: var(--muted); font-size: .9rem; }

/* День */
.grid-head { display: none; }
.slot { display: grid; grid-template-columns: 1fr; gap: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 8px; }
.slot.routine { background: var(--surface-alt); border-style: dashed; }
.slot-time { display: flex; gap: 6px; } .slot-time input { width: 110px; min-height: 36px; padding: 4px 8px; color: var(--muted); font-weight: 600; }
.lane-label { display: block; font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 2px; }
.num { text-align: center; color: var(--muted); font-weight: 700; display: none; }
.cell { display: flex; flex-direction: column; gap: 4px; }
.add-here { background: none; border: 1px dashed var(--border); border-radius: 8px; color: var(--muted); text-align: left; padding: 6px 10px; min-height: 36px; }
.chip-item { display: flex; align-items: stretch; background: var(--surface-alt); border-left: 4px solid var(--task); border-radius: 8px; }
.chip-item.t-event { border-left-color: var(--event); } .chip-item.t-expense { border-left-color: var(--expense); } .chip-item.t-income { border-left-color: var(--income); }
.chip-item.is-done .chip-title { text-decoration: line-through; color: var(--muted); }
.chip-main { flex: 1; text-align: left; background: none; border: 0; padding: 8px 10px; display: flex; justify-content: space-between; gap: 8px; min-height: 40px; }
.chip-time { color: var(--muted); font-size: .85rem; flex: none; }
.tick { width: 40px; border: 0; background: none; font-weight: 700; color: var(--income); position: relative; }
.tick::before { content: ""; position: absolute; width: 22px; height: 22px; border: 2px solid var(--muted); border-radius: 50%; left: 9px; top: 50%; transform: translateY(-50%); }
.tick { line-height: 1; padding-left: 0; z-index: 0; } .is-done .tick::before { border-color: var(--income); }
.tick { text-align: center; }
.allday { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 8px; display: flex; flex-direction: column; gap: 4px; }
.allday h3 { font-size: .9rem; color: var(--muted); }
.routine-body { display: flex; flex-direction: column; gap: 6px; }
.results { flex-direction: column; }
@media (min-width: 760px) {
  .grid-head { display: grid; grid-template-columns: 130px 1fr 32px 1fr; gap: 8px; font-weight: 700; color: var(--muted); padding: 0 8px; }
  .slot:not(.routine) { grid-template-columns: 130px 1fr 32px 1fr; align-items: start; }
  .slot:not(.routine) .slot-time { flex-direction: column; } .slot-time input { width: 110px; }
  .slot.routine { grid-template-columns: 130px 1fr; }
  .lane-label { display: none; } .num { display: block; padding-top: 10px; }
}

/* Месяц / год */
.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; } .month-grid.wd span { text-align: center; color: var(--muted); font-weight: 600; font-size: .85rem; }
.day-cell { min-height: 64px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 4px; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; overflow: hidden; text-align: left; }
.day-cell.outside { opacity: .5; } .day-cell.today { border: 2px solid var(--primary); }
.dn { font-weight: 700; } .dot-count { font-size: .68rem; color: var(--primary); } .net { font-size: .66rem; font-weight: 700; } .net.pos { color: var(--income); } .net.neg { color: var(--expense); }
@media (min-width: 700px) { .day-cell { min-height: 84px; padding: 6px 8px; } .dot-count, .net { font-size: .8rem; } }
.year-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.mini-title { background: none; border: 0; font-weight: 700; text-align: left; padding: 4px 0; min-height: 36px; }
.mini-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; font-size: .78rem; } .mini-grid.wd { color: var(--muted); }
.mini-day { border: 0; background: none; border-radius: 6px; padding: 5px 0; min-height: 30px; } .mini-day.has { background: var(--surface-alt); font-weight: 700; color: var(--primary); } .mini-day.today { outline: 2px solid var(--primary); }

/* Аналитика */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; } .stat strong { font-size: 1.25rem; }
.pie-wrap { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; } .pie { width: 170px; height: 170px; flex: none; } .pie-hole { fill: var(--surface); }
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 200px; } .legend li { display: flex; gap: 8px; align-items: center; } .legend i { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.bars { width: 100%; height: auto; } .bar-income { fill: var(--income); } .bar-expense { fill: var(--expense); } .bar-label { fill: var(--muted); font-size: 11px; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; } .sw.income { background: var(--income); } .sw.expense { background: var(--expense); }
.meter { height: 10px; border-radius: 99px; background: var(--surface-alt); overflow: hidden; } .meter i { display: block; height: 100%; background: var(--primary); }
.meter.warn i { background: var(--warning); } .meter.over i { background: var(--expense); }
.budget-row input { width: 130px; } .goal input { flex: 1; }
.import-row { gap: 6px; } .file-in { padding: 10px; border: 2px dashed var(--border); border-radius: 12px; background: var(--surface); }
.settings-sec { gap: 10px; } ul.plain { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.profile-row { display: flex; gap: 6px; } .profile-row.active .btn.grow { border-color: var(--primary); font-weight: 700; }
.profile-sel { width: 100%; background: var(--side-active); color: #fff; border: 0; }
.more-list { display: flex; flex-direction: column; gap: 6px; } .more-item { display: flex; gap: 12px; align-items: center; background: var(--surface-alt); border: 0; border-radius: 12px; padding: 14px; text-align: left; min-height: 52px; }

/* Блокировка */
.lock-screen { position: fixed; inset: 0; background: var(--bg); z-index: 100; display: grid; place-items: center; padding: 20px; }
.lock-box { width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 12px; text-align: center; } .lock-icon { font-size: 3rem; }
.pin-input { text-align: center; font-size: 1.6rem; letter-spacing: .4em; }

@media print { .sidebar, .tabbar, .fabs, .toolbar, #toasts, .btn { display: none !important; } .content { padding: 0; max-width: none; } body { background: #fff; color: #000; } }
