/*
 * Operator workflow screens: the queue, and what a run produced.
 *
 * Loaded after app.css and reuses its tokens and components -- panels, tables,
 * badges, cards -- rather than starting a second visual language.
 *
 * Audience: a wide monitor in shop-floor lighting, read by someone mid-job who
 * does not want to read. Big targets, high contrast, and the dangerous states
 * are the loudest things on the page. A queue line that loses cut geometry
 * should be visible from the far side of the bench.
 *
 * Plain CSS, no build step, house convention.
 */

/* --------------------------------------------------------------- header add */

.app-nav__count {
    display: inline-block;
    min-width: 1.6em;
    margin-left: 6px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--brand);
    color: #ffffff;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    text-align: center;
}

.app-nav__link.is-current .app-nav__count {
    background: #ffffff;
    color: var(--brand-dark);
}

/* --------------------------------------------------------------- alerts */

/*
 * Four levels, and the loudest is the one hard rule 1 turns on: geometry the
 * operator expected to cut and will not get. A discard that scrolls past unread
 * is the whole failure this app exists to stop, so it gets a heavier border and
 * a warmer ground than an ordinary warning.
 */
.alert {
    margin: 0 0 20px;
    padding: 14px 18px;
    border: 1px solid var(--line);
    border-left: 8px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--surface);
}

.alert__title {
    margin: 0 0 6px;
    font-size: 17px;
    font-weight: 700;
}

.alert p {
    margin: 0 0 8px;
    max-width: 110ch;
}

.alert p:last-child,
.alert ul:last-child {
    margin-bottom: 0;
}

.alert__list {
    margin: 8px 0 0;
    padding-left: 20px;
}

.alert__list li {
    margin-bottom: 6px;
    max-width: 120ch;
}

.alert--good {
    background: #e9f5ea;
    border-color: #a8d3ab;
    border-left-color: #2f7d32;
}

.alert--good .alert__title {
    color: #1e5c22;
    font-weight: 600;
}

.alert--block {
    background: var(--cut-bg);
    border-color: var(--cut-line);
    border-left-color: var(--cut-ink);
}

.alert--block .alert__title {
    color: var(--cut-ink);
}

.alert--warn {
    background: var(--warn-bg);
    border-color: var(--warn-line);
    border-left-color: var(--warn-ink);
}

.alert--warn .alert__title {
    color: var(--warn-ink);
}

.alert--discard {
    background: #fff4e2;
    border-color: #e0a24a;
    border-left-color: #b45309;
    box-shadow: 0 2px 0 rgba(180, 83, 9, 0.25);
}

.alert--discard .alert__title {
    color: #8a3d09;
    font-size: 19px;
}

/* -------------------------------------------------------------- controls */

.btn {
    display: inline-block;
    padding: 10px 18px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.btn:hover,
.btn:focus {
    border-color: var(--brand);
    background: var(--brand-tint);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn--primary {
    background: var(--brand);
    border-color: var(--brand);
    color: #ffffff;
}

.btn--primary:hover,
.btn--primary:focus {
    background: var(--brand-dark);
    border-color: var(--brand-dark);
    color: #ffffff;
}

.btn--big {
    padding: 14px 26px;
    font-size: 18px;
}

.btn--quiet {
    padding: 8px 14px;
    border-color: var(--line);
    background: transparent;
    color: var(--ink-soft);
    font-size: 14px;
    font-weight: 600;
}

.inline-form,
.hidden-form {
    display: inline;
    margin: 0;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin: 16px 0 0;
}

.actions--advance {
    margin: 26px 0;
    padding-top: 20px;
    border-top: 2px solid var(--line);
}

.field {
    display: block;
    min-width: 0;
}

.field__label {
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-faint);
}

.field__control {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    font-family: inherit;
    font-size: 16px;
}

.field__control:focus {
    outline: 3px solid var(--brand-tint);
    border-color: var(--brand);
}

.switches {
    display: flex;
    gap: 6px;
}

.switch {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 11px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--surface);
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}

.switch:has(input:checked) {
    background: var(--warn-bg);
    border-color: var(--warn-ink);
    color: var(--warn-ink);
}

/* -------------------------------------------------------------- dropzone */

.dropzone {
    margin: 0 0 20px;
    padding: 0;
    border: 3px dashed var(--line-strong);
    border-radius: var(--radius);
    background: var(--surface);
}

.dropzone.is-dragging {
    border-color: var(--brand);
    background: var(--brand-tint);
    box-shadow: inset 0 0 0 3px rgba(11, 95, 165, 0.15);
}

.dropzone__inner {
    padding: 28px 24px;
    text-align: center;
}

.dropzone__headline {
    margin: 0 0 4px;
    font-size: 24px;
    font-weight: 800;
}

.dropzone__sub {
    margin: 0 auto 16px;
    max-width: 72ch;
    color: var(--ink-soft);
}

/* The real input stays in the DOM and keyboard-reachable; the label is the
 * visible target so the control is a proper button-sized thing to hit. */
.dropzone__browse {
    position: relative;
    overflow: hidden;
}

.dropzone__browse input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.dropzone__submit {
    margin-left: 10px;
}

.dropzone__progress {
    margin: 0;
    padding: 0 24px 20px;
    list-style: none;
}

.dropzone__file {
    display: grid;
    grid-template-columns: minmax(180px, 30ch) 1fr;
    align-items: center;
    gap: 12px;
    padding: 6px 0;
    font-size: 14px;
}

.dropzone__file.is-failed {
    display: block;
    color: var(--cut-ink);
    font-weight: 600;
}

.dropzone__file-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dropzone__bar {
    display: block;
    height: 10px;
    border-radius: 999px;
    background: var(--off-bg);
    overflow: hidden;
}

.dropzone__bar-fill {
    display: block;
    width: 0;
    height: 100%;
    background: var(--brand);
    transition: width 120ms linear;
}

/* ---------------------------------------------------------------- totals */

.totals {
    position: sticky;
    top: 0;
    z-index: 5;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px 24px;
    align-items: center;
    margin: 0 0 22px;
    padding: 14px 18px;
    background: var(--surface);
    border: 2px solid var(--brand);
    border-radius: var(--radius);
    box-shadow: 0 3px 10px rgba(20, 32, 46, 0.08);
}

.totals__figures {
    grid-column: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 22px;
    font-size: 15px;
}

.totals__figure strong {
    font-size: 24px;
    font-variant-numeric: tabular-nums;
}

.totals__figure--bad {
    color: var(--cut-ink);
}

.totals__figure--warn {
    color: var(--warn-ink);
}

.totals__breakdown {
    grid-column: 1;
    grid-row: 2;
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
}

.totals__breakdown li {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 5px 11px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 14px;
}

.totals__material {
    font-weight: 700;
}

.totals__count {
    color: var(--ink-soft);
    font-variant-numeric: tabular-nums;
}

.totals__go {
    grid-column: 2;
    grid-row: 1 / span 2;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    margin: 0;
}

.totals__hint {
    font-size: 13px;
    color: var(--ink-faint);
    text-align: right;
    max-width: 34ch;
}

@media (max-width: 1000px) {
    .totals {
        grid-template-columns: 1fr;
    }

    .totals__go {
        grid-column: 1;
        grid-row: auto;
        align-items: flex-start;
    }

    .totals__hint {
        text-align: left;
    }
}

/* ----------------------------------------------------------- queue lines */

.lines {
    display: block;
}

.line {
    margin: 0 0 14px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 8px solid var(--line-strong);
    border-radius: var(--radius);
}

.line--pass {
    border-left-color: #2f7d32;
}

.line--block {
    border-left-color: var(--cut-ink);
    background: #fffafa;
}

/* Losing geometry outranks passing preflight: a line can be PASS and still be
 * about to cut less than the operator thinks. */
.line--alarm {
    border-left-color: #b45309;
}

.line.is-busy {
    opacity: 0.55;
}

.line__form {
    margin: 0;
}

.line__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 16px;
    margin-bottom: 12px;
}

.line__name {
    flex: 1 1 320px;
    font-size: 17px;
    min-width: 0;
}

.line__name .muted {
    display: block;
    font-size: 14px;
    font-weight: 400;
}

.verdict {
    flex: 0 0 auto;
    padding: 7px 14px;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.verdict--pass {
    background: #e6f4e7;
    color: #1e5c22;
    border: 1px solid #a8d3ab;
}

.verdict--block {
    background: var(--cut-bg);
    color: var(--cut-ink);
    border: 1px solid var(--cut-line);
}

/* One row of tagging controls on a wide monitor. The three material selects
 * are the wide ones because they are what the operator actually changes. */
.line__tags {
    display: grid;
    grid-template-columns:
        minmax(190px, 1.4fr)
        minmax(170px, 1.2fr)
        minmax(150px, 1fr)
        84px
        minmax(150px, 1fr)
        auto
        96px
        96px
        auto;
    gap: 10px;
    align-items: end;
}

@media (max-width: 1500px) {
    .line__tags {
        grid-template-columns: repeat(4, minmax(150px, 1fr));
    }

    .line__buttons {
        grid-column: 1 / -1;
    }
}

@media (max-width: 780px) {
    .line__tags {
        grid-template-columns: 1fr 1fr;
    }
}

.line__buttons {
    display: flex;
    gap: 8px;
    align-items: end;
}

.line__note {
    margin: 12px 0 0;
    font-size: 14px;
    color: var(--ink-soft);
}

.line__spots {
    margin-top: 12px;
}

.line__spots > summary {
    cursor: pointer;
    padding: 6px 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--ink-soft);
}

.line__spots[open] > summary {
    margin-bottom: 8px;
}

.line .alert {
    margin: 12px 0 0;
}

table.data tbody tr.is-discarded {
    background: var(--warn-bg);
}

/* -------------------------------------------------------------- run result */

.scoreboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin: 0 0 20px;
}

.score {
    padding: 14px 18px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

/* Linear metres on roll work, sheet count on rigid. The number the business
 * decides on gets the size, not an equal share of the row. */
.score--headline {
    border: 2px solid var(--brand);
    background: var(--brand-tint);
}

.score--bad {
    border-color: var(--cut-line);
    background: var(--cut-bg);
}

.score__value {
    display: block;
    font-size: 34px;
    font-weight: 800;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.score--headline .score__value {
    font-size: 46px;
    color: var(--brand-dark);
}

.score--bad .score__value {
    color: var(--cut-ink);
}

.score__label {
    display: block;
    margin-top: 2px;
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-soft);
}

.score__note {
    display: block;
    margin-top: 4px;
    font-size: 13px;
    color: var(--ink-faint);
}

.material {
    margin: 0 0 34px;
    padding-top: 18px;
    border-top: 3px solid var(--line);
}

.material__head {
    margin-bottom: 14px;
}

.material__title {
    margin: 0;
    font-size: 22px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.material__machines {
    margin: 4px 0 0;
    font-size: 14px;
    color: var(--ink-soft);
}

.sheet-card {
    margin: 0 0 18px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 5px solid var(--brand);
    border-radius: var(--radius);
}

.sheet-card__head {
    margin-bottom: 10px;
}

.sheet-card__title {
    margin: 0;
    font-size: 17px;
    font-family: var(--mono);
    word-break: break-all;
}

.sheet-card__facts {
    margin: 4px 0 0;
    font-size: 14px;
    color: var(--ink-soft);
}

/* --------------------------------------------------------- nest viewer */

.viewer {
    display: block;
    margin-bottom: 18px;
}

.sheet {
    margin: 0 0 20px;
    padding: 12px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.sheet__caption {
    margin-bottom: 10px;
    font-size: 14px;
    color: var(--ink-soft);
}

.sheet__zone {
    display: inline-block;
    margin-top: 4px;
    padding: 2px 9px;
    background: var(--brand-tint);
    border: 1px solid var(--ink-line);
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-ink);
}

.sheet__canvas {
    display: block;
    background: #ffffff;
    border: 1px solid var(--line-strong);
    cursor: crosshair;
}

.nest-tip {
    position: fixed;
    z-index: 20;
    max-width: 38ch;
    padding: 8px 11px;
    background: var(--ink);
    color: #ffffff;
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.4;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(20, 32, 46, 0.3);
}

/* --------------------------------------------------------------- print */

@media print {
    .dropzone,
    .totals__go,
    .btn,
    .actions,
    .line__buttons,
    .nest-tip {
        display: none !important;
    }

    .totals {
        position: static;
        box-shadow: none;
    }

    .alert {
        border: 2px solid #000000 !important;
        background: #ffffff !important;
        border-radius: 0;
    }

    .line,
    .score,
    .sheet,
    .sheet-card {
        border: 1px solid #000000;
        border-radius: 0;
        background: #ffffff;
        break-inside: avoid;
    }

    .verdict {
        border: 1px solid #000000 !important;
        background: #ffffff !important;
        color: #000000 !important;
    }

    .line__spots {
        display: block;
    }
}
