/* Оформление рабочих экранов.
   Один набор стилей на компьютер и телефон: на узком экране колонки
   перестраиваются, таблицы прокручиваются вбок, кнопки становятся крупнее. */

:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --border: #dfe4ea;
    --text: #1f2933;
    --text-muted: #6b7784;
    --accent: #2f6fb0;
    --accent-dark: #245a91;
    --success: #2e7d4f;
    --success-bg: #e7f4ec;
    --warning: #9a6b00;
    --warning-bg: #fdf3dd;
    --danger: #b3372c;
    --danger-bg: #fbeceb;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

/* ---------- Верхняя панель ---------- */

.topbar {
    background: #22303c;
    color: #fff;
    padding: 12px 0;
}
.topbar .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.topbar__brand { font-size: 17px; font-weight: 600; color: #fff; }
.topbar__brand:hover { text-decoration: none; }
.topbar__user { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.topbar__name { color: #cfd8e0; }
.topbar__role { color: #8ea3b5; font-size: 13px; }
.topbar a.topbar__link { color: #cfd8e0; }

/* Уведомления и журнал — значками в шапке, а не вкладками в меню:
   это «посмотреть, что происходит», а не работа. Меню от этого короче */
.topbar__icon {
    position: relative;
    display: flex;
    align-items: center;
    color: #cfd8e0;
    padding: 4px;
    border-radius: var(--radius-sm, 6px);
}
.topbar__icon:hover { color: #fff; background: rgba(255, 255, 255, .1); }
.topbar__icon svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}
/* Счётчик непрочитанного: он и есть причина сюда смотреть */
.topbar__count {
    position: absolute;
    top: -3px;
    left: 16px;
    min-width: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--danger);
    color: #fff;
    font-size: 11px;
    line-height: 16px;
    text-align: center;
}

/* ---------- Меню вкладок ---------- */

.nav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}
.nav .container { display: flex; gap: 4px; }
.nav__item {
    padding: 13px 14px;
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
}
.nav__item:hover { color: var(--text); text-decoration: none; }
.nav__item--active { color: var(--accent); border-bottom-color: var(--accent); }

/* Разделы документов под одним пунктом: вчетвером их длинные названия
   съедали пол-строки, а сокращать их нельзя — они повторяют вкладки 1С */
.nav__item--toggle {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    /* Поимённо, а не сокращением `font`: оно сбросило бы и насыщенность,
       и пункт «Документы» оказался бы бледнее соседей */
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.nav__caret { font-size: 10px; }

/* Панель раскрывается под строкой меню — всплывающий список обрезался бы
   прокруткой самой строки */
.nav-panel {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
}
.nav-panel .container {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding-top: 8px;
    padding-bottom: 8px;
}
.nav-panel__item {
    padding: 8px 12px;
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
}
.nav-panel__item:hover { background: #eef1f4; text-decoration: none; }
.nav-panel__item--active { color: var(--accent); font-weight: 500; }

/* ---------- Содержимое ---------- */

main { padding: 24px 0 64px; }

h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.page-header { margin-bottom: 20px; display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.subtitle { color: var(--text-muted); font-size: 14px; margin: 0; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    margin-bottom: 16px;
}
.card--flush { padding: 0; overflow: hidden; }

.empty {
    text-align: center;
    color: var(--text-muted);
    padding: 44px 16px;
}
.empty__icon { font-size: 30px; display: block; margin-bottom: 8px; opacity: .5; }

/* ---------- Кнопки ---------- */

.btn {
    display: inline-block;
    padding: 9px 16px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-weight: 500;
    cursor: pointer;
    text-align: center;
}
.btn:hover { background: var(--accent-dark); text-decoration: none; color: #fff; }
.btn--secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn--secondary:hover { background: #eef1f4; color: var(--text); }
.btn--danger { background: var(--danger); }
.btn--danger:hover { background: #932c23; }
.btn--small { padding: 6px 11px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Переключатель «Мои / Все»: это не два действия, а один орган с двумя
   положениями. Пока он выглядел парой кнопок, он спорил с соседними
   «Поставить задачу» и вдобавок был ниже их ростом */
.switch { display: inline-flex; }
.switch__option {
    padding: 9px 16px;
    border: 1px solid var(--border);
    background: var(--surface);
    /* Цвет читается от фона: на белом — тёмный, на синем — белый.
       Приглушённый серый здесь не годится: это не подпись, а орган
       управления, и невыбранная половина должна читаться так же ясно */
    color: var(--text);
    font-weight: 500;
    font-size: 14px;
    white-space: nowrap;
}
.switch__option:first-child { border-radius: 8px 0 0 8px; }
.switch__option:last-child { border-radius: 0 8px 8px 0; margin-left: -1px; }
.switch__option:hover { background: #eef1f4; text-decoration: none; }
.switch__option--active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    position: relative;
}
.switch__option--active:hover { background: var(--accent-dark); color: #fff; }

/* ---------- Значки и статусы ---------- */

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: #eceff2;
    color: var(--text-muted);
}
.badge--actual { background: #e6effa; color: var(--accent-dark); }
.badge--completed { background: var(--success-bg); color: var(--success); }
.badge--incomplete { background: var(--warning-bg); color: var(--warning); }
.badge--cancelled { background: var(--danger-bg); color: var(--danger); }
.badge--draft { background: var(--warning-bg); color: var(--warning); }
.badge--count {
    background: var(--accent);
    color: #fff;
    margin-left: 6px;
    padding: 1px 7px;
}
.nav__item--active .badge--count { background: var(--accent); }

/* ---------- Таблицы ---------- */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); }
th { font-size: 13px; text-transform: uppercase; letter-spacing: .3px; color: var(--text-muted); font-weight: 600; background: #fafbfc; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Пары «поле — значение»: стороны передачи в задаче документообороту.
   Не список данных, а шапка будущей бумаги, поэтому без полос и наведения */
.params { margin: 0 0 14px; }
.params th { width: 190px; background: none; border-bottom: none; padding: 4px 0; }
.params td { border-bottom: none; padding: 4px 0; }
.params tbody tr:hover { background: none; }
@media (max-width: 640px) {
    .params th, .params td { display: block; width: auto; padding: 2px 0; }
    .params th { padding-top: 8px; }
}
.muted { color: var(--text-muted); }
.small { font-size: 13px; }

/* ---------- Формы ---------- */

label { display: block; font-weight: 500; margin-bottom: 5px; font-size: 14px; }
input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
    background: #fff;
    color: var(--text);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(47, 111, 176, .15);
}
.field { margin-bottom: 14px; }
.field__hint { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.errorlist { list-style: none; margin: 6px 0 0; padding: 0; color: var(--danger); font-size: 13px; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row > * { flex: 1; min-width: 180px; }
/* Кнопки в строке отбора: занимают ровно свою ширину. Без этого им
   доставалась доля строки, и пара кнопок вылезала за край карточки */
.form-row > .form-row__actions {
    flex: 0 0 auto;
    min-width: 0;
    display: flex;
    align-items: flex-end;
    gap: 8px;
}
.form-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

/* Строки позиций в форме выдачи */
.items-table th:last-child, .items-table td:last-child { width: 44px; }
.items-table input, .items-table select { margin: 0; }
.items-table .errorlist { margin-top: 4px; }
.row-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
}
.row-remove:hover { color: var(--danger); }

/* ---------- Сообщения ---------- */

.messages { margin-bottom: 16px; }
.message {
    padding: 11px 14px;
    border-radius: 8px;
    margin-bottom: 8px;
    border: 1px solid transparent;
    font-size: 14px;
}
.message--success { background: var(--success-bg); color: var(--success); border-color: #bfe0cc; }
.message--info { background: #e6effa; color: var(--accent-dark); border-color: #c3d8ee; }
.message--warning { background: var(--warning-bg); color: var(--warning); border-color: #eed9a8; }
.message--error { background: var(--danger-bg); color: var(--danger); border-color: #efc4c0; }

/* ---------- Чек-лист задачи ---------- */

.checklist { list-style: none; margin: 0; padding: 0; }
.checklist__item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
}
.checklist__item:last-child { border-bottom: none; }
.checklist__item--done { background: #fafdfb; }
.checklist__item input[type=checkbox] { width: 20px; height: 20px; flex: none; cursor: pointer; accent-color: var(--accent); }
.checklist__body { flex: 1; min-width: 0; }
.checklist__name { font-weight: 500; }
.checklist__item--done .checklist__name { color: var(--text-muted); text-decoration: line-through; }
.checklist__meta { font-size: 13px; color: var(--text-muted); }
.checklist__qty { font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }

.progress { height: 6px; background: #eceff2; border-radius: 999px; overflow: hidden; margin-top: 10px; }
.progress__bar { height: 100%; background: var(--success); transition: width .2s; }

/* ---------- Пересчёт ---------- */

/* Непосчитанные позиции видно сразу — не надо выискивать пропуски глазами */
.count-row--empty td:first-child { color: var(--text-muted); }
.count-input { max-width: 130px; }

/* ---------- Переключатель «комплектующие / изделия» ---------- */

.cargo-switch { display: flex; gap: 8px; flex-wrap: wrap; }
.cargo-switch .btn { flex: 0 0 auto; }

/* ---------- Отчёт по движениям ---------- */

/* Заголовок группы колонок стоит над своей тройкой, поэтому по центру
   и с рамкой — иначе не видно, где кончается один раздел и начинается другой */
.report th.group { text-align: center; border-left: 1px solid var(--border); }
.report th.net, .report td.net { background: #fafbfc; font-weight: 600; }
.report td.total { font-weight: 700; }
.report .minus { color: var(--danger); }
.report-row--empty td { color: var(--text-muted); }

/* ---------- Комментарии к позиции ---------- */

.notes { list-style: none; margin: 0 0 16px; padding: 0; }
.note {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 11px 0;
    border-bottom: 1px solid var(--border);
}
.note:last-child { border-bottom: none; }
.note__body { flex: 1; min-width: 0; }
.note__text { white-space: pre-wrap; overflow-wrap: anywhere; }
.note__meta { margin-top: 3px; }
.note form { flex: none; }
.note-form { border-top: 1px solid var(--border); padding-top: 14px; }

/* ---------- Выбор исполнителей ---------- */

.assignees { display: flex; flex-wrap: wrap; gap: 8px; }
.assignee {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-weight: 400;
    margin: 0;
    cursor: pointer;
}
.assignee:hover { background: #fafbfc; }
.assignee input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.assignee ul { list-style: none; margin: 0; padding: 0; }

/* ---------- Уведомления ---------- */

.notification {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}
.notification:last-child { border-bottom: none; }
.notification--unread { background: #f5f9fd; }
.notification__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-top: 7px; flex: none; }
.notification--read .notification__dot { background: transparent; }
.notification__body { flex: 1; min-width: 0; }
.notification__time { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ---------- Теги ---------- */

.tags { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg);
    font-size: 13px;
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
}
.tag:hover { border-color: var(--accent); }
.tag--on { border-color: var(--accent); background: #eef5fd; }
.tag--on a { text-decoration: none; }
.tag--small { padding: 1px 8px; font-size: 12px; margin-left: 6px; }

/* Крестик снятия — кнопка, но выглядеть должна как часть метки */
.tag__remove {
    border: none;
    background: none;
    cursor: pointer;
    padding: 0 0 0 2px;
    color: var(--text-muted);
    font-size: 15px;
    line-height: 1;
}
.tag__remove:hover { color: var(--danger); }

/* ---------- Вход ---------- */

.login-wrap { max-width: 380px; margin: 8vh auto; padding: 0 16px; }
.login-title { text-align: center; margin-bottom: 6px; }
.login-sub { text-align: center; color: var(--text-muted); margin: 0 0 22px; font-size: 14px; }

/* ---------- Телефон ---------- */

@media (max-width: 640px) {
    .topbar__role { display: none; }
    /* Меню не переносится на три строки, а прокручивается вбок:
       так шапка остаётся одной высоты, сколько бы прав ни было */
    .nav .container {
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
    }
    .nav .container::-webkit-scrollbar { display: none; }
    .nav__item { white-space: nowrap; }
    /* На телефоне разделы столбиком: в строку они всё равно не встанут */
    .nav-panel .container { flex-direction: column; }
    .btn { padding: 11px 16px; }
    .card { padding: 14px; }
    .form-row > * { min-width: 100%; }
    th, td { padding: 10px; }
    h1 { font-size: 19px; }
}
