/* What Unfold does not style: its Tailwind build holds only the classes its own
   templates use, so the project's markup gets plain rules on the shared tokens. */

.panel-logo {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--ink);
}

/* Fields grouped in the admin's fieldsets keep sharing a line. */
@media (min-width: 1024px) {
    .form-row:has(> .field-line ~ .field-line) {
        display: flex;
    }

    .form-row:has(> .field-line ~ .field-line) > .field-line {
        flex: 1 1 0;
        min-width: 0;
    }

    .form-row:has(> .field-line ~ .field-line) > .field-line ~ .field-line > div:first-child {
        width: auto;
        min-width: 0;
        margin-right: 12px;
    }
}

/* An inline row needs no title: its first columns already identify it. The cell
   stays, it holds the row's hidden id. */
.formset td[colspan] > p {
    display: none;
}

.panel-section-icon {
    margin-right: 8px;
    font-size: 18px;
    color: var(--muted);
}

/* The menu: Unfold's sidebar and top bar. IDs outrank Unfold's Tailwind classes. */
#nav-sidebar,
#main > div:has(> div > #header-inner) {
    background: var(--chrome);
    border-color: var(--chrome-line);
}

/* Sidebar. A section heading starts 24px in: the line runs under the middle of its
   icon and the entries start 16px further in. */
#nav-sidebar-apps ol {
    margin-inline-start: 32px;
    margin-bottom: 4px;
    padding-inline: 0 24px;
    border-inline-start: 1px solid var(--line-strong);
}

#nav-sidebar-apps ol > li > a {
    margin-inline-start: 2px;
    padding-inline-start: 5px;
}

#nav-sidebar-apps ol > li > a.active {
    color: var(--accent-text);
    background: var(--accent-soft);
}

#nav-sidebar-apps .sidebar-badge {
    margin-inline-start: auto;
}

#nav-sidebar-apps > div:has(> ol a.active) > h2,
#nav-sidebar-apps > div:has(> ol a.active) > h2 .panel-section-icon {
    color: var(--accent-text);
}

/* The way back on screens with no place in the admin's own title path. */
.panel-crumbs {
    margin-bottom: 16px;
    font-size: 0.75rem;
    color: var(--muted);
}

.panel-crumbs a {
    color: var(--accent);
}

html.dark .panel-crumbs a {
    color: var(--color-primary-400);
}

/* Buttons */
.panel-button,
.panel-form input[type="submit"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-weight: 500;
    white-space: nowrap;
    color: var(--ink);
    background: var(--surface);
    cursor: pointer;
}

.panel-button:hover,
.panel-form input[type="submit"]:hover {
    background: var(--surface-sunken);
}

.panel-button-primary,
.panel-form input[type="submit"].panel-button-primary {
    border-color: transparent;
    color: var(--on-accent);
    background: var(--accent);
}

.panel-button-primary:hover,
.panel-form input[type="submit"].panel-button-primary:hover {
    background: var(--accent-hover);
}

/* Fields in a project template */
.panel-form label {
    display: block;
    margin-bottom: 4px;
    font-weight: 500;
    color: var(--ink);
}

.panel-form input[type="text"],
.panel-form input[type="number"],
.panel-form input[type="date"],
.panel-form input[type="datetime-local"],
.panel-form input[type="file"],
.panel-form select,
.panel-form textarea {
    max-width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--ink);
    background: var(--surface);
}

.panel-form input:focus,
.panel-form select:focus,
.panel-form textarea:focus {
    outline: 2px solid var(--color-primary-400);
    outline-offset: -1px;
}

.panel-form input:disabled,
.panel-form select:disabled,
.panel-form textarea:disabled {
    color: var(--muted);
    background: var(--surface-sunken);
}

.panel-form input[type="checkbox"] {
    accent-color: var(--accent);
}

.panel-form p {
    margin-bottom: 12px;
}

/* Tables and boxes in a project template */
.panel-box {
    margin-bottom: 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}

.panel-box > h2 {
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    font-weight: 600;
    color: var(--ink);
    background: var(--surface-sunken);
}

.panel-box > .help {
    padding: 10px 12px;
}

.panel-table {
    width: 100%;
    border-collapse: collapse;
}

.panel-table th {
    padding: 8px 12px;
    border-bottom: 1px solid var(--line);
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
    color: var(--ink);
}

.panel-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

.panel-table tbody tr:last-child td {
    border-bottom: 0;
}

.panel-table a,
.panel-link {
    color: var(--accent);
}

html.dark .panel-table a,
html.dark .panel-link {
    color: var(--color-primary-400);
}

.help {
    font-size: 0.75rem;
    color: var(--muted);
}

.errornote {
    margin-bottom: 12px;
    padding: 8px 12px;
    border-radius: var(--radius);
    color: var(--bad);
    background: var(--bad-soft);
}

.panel-heading {
    margin-bottom: 8px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--ink);
}

/* Status at a glance (ui-status). Badges are Unfold's labels; the layout around
   them is here. */

/* Tiles above the order list: a click filters, a second click clears. */
.board-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.board-tile {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 12px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--text);
    background: var(--surface);
}

.board-tile:hover {
    border-color: var(--line-strong);
    background: var(--surface-sunken);
}

.board-tile-active,
.board-tile-active:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.board-tile-count {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--ink);
}

.board-tile-active .board-tile-count,
.board-tile-active .board-tile-title {
    color: var(--accent-text);
}

.board-tile-title {
    font-weight: 500;
}

/* Tabs above a list, each with its count. */
.list-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 16px;
    padding: 4px;
    border-radius: var(--radius);
    background: var(--surface-sunken);
}

.list-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: var(--radius);
    font-weight: 500;
    white-space: nowrap;
    color: var(--ink);
}

.list-tab:hover {
    background: rgb(0 0 0 / 4%);
}

html.dark .list-tab:hover {
    background: rgb(255 255 255 / 6%);
}

.list-tab-active,
.list-tab-active:hover {
    background: var(--surface);
    box-shadow: 0 1px 2px rgb(0 0 0 / 8%);
}

html.dark .list-tab-active,
html.dark .list-tab-active:hover {
    background: var(--color-base-700);
}

/* Order page: progress under the title, warnings under the progress. */
.order-status {
    margin-bottom: 8px;
}

.order-progress {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px 24px;
    margin-bottom: 16px;
    padding: 12px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.order-progress-done [style^="width"] {
    background-color: var(--ok) !important;
}

.warning-link {
    color: inherit;
    font-weight: 600;
    text-decoration: underline;
}

/* Unfold puts the dataset tabs last; Attachments and History go after Labels. */
.model-order #tabs-items > a[href="#attachments"] {
    order: 1;
}

.model-order #tabs-items > a[href="#dataset-history"] {
    order: 2;
}

.order-tab .help {
    padding: 4px 0;
}

.nowrap {
    white-space: nowrap;
}

/* The expanded row of the order list. */
.section-lines {
    background: var(--surface);
}

/* Start page. */
.dashboard-overview {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    margin-bottom: 16px;
    padding: 12px 16px;
}

.dashboard-overview-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 8px;
}

.dashboard-overview-scroll {
    overflow-x: auto;
}

.dashboard-overview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}

.dashboard-overview-table th,
.dashboard-overview-table td {
    padding: 6px 10px;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--line);
}

.dashboard-overview-table .num {
    text-align: right;
    white-space: nowrap;
}

.dashboard-overview-table tbody tr:hover {
    background: rgba(128, 128, 128, .08);
    cursor: pointer;
}

.dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
}

.dashboard-tile {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: hidden;
}

.dashboard-tile-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    color: var(--ink);
    background: var(--surface-sunken);
}

.dashboard-tile-head:hover .dashboard-tile-title {
    color: var(--accent-text);
}

.dashboard-tile-icon {
    font-size: 20px;
    color: var(--accent-text);
}

.dashboard-tile-title {
    font-weight: 600;
}

.dashboard-tile-count {
    margin-left: auto;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
}

.dashboard-rows {
    margin: 0;
    padding: 4px 0;
    list-style: none;
}

.dashboard-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    color: var(--text);
}

.dashboard-row:hover {
    background: var(--surface-sunken);
}

.dashboard-row-main {
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
    font-weight: 500;
    color: var(--ink);
}

/* The order number is never cut; what follows it gives way first. */
.dashboard-row-lead {
    flex: 0 0 auto;
    white-space: nowrap;
}

.dashboard-row-detail {
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: pre;
}

.side-short {
    display: none;
}

@media (max-width: 520px) {
    .dashboard-row-side.has-short .side-long {
        display: none;
    }

    .dashboard-row-side.has-short .side-short {
        display: inline;
    }
}

.dashboard-row-side {
    flex: 0 0 auto;
    margin-left: auto;
    font-size: 0.75rem;
    white-space: nowrap;
    color: var(--muted);
}

.dashboard-row-late .dashboard-row-side {
    font-weight: 600;
    color: var(--bad);
}

.dashboard-more {
    padding: 6px 16px 10px;
    font-size: 0.75rem;
    color: var(--accent-text);
}

.dashboard-empty {
    padding: 12px 16px;
}

[x-cloak] {
    display: none !important;
}

/* The shared lightbox (core/lightbox.js): fixed in the middle of the window, the original
   file fitted into 90 % x 90 % of it. Every photo opens at the same, largest size. */
a[data-lightbox] {
    display: inline-block;
    cursor: zoom-in;
}

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.75);
    overscroll-behavior: contain;
    touch-action: none;
    outline: none;
}

.lightbox[hidden] {
    display: none;
}

.lightbox-image {
    display: block;
    width: 90vw;
    height: 90vh;
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    user-select: none;
    -webkit-user-select: none;
}

.lightbox-control {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    font: 28px/1 sans-serif;
    color: #fff;
    background: rgba(0, 0, 0, 0.55);
    cursor: pointer;
}

.lightbox-control:hover,
.lightbox-control:focus-visible {
    background: rgba(0, 0, 0, 0.85);
}

.lightbox-control[hidden] {
    display: none;
}

.lightbox-close {
    top: 12px;
    right: 12px;
}

.lightbox-previous {
    top: 50%;
    left: 12px;
    transform: translateY(-50%);
}

.lightbox-next {
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
}

.lightbox-counter {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.8125rem;
    color: #fff;
    background: rgba(0, 0, 0, 0.55);
}

.lightbox-counter[hidden] {
    display: none;
}

/* A product's first photo in the product list. */
.list-thumbnail {
    display: block;
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: var(--radius);
}

/* A product's packshot in the lists of order lines: the look of the product list,
   with a grey square of the same size when there is none, so that rows do not jump. */
.line-thumb-empty {
    background: var(--quiet-soft);
}

.line-thumb-cell {
    width: 1%;
    white-space: nowrap;
}

/* files-23: compact tables. Every data row is one line high; the table scrolls
   sideways inside its own window, never the page. */
.compact-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.compact-table th,
.compact-table td {
    white-space: nowrap;
    vertical-align: middle;
    padding: 6px 10px;
}

/* Brand and name: a fixed width, then an ellipsis; the tooltip has the rest. */
.cell-ellipsis {
    display: inline-block;
    vertical-align: middle;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cell-brand {
    max-width: 14ch;
}

.cell-name {
    max-width: 30ch;
}

/* Chips and badges stay on one line. */
.compact-table .lang-chips {
    flex-wrap: nowrap;
}

.compact-table .lang-chip,
.compact-table .format-note,
.compact-table small {
    white-space: nowrap;
}

/* Thumbnail and GTIN stay in view while the rest scrolls (files-23). The thumbnail
   column is 64 px wide: 40 px picture and 2 x 12 px padding. */
.compact-table .sticky-thumb,
.compact-table .sticky-gtin {
    position: sticky;
    z-index: 1;
    background: var(--surface);
}

.compact-table th.sticky-thumb,
.compact-table th.sticky-gtin {
    z-index: 2;
}

.compact-table .sticky-thumb {
    left: 0;
    width: 64px;
    min-width: 64px;
    max-width: 64px;
    padding-left: 12px;
    padding-right: 12px;
}

.compact-table .sticky-gtin {
    left: 64px;
}

/* Cancelled lines (files-23): grey, nothing to do on them. */
/* Only the row of the cancelled line itself: `>` keeps it off nested tables, and the
   :has() fallback (admin rows that cannot carry the class) skips any row that holds a
   table, such as the outer row of an expanded order. */
tr.line-cancelled > td,
tr:not(:has(table)):has(.line-cancelled-chip) > td {
    opacity: 0.55;
}

.line-cancelled-chip {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--quiet-soft);
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.pack-line-cancelled {
    opacity: 0.6;
}

.line-cancel-link {
    white-space: nowrap;
}

.overview-lines {
    color: var(--muted);
    white-space: nowrap;
}

/* The Labels tab: each decision is one block, controls on one row. */
.decision-cell .decision-caption {
    display: block;
    max-width: 22ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 2px;
}

.decision-cell form.label-decision {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 4px;
    margin: 0;
}

.decision-cell form.label-decision select {
    width: 10.5em;
}

.decision-cell form.label-decision input[type="text"] {
    width: 9em;
}

/* Notes under a badge sit beside it, so that a row stays one line high. */
.compact-table td .format-note {
    display: inline;
    margin-left: 6px;
}

.compact-table td .format-note form {
    display: inline;
}
