/* Информация о складе: цвет названия обозначает условия возврата. */
.dk-stock-link {
    --stock-color: var(--text-muted);
    display: inline-flex; align-items: center; gap: 6px;
    max-width: 100%; padding: 4px 0;
    border: 0; background: none; color: var(--stock-color);
    font: inherit; font-weight: 800; line-height: 1.35; text-align: left;
    cursor: pointer; border-radius: 5px;
}
.dk-stock-link--allowed { --stock-color: var(--green-ink); }
.dk-stock-link--restricted { --stock-color: var(--accent-ink); }
.dk-stock-link--unavailable { --stock-color: var(--danger); }
.dk-stock-link__label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.dk-stock-link__badge {
    position: relative; display: inline-grid; place-items: center; flex: 0 0 25px;
    width: 25px; height: 25px; border-radius: 50%;
    transition: transform .25s, box-shadow .25s;
}
.dk-stock-link__ring {
    position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none;
    stroke-width: 1.75; transform: rotate(-90deg);
}
.dk-stock-link__ring-track { stroke: var(--border-light); }
.dk-stock-link__ring-value { stroke: var(--green-ink); stroke-linecap: butt; }
.dk-stock-link__info {
    position: relative;
    display: inline-flex; align-items: center; justify-content: center; flex: 0 0 17px;
    width: 17px; height: 17px; border: 1px solid currentColor; border-radius: 50%;
    font: 800 11px/1 var(--font); opacity: .8;
    transition: background .2s, color .2s;
}
.dk-stock-link:hover .dk-stock-link__label { text-decoration: underline; text-underline-offset: 4px; }
.dk-stock-link:hover .dk-stock-link__info {
    background: var(--stock-color); border-color: var(--stock-color); color: var(--bg);
    opacity: 1;
}
.dk-stock-link:hover .dk-stock-link__badge {
    transform: translateY(-1px); box-shadow: 0 0 0 3px color-mix(in srgb, var(--stock-color) 12%, transparent);
}
.dk-stock-link:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 4px; }
.dk-table .dk-stock-amount { color: var(--text); font-weight: 800; white-space: nowrap; }

/* Native dialog сохраняет фокус внутри окна и делает фон недоступным. */
html.dk-stock-open { overflow: hidden; scrollbar-gutter: stable; }
.dk-stock-modal {
    --stock-good: var(--green-ink);
    width: min(740px, calc(100% - 36px)); max-width: none;
    max-height: min(90dvh, 960px); margin: auto; padding: 0;
    border: 1px solid var(--border-light); border-radius: 24px;
    background: var(--bg-surface); color: var(--text);
    box-shadow: 0 36px 140px rgba(0,0,0,.5); overflow: auto;
    overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--border-light) transparent;
}
.dk-stock-modal[open] { animation: dk-stock-in .32s cubic-bezier(.2,.85,.25,1) both; }
.dk-stock-modal::backdrop { background: rgba(4,8,13,.72); backdrop-filter: blur(8px); animation: dk-stock-backdrop .25s both; }
.dk-stock-modal.is-closing { animation: dk-stock-out .16s ease-in both; }
.dk-stock-modal.is-closing::backdrop { animation: dk-stock-backdrop .16s reverse both; }
.dk-stock-modal__head {
    position: sticky; top: 0; z-index: 2; overflow: hidden; padding: 30px 34px 26px;
    border-bottom: 1px solid var(--border);
    background: radial-gradient(ellipse at 100% 0%, var(--accent-subtle), transparent 65%), var(--bg-elevated);
}
.dk-stock-modal__eyebrow { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 10px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.dk-stock-modal__eyebrow > span { width: 6px; height: 6px; border-radius: 50%; background: var(--accent-ink); box-shadow: 0 0 0 4px var(--accent-subtle); }
.dk-stock-modal__head h2 { position: relative; z-index: 1; margin: 14px 38px 7px 0; font-size: clamp(23px, 4vw, 31px); letter-spacing: -.025em; overflow-wrap: anywhere; }
.dk-stock-modal__warehouse { position: absolute; right: 45px; bottom: -14px; width: 132px; height: 132px; color: var(--accent-ink); opacity: .1; transform: rotate(-8deg); pointer-events: none; }
.dk-stock-modal__warehouse svg { width: 100%; height: 100%; }
.dk-stock-modal__close { position: absolute; z-index: 2; right: 20px; top: 20px; display: grid; place-items: center; width: 36px; height: 36px; border: 1px solid var(--border); border-radius: 50%; background: var(--bg-surface); color: var(--text-muted); transition: color .2s, background .2s, transform .2s; }
.dk-stock-modal__close svg { width: 19px; height: 19px; }
.dk-stock-modal__close:hover { color: var(--text); background: var(--bg-hover); transform: rotate(90deg); }
.dk-stock-modal button:focus-visible, .dk-stock-modal summary:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 3px; }
.dk-stock-modal__body { display: grid; gap: 19px; padding: 25px 34px 23px; }
.dk-stock-return {
    --return-color: var(--text-muted); display: flex; align-items: flex-start; gap: 15px;
    border: 1px solid color-mix(in srgb, var(--return-color) 26%, transparent); border-radius: 14px;
    background: color-mix(in srgb, var(--return-color) 7%, var(--bg-surface)); padding: 19px 20px;
}
.dk-stock-return[data-state="allowed"] { --return-color: var(--stock-good); }
.dk-stock-return[data-state="restricted"] { --return-color: var(--accent-ink); }
.dk-stock-return[data-state="unavailable"] { --return-color: var(--danger); }
.dk-stock-return__icon { display: grid; place-items: center; flex: 0 0 36px; width: 36px; height: 40px; color: var(--return-color); }
.dk-stock-return__icon svg { width: 32px; height: 32px; }
.dk-stock-kicker { display: block; color: var(--text-muted); font-size: 10px; line-height: 1.4; letter-spacing: .09em; text-transform: uppercase; font-weight: 800; }
.dk-stock-return h3 { color: var(--return-color); margin: 5px 0 7px; font-size: 18px; line-height: 1.25; }
.dk-stock-return p { color: var(--text-muted); font-size: 12px; line-height: 1.6; }
.dk-stock-facts { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.dk-stock-fact { padding: 14px 15px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-elevated); }
.dk-stock-fact > span { display: block; color: var(--text-muted); font-size: 10px; line-height: 1.4; }
.dk-stock-fact > strong { display: block; margin-top: 7px; font-size: 18px; font-weight: 900; line-height: 1.25; }
.dk-stock-merged { color: var(--text-muted); font-size: 11px; margin-top: -9px; }
.dk-stock-update:has(> [hidden]):not(:has(> :not([hidden]))) { display: none; }
.dk-stock-update { font-size: 11px; color: var(--text-muted); }
.dk-stock-update__busy { display: flex; align-items: center; gap: 9px; }
.dk-stock-orbit { width: 13px; height: 13px; border: 2px solid var(--border-light); border-top-color: var(--accent-ink); border-radius: 50%; animation: dk-stock-spin .8s linear infinite; }
.dk-stock-update__error { display: block; padding: 10px 13px; border: 1px solid var(--border-light); border-radius: 9px; }
.dk-stock-update__error button { color: var(--accent-ink); background: none; border: 0; padding: 3px; font: inherit; font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }
.dk-stock-modal__columns { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.dk-stock-panel { min-width: 0; padding: 19px; border: 1px solid var(--border); border-radius: 14px; background: var(--bg-elevated); }
.dk-stock-panel h3 { font-size: 13px; font-weight: 800; line-height: 1.4; }
.dk-stock-reliability__main { display: flex; align-items: center; gap: 19px; margin: 20px 0 17px; }
.dk-stock-gauge {
    --stock-success: 0; position: relative; display: flex; flex: 0 0 95px; flex-direction: column;
    align-items: center; justify-content: center; width: 95px; height: 95px; border-radius: 50%;
    background: conic-gradient(var(--stock-good) calc(var(--stock-success) * 1%), var(--border) 0);
}
.dk-stock-gauge::before { content: ""; position: absolute; inset: 5px; border-radius: inherit; background: var(--bg-elevated); }
.dk-stock-gauge span { position: relative; font-size: 24px; font-weight: 900; letter-spacing: -.035em; line-height: 1.25; }
.dk-stock-gauge small { position: relative; color: var(--text-muted); font-size: 9px; }
.dk-stock-reliability__legend { display: grid; gap: 13px; width: 100%; min-width: 0; }
.dk-stock-reliability__legend > div { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 2px 10px; font-size: 11px; }
.dk-stock-reliability__legend > div > span { display: flex; align-items: center; gap: 6px; color: var(--text-muted); }
.dk-stock-reliability__legend strong { font-size: 14px; font-weight: 900; }
.dk-stock-dot { width: 5px; height: 5px; border-radius: 50%; flex: 0 0 5px; }
.dk-stock-dot--ok { background: var(--stock-good); }
.dk-stock-dot--fail { background: var(--danger); }
.dk-stock-note { color: var(--text-muted); font-size: 10px; line-height: 1.65; }
.dk-stock-stamp { margin-top: 9px; color: var(--text-muted); font-size: 9px; }
.dk-stock-dispatch__next { margin: 16px 0 14px; padding-left: 11px; border-left: 2px solid var(--accent-line); }
.dk-stock-dispatch__next strong { display: block; margin-top: 5px; font-size: 15px; line-height: 1.5; font-weight: 900; }
.dk-stock-schedule { display: grid; gap: 7px; padding: 12px 0; border-top: 1px solid var(--border); }
.dk-stock-schedule:empty { display: none; }
.dk-stock-schedule > div { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; font-size: 11px; }
.dk-stock-schedule dt { flex-shrink: 0; color: var(--text-muted); }
.dk-stock-schedule dd { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }
.dk-stock-conditions p { margin-top: 11px; color: var(--text-muted); font-size: 12px; line-height: 1.8; white-space: pre-line; overflow-wrap: anywhere; }
.dk-stock-distribution { --histogram-color: var(--stock-good); }
.dk-stock-distribution[data-series="refused"] { --histogram-color: var(--danger); }
.dk-stock-distribution__head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
.dk-stock-distribution__switch { display: inline-flex; gap: 3px; padding: 3px; border: 1px solid var(--border); border-radius: 9px; background: var(--bg-surface); }
.dk-stock-distribution__switch button { border: 0; border-radius: 6px; padding: 6px 10px; background: none; color: var(--text-muted); font: 800 10px/1.4 var(--font); transition: color .2s, background .2s; }
.dk-stock-distribution__switch button[aria-pressed="true"] { background: var(--bg-hover); color: var(--text); box-shadow: var(--shadow-sm); }
.dk-stock-histogram { display: grid; gap: 10px; margin-bottom: 18px; }
.dk-stock-histogram > div { display: grid; grid-template-columns: 104px minmax(0, 1fr) 47px; align-items: center; gap: 13px; }
.dk-stock-histogram dt { color: var(--text-muted); font-size: 11px; line-height: 1.4; }
.dk-stock-histogram dd { display: contents; }
.dk-stock-histogram__track { height: 7px; border-radius: 5px; background: var(--border); overflow: hidden; }
.dk-stock-histogram__bar { display: block; width: calc(var(--bar-value, 0) * 1%); height: 100%; background: var(--histogram-color); border-radius: inherit; transform-origin: left; animation: dk-stock-bar-in .45s cubic-bezier(.16,1,.3,1) both; animation-delay: calc(var(--bar-index, 0) * 24ms); }
.dk-stock-histogram strong { text-align: right; color: var(--text); font-size: 12px; font-weight: 900; font-variant-numeric: tabular-nums; }
.dk-stock-distribution__empty { color: var(--text-muted); font-size: 12px; padding: 12px 0 18px; }
.dk-stock-distribution__partial { margin-top: 7px; }
@keyframes dk-stock-bar-in { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.dk-stock-certificate { border: 1px solid var(--border); border-radius: 11px; padding: 13px 16px; }
.dk-stock-certificate summary { display: flex; align-items: center; justify-content: space-between; gap: 15px; font-size: 11px; font-weight: 800; cursor: pointer; list-style: none; }
.dk-stock-certificate summary::-webkit-details-marker { display: none; }
.dk-stock-certificate summary span { font-size: 18px; color: var(--text-muted); transition: transform .2s; }
.dk-stock-certificate[open] summary span { transform: rotate(45deg); }
.dk-stock-certificate p { margin-top: 10px; font-size: 11px; color: var(--text-muted); white-space: pre-line; overflow-wrap: anywhere; }
.dk-stock-modal__foot { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px 15px; padding-top: 2px; color: var(--text-muted); font-size: 9px; }
.dk-stock-modal__foot > span:empty { display: none; }
.dk-stock-modal.is-loading .dk-stock-dispatch { position: relative; overflow: hidden; }
.dk-stock-modal.is-loading .dk-stock-dispatch::after { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 25%, color-mix(in srgb, var(--text) 4%, transparent) 50%, transparent 75%); transform: translateX(-100%); animation: dk-stock-shimmer 1.4s ease-in-out infinite; pointer-events: none; }
@keyframes dk-stock-in { from { opacity: 0; transform: translateY(22px) scale(.97); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes dk-stock-out { to { opacity: 0; transform: translateY(10px) scale(.98); } }
@keyframes dk-stock-backdrop { from { opacity: 0; } to { opacity: 1; } }
@keyframes dk-stock-spin { to { transform: rotate(360deg); } }
@keyframes dk-stock-shimmer { to { transform: translateX(100%); } }
@media (max-width: 600px) {
    .dk-stock-modal { width: calc(100% - 20px); max-height: 92dvh; border-radius: 20px; }
    .dk-stock-modal__head { padding: 24px 21px 22px; }
    .dk-stock-modal__head h2 { margin-top: 14px; font-size: 24px; }
    .dk-stock-modal__close { right: 13px; top: 13px; width: 34px; height: 34px; }
    .dk-stock-modal__body { padding: 18px; gap: 14px; }
    .dk-stock-return { gap: 10px; padding: 16px 14px; }
    .dk-stock-return h3 { font-size: 17px; }
    .dk-stock-return__icon { flex-basis: 29px; width: 29px; }
    .dk-stock-return__icon svg { width: 27px; }
    .dk-stock-facts { gap: 6px; }
    .dk-stock-fact { padding: 12px 10px; }
    .dk-stock-fact > span { font-size: 9px; }
    .dk-stock-fact > strong { font-size: 15px; }
    .dk-stock-modal__columns { grid-template-columns: 1fr; gap: 12px; }
    .dk-stock-panel { padding: 17px; }
    .dk-stock-distribution__head { align-items: flex-start; gap: 13px; }
    .dk-stock-histogram > div { grid-template-columns: 94px minmax(0, 1fr) 39px; gap: 9px; }
    .dk-stock-histogram dt { font-size: 10px; }
    .dk-stock-histogram strong { font-size: 11px; }
    .dk-stock-reliability__main { gap: 26px; margin: 17px 0; }
    .dk-stock-reliability__legend { max-width: 230px; gap: 18px; }
    .dk-stock-reliability__legend > div { font-size: 12px; }
    .dk-stock-link { gap: 5px; }
    .dk-stock-link__badge { width: 23px; height: 23px; flex-basis: 23px; }
    .dk-stock-link__label { white-space: nowrap; }
    .dk-offers .dk-offer__stock { display: inline-flex; align-items: center; }
    .dk-stock-link__info { width: 15px; height: 15px; flex-basis: 15px; font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) {
    .dk-stock-modal, .dk-stock-modal::backdrop, .dk-stock-modal *, .dk-stock-link * { animation: none !important; transition: none !important; }
}
