/* ════════════════════════════════════════════════════════════════
   Дашборды цехов — оформление в стиле новой админки (20.10.2026).
   Подключается ПОСЛЕ /dash.css и действует только на <body class="dui">,
   так что главная, цеха и прочие страницы на dash.css не меняются.
   Разметку и скрипты дашбордов не трогаем — только внешний вид.
   Откат: убрать из страницы <link …dash-ui.css>, <script …dash-ui.js>
   и class="dui" у body.
   ════════════════════════════════════════════════════════════════ */

body.dui {
    --soft: 0 1px 2px rgba(26,29,36,.04), 0 10px 30px -14px rgba(26,29,36,.22);
    --soft-hi: 0 2px 4px rgba(26,29,36,.05), 0 22px 44px -18px rgba(26,29,36,.32);
    --ease: cubic-bezier(.16,1,.3,1);
    padding: 0 0 60px;
    background: radial-gradient(1200px 600px at 100% -10%, var(--indigo-soft), transparent 60%), var(--holst);
    background-attachment: fixed;
}
:root[data-theme="dark"] body.dui {
    --soft: 0 1px 2px rgba(0,0,0,.35), 0 12px 30px -16px rgba(0,0,0,.8);
    --soft-hi: 0 2px 4px rgba(0,0,0,.4), 0 24px 48px -18px rgba(0,0,0,.9);
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) body.dui {
        --soft: 0 1px 2px rgba(0,0,0,.35), 0 12px 30px -16px rgba(0,0,0,.8);
        --soft-hi: 0 2px 4px rgba(0,0,0,.4), 0 24px 48px -18px rgba(0,0,0,.9);
    }
}
.dui .container { max-width: 1480px; padding: 0 30px; }

/* ---------- шапка: светлая «стеклянная» вместо тёмного верстака ---------- */
.dui header {
    position: sticky; top: 0; z-index: 20;
    margin: 0 -30px 18px; padding: 18px 30px;
    background: color-mix(in srgb, var(--holst) 78%, transparent);
    backdrop-filter: saturate(1.4) blur(16px); -webkit-backdrop-filter: saturate(1.4) blur(16px);
    color: var(--ink); gap: 18px;
}
.dui header::before { display: none; }
.dui header h1 {
    margin: 0; color: var(--ink); font-family: var(--display); font-size: 22px; font-weight: 700; letter-spacing: -.02em;
    display: block;
}
.dui header h1 .sub-h {
    display: block; margin-top: 4px; font-family: var(--body); font-size: 13px; font-weight: 400;
    letter-spacing: 0; text-transform: none; color: var(--ink-3);
}
.dui .head-title { gap: 14px; }
.dui .head-title .mark {
    width: 46px; height: 46px; border-radius: 14px; font-size: 22px;
    background: var(--paper); border: 1px solid var(--hairline-soft); box-shadow: var(--soft);
}
.dui .header-actions { gap: 8px; }
.dui #lastUpdate { font-family: var(--body); font-size: 12.5px; color: var(--ink-3); }
.dui .btn-back, .dui .btn-refresh, .dui .theme-btn {
    display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px; border-radius: 12px;
    border: 1px solid var(--hairline); background: var(--paper); color: var(--ink-2);
    font: inherit; font-size: 13.5px; font-weight: 600; text-decoration: none !important; cursor: pointer;
    box-shadow: var(--soft); transition: color .2s, border-color .2s, transform .25s var(--ease), box-shadow .25s var(--ease);
}
.dui .theme-btn { width: 40px; padding: 0; justify-content: center; font-size: 15px; }
.dui .btn-back:hover, .dui .btn-refresh:hover, .dui .theme-btn:hover { color: var(--indigo); border-color: var(--indigo); transform: translateY(-1px); box-shadow: var(--soft-hi); }
.dui .btn-refresh { background: var(--indigo); border-color: var(--indigo); color: #fff; }
.dui .btn-refresh:hover { color: #fff; filter: brightness(1.08); }
.dui .btn-refresh.dui-spin { pointer-events: none; opacity: .8; }

/* ---------- заголовки разделов ---------- */
.dui .section-title {
    margin: 30px 2px 14px; font-family: var(--display); font-size: 18px; font-weight: 700;
    letter-spacing: -.015em; text-transform: none; color: var(--ink);
}
.dui .section-title:first-of-type { margin-top: 6px; }

/* ---------- плитки: отдельные мягкие карточки ---------- */
.dui .stats-grid {
    gap: 14px; background: none; border: 0; border-radius: 0; overflow: visible; margin-bottom: 20px;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}
.dui .stat-card {
    position: relative; overflow: hidden; align-items: flex-start; flex-direction: column; gap: 14px;
    padding: 18px 18px 16px; border-radius: 16px; background: var(--paper);
    border: 1px solid var(--hairline-soft); box-shadow: var(--soft);
    transition: transform .35s var(--ease), box-shadow .35s var(--ease), border-color .3s;
}
.dui .stat-card::before { display: none; }
.dui .stat-card::after {
    content: ""; position: absolute; right: -40px; bottom: -60px; width: 170px; height: 170px; border-radius: 50%;
    background: radial-gradient(circle, var(--card-soft, var(--indigo-soft)), transparent 70%); pointer-events: none;
    opacity: 1; transform: none; top: auto; font-size: 0;
}
.dui .stat-card:hover { transform: translateY(-3px); box-shadow: var(--soft-hi); border-color: var(--hairline); background: var(--paper); }
.dui .stat-icon {
    width: 40px; height: 40px; border-radius: 12px; font-size: 19px;
    background: var(--card-soft, var(--indigo-soft)); color: var(--card-accent, var(--indigo));
}
.dui .stat-info { position: relative; z-index: 1; display: flex; flex-direction: column-reverse; gap: 8px; }
.dui .stat-value {
    font-family: var(--display); font-size: 30px; font-weight: 700; letter-spacing: -.03em; line-height: 1;
    color: var(--card-tone, var(--ink)); font-variant-numeric: tabular-nums;
}
.dui .stat-label { font-family: var(--body); font-size: 13px; font-weight: 550; letter-spacing: 0; text-transform: none; color: var(--ink-2); line-height: 1.3; }

/* ---------- карточки ---------- */
.dui .card {
    background: var(--paper); border: 1px solid var(--hairline-soft); border-radius: 20px;
    box-shadow: var(--soft); padding: 22px 24px; margin-bottom: 18px;
    transition: box-shadow .35s var(--ease), border-color .3s;
}
.dui .card:hover { box-shadow: var(--soft-hi); }
.dui .two-col > .card, .dui .three-col > .card { margin-bottom: 0; }
.dui .card h2 {
    margin: 0 0 16px; font-family: var(--display); font-size: 16px; font-weight: 700; letter-spacing: -.01em;
    color: var(--ink); flex-wrap: wrap;
}
.dui .card h2 .h2-note { font-family: var(--body); font-size: 12.5px; font-weight: 400; color: var(--ink-3); letter-spacing: 0; text-transform: none; }
.dui .two-col, .dui .three-col { gap: 18px; margin-bottom: 18px; }
.dui .empty-text { padding: 28px 10px; color: var(--ink-3); }

/* ---------- списки ---------- */
.dui .recent-order {
    margin: 0 -10px; padding: 11px 10px; border-radius: 12px; border-bottom: 1px solid var(--hairline-soft);
    transition: background .18s;
}
.dui .recent-order:hover { background: color-mix(in srgb, var(--indigo-soft) 60%, transparent); }
.dui .recent-order .order-number {
    min-width: 0; padding: 4px 9px; border-radius: 9px; background: var(--holst);
    font-size: 12.5px; font-weight: 600; color: var(--ink); white-space: nowrap;
}
.dui .recent-order .order-name { color: var(--ink); font-weight: 500; }
.dui .worker-item, .dui .popular-item { margin: 0 -8px; padding: 10px 8px; border-radius: 11px; transition: background .18s; }
.dui .worker-item:hover, .dui .popular-item:hover { background: var(--hairline-soft); }
.dui .worker-rank {
    width: 26px; height: 26px; display: grid; place-items: center; border-radius: 8px; background: var(--holst); color: var(--ink-2);
}
.dui .worker-item:nth-child(1) .worker-rank { background: var(--latun-soft); color: var(--latun); }
.dui .worker-bar { height: 8px; border-radius: 99px; background: var(--hairline-soft); }
.dui .worker-bar-fill { border-radius: 99px; background: linear-gradient(90deg, var(--indigo), var(--indigo-2)); }
.dui .popular-count { border-radius: 99px; }
.dui .badge, .dui .date-pill { max-width: none; }
.dui .chart-legend { margin-bottom: 10px; }
.dui .chart-legend i { border-radius: 3px; }
.dui .chart-lead .big { font-family: var(--display); letter-spacing: -.02em; }

/* общий дашборд: панели отделов */
.dui .dept-grid { gap: 14px; }
.dui .dept-panel { border-radius: 18px; border: 1px solid var(--hairline-soft); box-shadow: var(--soft); transition: transform .35s var(--ease), box-shadow .35s var(--ease); }
.dui .dept-panel:hover { transform: translateY(-3px); box-shadow: var(--soft-hi); }
.dui .dept-head .ico { border-radius: 12px; }
.dui .dept-metric .m-val { font-family: var(--display); letter-spacing: -.02em; }

/* ---------- плавное появление ---------- */
@media (prefers-reduced-motion: no-preference) {
    @keyframes dui-rise { from { opacity: 0; transform: translateY(14px) scale(.99); } to { opacity: 1; transform: none; } }
    .dui .stat-card, .dui .card, .dui .dept-panel { animation: dui-rise .7s var(--ease) both; }
    .dui .stats-grid .stat-card:nth-child(2) { animation-delay: .05s; }
    .dui .stats-grid .stat-card:nth-child(3) { animation-delay: .1s; }
    .dui .stats-grid .stat-card:nth-child(4) { animation-delay: .15s; }
    .dui .stats-grid .stat-card:nth-child(5) { animation-delay: .2s; }
    .dui .stats-grid .stat-card:nth-child(n+6) { animation-delay: .25s; }
    .dui .card { animation-delay: .18s; }
    .dui .recent-order { animation: dash-rise .45s ease both; }
    /* motion.css проявляет .container > * — здесь это уже делают карточки */
    .dui .container > * { animation: none; }
}

/* ---------- узкие экраны ---------- */
@media (max-width: 760px) {
    .dui .container { padding: 0 14px; }
    .dui header { position: static; margin: 0 -14px 12px; padding: 16px 14px; }
    .dui header h1 { font-size: 19px; }
    .dui .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .dui .stat-card { padding: 14px; }
    .dui .stat-value { font-size: 25px; }
    .dui .card { padding: 16px; border-radius: 16px; }
}
@media (max-width: 420px) {
    .dui .stats-grid { grid-template-columns: 1fr; }
}

/* ════════════════════════════════════════════════════════════════
   Дашборды v2 (20.10.2026) — /dash-pro.js: боковое меню и «Картина цеха»
   ════════════════════════════════════════════════════════════════ */

/* боковое меню (на широком экране) */
.dp-side { display: none; }
@media (min-width: 1100px) {
    body.dp-has-side .container { margin-left: 250px; max-width: calc(100vw - 270px); }
    .dp-side {
        position: fixed; left: 0; top: 0; bottom: 0; width: 236px; z-index: 25; display: flex; flex-direction: column; gap: 6px;
        padding: 20px 14px; border-right: 1px solid var(--hairline-soft);
        background: color-mix(in srgb, var(--paper) 72%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
        animation: dp-slide .6s var(--ease) both;
    }
}
@keyframes dp-slide { from { opacity: 0; transform: translateX(-12px); } to { opacity: 1; transform: none; } }
.dp-side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 16px; font-family: var(--display); font-weight: 700; font-size: 14px; line-height: 1.2; color: var(--ink); }
.dp-side-mark { width: 38px; height: 38px; flex-shrink: 0; display: grid; place-items: center; font-size: 19px; border-radius: 11px; background: var(--paper); border: 1px solid var(--hairline-soft); box-shadow: var(--soft); }
.dp-side-nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.dp-side-nav a, .dp-side-foot a {
    display: block; padding: 9px 12px; border-radius: 10px; color: var(--ink-2); font-size: 13.5px; font-weight: 550;
    text-decoration: none !important; transition: background .2s, color .2s, box-shadow .25s;
}
.dp-side-nav a:hover, .dp-side-foot a:hover { background: var(--hairline-soft); color: var(--ink); }
.dp-side-nav a.on { background: var(--indigo-soft); color: var(--indigo); box-shadow: inset 3px 0 0 var(--indigo); }
.dp-side-foot { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--hairline-soft); display: flex; flex-direction: column; gap: 2px; }

/* «Картина цеха» */
.dpro { margin: 0 0 22px; }
.dp-head { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; margin-bottom: 14px; border-radius: 16px; background: var(--paper); border: 1px solid var(--hairline-soft); box-shadow: var(--soft); }
.dp-head p { margin: 0; font-size: 15px; line-height: 1.55; color: var(--ink-2); }
.dp-head b { color: var(--ink); }
.dpro .ins-dot { width: 9px; height: 9px; margin-top: 8px; border-radius: 50%; background: var(--zelen); flex-shrink: 0; animation: dp-pulse 2.4s ease-out infinite; }
@keyframes dp-pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--zelen) 55%, transparent); } 70%, 100% { box-shadow: 0 0 0 9px transparent; } }
.dp-bad { color: var(--nit) !important; } .dp-warn { color: var(--latun) !important; } .dp-good { color: var(--zelen) !important; }
.dp-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.dp-wide { grid-column: span 2; }
.dp-card {
    background: var(--paper); border: 1px solid var(--hairline-soft); border-radius: 20px; box-shadow: var(--soft);
    padding: 18px 20px; min-width: 0; scroll-margin-top: 100px;
    transition: box-shadow .35s var(--ease), transform .35s var(--ease);
}
.dp-card:hover { box-shadow: var(--soft-hi); }
.dp-card h3 { margin: 0; font-family: var(--display); font-size: 15px; font-weight: 700; letter-spacing: -.01em; color: var(--ink); }
.dp-sub { margin: 4px 0 14px; font-size: 12.5px; color: var(--ink-3); }
.dp-empty { margin: 8px 0; color: var(--ink-3); font-size: 13.5px; }
.dp-more { margin: 8px 0 0; font-size: 12.5px; color: var(--ink-3); }

/* очередь по срокам: полоса-шкала + легенда */
.dp-stack { display: flex; height: 16px; border-radius: 99px; overflow: hidden; background: var(--hairline-soft); gap: 2px; }
.dp-stack i { display: block; height: 100%; width: var(--w); transform-origin: left; animation: dp-grow .9s var(--ease) both; }
@keyframes dp-grow { from { transform: scaleX(0); } to { transform: none; } }
.dp-s-late { background: var(--nit); } .dp-s-d3 { background: #E07B39; } .dp-s-d7 { background: var(--latun); }
.dp-s-d21 { background: var(--indigo); } .dp-s-later { background: var(--zelen); } .dp-s-none { background: var(--ink-3); }
.dp-legend { list-style: none; margin: 14px 0 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
.dp-legend li { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.dp-legend li.zero { opacity: .5; }
.dp-legend li i { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.dp-legend li b { margin-left: auto; font-family: var(--mono); font-weight: 600; color: var(--ink); }

/* столбики по неделям */
.dp-chart { width: 100%; min-height: 190px; }
.dp-bars { display: block; max-width: 100%; height: auto; overflow: visible; }
.dp-bars .dp-gl { stroke: var(--hairline-soft); stroke-width: 1; }
.dp-bars .dp-avg { stroke: var(--ink-3); stroke-width: 1.2; stroke-dasharray: 5 4; }
.dp-bars .dp-ax { fill: var(--ink-3); font-size: 11px; font-family: var(--body); }
.dp-bars .dp-val { fill: var(--ink-2); font-size: 11.5px; font-weight: 600; font-family: var(--mono); }
.dp-bar rect { fill: var(--indigo); opacity: .85; transform-box: fill-box; transform-origin: bottom; animation: dp-rise .8s var(--ease) both; animation-delay: calc(var(--i) * 50ms); transition: opacity .2s; }
.dp-bar:hover rect { opacity: 1; }
.dp-bar.hl rect { fill: var(--indigo-2); opacity: .55; }
@keyframes dp-rise { from { transform: scaleY(0); } to { transform: none; } }

/* время в цехе */
.dp-big { display: flex; align-items: baseline; gap: 10px; margin: 6px 0 14px; }
.dp-big b { font-family: var(--display); font-size: 44px; font-weight: 700; letter-spacing: -.03em; line-height: 1; color: var(--ink); }
.dp-big span { font-size: 13px; color: var(--ink-3); }
.dp-range { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--ink-3); }
.dp-range b { color: var(--ink); font-family: var(--mono); }

/* горизонтальные полосы (мастера/менеджеры) */
.dp-hbars { display: flex; flex-direction: column; gap: 9px; }
.dp-hb { display: grid; grid-template-columns: minmax(80px, 34%) 1fr auto; align-items: center; gap: 10px; font-size: 13px; }
.dp-hb-n { color: var(--ink); font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dp-hb-t { height: 8px; border-radius: 99px; background: var(--hairline-soft); overflow: hidden; }
.dp-hb-t i { display: block; height: 100%; width: var(--w); border-radius: inherit; background: linear-gradient(90deg, var(--indigo), var(--indigo-2)); transform-origin: left; animation: dp-grow .9s var(--ease) both; animation-delay: calc(var(--i) * 60ms); }
.dp-hb b { font-family: var(--mono); font-weight: 600; color: var(--ink); white-space: nowrap; }
.dp-hb b small { color: var(--ink-3); font-weight: 400; }

/* списки (застряло / придёт следом) */
.dp-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.dp-list li { display: flex; align-items: center; gap: 10px; padding: 8px 8px; margin: 0 -8px; border-radius: 11px; transition: background .15s; }
.dp-list li:hover { background: var(--hairline-soft); }
.dp-num { min-width: 52px; padding: 3px 7px; border-radius: 8px; background: var(--holst); font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--ink); text-align: center; white-space: nowrap; }
.dp-li-m { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.dp-li-m b { font-size: 13px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dp-li-m small { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dp-li-r { font-family: var(--mono); font-size: 12.5px; font-weight: 600; white-space: nowrap; color: var(--ink-2); }

@media (prefers-reduced-motion: reduce) {
    .dp-stack i, .dp-bar rect, .dp-hb-t i, .dp-side { animation: none !important; }
}
@media (max-width: 1250px) { .dp-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) {
    .dp-grid { grid-template-columns: 1fr; }
    .dp-wide { grid-column: auto; }
    .dp-head p { font-size: 14px; }
}
/* колонки сетки не распираются длинными строками (имена клиентов) — обрезаются многоточием */
.dui .two-col { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.dui .three-col { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dui .card { min-width: 0; }
@media (max-width: 900px) { .dui .two-col, .dui .three-col { grid-template-columns: minmax(0, 1fr); } }
