/* Стили учёта расходов (design-taste-frontend, pastel-consumer) */
:root {
    --ground: #f3f5f7;
    --surface: #ffffff;
    --raised: #f2f8fd;
    --border: #e6e6e6;
    --rule: #f4f4f4;
    --control: #d6d9dd;
    --text: #1b1d1f;
    --muted: #5c6064;
    --accent: #1d5fd6;
    --accent-soft: #dcf1ff;
    --accent-ink: #0a3a80;
    --positive: #2f7a45;
    --negative: #c41c29;
    --warning: #92400e;
    --chart-1: #1d5fd6;
    --chart-2: #b45309;
    --chart-3: #2a8798;
    --radius-card: 20px;
    --radius-control: 10px;
    --gap: 24px;
    --pad: 24px;
    --control-height: 40px;
    --fs-title: 28px;
    --fs-section: 20px;
    --fs-kpi: 32px;
    --fs-body: 16px;
    --fs-small: 14px;
    --sidebar-width: 232px;
  }
  [data-theme="dark"] {
    --ground: #131417;
    --surface: #1b1d20;
    --raised: #1d2126;
    --border: #2a2d31;
    --rule: #23262a;
    --control: #3a3d41;
    --text: #e8eaed;
    --muted: #9aa0a6;
    --accent: #6ea8ff;
    --accent-soft: #1d2c40;
    --accent-ink: #a8cfff;
    --positive: #57b377;
    --negative: #e2606c;
  }
  * { box-sizing: border-box; }
  html, body { height: 100%; }
  body {
    margin: 0; font-family: "Manrope", Inter, system-ui, sans-serif;
    background: var(--ground); color: var(--text); font-size: var(--fs-body);
    -webkit-font-smoothing: antialiased; transition: background .2s, color .2s;
  }
  .app { display: flex; min-height: 100vh; min-height: 100dvh; }
  a { color: var(--accent); }
  .hidden { display: none !important; }

  /* ---- shell: open plane ---- */
  .sidebar {
    width: var(--sidebar-width); flex-shrink: 0; padding: 20px 14px;
    display: flex; flex-direction: column; gap: 6px; border-right: 1px solid var(--border);
    background: var(--ground); position: sticky; top: 0; height: 100vh;
  }
  .brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; }
  .brand .mark {
    width: 26px; height: 26px; border-radius: 7px; background: var(--accent);
    display: grid; place-items: center; color: #fff; font-weight: 600; font-size: 14px; flex-shrink: 0;
  }
  .brand .name { font-weight: 600; font-size: 15px; }
  .nav-group { font-size: 12px; color: var(--muted); padding: 14px 10px 6px; }
  .nav-item {
    display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
    color: var(--muted); text-decoration: none; font-size: 14px; cursor: pointer; border: none; background: none;
    font: inherit; text-align: left; width: 100%;
  }
  .nav-item:hover { color: var(--text); background: var(--rule); }
  .nav-item.active { background: var(--control); color: var(--text); }
  .sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 4px; }
  .theme-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 6px; }
  .theme-tile { height: 40px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); border-radius: 9px; font: inherit; font-size: 12px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 5px; }
  .theme-tile:hover { border-color: var(--accent); color: var(--text); }
  .theme-tile.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

  .main { flex: 1; min-width: 0; display: flex; }
  .mobile-bar { display: none; }
  .mobile-chat-btn { margin-left: auto; height: 34px; padding: 0 12px; font-size: 13px; white-space: nowrap; }
  .menu-btn { height: 38px; width: 42px; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 9px; font-size: 18px; line-height: 1; cursor: pointer; }
  .mobile-title { font-weight: 600; font-size: 15px; }
  .sidebar-backdrop { display: none; }
  .sidebar-backdrop:not(.hidden) { display: block; position: fixed; inset: 0; background: rgba(16,18,20,.45); z-index: 120; }
  .canvas { flex: 1; min-width: 0; padding: 32px var(--gap) 60px; max-width: 1180px; margin: 0 auto; width: 100%; }

  /* ---- page head ---- */
  .page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: nowrap; margin-bottom: 20px; }
  .page-head > div:first-child { flex: 1 1 auto; min-width: 0; }
  .page-head h1 { font-size: var(--fs-title); margin: 0; font-weight: 600; letter-spacing: -.02em; }
  .page-head .finding { font-size: var(--fs-small); color: var(--muted); margin: 6px 0 0; }
  .head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; flex: 0 0 auto; margin-left: auto; }
  .hidden-date { display: none !important; }
  .date-range-tile {
    height: var(--control-height); padding: 0 12px; border: 1px solid var(--border);
    border-radius: var(--radius-control); background: var(--surface); color: var(--text);
    font: inherit; font-size: 13px; display: flex; align-items: center; gap: 8px; white-space: nowrap;
  }
  .date-range-tile svg { opacity: .65; flex-shrink: 0; }
  .date-range-box { width: 350px; max-width: 94vw; }
  .dr-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
  .dr-head #drMonth { font-weight: 600; font-size: 15px; text-transform: capitalize; }
  .dr-nav { width: 34px; height: 34px; padding: 0; font-size: 20px; line-height: 1; }
  .dr-weekdays, .dr-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
  .dr-weekdays span { text-align: center; font-size: 11px; color: var(--muted); padding: 4px 0; }
  .dr-day { height: 38px; padding: 0; border: none; background: none; border-radius: 50%; font-size: 13px; color: var(--text); }
  .dr-day:hover { background: var(--rule); }
  .dr-day.empty { visibility: hidden; }
  .dr-day.today { box-shadow: inset 0 0 0 1px var(--accent); }
  .dr-day.in-range { background: var(--accent-soft); border-radius: 0; }
  .dr-day.start, .dr-day.end { background: var(--accent); color: #fff; }
  .dr-day.start { border-radius: 50% 0 0 50%; }
  .dr-day.end { border-radius: 0 50% 50% 0; }
  .dr-day.start.end { border-radius: 50%; }
  .dr-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
  .dr-actions { display: flex; gap: 8px; margin-left: auto; }
  #drApply:disabled { opacity: .45; cursor: default; }
  .salary-form { display: grid; gap: 12px; }
  .salary-form label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
  .salary-form input, .salary-form select { width: 100%; }
  .salary-note { font-size: 12px; margin: 12px 0 0; line-height: 1.5; }
  .salary-schedule { display: grid; gap: 8px; margin-top: 14px; border-top: 1px solid var(--rule); padding-top: 12px; }
  .salary-event { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
  .salary-event .date { white-space: nowrap; font-variant-numeric: tabular-nums; text-align: right; }
  .salary-event .moved { display: block; color: var(--warning); font-size: 11px; }

  /* ---- controls ---- */
  button, .btn {
    font: inherit; cursor: pointer; border: 1px solid var(--border); background: var(--surface);
    color: var(--text); border-radius: var(--radius-control); padding: 8px 14px; height: var(--control-height);
    transition: background .15s, border-color .15s;
  }
  button:hover { background: var(--rule); }
  button.primary { background: var(--text); border-color: var(--text); color: var(--surface); }
  button.primary:hover { background: var(--accent); border-color: var(--accent); }
  button.ghost { border-color: transparent; background: transparent; }
  button.ghost:hover { background: var(--rule); }
  input[type=text], input[type=date], input[type=password], input[type=number], select, .combo-input {
    font: inherit; border: 1px solid var(--border); border-radius: var(--radius-control); padding: 0 12px;
    background: var(--surface); color: var(--text); outline: none; height: var(--control-height);
  }
  input:focus, select:focus, .combo-input:focus { border-color: var(--accent); }
  .seg { display: inline-flex; background: var(--rule); border-radius: var(--radius-control); padding: 3px; gap: 2px; }
  .seg button { border: none; background: transparent; height: 32px; padding: 0 12px; border-radius: 7px; font-size: var(--fs-small); color: var(--muted); }
  .seg button.active { background: var(--surface); color: var(--text); border: 1px solid var(--border); }

  /* ---- KPI strip (one container, 1px dividers) ---- */
  .kpi-strip {
    display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius-card); overflow: hidden; margin-bottom: var(--gap);
  }
  .kpi { padding: 18px 22px; border-right: 1px solid var(--rule); }
  .kpi-click { cursor: pointer; }
  .kpi-click:hover { background: var(--raised); }
  .kpi:last-child { border-right: none; }
  .kpi .label { font-size: var(--fs-small); color: var(--muted); margin-bottom: 4px; }
  .kpi .value { font-size: var(--fs-kpi); font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
  .kpi .delta { font-size: 12px; margin-top: 3px; color: var(--muted); }
  .kpi .kpi-sub { font-size: 11px; margin-top: 4px; color: var(--muted); font-variant-numeric: tabular-nums; }
  .kpi .value.neg { color: var(--text); }
  .kpi .value.pos { color: var(--positive); }
  .delta.up { color: var(--negative); }
  .delta.down { color: var(--positive); }

  /* ---- category tiles (pale tints) ---- */
  .cat-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: var(--gap); }
  .cat-tile { border-radius: var(--radius-card); padding: 16px 18px; cursor: pointer; border: none; text-align: left; font: inherit; height: auto; }
  .cat-tile .name { font-size: var(--fs-small); font-weight: 600; margin-bottom: 8px; }
  .cat-tile .sum { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
  .cat-tile .cnt { font-size: 12px; opacity: .75; margin-top: 2px; }

  /* ---- month tiles ---- */
  .month-tiles { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
  .month-tile { width: 64px; height: 34px; padding: 0; text-align: center; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 14px; cursor: pointer; }
  .month-tile:hover { border-color: var(--accent); }
  .month-tile.active { background: var(--accent); border-color: var(--accent); color: #fff; }
  .account-tiles { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
  .account-tile {
    width: 100px; height: 100px; padding: 10px; border-radius: 16px;
    border: 1px solid var(--border); background: var(--surface); color: var(--muted);
    font-size: 12px; line-height: 1.3; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    text-align: center; overflow-wrap: anywhere;
  }
  .account-tile:hover { border-color: var(--accent); color: var(--text); }
  .account-tile.on { background: var(--accent); border-color: var(--accent); color: #fff; }
  .account-tile.all { font-weight: 600; font-size: 12px; }
  .account-cell { position: relative; display: flex; }
  .acct-name { display: block; max-width: 100%; }
  .acct-actions { position: absolute; top: 3px; right: 3px; display: flex; gap: 2px; z-index: 2; }
  .acct-act {
    width: 22px; height: 22px; min-width: 22px; padding: 0; border: none;
    background: transparent; color: var(--muted); opacity: .55;
    font-size: 14px; line-height: 1; border-radius: 5px;
  }
  .acct-act:hover { opacity: 1; background: var(--rule); }
  .acct-act svg { display: block; margin: 0 auto; }
  .account-cell.on .acct-act { color: #fff; opacity: .8; }
  .account-cell.on .acct-act:hover { background: rgba(255,255,255,.2); }
  .account-tile.is-hidden { opacity: .55; }
  .accounts-toggle {
    align-self: center; height: 28px; padding: 0 10px; font-size: 11px;
    border: 1px dashed var(--border); background: none; color: var(--muted); border-radius: 8px;
  }

  /* ---- топ категорий (bar list) ---- */
  .rank-list { display: flex; flex-direction: column; gap: 8px; }
  .plan-tools { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; font-size: 13px; flex-wrap: wrap; }
  .plan-row { display: flex; gap: 6px; align-items: center; }
  .plan-tools input { height: 34px; width: 74px; text-align: center; }
  .seg { display: flex; gap: 2px; background: var(--rule); border-radius: 8px; padding: 2px; }
  .seg-btn { height: auto; border: none; background: none; color: var(--muted); padding: 5px 10px; border-radius: 6px; font-size: 12px; cursor: pointer; }
  .seg-btn.on { background: var(--surface); color: var(--text); }
  .confirm-text { margin: 0 0 18px; font-size: 14px; color: var(--text); line-height: 1.5; }
  .confirm-actions { display: flex; gap: 8px; justify-content: flex-end; }
  .cselect { position: relative; display: inline-block; }
  .cselect-btn { height: 36px; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px; padding: 0 12px; font: inherit; font-size: 13px; cursor: pointer; text-align: left; min-width: 140px; }
  .cselect-menu { position: absolute; top: calc(100% + 4px); left: 0; z-index: 80; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 6px; min-width: 100%; box-shadow: 0 12px 30px rgba(0,0,0,.15); } /* taste-skill-ignore: выпадающий список — оверлей */
  .cselect-opt { display: block; width: 100%; text-align: left; border: none; background: none; color: var(--text); padding: 7px 10px; border-radius: 6px; font: inherit; font-size: 13px; cursor: pointer; height: auto; }
  .cselect-opt:hover { background: var(--rule); }
  .cselect-opt.on { color: var(--accent); }
  #transactions .toolbar .cselect { height: var(--control-height); }
  #transactions .toolbar .cselect-btn { height: 100%; font-size: 16px; }
  .rank-icon { height: auto; border: none; background: none; color: var(--muted); padding: 2px; cursor: pointer; display: inline-flex; align-items: center; opacity: .45; }
  .rank-icon:hover { opacity: 1; color: var(--accent); }
  .rank-icon.on { opacity: 1; color: var(--accent); }
  .rank-row { display: block; padding-bottom: 10px; border-bottom: 1px solid var(--rule); }
  .rank-zero { opacity: .7; }
  .rank-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
  .rank-sum { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; flex-shrink: 0; cursor: pointer; }
  .rank-name { font-size: 14px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
  .rank-bar { position: relative; height: 72px; border-radius: 12px; background: var(--rule); border: 1px solid var(--border); overflow: hidden; }
  .rank-plan-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--cat-bg, var(--raised)); opacity: .45; }
  .rank-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--cat-bg, var(--raised)); }
  .rank-inbar-name { position: absolute; left: 13px; top: 9px; max-width: calc(100% - 26px); font-size: 13px; font-weight: 600; color: var(--cat-ink, var(--text)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; z-index: 3; cursor: pointer; }
  .rank-pct { position: absolute; left: 13px; bottom: 8px; font-size: 24px; font-weight: 700; line-height: 1; letter-spacing: -.03em; font-variant-numeric: tabular-nums; white-space: nowrap; z-index: 4; pointer-events: none; color: var(--cat-ink, var(--text)); }
  .rank-marker { position: absolute; top: 0; bottom: 0; transform: translateX(-50%); cursor: grab; touch-action: none; z-index: 5; }
  .rank-marker.plan { width: 14px; border-radius: 4px; background: var(--cat-ink, var(--muted)); opacity: .35; }
  .rank-marker.plan.locked { opacity: .7; }
  .rank-marker.fc { width: 16px; }
  .rank-marker.fc .fc-line { position: absolute; left: 50%; top: 0; bottom: 0; border-left: 2px dashed var(--cat-ink, var(--muted)); opacity: .85; transform: translateX(-1px); }
  .rank-marker.fc.locked .fc-line { opacity: 1; }
  .rank-marker:active { cursor: grabbing; }
  .rank-meta { font-size: 11px; color: var(--muted); margin-top: 5px; }
  .rank-tick { display: none; }
  .plan-edit, .fc-edit { cursor: pointer; text-decoration: underline dotted; text-underline-offset: 2px; }
  .plan-edit:hover, .fc-edit:hover { color: var(--accent); }
  .plan-input { width: 100px; height: 24px; font: inherit; font-size: 12px; border: 1px solid var(--accent); border-radius: 6px; padding: 0 6px; background: var(--surface); color: var(--text); }
  .rank-val { grid-column: 2; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 15px; }
  .chart-delta { font-size: 14px; color: var(--muted); font-weight: 600; }
  .chart-delta.up { color: var(--negative); }
  .chart-delta.down { color: var(--positive); }

  /* ---- category picker (tiles) ---- */
  .cat-btn { display: inline-flex; align-items: center; gap: 0; border: 1px solid transparent; background: var(--surface); color: var(--text); border-radius: 8px; padding: 6px 10px; max-width: 100%; font-size: 13px; font-weight: 600; cursor: pointer; }
  .cat-btn:hover { border-color: transparent; filter: brightness(.96); }
  .cat-btn .dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
  .cat-btn span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .cat-picker { position: fixed; z-index: 90; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 10px; width: 430px; max-width: 94vw; max-height: 82vh; overflow: auto; box-shadow: 0 16px 40px rgba(0,0,0,.18); } /* taste-skill-ignore: поповер выбора категории — оверлей */
  .cat-picker-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .cat-picker-tile { border: none; border-radius: 10px; padding: 10px 9px; font-size: 13px; font-weight: 600; cursor: pointer; text-align: left; line-height: 1.2; min-height: 46px; }
  .cat-picker-more { background: var(--rule); color: var(--muted); }
  .cat-picker .combo-input { width: 100%; margin-top: 8px; }
  .cat-picker-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-size: 13px; font-weight: 600; }
  .cat-picker-back { border: none; background: none; color: var(--accent); cursor: pointer; font-size: 12px; padding: 2px 6px; height: auto; }
  .cat-picker-back:hover { background: var(--rule); }

  /* ---- panels & grid ---- */
  .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: var(--gap); }
  .grid.single { grid-template-columns: 1fr; }
  .panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 20px 22px; }
  .panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
  .panel h2 { font-size: var(--fs-section); margin: 0; font-weight: 600; letter-spacing: -.01em; }
  canvas { max-height: 300px; }

  .toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }

  /* ---- dropdown-фильтр (экселевский) ---- */
  .dropdown { position: relative; }
  .dropdown-menu { position: absolute; top: calc(100% + 4px); left: 0; z-index: 70; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); width: 260px; max-height: 340px; overflow: auto; padding: 8px; } /* taste-skill-ignore: выпадающее меню — оверлей */
  .dropdown-head { display: flex; gap: 6px; padding: 2px 2px 8px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
  .dropdown-search { width: 100%; height: 34px; margin-bottom: 8px; }
  .dropdown-head button { height: 30px; padding: 0 10px; font-size: 12px; }
  .dropdown-list label { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 7px; cursor: pointer; font-size: 14px; }
  .dropdown-list label:hover { background: var(--rule); }
  .dropdown-list input { height: auto; }
  .totals-bar { display: flex; gap: 6px 18px; flex-wrap: wrap; font-size: 14px; color: var(--muted); padding: 8px 2px 12px; border-bottom: 1px solid var(--rule); margin-bottom: 4px; }
  .totals-bar > span { white-space: nowrap; }
  .totals-bar .totals-sep { opacity: .6; }
  .totals-bar b { color: var(--text); font-variant-numeric: tabular-nums; }

  table { width: 100%; border-collapse: collapse; }
  th, td { text-align: left; padding: 12px 12px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
  th { color: var(--muted); font-weight: 500; font-size: 12px; }
  th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
  td.num.neg { color: var(--text); }
  td.num.pos { color: var(--positive); }
  td.desc { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .desc-text { cursor: pointer; border-bottom: 1px dashed transparent; }
  .desc-text:hover { border-bottom-color: var(--muted); }
  .desc-input { width: 100%; min-width: 180px; height: 28px; font: inherit; font-size: 13px; border: 1px solid var(--accent); border-radius: 6px; padding: 0 8px; background: var(--surface); color: var(--text); }
  .mcc { color: var(--muted); font-size: 12px; }
  .badge { display: inline-block; background: var(--rule); border-radius: 6px; padding: 1px 8px; font-size: 11px; color: var(--muted); }
  .del { border: none; background: none; color: var(--muted); font-size: 16px; padding: 2px 6px; height: auto; }
  .del:hover { color: var(--negative); background: none; }
  .pay-del { border: none; background: none; color: var(--muted); font-size: 16px; padding: 2px 6px; height: auto; cursor: pointer; }
  .pay-del:hover { color: var(--negative); }
  .muted { color: var(--muted); }
  .empty { color: var(--muted); text-align: center; padding: 32px; }
  .pager { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 12px; }

  /* ---- combobox ---- */
  .combo { display: flex; align-items: center; gap: 6px; width: 100%; }
  .combo-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; background: var(--muted); }
  .combo-input { width: 100%; min-width: 0; flex: 1; }
  .combo-list {
    position: fixed; z-index: 80; background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; max-height: 280px; overflow: auto; padding: 4px; min-width: 160px;
  }
  .combo-item { padding: 8px 10px; border-radius: 7px; cursor: pointer; font-size: 14px; display: flex; align-items: center; gap: 8px; }
  .combo-item:hover { background: var(--rule); }
  .combo-item-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
  .combo-more { color: var(--accent); font-weight: 600; }
  .combo-add { color: var(--accent); font-weight: 600; border-top: 1px solid var(--border); margin-top: 2px; }

  /* ---- chat ---- */
  .chatbar { width: 372px; flex-shrink: 0; background: var(--surface); border-left: 1px solid var(--border); display: flex; flex-direction: column; height: 100vh; position: sticky; top: 0; transition: width .2s; }
  .chatbar.collapsed { width: 0; border-left: none; overflow: hidden; }
  .chat-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
  .chat-head h2 { margin: 0; font-size: 16px; font-weight: 600; }
  .chat-key { padding: 14px 18px; border-bottom: 1px solid var(--border); background: var(--raised); }
  .chat-msgs { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
  .msg { max-width: 88%; padding: 9px 12px; border-radius: 12px; font-size: 14px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
  .msg.user { align-self: flex-end; background: var(--accent-soft); color: var(--accent-ink); }
  .msg.agent { align-self: flex-start; background: var(--rule); color: var(--text); }
  .chat-input { display: flex; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); }
  .chat-input input { flex: 1; }
  .typing { color: var(--muted); font-size: 12px; padding: 4px 12px; }
  .chat-card { max-width: 96%; white-space: normal; }
  .chat-q { font-size: 13px; font-weight: 600; margin-bottom: 8px; }
  .chat-tiles { display: flex; flex-wrap: wrap; gap: 6px; }
  .chat-tile { height: auto; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px; padding: 6px 12px; font-size: 12px; cursor: pointer; }
  .chat-tile:hover { border-color: var(--accent); color: var(--accent); }
  .chat-tile.on { background: var(--accent); border-color: var(--accent); color: #fff; }
  .chat-tile:disabled { opacity: .45; cursor: default; }
  .chat-tile.cat-tile-chat { border-color: transparent; font-weight: 500; }
  .chat-tile.cat-tile-chat:hover { filter: brightness(.96); }
  .review-list { display: flex; flex-direction: column; gap: 10px; }
  .review-item { padding: 10px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); }
  .review-item.done { opacity: .55; }
  .review-head { display: flex; flex-direction: column; gap: 4px; margin-bottom: 7px; cursor: pointer; }
  .review-head:hover .review-desc { text-decoration: underline; }
  .review-top { display: flex; align-items: center; gap: 8px; font-size: 12px; }
  .review-date { color: var(--muted); white-space: nowrap; }
  .review-cat { font-size: 11px; border-radius: 5px; padding: 1px 7px; font-weight: 500; white-space: nowrap; }
  .review-desc { font-size: 13px; overflow-wrap: anywhere; }
  .review-amt { margin-left: auto; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .review-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
  .review-tiles .chat-tile { text-align: center; padding: 6px 8px; line-height: 1.25; }

  /* ---- modal ---- */
  .modal { position: fixed; inset: 0; background: rgba(16,18,20,.45); display: flex; align-items: center; justify-content: center; z-index: 100; }
  .modal-box { background: var(--surface); border-radius: 18px; padding: 22px; width: 560px; max-width: 94vw; max-height: 84vh; overflow: auto; border: 1px solid var(--border); }
  .modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
  .modal-head h2 { margin: 0; font-size: 20px; font-weight: 600; }
  .ai-box { width: 840px; max-width: 94vw; }
  .ai-section { padding: 16px 0; border-top: 1px solid var(--rule); }
  .ai-section:first-of-type { border-top: none; padding-top: 2px; }
  .ai-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
  .ai-section-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
  .ai-status { font-size: 12px; color: var(--muted); }
  .ai-instr, .ai-goals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
  .ai-opt, .ai-mode { height: auto; border: 1px solid var(--border); background: var(--surface); border-radius: 12px; padding: 12px; text-align: left; cursor: pointer; font: inherit; }
  .ai-opt .t, .ai-mode .t { display: block; font-size: 13px; font-weight: 600; color: var(--text); }
  .ai-opt .s, .ai-mode .s { display: block; font-size: 11px; color: var(--muted); margin-top: 3px; }
  .ai-opt.on, .ai-mode.on { border-color: var(--accent); background: var(--accent-soft); }
  .ai-opt:hover, .ai-mode:hover { border-color: var(--accent); }
  .ai-modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .ai-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
  .ai-toggles { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
  .ai-toggles label { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
  .ai-toggles input { width: auto; }
  .ai-label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
  .ai-section textarea { width: 100%; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; line-height: 1.55; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: var(--surface); color: var(--text); resize: vertical; } /* taste-skill-ignore: textarea для markdown-скилла — это поле ввода */
  .ai-section textarea:focus { outline: none; border-color: var(--accent); }
  .cats-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
  .cats-cols h3 { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
  .cat-row { display: flex; align-items: center; justify-content: flex-start; gap: 8px; padding: 6px 8px; border-radius: 8px; }
  .cat-row:hover { background: var(--rule); }
  .cat-row .cat-row-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .cat-color { width: 22px; height: 22px; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: none; cursor: pointer; flex-shrink: 0; }
  .nav-select { width: 100%; height: 40px; font-size: 13px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--muted); padding: 0 8px; cursor: pointer; }
  .cat-row .rm { border: none; background: none; color: var(--muted); cursor: pointer; font-size: 14px; padding: 0 4px; height: auto; }
  .cat-row .rm:hover { color: var(--negative); }
  .cats-add { display: flex; gap: 8px; margin-top: 16px; }
  .cats-add input { flex: 1; }

  .drop { border: 2px dashed var(--border); border-radius: var(--radius-card); padding: 24px; text-align: center; color: var(--muted); margin-bottom: var(--gap); background: var(--surface); cursor: pointer; }
  .drop.drag { border-color: var(--accent); background: var(--raised); }
  #toast { position: fixed; bottom: calc(22px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); background: var(--text); color: var(--surface); padding: 11px 18px; border-radius: 10px; z-index: 200; font-size: 13px; }

  @media (max-width: 1100px) {
    .page-head { flex-wrap: wrap; }
    .page-head > div:first-child { flex: 1 1 100%; min-width: 0; }
    .head-actions { margin-left: 0; }
  }
  @media (max-width: 900px) {
    .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 272px; height: 100dvh; z-index: 130; transform: translateX(-100%); transition: transform .22s ease; }
    .sidebar.open { transform: none; }
    .main { flex-direction: column; }
    .head-actions { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; width: 100%; align-items: stretch; }
    .head-actions [data-range] { grid-column: span 2; width: 100%; min-width: 0; padding: 0 2px; font-size: 13px; letter-spacing: -.2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .head-actions input[type=date] { grid-column: span 3; width: 100%; min-width: 0; padding: 0 8px; font-size: 14px; }
    .date-range-tile { grid-column: span 6; width: 100%; justify-content: space-between; }
    #top, #transactions, #categories { scroll-margin-top: 76px; }
    .toolbar { gap: 8px; }
    .toolbar select { max-width: 100%; }
    #transactions .toolbar { display: grid; grid-template-columns: 1fr 1fr; }
    #transactions .toolbar > * { width: 100%; min-width: 0; height: var(--control-height); }
    #transactions .toolbar .dropdown { height: var(--control-height); }
    #transactions .toolbar .dropdown > button { width: 100%; height: 100%; white-space: nowrap; font-size: 13px; padding: 0 12px; display: flex; align-items: center; justify-content: flex-start; gap: 0; }
    #transactions .toolbar .cselect { width: 100%; height: var(--control-height); }
    #transactions .toolbar .cselect-btn { width: 100%; height: 100%; font-size: 13px; padding: 0 12px; text-align: left; }
    #transactions .toolbar select, #transactions .toolbar input { font-size: 13px; }
    .mobile-bar { display: flex; align-items: center; gap: 10px; padding: calc(8px + env(safe-area-inset-top)) 14px 10px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 60; }
    .kpi-strip { grid-template-columns: 1fr 1fr; }
    .cat-tiles { grid-template-columns: 1fr 1fr; }
    .chatbar { position: fixed; inset: 0; width: 100%; max-width: none; height: 100dvh; z-index: 95; border-left: none; }
    .chatbar.collapsed { display: none; }
    .chat-msgs { padding: 12px 14px; }
    .chat-input { padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); }
  }
  @media (max-width: 640px) {
    :root { --fs-kpi: 24px; --fs-title: 22px; --gap: 16px; }
    .canvas { padding: 16px 18px calc(48px + env(safe-area-inset-bottom)); }
    .head-actions input[type=date] { grid-column: span 6; font-size: 12px; }
    .totals-bar { gap: 4px 14px; font-size: 13px; }
    .totals-bar .totals-sep { display: none; }
    .cats-cols { grid-template-columns: 1fr; }
    .ai-instr, .ai-goals, .ai-modes { grid-template-columns: 1fr; }
    .kpi { padding: 12px 14px; }
    .kpi .value { font-size: 24px; }
    .panel-head { gap: 8px; align-items: flex-start; }
    .panel-head h2 { font-size: 16px; }
    .chart-delta { display: none; }
    .hide-sm { display: none; }
    .rank-meta { font-size: 11px; }
    .plan-tools { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 12px; margin-bottom: 12px; }
    .plan-tools .plan-slider-label { flex: 1 1 100%; }
    .plan-row { display: flex; gap: 8px; align-items: center; flex: 0 0 auto; }
    #planApply { flex: 0 0 auto; white-space: nowrap; }
    #planHint { flex: 1 1 100%; }
    .plan-tools input { width: 76px; height: 36px; padding: 0 10px; text-align: left; }
    .seg { padding: 2px; }
    .seg-btn { padding: 6px 12px; font-size: 12px; }
    #planApply { height: 36px; padding: 0 16px; font-size: 13px; }
    #planHint { display: block; }
    .kpi-strip { gap: 10px; }
    .cat-tiles { gap: 10px; }
    .rank-list { gap: 8px; padding: 0; }
    .rank-name { font-size: 13px; }
    .rank-bar { height: 66px; }
    .rank-pct { font-size: 21px; }
    .rank-inbar-name { font-size: 12px; }
    .head-actions { width: 100%; }
    .month-tiles { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
    .month-tile { width: auto; min-width: 0; height: 32px; padding: 0; font-size: 12px; }
    .account-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
    .account-cell { width: auto; }
    .account-tile { width: 100%; height: auto; aspect-ratio: 1; padding: 6px; font-size: 10px; gap: 3px; }
    .account-tile.all { font-size: 10px; }
    .acct-actions { top: 2px; right: 2px; }
    .acct-act { width: 18px; height: 18px; min-width: 18px; }
    .acct-act svg { width: 11px; height: 11px; }
    .modal-box { padding: 16px; border-radius: 14px; max-height: 88vh; }
    .panel { padding: 16px 14px; }
    input, select, textarea { font-size: 16px; }
    .cat-picker { left: 8px !important; right: 8px; width: auto; max-width: none; }
    .cat-picker-grid { grid-template-columns: repeat(2, 1fr); }
    #transactions thead { display: none; }
    #txBody tr { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; grid-template-areas: "date cat sum del" "desc desc desc desc"; gap: 3px 8px; padding: 10px 0; border-bottom: 1px solid var(--border); align-items: center; }
    #txBody td { display: block; border: none; padding: 0; vertical-align: middle; }
    #txBody td:nth-child(1) { grid-area: date; font-size: 11px; color: var(--muted); white-space: nowrap; }
    #txBody td:nth-child(1) br, #txBody td:nth-child(1) .mcc { display: none; }
    #txBody td:nth-child(2) { grid-area: desc; font-size: 13px; max-width: none; white-space: normal; overflow: visible; text-overflow: clip; }
    #txBody td:nth-child(3) { grid-area: cat; min-width: 0; }
    #txBody td:nth-child(4) { grid-area: sum; text-align: right; white-space: nowrap; font-size: 14px; }
    #txBody td:nth-child(5) { grid-area: del; }
    #txBody .cat-btn { padding: 3px 8px; font-size: 12px; border-radius: 7px; }
    .rank-bar { border: 1px solid var(--border); }
  }
