:root {
  --bg: #f3f6fc;
  --card: #ffffff;
  --line: #e6ecf7;
  --text: #16233d;
  --ink: #0e1b33;
  --muted: #7b879b;
  --navy: #12203a;
  --navy-2: #1e3a6e;
  --accent: #3a6ed6;
  --accent-2: #5b8cf0;
  --accent-soft: #eaf0fd;
  --surface-2: #f2f6fd;
  --header-a: #12203a;
  --header-b: #1e3a6e;
  --header-c: #2c57a8;
  --head-foot: rgba(243, 246, 252, 0);
  --tabs-bg: rgba(255, 255, 255, .93);
  --tabs-line: rgba(230, 236, 247, .9);
  --amber: #dd8a2b;
  --amber-soft: #fdf3e4;
  --green: #1c9b72;
  --green-soft: #e6f6f0;
  --red: #c2413f;
  --red-soft: #fdeceb;
  --radius: 20px;
  --shadow: 0 1px 2px rgba(14, 27, 51, .05), 0 8px 24px rgba(14, 27, 51, .06);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #0b1220;
  --card: #141d2e;
  --line: #233046;
  --text: #e7eefb;
  --ink: #ffffff;
  --muted: #8ea1c0;
  --navy: #0d1526;
  --navy-2: #16233a;
  --accent: #5b8cf0;
  --accent-2: #86acff;
  --accent-soft: #1b2a44;
  --surface-2: #1a2334;
  --header-a: #0b1220;
  --header-b: #14213a;
  --header-c: #1d3157;
  --head-foot: rgba(11, 18, 32, 0);
  --tabs-bg: rgba(20, 29, 46, .94);
  --tabs-line: rgba(35, 48, 70, .9);
  --amber: #f0a53c;
  --amber-soft: #2c2214;
  --green: #35c79a;
  --green-soft: #10291f;
  --red: #ef6b68;
  --red-soft: #2b1618;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 24px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overscroll-behavior-y: contain;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(1200px 420px at 50% -160px, var(--accent-soft) 0%, rgba(234, 240, 253, 0) 70%),
    var(--bg);
  transition: background .2s;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  padding-bottom: calc(96px + var(--safe-b));
}

/* ---------- top bar ---------- */
#topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  color: #fff;
  background: linear-gradient(135deg, var(--header-a) 0%, var(--header-b) 55%, var(--header-c) 100%);
  padding: calc(16px + env(safe-area-inset-top, 0px)) 20px 20px;
  border-radius: 0 0 26px 26px;
  box-shadow: 0 12px 30px rgba(9, 18, 36, .2);
}
#topbar .row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
#topbar h1 { font-size: 21px; margin: 0; font-weight: 800; letter-spacing: -.2px; }
#topbar .sub { font-size: 12.5px; color: #a9bcdf; margin-top: 3px; }
#topbar .pill {
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .18);
  color: #fff;
  font-size: 12px;
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 600;
}

/* ---------- tabs ---------- */
#tabs {
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: calc(10px + var(--safe-b));
  z-index: 40;
  display: flex;
  gap: 4px;
  padding: 7px;
  max-width: 540px;
  margin: 0 auto;
  background: var(--tabs-bg);
  backdrop-filter: blur(14px);
  border: 1px solid var(--tabs-line);
  border-radius: 22px;
  box-shadow: 0 10px 30px rgba(9, 18, 36, .16);
}
#tabs button {
  flex: 1;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .01em;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 9px 2px;
  border-radius: 16px;
  transition: background .18s, color .18s;
}
#tabs button svg { width: 21px; height: 21px; }
#tabs button { position: relative; }
.tabdot { position: absolute; top: 7px; right: 50%; margin-right: -14px; width: 8px; height: 8px; border-radius: 50%; background: #e2574c; box-shadow: 0 0 0 2px var(--tabs-bg); }
#tabs button.on {
  color: #fff;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  box-shadow: 0 8px 18px rgba(58, 110, 214, .32);
}

/* ---------- fab ---------- */
#fab {
  position: fixed;
  z-index: 35;
  right: max(18px, calc((100vw - 560px) / 2 + 18px));
  bottom: calc(104px + var(--safe-b));
  width: 60px;
  height: 60px;
  border-radius: 20px;
  border: 0;
  color: #fff;
  background: linear-gradient(140deg, var(--accent-2) 0%, var(--accent) 100%);
  box-shadow: 0 14px 28px rgba(47, 95, 196, .38);
  display: grid;
  place-items: center;
}
#fab svg { width: 26px; height: 26px; }

/* ---------- common ---------- */
main { padding: 16px 16px 8px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.h2 {
  font-size: 11.5px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .12em;
  margin: 22px 6px 10px;
}
.empty { text-align: center; color: var(--muted); padding: 38px 20px; font-size: 14px; }
.empty b { display: block; color: var(--text); font-size: 17px; margin-bottom: 8px; font-weight: 800; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- day ---------- */
.datebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 12px 8px;
}
.datebar .nav {
  width: 40px; height: 40px;
  border: 0;
  border-radius: 13px;
  background: var(--surface-2);
  color: var(--accent);
  display: grid;
  place-items: center;
  flex: none;
}
.datebar .nav svg { width: 20px; height: 20px; }
.datebar .center { text-align: center; flex: 1; min-width: 0; padding: 0 4px; }
.datebar .dow {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--muted);
  font-weight: 800;
}
.datebar .dnum { font-size: 19px; font-weight: 800; letter-spacing: -.3px; margin-top: 2px; white-space: nowrap; }
.datebar .today {
  border: 0;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 11.5px;
  border-radius: 11px;
  padding: 9px 10px;
  flex: none;
  margin-right: 4px;
}

.stats { display: flex; gap: 10px; margin-top: 12px; }
.stat {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 14px 12px;
}
.stat .v { font-size: 26px; font-weight: 800; color: var(--ink); line-height: 1.05; letter-spacing: -.5px; }
.stat .k { font-size: 11px; color: var(--muted); margin-top: 4px; font-weight: 600; }

/* ---------- entry cards ---------- */
.list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.entry {
  display: flex;
  gap: 13px;
  align-items: center;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 13px;
  width: 100%;
  color: inherit;
}
.entry .ic {
  width: 46px; height: 46px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  flex: none;
}
.entry .ic svg { width: 23px; height: 23px; }
.entry .body { flex: 1; min-width: 0; }
.entry .t { font-weight: 800; font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.1px; }
.entry .s { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 3px; }
.entry .r { text-align: right; flex: none; }
.entry .r .n { font-size: 19px; font-weight: 800; color: var(--ink); letter-spacing: -.4px; }
.entry .r .u { font-size: 10px; color: var(--muted); font-weight: 600; }
.thumbs { display: flex; gap: 5px; margin-top: 7px; }
.thumbs img { width: 36px; height: 36px; object-fit: cover; border-radius: 10px; }

.ic.assembly { background: linear-gradient(135deg, #e8f0ff, #d7e6ff); color: #2f5fc4; }
.ic.montage { background: linear-gradient(135deg, #efe9ff, #e0d6ff); color: #5b46b8; }
.ic.house { background: linear-gradient(135deg, #fdf1e0, #fbe6c8); color: #b06f1b; }
.ic.delivery { background: linear-gradient(135deg, #e4f6ee, #d3efe2); color: #16795a; }
.ic.repair { background: linear-gradient(135deg, #fdecec, #fbdada); color: #b03a3a; }
.ic.other { background: linear-gradient(135deg, #eaf1fb, #dbe7fb); color: #3a63a8; }

html[data-theme="dark"] .ic.assembly { background: linear-gradient(135deg, #1c2c4a, #22375c); color: #93b6ff; }
html[data-theme="dark"] .ic.montage { background: linear-gradient(135deg, #2a2246, #322a55); color: #c2b0ff; }
html[data-theme="dark"] .ic.house { background: linear-gradient(135deg, #3a2c17, #453320); color: #f0b465; }
html[data-theme="dark"] .ic.delivery { background: linear-gradient(135deg, #122e26, #163830); color: #6fdcb4; }
html[data-theme="dark"] .ic.repair { background: linear-gradient(135deg, #3a1e20, #452427); color: #ff9c98; }
html[data-theme="dark"] .ic.other { background: linear-gradient(135deg, #1c283c, #22314a); color: #9db8e0; }

/* ---------- chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 13px;
  padding: 10px 14px;
  font-size: 13.5px;
  font-weight: 600;
}
.chip.on {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 14px rgba(58, 110, 214, .26);
}
.chip.sm { padding: 7px 12px; font-size: 12.5px; border-radius: 11px; }

/* ---------- sheet (editor) ---------- */
#sheet {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--bg);
  display: none;
  flex-direction: column;
}
#sheet.open { display: flex; }
.sheet-head {
  color: #fff;
  background: linear-gradient(135deg, var(--header-a) 0%, var(--header-b) 60%, var(--header-c) 100%);
  padding: calc(14px + env(safe-area-inset-top, 0px)) 14px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 0 0 22px 22px;
}
.sheet-head .ttl { flex: 1; font-weight: 800; font-size: 17px; padding-left: 4px; letter-spacing: -.2px; }
.sheet-head button {
  border: 1px solid rgba(255, 255, 255, .16);
  background: rgba(255, 255, 255, .12);
  color: #fff;
  border-radius: 13px;
  padding: 10px 14px;
  font-weight: 700;
  font-size: 14px;
}
.sheet-head button.primary { background: #fff; color: var(--navy); border: 0; }
.sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px calc(130px + var(--safe-b));
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
}
.sheet-foot {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px 16px calc(12px + var(--safe-b));
  background: linear-gradient(180deg, var(--head-foot) 0%, var(--bg) 45%);
  max-width: 560px;
  margin: 0 auto;
}
.sheet-foot button {
  width: 100%;
  border: 0;
  border-radius: 16px;
  padding: 17px;
  background: linear-gradient(135deg, var(--accent-2) 0%, var(--accent) 100%);
  color: #fff;
  font-weight: 800;
  font-size: 16px;
  box-shadow: 0 12px 26px rgba(47, 95, 196, .32);
}

.field { margin-bottom: 16px; }
.field > label {
  display: block;
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .1em;
  margin: 0 6px 8px;
}
input[type=text], input[type=number], input[type=date], input[type=time], textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 14px;
  padding: 13px 15px;
  font: inherit;
  color: var(--text);
  outline: none;
  box-shadow: 0 1px 2px rgba(14, 27, 51, .03);
}
input::placeholder, textarea::placeholder { color: var(--muted); }
input[type=checkbox] { accent-color: var(--accent); width: 20px; height: 20px; }
input[type=checkbox] + span { line-height: 1.35; }
input:focus, textarea:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 4px rgba(91, 140, 240, .16);
}
textarea { resize: vertical; min-height: 88px; }

.typegrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.typebtn {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 16px;
  padding: 16px 13px;
  text-align: left;
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 1px 2px rgba(14, 27, 51, .03);
}
.typebtn svg { width: 24px; height: 24px; }
.typebtn.on {
  border-color: transparent;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 20px rgba(58, 110, 214, .28);
}

.screen-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 12px;
}
.screen-card .sc-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.screen-card .sc-head .nm { font-weight: 800; font-size: 14.5px; color: var(--ink); }
.screen-card .del { border: 0; background: var(--red-soft); color: var(--red); border-radius: 11px; padding: 9px 11px; font-weight: 600; }

.sizerow { display: flex; gap: 10px; }
.sizebox {
  flex: 1;
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: var(--card);
}
.sizebox button { border: 0; background: var(--surface-2); width: 40px; height: 48px; font-size: 20px; color: var(--accent); font-weight: 700; }
.sizebox input { border: 0; box-shadow: none; text-align: center; flex: 1; width: 100%; padding: 12px 0; font-weight: 800; font-size: 16px; }
.sizebox .unit { font-size: 11px; color: var(--muted); padding-right: 8px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 12px;
  padding: 7px 12px;
  font-size: 12.5px;
  font-weight: 700;
  margin-top: 9px;
}
.badge.ok { background: var(--green-soft); color: var(--green); }
.badge.warn { background: var(--amber-soft); color: var(--amber); }

.addrow {
  width: 100%;
  border: 1px dashed var(--line);
  background: var(--surface-2);
  color: var(--accent);
  border-radius: 16px;
  padding: 14px;
  font-weight: 700;
  font-size: 14.5px;
}

.photo-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.photo-grid .ph { position: relative; aspect-ratio: 1; border-radius: 14px; overflow: hidden; background: var(--surface-2); }
.photo-grid .ph img { width: 100%; height: 100%; object-fit: cover; }
.photo-grid .ph button {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 23px;
  height: 23px;
  border: 0;
  border-radius: 50%;
  background: rgba(10, 16, 28, .62);
  color: #fff;
  font-size: 13px;
  line-height: 1;
}
.photo-grid .add {
  aspect-ratio: 1;
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: var(--card);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 26px;
}
.photo-grid .add svg { width: 26px; height: 26px; }
.photo-grid .ph .dur {
  position: absolute;
  left: 4px;
  bottom: 4px;
  background: rgba(10, 16, 28, .7);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 7px;
}
.photo-grid .ph.vid .vplaceholder { width: 100%; height: 100%; display: grid; place-items: center; color: #cfdcf5; font-size: 22px; background: linear-gradient(135deg, #1a2b4d, #24406e); }

/* ---------- report ---------- */
.report-tabs { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.report-tabs .m { font-size: 18px; font-weight: 800; letter-spacing: -.3px; text-transform: capitalize; }
.report-tabs button {
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow);
  width: 46px;
  height: 46px;
  border-radius: 15px;
  color: var(--accent);
  display: grid;
  place-items: center;
}

.rtable { margin-top: 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.rtable .rh {
  display: grid;
  grid-template-columns: 1fr 62px;
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--header-a), var(--header-c));
  color: #fff;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.rrow { display: grid; grid-template-columns: 1fr 62px; padding: 12px 16px; border-top: 1px solid var(--line); gap: 8px; }
.rrow .l { min-width: 0; }
.rrow .t { font-weight: 800; font-size: 14.5px; }
.rrow .s { font-size: 12px; color: var(--muted); margin-top: 3px; }
.rrow .n { text-align: right; font-weight: 800; color: var(--ink); font-size: 16px; }
.rrow .n small { display: block; font-size: 10px; color: var(--muted); font-weight: 600; }
.rrow.act .t { color: var(--muted); font-style: italic; font-weight: 600; }
.rtotal {
  display: grid;
  grid-template-columns: 1fr 62px;
  padding: 13px 16px;
  background: linear-gradient(135deg, var(--header-a), var(--header-c));
  color: #fff;
  font-weight: 800;
}
.rtotal.one { grid-template-columns: 1fr; text-align: center; font-size: 14px; }
.rtotal .n { text-align: right; font-size: 17px; }

.actions { display: flex; gap: 10px; margin-top: 14px; }
.actions button { flex: 1; border: 0; border-radius: 16px; padding: 16px; font-weight: 800; font-size: 15px; }
.btn-main {
  background: linear-gradient(135deg, var(--accent-2) 0%, var(--accent) 100%);
  color: #fff;
  box-shadow: 0 12px 26px rgba(47, 95, 196, .3);
}
.btn-ghost { background: var(--card); color: var(--accent); border: 1px solid var(--line) !important; }

/* ---------- orders ---------- */
.searchbox {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 4px 14px;
  box-shadow: var(--shadow);
}
.searchbox input { border: 0; box-shadow: none; padding: 13px 0; }
.order-row { display: flex; gap: 12px; align-items: center; padding: 14px 16px; border-top: 1px solid var(--line); }

/* ---------- заказ: экраны и история ---------- */
.scr-row { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.scr-row:last-child { border-bottom: 0; }
.scr-l { flex: 1; min-width: 0; }
.stchip { border: 0; border-radius: 12px; padding: 10px 14px; font-weight: 800; font-size: 12.5px; flex: none; }
.stchip.done { background: var(--green-soft); color: var(--green); }
.stchip.wip { background: var(--amber-soft); color: var(--amber); }
.stchip.none { background: var(--surface-2); color: var(--muted); }
.hist-row { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.hist-row:first-child { border-top: 0; }
.hist-date { flex: none; background: var(--surface-2); color: var(--accent); font-weight: 800; font-size: 12.5px; border-radius: 10px; padding: 7px 10px; }
.hist-text { font-size: 13.5px; color: var(--text); }
.order-row:first-child { border-top: 0; }
.order-row .num { font-weight: 800; font-size: 15.5px; letter-spacing: -.1px; }
.order-row .meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.order-row .mods { margin-left: auto; font-weight: 800; color: var(--ink); font-size: 17px; }
.or-r { text-align: right; flex: none; }
.ost { font-size: 10.5px; font-weight: 800; margin-top: 2px; letter-spacing: .01em; }
.ost.done { color: var(--green); }
.ost.wip { color: var(--amber); }
.ost.none { color: var(--muted); }

/* ---------- photo viewer ---------- */
#viewer { position: fixed; inset: 0; z-index: 80; background: rgba(8, 14, 27, .95); display: none; }
#viewer.open { display: flex; align-items: center; justify-content: center; }
#viewer img { max-width: 100%; max-height: 88%; border-radius: 14px; }
#viewer button.vclose {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top, 0px));
  right: 16px;
  border: 0;
  background: rgba(255, 255, 255, .16);
  color: #fff;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 18px;
}
#viewer .vbar { position: absolute; left: 0; right: 0; bottom: calc(26px + env(safe-area-inset-bottom, 0px)); display: flex; justify-content: center; }
#viewer .vbar button {
  border: 0;
  background: #fff;
  color: #12203a;
  font-weight: 800;
  font-size: 15px;
  padding: 15px 26px;
  border-radius: 16px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .35);
}

/* ---------- toast ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(112px + var(--safe-b));
  transform: translate(-50%, 20px);
  background: #12203a;
  color: #fff;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: .22s;
  z-index: 90;
  max-width: 86vw;
  text-align: center;
  box-shadow: 0 12px 28px rgba(8, 14, 27, .35);
}
html[data-theme="dark"] #toast { background: #24314a; border: 1px solid #33425f; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- demo ---------- */
.demo { background: var(--amber-soft); color: var(--amber); font-size: 12px; font-weight: 700; padding: 8px 14px; text-align: center; }

/* ---------- обучение ---------- */
#tutorial { position: fixed; inset: 0; z-index: 95; background: rgba(8, 14, 27, .9); backdrop-filter: blur(6px); display: none; align-items: flex-end; justify-content: center; padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
#tutorial.open { display: flex; }
.tut-card {
  width: 100%;
  max-width: 460px;
  background: var(--card);
  border-radius: 26px;
  padding: 24px 22px 20px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(6, 12, 24, .45);
}
.tut-icon { font-size: 46px; line-height: 1; margin-bottom: 12px; }
.tut-step { font-size: 10.5px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.tut-title { font-size: 21px; font-weight: 800; color: var(--ink); margin: 9px 0; letter-spacing: -.3px; }
.tut-text { font-size: 14.5px; line-height: 1.5; color: var(--text); }
.tut-dots { display: flex; gap: 6px; justify-content: center; margin: 20px 0 16px; }
.tut-dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.tut-dots span.on { background: var(--accent); width: 20px; border-radius: 4px; }
.tut-actions { display: flex; gap: 10px; margin-top: 4px; }
.tut-skip { flex: 0 0 40%; border: 0; background: var(--surface-2); color: var(--text); border-radius: 16px; padding: 16px; font-weight: 700; font-size: 14px; }
.tut-next {
  flex: 1;
  border: 0;
  background: linear-gradient(135deg, var(--accent-2) 0%, var(--accent) 100%);
  color: #fff;
  border-radius: 16px;
  padding: 16px;
  font-weight: 800;
  font-size: 15px;
  box-shadow: 0 12px 24px rgba(47, 95, 196, .3);
}

/* ---------- выбор заказа ---------- */
#picker { position: fixed; inset: 0; z-index: 70; background: rgba(8, 14, 27, .46); display: none; align-items: flex-end; justify-content: center; }
#picker.open { display: flex; }
.pick-card { width: 100%; max-width: 560px; background: var(--card); border-radius: 26px 26px 0 0; max-height: 84vh; display: flex; flex-direction: column; box-shadow: 0 -10px 40px rgba(8, 14, 27, .3); }
.pick-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 18px 6px; }
.pick-title { font-weight: 800; font-size: 18px; color: var(--ink); letter-spacing: -.2px; }
.pick-close { border: 0; background: var(--surface-2); color: var(--muted); width: 38px; height: 38px; border-radius: 13px; font-size: 15px; }
.pick-monthbar { display: flex; align-items: center; gap: 6px; padding: 2px 14px 8px; }
.pm-nav { border: 0; background: var(--surface-2); color: var(--accent); width: 34px; height: 34px; border-radius: 11px; font-size: 18px; font-weight: 700; flex: none; }
.pm-cur { flex: 1; text-align: center; font-weight: 800; font-size: 14.5px; color: var(--ink); text-transform: capitalize; }
.pm-count { display: inline-block; margin-left: 6px; font-size: 11.5px; font-weight: 700; color: var(--accent); background: var(--accent-soft); border-radius: 8px; padding: 2px 7px; }
.pm-all { border: 1px solid var(--line); background: var(--card); color: var(--muted); border-radius: 11px; padding: 8px 12px; font-size: 12px; font-weight: 700; flex: none; }
.pm-all.on { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.pick-search { padding: 6px 18px 10px; }
.pick-search input { width: 100%; }
.pick-list { overflow-y: auto; padding: 0 12px 6px; }
.pick-row { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 0; background: var(--card); border-top: 1px solid var(--line); padding: 13px 10px; color: var(--text); }
.pick-row:first-child { border-top: 0; }
.pick-row.on { background: var(--accent-soft); }
.pk-name { font-weight: 800; font-size: 15px; color: var(--ink); }
.pk-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.pk-check { margin-left: auto; width: 26px; height: 26px; border-radius: 9px; border: 1.5px solid var(--line); display: grid; place-items: center; font-weight: 800; color: var(--accent); }
.pick-row.on .pk-check { background: var(--accent); border-color: var(--accent); color: #fff; }
.pk-arrow { margin-left: auto; color: var(--muted); font-size: 22px; }
.pick-foot { padding: 12px 18px calc(14px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); }
.pick-foot button { width: 100%; border: 0; border-radius: 16px; padding: 16px; background: linear-gradient(135deg, var(--accent-2) 0%, var(--accent) 100%); color: #fff; font-weight: 800; font-size: 15px; box-shadow: 0 12px 24px rgba(47, 95, 196, .28); }

/* ---------- чат ---------- */
.ch-row { display: flex; gap: 12px; align-items: center; padding: 13px 16px; border-top: 1px solid var(--line); }
.ch-row:first-child { border-top: 0; }
.ch-ava { width: 42px; height: 42px; flex: none; border-radius: 14px; display: grid; place-items: center; font-weight: 800; font-size: 17px;
  background: linear-gradient(135deg, var(--accent-soft), var(--surface-2)); color: var(--accent); }
.ch-name { font-weight: 800; font-size: 15px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.ch-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex: none; }

#chatroom { position: fixed; inset: 0; z-index: 65; background: var(--bg); display: none; flex-direction: column; }
#chatroom.open { display: flex; }
.ch-head { display: flex; align-items: center; gap: 10px; color: #fff; padding: calc(12px + env(safe-area-inset-top, 0px)) 14px 14px;
  background: linear-gradient(135deg, var(--header-a) 0%, var(--header-b) 60%, var(--header-c) 100%); border-radius: 0 0 22px 22px; }
.ch-head button { border: 1px solid rgba(255,255,255,.16); background: rgba(255,255,255,.12); color: #fff; width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; }
.ch-head button svg { width: 20px; height: 20px; }
.ch-title { flex: 1; font-weight: 800; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-info { font-size: 11.5px; color: #b9c9e6; }
.ch-body { flex: 1; overflow-y: auto; padding: 16px 14px 12px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 84%; display: flex; flex-direction: column; align-items: flex-start; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.bub { background: var(--card); border: 1px solid var(--line); border-radius: 16px 16px 16px 6px; padding: 10px 14px; font-size: 14.5px;
  white-space: pre-wrap; word-break: break-word; }
.msg.mine .bub { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border: 0; border-radius: 16px 16px 6px 16px; }
.mt { font-size: 10px; color: var(--muted); margin-top: 3px; }
.ch-input { display: flex; gap: 8px; padding: 10px 12px calc(12px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); background: var(--card); }
.ch-input input { flex: 1; }
.ch-input button { border: 0; width: 52px; border-radius: 14px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--accent-2), var(--accent)); }
.ch-input button svg { width: 22px; height: 22px; }

/* ---------- iOS ---------- */
html.ios input[type=text], html.ios input[type=number], html.ios input[type=date],
html.ios input[type=time], html.ios textarea, html.ios select { font-size: 16px; }
.sheet-body, .ch-body, #view, .pick-list { -webkit-overflow-scrolling: touch; }
button, .chip, .entry, .order-row, .ch-row, .typebtn, .stchip, #fab, #tabs button { touch-action: manipulation; }
html.ios #topbar { padding-top: calc(14px + env(safe-area-inset-top, 0px)); }
html.ios .sheet-head { padding-top: calc(12px + env(safe-area-inset-top, 0px)); }
html.ios .ch-head { padding-top: calc(10px + env(safe-area-inset-top, 0px)); }
html.ios #tabs { bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }
html.ios .sheet-foot, html.ios .ch-input { padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }

/* ---------- аватарки ---------- */
.ch-ava { overflow: hidden; }
.ch-ava img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; }
.ch-ava.big { width: 56px; height: 56px; border-radius: 18px; font-size: 22px; }
.ava-btn { border: 0; background: none; padding: 0; flex: none; border-radius: 18px; }

/* ---------- админка чата ---------- */
.adm-row { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-top: 1px solid var(--line); }
.adm-row:first-child { border-top: 0; }
.adm-btns { display: flex; gap: 6px; flex: none; }
.chip.del { color: var(--red); border-color: var(--red-soft); background: var(--red-soft); }
.adm-badge { font-size: 10px; font-weight: 800; color: var(--accent); background: var(--accent-soft); border-radius: 7px; padding: 2px 6px; }

.ch-del { border: 0; background: none; color: var(--muted); font-size: 15px; padding: 6px 4px 6px 10px; flex: none; }

.ch-profile { display: flex; gap: 12px; align-items: center; }
.ava-btn { cursor: pointer; display: block; flex: none; }
.ava-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; }
