/* ============================================================================
   B2B CRM — производственный журнал

   Интерфейс отдела, который ведёт проработки с фабриками. Отсюда язык:
   тёплая бумага вместо белого экрана, записи в виде тикетов с линией отреза,
   статусы — диагональные штампы, как отметка ОТК на бланке.
   Данные (даты, цены, номера) набраны моноширинным с разрядкой — тикетный вид.
   ============================================================================ */

/* ---------- Светлая тема ---------- */
:root {
  --paper: #efebe3;
  --paper-2: #e7e2d8;        /* подложки, шапки таблиц */
  --card: #f7f5f0;           /* тикеты и карточки */
  --ink: #201f1d;
  --ink-soft: #55524c;
  --ink-faint: #86817a;
  --moss: #566246;           /* сайдбар, вторичные акценты */
  --moss-soft: #e2e5da;
  --teal: #1f5c54;           /* основной акцент */
  --teal-soft: #dbe7e4;
  --teal-text: #f7f5f0;
  --wheat: #c99a3d;          /* ожидание */
  --wheat-soft: #f6ecd8;
  --rust: #a2472f;           /* просрочка, отказ */
  --rust-soft: #f5e0d9;
  --hairline: #c9c2b0;
  --hairline-soft: #ddd7c8;

  --shadow: 0 1px 1px rgba(32, 31, 29, .05), 0 8px 20px -16px rgba(32, 31, 29, .5);
  --shadow-lift: 0 2px 4px rgba(32, 31, 29, .07), 0 14px 28px -18px rgba(32, 31, 29, .55);
  --radius: 4px;
  --radius-sm: 3px;

  --font-display: "Space Grotesk", "Unbounded", "Inter", sans-serif;
  --font: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  color-scheme: light;
}

/* ---------- Тёмная тема: бумага и чернила меняются местами ---------- */
[data-theme="dark"] {
  --paper: #1b1a18;
  --paper-2: #232120;
  --card: #26241f;
  --ink: #ece8df;
  --ink-soft: #b0aaa0;
  --ink-faint: #857f76;
  --moss: #8ea076;
  --moss-soft: #2b3227;
  --teal: #5cab9e;
  --teal-soft: #1d312e;
  --teal-text: #14201e;
  --wheat: #d9ae58;
  --wheat-soft: #332a17;
  --rust: #d3775a;
  --rust-soft: #36211a;
  --hairline: #413d36;
  --hairline-soft: #322e29;
  --shadow: 0 1px 1px rgba(0, 0, 0, .4), 0 8px 22px -16px rgba(0, 0, 0, .9);
  --shadow-lift: 0 2px 6px rgba(0, 0, 0, .5), 0 16px 30px -18px rgba(0, 0, 0, .95);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  [data-theme="auto"] {
    --paper: #1b1a18; --paper-2: #232120; --card: #26241f;
    --ink: #ece8df; --ink-soft: #b0aaa0; --ink-faint: #857f76;
    --moss: #8ea076; --moss-soft: #2b3227;
    --teal: #5cab9e; --teal-soft: #1d312e; --teal-text: #14201e;
    --wheat: #d9ae58; --wheat-soft: #332a17;
    --rust: #d3775a; --rust-soft: #36211a;
    --hairline: #413d36; --hairline-soft: #322e29;
    --shadow: 0 1px 1px rgba(0,0,0,.4), 0 8px 22px -16px rgba(0,0,0,.9);
    --shadow-lift: 0 2px 6px rgba(0,0,0,.5), 0 16px 30px -18px rgba(0,0,0,.95);
    color-scheme: dark;
  }
}

/* ---------- Основа ---------- */
* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.55 var(--font);
}

a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; border-radius: var(--radius-sm); }

h1, h2, h3, .display { font-family: var(--font-display); letter-spacing: -.01em; overflow-wrap: anywhere; }
h1 { font-size: 26px; margin: 0 0 4px; font-weight: 700; }
h2 { font-size: 17px; margin: 22px 0 10px; font-weight: 700; }
h3 { font-size: 12px; margin: 16px 0 8px; font-weight: 600; text-transform: uppercase;
     letter-spacing: .1em; color: var(--moss); }

/* подпись-лейбл: тонкая разрядка, как на бланке */
.label { font-family: var(--font-display); font-size: 11px; font-weight: 600; letter-spacing: .12em;
         text-transform: uppercase; color: var(--moss); }

/* ---------- Каркас ---------- */
.layout { display: grid; grid-template-columns: 244px minmax(0, 1fr); min-height: 100vh; }
[data-nav="collapsed"] .layout { grid-template-columns: 66px minmax(0, 1fr); }

.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
           background: var(--paper-2); border-right: 1px solid var(--hairline); z-index: 30; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 8px;
                padding: 15px 14px 13px; border-bottom: 1px solid var(--hairline-soft); }
.brand { font-family: var(--font-display); font-weight: 700; font-size: 17px; color: var(--ink);
         letter-spacing: -.02em; white-space: nowrap; }
.brand span { color: var(--teal); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 9px; position: relative; }
.nav-group + .nav-group { margin-top: 16px; }
.nav-group-title { margin: 0 0 6px 11px; font-family: var(--font-display); font-size: 10px;
                   text-transform: uppercase; letter-spacing: .14em; color: var(--ink-faint); }

/* подложка активного пункта — скользит между разделами */
.nav-marker { position: absolute; top: 0; left: 9px; right: 9px; height: 0; border-radius: var(--radius);
              background: var(--teal-soft); border-left: 3px solid var(--teal);
              transition: transform .32s cubic-bezier(.4, 0, .2, 1), height .32s cubic-bezier(.4, 0, .2, 1);
              pointer-events: none; opacity: 0; }
.nav-marker.ready { opacity: 1; }

.nav-link { position: relative; z-index: 1; display: flex; align-items: center; gap: 11px;
            padding: 9px 11px; border-radius: var(--radius); color: var(--ink-soft);
            font-size: 14.5px; white-space: nowrap; }
.nav-link:hover { color: var(--ink); text-decoration: none; }
.nav-link:hover:not(.active) { background: var(--moss-soft); }
.nav-link.active { color: var(--teal); font-weight: 600; }
.nav-link .ic { flex: none; }
.sidebar-foot { padding: 9px; border-top: 1px solid var(--hairline-soft); }
/* подложка скользит только по основному меню, нижним пунктам рисуем её на месте */
.sidebar-foot .nav-link.active { background: var(--teal-soft); border-left: 3px solid var(--teal);
                                 padding-left: 8px; }
.ic { width: 19px; height: 19px; }

[data-nav="collapsed"] .brand span,
[data-nav="collapsed"] .nav-link span,
[data-nav="collapsed"] .nav-group-title { display: none; }
[data-nav="collapsed"] .nav-link { justify-content: center; padding: 10px 0; }
[data-nav="collapsed"] .sidebar-head { justify-content: center; }
[data-nav="collapsed"] .nav-collapse { transform: rotate(180deg); }

/* ---------- Верхняя строка ---------- */
.content { display: flex; flex-direction: column; min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 25; display: flex; align-items: center; gap: 12px;
          padding: 10px 24px; background: var(--paper); border-bottom: 1px solid var(--hairline-soft); }
.search { position: relative; flex: 1; max-width: 480px; display: flex; align-items: center; }
.search .ic { position: absolute; left: 11px; color: var(--ink-faint); pointer-events: none; }
.search input { padding-left: 36px; }
.topbar-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }

.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px;
            border: 1px solid transparent; border-radius: var(--radius); background: transparent;
            color: var(--ink-soft); cursor: pointer; position: relative; }
.icon-btn:hover { background: var(--paper-2); color: var(--ink); }
.bell b { position: absolute; top: 2px; right: 1px; background: var(--rust); color: #fff;
          border-radius: 8px; font-size: 10px; padding: 0 5px; font-weight: 500; font-family: var(--mono); }
.nav-open { display: none; }

.theme-switch { display: inline-flex; border: 1px solid var(--hairline); border-radius: var(--radius);
                overflow: hidden; background: var(--card); }
.theme-switch button { background: none; border: 0; padding: 6px 9px; cursor: pointer;
                       color: var(--ink-faint); line-height: 0; }
.theme-switch button:hover { background: var(--paper-2); color: var(--ink); }
.theme-switch button[aria-pressed="true"] { background: var(--teal); color: var(--teal-text); }
.theme-switch .ic { width: 16px; height: 16px; }

main { padding: 22px 24px 28px; max-width: 1460px; width: 100%; }
main.plain { max-width: none; padding: 0; }
.nav-backdrop { display: none; }

/* ---------- Шина смены: дата и краткий итог дня ---------- */
.shift-bar { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap;
             padding: 0 0 14px; border-bottom: 2px solid var(--ink); margin-bottom: 20px; }
.shift-date { font-family: var(--mono); font-size: 13px; letter-spacing: .08em; color: var(--moss);
              text-transform: uppercase; }
.shift-line { font-family: var(--font-display); font-size: 22px; font-weight: 700; margin: 0; }
.shift-note { color: var(--ink-soft); font-size: 14px; margin-left: auto; }

/* ---------- Тикет: запись с линией отреза и штампом ---------- */
.ticket {
  position: relative; background: var(--card); border: 1px solid var(--hairline-soft);
  border-radius: var(--radius); padding: 13px 15px 13px 26px; box-shadow: var(--shadow);
  transition: transform .16s ease, box-shadow .16s ease;
  /* перфорация по левому краю — полукруглые вырезы, как у оторванного бланка */
  -webkit-mask-image: radial-gradient(circle 4px at left, transparent 96%, #000 100%);
  mask-image: radial-gradient(circle 4px at left, transparent 96%, #000 100%);
  -webkit-mask-size: 100% 15px; mask-size: 100% 15px;
  -webkit-mask-repeat: repeat-y; mask-repeat: repeat-y;
}
.ticket::before { content: ""; position: absolute; left: 13px; top: 9px; bottom: 9px;
                  border-left: 1px dashed var(--hairline); }
.ticket:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.ticket-title { display: block; font-weight: 600; color: var(--ink); margin-bottom: 3px; }
.ticket-sub { display: block; font-size: 13px; color: var(--ink-soft); }
.ticket-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; align-items: center; }
.ticket-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px;
               margin-top: 9px; }

/* штамп ОТК: диагональная отметка в правом верхнем углу */
.stamp-mark {
  position: absolute; top: 10px; right: 12px; transform: rotate(-7deg);
  font-family: var(--mono); font-size: 10.5px; font-weight: 500; letter-spacing: .1em;
  text-transform: uppercase; padding: 3px 8px; border: 1.5px solid currentColor;
  border-radius: var(--radius-sm); color: var(--moss); background: var(--card);
  animation: stamp-press .28s cubic-bezier(.2, 1.3, .5, 1);
}
.stamp-mark.ok { color: var(--teal); }
.stamp-mark.wait { color: var(--wheat); }
.stamp-mark.late { color: var(--rust); }
.ticket.has-stamp { padding-right: 108px; }

@keyframes stamp-press {
  0%   { transform: rotate(-14deg) scale(1.15); opacity: 0; }
  60%  { transform: rotate(-5deg) scale(.98); opacity: 1; }
  100% { transform: rotate(-7deg) scale(1); }
}

/* ---------- Статус-тикеты (счётчики) ---------- */
.status-row { display: grid; gap: 12px; grid-template-columns: repeat(4, minmax(0, 1fr));
              margin-bottom: 22px; }
.status-ticket { position: relative; background: var(--card); border: 1px solid var(--hairline-soft);
                 border-top: 3px solid var(--moss); border-radius: var(--radius);
                 padding: 13px 15px; box-shadow: var(--shadow);
                 transition: transform .16s ease, box-shadow .16s ease; }
.status-ticket:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.status-ticket.alert { border-top-color: var(--rust); }
.status-ticket.wait { border-top-color: var(--wheat); }
.status-ticket.ok { border-top-color: var(--teal); }
.status-value { font-family: var(--mono); font-size: 32px; font-weight: 500; line-height: 1.05;
                letter-spacing: -.02em; }
.status-ticket.alert .status-value { color: var(--rust); }
.status-ticket.wait .status-value { color: var(--wheat); }
.status-ticket.ok .status-value { color: var(--teal); }
.status-label { color: var(--ink-soft); font-size: 13px; margin-top: 5px; }
.status-hint { font-family: var(--mono); font-size: 11px; color: var(--ink-faint); margin-top: 7px;
               letter-spacing: .04em; }

/* ---------- Журнал: лента по дням ---------- */
.journal { display: flex; flex-direction: column; gap: 22px; }
.journal-day { display: grid; grid-template-columns: 108px minmax(0, 1fr); gap: 16px; }
.journal-date { position: sticky; top: 68px; align-self: start; }
.journal-date .day { font-family: var(--mono); font-size: 15px; letter-spacing: .06em; color: var(--ink); }
.journal-date .weekday { font-size: 12px; color: var(--ink-faint); text-transform: lowercase; }
.journal-items { display: flex; flex-direction: column; gap: 9px; min-width: 0; }
.journal-empty { color: var(--ink-soft); font-size: 14px; }

/* ---------- Карточки и сетки ---------- */
.card { background: var(--card); border: 1px solid var(--hairline-soft); border-radius: var(--radius);
        padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card h2:first-child, .card h3:first-child { margin-top: 0; }
.card table { display: block; overflow-x: auto; max-width: 100%; white-space: normal; }
.card .table-wrap table { display: table; }

.grid { display: grid; gap: 16px; }
.grid > * { min-width: 0; }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
.grid.c3 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.c4 { grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); }

.kpi { background: var(--card); border: 1px solid var(--hairline-soft); border-top: 3px solid var(--moss);
       border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .value { font-family: var(--mono); font-size: 29px; font-weight: 500; line-height: 1.1;
              letter-spacing: -.02em; }
.kpi .label { color: var(--ink-soft); font-size: 13px; margin-top: 4px; text-transform: none;
              letter-spacing: 0; font-family: var(--font); font-weight: 400; }
.kpi.warn { border-top-color: var(--rust); }
.kpi.warn .value { color: var(--rust); }
.kpi.ok { border-top-color: var(--teal); }
.kpi.ok .value { color: var(--teal); }

/* ---------- Таблицы ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 9px 11px; text-align: left; border-bottom: 1px solid var(--hairline-soft);
         vertical-align: top; }
th { background: var(--paper-2); font-family: var(--font-display); font-weight: 600; font-size: 11px;
     color: var(--moss); text-transform: uppercase; letter-spacing: .1em; }
tbody tr:hover td { background: var(--paper-2); }
td.num, th.num { text-align: right; white-space: nowrap; font-family: var(--mono); }
.table-wrap { overflow-x: auto; max-width: 100%; border: 1px solid var(--hairline-soft);
              border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); }
.table-wrap th { position: sticky; top: 0; z-index: 1; }
.nowrap { white-space: nowrap; }
.small { font-size: 13px; color: var(--ink-soft); }
.muted { color: var(--ink-soft); }

/* ---------- Штампы-подписи в строках ---------- */
.stamp, .badge {
  display: inline-block; padding: 2px 7px; border-radius: var(--radius-sm);
  font-family: var(--mono); font-size: 11px; line-height: 1.5; white-space: nowrap;
  letter-spacing: .05em; border: 1px solid currentColor; color: var(--ink-soft); background: transparent;
}
.badge.green, .stamp-ok { color: var(--teal); background: var(--teal-soft); }
.badge.orange, .stamp-warn { color: var(--wheat); background: var(--wheat-soft); }
.badge.red, .stamp-alert { color: var(--rust); background: var(--rust-soft); }
.badge.blue { color: var(--moss); background: var(--moss-soft); }
.badge.violet { color: var(--moss); background: var(--moss-soft); }
.badge.teal { color: var(--teal); background: var(--teal-soft); }
.badge.gray { color: var(--ink-soft); background: var(--paper-2); }
.badge.demo, .stamp-demo { color: var(--wheat); background: var(--wheat-soft); font-weight: 500; }

/* ---------- Кнопки ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
       padding: 8px 14px; border-radius: var(--radius); border: 1px solid var(--hairline);
       background: var(--card); color: var(--ink); cursor: pointer; font-size: 14px;
       font-family: inherit; text-decoration: none; transition: background .14s ease, border-color .14s ease; }
.btn:hover { background: var(--paper-2); border-color: var(--moss); text-decoration: none; }
.btn.primary { background: var(--teal); border-color: var(--teal); color: var(--teal-text); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.small { padding: 4px 9px; font-size: 13px; }
.btn.danger { color: var(--rust); border-color: var(--rust); background: transparent; }
.btn.danger:hover { background: var(--rust-soft); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Формы ---------- */
label { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 4px; }
input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--hairline);
  border-radius: var(--radius); font: inherit; font-size: 14px; background: var(--card); color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-soft); }
input[type=date], input[type=time], input[type=number] { font-family: var(--mono); }
textarea { min-height: 76px; resize: vertical; }
.field { margin-bottom: 12px; }
.form-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
form.inline { display: inline; }
fieldset { border: 1px solid var(--hairline-soft); border-radius: var(--radius); padding: 12px;
           margin: 0 0 14px; background: var(--paper-2); }
legend { font-family: var(--font-display); font-size: 11px; color: var(--moss); padding: 0 6px;
         text-transform: uppercase; letter-spacing: .1em; }
.checks { display: flex; gap: 16px; flex-wrap: wrap; }
.checks label { display: flex; align-items: center; gap: 6px; color: var(--ink); font-size: 14px; margin: 0; }
.checks input { width: auto; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters .field { margin: 0; min-width: 170px; }

/* ---------- Сообщения ---------- */
.msg { padding: 11px 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: 14px;
       border-left: 3px solid currentColor; }
.msg.ok { background: var(--teal-soft); color: var(--teal); }
.msg.err { background: var(--rust-soft); color: var(--rust); }
.msg.info { background: var(--moss-soft); color: var(--moss); }
.msg.warn { background: var(--wheat-soft); color: var(--wheat); }
.msg ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------- Прочее ---------- */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 9px 0; border-bottom: 1px solid var(--hairline-soft); }
.timeline li:last-child { border-bottom: 0; }

dl.props { display: grid; grid-template-columns: 190px 1fr; gap: 8px 14px; margin: 0; }
dl.props dt { color: var(--ink-soft); font-size: 13px; }
dl.props dd { margin: 0; }

/* ---------- Доска задач ---------- */
.board { display: grid; gap: 14px; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; }
.board-col { background: var(--paper-2); border: 1px solid var(--hairline-soft); border-radius: var(--radius);
             padding: 10px; transition: border-color .15s ease; }
.board-col.is-over { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-soft); }
.board-col-head { display: flex; align-items: center; justify-content: space-between; gap: 8px;
                  padding: 2px 4px 10px; }
.board-col-head h2 { margin: 0; font-size: 11px; text-transform: uppercase; letter-spacing: .12em;
                     color: var(--moss); }
.board-count { font-family: var(--mono); font-size: 12px; color: var(--ink-soft);
               background: var(--card); border: 1px solid var(--hairline-soft);
               border-radius: var(--radius-sm); padding: 1px 7px; }
.board-drop { display: flex; flex-direction: column; gap: 9px; min-height: 70px; }
.board-card { position: relative; background: var(--card); border: 1px solid var(--hairline-soft);
              border-left: 3px solid var(--moss); border-radius: var(--radius); padding: 10px 11px;
              cursor: grab; box-shadow: var(--shadow);
              transition: transform .16s ease, box-shadow .16s ease; }
.board-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.board-card:active { cursor: grabbing; }
.board-card.is-dragging { opacity: .45; }
.board-card.is-overdue { border-left-color: var(--rust); }
.board-title { display: block; font-weight: 600; color: var(--ink); margin-bottom: 4px; }
.board-object { display: block; font-size: 12.5px; margin-bottom: 6px; }
.board-meta { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 8px; }
.board-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.board-move { display: flex; gap: 4px; }
.board-move form { display: inline; }
.board-empty { color: var(--ink-faint); font-size: 13px; text-align: center; padding: 14px 0; margin: 0; }

/* ---------- Фотографии ---------- */
.photos { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.photo { margin: 0; background: var(--card); border: 1px solid var(--hairline-soft);
         border-radius: var(--radius); overflow: hidden; }
.photo img { display: block; width: 100%; height: 150px; object-fit: cover; background: var(--paper-2); }
.photo figcaption { padding: 8px 10px; font-size: 13px; }
.photo figcaption form { margin-top: 6px; }
.photo-file { display: flex; flex-direction: column; align-items: center; justify-content: center;
              height: 150px; gap: 6px; background: var(--paper-2); text-align: center; padding: 8px; }
.photo-ext { font-size: 19px; font-weight: 500; color: var(--ink-soft); font-family: var(--mono); }
.upload-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.upload-caption { flex: 1; min-width: 180px; width: auto; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input[type=file] { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }
.file-hint { color: var(--teal); }
.mobile-only { display: none; }

/* ---------- Вход и чат ---------- */
.login-wrap { max-width: 390px; margin: 9vh auto; background: var(--card);
              border: 1px solid var(--hairline-soft); border-top: 3px solid var(--teal);
              border-radius: var(--radius); padding: 26px; box-shadow: var(--shadow); }
.chat-log { max-height: 60vh; overflow-y: auto; display: flex; flex-direction: column;
            gap: 12px; margin-bottom: 14px; }
.bubble { padding: 11px 14px; border-radius: var(--radius); max-width: 82%; }
.bubble.me { background: var(--teal-soft); align-self: flex-end; }
.bubble.bot { background: var(--paper-2); align-self: flex-start; }
.bubble ul { margin: 8px 0 0; padding-left: 18px; }

footer.status { margin-top: 10px; padding: 8px 0 24px; color: var(--ink-faint); font-size: 12px;
                font-family: var(--mono); letter-spacing: .03em; border-top: 1px solid var(--hairline-soft); }
.overdue { color: var(--rust); font-weight: 600; }
.soon { color: var(--wheat); }

.nav-collapse { background: transparent; border: 1px solid transparent;
  border-radius: var(--radius); padding: 6px; cursor: pointer; color: var(--ink-soft); line-height: 0; }
.nav-collapse:hover { background: var(--card); color: var(--ink); }

/* ---------- Планшет и телефон ---------- */
@media (max-width: 1100px) {
  .board { grid-template-columns: 1fr; }
  .status-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
  .layout, [data-nav="collapsed"] .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 268px; transform: translateX(-100%);
             transition: transform .2s ease; box-shadow: var(--shadow-lift); }
  [data-nav="mobile"] .sidebar { transform: none; }
  [data-nav="collapsed"] .brand span, [data-nav="collapsed"] .nav-link span,
  [data-nav="collapsed"] .nav-group-title { display: inline; }
  [data-nav="collapsed"] .nav-link { justify-content: flex-start; padding: 11px 10px; }
  .nav-collapse { display: none; }
  .nav-open { display: inline-flex; }
  .nav-backdrop { display: block; position: fixed; inset: 0; background: rgba(20, 18, 15, .5); z-index: 28; }
  .nav-backdrop[hidden] { display: none; }
  .nav-link { padding: 12px 10px; font-size: 15.5px; }
  .topbar { padding: 9px 14px; gap: 8px; }
  .search { max-width: none; }
  main { padding: 14px; }
  h1 { font-size: 20px; }
  .shift-line { font-size: 19px; }
  .shift-note { margin-left: 0; flex-basis: 100%; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1; }
  .mobile-only { display: inline-flex; }
  .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: 1fr; }
  .journal-day { grid-template-columns: 1fr; gap: 8px; }
  .journal-date { position: static; display: flex; gap: 8px; align-items: baseline;
                  border-bottom: 1px dashed var(--hairline); padding-bottom: 5px; }
  .btn { min-height: 40px; }
  .btn.small { min-height: 34px; }
  input, select, textarea { font-size: 16px; }
  .filters { flex-direction: column; align-items: stretch; }
  .filters .field { min-width: 0; width: 100%; }
  .card { padding: 13px; }
  .card table { font-size: 13.5px; }
  .hide-mobile { display: none; }
  .photos { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; }
  .photo img, .photo-file { height: 124px; }
  .upload-form { flex-direction: column; align-items: stretch; }
  .upload-form .btn, .upload-caption { width: 100%; }
  dl.props { grid-template-columns: 1fr; gap: 3px 0; }
  dl.props dt { margin-top: 8px; }
  .board-card { cursor: default; }
}

@media (max-width: 560px) {
  .status-row { grid-template-columns: 1fr; gap: 9px; }
  .status-value { font-size: 27px; }
  .ticket.has-stamp { padding-right: 15px; padding-top: 34px; }
  .stamp-mark { top: 9px; right: auto; left: 26px; }
  .photos { grid-template-columns: 1fr 1fr; }
  .brand { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .nav-marker { transition: none !important; }
}
