/* Дашборд «Корпусные десерты»
   Палитра: безе, тёмный шоколад, малина. Статусы — фиксированные цвета с иконкой и подписью. */

:root {
  --paper: #fff6f4;
  --card: #ffffff;
  --ink: #3a2327;
  --crumb: #8e7479;
  --line: #f1dcdc;
  --line-strong: #e4c6c9;
  --raspberry: #c8325e;
  --raspberry-soft: #fbe3ea;
  --on-accent: #ffffff;
  --good: #0a8a0a;
  --good-soft: #e3f4e0;
  --bad: #d03b3b;
  --bad-soft: #fbe4e2;
  --wait: #9a6a00;
  --wait-soft: #fdf1d3;
  --muted-soft: #f3ebea;
  --shadow: 0 10px 28px -18px rgba(58, 35, 39, .45);

  --display: "Unbounded", "Manrope", system-ui, sans-serif;
  --body: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 16px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --paper: #1b1315;
  --card: #261b1e;
  --ink: #f7e9ec;
  --crumb: #b59da3;
  --line: #3a2a2f;
  --line-strong: #4c373d;
  --raspberry: #f0668f;
  --raspberry-soft: #45222e;
  --on-accent: #1b1315;
  --good: #3ccf3c;
  --good-soft: #17301a;
  --bad: #ff6b6b;
  --bad-soft: #3d1c1d;
  --wait: #f5c14b;
  --wait-soft: #3a2e14;
  --muted-soft: #140e10;
  --shadow: 0 10px 28px -18px rgba(0, 0, 0, .8);
  color-scheme: dark;
}

* { box-sizing: border-box; }
/* Экран зафиксирован: страница не масштабируется, не пружинит и не уезжает вбок.
   Прокручивается только содержимое внутри .app и только по вертикали. */
html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}
body {
  position: fixed;
  inset: 0;
  width: 100%;
  background: var(--paper);
  color: var(--ink);
  font: 500 15px/1.4 var(--body);
}
.app {
  position: absolute;
  inset: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}
.pills--scroll { touch-action: pan-x pan-y; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--raspberry); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- шапка и переключатели ---------- */

.top {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 14px 16px 12px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.brand {
  margin: 0 0 10px;
  font: 600 12px/1 var(--display);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--raspberry);
}
.switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: var(--muted-soft);
}
.switch__item {
  border: 0;
  border-radius: 10px;
  padding: 9px 0;
  background: transparent;
  font-weight: 700;
  color: var(--crumb);
  transition: background .2s, color .2s;
}
.switch__item.is-active { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

main { padding: 14px 16px 0; max-width: 640px; margin: 0 auto; }

.pills { display: flex; gap: 8px; margin-bottom: 16px; }
.pills--scroll { overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; margin-inline: -16px; padding-inline: 16px; }
.pills--scroll::-webkit-scrollbar { display: none; }
.pill {
  flex: none;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 7px 14px;
  background: transparent;
  font-weight: 600;
  font-size: 14px;
  color: var(--crumb);
}
.pill.is-active { background: var(--ink); border-color: var(--ink); color: var(--paper); }

/* ---------- заказы: чеки ---------- */

.day { margin: 0 0 20px; }
.day__label {
  margin: 0 0 10px;
  font: 600 13px/1.2 var(--display);
  color: var(--crumb);
}
.ticket {
  position: relative;
  margin-bottom: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}
.ticket.is-closed { opacity: .72; }
.ticket__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ticket__time { font: 600 15px/1 var(--display); letter-spacing: .01em; }
.ticket__client { margin: 8px 0 0; font-size: 19px; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.ticket__tear {
  position: relative;
  margin: 14px -16px;
  border-top: 1.5px dashed var(--line-strong);
}
.ticket__tear::before,
.ticket__tear::after {
  content: "";
  position: absolute;
  top: -10px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--paper);
  border: 1px solid var(--line);
}
.ticket__tear::before { left: -10px; clip-path: inset(0 0 0 50%); }
.ticket__tear::after { right: -10px; clip-path: inset(0 50% 0 0); }
.items { margin: 0; padding: 0; list-style: none; }
.items li { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; }
.items li span:last-child { color: var(--crumb); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ticket__sum {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.ticket__pieces { color: var(--crumb); font-weight: 600; }
.ticket__price { font: 600 18px/1 var(--display); }
.ticket__note { margin-top: 4px; font-size: 12px; color: var(--crumb); text-align: right; }
.meta { margin: 12px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: 14px; }
.meta li { display: flex; gap: 8px; overflow-wrap: anywhere; }
.meta li b { flex: none; width: 18px; text-align: center; font-weight: 400; }
.meta__muted { color: var(--crumb); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.chip--active { background: var(--raspberry-soft); color: var(--raspberry); }
.chip--pending { background: var(--wait-soft); color: var(--wait); }
.chip--done { background: var(--good-soft); color: var(--good); }
.chip--cancelled, .chip--declined { background: var(--muted-soft); color: var(--crumb); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.chip--urgent { background: var(--bad-soft); color: var(--bad); }
.items li.is-urgent span:first-child { color: var(--bad); font-weight: 700; }
.items li.is-urgent small { display: block; font-size: 12px; font-weight: 600; }

/* ---------- учёт ---------- */

.hero { padding: 6px 0 18px; }
.hero__label { margin: 0; font-weight: 600; color: var(--crumb); }
.hero__value {
  margin: 6px 0 8px;
  font: 700 clamp(38px, 12vw, 52px)/1.05 var(--display);
  letter-spacing: -.02em;
  overflow-wrap: anywhere;
}
.sign { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 14px; }
.sign--up { color: var(--good); }
.sign--down { color: var(--bad); }
.sign--zero { color: var(--crumb); }

.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.tile {
  padding: 12px 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
}
.tile__label { margin: 0 0 6px; font-size: 12px; font-weight: 600; color: var(--crumb); }
.tile--link {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  width: 100%;
  text-align: left;
}
.tile__more { margin-top: 6px; font-size: 12px; font-weight: 700; color: var(--raspberry); }
.tile--link:active { background: var(--raspberry-soft); }
.tile__value { margin: 0; font-size: 16px; font-weight: 700; overflow-wrap: anywhere; }

.notice {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--wait-soft);
  color: var(--wait);
  font-size: 14px;
  font-weight: 600;
}

.btn {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 14px;
  padding: 14px;
  font-weight: 700;
  font-size: 16px;
}
.btn--primary { background: var(--raspberry); color: var(--on-accent); }
.btn--primary:disabled { opacity: .6; }
.btn--ghost { margin-top: 6px; background: transparent; color: var(--crumb); }
.btn--danger { margin-top: 8px; background: var(--bad-soft); color: var(--bad); }

/* ---------- список трат категории ---------- */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 6px;
  padding: 6px 0;
  border: 0;
  background: none;
  font-weight: 700;
  color: var(--raspberry);
}
.hero__value--small { font-size: clamp(30px, 9vw, 40px); }
.expenses { border-top: 1px solid var(--line); }
.expense {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 12px;
  width: 100%;
  padding: 12px 2px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  text-align: left;
}
.expense:active { background: var(--raspberry-soft); }
.expense__name { font-weight: 700; overflow-wrap: anywhere; }
.expense__sum { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.expense__sub { grid-column: 1 / -1; color: var(--crumb); font-size: 13px; white-space: pre-line; overflow-wrap: anywhere; }
#view-books { padding-bottom: 96px; }
.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  padding: 16px 16px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--paper) 72%, transparent);
}
.dock .btn { max-width: 608px; margin: 0 auto; box-shadow: var(--shadow); }

.table { border-top: 1px solid var(--line); }
.table__head,
.trow__main {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) repeat(3, minmax(0, 1fr));
  gap: 6px;
  align-items: center;
}
.table__head {
  padding: 10px 2px;
  font-size: 12px;
  font-weight: 600;
  color: var(--crumb);
}
.table__head span:not(:first-child),
.trow__main span:not(:first-child) { text-align: right; }
.trow { border-top: 1px solid var(--line); }
.trow__main {
  width: 100%;
  padding: 12px 2px;
  border: 0;
  background: transparent;
  text-align: left;
  font-variant-numeric: tabular-nums;
  font-size: 14px;
}
.trow__main span:first-child { font-weight: 700; }
.trow__main .neg { color: var(--bad); }
.trow__main .pos { color: var(--good); }
.trow.is-open .trow__main span:first-child::after { content: " ▾"; color: var(--crumb); }
.trow__main span:first-child::after { content: " ▸"; color: var(--crumb); }

.details { padding: 4px 2px 14px; }
.details h3 { margin: 10px 0 6px; font: 600 12px/1.2 var(--display); color: var(--crumb); }
.line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 12px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 14px;
}
.line:last-child { border-bottom: 0; }
.line__title { font-weight: 700; overflow-wrap: anywhere; }
.line__sum { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.line__sub { grid-column: 1; color: var(--crumb); font-size: 13px; overflow-wrap: anywhere; white-space: pre-line; }
.line__del {
  grid-column: 2;
  justify-self: end;
  border: 0;
  padding: 2px 0;
  background: none;
  color: var(--bad);
  font-size: 13px;
  font-weight: 600;
}

/* ---------- пустые состояния и ошибки ---------- */

.empty {
  padding: 36px 12px;
  text-align: center;
  color: var(--crumb);
}
.empty__title { margin: 0 0 6px; font: 600 16px/1.3 var(--display); color: var(--ink); }
.empty p { margin: 0; white-space: pre-line; }
.skeleton {
  height: 120px;
  margin-bottom: 12px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--muted-soft), var(--card), var(--muted-soft));
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite linear;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- форма траты ---------- */

.sheet { position: fixed; inset: 0; z-index: 20; touch-action: pan-y; }
.sheet__backdrop { position: absolute; inset: 0; background: rgba(27, 19, 21, .45); }
.sheet__panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 92vh;
  overflow-y: auto;
  padding: 10px 16px calc(16px + env(safe-area-inset-bottom));
  border-radius: 22px 22px 0 0;
  background: var(--paper);
  animation: rise .22s ease-out;
}
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
.sheet__grip { width: 40px; height: 4px; margin: 0 auto 12px; border-radius: 4px; background: var(--line-strong); }
.sheet__title { margin: 0 0 14px; font: 600 20px/1.2 var(--display); }

.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-bottom: 14px; border-radius: 14px; background: var(--muted-soft); }
.seg__item { border: 0; border-radius: 10px; padding: 9px 0; background: transparent; font-weight: 700; color: var(--crumb); }
.seg__item.is-active { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

.field { display: block; margin-bottom: 12px; }
.field__label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: var(--crumb); }
.field__input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--card);
  font-size: 16px;
}
.field__input--area { resize: vertical; min-height: 64px; }
.units { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.unit { border: 1px solid var(--line-strong); border-radius: 12px; padding: 10px 0; background: var(--card); font-weight: 700; }
.unit.is-active { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-error { margin: 0 0 12px; color: var(--bad); font-weight: 600; white-space: pre-line; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 30;
  transform: translateX(-50%);
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 700;
  font-size: 14px;
  max-width: calc(100% - 32px);
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
