/* Money Lab в оформлении HomeHub (home.pervomay.org, версия 24.10.2026):
   бумага цвета слоновой кости, карточки — кремовый картон с сепией, текст — «чернила»,
   выделение — тёплая сепия, плавающая панель закладок, освещение по времени суток.
   Значения взяты из итоговых слоёв HomeHub (css/app.css, body.home-wall). Тёмной темы нет —
   как и в HomeHub, страница всегда «бумажная». */
:root {
  /* бумага и чернила */
  --paper: #f1e9d6;
  --ink: #2b241c;
  --ink-soft: rgba(43, 36, 28, .62);
  --ink-faint: rgba(43, 36, 28, .42);
  /* картон */
  --card: rgba(252, 248, 238, .82);
  --card-2: rgba(255, 252, 246, .95);
  --sepia: rgba(90, 70, 40, .18);
  --sepia-2: rgba(90, 70, 40, .3);
  --card-shadow: 0 10px 26px -12px rgba(70, 50, 20, .28), 0 1px 0 rgba(255, 255, 255, .7) inset;
  /* акценты */
  --accent: #2f4d8f;
  --select: #8a5a34;
  --select-fg: #fbf6ea;
  --ok: #3f7d4e;
  --bad: #a93a2a;
  --warn: #b7772a;
  --blue: #3f6e8c;
  --orange: #b8622f;
  --purple: #7d2f4e;
  --pink: #b04a6e;
  --indigo: #4a5a9c;
  --radius: 16px;
  --display: "Manrope", "SF Pro Display", -apple-system, system-ui, sans-serif;
  --body: "Golos Text", "SF Pro Text", -apple-system, system-ui, sans-serif;
  --tabbar-h: 60px;
  /* серии графиков — те же «сургучные» цвета */
  --c1: #2f4d8f; --c2: #b8622f; --c3: #3f7d4e; --c4: #7d2f4e; --c5: #b7772a; --c6: #b04a6e; --c7: #3f6e8c; --c8: #8a7a66;
  color-scheme: light;
}
/* освещение по времени суток (js/app.js → applyLight) */
body.light-morning { --paper: #f3eee0; --select: #8a7a3a; --card: rgba(253, 251, 244, .84); --card-2: rgba(255, 254, 249, .96); }
body.light-evening { --paper: #efe2cc; --select: #a4522c; --card: rgba(252, 245, 232, .84); --card-2: rgba(255, 250, 240, .96); }
body.light-night {
  --paper: #c3b69b; --select: #5a3d22; --ink: #261f17; --ink-soft: rgba(38, 31, 23, .7); --ink-faint: rgba(38, 31, 23, .5);
  --card: rgba(228, 219, 198, .88); --card-2: rgba(238, 230, 212, .97); --sepia: rgba(60, 44, 24, .24); --sepia-2: rgba(60, 44, 24, .38);
}
html { background: var(--paper); touch-action: pan-x pan-y; }
html:has(body.light-morning) { background: #f3eee0; }
html:has(body.light-evening) { background: #efe2cc; }
html:has(body.light-night) { background: #c3b69b; }

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0; background: transparent; color: var(--ink);
  font: 15px/1.45 var(--body); -webkit-text-size-adjust: 100%; -webkit-font-smoothing: antialiased;
}
body, .wallpaper, .card, .tabbar, .btn, .iconbtn { transition: background-color 2s ease, border-color 2s ease; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
h1, h2, h3, h4 { font-family: var(--display); letter-spacing: -0.01em; margin: 0; color: var(--ink); }
h3 { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
h4 { font-size: 14px; font-weight: 700; margin: 10px 0 6px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
code { background: rgba(90, 70, 40, .09); padding: 1px 5px; border-radius: 5px; font-size: 13px; }

/* ── обои: бумага с волокнами ─────────────────────────── */
.wallpaper { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; background: var(--paper); }
.wallpaper::before, .wallpaper::after { content: ""; position: absolute; border-radius: 50%; filter: blur(70px); transition: opacity 2s ease; }
.wallpaper::before { /* светлое пятно, как засвет листа */
  width: 120vmax; height: 60vmax; left: -20vmax; top: -22vmax; background: radial-gradient(closest-side, rgba(255, 255, 255, .75), transparent);
}
.wallpaper::after { /* тёплое затемнение к краю */
  width: 90vmax; height: 50vmax; right: -30vmax; bottom: -10vmax; background: radial-gradient(closest-side, rgba(214, 186, 130, .45), transparent);
}
.wallpaper i.grain { /* волокна бумаги: мелкий шум + редкие горизонтальные прожилки */
  position: absolute; inset: 0; display: block;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .26 0 0 0 0 .2 0 0 0 0 .12 0 0 0 .16 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='520' height='520'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.004 .09' numOctaves='2' seed='7' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .3 0 0 0 0 .22 0 0 0 0 .1 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)'/%3E%3C/svg%3E");
}
body.light-morning .wallpaper::after { opacity: .5; }
body.light-night .wallpaper::before { opacity: .25; }

/* ── шапка: крупный заголовок слева, при прокрутке — в центр ── */
.topbar { position: sticky; top: 0; z-index: 20; padding-top: env(safe-area-inset-top, 0px); }
.topbar::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; bottom: -30px; z-index: -1; pointer-events: none;
  background: linear-gradient(180deg, rgba(241, 233, 214, .96) 0%, rgba(241, 233, 214, .8) 60%, rgba(241, 233, 214, 0) 100%);
  -webkit-backdrop-filter: blur(22px) saturate(140%); backdrop-filter: blur(22px) saturate(140%);
  -webkit-mask-image: linear-gradient(180deg, #000 58%, transparent); mask-image: linear-gradient(180deg, #000 58%, transparent);
  opacity: 0; transition: opacity .4s ease;
}
.topbar.scrolled::before { opacity: 1; }
body.light-morning .topbar::before { background: linear-gradient(180deg, rgba(243, 238, 224, .96) 0%, rgba(243, 238, 224, .8) 60%, rgba(243, 238, 224, 0) 100%); }
body.light-evening .topbar::before { background: linear-gradient(180deg, rgba(239, 226, 204, .96) 0%, rgba(239, 226, 204, .8) 60%, rgba(239, 226, 204, 0) 100%); }
body.light-night .topbar::before { background: linear-gradient(180deg, rgba(195, 182, 155, .96) 0%, rgba(195, 182, 155, .8) 60%, rgba(195, 182, 155, 0) 100%); }
.topbar-in {
  position: relative; max-width: 720px; margin: 0 auto; display: flex; align-items: center; gap: 8px; min-height: 64px;
  padding: 4px max(16px, env(safe-area-inset-right, 0px)) 4px max(16px, env(safe-area-inset-left, 0px));
}
.title-wrap {
  position: absolute; left: max(16px, env(safe-area-inset-left, 0px)); right: 110px; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; align-items: flex-start;
  transition: left .42s cubic-bezier(.2, .7, .2, 1), right .42s cubic-bezier(.2, .7, .2, 1);
}
.title {
  font-size: 26px; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; color: var(--ink);
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: font-size .42s cubic-bezier(.2, .7, .2, 1);
}
.profile-name, .profile-select { font-size: 12.5px; color: var(--ink-soft); transition: opacity .3s; }
.topbar.scrolled .title-wrap { left: 64px; right: 64px; align-items: center; }
.topbar.scrolled .title { font-size: 17px; font-weight: 700; }
.topbar.scrolled .profile-name, .topbar.scrolled .profile-select { opacity: 0; pointer-events: none; height: 0; }
.profile-select {
  -webkit-appearance: none; appearance: none; border: 0; padding: 0 14px 0 0; width: max-content; max-width: 100%;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='14' viewBox='0 0 10 14'%3E%3Cpath d='M2 5l3-3 3 3M2 9l3 3 3-3' fill='none' stroke='%237a6a55' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right center / 8px 12px;
}
.actions { position: relative; z-index: 1; margin-left: auto; display: flex; gap: 8px; align-items: center; }
.iconbtn {
  width: 38px; height: 38px; border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center;
  background: var(--card-2); color: var(--ink); border: 1px solid var(--sepia);
}
.iconbtn:active { background: rgba(90, 70, 40, .08); }
.iconbtn svg { width: 20px; height: 20px; }
.sync { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-right: 4px; }
.sync.err { background: var(--bad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 25%, transparent); }

.view {
  max-width: 720px; margin: 0 auto;
  padding: 8px max(16px, env(safe-area-inset-right, 0px)) calc(var(--tabbar-h) + 36px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}

/* ── плавающая панель закладок: картон, активная — сепиевая печать ── */
.tabbar {
  position: fixed; z-index: 20; left: 50%; transform: translateX(-50%);
  width: min(calc(100% - 2 * max(16px, env(safe-area-inset-left, 0px))), 688px);
  bottom: calc(env(safe-area-inset-bottom, 0px) * .4 + 8px);
  border-radius: 22px; background: rgba(252, 248, 238, .9); border: 1px solid var(--sepia);
  box-shadow: var(--card-shadow), 0 14px 30px -12px rgba(70, 50, 20, .35);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
body.light-night .tabbar { background: rgba(232, 223, 203, .94); }
.tabbar-in { display: grid; grid-template-columns: repeat(5, 1fr); height: var(--tabbar-h); }
.tab {
  position: relative; z-index: 0; border: 0; background: transparent; color: var(--ink-soft);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 10.5px; font-weight: 500;
}
.tab svg { width: 22px; height: 22px; }
.tab[aria-current="page"] { color: var(--select); }
.tab[aria-current="page"]::before {
  content: ""; position: absolute; inset: 6px 4px; border-radius: 16px; z-index: -1;
  background: color-mix(in srgb, var(--select) 14%, transparent);
}

/* ── общие элементы ───────────────────────────────────── */
.section { margin-top: 18px; }
.section-title {
  font-family: var(--display); font-size: 17px; font-weight: 700; letter-spacing: -.01em; color: var(--ink);
  margin: 22px 6px 10px; display: flex; align-items: baseline; gap: 8px;
}
.section > .section-title { margin-top: 0; }
.section-title .n { margin-left: auto; font-family: var(--body); font-size: 13.5px; font-weight: 600; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.card {
  background: var(--card); color: var(--ink); border: 1px solid var(--sepia); border-radius: var(--radius); box-shadow: var(--card-shadow);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  padding: 14px 16px; margin-bottom: 12px; min-width: 0;
}
.card.list { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.card.pad { padding: 14px 16px; }
.empty-card { padding: 22px 16px; text-align: center; }
.empty-card p { margin: 0; color: var(--ink-soft); }
.empty { padding: 40px 16px; text-align: center; color: var(--ink-soft); }
.empty h3 { font-size: 18px; margin-bottom: 6px; }

/* Строка списка (.row в HomeHub) */
.entry {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px; width: 100%; text-align: left;
  border: 0; background: transparent; color: var(--ink); border-top: 1px solid var(--sepia);
}
.entry:first-child { border-top: 0; }
.entry:active { background: rgba(90, 70, 40, .07); }
.entry .ava {
  flex: none; width: 42px; height: 42px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 20px;
  background: var(--card-2); border: 1px solid var(--sepia); box-shadow: 0 4px 12px -4px rgba(70, 50, 20, .4);
}
.entry .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.entry .name { font-weight: 500; line-height: 1.3; overflow-wrap: anywhere; color: var(--ink); }
.entry .meta { font-size: 12.5px; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry .aside { flex: none; text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.entry .aside b { font-family: var(--display); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ink); }
.entry .aside small { font-size: 11.5px; color: var(--ink-faint); white-space: nowrap; }
.entry .chev { flex: none; color: var(--ink-faint); display: flex; }
.entry .chev svg { width: 16px; height: 16px; }
.is-hidden { opacity: .55; }

.pill { display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: rgba(90, 70, 40, .09); color: var(--ink); vertical-align: 1px; }
.tag { font-size: 11.5px; padding: 1px 7px; border-radius: 6px; background: rgba(90, 70, 40, .09); color: var(--ink); margin-left: 4px; }
.btn {
  border-radius: 12px; padding: 12px 14px; font-weight: 600; font-size: 15px; display: flex; align-items: center;
  justify-content: center; gap: 8px; width: 100%;
  background: var(--card-2); color: var(--ink); border: 1px solid var(--sepia); box-shadow: 0 1px 0 rgba(255, 255, 255, .6) inset;
}
.btn.primary { background: var(--select); color: var(--select-fg); border-color: var(--select); }
.btn.small { width: auto; padding: 9px 14px; font-size: 14px; }
/* Кнопка-подпись для выбора файла (<label class="button"><input type="file" hidden>) */
label.button {
  flex-direction: row; align-items: center; justify-content: center; width: 100%; cursor: pointer;
  border-radius: 12px; padding: 9px 14px; font-size: 14px; font-weight: 500; color: var(--ink);
  background: var(--card-2); border: 1px solid var(--sepia); box-shadow: 0 1px 0 rgba(255, 255, 255, .6) inset;
}
.btn:active { opacity: .85; }
.link { border: 0; background: transparent; color: var(--accent); font-size: 15px; padding: 4px 2px; }
.link.strong { font-weight: 700; }
.link:disabled { color: var(--ink-faint); }
.hint { font-size: 12.5px; color: var(--ink-soft); margin: 6px 4px 0; }
.stack { display: flex; flex-direction: column; gap: 8px; }

/* Простые кнопки внутри карточек и листов (категории, «Ещё»). Специфичность нулевая (:where),
   чтобы стили компонентов — дни календаря, строки, чипы — всегда были сильнее. */
:where(.card, .sheet-form) :where(button:not(.entry, .chip, .link, .btn, .icon, .iconbtn, .day, .tab)) {
  border: 1px solid var(--sepia); border-radius: 10px; background: var(--card-2); color: var(--ink); padding: 6px 12px; font-size: 14px; font-weight: 500;
}
:where(.card, .sheet-form) :where(button.small:not(.btn, .link)) { padding: 4px 10px; font-size: 13px; }
/* Главная кнопка сильнее и общего правила выше, и базового button { color: inherit } */
button.primary:not(.btn) { background: var(--select); border-color: var(--select); color: var(--select-fg); }
button.danger { color: var(--bad); }
button.icon { border: 0; background: transparent; color: var(--ink-faint); font-size: 16px; padding: 4px 6px; }

/* Раскладка */
.row { display: flex; gap: 10px; align-items: flex-end; }
.row > label { flex: 1; }
.row.between { justify-content: space-between; align-items: center; }
.row.end { justify-content: flex-end; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.grid { display: grid; gap: 12px; }
.grid.two { grid-template-columns: 1fr; }
.muted { color: var(--ink-soft); }
.small { font-size: 13px; }
.pos { color: var(--ok); }
.neg { color: var(--bad); }
.entry .aside b.pos, .kv .v b.pos { color: var(--ok); }
.entry .aside b.neg, .kv .v b.neg { color: var(--bad); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.center { text-align: center; padding: 40px; }
.cap { display: inline-block; }
.cap::first-letter { text-transform: uppercase; }
.errors { color: var(--bad); padding-left: 18px; margin: 4px 0; font-size: 14px; }
.errors:empty { display: none; }

/* ── Сегодня: календарь как «Смены» в HomeHub ─────────── */
.calendar { padding: 10px 8px 10px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin: 0 4px 6px; }
.cal-head b { font-family: var(--display); font-size: 20px; font-weight: 800; color: var(--ink); }
.cal-head .iconbtn { width: 34px; height: 34px; }
.cal-head .iconbtn svg { width: 16px; height: 16px; }
.grid7 { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.grid7 .wd { text-align: center; font-size: 11px; font-weight: 600; color: var(--ink-faint); padding-bottom: 4px; }
.day {
  border: 0; background: transparent; border-radius: 12px; padding: 5px 2px 6px; min-height: 46px;
  display: flex; flex-direction: column; align-items: center; gap: 5px; color: var(--ink);
}
.day b {
  font-family: var(--body); font-size: 14px; font-weight: 600; line-height: 1; width: 28px; height: 28px; font-variant-numeric: tabular-nums;
  display: inline-flex; align-items: center; justify-content: center; border-radius: 50%;
}
.day.today b { box-shadow: inset 0 0 0 1.5px var(--select); }
.day.selected b { background: var(--select); color: var(--select-fg); box-shadow: none; }
.day:active { background: rgba(90, 70, 40, .08); }
.day .mark { display: block; width: 6px; height: 6px; border-radius: 50%; }
.day .mark.on { background: var(--select); }
.to-today { display: block; margin: 4px auto 0; color: var(--select); }

/* ── Баланс ───────────────────────────────────────────── */
.hero-card { display: flex; flex-direction: column; gap: 2px; padding: 16px; }
.hero-card .muted { font-size: 13px; }
.hero-card .big { font-family: var(--display); font-size: 32px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.twin { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 13px; color: var(--ink-soft); margin-top: 4px; }
.twin b { font-family: var(--display); font-variant-numeric: tabular-nums; margin-left: 4px; }
.show-hidden { display: block; margin: 4px auto 0; }
.kv { padding: 0; }
.kv .r { display: flex; justify-content: space-between; gap: 14px; padding: 11px 14px; border-top: 1px solid var(--sepia); font-size: 15px; }
.kv .r:first-child { border-top: 0; }
.kv .r .k { color: var(--ink); }
.kv .r .v { color: var(--ink-soft); text-align: right; font-variant-numeric: tabular-nums; }
.kv .r .v b { font-family: var(--display); }

/* ── переключатели и фильтры ─────────────────────────── */
.segmented {
  display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; border-radius: 12px; padding: 3px; gap: 2px;
  background: var(--card-2); border: 1px solid var(--sepia); box-shadow: 0 1px 0 rgba(255, 255, 255, .6) inset;
}
.segmented button { border: 0; border-radius: 9px; background: transparent; padding: 7px 12px; font-size: 13.5px; font-weight: 500; color: var(--ink-soft); }
.segmented button.on { background: var(--select); color: var(--select-fg); font-weight: 600; }
.segmented.big { display: grid; width: 100%; margin-bottom: 12px; }
.segmented.big button { padding: 8px 4px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 4px; }
.filters select, .filters input {
  width: auto; border-radius: 999px; padding: 7px 13px; font-size: 14px; font-weight: 500; min-width: 0; max-width: 100%;
  background: var(--card-2); color: var(--ink); border: 1px solid var(--sepia);
}
.filters input[type="search"] { flex: 1 1 180px; }
.back-link { display: block; margin: 0 0 8px; }
.summary { margin: 0 6px 8px; color: var(--ink-soft); font-size: 14px; }
.summary b { color: var(--ink); }
.export { margin-top: 14px; justify-content: center; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.kpi {
  background: var(--card); border: 1px solid var(--sepia); box-shadow: var(--card-shadow); border-radius: 14px;
  padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; min-width: 0;
}
.kpi .k { font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.kpi .v { font-family: var(--display); font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

/* ── таблицы ──────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--ink-faint); font-weight: 600; padding: 8px; border-bottom: 1px solid var(--sepia); }
td { padding: 9px 8px; border-bottom: 1px solid var(--sepia); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.actions { width: 1%; white-space: nowrap; }
.actions .small { margin-left: 4px; }

/* ── графики ──────────────────────────────────────────── */
/* Карточка с графиком никогда не прокручивается вбок: график вписан в её ширину. */
.chart-card { overflow: hidden; }
.chart-card svg { display: block; max-width: 100%; }
.entry .swatch { flex: none; width: 12px; height: 12px; border-radius: 50%; margin: 0 4px; box-shadow: 0 0 0 2px var(--card-2), 0 0 0 3px var(--sepia); }
.entry.total { background: rgba(90, 70, 40, .05); }
.entry.total .name { font-weight: 700; }
div.entry:active { background: transparent; }
div.entry.total:active { background: rgba(90, 70, 40, .05); }
.chart { width: 100%; height: auto; display: block; }
.chart .axis { font-size: 11px; fill: var(--ink-soft); }
.chart .baseline { stroke: var(--sepia-2); }
.chart .baseline.danger { stroke: var(--bad); stroke-dasharray: 4 4; }
.legend { list-style: none; padding: 0; margin: 0; }
.legend li { display: flex; gap: 8px; align-items: center; padding: 3px 0; font-size: 14px; }
.legend li b { margin-left: auto; font-variant-numeric: tabular-nums; }
.legend.inline { display: flex; gap: 16px; justify-content: center; margin-top: 6px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.donut { display: grid; grid-template-columns: minmax(160px, 220px) 1fr; gap: 20px; align-items: center; }
.donut.solo { grid-template-columns: minmax(160px, 220px); justify-content: center; margin-bottom: 6px; }
.donut-label { font-size: 11px; fill: var(--ink-soft); }
.donut-total { font-family: var(--display); font-size: 15px; font-weight: 800; fill: var(--ink); }

/* ── Категории ───────────────────────────────────────── */
.entry.child { padding-left: 30px; }
.entry.child .ava { width: 34px; height: 34px; font-size: 16px; }
.entry.add .name { color: var(--accent); font-weight: 600; }
.add-group { margin-top: 18px; }
.card > .row.between h3 { margin: 0; }
.card .list { list-style: none; margin: 8px -16px -14px; padding: 0; }
.card .list li { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 10px 16px; border-top: 1px solid var(--sepia); flex-wrap: wrap; }
.card .list li > span:first-child { flex: 1; min-width: 140px; display: flex; flex-direction: column; align-items: flex-start; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; font-size: 13.5px; font-weight: 500;
  background: var(--card-2); color: var(--ink); border: 1px solid var(--sepia); box-shadow: 0 1px 0 rgba(255, 255, 255, .6) inset;
}

/* ── Ещё ─────────────────────────────────────────────── */
.split > aside { margin-bottom: 4px; }
.side-menu { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; margin: 0 -2px; scrollbar-width: none; }
.side-menu::-webkit-scrollbar { display: none; }
.side-menu button {
  flex: none; border-radius: 999px; padding: 7px 13px; font-size: 14px; font-weight: 500; white-space: nowrap;
  background: var(--card-2); color: var(--ink); border: 1px solid var(--sepia); box-shadow: 0 1px 0 rgba(255, 255, 255, .6) inset;
}
.side-menu button.on { background: var(--select); border-color: var(--select); color: var(--select-fg); }
details summary { cursor: pointer; }
/* Списки в «Ещё» (люди, устройства, копии): сверху название, ниже действия с переносом строк */
.rec-list { margin: 8px -16px 10px; }
.rec { padding: 10px 16px; border-top: 1px solid var(--sepia); }
.rec:first-child { border-top: 0; }
.rec-main { overflow-wrap: anywhere; }
.rec-card { padding: 0; }
.rec select { margin-top: 6px; }
.rec-meta { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
.rec-actions { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 4px; }
.rec-actions .link, .cur-actions .link { padding: 2px 0; font-size: 13.5px; }

/* Валюты: строка — код и курс, ниже действия; ничего не шире карточки */
.cur-list { margin: 10px -16px 12px; }
.cur-row { padding: 10px 16px; border-top: 1px solid var(--sepia); }
.cur-row:first-child { border-top: 0; }
.cur-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.cur-head b { font-family: var(--display); font-size: 16px; }
.cur-head .tag { margin-left: 0; }
.cur-rate { margin-left: auto; flex-direction: row; align-items: center; gap: 6px; font-size: 14px; color: var(--ink-soft); white-space: nowrap; }
/* селектор сильнее общего правила полей (width: 100%) */
.cur-list .cur-rate input.rate:not([type="checkbox"]) { width: 96px; padding: 7px 10px; font-size: 15px; text-align: right; }
.cur-actions { display: flex; gap: 14px; margin-top: 2px; }
.cur-actions .link { padding: 2px 0; font-size: 13.5px; }

/* ── лист (форма) — лист кремовой бумаги ─────────────── */
dialog#modal {
  border: 1px solid var(--sepia); padding: 0; background: #f7f1e3; color: var(--ink);
  width: 100%; max-width: 720px; max-height: 92dvh; margin: auto auto 0; border-radius: 20px 20px 0 0;
  overflow: hidden; animation: up .22s ease-out;
}
dialog#modal[open] { display: flex; flex-direction: column; }
dialog#modal > form { display: flex; flex-direction: column; min-height: 0; max-height: 92dvh; }
dialog::backdrop { background: rgba(40, 30, 18, .45); }
@keyframes up { from { transform: translateY(30px); opacity: 0 } to { transform: none; opacity: 1 } }
@media (prefers-reduced-motion: reduce) { dialog#modal { animation: none; } }
.sheet-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--sepia); background: transparent; flex: none; }
.sheet-head .link:first-child { justify-self: start; }
.sheet-head .link:last-child { justify-self: end; }
.sheet-head b { font-family: var(--display); font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; color: var(--ink); }
.sheet-form { overflow-y: auto; padding: 14px 16px calc(24px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 12px; }
.sheet-form > * { flex-shrink: 0; }
.sheet-form .card { margin-bottom: 0; box-shadow: none; background: var(--card-2); }
.sheet-extra { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.sheet-extra button { border-radius: 12px !important; padding: 12px !important; font-weight: 600; }
.sheet-form p { margin: 0; }

/* Поля форм */
label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--ink-faint); font-weight: 500; }
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select, textarea {
  width: 100%; min-width: 0; border-radius: 12px; padding: 10px 12px; font-size: 16px;
  background: var(--card-2); color: var(--ink); border: 1px solid var(--sepia); color-scheme: light;
}
input::placeholder, textarea::placeholder { color: var(--ink-faint); }
label.check { flex-direction: row; align-items: center; gap: 10px; color: var(--ink); font-size: 15px; font-weight: 400; }
label.check input { width: 20px; height: 20px; accent-color: var(--select); }
.checks { gap: 6px 18px; }
fieldset { border: 1px solid var(--sepia); background: var(--card-2); border-radius: 12px; padding: 10px 14px; margin: 0; display: flex; flex-direction: column; gap: 8px; }
fieldset.plain { border: 0; background: transparent; padding: 0; gap: 12px; }
fieldset.plain > .tx-fields { display: flex; flex-direction: column; gap: 12px; }
legend { font-size: 12.5px; color: var(--ink-faint); font-weight: 600; padding: 0; margin-bottom: 4px; }
.explain { background: rgba(90, 70, 40, .07); border: 1px solid var(--sepia); border-radius: 12px; padding: 12px 14px; font-size: 14px; }
.explain ul { margin: 4px 0; padding-left: 18px; }
.explain h4 { margin: 0 0 4px; }
.explain p { margin: 4px 0 0 !important; }
.splits { border-left: 3px solid var(--sepia-2); padding-left: 10px; display: flex; flex-direction: column; gap: 6px; }
.items { border-left: 3px solid var(--ok); padding-left: 10px; display: flex; flex-direction: column; gap: 6px; }
.item-row { display: grid; grid-template-columns: 2fr 1.6fr 0.7fr 1fr 0.9fr auto; gap: 6px; align-items: center; }
.item-row.head { font-size: 11.5px; color: var(--ink-faint); }
.item-row input, .item-row select { padding: 8px 10px; font-size: 14px; }

/* ── вход — как экран входа HomeHub ───────────────────── */
.welcome {
  position: relative; width: calc(100% - 32px); max-width: 380px; margin: 12vh auto; padding: 28px 22px;
  display: flex; flex-direction: column; gap: 12px;
  background: var(--card); border: 1px solid var(--sepia); border-radius: 22px; box-shadow: var(--card-shadow); color: var(--ink);
}
.welcome h1 { font-size: 22px; font-weight: 800; text-align: center; }
.welcome p { margin: 0; color: var(--ink-soft); font-size: 14px; text-align: center; }
.welcome .btn.primary { margin-top: 4px; }
.lock-mark {
  width: 48px; height: 48px; margin: 0 auto; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--select); color: var(--select-fg); box-shadow: 0 3px 8px -2px rgba(138, 90, 52, .6), inset 0 0 0 2px rgba(255, 255, 255, .35);
}
.lock-mark svg { width: 24px; height: 24px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 22px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 10px);
  background: rgba(52, 40, 28, .95); color: #fbf6ea; padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 50; max-width: 90vw;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--bad); color: #fbf6ea; }

@media (min-width: 600px) {
  dialog#modal { margin: auto; border-radius: 20px; max-width: 560px; max-height: 86dvh; }
  dialog#modal.wide { max-width: 720px; }
  dialog#modal > form { max-height: 86dvh; }
}
@media (max-width: 560px) {
  .row:not(.between):not(.end) { flex-direction: column; align-items: stretch; }
  .item-row { grid-template-columns: 1fr 1fr; }
  .item-row.head { display: none; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpis .kpi:last-child { grid-column: span 2; }
  .donut { grid-template-columns: 1fr; }
}
