/* =========================================================
   Kiraye — оформление в духе iOS (system grouped style)
   ========================================================= */

:root {
  /* палитра iOS light */
  --bg: #f2f2f7;
  --card: #ffffff;
  --card-press: #d1d1d6;
  --sep: rgba(60, 60, 67, 0.29);
  --label: #000000;
  --label-2: rgba(60, 60, 67, 0.6);
  --label-3: rgba(60, 60, 67, 0.3);
  --fill: rgba(120, 120, 128, 0.12);
  --fill-2: rgba(120, 120, 128, 0.08);

  --blue: #007aff;
  --green: #34c759;
  --red: #ff3b30;
  --orange: #ff9500;
  --purple: #af52de;
  --cyan: #32ade6;
  --gray: #8e8e93;

  --radius: 10px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1c1c1e;
    --card-press: #2c2c2e;
    --sep: rgba(84, 84, 88, 0.65);
    --label: #ffffff;
    --label-2: rgba(235, 235, 245, 0.6);
    --label-3: rgba(235, 235, 245, 0.3);
    --fill: rgba(118, 118, 128, 0.24);
    --fill-2: rgba(118, 118, 128, 0.16);

    --blue: #0a84ff;
    --green: #30d158;
    --red: #ff453a;
    --orange: #ff9f0a;
    --purple: #bf5af2;
    --cyan: #64d2ff;
    --gray: #98989d;
  }
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--label);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.29;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(60px + var(--safe-b));
  overscroll-behavior-y: none;
}

button,
input,
select,
textarea {
  font-family: inherit;
  letter-spacing: inherit;
}

/* ===================== навигационная панель ===================== */

.nav {
  position: sticky;
  top: 0;
  z-index: 40;
  padding-top: var(--safe-t);
  background: transparent;
  transition: background 0.25s ease;
}
.nav__bar {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  position: relative;
}
.nav__title {
  font-size: 17px;
  font-weight: 600;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.nav.is-scrolled {
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 0.5px 0 var(--sep);
}
.nav.is-scrolled .nav__title {
  opacity: 1;
  transform: none;
}
.nav__action {
  position: absolute;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.view {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 0 40px;
  animation: appear 0.28s var(--ease);
}
@keyframes appear {
  from {
    opacity: 0;
  }
}

.large-title {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin: 0 0 2px;
  padding: 0 16px;
}
.subtitle {
  padding: 0 16px;
  color: var(--label-2);
  font-size: 15px;
  margin-bottom: 18px;
}

/* ===================== сгруппированные списки ===================== */

.group {
  background: var(--card);
  border-radius: var(--radius);
  margin: 0 16px 24px;
  overflow: hidden;
}
.group--plain {
  background: transparent;
}

.group-title {
  font-size: 13px;
  color: var(--label-2);
  padding: 0 16px 7px;
  margin: 2px 0 0;
}
.group-note {
  font-size: 13px;
  color: var(--label-2);
  padding: 0 16px;
  margin: -18px 0 24px;
  line-height: 1.35;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 11px 16px;
  position: relative;
  background: var(--card);
  color: inherit;
  text-decoration: none;
  width: 100%;
  border: 0;
  font-size: 17px;
  text-align: left;
}
.row + .row::before {
  content: "";
  position: absolute;
  top: 0;
  left: 16px;
  right: 0;
  height: 0.5px;
  background: var(--sep);
  transform: scaleY(0.5);
}
.row--icon + .row--icon::before {
  left: 57px;
}
.row.is-tappable {
  cursor: pointer;
  transition: background 0.1s ease;
}
.row.is-tappable:active {
  background: var(--fill-2);
}

.row__icon {
  width: 29px;
  height: 29px;
  border-radius: 7px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  background: var(--gray);
}
.row__icon svg {
  width: 17px;
  height: 17px;
  fill: #fff;
}
.row__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.row__title {
  font-size: 17px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row__sub {
  font-size: 13px;
  color: var(--label-2);
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row__value {
  color: var(--label-2);
  font-size: 17px;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.row__value b {
  color: var(--label);
  font-weight: 400;
}
.row__value-sub {
  display: block;
  font-size: 12px;
  color: var(--label-2);
  margin-top: 1px;
}
.row__chev {
  width: 7px;
  height: 12px;
  flex-shrink: 0;
  fill: none;
  stroke: var(--label-3);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tint-blue {
  background: var(--blue);
}
.tint-green {
  background: var(--green);
}
.tint-red {
  background: var(--red);
}
.tint-orange {
  background: var(--orange);
}
.tint-purple {
  background: var(--purple);
}
.tint-cyan {
  background: var(--cyan);
}
.tint-gray {
  background: var(--gray);
}

.text-green,
.row__value .text-green {
  color: var(--green);
}
.text-red,
.row__value .text-red {
  color: var(--red);
}
.text-dim {
  color: var(--label-2);
}

/* ===================== итог месяца ===================== */

.total {
  text-align: center;
  padding: 6px 16px 26px;
}
.total__label {
  font-size: 15px;
  color: var(--label-2);
}
.total__value {
  font-size: 44px;
  font-weight: 700;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
  margin: 2px 0 14px;
}
.total__value small {
  font-size: 24px;
  font-weight: 600;
  color: var(--label-2);
  letter-spacing: -0.02em;
}
.progress {
  height: 6px;
  border-radius: 3px;
  background: var(--fill);
  overflow: hidden;
  max-width: 260px;
  margin: 0 auto;
}
.progress > i {
  display: block;
  height: 100%;
  background: var(--green);
  border-radius: 3px;
  transition: width 0.5s var(--ease);
}

/* переключатель месяца */
.month {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--fill);
  border-radius: 8px;
  padding: 2px;
}
.month button {
  border: 0;
  background: transparent;
  color: var(--blue);
  font-size: 15px;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.month button:active {
  background: var(--fill);
}
.month__label {
  font-size: 15px;
  font-weight: 600;
  min-width: 104px;
  text-align: center;
  color: var(--label);
}
.month svg {
  width: 8px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ===================== сегментированный контрол ===================== */

.segment {
  display: flex;
  background: var(--fill);
  border-radius: 9px;
  padding: 2px;
  margin: 0 16px 22px;
}
.segment button {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--label);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 4px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.segment button.is-active {
  background: var(--card);
  font-weight: 600;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 3px 1px rgba(0, 0, 0, 0.04);
}
@media (prefers-color-scheme: dark) {
  .segment button.is-active {
    background: #636366;
  }
}

/* ===================== кнопки ===================== */

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-height: 50px;
  border: 0;
  border-radius: 12px;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  background: var(--card);
  color: var(--blue);
  transition: opacity 0.15s ease, transform 0.12s var(--ease);
}
.btn:active {
  opacity: 0.65;
  transform: scale(0.985);
}
.btn--filled {
  background: var(--blue);
  color: #fff;
}
.btn--tinted {
  background: color-mix(in srgb, var(--blue) 15%, transparent);
  color: var(--blue);
}
.btn--destructive {
  color: var(--red);
}
.btn--whatsapp {
  background: #25d366;
  color: #fff;
  text-decoration: none;
}
.btn--whatsapp svg {
  width: 21px;
  height: 21px;
  fill: currentColor;
}

/* значок WhatsApp в строке списка счетов */
.row__wa {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 9px;
  background: color-mix(in srgb, #25d366 16%, transparent);
  color: #1faa53;
  display: grid;
  place-items: center;
  text-decoration: none;
  transition: background 0.12s ease, transform 0.12s var(--ease);
}
.row__wa svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}
.row__wa:active {
  background: color-mix(in srgb, #25d366 30%, transparent);
  transform: scale(0.92);
}
@media (prefers-color-scheme: dark) {
  .row__wa {
    color: #25d366;
  }
}
.btn[disabled] {
  opacity: 0.4;
  pointer-events: none;
}
.btn-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 16px 24px;
}

.link {
  border: 0;
  background: none;
  color: var(--blue);
  font-size: 17px;
  padding: 0;
  cursor: pointer;
}
.link--strong {
  font-weight: 600;
}
.link:active {
  opacity: 0.5;
}

.nav__action .link {
  font-size: 17px;
}
.plus {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  background: none;
  cursor: pointer;
  color: var(--blue);
}
.plus svg {
  width: 21px;
  height: 21px;
  fill: currentColor;
}

/* ===================== формы ===================== */

.row__label {
  width: 40%;
  max-width: 150px;
  flex-shrink: 0;
  font-size: 17px;
}
.field-input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--label);
  font-size: 17px;
  padding: 0;
  outline: none;
  text-align: right;
  min-height: 22px;
}
.field-input::placeholder {
  color: var(--label-3);
}
.field-input[type="date"],
.field-input[type="month"],
.field-input[type="number"] {
  font-variant-numeric: tabular-nums;
}
/* браузерные стрелки-спиннеры у числовых полей не нужны */
.field-input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}
.field-input[type="number"]::-webkit-outer-spin-button,
.field-input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
}
select.field-input {
  appearance: none;
  text-align: right;
  text-align-last: right;
  color: var(--label-2);
  padding-right: 2px;
}
textarea.field-input {
  text-align: left;
  resize: none;
  min-height: 66px;
  padding: 2px 0;
  line-height: 1.35;
}
.field-input:focus {
  outline: none;
}

/* iOS-переключатель */
.toggle {
  position: relative;
  width: 51px;
  height: 31px;
  flex-shrink: 0;
}
.toggle input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  margin: 0;
  z-index: 2;
  cursor: pointer;
}
.toggle i {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--fill);
  transition: background 0.28s var(--ease);
}
.toggle i::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), 0 1px 1px rgba(0, 0, 0, 0.16);
  transition: transform 0.28s var(--ease);
}
.toggle input:checked + i {
  background: var(--green);
}
.toggle input:checked + i::after {
  transform: translateX(20px);
}

/* ===================== таб-бар ===================== */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: flex;
  background: color-mix(in srgb, var(--card) 78%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  padding-bottom: var(--safe-b);
}
.tabbar::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 0.5px;
  background: var(--sep);
  transform: scaleY(0.5);
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  color: var(--gray);
  font-size: 10px;
  letter-spacing: 0;
  padding: 7px 0 6px;
  transition: color 0.15s ease;
}
.tab svg {
  width: 25px;
  height: 25px;
  fill: currentColor;
}
.tab.is-active {
  color: var(--blue);
}

/* ===================== модальная шторка ===================== */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.4);
  animation: scrimIn 0.4s var(--ease);
}
@keyframes scrimIn {
  from {
    opacity: 0;
  }
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 61;
  max-width: 640px;
  margin: 0 auto;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-radius: 12px 12px 0 0;
  box-shadow: 0 -1px 40px rgba(0, 0, 0, 0.18);
  animation: sheetIn 0.45s var(--ease);
}
@keyframes sheetIn {
  from {
    transform: translateY(100%);
  }
}
.sheet.is-closing {
  animation: sheetOut 0.3s var(--ease) forwards;
}
@keyframes sheetOut {
  to {
    transform: translateY(100%);
  }
}
.sheet__grabber {
  width: 36px;
  height: 5px;
  border-radius: 3px;
  background: var(--label-3);
  margin: 5px auto 0;
  flex-shrink: 0;
}
.sheet__bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 12px 16px 10px;
  flex-shrink: 0;
}
.sheet__bar h2 {
  font-size: 17px;
  font-weight: 600;
  margin: 0;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sheet__bar .link {
  justify-self: start;
}
.sheet__spacer {
  justify-self: end;
}
.sheet__body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 0 calc(24px + var(--safe-b));
}
.sheet__body .group:last-child {
  margin-bottom: 24px;
}

/* ===================== мелочи ===================== */

.empty {
  text-align: center;
  padding: 70px 40px;
  color: var(--label-2);
}
.empty svg {
  width: 46px;
  height: 46px;
  fill: var(--label-3);
  margin-bottom: 12px;
}
.empty b {
  display: block;
  color: var(--label);
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 4px;
}
.empty span {
  font-size: 15px;
}

.loader {
  padding: 60px;
  text-align: center;
  color: var(--label-3);
  font-size: 15px;
}

.toasts {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(72px + var(--safe-b));
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: rgba(30, 30, 32, 0.92);
  backdrop-filter: blur(20px);
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  padding: 11px 20px;
  border-radius: 999px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
  animation: toastIn 0.35s var(--ease);
  max-width: 88%;
  text-align: center;
}
.toast--err {
  background: rgba(255, 59, 48, 0.94);
}
@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.94);
  }
}

/* динамика по месяцам */
.chart {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 108px;
  padding: 16px 16px 12px;
}
.chart__col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  height: 100%;
}
.chart__bar {
  width: 100%;
  max-width: 28px;
  min-height: 3px;
  border-radius: 4px;
  background: var(--blue);
  opacity: 0.32;
  transition: height 0.5s var(--ease);
}
.chart__col.is-current .chart__bar {
  opacity: 1;
}
.chart__label {
  font-size: 11px;
  color: var(--label-2);
}

/* строка расчёта в форме счёта */
.calc-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 8px 16px;
  font-size: 15px;
  color: var(--label-2);
}
.calc-row b {
  color: var(--label);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}
.calc-total {
  display: flex;
  justify-content: space-between;
  padding: 12px 16px;
  font-size: 17px;
  font-weight: 600;
  border-top: 0.5px solid var(--sep);
  font-variant-numeric: tabular-nums;
}
.calc-warn {
  padding: 8px 16px 12px;
  font-size: 13px;
  color: var(--orange);
}

/* ===================== экран с кодом доступа ===================== */

.gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 24px calc(28px + var(--safe-b));
  animation: appear 0.3s var(--ease);
}
.gate__icon {
  width: 66px;
  height: 66px;
  border-radius: 16px;
  background: var(--blue);
  display: grid;
  place-items: center;
  margin-bottom: 18px;
}
.gate__icon svg {
  width: 38px;
  height: 38px;
  fill: #fff;
}
.gate__title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.gate__sub {
  font-size: 15px;
  color: var(--label-2);
  margin-top: 4px;
  text-align: center;
  max-width: 260px;
}
.gate__form {
  width: 100%;
  max-width: 380px;
  margin-top: 26px;
}
.gate__form .group {
  margin: 0 0 4px;
}
.gate__form .row__label {
  width: 34%;
}
.gate__form .btn {
  margin-top: 6px;
}

.gate__dots {
  display: flex;
  gap: 20px;
  margin: 26px 0 8px;
}
.gate__dots i {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid var(--label-3);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s var(--ease);
}
.gate__dots i.is-on {
  background: var(--label);
  border-color: var(--label);
  transform: scale(1.08);
}
.gate__dots.is-wrong {
  animation: shake 0.42s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}
@keyframes shake {
  10%, 90% { transform: translateX(-5px); }
  20%, 80% { transform: translateX(9px); }
  30%, 50%, 70% { transform: translateX(-12px); }
  40%, 60% { transform: translateX(12px); }
}
.gate__err {
  min-height: 22px;
  color: var(--red);
  font-size: 14px;
  text-align: center;
  padding: 6px 12px 2px;
}
.keypad {
  display: grid;
  grid-template-columns: repeat(3, 78px);
  gap: 20px 24px;
  margin-top: 18px;
}
.key {
  height: 78px;
  border: 0;
  border-radius: 50%;
  background: var(--fill);
  color: var(--label);
  font-size: 32px;
  font-weight: 400;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.12s ease, transform 0.12s var(--ease);
}
.key:active {
  background: var(--card-press);
  transform: scale(0.94);
}
.key--blank {
  background: transparent;
  pointer-events: none;
}
.key--back {
  background: transparent;
  font-size: 25px;
}
.gate__hint {
  margin-top: 26px;
  font-size: 13px;
  color: var(--label-3);
  text-align: center;
  max-width: 300px;
  line-height: 1.4;
}

.badge {
  font-size: 13px;
  color: var(--label-2);
}
.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: 1px;
}
