/* Сначала телефон, на широком экране только добавляется верхнее меню. */
:root {
  --bg: #f5f5f7; --card: #fff; --text: #1d1d1f; --muted: #6e6e73; --line: #ececf0; --field: #f2f2f5;
  --blue: #0071e3; --red: #d70015; --orange: #b25000; --green: #1d8039;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 16px/1.4 var(--sans); -webkit-font-smoothing: antialiased; font-feature-settings: "tnum"; }
a { color: var(--blue); text-decoration: none; }
small { font-size: .7em; font-weight: 500; color: var(--muted); }
[hidden] { display: none !important; }

/* Шапка и нижнее меню */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; height: 48px; padding: 0 14px; background: var(--bg); }
.brand { font-weight: 600; font-size: 17px; letter-spacing: -.02em; color: var(--text); }
.nav { position: fixed; z-index: 25; left: 0; right: 0; bottom: 0; display: flex; padding: 5px 6px calc(5px + env(safe-area-inset-bottom)); background: rgba(250,250,252,.94); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-top: 1px solid rgba(0,0,0,.08); }
.nav a { flex: 1; display: flex; align-items: center; justify-content: center; height: 44px; border-radius: 12px; color: var(--muted); font-size: 14px; }
.nav a.on { color: var(--text); background: rgba(0,0,0,.06); font-weight: 600; }
.right { margin-left: auto; }

/* Раскрывающиеся списки */
details > summary { list-style: none; cursor: pointer; user-select: none; }
details > summary::-webkit-details-marker { display: none; }
.drop { position: relative; }
.drop > summary { font-size: 14px; padding: 6px 12px; border-radius: 980px; background: rgba(0,0,0,.05); white-space: nowrap; }
.drop > summary::after, .more > summary::after { content: ""; display: inline-block; width: 6px; height: 6px; margin: 0 2px 3px 8px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(45deg); transition: transform .15s; }
.drop[open] > summary::after, .more[open] > summary::after { transform: translateY(3px) rotate(-135deg); }
.pop { position: absolute; z-index: 30; right: 0; top: calc(100% + 8px); width: 240px; padding: 12px; background: #fff; border-radius: 16px; box-shadow: 0 12px 40px rgba(0,0,0,.16); }
.pop p { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.pop button, .pop .btn { display: block; width: 100%; margin-top: 6px; }
.more > summary { display: flex; align-items: center; justify-content: space-between; min-height: 44px; font-size: 15px; font-weight: 500; }
.card.more { padding-top: 2px; padding-bottom: 2px; }
.card.more[open] { padding-bottom: 12px; }
.soft > summary { color: var(--muted); font-weight: 400; font-size: 14px; min-height: 36px; }

/* Страница */
main { max-width: 620px; margin: 0 auto; padding: 2px 14px calc(76px + env(safe-area-inset-bottom)); }
.head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
h1 { font-size: 26px; line-height: 1.15; font-weight: 700; letter-spacing: -.025em; margin: 0; }
.head .actions { margin-left: auto; display: flex; gap: 6px; }
.back { display: inline-block; font-size: 15px; padding: 2px 0 6px; }
h2 { display: flex; justify-content: space-between; align-items: baseline; font-size: 18px; font-weight: 600; letter-spacing: -.015em; margin: 20px 2px 8px; }
h2 b { font-weight: 600; }
h3 { font-size: 16px; font-weight: 600; margin: 0; }
.card { display: block; background: var(--card); border-radius: 14px; padding: 12px 14px; color: inherit; }
.stack { margin-top: 8px; }
.grid3 { display: grid; gap: 8px; }

/* Полоса «что заказать» */
.strip { display: grid; grid-template-columns: 1fr 1fr 1.25fr; gap: 6px; }
.strip a { display: block; padding: 10px 11px; background: var(--card); border-radius: 13px; color: inherit; }
.strip b { display: block; font-size: 21px; line-height: 1.15; font-weight: 600; letter-spacing: -.02em; white-space: nowrap; }
.strip span { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.strip .red b { color: var(--red); } .strip .orange b { color: var(--orange); }

/* Строки-карточки */
.list { background: var(--card); border-radius: 14px; padding: 0 14px; }
.go { display: flex; align-items: center; gap: 10px; min-height: 60px; padding: 9px 0; color: inherit; border-top: 1px solid var(--line); }
.list > .go:first-child, .list > .rec:first-child { border-top: 0; }
.go .main, .rec .main { flex: 1; min-width: 0; }
.go .t { font-size: 16px; font-weight: 500; }
.go .amt { font-size: 21px; font-weight: 600; letter-spacing: -.02em; white-space: nowrap; }
.go.small .amt { font-size: 16px; font-weight: 500; letter-spacing: 0; }
.go::after { content: ""; flex: none; width: 7px; height: 7px; border-top: 1.5px solid #b0b0b6; border-right: 1.5px solid #b0b0b6; transform: rotate(45deg); }
.sub { font-size: 13px; color: var(--muted); line-height: 1.3; margin-top: 1px; overflow-wrap: anywhere; }
.rec { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; min-height: 52px; padding: 8px 0; border-top: 1px solid var(--line); }
.rec.click { cursor: pointer; }
.rec .t { font-size: 15px; overflow-wrap: anywhere; }
.thumb { flex: none; width: 44px; height: 44px; border-radius: 10px; background: var(--field); overflow: hidden; }
.thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.rec .amt { font-size: 15px; font-weight: 500; white-space: nowrap; }
.rec .extra { flex-basis: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); }
.dayhead { font-size: 13px; font-weight: 600; color: var(--muted); padding: 12px 0 2px; }
.list > .dayhead:first-child { padding-top: 10px; }
.dayhead + .rec { border-top: 0; }
.day > summary { display: flex; align-items: center; gap: 10px; min-height: 58px; padding: 8px 0; border-top: 1px solid var(--line); }
.list > .day:first-child > summary { border-top: 0; }
.day > summary .main { flex: 1; }
.day > summary .t { font-weight: 500; }
.day > summary .amt { font-weight: 600; white-space: nowrap; }
.day > summary::after { content: ""; width: 7px; height: 7px; border-right: 1.5px solid #b0b0b6; border-bottom: 1.5px solid #b0b0b6; transform: rotate(45deg); transition: transform .15s; }
.day[open] > summary::after { transform: rotate(-135deg); }
.block-title { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; padding: 8px 0 0; }
.hist { font-size: 13px; color: var(--muted); padding: 4px 0; }

/* Цифры */
.big { font-size: 32px; font-weight: 600; letter-spacing: -.03em; line-height: 1.15; }
.cap { font-size: 13px; color: var(--muted); }
.note { font-size: 13px; color: var(--muted); margin: 8px 2px 0; }
.bad { color: var(--red); } .good { color: var(--green); }
.line { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; font-size: 15px; }
.line span:first-child { color: var(--muted); }
.line b { font-weight: 500; white-space: nowrap; }
.line.sum { border-top: 1px solid var(--line); margin-top: 3px; padding-top: 8px; }
.line.sum span:first-child { color: var(--text); font-weight: 500; }
.line.sum b { font-weight: 600; }
.status { font-size: 13px; font-weight: 500; white-space: nowrap; }
.s0 { color: var(--red); } .s1 { color: var(--orange); } .s2 { color: #86868b; } .s3 { color: var(--green); }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
td { border-top: 1px solid var(--line); padding: 9px 0; } tr:first-child td { border-top: 0; }
td.n, th.n { text-align: right; white-space: nowrap; }
tr.total td { font-weight: 600; }
th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 0 0 6px; }

/* Формы и кнопки: высота под палец */
button, .btn { display: inline-block; min-height: 40px; font: 500 15px/1.2 var(--sans); padding: 9px 16px; border: 0; border-radius: 12px; background: var(--blue); color: #fff; cursor: pointer; text-align: center; }
button.ghost, .btn.ghost { background: rgba(0,0,0,.06); color: var(--text); }
button.danger { background: none; color: var(--red); padding-left: 0; }
button.small { min-height: 34px; padding: 6px 11px; font-size: 13px; background: rgba(0,0,0,.06); color: var(--text); }
input, select { width: 100%; font: 400 16px/1.3 var(--sans); color: var(--text); padding: 10px 12px; border: 1px solid transparent; border-radius: 11px; background: var(--field); outline: none; appearance: none; -webkit-appearance: none; }
select { padding-right: 28px; background-image: linear-gradient(45deg, transparent 50%, #86868b 50%), linear-gradient(135deg, #86868b 50%, transparent 50%); background-position: right 15px center, right 10px center; background-size: 5px 5px; background-repeat: no-repeat; }
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,113,227,.16); background-color: #fff; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 9px; }
label input, label select { margin-top: 3px; }
input.qty { width: 54px; min-height: 34px; padding: 5px 7px; text-align: right; font-size: 14px; }
.inline { display: flex; align-items: center; gap: 5px; }
.dates { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px; }
.dates input { background-color: #fff; font-size: 15px; padding: 9px 10px; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px; }
.filters select { background-color: #fff; font-size: 15px; padding: 9px 26px 9px 10px; }
.filters.one { grid-template-columns: 1fr; }

/* Вкладки помещаются в одну строку */
.tabs { display: flex; gap: 2px; padding: 3px; margin-bottom: 10px; background: rgba(0,0,0,.06); border-radius: 11px; }
.tabs a { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 36px; padding: 0 2px; border-radius: 9px; color: var(--text); font-size: 13.5px; white-space: nowrap; }
.tabs a.on { background: #fff; font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.badge { display: inline-block; min-width: 17px; padding: 0 4px; margin-left: 3px; border-radius: 9px; background: var(--red); color: #fff; font-size: 11px; line-height: 17px; text-align: center; }

/* Окна */
dialog { width: min(440px, calc(100vw - 20px)); max-height: 90vh; border: 0; border-radius: 20px; padding: 18px; color: var(--text); box-shadow: 0 24px 70px rgba(0,0,0,.28); }
dialog::backdrop { background: rgba(0,0,0,.34); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); }
dialog h3 { font-size: 20px; margin-bottom: 12px; letter-spacing: -.02em; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 8px; }
.foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; }
.foot .gap { display: flex; gap: 6px; margin-left: auto; }

/* Сообщения и вход */
.msg { background: #fff; border-radius: 12px; padding: 10px 13px; margin-bottom: 8px; font-size: 14px; box-shadow: 0 2px 12px rgba(0,0,0,.08); }
.err { color: var(--red); }
.login { max-width: 340px; margin: 12vh auto; padding: 26px 22px; }
.login h1 { margin-bottom: 16px; text-align: center; }
.login input { margin-bottom: 8px; } .login button { width: 100%; min-height: 46px; font-size: 16px; }

@media (min-width: 761px) {
  .top { gap: 22px; height: 52px; padding: 0 max(20px, calc((100vw - 620px) / 2)); background: rgba(245,245,247,.84); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); border-bottom: 1px solid rgba(0,0,0,.06); }
  .nav { position: static; padding: 0; gap: 4px; background: none; border: 0; backdrop-filter: none; -webkit-backdrop-filter: none; }
  .nav a { flex: none; height: auto; padding: 6px 12px; border-radius: 980px; }
  main { padding: 18px 14px 50px; }
}
