:root {
  --bg: #FFF6EA;
  --card: #FFFFFF;
  --soft: #FBE9D2;
  --ink: #2B1D14;
  --ink-2: #6B5646;
  --line: rgba(43, 29, 20, .12);
  --tomato: #E8452C;
  --mustard: #F4C542;
  --green: #2E9F62;
  --blue: #3A6FD8;
  --radius: 18px;
  --shadow: 0 1px 0 rgba(43, 29, 20, .06), 0 10px 30px -18px rgba(43, 29, 20, .45);
  --head: "Unbounded", system-ui, sans-serif;
  --body: "Manrope", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1B1410; --card: #251C16; --soft: #33271F; --ink: #F6EBDD; --ink-2: #B9A898;
    --line: rgba(246, 235, 221, .12); --shadow: 0 1px 0 rgba(0, 0, 0, .3); color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 var(--body); -webkit-tap-highlight-color: transparent; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* ---------- каркас ---------- */
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { font-family: var(--head); font-weight: 700; font-size: 17px; letter-spacing: -.02em; display: flex; align-items: center; gap: 8px; }
.brand b { color: var(--tomato); }
.brand__dot { width: 28px; height: 28px; border-radius: 50%; background: var(--tomato); display: grid; place-items: center; color: #fff; font-size: 15px; }
.top__right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.chip-status { font-size: 12px; font-weight: 700; padding: 5px 10px; border-radius: 999px; background: var(--soft); white-space: nowrap; }
.chip-status.ok { background: rgba(46, 159, 98, .14); color: var(--green); }
.chip-status.warn { background: rgba(232, 69, 44, .12); color: var(--tomato); }

.tabs { display: flex; gap: 4px; padding: 4px; background: var(--soft); border-radius: 14px; }
.tab { border: 0; background: transparent; padding: 8px 14px; border-radius: 10px; font-weight: 700; cursor: pointer; color: var(--ink-2); }
.tab[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

main { max-width: 1080px; margin: 0 auto; padding: 16px 16px 110px; }
.view { animation: fade .25s ease; }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 0 16px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-weight: 700; cursor: pointer;
  text-decoration: none; white-space: nowrap; transition: transform .12s, background .15s, border-color .15s;
}
.btn:hover { border-color: color-mix(in srgb, var(--ink) 30%, transparent); }
.btn:active { transform: scale(.97); }
.btn--primary { background: var(--tomato); border-color: var(--tomato); color: #fff; }
.btn--primary:hover { background: #d63a22; border-color: #d63a22; }
.btn--ghost { background: transparent; }
.btn--danger { color: var(--tomato); }
.btn--sm { min-height: 34px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.icon-btn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); cursor: pointer; display: grid; place-items: center; }

/* ---------- даты ---------- */
.dates { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; margin: 0 -16px; padding-inline: 16px; scrollbar-width: none; }
.dates::-webkit-scrollbar { display: none; }
.date {
  flex: none; min-width: 92px; padding: 10px 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--card);
  cursor: pointer; text-align: left; position: relative; transition: transform .15s;
}
.date:active { transform: scale(.97); }
.date__label { font-family: var(--head); font-weight: 700; font-size: 15px; }
.date__rel { font-size: 12px; color: var(--ink-2); }
.date__count { position: absolute; top: -7px; right: -5px; min-width: 24px; height: 24px; padding: 0 7px; border-radius: 999px; background: var(--tomato); color: #fff; font-size: 12px; font-weight: 800; display: grid; place-items: center; }
.date[aria-selected="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.date[aria-selected="true"] .date__rel { color: color-mix(in srgb, var(--bg) 70%, transparent); }
.date.is-closed .date__label { text-decoration: line-through; opacity: .6; }

/* ---------- сводка ---------- */
.hero { display: grid; grid-template-columns: 1.3fr 1fr; gap: 12px; margin-bottom: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.day-title { font-family: var(--head); font-weight: 900; font-size: clamp(24px, 5vw, 34px); letter-spacing: -.03em; line-height: 1.05; margin: 0; }
.day-sub { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; background: var(--soft); }
.pill--open { background: rgba(46, 159, 98, .14); color: var(--green); }
.pill--closed { background: rgba(232, 69, 44, .12); color: var(--tomato); }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill--open .dot { animation: ping 1.6s infinite; }
.day-menu { margin: 12px 0 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
.day-menu li { padding: 5px 10px; border-radius: 10px; background: var(--soft); font-size: 14px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--soft); border-radius: 14px; padding: 12px; }
.stat b { display: block; font-family: var(--head); font-size: 30px; line-height: 1; letter-spacing: -.03em; }
.stat span { font-size: 12px; font-weight: 700; color: var(--ink-2); }
.stat--main { background: var(--mustard); color: #2B1D14; }
.stat--main span { color: rgba(43, 29, 20, .7); }
.hero__toggle { margin-top: 10px; width: 100%; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 14px; }
.notify-toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--ink-2); margin-left: auto; cursor: pointer; }
.notify-toggle input { width: 18px; height: 18px; accent-color: var(--tomato); }

/* ---------- заказы ---------- */
.orders { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; }
.order { position: relative; display: grid; grid-template-columns: 56px 1fr; gap: 12px; padding: 14px; transition: opacity .2s, transform .2s; }
.order.is-new { animation: flash 1.6s ease; }
.order.is-cancel { opacity: .5; }
.order.is-cancel .order__addr { text-decoration: line-through; }
.order.is-done { opacity: .72; }
.qty { width: 56px; height: 56px; border-radius: 16px; background: var(--soft); display: grid; place-content: center; text-align: center; }
.qty b { font-family: var(--head); font-size: 24px; line-height: 1; }
.qty span { font-size: 11px; font-weight: 700; color: var(--ink-2); }
.order__head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); font-weight: 600; }
.badge { padding: 2px 7px; border-radius: 6px; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.badge--vk { background: rgba(58, 111, 216, .14); color: var(--blue); }
.badge--phone { background: rgba(244, 197, 66, .3); color: #8A6400; }
.badge--slot { background: rgba(46, 159, 98, .14); color: var(--green); text-transform: none; letter-spacing: 0; font-size: 12px; }
.order__addr { font-weight: 800; font-size: 17px; margin: 4px 0 2px; line-height: 1.25; text-decoration: none; display: block; }
.order__addr:hover { color: var(--tomato); }
.order__line { font-size: 14px; display: flex; gap: 10px; flex-wrap: wrap; }
.order__line a { font-weight: 700; text-decoration: none; }
.order__comment { margin-top: 6px; padding: 6px 10px; border-radius: 10px; background: var(--soft); font-size: 14px; }
.order__foot { grid-column: 1 / -1; display: flex; gap: 6px; align-items: center; }
.seg { display: flex; flex: 1; background: var(--soft); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 9px; padding: 7px 4px; font-size: 13px; font-weight: 700; cursor: pointer; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.seg button[data-s="way"][aria-pressed="true"] { background: var(--blue); color: #fff; }
.seg button[data-s="done"][aria-pressed="true"] { background: var(--green); color: #fff; }
.empty { text-align: center; padding: 48px 16px; color: var(--ink-2); }
.empty b { display: block; font-size: 42px; margin-bottom: 6px; }

/* ---------- меню ---------- */
.paste { display: grid; gap: 10px; }
.paste textarea { min-height: 160px; }
.week { margin-top: 18px; }
.week__title { display: flex; align-items: baseline; gap: 10px; margin: 0 0 10px; font-family: var(--head); font-size: 18px; }
.week__title span { font-family: var(--body); font-size: 13px; font-weight: 700; color: var(--tomato); }
.week__days { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.mday { padding: 12px; display: flex; flex-direction: column; gap: 8px; min-height: 150px; }
.mday.is-past { opacity: .55; }
.mday__head { display: flex; justify-content: space-between; align-items: center; font-weight: 800; }
.mday ol { margin: 0; padding-left: 18px; font-size: 14px; display: grid; gap: 4px; }
.mday__empty { color: var(--ink-2); font-size: 14px; flex: 1; }
.mday textarea { min-height: 110px; font-size: 14px; }
.pic { position: relative; margin-top: auto; }
.pic img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); }
.pic__kind { position: absolute; left: 6px; top: 6px; padding: 2px 8px; border-radius: 999px; background: rgba(43, 29, 20, .75); color: #fff; font-size: 11px; font-weight: 700; }
.pic__empty { border: 1px dashed var(--line); border-radius: 12px; padding: 18px 6px; text-align: center; font-size: 12px; color: var(--ink-2); }
.pic__btns { display: flex; gap: 6px; }
.pic__btns .btn { flex: 1; padding: 0 6px; font-size: 13px; }
@media (max-width: 760px) { .pic img { max-width: 220px; } }

/* ---------- формы ---------- */
label.f { display: grid; gap: 5px; font-size: 13px; font-weight: 700; color: var(--ink-2); }
input[type=text], input[type=tel], input[type=search], input[type=number], input[type=password], textarea, select {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg);
  outline: none; transition: border-color .15s, box-shadow .15s; resize: vertical; font-weight: 500; color: var(--ink);
}
input:focus, textarea:focus, select:focus { border-color: var(--tomato); box-shadow: 0 0 0 3px rgba(232, 69, 44, .15); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.preview { background: var(--soft); border-radius: 14px; padding: 12px; font-size: 14px; }
.preview h4 { margin: 0 0 4px; }
.preview ul { margin: 0 0 8px; padding-left: 18px; }
.warn { color: var(--tomato); font-weight: 700; font-size: 14px; }

/* ---------- доход ---------- */
.npd { margin-bottom: 12px; }
.npd__head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.npd__sum b { font-family: var(--head); font-size: clamp(26px, 6vw, 38px); letter-spacing: -.03em; }
.npd__pct { font-family: var(--head); font-weight: 900; font-size: 28px; color: var(--green); }
.npd__pct.warn { color: #C98A00; }
.npd__pct.danger { color: var(--tomato); }
.npd__track { position: relative; height: 16px; border-radius: 999px; background: var(--soft); overflow: hidden; margin: 12px 0 10px; }
.npd__fill { height: 100%; width: 0; border-radius: 999px; background: var(--green); transition: width .9s cubic-bezier(.34, 1.56, .64, 1); }
.npd__fill.warn { background: var(--mustard); }
.npd__fill.danger { background: var(--tomato); }
.npd__note { margin: 0; font-size: 15px; }
.money-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.money-stats .stat b { font-size: 24px; }
.card + .card, .money-stats + .card { margin-top: 12px; }
.card-title { margin: 0 0 10px; font-size: 16px; }
.months { display: flex; align-items: flex-end; gap: 6px; height: 150px; }
.month { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; height: 100%; min-width: 0; }
.month__bar { width: 100%; max-width: 44px; border-radius: 8px 8px 3px 3px; background: var(--tomato); min-height: 3px; transition: height .8s cubic-bezier(.2, .8, .2, 1); }
.month__val { font-size: 11px; font-weight: 800; white-space: nowrap; }
.month__name { font-size: 11px; color: var(--ink-2); }
.income-form { display: grid; grid-template-columns: 1fr 2fr 1fr auto; gap: 8px; margin-bottom: 10px; }
.income { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.income b { white-space: nowrap; }
.receipts { width: 100%; border-collapse: collapse; font-size: 15px; }
.receipts td { padding: 8px 4px; border-top: 1px solid var(--line); }
.receipts td:last-child { text-align: right; font-weight: 800; white-space: nowrap; }
.range { display: flex; flex-wrap: wrap; gap: 6px; }
.range button[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
@media (max-width: 760px) {
  .money-stats { grid-template-columns: repeat(2, 1fr); }
  .income-form { grid-template-columns: 1fr 1fr; }
  .income-form input[type=text] { grid-column: 1 / -1; order: -1; }
}

/* ---------- воронка ---------- */
.funnel { margin-bottom: 12px; }
.funnel__head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.fstep { display: grid; grid-template-columns: minmax(0, 190px) minmax(0, 1fr) 76px; gap: 10px; align-items: center; margin: 6px 0; font-size: 14px; }
.fstep__bar { height: 22px; border-radius: 7px; background: var(--soft); overflow: hidden; }
.fstep__bar div { height: 100%; background: var(--tomato); border-radius: 7px; min-width: 2px; transition: width .7s cubic-bezier(.2, .8, .2, 1); }
.fstep--final .fstep__bar div { background: var(--green); }
.fstep__n { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }
.fstep__n small { display: block; font-weight: 600; color: var(--ink-2); font-size: 11px; }
.fdrop { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 6px; font-size: 13px; }
.fdrop span { padding: 4px 10px; border-radius: 999px; background: var(--soft); }
@media (max-width: 560px) { .fstep { grid-template-columns: minmax(0, 1fr) 64px; } .fstep__bar { grid-column: 1 / -1; order: 3; } }

/* ---------- клиенты ---------- */
.clients { display: grid; gap: 8px; margin-top: 12px; }
.client { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 12px 14px; }
.client__name { font-weight: 800; }
.client__meta { font-size: 14px; color: var(--ink-2); }
.client__num { text-align: right; font-size: 13px; color: var(--ink-2); }
.client__num b { display: block; font-family: var(--head); font-size: 20px; color: var(--ink); }

/* ---------- модалка ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: end center; background: rgba(20, 12, 8, .45); animation: fade .2s; }
.modal__box { width: min(560px, 100%); max-height: 92vh; overflow: auto; background: var(--card); border-radius: 22px 22px 0 0; padding: 18px 16px 24px; animation: up .3s cubic-bezier(.2, .8, .2, 1); }
.modal__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal__head h3 { margin: 0; font-family: var(--head); font-size: 19px; }
.modal__body { display: grid; gap: 10px; }
.modal__foot { display: flex; gap: 8px; margin-top: 14px; }
.modal__foot .btn { flex: 1; }
@media (min-width: 700px) { .modal { place-items: center; } .modal__box { border-radius: 22px; } }

.sheet { font-size: 15px; }
.sheet ol { padding-left: 22px; margin: 0; display: grid; gap: 8px; }
.sheet li b { font-weight: 800; }

/* ---------- нижняя навигация и тост ---------- */
.nav-bottom { display: none; }
.toast {
  position: fixed; left: 50%; bottom: 90px; z-index: 60; transform: translate(-50%, 30px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 14px; font-weight: 700; font-size: 14px;
  transition: transform .3s cubic-bezier(.2, .8, .2, 1), opacity .3s; width: max-content; max-width: calc(100% - 32px); text-align: center;
}
.toast.on { transform: translate(-50%, 0); opacity: 1; }

/* ---------- вход ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { width: min(360px, 100%); display: grid; gap: 12px; }
.login h1 { font-family: var(--head); font-size: 26px; margin: 8px 0 0; letter-spacing: -.03em; }
.login .brand__dot { width: 52px; height: 52px; font-size: 26px; }

@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px var(--mustard); } }
@keyframes ping { 70% { box-shadow: 0 0 0 7px transparent; } 0% { box-shadow: 0 0 0 0 currentColor; } }

@media (max-width: 760px) {
  .top .tabs { display: none; }
  .nav-bottom {
    display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--card); border-top: 1px solid var(--line); padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  }
  .nav-bottom button { border: 0; background: none; padding: 6px; border-radius: 12px; font-size: 12px; font-weight: 700; color: var(--ink-2); display: grid; justify-items: center; gap: 2px; cursor: pointer; }
  .nav-bottom button i { font-style: normal; font-size: 20px; }
  .nav-bottom button[aria-selected="true"] { color: var(--tomato); background: var(--soft); }
  .hero { grid-template-columns: 1fr; }
  .orders { grid-template-columns: 1fr; }
  .week__days { grid-template-columns: 1fr; }
  .mday { min-height: 0; }
  .notify-toggle { margin-left: 0; width: 100%; }
  .actions .btn { flex: 1 1 auto; }
}
@media print {
  .top, .nav-bottom, .actions, .dates, .hero, .order__foot, .toast { display: none !important; }
  .modal { position: static; background: none; }
  .modal__box { box-shadow: none; max-height: none; }
  .modal__foot, .modal__head button { display: none; }
  body.printing main { display: none; }
}

/* ---------- вкладка «Сервис» (только разработчик) ---------- */
.sys-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.sys-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 12px; }
.sys-tile { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; display: grid; gap: 2px; min-width: 0; }
.sys-tile b { font-family: var(--head); font-size: 20px; font-variant-numeric: tabular-nums; }
.sys-tile span { color: var(--ink-2); font-size: 13px; }
.sys-tile.ok b { color: var(--green); }
.sys-tile.bad b { color: var(--tomato); }
.sys-log { margin: 0; max-height: 320px; overflow: auto; background: var(--soft); border-radius: 12px; padding: 10px 12px;
  font: 12px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap; word-break: break-word; }
.sys-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.sys-row:last-child { border-bottom: 0; }
