/* Стиль iOS: системные цвета и шрифты, сгруппированные списки, листы, пружинная анимация. */
:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --card-2: #f2f2f7;
  --label: #000000;
  --label-2: rgba(60, 60, 67, 0.6);
  --label-3: rgba(60, 60, 67, 0.3);
  --sep: rgba(60, 60, 67, 0.18);
  --fill: rgba(120, 120, 128, 0.12);
  --fill-2: rgba(120, 120, 128, 0.2);
  --tint: #007aff;
  --green: #34c759;
  --red: #ff3b30;
  --orange: #ff9500;
  --indigo: #5856d6;
  --teal: #30b0c7;
  --pink: #ff2d55;
  --bar: rgba(249, 249, 249, 0.86);
  --overlay: rgba(0, 0, 0, 0.35);
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.18);
  --spring: cubic-bezier(0.32, 0.72, 0, 1);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #000000;
  --card: #1c1c1e;
  --card-2: #2c2c2e;
  --label: #ffffff;
  --label-2: rgba(235, 235, 245, 0.6);
  --label-3: rgba(235, 235, 245, 0.3);
  --sep: rgba(84, 84, 88, 0.55);
  --fill: rgba(120, 120, 128, 0.24);
  --fill-2: rgba(120, 120, 128, 0.36);
  --tint: #0a84ff;
  --green: #30d158;
  --red: #ff453a;
  --orange: #ff9f0a;
  --indigo: #5e5ce6;
  --teal: #40c8e0;
  --pink: #ff375f;
  --bar: rgba(22, 22, 24, 0.86);
  --overlay: rgba(0, 0, 0, 0.55);
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--label); overflow: hidden; }
body {
  font: 17px/1.3 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased; letter-spacing: -0.012em; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
}
input, textarea, select, button { font: inherit; color: inherit; letter-spacing: inherit; }
input, textarea { -webkit-user-select: text; user-select: text; }
button { border: 0; background: none; padding: 0; cursor: pointer; }
.num { font-variant-numeric: tabular-nums; }
svg.i { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- экраны и навигация ---------- */
#app { position: fixed; inset: 0; overflow: hidden; }
.screen {
  position: absolute; inset: 0; background: var(--bg); display: flex; flex-direction: column;
  will-change: transform; transition: transform 0.42s var(--spring), opacity 0.42s var(--spring);
}
.screen.enter { transform: translateX(100%); }
.screen.under { transform: translateX(-28%); opacity: 0.6; }
.screen.leave { transform: translateX(100%); }
.screen.swipe { transition: none; }
.screen.fade-in { animation: fade 0.3s ease both; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.screen::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; background: #000; transition: opacity 0.42s var(--spring);
}
.screen.under::after { opacity: 0.08; }

.navbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 5; padding-top: var(--sat);
  background: transparent; transition: background 0.2s, box-shadow 0.2s;
}
.navbar.solid { background: var(--bar); -webkit-backdrop-filter: saturate(180%) blur(22px); backdrop-filter: saturate(180%) blur(22px); box-shadow: 0 0.5px 0 var(--sep); }
.navrow { height: 44px; display: flex; align-items: center; padding: 0 8px; position: relative; }
.navtitle {
  position: absolute; left: 70px; right: 70px; text-align: center; font-weight: 600; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; opacity: 0; transform: translateY(4px); transition: opacity 0.2s, transform 0.2s;
}
.navbar.solid .navtitle { opacity: 1; transform: none; }
.nbtn { color: var(--tint); display: inline-flex; align-items: center; gap: 2px; height: 44px; padding: 0 8px; border-radius: 10px; transition: opacity 0.15s; font-size: 17px; }
.nbtn:active { opacity: 0.35; }
.nbtn.back svg { width: 26px; height: 26px; margin-left: -6px; }
.nspacer { flex: 1; }
.scroll {
  flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior-y: contain;
  padding: calc(44px + var(--sat)) 16px calc(32px + var(--sab));
}
.large { font-size: 34px; font-weight: 700; letter-spacing: 0.01em; line-height: 1.12; margin: 4px 0 14px 4px; }
.sub { color: var(--label-2); font-size: 15px; }

/* ---------- группы и строки ---------- */
.gh { font-size: 13px; text-transform: uppercase; color: var(--label-2); margin: 22px 0 7px 16px; letter-spacing: 0.01em; display: flex; justify-content: space-between; align-items: baseline; padding-right: 16px; }
.gh .link { text-transform: none; font-size: 15px; color: var(--tint); }
.gf { font-size: 13px; color: var(--label-2); margin: 7px 16px 0; line-height: 1.35; }
.group { background: var(--card); border-radius: 12px; overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 10px 16px; position: relative; width: 100%; text-align: left;
  background: var(--card); transition: background 0.12s;
}
.row + .row::before { content: ""; position: absolute; left: 16px; right: 0; top: 0; height: 0.5px; background: var(--sep); }
.row.icon + .row.icon::before { left: 58px; }
button.row:active, a.row:active { background: var(--fill); }
.row .grow { flex: 1; min-width: 0; }
.row .t { font-size: 17px; }
.row .s { font-size: 14px; color: var(--label-2); margin-top: 1px; }
.row .t, .row .s { overflow: hidden; text-overflow: ellipsis; }
.row .s { white-space: pre-line; }
.row .v { color: var(--label-2); text-align: right; flex: none; }
.row .chev { color: var(--label-3); width: 17px; height: 17px; stroke-width: 2.4; }
.tile { width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center; color: #fff; flex: none; }
.tile svg { width: 19px; height: 19px; }
.c-blue { background: var(--tint); } .c-green { background: var(--green); } .c-orange { background: var(--orange); }
.c-red { background: var(--red); } .c-indigo { background: var(--indigo); } .c-teal { background: var(--teal); } .c-pink { background: var(--pink); }
.c-gray { background: #8e8e93; }
.pos { color: var(--green); } .neg { color: var(--red); } .warn { color: var(--orange); }
.badge { display: inline-block; min-width: 24px; padding: 2px 8px; border-radius: 999px; background: var(--fill); font-size: 14px; text-align: center; font-weight: 500; }
.badge.red { background: var(--red); color: #fff; } .badge.green { background: color-mix(in srgb, var(--green) 18%, transparent); color: var(--green); }
.badge.orange { background: color-mix(in srgb, var(--orange) 18%, transparent); color: var(--orange); }
.badge.blue { background: color-mix(in srgb, var(--tint) 16%, transparent); color: var(--tint); }

.thumb { width: 44px; height: 44px; border-radius: 9px; background: var(--fill); flex: none; display: grid; place-items: center; color: var(--label-2); font-weight: 600; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---------- кнопки ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 50px; border-radius: 14px; background: var(--tint);
  color: #fff; font-weight: 600; transition: transform 0.18s var(--spring), opacity 0.15s;
}
.btn:active { transform: scale(0.97); opacity: 0.85; }
.btn.gray { background: var(--fill); color: var(--tint); }
.btn.red { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); }
.btn.small { height: 36px; width: auto; padding: 0 14px; font-size: 15px; border-radius: 999px; }
.btn[disabled] { opacity: 0.4; pointer-events: none; }
.btn .spin { width: 18px; height: 18px; }
.btnrow { display: flex; gap: 10px; } .btnrow > * { flex: 1; }
.stack > * + * { margin-top: 12px; }

.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.act { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 2px 10px; background: var(--card); border-radius: 12px; font-size: 12px; color: var(--tint); text-align: center; transition: transform 0.18s var(--spring), background 0.12s; line-height: 1.15; }
.act:active { transform: scale(0.94); background: var(--fill); }
.act svg { width: 24px; height: 24px; }

/* ---------- поля ---------- */
.field { display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 0 16px; background: var(--card); position: relative; }
.field + .field::before { content: ""; position: absolute; left: 16px; right: 0; top: 0; height: 0.5px; background: var(--sep); }
.field label { flex: none; max-width: 62%; }
.field input, .field select, .field textarea {
  flex: 1 1 80px; min-width: 60px; border: 0; outline: 0; background: transparent; text-align: right; height: 46px; padding: 0; appearance: none; -webkit-appearance: none;
}
.field textarea { height: auto; min-height: 70px; padding: 12px 0; text-align: left; resize: none; }
.field.col { flex-direction: column; align-items: stretch; gap: 0; padding-top: 10px; padding-bottom: 4px; }
.field.col label { max-width: none; font-size: 13px; color: var(--label-2); }
.field.col textarea { min-height: 64px; padding-top: 6px; }
.field input::placeholder, .field textarea::placeholder { color: var(--label-3); }
.field .pick { flex: 1; text-align: right; color: var(--tint); height: 46px; display: flex; align-items: center; justify-content: flex-end; gap: 6px; min-width: 0; }
.field .pick span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.field.err { background: color-mix(in srgb, var(--red) 8%, var(--card)); }
.field input[type="date"] { color: var(--tint); }
.errtext { color: var(--red); font-size: 14px; margin: 10px 16px 0; animation: shake 0.4s; }
@keyframes shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }
.search { display: flex; align-items: center; gap: 6px; background: var(--fill); border-radius: 10px; height: 36px; padding: 0 8px; color: var(--label-2); }
.search svg { width: 18px; height: 18px; }
.search input { flex: 1; border: 0; background: transparent; outline: 0; height: 36px; min-width: 0; }
.search input::placeholder { color: var(--label-2); }
.search .clr { width: 18px; height: 18px; border-radius: 50%; background: var(--label-3); color: var(--card); display: none; place-items: center; }
.search .clr svg { width: 12px; height: 12px; stroke-width: 3; }
.search.has .clr { display: grid; }

.switch { position: relative; width: 51px; height: 31px; border-radius: 999px; background: var(--fill-2); transition: background 0.25s; flex: none; }
.switch::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,.15), 0 1px 1px rgba(0,0,0,.16); transition: transform 0.3s var(--spring); }
.switch.on { background: var(--green); } .switch.on::after { transform: translateX(20px); }

.seg { display: flex; position: relative; background: var(--fill); border-radius: 9px; padding: 2px; }
.seg button { flex: 1; position: relative; z-index: 1; height: 28px; font-size: 13px; font-weight: 500; border-radius: 7px; white-space: nowrap; transition: color 0.2s; padding: 0 6px; }
.seg .thumbbg { position: absolute; top: 2px; bottom: 2px; left: 2px; border-radius: 7px; background: var(--card); box-shadow: 0 3px 8px rgba(0,0,0,.12), 0 3px 1px rgba(0,0,0,.04); transition: transform 0.32s var(--spring), width 0.32s var(--spring); }
:root[data-theme="dark"] .seg .thumbbg { background: #636366; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 10px 16px; margin: 0 -16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 32px; padding: 0 14px; border-radius: 999px; background: var(--card); font-size: 15px; display: inline-flex; align-items: center; gap: 4px; transition: transform 0.18s var(--spring), background 0.2s, color 0.2s; }
.chip:active { transform: scale(0.95); }
.chip.on { background: var(--tint); color: #fff; }

.stepper { display: inline-flex; align-items: center; background: var(--fill); border-radius: 9px; height: 32px; }
.stepper button { width: 38px; height: 32px; display: grid; place-items: center; color: var(--label); }
.stepper button:active { opacity: 0.4; }
.stepper span { min-width: 30px; text-align: center; font-weight: 600; }
.stepper i { width: 0.5px; height: 18px; background: var(--label-3); }

/* ---------- карточки-метрики ---------- */
.hero { background: var(--card); border-radius: 16px; padding: 18px 18px 16px; }
.hero .k { font-size: 13px; color: var(--label-2); text-transform: uppercase; letter-spacing: 0.02em; }
.hero .big { font-size: 40px; font-weight: 700; letter-spacing: -0.02em; margin-top: 2px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.metric { background: var(--card); border-radius: 14px; padding: 12px 14px; text-align: left; transition: transform 0.18s var(--spring), background 0.12s; }
button.metric:active { transform: scale(0.97); background: var(--fill); }
.metric .k { font-size: 13px; color: var(--label-2); }
.metric .v { font-size: 22px; font-weight: 650; margin-top: 2px; letter-spacing: -0.01em; }
.bar { height: 8px; border-radius: 4px; background: var(--fill); overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; width: 0; border-radius: 4px; background: var(--tint); transition: width 0.8s var(--spring); }
.chart { display: flex; align-items: flex-end; gap: 10px; height: 120px; padding: 6px 4px 0; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; font-size: 11px; color: var(--label-2); }
.chart .col i { display: block; width: 100%; max-width: 34px; border-radius: 6px 6px 2px 2px; background: var(--tint); height: 0; transition: height 0.8s var(--spring); }
.chart .col i.neg { background: var(--red); }

.banner { display: flex; align-items: center; gap: 12px; background: color-mix(in srgb, var(--orange) 14%, var(--card)); border-radius: 12px; padding: 12px 14px; width: 100%; text-align: left; transition: transform 0.18s var(--spring); }
.banner:active { transform: scale(0.98); }
.empty { text-align: center; color: var(--label-2); padding: 56px 24px; }
.empty svg { width: 54px; height: 54px; stroke-width: 1.2; color: var(--label-3); margin-bottom: 10px; }
.empty b { display: block; color: var(--label); font-size: 20px; margin-bottom: 4px; }

/* ---------- листы и диалоги ---------- */
.backdrop { position: fixed; inset: 0; background: var(--overlay); opacity: 0; transition: opacity 0.35s var(--spring); z-index: 50; }
.backdrop.show { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 51; max-height: 92dvh; display: flex; flex-direction: column; background: var(--bg);
  border-radius: 14px 14px 0 0; transform: translateY(100%); transition: transform 0.45s var(--spring); box-shadow: var(--shadow);
  padding-bottom: var(--sab);
}
.sheet.show { transform: none; }
.sheet.drag { transition: none; }
.sheet .grab { width: 36px; height: 5px; border-radius: 3px; background: var(--label-3); margin: 6px auto 0; flex: none; }
.sheet header { display: grid; grid-template-columns: auto 1fr auto; align-items: center; height: 50px; padding: 0 8px; flex: none; position: relative; touch-action: none; }
.sheet header h3 { margin: 0; padding: 0 6px; font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; min-width: 0; grid-column: 2; }
.sheet header .nbtn:first-child { grid-column: 1; }
.sheet header .nbtn.bold { grid-column: 3; }
.sheet .sbody { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 4px 16px 24px; overscroll-behavior: contain; }
.sheet header .nbtn.bold { font-weight: 600; }
.alertbox {
  position: fixed; z-index: 70; left: 50%; top: 50%; width: 270px; background: var(--bar); -webkit-backdrop-filter: blur(30px); backdrop-filter: blur(30px);
  border-radius: 14px; text-align: center; transform: translate(-50%, -50%) scale(1.15); opacity: 0; transition: transform 0.3s var(--spring), opacity 0.2s;
}
:root:not([data-theme="dark"]) .alertbox { background: rgba(242, 242, 247, 0.96); }
.alertbox.show { transform: translate(-50%, -50%) scale(1); opacity: 1; }
.alertbox .m { padding: 20px 16px 16px; } .alertbox .m b { display: block; font-size: 17px; margin-bottom: 4px; } .alertbox .m span { font-size: 13px; color: var(--label); display: block; white-space: pre-line; }
.alertbox .bs { display: flex; border-top: 0.5px solid var(--sep); } .alertbox .bs button { flex: 1; height: 44px; color: var(--tint); font-size: 17px; }
.alertbox .bs button + button { border-left: 0.5px solid var(--sep); font-weight: 600; } .alertbox .bs button.red { color: var(--red); }
.alertbox .bs button:active { background: var(--fill); }
.toast {
  position: fixed; z-index: 80; left: 50%; top: calc(var(--sat) + 10px); transform: translate(-50%, -140%); background: var(--card); box-shadow: var(--shadow);
  padding: 11px 18px; border-radius: 999px; font-size: 15px; font-weight: 500; max-width: 88vw; display: flex; gap: 8px; align-items: center; transition: transform 0.5s var(--spring);
}
.toast.show { transform: translate(-50%, 0); } .toast.bad svg { color: var(--red); } .toast.ok svg { color: var(--green); }
.toast svg { width: 20px; height: 20px; stroke-width: 2.4; }

/* ---------- появление и загрузка ---------- */
.rise { animation: rise 0.55s var(--spring) both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.skel { background: linear-gradient(90deg, var(--fill) 25%, var(--fill-2) 50%, var(--fill) 75%); background-size: 200% 100%; animation: sh 1.3s infinite; border-radius: 12px; }
@keyframes sh { to { background-position: -200% 0; } }
.spin { animation: rot 0.8s linear infinite; } @keyframes rot { to { transform: rotate(360deg); } }
.photos { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; margin: 0 -16px 14px; padding: 0 16px; scrollbar-width: none; }
.photos::-webkit-scrollbar { display: none; }
.photos img { height: 260px; width: auto; max-width: 86%; border-radius: 14px; scroll-snap-align: center; object-fit: cover; flex: none; background: var(--fill); }
.mono { font-variant-numeric: tabular-nums; }
.hide { display: none !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
