:root {
  --teal: #007C7C;
  --teal-hover: #006868;
  --teal-press: #005555;
  --teal-deep: #0D3836;
  --teal-soft: #E1F0EF;
  --teal-line: #CFE2E1;
  --paper: #F3F8F7;
  --card: #FFFFFF;
  --ink: #15302E;
  --muted: #5B7371;
  --danger: #B3372F;
  --danger-soft: #FBE9E7;
  --s-new-bg: #E4ECF6; --s-new-fg: #234B7A;
  --s-work-bg: #FFEFCF; --s-work-fg: #805300;
  --s-done-bg: #DCF1E5; --s-done-fg: #0E6A3A;
  --r-card: 14px; --r-ctl: 10px;
  --shadow: 0 1px 2px rgba(13,56,54,.07), 0 8px 24px rgba(13,56,54,.06);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 16px/1.5 "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 1.65rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; font-weight: 650; margin-bottom: 12px; }
h3 { font-size: 1rem; font-weight: 650; }
small.muted { display: block; margin-top: 5px; font-size: .85rem; }
a { color: var(--teal); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--teal-press); }
:focus-visible { outline: 3px solid #4FB3B0; outline-offset: 2px; }
.muted { color: var(--muted); }
.strong { font-weight: 650; }
.breakall { word-break: break-all; }
.pre { white-space: pre-wrap; margin: 0; overflow-wrap: anywhere; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.note { margin: 10px 4px 0; font-size: .9rem; }
.sec { margin: 28px 0 12px; }

/* шапка */
.top { background: var(--teal-deep); color: #fff; }
.top-in { max-width: 1120px; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; gap: 24px; min-height: 58px; }
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem; letter-spacing: .01em; white-space: nowrap; }
.brand:hover { color: #fff; }
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { color: #BFDCDA; text-decoration: none; padding: 17px 14px 14px; border-bottom: 3px solid transparent; white-space: nowrap; font-weight: 550; }
.tabs a:hover { color: #fff; border-bottom-color: #3E8C89; }
.tabs a:active { background: rgba(255,255,255,.08); }
.tabs a.on { color: #fff; border-bottom-color: #35C4C0; }
.who { display: flex; align-items: center; gap: 10px; margin: 0; }
.who-name { color: #BFDCDA; font-size: .9rem; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 24px 20px 56px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.head-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.back { display: inline-block; margin-bottom: 6px; font-size: .92rem; color: var(--muted); }
.onum-lg { font-variant-numeric: tabular-nums; }

/* карточки */
.card { background: var(--card); border-radius: var(--r-card); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }
.table-card { padding: 4px 8px; overflow-x: auto; }
.empty { text-align: center; padding: 40px 20px; }
.empty p { margin: 8px 0 18px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid2 .card { margin-bottom: 0; }
.grid2 { margin-bottom: 16px; }
.stack { display: block; }
.stack-s > * + * { margin-top: 14px; }

/* кнопки */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 0 16px; border-radius: var(--r-ctl);
  border: 1px solid var(--teal-line); background: #fff; color: var(--teal-deep);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  transition: background-color .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--teal-soft); border-color: #A9CFCD; color: var(--teal-deep); }
.btn:active { background: #CDE5E3; }
.btn-primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-hover); border-color: var(--teal-hover); color: #fff; }
.btn-primary:active { background: var(--teal-press); }
.btn-ok { background: var(--s-done-bg); border-color: #B5E0C6; color: var(--s-done-fg); }
.btn-ok:hover { background: #C7EBD6; color: var(--s-done-fg); }
.btn-ok:active { background: #B5E0C6; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: #EBB9B3; color: var(--danger); }
.btn-danger:active { background: #F5D4D0; }
.btn-ghost { background: transparent; border-color: rgba(255,255,255,.3); color: #fff; min-height: 36px; }
.btn-ghost:hover { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.5); color: #fff; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: .9rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: default; }

/* переключатели */
.seg { display: inline-flex; background: var(--teal-soft); border-radius: 12px; padding: 4px; gap: 4px; flex-wrap: wrap; }
.seg form { margin: 0; }
.seg-item {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; border-radius: 9px;
  border: 0; background: transparent; color: var(--teal-deep); font: inherit; font-weight: 600;
  text-decoration: none; cursor: pointer; transition: background-color .12s;
}
.seg-item:hover { background: rgba(255,255,255,.7); color: var(--teal-deep); }
.seg-item:active { background: #fff; }
.seg-item.on { background: var(--teal); color: #fff; }
.seg-item.on:hover { background: var(--teal); color: #fff; }
.seg-item.radio { position: relative; }
.seg-item.radio input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg-item.radio:focus-within { outline: 3px solid #4FB3B0; outline-offset: 1px; }
.seg-item.s-new.on { background: var(--s-new-fg); }
.seg-item.s-work.on { background: #A86B00; }
.seg-item.s-done.on { background: var(--s-done-fg); }
.seg-item[disabled] { cursor: default; opacity: 1; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; padding: 12px 14px; }
.search { display: flex; gap: 8px; flex: 1; min-width: 240px; max-width: 460px; margin: 0; }
.search input { flex: 1; }

/* формы */
.field { display: block; }
.field > span { display: block; font-size: .9rem; font-weight: 600; margin-bottom: 5px; color: var(--teal-deep); }
.field + .field { margin-top: 14px; }
input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea {
  width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid #BFD6D4; border-radius: var(--r-ctl);
  background: #fff; color: var(--ink); font: inherit;
}
textarea { resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: #8FBFBC; }
input:focus, select:focus, textarea:focus { outline: 3px solid #4FB3B0; outline-offset: 0; border-color: var(--teal); }
.cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.cols2 .field + .field { margin-top: 0; }
.cols2 + .field { margin-top: 14px; }
.client-pick { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 10px; }
.inline-panel { margin-top: 14px; padding: 16px; background: var(--paper); border-radius: var(--r-ctl); border: 1px dashed #9CC9C6; }
.inline-panel .btn { margin-top: 12px; }
.field-error { color: var(--danger); margin: 10px 0 0; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chip input { position: absolute; opacity: 0; }
.chip span {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 16px; border-radius: 999px;
  border: 1px solid #BFD6D4; background: #fff; cursor: pointer; font-weight: 550;
  transition: background-color .12s, border-color .12s;
}
.chip span:hover { background: var(--teal-soft); border-color: #8FBFBC; }
.chip input:checked + span { background: var(--teal); border-color: var(--teal); color: #fff; }
.chip input:focus-visible + span { outline: 3px solid #4FB3B0; outline-offset: 2px; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
[hidden] { display: none !important; }

/* таблицы */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: .85rem; font-weight: 600; color: var(--muted); padding: 12px 10px; border-bottom: 1px solid var(--teal-line); white-space: nowrap; }
.tbl th.num { text-align: right; }
.tbl td .muted { white-space: nowrap; }
.tbl td { padding: 12px 10px; border-bottom: 1px solid #E8F0EF; vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: #F7FBFA; }
.onum { white-space: nowrap; font-weight: 700; font-variant-numeric: tabular-nums; text-decoration: none; }
.onum:hover { text-decoration: underline; }
.act { white-space: nowrap; }
.actions { display: flex; gap: 6px; justify-content: flex-end; align-items: center; flex-wrap: nowrap; }
.actions form { margin: 0; }

.pill { display: inline-block; padding: 3px 12px; border-radius: 999px; font-size: .85rem; font-weight: 650; white-space: nowrap; vertical-align: middle; }
.pill.s-new { background: var(--s-new-bg); color: var(--s-new-fg); }
.pill.s-work { background: var(--s-work-bg); color: var(--s-work-fg); }
.pill.s-done { background: var(--s-done-bg); color: var(--s-done-fg); }
h1 .pill { margin-left: 6px; font-size: .9rem; }

.kv { display: grid; grid-template-columns: minmax(110px, 170px) 1fr; gap: 10px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.plain { list-style: none; margin: 0; padding: 0; }
.files li, .plain li { padding: 2px 0; }
.files li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; background: var(--paper); border-radius: 8px; margin-top: 8px; }
.fields-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid #E8F0EF; }
.add-field { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--teal-line); }
.danger-zone { margin: 8px 0 0; text-align: right; }
.add-client summary { list-style: none; width: max-content; }
.add-client summary::-webkit-details-marker { display: none; }
.add-client[open] summary { margin-bottom: 16px; }

/* статистика */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-bottom: 8px; }
.stat { background: var(--card); border-radius: var(--r-card); box-shadow: var(--shadow); padding: 18px 20px; border-left: 5px solid var(--teal-line); }
.stat-v { font-size: 1.8rem; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat-l { color: var(--muted); margin-top: 4px; }
.stat.s-work { border-left-color: #E3A93B; }
.stat.s-done { border-left-color: #35A06A; }
.strong-card { border-left-color: var(--teal); background: var(--teal); color: #fff; }
.strong-card .stat-l { color: #CDEDEB; }

/* сообщения */
.flash { padding: 12px 16px; border-radius: var(--r-ctl); margin-bottom: 14px; font-weight: 550; }
.flash-ok { background: var(--s-done-bg); color: var(--s-done-fg); }
.flash-err { background: var(--danger-soft); color: var(--danger); }

/* вход: метки реза в углах карточки, как на печатном листе */
.login-wrap { min-height: 80vh; display: grid; place-items: center; padding: 20px 0; }
.login { width: 100%; max-width: 400px; padding: 32px 28px; position: relative; margin: 22px; }
.login h1 { color: var(--teal); margin-bottom: 4px; }
.login p { margin: 0 0 20px; }
.login .btn { margin-top: 20px; }
.marks::before, .marks::after { content: ""; position: absolute; width: 26px; height: 26px; pointer-events: none; }
.marks::before { top: -14px; left: -14px; border-right: 1px solid var(--teal); border-bottom: 1px solid var(--teal); }
.marks::after { bottom: -14px; right: -14px; border-left: 1px solid var(--teal); border-top: 1px solid var(--teal); }

/* планшет и телефон */
@media (max-width: 860px) {
  .grid2 { grid-template-columns: 1fr; }
  .client-pick { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .top-in { flex-wrap: wrap; gap: 0 12px; padding: 0 14px; }
  .brand { padding: 12px 0 4px; }
  .who { margin-left: auto; padding-top: 8px; }
  .tabs { order: 3; flex-basis: 100%; }
  .tabs a { padding: 10px 12px 9px; }
  .wrap { padding: 18px 14px 48px; }
  h1 { font-size: 1.4rem; }
  .cols2 { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 10px; }
  .search { max-width: none; }
  .toolbar .seg { display: flex; width: 100%; flex-wrap: nowrap; }
  .toolbar .seg .seg-item { flex: 1; justify-content: center; padding: 0 6px; }
  .table-card { padding: 8px; overflow: visible; }
  .tbl thead { display: none; }
  .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; width: 100%; }
  .tbl tr { padding: 10px 6px; border-bottom: 1px solid var(--teal-line); }
  .tbl tbody tr:last-child { border-bottom: 0; }
  .tbl td { border: 0; padding: 4px 4px; display: flex; justify-content: space-between; gap: 14px; text-align: right; }
  .tbl td::before { content: attr(data-label); color: var(--muted); font-size: .88rem; text-align: left; flex-shrink: 0; }
  .tbl td.act { display: block; padding-top: 10px; }
  .tbl td.act::before { content: none; }
  .actions { justify-content: flex-start; flex-wrap: wrap; }
  .tbl td.num { text-align: right; }
  .stat-v { font-size: 1.5rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* заказ: позиции, дата приёма, сдача */
.accepted { background: var(--teal-soft); border-left: 5px solid var(--teal); border-radius: 0 var(--r-ctl) var(--r-ctl) 0; padding: 10px 16px; margin-bottom: 16px; font-size: 1.02rem; }
fieldset.card { border: 0; min-width: 0; margin-left: 0; margin-right: 0; }
.item { border-left: 5px solid var(--teal); }
.item-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.item-head h2 { margin: 0; }
.item .field + .field, .item .cols3 + .field, .item .field + .cols2, .item .cols3 { margin-top: 14px; }
.item .cols3:first-of-type { margin-top: 14px; }
.cols3 { display: grid; grid-template-columns: 1fr 1.2fr 1.4fr; gap: 14px; }
.cols3 .field + .field { margin-top: 0; }
.add-item { width: 100%; min-height: 52px; margin-bottom: 16px; border: 2px dashed #8FBFBC; background: transparent; color: var(--teal-deep); font-size: 1rem; }
.add-item:hover { background: var(--teal-soft); border-color: var(--teal); }
.add-item .plus { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--teal); color: #fff; font-size: 1.25rem; line-height: 1; font-weight: 700; }
.chips-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chips-list li { display: inline-flex; align-items: center; gap: 4px; padding: 4px 6px 4px 14px; background: var(--paper); border: 1px solid var(--teal-line); border-radius: 999px; }
.chips-list form { margin: 0; }
.chip-x { border: 0; background: transparent; color: var(--danger); font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; padding: 4px 8px; border-radius: 999px; }
.chip-x:hover { background: var(--danger-soft); }
.chip-x:active { background: #F5D4D0; }
.service-add { max-width: 480px; }
.totals { border-left: 5px solid var(--teal); }
@media (max-width: 860px) { .cols3 { grid-template-columns: 1fr; } }
.item .cols2 .field + .field, .item .cols3 .field + .field { margin-top: 0; }
.cols2 { align-items: start; }

.install-banner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--teal-soft); border: 1px solid #A9CFCD; border-radius: var(--r-ctl); padding: 10px 14px; margin-bottom: 16px; }
.install-banner span { flex: 1 1 240px; }

/* аналитика */
.filters { padding: 16px 20px; }
.filters-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; align-items: end; }
.filters-grid .field + .field { margin-top: 0; }
.custom-dates { display: contents; }
.custom-dates[hidden] { display: none !important; }
.scope { margin: 0 4px 16px; font-size: .95rem; }
.warn { background: #FFF6E0; border-left: 5px solid #E3A93B; }
.warn h2 { color: #805300; }
.warn p { margin: 0 0 8px; }
.warn .links a { font-weight: 650; }
.stat.accent { border-left-color: #2E9E66; }
.delta { display: inline-block; margin-top: 8px; padding: 2px 10px; border-radius: 999px; font-size: .85rem; font-weight: 650; background: var(--paper); color: var(--muted); }
.delta.good { background: var(--s-done-bg); color: var(--s-done-fg); }
.delta.bad { background: var(--danger-soft); color: var(--danger); }
.strong-card .delta { background: rgba(255,255,255,.22); color: #fff; }
.legend { display: flex; flex-wrap: wrap; gap: 18px; margin-bottom: 10px; font-size: .9rem; color: var(--muted); }
.lg::before { content: ""; display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.lg-rev::before { background: var(--teal); }
.lg-cost::before { background: #A7BEBC; }
.lg-profit::before { background: #2E9E66; }
.chart-scroll { overflow-x: auto; }
.chart .grid { stroke: #DCE9E8; stroke-width: 1; }
.chart .zero { stroke: #8FA9A7; stroke-width: 1.2; }
.chart .ax { fill: #5B7371; font-size: 11px; font-family: inherit; }
.chart .b-rev { fill: #007C7C; }
.chart .b-cost { fill: #A7BEBC; }
.chart .b-profit { fill: #2E9E66; }
.chart .b-loss { fill: #B3372F; }
.chart rect:hover { opacity: .8; }
.tbl-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 10px 4px; }
.tbl-head h2 { margin: 0; }
.tbl tfoot td { font-weight: 700; border-top: 2px solid var(--teal-line); background: #F7FBFA; }
.tbl .zero-row td { color: #8FA3A1; }
.tbl .neg { color: var(--danger); font-weight: 650; }
.share { display: flex; align-items: center; gap: 8px; min-width: 130px; }
.share-bar { display: block; height: 8px; min-width: 2px; max-width: 70px; border-radius: 4px; background: var(--teal); }
.share-n { font-variant-numeric: tabular-nums; font-size: .9rem; color: var(--muted); white-space: nowrap; }
.top-bottom .tbl td { padding: 8px 6px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 16px; }
.grid3 .card { margin-bottom: 0; }
.due-list li { padding: 5px 0; border-bottom: 1px solid #E8F0EF; }
.due-list li:last-child { border-bottom: 0; }
@media (max-width: 860px) { .grid3 { grid-template-columns: 1fr; } }
@media (max-width: 720px) {
  .table-card.scroll { overflow-x: auto; }
  .tbl.keep { display: table; }
  .tbl.keep thead { display: table-header-group; }
  .tbl.keep tbody { display: table-row-group; }
  .tbl.keep tfoot { display: table-footer-group; }
  .tbl.keep tr { display: table-row; padding: 0; }
  .tbl.keep td, .tbl.keep th { display: table-cell; width: auto; text-align: left; padding: 10px; white-space: nowrap; }
  .tbl.keep td::before { content: none; }
  .tbl.keep td.num, .tbl.keep th.num { text-align: right; }
  .tbl.keep td { border-bottom: 1px solid #E8F0EF; }
}
@media (max-width: 720px) {
  .filters { padding: 14px; }
  .filters-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .filters-grid > label:first-child, .filters-grid > button { grid-column: 1 / -1; }
}
