/* Golos Text — шрифт с кириллицей как основным письмом; раздаётся с нашего сервера. */
@font-face {
  font-family: 'Golos Text';
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url('/static/fonts/golos-text-cyrillic-ext-wght-normal.woff2') format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: 'Golos Text';
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url('/static/fonts/golos-text-cyrillic-wght-normal.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Golos Text';
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url('/static/fonts/golos-text-latin-ext-wght-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+20A0-20AB, U+20AD-20C0, U+2113;
}
@font-face {
  font-family: 'Golos Text';
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url('/static/fonts/golos-text-latin-wght-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212;
}

/* Палитра: белая глазурь, кобальт и бирюза риштанской керамики, марена для расхода. */
:root {
  --paper: #f4f6fa;
  --surface: #ffffff;
  --ink: #14213b;
  --muted: #586479;
  --line: #dbe1ea;
  --edge: #b7c0cf;
  --cobalt: #1b49c8;
  --in: #08796a;
  --in-soft: #e1f2ee;
  --out: #bf2c46;
  --out-soft: #fae8eb;
  --radius: 10px;
  --font: 'Golos Text', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.45 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-text-size-adjust: 100%;
}

a {
  color: var(--cobalt);
  text-underline-offset: 3px;
}

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--cobalt) 50%, transparent);
  outline-offset: 2px;
}

h1 {
  margin: 0 0 16px;
  font-size: 24px;
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -0.01em;
}

h2 {
  margin: 0 0 8px;
  font-size: 17px;
  line-height: 1.3;
  font-weight: 600;
}

h2 a {
  color: inherit;
}

h3 {
  margin: 20px 0 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
}

p {
  margin: 0 0 12px;
}

.muted {
  color: var(--muted);
}

.cur {
  color: var(--muted);
  font-weight: 500;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* --- Каркас: на телефоне шапка сверху и вкладки снизу, на широком экране — колонка слева --- */

.top {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.brand {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
}

.top-user {
  flex: none;
  color: var(--muted);
  font-size: 14px;
}

.top-user[aria-current] {
  color: var(--ink);
}

.tabs {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 2;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}

.tab {
  flex: 1 1 0;
  min-width: 0;
  padding: 11px 4px 13px;
  border-top: 2px solid transparent;
  margin-top: -1px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  text-decoration: none;
}

.tab[aria-current] {
  border-top-color: var(--cobalt);
  color: var(--ink);
  font-weight: 600;
}

.wide-only {
  display: none;
}

.main {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 104px;
}

@media (min-width: 880px) {
  body:not(.bare) {
    display: grid;
    grid-template-columns: 232px minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    min-height: 100vh;
  }

  .top {
    position: static;
    grid-column: 1;
    grid-row: 1;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 32px 24px 20px;
    border-bottom: 0;
  }

  .brand {
    max-width: 100%;
    white-space: normal;
    font-size: 17px;
    line-height: 1.25;
  }

  .tabs {
    position: static;
    grid-column: 1;
    grid-row: 2;
    align-self: start;
    flex-direction: column;
    gap: 2px;
    padding: 0 12px;
    background: none;
    border-top: 0;
  }

  .tab {
    flex: none;
    margin: 0;
    padding: 9px 12px;
    border-top: 0;
    border-radius: 8px;
    font-size: 15px;
    text-align: left;
  }

  .tab[aria-current] {
    background: var(--surface);
    box-shadow: inset 3px 0 0 var(--cobalt);
  }

  .wide-only {
    display: block;
  }

  .narrow-only {
    display: none;
  }

  .main {
    grid-column: 2;
    grid-row: 1 / span 2;
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 36px 48px 64px;
    border-left: 1px solid var(--line);
  }

  .main > * {
    max-width: 680px;
  }
}

/* --- Итог периода: главное число на экране --- */

.result {
  margin: 4px 0 20px;
}

.result-label {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

.result-figure {
  margin: 2px 0 14px;
  font-size: clamp(38px, 11vw, 56px);
  line-height: 1.05;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.result-figure .cur {
  font-size: 0.36em;
  letter-spacing: 0;
}

.result-figure.is-minus {
  color: var(--out);
}

.result-empty {
  margin: 0;
  padding: 20px 0;
  color: var(--muted);
}

.split {
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
}

.split svg {
  display: block;
  width: 100%;
  height: 100%;
}

.split-in {
  fill: var(--in);
}

.split-out {
  fill: var(--out);
}

.result-split {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 28px;
  margin: 10px 0 0;
}

.result-split dt {
  color: var(--muted);
  font-size: 14px;
}

.result-split dd {
  margin: 0;
  font-size: 17px;
  font-weight: 500;
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
}

.dot-in {
  background: var(--in);
}

.dot-out {
  background: var(--out);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: 500 16px/1.2 var(--font);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.btn-primary {
  border-color: var(--cobalt);
  background: var(--cobalt);
  color: #fff;
}

.btn-income {
  border-color: var(--in);
  background: var(--in);
  color: #fff;
}

.btn-expense {
  border-color: var(--out);
  background: var(--out);
  color: #fff;
}

.btn-block {
  width: 100%;
}

[aria-disabled='true'] {
  opacity: 0.6;
  pointer-events: none;
}

.link,
.link-danger {
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--cobalt);
  font: 400 14px/1.3 var(--font);
  cursor: pointer;
}

.link-danger {
  color: var(--out);
}

.link:hover,
.link-danger:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 20px 0 28px;
}

.head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.head-row h1 {
  margin: 0;
}

/* --- Строки журнала: линейки вместо карточек, суммы в одну колонку --- */

.block {
  margin-top: 32px;
}

.ledger {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}

.row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.row-date {
  flex: 0 0 50px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.row-main {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
}

.row-link {
  color: inherit;
  text-decoration: none;
}

.row-link .row-title {
  color: var(--cobalt);
}

.row-title {
  font-weight: 500;
}

.row-sub {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.row-amount {
  flex: none;
  font-weight: 500;
  text-align: right;
  white-space: nowrap;
}

.row-amount.is-plus,
.table .is-plus {
  color: var(--in);
}

.row-amount.is-minus,
.table .is-minus {
  color: var(--out);
}

.row-total {
  border-bottom: 0;
}

.row-total .row-title,
.row-total .row-amount {
  font-weight: 600;
}

.row-action,
.row-tools {
  display: flex;
  flex: none;
  gap: 14px;
}

.row-share {
  display: inline-block;
  width: 46px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}

.bar {
  display: block;
  width: 100%;
  height: 4px;
  margin-top: 7px;
  border-radius: 2px;
  background: var(--line);
}

.bar-in rect {
  fill: var(--in);
}

.bar-out rect {
  fill: var(--out);
}

.tag {
  display: block;
  font-size: 13px;
  font-weight: 400;
}

.tag-in {
  color: var(--in);
}

.tag-out {
  color: var(--out);
}

.empty {
  margin: 0;
  padding: 20px 0;
  color: var(--muted);
}

.more {
  margin: 12px 0 0;
  font-size: 14px;
}

.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 0 0 20px;
}

.pair dt {
  color: var(--muted);
  font-size: 14px;
}

.pair dd {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.pair .cur {
  font-size: 14px;
}

.facts {
  margin: 0;
  border-top: 1px solid var(--line);
}

.facts div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.facts dt {
  color: var(--muted);
}

.facts dd {
  margin: 0;
  font-weight: 500;
  text-align: right;
}

.client-balance {
  margin: 16px 0 0;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.client-balance .tag {
  font-size: 14px;
  letter-spacing: 0;
}

/* --- Формы --- */

.form {
  display: grid;
  gap: 18px;
  max-width: 460px;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

label,
legend {
  padding: 0;
  color: var(--muted);
  font-size: 14px;
}

legend {
  margin-bottom: 6px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: 400 16px/1.4 var(--font);
  font-variant-numeric: tabular-nums;
}

textarea {
  resize: vertical;
}

/* Поле суммы — как табло калькулятора: крупные цифры на линейке. */
.amount {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding-bottom: 2px;
  border-bottom: 2px solid var(--ink);
}

.amount input {
  min-width: 0;
  min-height: 60px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  font-size: 40px;
  font-weight: 600;
  letter-spacing: -0.02em;
  outline: none;
}

.amount input::placeholder {
  color: var(--edge);
}

.amount span {
  flex: none;
  color: var(--muted);
  font-size: 17px;
}

.amount-in:focus-within {
  border-bottom-color: var(--in);
}

.amount-out:focus-within {
  border-bottom-color: var(--out);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  position: relative;
  color: var(--ink);
  font-size: 15px;
}

.chip input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.chip span {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 15px;
  border: 1px solid var(--edge);
  border-radius: 22px;
  background: var(--surface);
}

.chip input:checked + span {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.chip input:focus-visible + span {
  outline: 3px solid color-mix(in srgb, var(--cobalt) 50%, transparent);
  outline-offset: 2px;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--ink);
  font-size: 16px;
}

.check input {
  flex: none;
  width: 22px;
  height: 22px;
  min-height: 0;
  padding: 0;
  accent-color: var(--cobalt);
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 6px;
}

.form-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  max-width: none;
  margin-top: 14px;
}

.form-inline .field {
  flex: 1 1 160px;
}

.switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  max-width: 460px;
  margin-bottom: 22px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.switch a {
  padding: 10px;
  border-radius: 7px;
  color: var(--muted);
  font-weight: 500;
  text-align: center;
  text-decoration: none;
}

.switch-in[aria-current] {
  background: var(--in-soft);
  color: var(--in);
}

.switch-out[aria-current] {
  background: var(--out-soft);
  color: var(--out);
}

.period {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  margin: 4px 0 10px;
}

.period .field {
  flex: 1 1 130px;
  max-width: 190px;
}

.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin: 0 0 22px;
  font-size: 14px;
}

.presets a[aria-current] {
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
}

.alert,
.notice {
  margin: 0 0 18px;
  padding: 12px 14px;
  border-left: 3px solid var(--out);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--out-soft);
  color: #7a1a2c;
}

.notice {
  border-left-color: var(--in);
  background: var(--in-soft);
  color: var(--ink);
}

.notice p {
  margin: 0;
}

.secret {
  padding: 4px 0;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0.06em;
  user-select: all;
}

/* --- Таблица по месяцам --- */

.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

.table th,
.table td {
  padding: 10px 0 10px 12px;
  border-bottom: 1px solid var(--line);
  font-weight: 400;
  text-align: left;
}

.table th:first-child {
  padding-left: 0;
}

.table thead th {
  color: var(--muted);
  font-size: 13px;
}

.table tbody th {
  font-weight: 500;
}

.table .num {
  text-align: right;
  white-space: nowrap;
}

@media (max-width: 520px) {
  .table {
    font-size: 13px;
  }

  .table th,
  .table td {
    padding-left: 8px;
  }
}

.table + .muted,
.table-wrap + .muted {
  margin-top: 12px;
  font-size: 14px;
}

/* --- Язык, выход, страницы без меню --- */

.lang {
  display: flex;
  gap: 8px;
}

.lang button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--edge);
  border-radius: 20px;
  background: var(--surface);
  color: var(--ink);
  font: 400 15px/1 var(--font);
  cursor: pointer;
}

.lang button[aria-pressed='true'] {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.logout {
  margin-top: 36px;
}

.bare-main {
  max-width: 380px;
  margin: 0 auto;
  padding: 12vh 20px 40px;
}

.bare-main .lang {
  margin-top: 28px;
}

.bare-company {
  margin: 0 0 6px;
  color: var(--muted);
  font-weight: 500;
}

@media (prefers-reduced-motion: no-preference) {
  .btn,
  .chip span,
  .tab {
    transition: background-color 0.12s, border-color 0.12s, color 0.12s;
  }
}
