/* =====================================================================
   techRepairShop — компоненты дизайн-системы.
   Токены и перекраска Bootstrap — в theme.css (подключается раньше).
   Разметка компонентов — templates/ui/macros.html.
   ===================================================================== */

/* ---------- Шапка страницы ---------- */
.page-head { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; justify-content: space-between; margin-bottom: 20px; }
.page-head__main { display: flex; gap: 12px; align-items: flex-start; min-width: 0; }
.page-head__back {
    width: 34px; height: 34px; flex: none; display: grid; place-items: center; margin-top: 2px;
    border-radius: var(--radius-sm); border: 1px solid var(--line-2); color: var(--text-2); text-decoration: none;
    transition: background .15s, color .15s;
}
.page-head__back:hover { background: var(--surface-2); color: var(--text); }
.page-eyebrow { font: 500 12.5px var(--mono); color: var(--accent-text); margin-bottom: 4px; }
.app-content h1.page-title, .page-title { margin: 0; font-size: 24px; font-weight: 600; letter-spacing: -.015em; line-height: 1.25; }
.page-title i { color: var(--muted-2); font-size: .8em; margin-right: 10px; }
.page-sub { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }
.page-head__actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------- Панель (карточка раздела) ---------- */
.panel {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    animation: tr-rise .32s var(--ease) both; min-width: 0;
}
.panel + .panel, .stack > * + * { margin-top: 16px; }
.panel__head {
    display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between;
    padding: 13px 18px; border-bottom: 1px solid var(--line);
}
.app-content .panel__title, .panel__title { margin: 0; font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.panel__title i { color: var(--muted-2); font-size: 13px; }
.panel__title .count { font: 500 12px var(--mono); color: var(--muted); }
.panel__actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.panel__body { padding: 16px 18px; }
.panel--flush .panel__body { padding: 0; }
.panel__foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; flex-wrap: wrap; }

/* Раскладки */
.layout-split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.layout-split > .side { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 20px; }
@media (max-width: 1199.98px) { .layout-split { grid-template-columns: minmax(0, 1fr); } .layout-split > .side { position: static; } }
.stack { display: flex; flex-direction: column; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 767.98px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }

/* ---------- KPI ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--text);
    animation: tr-rise .32s var(--ease) both; transition: border-color .2s, transform .2s var(--ease);
}
a.kpi:hover { border-color: var(--line-3); transform: translateY(-1px); color: var(--text); }
.kpi:nth-child(2) { animation-delay: .04s; } .kpi:nth-child(3) { animation-delay: .08s; } .kpi:nth-child(4) { animation-delay: .12s; }
.kpi__label { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.kpi__label i { color: var(--muted-2); }
.kpi__value { font: 500 26px/1.1 var(--mono); }
.kpi__hint { font-size: 12px; color: var(--muted); }
.kpi--accent .kpi__value, .kpi--accent .kpi__hint { color: var(--accent-text); }
.kpi--warn .kpi__value { color: var(--warn-text); }
.kpi--danger .kpi__value { color: var(--danger-text); }
.kpi--info .kpi__value { color: var(--info-text); }
.kpi--ok .kpi__value { color: var(--ok-text); }

/* ---------- Статусы ---------- */
.badge.st { font-weight: 500; font-size: 12px; padding: 3px 8px; border-radius: 5px; white-space: nowrap; }
.st-ok      { background: var(--ok-bg) !important;     color: var(--ok-text) !important; }
.st-accent  { background: var(--accent-bg) !important; color: var(--accent-text) !important; }
.st-info    { background: var(--info-bg) !important;   color: var(--info-text) !important; }
.st-warn    { background: var(--warn-bg) !important;   color: var(--warn-text) !important; }
.st-danger  { background: var(--danger-bg) !important; color: var(--danger-text) !important; }
.st-violet  { background: #231C33 !important;          color: #C4B5FD !important; }
.st-neutral { background: var(--surface-3) !important; color: var(--text-2) !important; }

/* Точка приоритета / свежести */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--line-3); }
.dot--danger { background: var(--danger); box-shadow: 0 0 0 3px rgba(239,68,68,.15); animation: tr-pulse 1.8s ease-in-out infinite; }
.dot--warn { background: var(--warn-text); }
.dot--ok { background: var(--accent); }
.dot--info { background: var(--info-text); }

/* ---------- Таблица данных ---------- */
.data-table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
    text-align: left; font-weight: 500; font-size: 11.5px; color: var(--muted-2); text-transform: uppercase;
    letter-spacing: .06em; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap;
    position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.data-table td { padding: 11px 14px; border-bottom: 1px solid #161C26; vertical-align: middle; color: var(--text); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr { transition: background .12s; }
.data-table tbody tr:hover td { background: var(--surface-2); }
.data-table tr.row-link { cursor: pointer; }
.data-table .cell-muted { color: var(--text-2); }
.data-table .cell-sub { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.data-table .cell-right { text-align: right; }
.data-table .cell-nowrap { white-space: nowrap; }

/* ---------- Пары «подпись — значение» ---------- */
.meta-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px 20px; margin: 0; }
.meta-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.meta dt, .meta__label { font-size: 12px; font-weight: 400; color: var(--muted); margin-bottom: 3px; }
.meta dd, .meta__value { margin: 0; font-size: 14px; color: var(--text); overflow-wrap: anywhere; }
.meta__value--lg { font-size: 16px; font-weight: 500; }

/* ---------- Таймлайн ---------- */
ol.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
ol.timeline::before { content: ""; position: absolute; left: 5px; top: 8px; bottom: 8px; width: 1px; background: var(--line-2); }
.tl-item { position: relative; padding: 0 0 18px 24px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
    content: ""; position: absolute; left: 0; top: 5px; width: 11px; height: 11px; border-radius: 50%;
    background: var(--surface); border: 2px solid var(--line-3);
}
.tl-item--accent::before { border-color: var(--accent); background: var(--accent-bg); }
.tl-item--warn::before { border-color: var(--warn-text); }
.tl-item--info::before { border-color: var(--info-text); }
.tl-head { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-size: 13px; }
.tl-time { font: 12px var(--mono); color: var(--muted-2); }
.tl-body { margin-top: 6px; font-size: 14px; color: #D3D9E3; line-height: 1.55; overflow-wrap: anywhere; }
.tl-box { margin-top: 8px; padding: 10px 12px; border-radius: 8px; background: var(--surface-3); border: 1px solid var(--line); }

/* ---------- Чипы (люди, теги) ---------- */
.chip {
    display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px;
    background: var(--surface-3); border: 1px solid var(--line-2); color: var(--text-2); font-size: 12.5px;
}
.chip--accent { background: var(--accent-bg); border-color: #1F4D47; color: var(--accent-text); }
.avatar { width: 28px; height: 28px; border-radius: 50%; flex: none; object-fit: cover; display: inline-grid; place-items: center; background: var(--info-bg); color: var(--info-text); font-size: 11px; font-weight: 600; }

/* ---------- Панель фильтров ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar .form-select, .toolbar .form-control { width: auto; min-width: 200px; height: 38px; font-size: 13.5px; }
.toolbar .grow { flex: 1 1 240px; }
.search-input { position: relative; }
.search-input i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted-2); font-size: 13px; pointer-events: none; }
.search-input .form-control { padding-left: 34px; }

/* ---------- Поля форм ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label, .field__label { font-size: 12.5px; color: var(--text-2); margin: 0; }
.field__hint { font-size: 12px; color: var(--muted); }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; padding-top: 4px; }
.dropzone {
    display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 64px; padding: 10px;
    border: 1px dashed var(--line-3); border-radius: 8px; color: var(--muted); font-size: 13px; text-align: center;
}

/* ---------- Пустое состояние ---------- */
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty i { font-size: 26px; color: var(--line-3); display: block; margin-bottom: 10px; }

/* ---------- Список-строки (задачи, события) ---------- */
.list { display: flex; flex-direction: column; }
.list-row {
    display: flex; gap: 12px; align-items: flex-start; padding: 12px 18px; border-bottom: 1px solid #161C26;
    color: var(--text); text-decoration: none; transition: background .12s;
}
.list-row:last-child { border-bottom: 0; }
a.list-row:hover, .list-row.is-link:hover { background: var(--surface-2); color: var(--text); }
.list-row__bar { width: 3px; align-self: stretch; border-radius: 2px; background: var(--line-3); flex: none; }
.list-row__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.list-row__title { font-size: 14px; font-weight: 500; }
.list-row__meta { font-size: 12.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.list-row__side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: none; }

/* ---------- Шаги (этапы ремонта) ---------- */
.steps { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 8px; }
.steps__bar { height: 4px; border-radius: 2px; background: var(--surface-3); position: relative; overflow: hidden; margin-bottom: 12px; }
.steps__fill { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 2px; transform-origin: left; animation: tr-fill .7s var(--ease) .15s both; }
.step { font-size: 12px; color: var(--muted-2); }
.step b { display: block; font-weight: 500; }
.step.is-done b { color: var(--accent-text); }
.step.is-current b { color: var(--text); font-weight: 600; }
@keyframes tr-fill { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@media (max-width: 767.98px) { .steps { grid-auto-flow: row; } }

/* ---------- Мелочи ---------- */
.mono { font-family: var(--mono) !important; }
.muted { color: var(--muted) !important; }
.inv { font: 500 13px var(--mono); color: var(--accent-text); }
.warn-days { font: 12px var(--mono); color: var(--warn-text); }
.divider { height: 1px; background: var(--line); margin: 14px 0; }
.btn-sm { font-size: 12.5px; }
.icon-btn {
    width: 32px; height: 32px; display: inline-grid; place-items: center; padding: 0;
    border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: transparent; color: var(--text-2);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-bg); color: var(--danger-text); border-color: #4A2323; }
.photo-thumb { width: 88px; height: 66px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line-2); cursor: zoom-in; transition: transform .2s var(--ease), border-color .2s; }
.photo-thumb:hover { transform: scale(1.04); border-color: var(--accent); }

/* Мобильные карточки вместо таблицы */
.m-cards { display: flex; flex-direction: column; gap: 10px; }
.m-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; cursor: pointer; }
.m-card__top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.m-card__row { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.m-card__row span:first-child { color: var(--muted); }

/* Заголовки компонентов не должны раздуваться общими правилами h1/h2 */
.app-content h2.panel__title { font-size: 15px; }
.app-content h1.page-title { font-size: 24px; }
a.inv { text-decoration: none; }
a.inv:hover { text-decoration: underline; }

/* ---------- Онлайн в боковом меню ---------- */
.sb-online { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 8px; }
.sb-online summary {
    list-style: none; display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-sm);
    color: var(--text-2); font-size: 13px; cursor: pointer; user-select: none;
}
.sb-online summary::-webkit-details-marker { display: none; }
.sb-online summary:hover { background: var(--surface-2); color: var(--text); }
.sb-online summary > span:nth-child(2) { flex: 1; }
.sb-online-chev { font-size: 10px; color: var(--muted-2); transition: transform .2s; }
.sb-online[open] .sb-online-chev { transform: rotate(180deg); }
.sb-online-list { max-height: 240px; overflow-y: auto; padding: 4px 4px 0; animation: tr-pop .15s var(--ease); }
.sb-online-group { font-size: 10.5px; color: var(--muted-2); text-transform: uppercase; letter-spacing: .08em; padding: 8px 6px 4px; }
.sb-online-user { display: flex; align-items: center; gap: 8px; padding: 4px 6px; font-size: 12.5px; color: var(--text-2); }
.sb-online-more { font-size: 12px; color: var(--muted); padding: 4px 6px; }

/* ---------- Вход / регистрация ---------- */
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-box { width: 100%; max-width: 400px; }
.auth-box--wide { max-width: 640px; }
.auth-brand { justify-content: center; margin-bottom: 18px; }
.grid-2 > .panel + .panel, .cams > .panel + .panel { margin-top: 0; }
.app-content a:not(.btn):not(.list-row):not(.kpi):not(.home-card):not(.sb-link) { text-decoration: none; }
.app-content a:not(.btn):not(.list-row):not(.kpi):not(.home-card):not(.sb-link):hover { text-decoration: underline; }

/* ---------- Совместимость: классы старой разметки, которую используют скрипты ---------- */
.text-task { color: var(--text) !important; }
.bg-card { background: var(--surface-3) !important; border-color: var(--line) !important; }
.bg-input { background: var(--input) !important; }
.cursor-pointer { cursor: pointer; }
.badge.bg-purple, .bg-purple { background: #231C33 !important; color: #C4B5FD !important; }
.badge.bg-outline-secondary { background: transparent !important; color: var(--text-2) !important; border: 1px solid var(--line-3); }
.user-badge { font-weight: 500; padding: 5px 9px; border-radius: 999px; transition: background .15s, transform .1s; }
.user-badge:hover { transform: translateY(-1px); }
.attachment-thumbnail img { border: 1px solid var(--line-2); transition: transform .2s var(--ease), border-color .2s; }
.attachment-thumbnail img:hover { transform: scale(1.04); border-color: var(--accent); }
.card-header .card-title, .card-header h5, .card-header h6 { font-size: 15px !important; font-weight: 600; }
.card-body h6 { font-size: 12px; font-weight: 400; color: var(--muted) !important; letter-spacing: .02em; }
.back-link { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.back-link:hover { color: var(--text); }
/* Таймлайн старой разметки (div.timeline > .timeline-item) */
div.timeline { position: relative; }
.timeline-item { position: relative; padding-left: 26px; }
.timeline-marker { position: absolute; left: 0; top: 6px; width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--line-3); background: var(--surface) !important; }
.timeline-marker.bg-primary { border-color: var(--accent); background: var(--accent-bg) !important; }
.timeline-connector { position: absolute; left: 5px; top: 20px; bottom: -22px; width: 1px; background: var(--line-2); }
.timeline-content { background: var(--surface-3); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.audio-player-container { background: var(--surface-2) !important; border: 1px solid var(--line-2) !important; border-radius: 8px; padding: 10px 12px; }
.audio-player-container.playing { border-color: var(--accent) !important; }
.audio-player-container audio { height: 34px; filter: invert(.9) hue-rotate(180deg); }
.file-size { font: 12px var(--mono); color: var(--muted); }
#notification-container .toast { background: var(--surface) !important; border: 1px solid var(--line-2) !important; }
