/*
 * Lokadarshan CMS: layout, panels, tables, forms, page manager, charts.
 * Depends on ld-base.css tokens.
 */

.ld-cms-body {
    --ld-side-w: 248px;
    --ld-side-w-collapsed: 72px;
    --ld-top-h: 64px;
    background: #f3f5f9;
}

.ld-cms {
    min-height: 100vh;
}

/* ---------------------------------------------------------------- Sidebar */

.ld-side {
    --bs-offcanvas-width: 272px;
    background: #fff;
    border-right: 1px solid var(--ld-line);
}

/* Bootstrap makes .offcanvas-lg transparent on large screens. */
.ld-cms .ld-side {
    background-color: #fff !important;
}

@media (min-width: 992px) {
    .ld-side {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 1035;
        display: flex;
        flex-direction: column;
        width: var(--ld-side-w);
        transition: width 0.18s ease;
    }

    .ld-cms[data-sidebar="collapsed"] .ld-side {
        width: var(--ld-side-w-collapsed);
    }
}

@media (prefers-reduced-motion: reduce) {
    .ld-side,
    .ld-cms__main {
        transition: none !important;
    }
}

.ld-side .offcanvas-header {
    border-bottom: 1px solid var(--ld-line);
}

.ld-side__inner {
    display: flex;
    flex: 1;
    flex-direction: column;
    width: 100%;
    min-height: 0;
}

.ld-side__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: var(--ld-top-h);
    padding: 0 18px;
    border-bottom: 1px solid var(--ld-line);
    color: var(--ld-ink);
    text-decoration: none;
}

.ld-side__brand img {
    width: auto;
    height: 30px;
}

.ld-side__brand span {
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--ld-blue-soft);
    color: var(--ld-blue-ink);
    font-size: 0.75rem;
    font-weight: 700;
}

.ld-side__nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 10px;
}

.ld-side__section {
    margin: 16px 10px 6px;
    color: var(--ld-ink-3);
    font-size: 0.75rem;
    font-weight: 700;
}

.ld-side__list {
    display: grid;
    gap: 2px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.ld-side__link {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 42px;
    padding: 0 12px;
    border-radius: var(--ld-radius-s);
    color: var(--ld-ink-2);
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

.ld-side__link .bi {
    flex: none;
    width: 22px;
    font-size: 1.1rem;
    text-align: center;
}

.ld-side__link:hover {
    background: var(--ld-paper);
    color: var(--ld-ink);
}

.ld-side__link[aria-current="page"] {
    background: var(--ld-blue-soft);
    color: var(--ld-blue-ink);
    box-shadow: inset 3px 0 0 var(--ld-blue);
}

.ld-side__foot {
    display: grid;
    gap: 2px;
    padding: 10px;
    border-top: 1px solid var(--ld-line);
}

.ld-side__collapse {
    width: 100%;
    border: 0;
    background: transparent;
}

@media (max-width: 991.98px) {
    .ld-side__collapse,
    .ld-side .ld-side__brand {
        display: none;
    }
}

@media (min-width: 992px) {
    .ld-cms[data-sidebar="collapsed"] .ld-side__label,
    .ld-cms[data-sidebar="collapsed"] .ld-side__section,
    .ld-cms[data-sidebar="collapsed"] .ld-side__brand span {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    .ld-cms[data-sidebar="collapsed"] .ld-side__brand {
        justify-content: center;
        padding: 0;
    }

    .ld-cms[data-sidebar="collapsed"] .ld-side__brand img {
        width: 36px;
        height: 30px;
        object-fit: cover;
        object-position: left center;
    }

    .ld-cms[data-sidebar="collapsed"] .ld-side__link {
        justify-content: center;
        padding: 0;
    }

    .ld-cms[data-sidebar="collapsed"] .ld-side__collapse .bi {
        transform: rotate(180deg);
    }
}

/* ---------------------------------------------------------------- Main column */

.ld-cms__main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 100vh;
}

@media (min-width: 992px) {
    .ld-cms__main {
        margin-left: var(--ld-side-w);
        transition: margin-left 0.18s ease;
    }

    .ld-cms[data-sidebar="collapsed"] .ld-cms__main {
        margin-left: var(--ld-side-w-collapsed);
    }
}

.ld-top {
    position: sticky;
    top: 0;
    z-index: 1020;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: var(--ld-top-h);
    padding: 0 clamp(12px, 3vw, 28px);
    border-bottom: 1px solid var(--ld-line);
    background: rgba(255, 255, 255, 0.96);
}

.ld-top__menu {
    width: 42px;
    padding: 0;
    font-size: 1.3rem;
}

@media (min-width: 992px) {
    .ld-top__menu {
        display: none;
    }
}

.ld-top__brand {
    display: flex;
    align-items: center;
}

.ld-top__brand img {
    width: auto;
    height: 26px;
}

@media (min-width: 992px) {
    .ld-top__brand {
        display: none;
    }
}

.ld-top__spacer {
    flex: 1;
}

.ld-top__user .dropdown-toggle {
    max-width: 220px;
}

.ld-top__user .dropdown-toggle span {
    overflow: hidden;
    text-overflow: ellipsis;
}

.ld-content {
    flex: 1;
    width: 100%;
    max-width: 1400px;
    padding: clamp(16px, 3vw, 28px) clamp(12px, 3vw, 28px) 48px;
}

/* Page heading */
.ld-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px 20px;
    margin-bottom: 20px;
}

.ld-head__text {
    min-width: 0;
}

.ld-head h1 {
    margin: 0;
    font-size: clamp(1.5rem, 1.3rem + 0.9vw, 2rem);
    font-weight: 800;
}

.ld-head p {
    max-width: 70ch;
    margin: 6px 0 0;
    color: var(--ld-ink-2);
}

.ld-head__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ld-crumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 6px;
    padding: 0;
    color: var(--ld-ink-3);
    font-size: 0.875rem;
    list-style: none;
}

.ld-crumbs li + li::before {
    content: "/";
    margin-right: 6px;
    color: var(--ld-line-strong);
}

.ld-crumbs a {
    color: var(--ld-ink-2);
}

/* ---------------------------------------------------------------- Panels */

.ld-panel {
    min-width: 0;
    border: 1px solid var(--ld-line);
    border-radius: var(--ld-radius-l);
    background: var(--ld-surface);
    box-shadow: var(--ld-shadow-1);
}

.ld-panel + .ld-panel {
    margin-top: 20px;
}

.ld-panel__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    padding: 16px 18px 0;
}

.ld-panel__title {
    margin: 0;
    font-size: 1.1875rem;
    font-weight: 700;
}

.ld-panel__sub {
    margin: 2px 0 0;
    color: var(--ld-ink-3);
    font-size: 0.875rem;
}

.ld-panel__body {
    padding: 16px 18px 18px;
}

.ld-panel__body--flush {
    padding: 12px 0 0;
}

.ld-grid {
    display: grid;
    gap: 20px;
}

@media (min-width: 1100px) {
    .ld-grid--2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .ld-grid--main-side {
        grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    }
}

.ld-grid > .ld-panel + .ld-panel {
    margin-top: 0;
}

/* Notices */
.ld-callout {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    padding: 14px 16px;
    border: 1px solid #c8d7f8;
    border-radius: var(--ld-radius);
    background: var(--ld-blue-soft);
    color: var(--ld-blue-ink);
}

.ld-callout > .bi {
    flex: none;
    margin-top: 2px;
    font-size: 1.1rem;
}

.ld-callout p {
    margin: 0;
}

.ld-callout code {
    color: inherit;
    font-weight: 600;
}

.ld-callout--warning {
    border-color: #f1d79b;
    background: var(--ld-amber-soft);
    color: #6d4200;
}

.ld-callout--danger {
    border-color: #f2c1c1;
    background: var(--ld-red-soft);
    color: #8c1b1b;
}

/* ---------------------------------------------------------------- KPI tiles */

.ld-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.ld-kpi {
    display: grid;
    gap: 4px;
    padding: 16px 18px;
    border: 1px solid var(--ld-line);
    border-radius: var(--ld-radius-l);
    background: var(--ld-surface);
    box-shadow: var(--ld-shadow-1);
}

.ld-kpi__label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--ld-ink-2);
    font-size: 0.9375rem;
    font-weight: 600;
}

.ld-kpi__swatch {
    width: 10px;
    height: 10px;
    border-radius: 3px;
}

.ld-kpi__value {
    color: var(--ld-ink);
    font-family: var(--ld-font-display);
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.ld-kpi__meta {
    color: var(--ld-ink-3);
    font-size: 0.8125rem;
}

.ld-delta {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-weight: 700;
}

.ld-delta--up {
    color: var(--ld-green);
}

.ld-delta--down {
    color: var(--ld-red);
}

.ld-delta--flat {
    color: var(--ld-ink-3);
}

/* ---------------------------------------------------------------- Filter bar */

.ld-filterbar {
    display: grid;
    gap: 12px;
    margin-bottom: 20px;
    padding: 14px 16px;
    border: 1px solid var(--ld-line);
    border-radius: var(--ld-radius-l);
    background: var(--ld-surface);
}

@media (min-width: 768px) {
    .ld-filterbar {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
        align-items: end;
    }
}

.ld-filterbar .form-label {
    font-size: 0.875rem;
}

.ld-filterbar__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ld-filterbar [data-ld-custom-range][hidden] {
    display: none;
}

.ld-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 14px;
    padding: 0;
    list-style: none;
}

.ld-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    padding: 0 12px;
    border: 1px solid var(--ld-line);
    border-radius: 999px;
    background: var(--ld-surface);
    color: var(--ld-ink-2);
    font-size: 0.9375rem;
    font-weight: 600;
    text-decoration: none;
}

.ld-tab:hover {
    border-color: var(--ld-line-strong);
    color: var(--ld-ink);
}

.ld-tab[aria-current="page"] {
    border-color: var(--ld-ink);
    background: var(--ld-ink);
    color: #fff;
}

.ld-tab__count {
    color: var(--ld-ink-3);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.ld-tab[aria-current="page"] .ld-tab__count {
    color: #dfe3ea;
}

/* ---------------------------------------------------------------- Tables */

.ld-table-wrap {
    width: 100%;
    overflow-x: auto;
    container-type: inline-size;
}

.ld-table {
    width: 100%;
    margin: 0;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.9375rem;
}

.ld-table th,
.ld-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--ld-line);
    vertical-align: middle;
}

.ld-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #f7f8fb;
    color: var(--ld-ink-2);
    font-size: 0.8125rem;
    font-weight: 700;
    text-align: left;
    white-space: nowrap;
}

.ld-table thead th a {
    color: inherit;
    text-decoration: none;
}

.ld-table thead th a:hover {
    color: var(--ld-blue);
}

.ld-table thead th a.asc::after {
    content: " ▲";
    font-size: 0.7em;
}

.ld-table thead th a.desc::after {
    content: " ▼";
    font-size: 0.7em;
}

.ld-table tbody tr:hover {
    background: #fafbfd;
}

.ld-table tbody tr:last-child > * {
    border-bottom: 0;
}

.ld-table .ld-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.ld-table .ld-actions {
    text-align: right;
    white-space: nowrap;
}

.ld-table__primary {
    display: grid;
    gap: 2px;
    color: var(--ld-ink);
    font-weight: 700;
}

.ld-table__primary small {
    color: var(--ld-ink-3);
    font-weight: 500;
}

.ld-table__thumb {
    width: 40px;
    height: 58px;
    border: 1px solid var(--ld-line);
    border-radius: 2px;
    background: #fff;
    object-fit: cover;
    object-position: top center;
}

.ld-table__thumb--empty {
    display: grid;
    place-items: center;
    color: var(--ld-ink-3);
}

.ld-pages-meter {
    display: grid;
    gap: 4px;
    min-width: 90px;
}

.ld-pages-meter__bar {
    height: 6px;
    overflow: hidden;
    border-radius: 999px;
    background: #e8ebf1;
}

.ld-pages-meter__bar span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--ld-green);
}

.ld-pages-meter--partial .ld-pages-meter__bar span {
    background: var(--ld-amber);
}

.ld-pages-meter small {
    color: var(--ld-ink-2);
    font-size: 0.8125rem;
    font-variant-numeric: tabular-nums;
}

.ld-row-actions {
    display: inline-flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}

.ld-row-delete {
    --bs-btn-color: var(--ld-red);
    --bs-btn-hover-color: var(--ld-red);
    --bs-btn-hover-bg: var(--ld-red-soft);
    --bs-btn-hover-border-color: rgba(180, 35, 35, 0.35);
    --bs-btn-active-color: var(--ld-red);
    --bs-btn-active-bg: var(--ld-red-soft);
}

/* Stacked table layout in narrow containers */
@container (max-width: 720px) {
    .ld-table--stack thead {
        display: none;
    }

    .ld-table--stack,
    .ld-table--stack tbody,
    .ld-table--stack tr,
    .ld-table--stack td,
    .ld-table--stack th {
        display: block;
        width: 100%;
    }

    .ld-table--stack tr {
        padding: 12px 14px;
        border-bottom: 1px solid var(--ld-line);
    }

    .ld-table--stack tbody tr:last-child {
        border-bottom: 0;
    }

    .ld-table--stack td,
    .ld-table--stack th {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 6px 0;
        border: 0;
        text-align: right;
    }

    .ld-table--stack td[data-label]::before {
        content: attr(data-label);
        content: attr(data-label) / attr(data-label);
        color: var(--ld-ink-3);
        font-size: 0.8125rem;
        font-weight: 600;
        text-align: left;
    }

    .ld-table--stack .ld-stack-head {
        justify-content: flex-start;
        text-align: left;
    }

    .ld-table--stack .ld-stack-head::before {
        display: none;
    }

    .ld-table--stack .ld-actions {
        justify-content: flex-start;
        padding-top: 10px;
    }

    .ld-table--stack .ld-actions::before {
        display: none;
    }

    .ld-table--stack .ld-row-actions {
        justify-content: flex-start;
    }
}

/* Paginator */
.ld-paging {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 16px;
    padding: 14px 18px;
    border-top: 1px solid var(--ld-line);
}

.ld-paging__count {
    margin: 0;
    color: var(--ld-ink-3);
    font-size: 0.875rem;
}

.ld-paging .pagination {
    --bs-pagination-color: var(--ld-ink);
    --bs-pagination-active-bg: var(--ld-blue);
    --bs-pagination-active-border-color: var(--ld-blue);
    --bs-pagination-focus-box-shadow: 0 0 0 3px rgba(36, 87, 214, 0.3);
    flex-wrap: wrap;
    margin: 0;
}

.ld-paging .page-link {
    min-width: 38px;
    min-height: 38px;
    display: grid;
    place-items: center;
}

/* ---------------------------------------------------------------- Forms */

.ld-form {
    display: grid;
    gap: 18px;
    max-width: 720px;
}

.ld-form__row {
    display: grid;
    gap: 18px;
}

@media (min-width: 640px) {
    .ld-form__row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.ld-form__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding-top: 18px;
    border-top: 1px solid var(--ld-line);
}

.ld-choice {
    display: grid;
    gap: 8px;
}

.ld-choice label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid var(--ld-line-strong);
    border-radius: var(--ld-radius);
    cursor: pointer;
}

.ld-choice label:has(input:checked) {
    border-color: var(--ld-blue);
    background: var(--ld-blue-soft);
}

.ld-choice input {
    margin-top: 4px;
}

.ld-choice strong {
    display: block;
}

.ld-choice small {
    color: var(--ld-ink-2);
}

.input.required > label::after,
.ld-required::after {
    content: " *";
    color: var(--ld-red);
}

/* Cake form helper wrappers */
.ld-form .input {
    min-width: 0;
}

/* ---------------------------------------------------------------- Page manager */

.ld-progress {
    display: grid;
    gap: 6px;
}

.ld-progress__bar {
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: #e8ebf1;
}

.ld-progress__bar span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--ld-green);
    transition: width 0.2s ease;
}

.ld-dropzone {
    display: grid;
    justify-items: center;
    gap: 8px;
    padding: clamp(18px, 4vw, 30px) 16px;
    border: 2px dashed var(--ld-line-strong);
    border-radius: var(--ld-radius-l);
    background: #fafbfd;
    text-align: center;
}

.ld-dropzone.is-over {
    border-color: var(--ld-blue);
    background: var(--ld-blue-soft);
}

.ld-dropzone .bi {
    color: var(--ld-blue);
    font-size: 2rem;
}

.ld-dropzone p {
    margin: 0;
    color: var(--ld-ink-2);
}

.ld-queue {
    display: grid;
    gap: 8px;
    margin: 16px 0 0;
    padding: 0;
    list-style: none;
}

.ld-queue li {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 6px 12px;
    padding: 10px 12px;
    border: 1px solid var(--ld-line);
    border-radius: var(--ld-radius);
    background: #fff;
}

.ld-queue__name {
    min-width: 0;
    overflow: hidden;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ld-queue__meta {
    grid-column: 1 / -1;
    color: var(--ld-ink-3);
    font-size: 0.8125rem;
}

.ld-queue__meta.is-error {
    color: var(--ld-red);
    font-weight: 600;
}

.ld-queue__meta.is-done {
    color: var(--ld-green);
    font-weight: 600;
}

.ld-queue select {
    width: auto;
    min-height: 36px;
}

.ld-queue progress {
    grid-column: 1 / -1;
    width: 100%;
    height: 6px;
    accent-color: var(--ld-blue);
}

.ld-slots {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr));
    gap: 16px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.ld-slot {
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 10px;
    height: 100%;
    padding: 12px;
    border: 1px solid var(--ld-line);
    border-radius: var(--ld-radius-l);
    background: #fff;
}

.ld-slot--empty {
    border-style: dashed;
    background: #fbfbfd;
}

.ld-slot--missing {
    border-color: #f1d79b;
    background: #fffcf3;
}

.ld-slot__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.ld-slot__number {
    font-family: var(--ld-font-display);
    font-size: 1.125rem;
    font-weight: 700;
}

.ld-slot__preview {
    display: grid;
    place-items: center;
    overflow: hidden;
    border: 1px solid var(--ld-line);
    border-radius: 3px;
    background: #f3f5f9;
    aspect-ratio: 240 / 357;
}

.ld-slot__preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
}

.ld-slot__preview .bi {
    color: var(--ld-ink-3);
    font-size: 1.8rem;
}

.ld-slot__file {
    overflow: hidden;
    color: var(--ld-ink-2);
    font-size: 0.8125rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ld-slot__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.ld-slot__actions .btn,
.ld-slot__actions form {
    flex: 1 1 auto;
}

.ld-slot__actions form .btn {
    width: 100%;
}

.ld-slot.is-uploading {
    opacity: 0.7;
}

.ld-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1.7;
    white-space: nowrap;
}

.ld-pill--ok {
    background: var(--ld-green-soft);
    color: var(--ld-green);
}

.ld-pill--warn {
    background: var(--ld-amber-soft);
    color: var(--ld-amber);
}

.ld-pill--empty {
    background: #eceef2;
    color: var(--ld-ink-2);
}

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

.ld-slot__clips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: 0.8125rem;
}

/* ---------------------------------------------------------------- Clip review editor */

.ld-ce__pages {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    padding-bottom: 4px;
    overflow-x: auto;
}

.ld-ce__tab {
    display: grid;
    flex: 0 0 auto;
    gap: 1px;
    min-width: 108px;
    padding: 8px 12px;
    border: 1px solid var(--ld-line);
    border-left: 4px solid var(--ld-line-strong);
    border-radius: var(--ld-radius);
    background: #fff;
    color: var(--ld-ink);
    font-weight: 700;
    text-align: left;
}

.ld-ce__tab small {
    color: var(--ld-ink-3);
    font-weight: 600;
}

.ld-ce__tab[data-state="approved"] {
    border-left-color: var(--ld-green);
}

.ld-ce__tab[data-state="draft"] {
    border-left-color: #e0a300;
}

.ld-ce__tab[aria-current="page"] {
    border-color: var(--ld-blue);
    box-shadow: 0 0 0 1px var(--ld-blue);
}

.ld-ce__tab:focus-visible {
    outline: 3px solid var(--ld-blue);
    outline-offset: 2px;
}

.ld-ce__main {
    display: grid;
    gap: 16px;
    align-items: start;
}

@media (min-width: 1200px) {
    .ld-ce__main {
        grid-template-columns: minmax(0, 1fr) 360px;
    }

    .ld-ce__side {
        position: sticky;
        top: 16px;
    }
}

.ld-ce__stage-panel {
    overflow: hidden;
}

.ld-ce__toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--ld-line);
}

.ld-ce__spacer {
    flex: 1 1 auto;
}

.ld-ce__zoom {
    min-width: 3.5em;
    color: var(--ld-ink-2);
    font-size: 0.875rem;
    font-variant-numeric: tabular-nums;
    text-align: center;
}

.ld-ce__scroller {
    position: relative;
    max-height: calc(100dvh - 210px);
    min-height: 320px;
    padding: 16px;
    overflow: auto;
    background: #e9ecf2;
}

.ld-ce__canvas {
    position: relative;
    width: 100%;
    margin-inline: auto;
}

.ld-ce__image {
    display: block;
    width: 100%;
    height: auto;
    background: #fff;
    box-shadow: 0 1px 2px rgba(27, 35, 51, 0.12);
    user-select: none;
}

.ld-ce__layer {
    position: absolute;
    inset: 0;
    cursor: crosshair;
    touch-action: none;
    user-select: none;
}

.ld-ce__loading {
    position: absolute;
    inset: 0;
    display: grid;
    place-content: center;
    grid-auto-flow: column;
    gap: 8px;
    align-items: center;
    color: var(--ld-ink-2);
}

.ld-ce__box {
    position: absolute;
    border: 2px solid rgba(200, 18, 111, 0.85);
    background: rgba(200, 18, 111, 0.07);
    cursor: move;
}

.ld-ce__box.is-selected {
    z-index: 2;
    border-color: var(--ld-blue);
    background: rgba(36, 87, 214, 0.1);
    box-shadow: 0 0 0 1px #fff;
}

.ld-ce__label {
    position: absolute;
    top: 0;
    left: 0;
    min-width: 22px;
    padding: 1px 5px;
    background: rgba(200, 18, 111, 0.92);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1.5;
    text-align: center;
    pointer-events: none;
}

.ld-ce__box.is-selected .ld-ce__label {
    background: var(--ld-blue);
}

.ld-ce__handle {
    position: absolute;
    width: 12px;
    height: 12px;
    border: 2px solid var(--ld-blue);
    border-radius: 2px;
    background: #fff;
}

.ld-ce__handle--nw { top: -7px; left: -7px; cursor: nwse-resize; }
.ld-ce__handle--n { top: -7px; left: calc(50% - 6px); cursor: ns-resize; }
.ld-ce__handle--ne { top: -7px; right: -7px; cursor: nesw-resize; }
.ld-ce__handle--e { top: calc(50% - 6px); right: -7px; cursor: ew-resize; }
.ld-ce__handle--se { right: -7px; bottom: -7px; cursor: nwse-resize; }
.ld-ce__handle--s { bottom: -7px; left: calc(50% - 6px); cursor: ns-resize; }
.ld-ce__handle--sw { bottom: -7px; left: -7px; cursor: nesw-resize; }
.ld-ce__handle--w { top: calc(50% - 6px); left: -7px; cursor: ew-resize; }

.ld-ce__list {
    display: grid;
    gap: 6px;
    max-height: calc(100dvh - 420px);
    min-height: 120px;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    list-style: none;
}

.ld-ce__item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 6px;
    padding: 4px;
    border: 1px solid transparent;
    border-radius: var(--ld-radius);
}

.ld-ce__item.is-selected {
    border-color: var(--ld-blue);
    background: var(--ld-blue-soft);
}

.ld-ce__num {
    min-width: 30px;
    padding: 3px 6px;
    border: 0;
    border-radius: var(--ld-radius-s);
    background: var(--ld-magenta);
    color: #fff;
    font-size: 0.8125rem;
    font-weight: 700;
}

.ld-ce__item.is-selected .ld-ce__num {
    background: var(--ld-blue);
}

.ld-ce__actions {
    display: grid;
    gap: 8px;
    padding: 14px 16px 16px;
    border-top: 1px solid var(--ld-line);
}

/* ---------------------------------------------------------------- Charts */

.ld-chart {
    position: relative;
    height: 260px;
}

.ld-chart--sm {
    height: 180px;
}

.ld-chart--tall {
    height: 320px;
}

.ld-chart canvas {
    max-width: 100%;
}

.ld-chart-table summary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    color: var(--ld-blue);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
}

.ld-chart-table .ld-table-wrap {
    max-height: 320px;
    margin-top: 10px;
    border: 1px solid var(--ld-line);
    border-radius: var(--ld-radius);
}

.ld-rank {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: rank;
}

.ld-rank li {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) auto;
    align-items: center;
    gap: 4px 10px;
    counter-increment: rank;
}

.ld-rank li::before {
    content: counter(rank);
    color: var(--ld-ink-3);
    font-weight: 700;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.ld-rank__name {
    min-width: 0;
    overflow: hidden;
    color: var(--ld-ink);
    font-weight: 600;
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ld-rank__name:hover {
    color: var(--ld-blue);
    text-decoration: underline;
}

.ld-rank__value {
    color: var(--ld-ink);
    font-weight: 700;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.ld-rank__bar {
    grid-column: 2 / -1;
    height: 8px;
    border-radius: 0 4px 4px 0;
}

.ld-definitions {
    display: grid;
    gap: 8px;
    margin: 0;
    color: var(--ld-ink-2);
    font-size: 0.875rem;
}

.ld-definitions dt {
    color: var(--ld-ink);
    font-weight: 700;
}

.ld-definitions dd {
    margin: 0 0 6px;
}

/* Report builder */
.ld-report-types {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
    gap: 10px;
}

.ld-report-types label {
    height: 100%;
}

.ld-format-choice {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ld-format-choice label {
    position: relative;
}

.ld-format-choice input {
    position: absolute;
    opacity: 0;
}

.ld-format-choice span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
    padding: 0 16px;
    border: 1px solid var(--ld-line-strong);
    border-radius: var(--ld-radius-s);
    font-weight: 600;
    cursor: pointer;
}

.ld-format-choice input:checked + span {
    border-color: var(--ld-blue);
    background: var(--ld-blue-soft);
    color: var(--ld-blue-ink);
    box-shadow: inset 0 0 0 1px var(--ld-blue);
}

.ld-format-choice input:focus-visible + span {
    outline: 3px solid var(--ld-blue);
    outline-offset: 2px;
}

/* Auth (login) */
.ld-auth {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 24px 16px;
    background:
        linear-gradient(180deg, var(--ld-yellow) 0 6px, transparent 6px),
        var(--ld-paper);
}

.ld-auth__card {
    width: min(420px, 100%);
    padding: clamp(22px, 5vw, 34px);
    border: 1px solid var(--ld-line);
    border-radius: var(--ld-radius-l);
    background: #fff;
    box-shadow: var(--ld-shadow-2);
}

.ld-auth__logo {
    display: block;
    width: auto;
    height: 44px;
    margin-bottom: 20px;
}

.ld-auth h1 {
    margin: 0 0 4px;
    font-size: 1.6rem;
    font-weight: 800;
}

.ld-auth__lede {
    margin: 0 0 20px;
    color: var(--ld-ink-2);
}

.ld-auth .input-group .btn {
    min-height: 42px;
}

.ld-auth__foot {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--ld-line);
    color: var(--ld-ink-3);
    font-size: 0.875rem;
}

/* Pass prices */
.ld-prices__off td {
    opacity: 0.6;
}

.ld-prices__off td:first-child {
    opacity: 1;
}

.ld-prices .form-control {
    min-width: 6rem;
}

.ld-prices__order {
    max-width: 5.5rem;
}
