/* Утилитарный стиль внутреннего приложения: только читаемость и скорость работы. */

:root {
    --border: #ccd2d9;
    --muted: #6b7480;
    --bg-head: #eef1f4;
    --bg-hover: #e8f1fb;
    --accent: #1f4e8c;
    --error: #a11b1b;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font: 15px/1.45 "Segoe UI", Arial, sans-serif;
    color: #1c1f23;
    background: #f7f8f9;
}

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

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

.topbar {
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
    padding: 10px 16px;
    background: #F9ECA0;
    color: #000;
    border-bottom: 1px solid var(--border);
}
.page-head{
 margin: 10px;
}

.brand { font-weight: 600; font-size: 16px; }

.mainnav { display: flex; gap: 16px; flex-wrap: wrap; }
.mainnav a { padding: 2px 0; }

.userbox { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.username { color: var(--muted); }

.mainnav a.active { font-weight: 600; text-decoration: underline; }

.inline-form { display: inline; }

.linklike {
    border: 0;
    background: none !important;
    color: var(--accent) !important;
    cursor: pointer;
    padding: 0;
    font: inherit;
}

main { padding: 16px; }

h1 { font-size: 20px; margin: 0 0 14px; }

/* Формы */

label { display: block; margin: 10px 0 4px; color: var(--muted); }

input[type="text"],
input[type="password"],
input[type="date"],
input[type="number"],
input[type="search"],
select,
textarea {
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 3px;
    font: inherit;
    background: #fff;
    max-width: 100%;
}

textarea { width: 100%; min-height: 60px; }

button {
    padding: 7px 14px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--bg-head);
    font: inherit;
    cursor: pointer;
}

button[type="submit"] { background: var(--accent); border-color: var(--accent); color: #fff; }
button:hover { filter: brightness(0.96); }

.loginbox {
    max-width: 360px;
    margin: 60px auto;
    padding: 20px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 4px;
}

.loginbox input { width: 100%; }
.loginbox button { width: 100%; margin-top: 14px; }

/* Таблицы */

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

th, td {
    padding: 3px 10px;
    border: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

th { background: var(--bg-head); font-weight: 600; }

td.num, th.num { text-align: right; white-space: nowrap; }

/* Подсветка строки таблицы при наведении курсора. */
tbody tr:hover td { background: var(--bg-hover); }

/* Строка неактивного товара */
tr.inactive td { background: #f3f4f5; color: var(--muted); }

tr.inactive:hover td { background: #e4e9ef; }

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

.msg { padding: 8px 10px; background: #fff; border: 1px solid var(--border); border-radius: 3px; }
.msg-error { border-color: var(--error); color: var(--error); }
.msg-warning {
    border-color: #b8860b;
    background: #fff8e1;
    color: #7a5c00;
}

.muted { color: var(--muted); }

.badge {
    display: inline-block;
    padding: 1px 6px;
    font-size: 11px;
    font-weight: 500;
    border-radius: 3px;
    line-height: 1.4;
}
.badge-warning {
    color: #8a5a00;
    background: #fdf3d8;
    border: 1px solid #e6d08a;
}
.badge-success {
    color: #155724;
    background: #d4edda;
    border: 1px solid #c3e6cb;
}
.badge-danger {
    color: #721c24;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
}
.text-danger {
    color: #b02a37;
    font-weight: 600;
}

/* Панель фильтров и действий */

.filters, .actions, .form-actions {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 2px;
}

.filters label { margin: 0 0 4px; }
.filters > div { display: flex; flex-direction: column; }

/* Поле, которое забирает свободное место в строке фильтров (поиск). */
.filters .field-grow { flex: 1 1 340px; min-width: 260px; }
.filters .field-grow input { width: 100%; }

/* Заголовок блока и кнопка справа/слева от него в одну строку. */
.items-head {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 0 0 8px;
}
.items-head h3 { margin: 0; }
.items-head .btnlink { padding: 4px 10px; font-size: 13px; }

/* Комментарий в форме продажи: во всю ширину страницы. */
.comment-wide {
    width: 100%;
    min-height: 150px;
    padding: 8px 10px;
    font: inherit;
    border: 1px solid var(--border);
    border-radius: 4px;
    resize: vertical;
}

/* Полоска состояния данных из 1С: даты и счётчики один раз над таблицей. */
.unf-bar {
    display: flex;
    align-items: baseline;
    gap: 18px;
    flex-wrap: wrap;
    padding: 8px 10px;
    margin-bottom: 10px;
    background: #f5f7f9;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
}
.unf-dates strong { font-size: 14px; }
.unf-counts { color: var(--muted); }
.unf-counts strong { color: var(--accent); }

.actions { align-items: center; }

.btnlink {
    display: inline-block;
    padding: 7px 14px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--bg-head);
   
}

td.actions { white-space: nowrap; }

/* Компактные строки таблиц (для больших справочников) */

table.compact th,
table.compact td {
    padding: 4px 8px;
    line-height: 1.35;
}

table.compact td.actions {
    white-space: nowrap;
}

/* Кнопки-иконки в ряд внутри ячейки таблицы */
.iconrow {
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: flex-start;
    margin: 0;
}

.iconbtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: 1px solid var(--border) !important;
    border-radius: 3px;
    background: #fff !important;
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
}

.iconbtn:hover { background: var(--bg-head); }
.iconbtn.danger { color: #b02a37; }
.iconbtn.danger:hover { background: #f8d7da; }
.iconbtn .inline-form { margin: 0; }
.iconbtn form { display: inline; margin: 0; }

/* Черновик продажи */

.badge-muted {
    background: #e9ecef;
    color: #495057;
}

tr.row-draft td {
    background: #f8f9fa;
    color: var(--muted);
}

tr.row-draft td a { color: #6c757d; }

.msg-info {
    background: #e7f1ff;
    border: 1px solid #b6d4fe;
    color: #0b4a8b;
    padding: 9px 12px;
    border-radius: 3px;
    margin: 0 0 12px;
}

.btn-secondary {
    background: #fff;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 7px 14px;
    border-radius: 3px;
    cursor: pointer;
}

.btn-secondary:hover { background: var(--bg-head); }

/* Автокомплит (интерактивный поиск по справочникам) */

.ac { position: relative; min-width: 240px; }
.ac .ac-input { width: 100%; padding-right: 28px; }

.ac .ac-clear {
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    border: 0;
    background: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
    padding: 2px 4px;
}

.ac .ac-clear:hover { color: #b02a37; }

.ac .ac-list {
    display: none;
    position: absolute;
    z-index: 50;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 320px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 3px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, .12);
}

.ac .ac-list.open { display: block; }

.ac .ac-item {
    padding: 6px 9px;
    font-size: 13px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
}

.ac .ac-item:last-child { border-bottom: 0; }
.ac .ac-item:hover,
.ac .ac-item.active { background: var(--bg-head); }

.ac-inline { display: flex; gap: 6px; align-items: center; }
.ac-inline .ac { flex: 1; }

td.actions > * { margin-right: 10px; }

/* Формы редактирования */

.editor { max-width: 640px; }
.editor input[type="text"], .editor textarea { width: 100%; }
.form-actions { margin-top: 16px; align-items: center; }

/* Строка неактивного товара — правило выше, рядом с hover. */

.pagination { margin-top: 12px; display: flex; gap: 10px; align-items: center; }

h2 { font-size: 17px; margin: 20px 0 8px; }

table.card { max-width: 900px; margin-bottom: 12px; }
table.card th { width: 130px; }


/* Адаптив для планшета и узких экранов */

@media (max-width: 900px) {
    .topbar { gap: 12px; }
    .userbox { margin-left: 0; }
    main { padding: 12px; }
    table { display: block; overflow-x: auto; white-space: nowrap; }
}
