:root {
  --ink: #17191E;
  --paper: #F6F4EF;
  --paper2: #ECE7DC;
  --card: #FFFDF9;
  --line: #DDD6C8;
  --muted: #5A5F68;
  --accent: #43B649;
  --accent-ink: #1E7A2E;
  --late: #C62828;
  --late-bg: #FBE4E1;
  --late-ink: #8A1C1C;
  --soon: #E0A100;
  --soon-ink: #7A5600;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Arial, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-ink); }
.loading { padding: 40px; text-align: center; color: var(--muted); }

/* Шапка */
.top { position: sticky; top: 0; z-index: 5; background: var(--ink); color: var(--paper);
  display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top)); }
.top .brand { font-weight: 800; letter-spacing: .5px; white-space: nowrap; cursor: pointer; }
.top .brand b { color: var(--accent); }
.top .grow { flex: 1; }
.top input[type=search] { width: 100%; max-width: 360px; background: #2A2D34; border: 0;
  border-radius: 10px; padding: 9px 12px; color: var(--paper); }
.top .icon { background: none; border: 0; color: var(--paper); padding: 8px; cursor: pointer;
  font-size: 15px; white-space: nowrap; }
.top .who { font-size: 13px; color: #B8BCC4; white-space: nowrap; }

/* Кнопки */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 12px; padding: 11px 18px; font-weight: 700; cursor: pointer;
  background: var(--paper2); color: var(--ink); min-height: 44px; }
.btn.main { background: var(--accent); color: var(--ink); }
.btn.dark { background: var(--ink); color: var(--paper); }
.btn.ghost { background: transparent; border: 1.5px solid var(--line); }
.btn.danger { background: var(--late-bg); color: var(--late-ink); }
.btn.big { width: 100%; font-size: 19px; padding: 16px; min-height: 58px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: 14px; border-radius: 10px; }

/* Фильтры */
.bar { display: flex; gap: 8px; align-items: center; padding: 12px 16px 4px; flex-wrap: wrap; }
.chip { border: 1.5px solid var(--line); background: var(--card); border-radius: 30px;
  padding: 6px 14px; cursor: pointer; font-size: 14px; font-weight: 600; }
.chip.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.bar .stat { font-size: 14px; color: var(--muted); margin-left: auto; }
.bar .stat b.late { color: var(--late); }

/* Доска */
.board { display: flex; gap: 12px; padding: 12px 16px 24px; overflow-x: auto;
  scroll-snap-type: x mandatory; align-items: flex-start; }
.col { flex: 0 0 280px; scroll-snap-align: start; background: var(--paper2);
  border-radius: 18px; padding: 12px 10px; display: flex; flex-direction: column; gap: 10px; }
.col h2 { font-size: 15px; margin: 2px 4px; display: flex; justify-content: space-between; }
.col h2 span { color: var(--muted); font-weight: 600; }
.col .empty { font-size: 14px; color: var(--muted); padding: 4px; }
@media (min-width: 1400px) { .col { flex: 1 1 0; min-width: 200px; } }

.ocard { background: var(--card); border-radius: 12px; padding: 11px 12px; cursor: pointer;
  border-left: 5px solid #C9CDD3; display: flex; flex-direction: column; gap: 3px;
  box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.ocard:hover { box-shadow: 0 4px 14px rgba(0,0,0,.08); }
.ocard.late { border-left-color: var(--late); }
.ocard.soon { border-left-color: var(--soon); }
.ocard .t { font-weight: 700; font-size: 15px; }
.ocard .d { font-size: 14px; color: var(--muted); overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ocard .f { display: flex; justify-content: space-between; gap: 8px; font-size: 13px;
  color: var(--muted); font-weight: 600; flex-wrap: wrap; }
.ocard.late .due { color: var(--late); }
.ocard.soon .due { color: var(--soon-ink); }
.warnmark { color: var(--late-ink); }

/* Список (закрытые / поиск) */
.list { padding: 0 16px 24px; display: flex; flex-direction: column; gap: 8px; max-width: 900px; }
.list h3 { margin: 16px 0 4px; font-size: 15px; color: var(--muted); }
.row { background: var(--card); border-radius: 12px; padding: 10px 14px; cursor: pointer;
  display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.row .s { font-size: 13px; font-weight: 700; background: var(--paper2); border-radius: 20px;
  padding: 2px 10px; }

/* Карточка заказа */
.page { max-width: 860px; margin: 0 auto; padding: 16px 16px 60px; display: flex;
  flex-direction: column; gap: 14px; }
.ohead { display: flex; flex-direction: column; gap: 6px; }
.ohead h1 { margin: 0; font-size: 24px; line-height: 1.2; }
.pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { background: var(--paper2); border-radius: 30px; padding: 4px 12px; font-size: 14px;
  font-weight: 700; }
.pill.status { background: var(--ink); color: var(--paper); }
.pill.late { background: var(--late-bg); color: var(--late-ink); }
.pill.soon { background: #FFF0C2; color: var(--soon-ink); }
.pill.ok { background: #DDF3DE; color: var(--accent-ink); }

.path { display: flex; gap: 4px; }
.path i { flex: 1; height: 6px; border-radius: 3px; background: var(--line); }
.path i.done { background: var(--ink); }
.path i.now { background: var(--accent); }

.warn { background: var(--late-bg); color: var(--late-ink); border-radius: 12px;
  padding: 10px 14px; font-size: 15px; }
.warn ul { margin: 4px 0 0; padding-left: 20px; }
.note { background: var(--paper2); border-radius: 12px; padding: 10px 14px; font-size: 15px;
  color: var(--muted); }

.sec { background: var(--card); border-radius: var(--radius); padding: 14px 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.sec .sh { display: flex; justify-content: space-between; align-items: center; gap: 10px;
  margin-bottom: 8px; }
.sec h2 { font-size: 17px; margin: 0; }
.kv { display: grid; grid-template-columns: 210px 1fr; gap: 6px 14px; font-size: 15px; }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 600; white-space: pre-wrap; word-break: break-word; }
.kv .v.no { color: #A7A9AE; font-weight: 400; }
@media (max-width: 560px) {
  .kv { grid-template-columns: 1fr; gap: 0; }
  .kv .v { margin-bottom: 8px; }
}

/* Формы */
.form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 14px; color: var(--muted); font-weight: 600; }
.field label .req { color: var(--late); }
.field input, .field select, .field textarea { width: 100%; border: 1.5px solid var(--line);
  border-radius: 10px; padding: 10px 12px; background: #fff; min-height: 44px; }
.field textarea { min-height: 76px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--accent);
  border-color: var(--accent); }
.yesno { display: flex; gap: 8px; }
.yesno button { flex: 1; }
.yesno button.on { background: var(--ink); color: var(--paper); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.sugg { background: #fff; border: 1.5px solid var(--line); border-radius: 10px; margin-top: 2px; }
.sugg div { padding: 8px 12px; cursor: pointer; font-size: 15px; }
.sugg div:hover { background: var(--paper2); }

/* Фото */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px;
  margin: 6px 0 10px; }
.photos figure { margin: 0; position: relative; }
.photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px;
  cursor: zoom-in; background: var(--paper2); display: block; }
.photos figcaption { font-size: 12px; color: var(--muted); }
.photos .x { position: absolute; top: 4px; right: 4px; background: rgba(23,25,30,.75);
  color: #fff; border: 0; border-radius: 50%; width: 26px; height: 26px; cursor: pointer; }

/* История */
.hist { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.hist div { border-top: 1px solid var(--paper2); padding-top: 6px; }
.hist .when { color: var(--muted); }

/* Окно */
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(23,25,30,.55);
  display: flex; align-items: flex-end; justify-content: center; }
.modal[hidden] { display: none; }
.dialog { background: var(--paper); width: 100%; max-width: 560px; max-height: 92vh;
  overflow-y: auto; border-radius: 20px 20px 0 0; padding: 20px 18px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom)); display: flex;
  flex-direction: column; gap: 14px; }
.dialog h2 { margin: 0; font-size: 20px; }
@media (min-width: 640px) {
  .modal { align-items: center; }
  .dialog { border-radius: 20px; }
}
.photo-view { max-width: 100%; max-height: 80vh; border-radius: 12px; }

/* Вход */
.login { max-width: 380px; margin: 12vh auto 0; padding: 24px; display: flex;
  flex-direction: column; gap: 16px; }
.login h1 { margin: 0; font-size: 28px; }
.login h1 b { color: var(--accent-ink); }
.login p { margin: 0; color: var(--muted); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 30;
  background: var(--ink); color: var(--paper); padding: 12px 18px; border-radius: 12px;
  max-width: 90vw; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.toast.err { background: var(--late); }

table.staff { width: 100%; border-collapse: collapse; font-size: 15px; }
table.staff td, table.staff th { text-align: left; padding: 8px 6px;
  border-bottom: 1px solid var(--paper2); }
table.staff tr.off { color: #A7A9AE; }

/* Файлы и макеты */
.files { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 10px; }
.file { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; position: relative;
  padding-right: 30px; font-size: 15px; }
.file span { color: var(--muted); font-size: 13px; }
.x2 { position: absolute; top: 0; right: 0; background: none; border: 0; font-size: 20px;
  color: var(--muted); cursor: pointer; line-height: 1; }
.layouts { display: flex; flex-direction: column; gap: 10px; margin: 8px 0 10px; }
.layout { display: flex; gap: 12px; align-items: flex-start; padding: 8px; border-radius: 12px;
  opacity: .65; }
.layout.latest { background: var(--paper); opacity: 1; }
.layout img, .layout .pdf { width: 110px; height: 110px; object-fit: contain; background: #fff;
  border-radius: 10px; flex: none; cursor: zoom-in; border: 1px solid var(--line); }
.layout .pdf { display: flex; align-items: center; justify-content: center; font-weight: 800;
  text-decoration: none; color: var(--late-ink); }
.layout .li { flex: 1; display: flex; flex-direction: column; gap: 4px; position: relative;
  padding-right: 26px; }
.layout .m { font-size: 13px; color: var(--muted); }
.layout .cm { font-size: 14px; background: var(--late-bg); color: var(--late-ink);
  border-radius: 8px; padding: 6px 10px; }
.tag { display: inline-block; font-size: 13px; font-weight: 700; background: var(--paper2);
  border-radius: 20px; padding: 2px 10px; }
.tag.ok { background: #DDF3DE; color: var(--accent-ink); }
.tag.bad { background: var(--late-bg); color: var(--late-ink); }
.hint { font-size: 13px; color: var(--muted); margin: 6px 0 0; }

/* Цех */
.shop .sec .m { color: var(--muted); font-weight: 700; }
.jobs { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.job { background: var(--paper); border-radius: 12px; padding: 12px; border-left: 6px solid #C9CDD3;
  display: flex; flex-direction: column; gap: 6px; }
.job.late { border-left-color: var(--late); }
.job.soon { border-left-color: var(--soon); }
.job .jt { font-size: 17px; cursor: pointer; display: flex; gap: 6px; flex-wrap: wrap; align-items: baseline; }
.job .jt .due { margin-left: auto; font-size: 14px; font-weight: 700; color: var(--muted); }
.job.late .due { color: var(--late); }
.job.soon .due { color: var(--soon-ink); }
.job .jd { font-size: 15px; }
.job .m { font-size: 13px; color: var(--muted); }
.job .btn { flex: 1; min-height: 52px; font-size: 17px; }

/* Уведомления */
.nrow { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.nrow b { width: 90px; }
.sum { white-space: pre-wrap; font: 14px/1.45 inherit; background: var(--paper); border-radius: 10px;
  padding: 0 12px; margin: 10px 0 0; }
.sum:not(:empty) { padding: 12px; }

/* Техбланк */
.tb { max-width: 800px; margin: 16px auto; background: #fff; padding: 28px 32px; color: #000; }
.tbh { display: flex; justify-content: space-between; gap: 20px; border-bottom: 3px solid #000; padding-bottom: 12px; }
.tbn { font-size: 40px; font-weight: 800; }
.tbc { font-size: 20px; font-weight: 700; }
.tbd { text-align: right; font-size: 16px; }
.tbd b { font-size: 20px; }
.tbt { width: 100%; border-collapse: collapse; margin-top: 14px; font-size: 16px; }
.tbt th, .tbt td { border: 1px solid #999; padding: 7px 10px; text-align: left; vertical-align: top; }
.tbt th { width: 32%; background: #f3f3f3; font-weight: 600; }
.tbt .v { font-weight: 700; white-space: pre-wrap; }
.tbt.sign th { width: 22%; }
.tbt.sign td { height: 34px; }
.tbimg { max-width: 100%; max-height: 420px; display: block; margin: 16px auto 0; border: 1px solid #ccc; }
@media print {
  .noprint, .top, .toast { display: none !important; }
  body { background: #fff; }
  .tb { margin: 0; padding: 0; max-width: none; }
}

/* Расчёт */
table.calc { width: 100%; border-collapse: collapse; font-size: 15px; margin-bottom: 8px; }
table.calc td { padding: 7px 4px; border-bottom: 1px solid var(--paper2); vertical-align: top; }
table.calc td span { display: block; font-size: 13px; color: var(--muted); }
table.calc .r { text-align: right; white-space: nowrap; }
table.calc .t td { border: 0; color: var(--muted); }
table.calc .tt td { border: 0; font-size: 19px; font-weight: 800; }
.cline { background: #fff; border: 1.5px solid var(--line); border-radius: 12px; padding: 10px; display: flex;
  flex-direction: column; gap: 8px; }
.crow { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; position: relative; }
.crow select, .crow input { flex: 1; min-width: 0; border: 1.5px solid var(--line); border-radius: 10px;
  padding: 9px 10px; background: #fff; min-height: 42px; }
.crow > select:first-child { padding-right: 30px; }
.crow label { flex: 1; min-width: 110px; display: flex; flex-direction: column; gap: 3px; font-size: 13px;
  color: var(--muted); font-weight: 600; }
.crow .x2 { position: static; }
.csum { font-size: 14px; color: var(--muted); text-align: right; }
.ctotal { flex: 2; text-align: right; font-size: 20px; font-weight: 800; align-self: center; }

/* Прайс */
.page.wide { max-width: 1200px; }
.ptable { display: flex; flex-direction: column; gap: 6px; }
.prow { display: grid; grid-template-columns: 1.2fr 2fr 0.7fr 0.8fr 0.8fr 1.2fr 28px; gap: 6px; align-items: center; }
.prow input, .prow select { width: 100%; border: 1.5px solid var(--line); border-radius: 8px; padding: 7px 8px;
  background: #fff; min-height: 38px; }
.prow.ph span { font-size: 13px; color: var(--muted); font-weight: 700; }
.prow .x2 { position: static; }
@media (max-width: 760px) {
  .prow { grid-template-columns: 1fr 1fr; background: var(--paper); padding: 8px; border-radius: 10px; }
  .prow.ph { display: none; }
}

/* Вывеска на фасаде */
.fz h1 { margin: 10px 0 12px; font-size: 22px; }
.fzrow { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.fzrow > span { width: 64px; flex: none; font-size: 13px; color: var(--muted); }
.strip { display: flex; gap: 8px; overflow-x: auto; flex: 1; padding: 2px; }
.strip img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; flex: none;
  border: 2px solid transparent; background: #fff; cursor: pointer; }
#fzS img { object-fit: contain; }
.strip img.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.fzwrap { margin: 10px 0; display: flex; justify-content: center; background: var(--paper2);
  border-radius: var(--radius); overflow: hidden; }
#fzC { touch-action: none; display: block; cursor: grab; }
.fztools { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; margin-bottom: 12px; font-size: 14px; }
.fztools label { display: flex; align-items: center; gap: 8px; }
.fztools input[type=range] { accent-color: var(--accent); width: 140px; }

/* этап 7: деньги, документы, клиенты */
.mtot { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 4px 0 10px; }
.mtot div { background: var(--paper2); border-radius: 12px; padding: 8px 12px; min-width: 0; }
.mtot span { display: block; font-size: 13px; color: var(--muted); }
.mtot b { font-size: 18px; overflow-wrap: anywhere; }
.mtot .due { background: #FFF0C2; color: var(--soon-ink); }
.mtot .okk { background: #DDF3DE; color: var(--accent-ink); }
.docs { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; margin-top: 6px; }
.docrow { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.docrow > span { font-weight: 600; margin-right: 4px; }
.methods { flex-wrap: wrap; }
.qrbox { display: flex; gap: 14px; align-items: center; background: #fff; border-radius: 12px; padding: 12px; }
.qrbox svg { flex: none; width: 200px; height: 200px; }
.qrbox p { margin: 0; font-size: 14px; color: var(--muted); }
table.debts tr, table.clients td[onclick], table.clients tr[onclick], table.calc tr[onclick] { cursor: pointer; }
table.calc b.late { color: var(--late); }
.sh input[type=month] { border: 1.5px solid var(--line); border-radius: 10px; padding: 4px 8px; background: var(--card); }
details summary { cursor: pointer; color: var(--muted); margin: 8px 0; }
@media (max-width: 600px) {
  .mtot { grid-template-columns: 1fr 1fr; }
  .qrbox { flex-direction: column; align-items: flex-start; }
}
.pays .x2 { position: static; padding: 0 4px; }
@media (max-width: 760px) {
  .top { flex-wrap: wrap; gap: 2px 4px; padding-left: 12px; padding-right: 12px; }
  .top .brand { margin-right: 6px; }
  .top .grow { order: 10; flex-basis: 100%; }
  .top .grow:empty { display: none; }
  .top .who { display: none; }
  .top .icon { padding: 6px; font-size: 14px; }
}
