/* Тетрадь — веб. Палитра и шкала из ui/theme/Theme.kt и Type.kt:
   системные цвета iOS, серый фон сгруппированных списков, один синий акцент.
   Траты — обычным цветом текста, зелёный — только доходы, красный — удаление. */

:root {
  --bg: #F2F2F7;
  --cell: #FFFFFF;
  --cell-hover: #F7F7FA;
  --sep: #C6C6C8;
  --sep-soft: rgba(60, 60, 67, 0.14);
  --label: #000000;
  --secondary: #8E8E93;
  --tertiary: #C4C4C7;
  --tint: #007AFF;
  --tint-soft: #EAF2FF;
  --fill: rgba(118, 118, 128, 0.12);
  --fill-strong: rgba(118, 118, 128, 0.2);
  --earn: #34C759;
  --earn-text: #248A3D;
  --destructive: #FF3B30;
  --glass: rgba(250, 250, 252, 0.86);
  --thumb: #FFFFFF;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.06);
  --shadow-pop: 0 24px 60px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.08);
  --radius: 20px;
  --radius-sm: 12px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --cell: #1C1C1E;
    --cell-hover: #242426;
    --sep: #38383A;
    --sep-soft: rgba(84, 84, 88, 0.5);
    --label: #FFFFFF;
    --secondary: #8E8E93;
    --tertiary: #48484A;
    --tint: #0A84FF;
    --tint-soft: #0B2A4D;
    --fill: rgba(118, 118, 128, 0.24);
    --fill-strong: rgba(118, 118, 128, 0.36);
    --earn: #30D158;
    --earn-text: #30D158;
    --destructive: #FF453A;
    --glass: rgba(28, 28, 30, 0.88);
    --thumb: #636366;
    --shadow: none;
    --shadow-pop: 0 24px 60px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #000000;
  --cell: #1C1C1E;
  --cell-hover: #242426;
  --sep: #38383A;
  --sep-soft: rgba(84, 84, 88, 0.5);
  --label: #FFFFFF;
  --secondary: #8E8E93;
  --tertiary: #48484A;
  --tint: #0A84FF;
  --tint-soft: #0B2A4D;
  --fill: rgba(118, 118, 128, 0.24);
  --fill-strong: rgba(118, 118, 128, 0.36);
  --earn: #30D158;
  --earn-text: #30D158;
  --destructive: #FF453A;
  --glass: rgba(28, 28, 30, 0.88);
  --thumb: #636366;
  --shadow: none;
  --shadow-pop: 0 24px 60px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--label);
  font: 15px/20px -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
a { color: var(--tint); text-decoration: none; }
[hidden] { display: none !important; }
.ic { flex: none; display: block; }
.muted { color: var(--secondary); }
.num, .amt { font-variant-numeric: tabular-nums; white-space: nowrap; }
.amt-earn { color: var(--earn-text); }
.amt-neutral { color: var(--secondary); }
.amt-neg { color: var(--destructive); }

/* --- Каркас -------------------------------------------------------------------- */

.layout { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 6px;
  padding: 22px 14px 18px;
  border-right: 0.5px solid var(--sep-soft);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 14px; font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.brand .ic { color: var(--tint); }
.btn-add { margin: 0 2px 12px; justify-content: center; height: 40px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  height: 38px; padding: 0 12px; border-radius: 10px;
  color: var(--label); font-weight: 500;
}
.nav a .ic { color: var(--secondary); }
.nav a:hover { background: var(--fill); }
.nav a.active { background: var(--tint-soft); color: var(--tint); }
.nav a.active .ic { color: var(--tint); }
.sidebar-foot { margin-top: auto; padding: 10px 12px 0; font-size: 12px; line-height: 16px; color: var(--secondary); }

.content { padding: 30px 40px 56px; max-width: 1200px; width: 100%; outline: none; }
.page-head { display: flex; align-items: center; gap: 12px; min-height: 44px; margin-bottom: 22px; }
.page-head h1 { margin: 0; font-size: 34px; line-height: 41px; font-weight: 700; letter-spacing: -0.02em; flex: 1; min-width: 0; }
.page-head .sub { color: var(--secondary); font-size: 15px; font-weight: 400; letter-spacing: 0; margin-left: 4px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 18px; }
.toolbar .grow { flex: 1; }

/* --- Группы ---------------------------------------------------------------------- */

.group { background: var(--cell); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.group + .section-head { margin-top: 28px; }
.section-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 26px;
  padding: 0 18px 6px; font-size: 13px; line-height: 18px; color: var(--secondary); text-transform: uppercase; letter-spacing: 0.02em;
}
.section-head a, .section-head button { text-transform: none; letter-spacing: 0; font-size: 15px; line-height: 18px; }
.section-head .btn-plain { height: auto; padding: 0; background: none; gap: 4px; }
.section-foot { padding: 8px 18px 0; font-size: 13px; line-height: 18px; color: var(--secondary); }
.stack { display: flex; flex-direction: column; gap: 28px; }
.stack > section { min-width: 0; }

.row {
  display: flex; align-items: center; gap: 12px;
  min-height: 56px; padding: 0 0 0 16px; position: relative;
  cursor: default; width: 100%; text-align: left; background: none; border: 0;
}
button.row, a.row { cursor: pointer; color: inherit; }
button.row:hover, a.row:hover { background: var(--cell-hover); }
.row-main {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px;
  align-self: stretch; padding: 9px 16px 9px 0;
}
.row + .row .row-main, .day-head + .row .row-main.first { box-shadow: inset 0 0.5px 0 var(--sep-soft); }
.day-head + .row .row-main { box-shadow: none; }
.row-text { flex: 1; min-width: 0; }
.row-title { font-size: 16px; line-height: 21px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 13px; line-height: 18px; color: var(--secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-end { text-align: right; flex: none; display: flex; flex-direction: column; align-items: flex-end; }
.row-end .amt { font-size: 16px; line-height: 21px; }
.row .chev { color: var(--tertiary); }

.avatar {
  flex: none; display: inline-grid; place-items: center; border-radius: 50%;
  background: var(--c); color: #fff;
}
.plate { flex: none; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--c); color: #fff; }

.day-head {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 16px 16px 6px; font-size: 15px; font-weight: 600;
}
.day-head .muted { font-weight: 400; font-variant-numeric: tabular-nums; }
.day-head:not(:first-child) { border-top: 0.5px solid var(--sep-soft); margin-top: 4px; }

/* --- Кнопки и поля --------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 16px; border-radius: 999px; border: 0;
  background: var(--fill); color: var(--label); font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--fill-strong); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--tint); color: #fff; }
.btn-primary:hover { background: var(--tint); filter: brightness(1.08); }
.btn-danger { background: var(--destructive); color: #fff; }
.btn-danger:hover { background: var(--destructive); filter: brightness(1.08); }
.btn-danger-text { background: none; color: var(--destructive); padding: 0 10px; }
.btn-danger-text:hover { background: var(--fill); }
.btn-plain { background: none; color: var(--tint); padding: 0 8px; }
.btn-plain:hover { background: var(--fill); }
.btn-sm { height: 30px; padding: 0 12px; font-size: 13px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--fill);
  display: grid; place-items: center; cursor: pointer; color: var(--label); flex: none;
}
.icon-btn:hover { background: var(--fill-strong); }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.icon-btn.flip .ic { transform: scaleX(-1); }

.seg { display: inline-flex; padding: 2px; border-radius: 999px; background: var(--fill); height: 36px; flex: none; }
.seg button {
  border: 0; background: none; border-radius: 999px; padding: 0 14px; font-weight: 500; cursor: pointer;
  color: var(--label); font-size: 14px;
}
.seg button.on { background: var(--thumb); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12); font-weight: 600; }

.input, .select, .field input, .field select, .field textarea {
  height: 36px; padding: 0 12px; border-radius: 10px; border: 0; background: var(--fill); outline: none; min-width: 0;
}
.input:focus, .select:focus, .field input:focus, .field select:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--tint) 35%, transparent); }
.select, .field select {
  appearance: none; padding-right: 30px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238E8E93' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.search { position: relative; display: flex; align-items: center; }
.search .ic { position: absolute; left: 10px; color: var(--secondary); pointer-events: none; }
.search .input { padding-left: 34px; width: 220px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span, .field-label { font-size: 13px; color: var(--secondary); }
.field input, .field select { height: 40px; width: 100%; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--tint); }

/* --- Окна ------------------------------------------------------------------------ */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px;
  background: rgba(0, 0, 0, 0.32); opacity: 0; transition: opacity 0.16s;
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.modal-backdrop.open { opacity: 1; }
.modal {
  width: min(540px, 100%); max-height: calc(100vh - 48px); display: flex; flex-direction: column;
  background: var(--cell); border-radius: 24px; box-shadow: var(--shadow-pop);
  transform: translateY(8px) scale(0.98); transition: transform 0.16s;
}
.modal.wide { width: min(680px, 100%); }
.modal-backdrop.open .modal { transform: none; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 18px 6px 24px; }
.modal-head h2 { margin: 0; font-size: 20px; line-height: 25px; font-weight: 600; }
.modal-body { padding: 10px 24px 8px; overflow: auto; }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 14px 24px 20px; }
.modal-foot .spacer { flex: 1; }
.confirm-text { margin: 4px 0 8px; color: var(--secondary); }

.editor { display: flex; flex-direction: column; gap: 16px; }
.editor .seg { align-self: flex-start; }
.field-static { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.amount-field { display: flex; align-items: baseline; gap: 8px; border-bottom: 0.5px solid var(--sep); padding-bottom: 6px; }
.amount-field input {
  flex: 1; min-width: 0; border: 0; background: none; outline: none;
  font-size: 44px; line-height: 50px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums;
}
.amount-field input:disabled { color: var(--secondary); }
.amount-cur { font-size: 28px; font-weight: 600; color: var(--secondary); }
.hint { font-size: 13px; color: var(--secondary); margin-top: -8px; }
.cat-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip-cat {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px 0 5px;
  border-radius: 999px; border: 0; background: var(--fill); cursor: pointer; font-weight: 500;
}
.chip-cat:hover { background: var(--fill-strong); }
.chip-cat.on { background: var(--tint-soft); box-shadow: inset 0 0 0 1.5px var(--tint); color: var(--tint); }
.form-error { color: var(--destructive); font-size: 14px; }
.history { border-top: 0.5px solid var(--sep-soft); padding-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.hist-row { display: grid; grid-template-columns: 120px 1fr auto; gap: 10px; font-size: 13px; line-height: 18px; }
.hist-when { color: var(--secondary); font-variant-numeric: tabular-nums; }

.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 60; transform: translate(-50%, 16px); opacity: 0;
  display: flex; align-items: center; gap: 16px; padding: 10px 10px 10px 18px; min-height: 44px; border-radius: 999px;
  background: rgba(30, 30, 32, 0.94); color: #fff; box-shadow: var(--shadow-pop); transition: all 0.2s;
}
.toast.open { opacity: 1; transform: translate(-50%, 0); }
.toast button { border: 0; background: rgba(255, 255, 255, 0.16); color: #fff; border-radius: 999px; height: 30px; padding: 0 14px; font-weight: 600; cursor: pointer; }
.toast:not(:has(button)) { padding-right: 18px; }

.empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 48px 24px; text-align: center; color: var(--secondary); }
.empty-title { color: var(--label); font-weight: 600; font-size: 17px; margin-top: 4px; }
.loading { display: grid; place-items: center; padding: 80px 0; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--fill-strong); border-top-color: var(--secondary); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Обзор ----------------------------------------------------------------------- */

.overview { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 28px; align-items: start; }
.hero { padding: 22px 24px 20px; }
.hero-label { font-size: 15px; color: var(--secondary); }
.hero-value { font-size: 44px; line-height: 50px; font-weight: 700; letter-spacing: -0.02em; margin: 2px 0 14px; font-variant-numeric: tabular-nums; }
.hero-stats { display: flex; gap: 28px; flex-wrap: wrap; }
.stat-label { font-size: 13px; color: var(--secondary); }
.stat-value { font-size: 17px; line-height: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.share-bar { display: flex; gap: 2px; height: 10px; border-radius: 5px; overflow: hidden; margin: 18px 0 12px; background: var(--fill); }
.share-bar span { background: var(--c); min-width: 3px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--secondary); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.legend b { color: var(--label); font-weight: 500; font-variant-numeric: tabular-nums; }
.total-row { display: flex; justify-content: space-between; align-items: baseline; padding: 16px 16px 12px; }
.total-row .big { font-size: 22px; line-height: 28px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* --- Движения: таблица ------------------------------------------------------------ */

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 18px; }
.filters .input.amount { width: 104px; }
.amount-range, .custom-dates { display: inline-flex; align-items: center; gap: 8px; }
.filters .dash { color: var(--secondary); }
.summary-line { display: flex; gap: 18px; padding: 0 18px 10px; font-size: 13px; color: var(--secondary); }
.summary-line b { color: var(--label); font-weight: 600; font-variant-numeric: tabular-nums; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 12px; font-weight: 500; color: var(--secondary); text-transform: uppercase; letter-spacing: 0.02em;
  padding: 12px 12px 8px; border-bottom: 0.5px solid var(--sep-soft); white-space: nowrap;
}
.table td { padding: 8px 12px; border-top: 0.5px solid var(--sep-soft); vertical-align: middle; font-size: 15px; }
.table tr.day td { border-top: 0; padding: 18px 16px 6px; font-weight: 600; background: var(--cell); }
.table tr.day + tr td { border-top: 0; }
.table tr.day td .muted { font-weight: 400; float: right; font-variant-numeric: tabular-nums; }
.table tbody tr.tx { cursor: pointer; }
.table tbody tr.tx:hover td { background: var(--cell-hover); }
.table td.c-amt, .table th.c-amt { text-align: right; }
.table th:first-child, .table td:first-child { padding-left: 16px; }
.table th:last-child, .table td:last-child { padding-right: 16px; }
.table .c-acc, .table .c-cat { color: var(--secondary); white-space: nowrap; }
.tx-cell { display: flex; align-items: center; gap: 12px; min-width: 0; }
.tx-cell .row-text { min-width: 0; }
.badge {
  display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 500;
  background: var(--fill); color: var(--secondary); white-space: nowrap; vertical-align: 1px;
}
.badge.tint { background: var(--tint-soft); color: var(--tint); }
.badge.green { background: color-mix(in srgb, var(--earn) 16%, transparent); color: var(--earn-text); }
.badge.red { background: color-mix(in srgb, var(--destructive) 14%, transparent); color: var(--destructive); }
.badge.purple { background: color-mix(in srgb, #AF52DE 16%, transparent); color: #AF52DE; }
.more { display: flex; justify-content: center; padding: 14px; border-top: 0.5px solid var(--sep-soft); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* --- Отчёты ------------------------------------------------------------------------ */

.period-nav { display: inline-flex; align-items: center; gap: 8px; }
.period-title { min-width: 170px; text-align: center; font-weight: 600; font-size: 17px; }
.report { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; align-items: start; }
.report-totals { display: grid; grid-template-columns: repeat(3, 1fr); padding: 18px 8px 16px; }
.report-totals > div { padding: 0 16px; }
.report-totals > div + div { border-left: 0.5px solid var(--sep-soft); }
.report-totals .stat-value { font-size: 22px; line-height: 28px; }
.chart { padding: 6px 16px 12px; position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .bar { fill: var(--c, var(--tint)); }
.chart .bar.dim { opacity: 0.35; }
.chart .grid-line { stroke: var(--sep-soft); stroke-width: 1; }
.chart .axis { fill: var(--secondary); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart .bar:hover { filter: brightness(1.12); }
.tip {
  position: absolute; pointer-events: none; z-index: 5; transform: translate(-50%, -100%);
  background: var(--cell); color: var(--label); border-radius: 10px; padding: 6px 10px; font-size: 13px; line-height: 17px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18); white-space: nowrap; border: 0.5px solid var(--sep-soft);
}
.tip b { font-variant-numeric: tabular-nums; }
.cat-share { width: 72px; height: 4px; border-radius: 2px; background: var(--fill); overflow: hidden; margin-top: 6px; }
.cat-share i { display: block; height: 100%; background: var(--c); border-radius: 2px; }
.change { font-size: 13px; color: var(--secondary); font-variant-numeric: tabular-nums; }

/* --- Календарь ---------------------------------------------------------------------- */

.months { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.month {
  background: var(--cell); border-radius: 18px; padding: 14px 16px 14px; min-height: 108px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; border: 0; text-align: left; position: relative;
}
button.month { cursor: pointer; }
button.month:hover { background: var(--cell-hover); }
.month.current { outline: 2px solid var(--tint); outline-offset: -2px; }
.month.future { background: transparent; box-shadow: inset 0 0 0 1px var(--sep); }
.month-name { font-size: 15px; font-weight: 600; }
.month-name .muted { font-weight: 400; }
.month-net { font-size: 22px; line-height: 28px; font-weight: 600; margin-top: auto; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.month.future .month-net { opacity: 0.75; }
.month-io { font-size: 12px; line-height: 16px; color: var(--secondary); font-variant-numeric: tabular-nums; margin-top: 2px; }
.cal-bottom { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 28px; align-items: start; margin-top: 28px; }
.balance-block { padding: 16px 16px 12px; }
.balance-head { display: flex; justify-content: space-between; align-items: flex-end; }
.balance-head .big { font-size: 22px; line-height: 28px; font-weight: 600; font-variant-numeric: tabular-nums; }
.line-chart { margin-top: 10px; }
.line-chart svg { width: 100%; height: 118px; display: block; overflow: visible; }
.line-chart .ln { fill: none; stroke: var(--tint); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.line-chart .ln.fc { stroke-dasharray: 4 5; }
.line-chart .area { fill: color-mix(in srgb, var(--tint) 10%, transparent); }
.line-chart .dot { fill: var(--tint); stroke: var(--cell); stroke-width: 2; }
.axis-months { display: grid; grid-template-columns: repeat(12, 1fr); font-size: 11px; color: var(--secondary); text-align: center; margin-top: 6px; }

/* --- Счета ------------------------------------------------------------------------ */

.acc-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 28px; align-items: start; }
.totals { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.totals .cur-line { display: flex; justify-content: space-between; align-items: baseline; }
.totals .cur-line .big { font-size: 22px; line-height: 28px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* --- Журнал -------------------------------------------------------------------------- */

.jr { display: flex; gap: 14px; padding: 14px 16px; }
.jr + .jr { border-top: 0.5px solid var(--sep-soft); }
.jr-icon { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--fill); color: var(--secondary); flex: none; }
.jr-icon.agent { background: color-mix(in srgb, #AF52DE 16%, transparent); color: #AF52DE; }
.jr-icon.web { background: var(--tint-soft); color: var(--tint); }
.jr-body { flex: 1; min-width: 0; }
.jr-top { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.jr-title { font-weight: 600; }
.jr-time { margin-left: auto; color: var(--secondary); font-size: 13px; font-variant-numeric: tabular-nums; }
.jr-who { font-size: 13px; color: var(--secondary); margin-top: 1px; }
.jr-reason { font-size: 14px; margin-top: 6px; }
.jr-reason::before { content: "«"; color: var(--secondary); }
.jr-reason::after { content: "»"; color: var(--secondary); }
.diff { margin-top: 10px; display: grid; grid-template-columns: max-content max-content max-content minmax(0, 1fr); gap: 4px 10px; justify-content: start; font-size: 13px; line-height: 18px; background: var(--bg); border-radius: 12px; padding: 10px 12px; }
.diff .f { color: var(--secondary); }
.diff .b { text-decoration: line-through; color: var(--secondary); text-decoration-color: color-mix(in srgb, var(--secondary) 60%, transparent); }
.diff .arrow { color: var(--tertiary); }
.diff .a { font-weight: 500; }
.jr-snap { margin-top: 8px; display: flex; align-items: center; gap: 10px; font-size: 14px; }
.jr-snap .amt { margin-left: auto; }
.jr-actions { margin-top: 10px; display: flex; gap: 8px; }
.journal-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 28px; align-items: start; }
.journal-side { position: sticky; top: 30px; }
.src-row .row-end b { font-weight: 600; font-variant-numeric: tabular-nums; }

/* --- Настройки ------------------------------------------------------------------------- */

.settings { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; align-items: start; }
.settings-col { display: flex; flex-direction: column; gap: 28px; min-width: 0; }
.intro { padding: 18px 20px; display: flex; gap: 14px; }
.intro p { margin: 0; color: var(--secondary); font-size: 14px; line-height: 20px; }
.intro + .row .row-main { box-shadow: inset 0 0.5px 0 var(--sep-soft); }
.intro p b { color: var(--label); font-weight: 600; }
.code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; line-height: 19px;
  background: var(--bg); border-radius: 12px; padding: 12px 14px; overflow-wrap: anywhere; white-space: pre-wrap; user-select: all;
}
.code-wrap { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.code-wrap .code { align-self: stretch; }
.key-once { display: flex; flex-direction: column; gap: 14px; }
.warn { display: flex; gap: 10px; padding: 12px 14px; border-radius: 12px; background: color-mix(in srgb, #FF9500 14%, transparent); font-size: 14px; line-height: 19px; }
.warn .ic { color: #FF9500; margin-top: 1px; }
.scope-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.scope-pick label {
  display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border-radius: 14px; background: var(--fill); cursor: pointer;
}
.scope-pick label:has(input:checked) { background: var(--tint-soft); box-shadow: inset 0 0 0 1.5px var(--tint); }
.scope-pick input { display: none; }
.scope-pick b { font-weight: 600; }
.scope-pick span { font-size: 13px; color: var(--secondary); line-height: 17px; }
.theme-row { padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* --- Вход ------------------------------------------------------------------------------- */

.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(380px, 100%); background: var(--cell); border-radius: 28px; padding: 36px 32px 28px; box-shadow: var(--shadow-pop); display: flex; flex-direction: column; gap: 16px; }
.login-logo { width: 64px; height: 64px; border-radius: 16px; background: var(--tint); color: #fff; display: grid; place-items: center; margin: 0 auto 2px; }
.login-card h1 { margin: 0; text-align: center; font-size: 28px; line-height: 34px; font-weight: 700; }
.login-card .sub { text-align: center; color: var(--secondary); margin: -10px 0 6px; }
.login-card .field input { height: 44px; font-size: 17px; }
.otp { letter-spacing: 0.4em; font-variant-numeric: tabular-nums; text-align: center; }
.login-card .btn { height: 44px; justify-content: center; font-size: 17px; margin-top: 4px; }
.login-foot { text-align: center; font-size: 13px; color: var(--secondary); }

/* --- Узкие экраны ------------------------------------------------------------------------- */

@media (max-width: 1180px) {
  .overview { grid-template-columns: minmax(0, 1fr) 320px; }
  .report { grid-template-columns: minmax(0, 1fr); }
  .table .c-acc { display: none; }
}

@media (max-width: 980px) {
  .layout { grid-template-columns: 72px minmax(0, 1fr); }
  .sidebar { padding: 18px 10px; align-items: center; }
  .brand span, .nav a span, .btn-add span, .sidebar-foot { display: none; }
  .brand { padding: 0 0 14px; }
  .btn-add { width: 44px; height: 44px; padding: 0; border-radius: 50%; margin: 0 0 12px; }
  .nav a { width: 48px; height: 44px; justify-content: center; padding: 0; }
  .overview, .acc-grid, .settings, .cal-bottom, .journal-layout { grid-template-columns: minmax(0, 1fr); }
  .journal-side { position: static; order: -1; }
  .months { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .content { padding: 24px 24px 48px; }
}

@media (max-width: 640px) {
  .layout { display: block; }
  .sidebar {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; z-index: 20;
    flex-direction: row; justify-content: center; padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    border-right: 0; border-top: 0.5px solid var(--sep-soft);
    background: var(--glass); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  }
  .brand { display: none; }
  .nav { flex-direction: row; gap: 0; }
  .nav a { width: 44px; }
  .btn-add { position: fixed; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); margin: 0; width: 52px; height: 52px; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2); }
  .content { padding: 18px 16px 120px; }
  .page-head h1 { font-size: 28px; line-height: 34px; }
  .page-head { flex-wrap: wrap; row-gap: 12px; }
  .page-head h1 { flex: 1 1 100%; }
  .page-head .period-nav { width: 100%; justify-content: space-between; }
  .months { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .table .c-cat, .table .c-date, .table th.c-acc { display: none; }
  .report-totals { padding: 14px 0; }
  .report-totals > div { padding: 0 12px; }
  .report-totals .stat-value { font-size: 17px; line-height: 22px; }
  .search .input { width: 100%; }
  .filters > * { flex: 1 1 140px; }
  .filters .amount-range, .filters .custom-dates { flex: 1 1 100%; }
  .amount-range .input, .custom-dates .input { flex: 1; width: auto; }
  .hero-stats { display: grid; grid-template-columns: repeat(3, auto); gap: 12px; justify-content: space-between; }
  .hero-stats .stat-label { font-size: 12px; }
  .grid2, .scope-pick { grid-template-columns: 1fr; }
  .hero-value { font-size: 36px; line-height: 42px; }
  .diff { grid-template-columns: max-content minmax(0, 1fr); }
  .diff .arrow { display: none; }
  .modal-backdrop { padding: 0; place-items: end center; }
  .modal { border-radius: 24px 24px 0 0; max-height: 92vh; }
}
