/* Экран телефона в первую очередь: крупные поля и кнопки, одна колонка; на широком экране — таблицы и две колонки. */
:root {
  --bg: #f4f5f7; --card: #fff; --ink: #1d2330; --muted: #667085; --line: #d9dde3; --line-soft: #e9ecf0;
  --accent: #1f5fbf; --accent-ink: #fff; --accent-soft: #e8f0fb;
  --bad: #b42318; --bad-bg: #fdecea; --bad-line: #f5b5ae;
  --warn: #93590a; --warn-bg: #fff4d6; --warn-line: #e9c46a;
  --soft: #7a6420; --soft-bg: #fbf6e4;
  --ok: #2e7d32; --ok-bg: #e8f5e9; --ok-line: #a5d6a7;
  --late: #8a4b08; --late-bg: #fbeee0;
  --mute: #667085; --mute-bg: #eef0f3;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
       background: var(--bg); color: var(--ink); }
a { color: var(--accent); }
code { font: 15px/1.3 ui-monospace, Consolas, Menlo, monospace; }
h1 { font-size: 22px; line-height: 1.25; margin: 10px 0 10px; }
h2 { font-size: 16px; margin: 0 0 8px; }
p { margin: 8px 0; }
.muted { color: var(--muted); font-size: 14px; }
.warn { color: var(--bad); font-weight: 600; }
/* Спокойнее, чем просрочка: человек еще не вошел или не включил уведомления */
.attn { color: var(--warn); }
.sub { display: block; color: var(--muted); font-size: 13px; font-weight: 400; line-height: 1.3; }
.sub.warn { color: var(--bad); font-weight: 600; }
.sub-inline { color: var(--muted); font-size: 12px; font-weight: 400; white-space: nowrap; }
.crumb { margin: 6px 0 0; font-size: 14px; }
.crumb a { text-decoration: none; }
.crumb a::before { content: "‹ "; }
.empty { background: var(--card); border: 1px dashed var(--line); border-radius: 10px; padding: 28px 16px; text-align: center; color: var(--muted); margin: 12px 0; }
.more { font-size: 15px; margin: 14px 0; }

/* Шапка и разделы */
header.top { background: var(--ink); color: #fff; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); }
.top-in { max-width: 1148px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { color: #fff; font-weight: 600; text-decoration: none; white-space: nowrap; }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who-name { font-size: 13px; opacity: .8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who form { margin: 0; }
button.ghost { padding: 4px 10px; font-size: 13px; font-weight: 400; background: transparent; color: #fff; border: 1px solid rgba(255, 255, 255, .45); border-radius: 8px; }
.tabs { background: #2b3445; }
.tabs-in { display: flex; gap: 2px; padding: 0 6px; overflow-x: auto; max-width: 1180px; margin: 0 auto; scrollbar-width: none; }
.tabs-in::-webkit-scrollbar { display: none; }
.tabs a { color: #dfe6f3; text-decoration: none; padding: 11px 10px; white-space: nowrap; font-size: 15px; border-bottom: 3px solid transparent; }
.tabs a:hover { color: #fff; }
.tabs a.on { color: #fff; border-bottom-color: #8fb7f2; font-weight: 600; }
.tabs a.tab-action { margin-left: auto; color: #fff; font-weight: 600; }
.count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: #e5484d; color: #fff; font-size: 12px; line-height: 20px; text-align: center; font-weight: 600; }

main { max-width: 760px; margin: 0 auto; padding: 12px 16px 56px; }
main.wide { max-width: 1180px; }
main.narrow { max-width: 420px; }

/* Кнопки и поля */
.btn, button { display: inline-block; text-align: center; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--accent);
       background: var(--card); color: var(--accent); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn.primary, button.primary { background: var(--accent); color: var(--accent-ink); }
button.wide, .btn.wide { width: 100%; }
button.second { margin-top: 8px; }
button.danger { border-color: var(--bad); color: var(--bad); }
button.quiet { border-color: var(--line); color: var(--muted); font-weight: 400; }
button:disabled { opacity: .55; cursor: default; }
.btnrow { display: flex; flex-wrap: wrap; gap: 8px; }
.field { margin: 0 0 14px; }
label { display: block; font-weight: 600; margin-bottom: 4px; }
.opt { font-weight: 400; color: var(--muted); font-size: 13px; }
.hint { margin: 10px 0 0; }
input:not([type=radio]):not([type=checkbox]):not([type=hidden]), select, textarea {
  width: 100%; padding: 11px 12px; font: inherit; color: inherit; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
textarea { resize: vertical; min-height: 80px; }
input:focus, select:focus, textarea:focus { outline: 2px solid #a8c6f3; outline-offset: 0; border-color: var(--accent); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.radios { display: grid; gap: 6px; }
.radios > label { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; margin: 0; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: #fff; cursor: pointer; }
.radios > label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.radios input { margin-top: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { padding: 6px 11px; font-size: 14px; font-weight: 400; border-color: var(--line); color: var(--ink); border-radius: 16px; }
.chip:hover { border-color: var(--accent); color: var(--accent); }

/* Сообщения */
.box { border-radius: 10px; padding: 10px 12px; margin: 10px 0; border: 1px solid var(--line); background: var(--card); }
.box-ok { background: var(--ok-bg); border-color: var(--ok-line); }
.box-bad { background: var(--bad-bg); border-color: var(--bad-line); }
.box-warn { background: var(--warn-bg); border-color: var(--warn-line); }
.pushbox { background: var(--accent-soft); border: 1px solid #bcd2f2; border-radius: 10px; padding: 12px; margin: 10px 0; }
.pushbox p { margin: 0 0 10px; }
.pushbox p.muted { margin: 8px 0 0; }
.pushbox p.muted:empty { display: none; }
.pushbox p:last-child { margin-bottom: 0; }
.steps { margin: 0; padding-left: 20px; }

/* Карточки */
.card { display: block; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin: 8px 0; }
.formcard { padding: 16px; }
a.card { color: inherit; text-decoration: none; }
a.card:hover { border-color: #b7bec9; }
.card.tone-bad, .card.tone-warn, .card.tone-soft, .card.tone-info, .card.tone-ok, .card.tone-late, .card.tone-mute, .card.tone-plain { border-left-width: 4px; }
.card.tone-bad { border-left-color: var(--bad); }
.card.tone-warn { border-left-color: #dd9c1c; }
.card.tone-soft { border-left-color: #e5cf85; }
.card.tone-info { border-left-color: var(--accent); }
.card.tone-ok { border-left-color: var(--ok); }
.card.tone-late { border-left-color: #c9853a; }
.card.tone-mute { border-left-color: #b4bac4; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 13px; font-weight: 600; line-height: 1.35; background: var(--mute-bg); color: var(--ink); }
.badge.big { font-size: 14px; padding: 4px 10px; }
.badge.tone-bad { background: var(--bad-bg); color: var(--bad); }
.badge.tone-warn { background: var(--warn-bg); color: var(--warn); }
.badge.tone-soft { background: var(--soft-bg); color: var(--soft); }
.badge.tone-plain { background: var(--mute-bg); color: #475066; font-weight: 400; }
.badge.tone-info { background: var(--accent-soft); color: var(--accent); }
.badge.tone-ok { background: var(--ok-bg); color: var(--ok); }
.badge.tone-late { background: var(--late-bg); color: var(--late); }
.badge.tone-mute { background: var(--mute-bg); color: var(--mute); }

.order-top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.num { color: var(--muted); font-size: 14px; white-space: nowrap; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin: 0 3px 1px 3px; }
.newmark { color: var(--accent); font-weight: 600; }
.order-text { margin: 6px 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.order-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--muted); font-size: 14px; }
.returned { color: var(--bad); font-weight: 600; }
.group { margin: 20px 0 6px; font-size: 15px; color: #475066; }
.group.g-bad { color: var(--bad); }
.group.g-warn { color: var(--warn); }
.group-n { color: var(--muted); font-weight: 400; }

/* Ответственный и соисполнители */
.order-team { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line-soft); font-size: 14px; color: #39424f; }
.corole { display: inline-block; padding: 1px 7px; margin-right: 4px; border-radius: 6px; background: #eee8f7; color: #5a3e8c; font-size: 13px; font-weight: 600; }
.co-line + .co-line { margin-top: 6px; }
.pool-list { list-style: none; margin: 0; padding: 0; }
.pool-list li { padding: 8px 0; border-top: 1px solid var(--line-soft); }
.pool-list li:first-child { border-top: 0; padding-top: 0; }
.pool-wait { margin: 8px 0 0; padding-top: 8px; border-top: 1px solid var(--line-soft); font-size: 14px; }
.pool .muted { margin: 0; }
.picklist { display: grid; gap: 4px; max-height: 260px; overflow-y: auto; margin-bottom: 10px; padding: 6px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.picklist label { display: flex; gap: 10px; align-items: flex-start; margin: 0; padding: 7px 6px; border-radius: 6px; font-weight: 400; cursor: pointer; }
.picklist label:hover { background: #f4f6f9; }
.picklist label:has(input:checked) { background: var(--accent-soft); }
.picklist label.off { opacity: .45; cursor: default; }
.picklist input { margin-top: 4px; flex: none; }
details.coexec { margin-bottom: 14px; }
.coexec .hint { margin: 0 0 8px; }
.count-co { font-weight: 400; color: var(--accent); font-size: 14px; }
.team { list-style: none; margin: 0; padding: 0; }
.team li { padding: 8px 0; border-top: 1px solid var(--line-soft); font-size: 15px; }
.team li:first-child { border-top: 0; padding-top: 0; }
.team-who { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 8px; align-items: baseline; }
.team-role { color: var(--muted); font-size: 13px; }
.team-more { color: var(--muted); font-size: 13px; line-height: 1.3; margin-top: 2px; }
.team-reminders { margin: 8px 0 0; padding-top: 8px; border-top: 1px solid var(--line-soft); font-size: 13px; }

/* Страница поручения */
.order-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 4px 12px; }
.order-head h1 { margin: 6px 0; }
.order-full { white-space: pre-wrap; overflow-wrap: anywhere; }
.sheet .order-full { font-size: 17px; }
.facts { margin: 12px 0 0; }
.facts > div { display: grid; grid-template-columns: 130px 1fr; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line-soft); }
.facts dt { color: var(--muted); font-size: 14px; }
.facts dd { margin: 0; }
.col-side .facts { margin-top: 0; }
.col-side .facts > div:first-child { border-top: 0; padding-top: 0; }
.col-side .facts > div { grid-template-columns: 1fr; gap: 0; }
.report { background: #f8fafd; }
.actions form { margin: 0 0 8px; }
details.act { border-top: 1px solid var(--line-soft); }
details.act summary { cursor: pointer; padding: 11px 0; font-weight: 600; color: var(--accent); }
details.act form { padding-bottom: 12px; margin: 0; }
details.act textarea, details.act input:not([type=checkbox]) { margin-bottom: 10px; }
details.act label { font-size: 14px; }
.actions .more { margin: 10px 0 0; border-top: 1px solid var(--line-soft); padding-top: 12px; font-size: 14px; }

.history { margin-top: 20px; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 16px; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 14px 2px; }
.timeline li::before { content: ""; position: absolute; left: -22px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: #b4bac4; border: 2px solid var(--bg); box-sizing: content-box; }
.timeline .ev-created::before { background: var(--accent); }
.timeline .ev-report::before, .timeline .ev-accepted::before { background: var(--ok); }
.timeline .ev-returned::before, .timeline .ev-reopened::before, .timeline .ev-cancelled::before { background: var(--bad); }
.timeline .ev-deadline::before { background: #dd9c1c; }
.ev-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 10px; }
.ev-label { font-weight: 600; font-size: 15px; }
.ev-time, .ev-who { color: var(--muted); font-size: 13px; }
.ev-text { margin-top: 3px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; }

/* Контроль */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0 12px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px; text-decoration: none; color: inherit; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tile:hover { border-color: #b7bec9; }
.tile.on { outline: 2px solid var(--accent); outline-offset: -1px; }
.tile-n { font-size: 26px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile-l { font-size: 13px; color: var(--muted); line-height: 1.2; }
.tile-bad { background: var(--bad-bg); border-color: var(--bad-line); }
.tile-bad .tile-n { color: var(--bad); }
.tile-warn { background: var(--warn-bg); border-color: var(--warn-line); }
.tile-warn .tile-n { color: var(--warn); }
.tile-info { background: var(--accent-soft); border-color: #bcd2f2; }
.tile-info .tile-n { color: var(--accent); }
.filters { display: grid; grid-template-columns: 1fr; gap: 8px; margin: 0 0 10px; }
.listhead { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 16px; margin-top: 6px; }
.listhead .btn { padding: 9px 14px; }
.listhead h1 { font-size: 18px; }
.listlinks { display: flex; gap: 14px; font-size: 14px; }

/* Таблицы: на телефоне строка становится карточкой */
.rtable { width: 100%; border-collapse: collapse; margin: 6px 0; }
.rtable thead { display: none; }
.rtable tr { display: block; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 8px 0; }
.rtable td { display: block; padding: 2px 0; }
.rtable td[data-label] { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; padding: 3px 0; }
.rtable td[data-label]::before { content: attr(data-label); color: var(--muted); }
.rtable .rowlink { color: inherit; text-decoration: none; font-weight: 600; }
.rtable .rowlink:hover { color: var(--accent); }
.rtable tr.tone-bad { border-left: 4px solid var(--bad); }
.rtable tr.tone-warn { border-left: 4px solid #dd9c1c; }
.rtable tr.tone-soft { border-left: 4px solid #e5cf85; }
.rtable tr.tone-info { border-left: 4px solid var(--accent); }
.rtable tr.tone-ok { border-left: 4px solid var(--ok); }
.rtable tr.tone-late { border-left: 4px solid #c9853a; }
.rtable tr.tone-mute { border-left: 4px solid #b4bac4; color: var(--muted); }
.orders-table tr { display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; }
.orders-table .c-num { grid-row: 1; grid-column: 1; color: var(--muted); font-size: 14px; }
.orders-table .c-num a { color: var(--muted); text-decoration: none; }
.orders-table .c-num a::before { content: "№ "; }
.orders-table .c-state { grid-row: 1; grid-column: 2; text-align: right; }
.orders-table .c-text { grid-column: 1 / -1; }
.orders-table .c-text .rowlink { font-weight: 400; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.orders-table .c-who { grid-column: 1 / -1; font-size: 14px; }
.orders-table .c-who .sub { display: inline; }
.orders-table .c-who .sub::before { content: " · "; }
.orders-table .c-who .sub.co-names { display: block; }
.orders-table .c-who .sub.co-names::before { content: none; }
.orders-table .c-term { grid-column: 1 / -1; font-size: 14px; color: var(--muted); }
.orders-table td.c-term::before { content: "Срок "; }

/* Лента уведомлений */
.feed { list-style: none; margin: 8px 0; padding: 0; }
.feed li { background: var(--card); border: 1px solid var(--line); border-radius: 10px; margin: 6px 0; }
.feed a { display: block; padding: 10px 12px; color: inherit; text-decoration: none; }
.feed .unseen { border-left: 4px solid var(--accent); }
.feed .unseen .feed-title { font-weight: 700; }
.feed-title { display: block; font-weight: 600; }
.feed-body { display: block; font-size: 15px; color: #39424f; overflow-wrap: anywhere; }
.feed-time { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }

/* Вход и листок с паролем */
.login { margin-top: 28px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px 16px; }
.login h1 { margin-top: 0; }
.login .muted { margin-bottom: 0; }
.slip { padding: 18px 16px; }
.slip h2 { color: var(--muted); font-size: 14px; font-weight: 600; }
.slip-name { font-size: 19px; font-weight: 600; margin: 4px 0 12px; }
.slip-data { margin: 0; }
.slip-data > div { display: grid; grid-template-columns: 80px 1fr; gap: 8px; align-items: baseline; padding: 7px 0; border-top: 1px solid var(--line-soft); }
.slip-data dt { color: var(--muted); font-size: 14px; }
.slip-data dd { margin: 0; overflow-wrap: anywhere; }
.slip-data code { font-size: 18px; font-weight: 600; }

/* Телефон: сначала поручение и отчеты, затем действия, сведения о доставке, в конце длинная история */
@media (max-width: 899px) {
  .cols { display: flex; flex-direction: column; }
  .col-main, .col-side { display: contents; }
  .col-main > .card, .col-main > .box, .col-side > .card { margin: 4px 0; }
  .col-side > .card { order: 2; }
  .col-side > .actions { order: 1; }
  .history { order: 3; }
}

/* Широкий экран администратора и директора */
@media (min-width: 620px) {
  .tiles { grid-template-columns: repeat(6, 1fr); }
  .filters { grid-template-columns: minmax(200px, 300px) 1fr auto; }
  .pushbox [data-push-state=ask], .pushbox [data-push-state=on] { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
  .pushbox [data-push-state=ask] p, .pushbox [data-push-state=on] p { margin: 0; }
  .pushbox button { white-space: nowrap; flex: none; }
  .pushbox .btnrow { flex: none; }
}
@media (min-width: 900px) {
  .cols { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
  .col-side { position: sticky; top: 12px; margin-top: 8px; }
  .rtable thead { display: table-header-group; }
  .rtable, .rtable tbody { background: var(--card); }
  .rtable { border: 1px solid var(--line); border-radius: 10px; border-collapse: separate; border-spacing: 0; overflow: hidden; }
  .rtable tr, .orders-table tr { display: table-row; background: transparent; border: 0; border-radius: 0; padding: 0; margin: 0; }
  .rtable td, .rtable td[data-label], .rtable th { display: table-cell; padding: 9px 12px; text-align: left; vertical-align: top; font-size: 15px; border-top: 1px solid var(--line-soft); }
  .rtable td[data-label]::before { content: none; }
  .rtable th { font-size: 13px; font-weight: 600; color: var(--muted); border-top: 0; background: #fafbfc; white-space: nowrap; }
  .rtable td.n, .rtable td.n[data-label], .rtable th.n { text-align: right; font-variant-numeric: tabular-nums; }
  .rtable th.n { white-space: normal; }
  .rtable tr.tone-bad, .rtable tr.tone-warn, .rtable tr.tone-soft, .rtable tr.tone-info, .rtable tr.tone-ok, .rtable tr.tone-late, .rtable tr.tone-mute { border-left: 0; }
  /* Цветная полоска — левая граница первой ячейки; у заголовка такая же прозрачная, чтобы колонки совпадали */
  .rtable th:first-child, .rtable td:first-child { border-left: 4px solid transparent; }
  .rtable tr.tone-bad td:first-child { border-left-color: var(--bad); }
  .rtable tr.tone-warn td:first-child { border-left-color: #dd9c1c; }
  .rtable tr.tone-soft td:first-child { border-left-color: #e5cf85; }
  .rtable tr.tone-info td:first-child { border-left-color: var(--accent); }
  .rtable tr.tone-ok td:first-child { border-left-color: var(--ok); }
  .rtable tr.tone-late td:first-child { border-left-color: #c9853a; }
  .rtable tr.tone-mute td:first-child { border-left-color: #b4bac4; }
  .rtable tbody tr:hover td { background: #fafbfc; }
  .orders-table .c-num { width: 56px; }
  .orders-table td.c-num { font-size: 15px; }
  .orders-table .c-num a::before { content: none; }
  .orders-table .c-state { width: 200px; text-align: left; }
  .orders-table .c-who { width: 220px; font-size: 15px; }
  .orders-table .c-who .sub { display: block; }
  .orders-table .c-who .sub::before { content: none; }
  .orders-table .c-term { width: 104px; white-space: nowrap; }
  .orders-table td.c-term { font-size: 15px; color: inherit; }
  .orders-table td.c-term::before { content: none; }
  .orders-table .c-text .rowlink { -webkit-line-clamp: 2; }
}
@media print {
  header.top, .tabs, .noprint { display: none !important; }
  body { background: #fff; }
  main { padding: 0; }
  .slip { border: 1px solid #000; max-width: 110mm; }
}
