﻿/* Operations screens: production console, documents and traceability. */

.num { text-align: right; }
.alert.blocked { color: #7a2f27; border: 1px solid #f0c2bc; background: #fbeae7; }
.alert.warning { color: #7a5a20; border: 1px solid #ecd7a8; background: #fbf3e2; }
.is-selected > td { background: #f5f1e7; }
.is-muted { opacity: .5; }
.icon-button.small { display: inline-grid; place-items: center; min-width: var(--alvo-compacto); min-height: var(--alvo-compacto); font-size: 1.1rem; line-height: 1; }

.meter { height: 7px; border-radius: 99px; background: #e4dfd4; overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: 99px; background: #2f7d5f; }

.op-console { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 20px; align-items: start; }
.step-rail { display: grid; gap: 8px; }
.step-chip { display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 11px; padding: 13px 14px; border: 1px solid #ded8cc; border-radius: 14px; background: rgba(255,255,255,.82); text-align: left; cursor: pointer; }
.step-chip:hover { border-color: #c3bba9; }
.step-chip.is-active { border-color: #173d35; box-shadow: 0 0 0 2px rgba(23,61,53,.1); }
.step-index { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: #efeae0; color: #4c5b55; font-weight: 800; font-size: .8rem; }
.step-chip.is-done .step-index { background: #dff0e6; color: #1f5f43; }
.step-chip.is-running .step-index { background: #173d35; color: #f5d4a9; }
.step-chip.is-blocked .step-index { background: #fbeae7; color: #a1382f; }
.step-body strong { display: block; font-size: .88rem; }
.step-body small { color: var(--cor-texto-fraco); font-size: .74rem; }
.step-tick { color: #1f5f43; font-weight: 800; }
.step-live { width: 9px; height: 9px; border-radius: 50%; background: #d79a52; box-shadow: 0 0 0 0 rgba(215,154,82,.7); animation: pulse 1.6s infinite; }

@keyframes pulse {
    70% { box-shadow: 0 0 0 8px rgba(215,154,82,0); }
    100% { box-shadow: 0 0 0 0 rgba(215,154,82,0); }
}

.step-work { display: grid; gap: 16px; min-width: 0; }
.step-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.step-head h2 { margin: 0; }
.timer-block { text-align: right; }
.timer { display: block; font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; color: #4c5b55; }
.timer.is-live { color: #173d35; }
/* Cada «small» na sua linha: quem opera a fase e quanto tempo estava previsto são duas coisas,
   e em linha liam-se como uma só — «Development Administrator previsto 03:00:00». Num ecrã
   estreito ainda se atropelavam, que foi como a varredura deu por isto. */
.timer-block small { display: block; color: var(--cor-texto-fraco); }

.readiness { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-radius: 13px; font-size: .88rem; font-weight: 600; }
.readiness.is-ready { color: #1f5f43; border: 1px solid #bcdcc9; background: #e6f4ec; }
.readiness.is-blocked { color: #7a5a20; border: 1px solid #ecd7a8; background: #fbf3e2; }
.readiness-icon { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: rgba(255,255,255,.75); font-weight: 900; }

.material-row { padding: 14px 0; border-bottom: 1px solid #eee9e0; }
.material-row:last-of-type { border-bottom: 0; }
.material-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 9px; }
.material-meter { display: grid; gap: 5px; margin-bottom: 9px; }
.material-meter small { color: var(--cor-texto-fraco); font-size: .76rem; }
.lot-tag { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 10px; padding: 7px 11px; margin-top: 6px; border: 1px solid #e2ddd2; border-radius: 9px; background: #faf8f4; font-size: .8rem; }
.lot-code { font-weight: 750; }
.lot-meta { color: var(--cor-texto-fraco); font-size: .74rem; }
.lot-qty { font-variant-numeric: tabular-nums; font-weight: 700; }

.output-row { padding: 13px 0; border-bottom: 1px solid #eee9e0; }
.output-row:last-of-type { border-bottom: 0; }
.output-numbers { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 6px; font-size: .82rem; color: #63716c; }
.output-numbers .under b { color: #a1382f; }
.output-numbers .over b { color: #8a6239; }
.output-numbers .on-target b { color: #1f5f43; }
.quantity-entry { display: flex; gap: 9px; margin-top: 14px; }
.quantity-entry input { flex: 1; }

.action-bar { display: flex; justify-content: flex-end; gap: 11px; }
.button.large { min-height: 52px; padding: 12px 26px; font-size: 1rem; }

.origin-chip { display: inline-flex; align-items: center; min-height: var(--alvo-compacto); padding: 0 var(--e-3); border-radius: var(--raio-redondo); font-size: var(--t-xs); font-weight: var(--peso-forte); text-transform: uppercase; letter-spacing: .04em; background: var(--cor-superficie-fria); color: var(--cor-texto-suave); }
.origin-chip.production { background: #e6f4ec; color: #1f5f43; }

.trace-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 20px; align-items: start; }
.lot-list { display: grid; gap: 12px; }
.search { width: 100%; }
.lot-scroll { display: grid; gap: 7px; max-height: 60vh; overflow-y: auto; }
.lot-item { display: grid; gap: 3px; padding: 11px 13px; border: 1px solid #e5e0d6; border-radius: 11px; background: #fff; text-align: left; cursor: pointer; }
.lot-item:hover { border-color: #c3bba9; }
.lot-item.is-active { border-color: #173d35; box-shadow: 0 0 0 2px rgba(23,61,53,.1); }
.lot-item-head { display: flex; align-items: center; justify-content: space-between; gap: 9px; }
.lot-item small { color: var(--cor-texto-fraco); font-size: var(--t-s); }
.lot-item-meta { font-variant-numeric: tabular-nums; }

.graph-panel { display: grid; gap: 16px; min-width: 0; }
.legend { display: flex; gap: 14px; color: var(--cor-texto-fraco); font-size: .74rem; }
.legend .dot { display: inline-block; width: 9px; height: 9px; margin-right: 5px; border-radius: 50%; }
.dot.upstream { background: #8a9b93; }
.dot.focus { background: #d79a52; }
.dot.downstream { background: #2f7d5f; }
.graph-scroll { overflow-x: auto; padding-bottom: 6px; }
.trace-edge { fill: none; stroke: #c3bba9; stroke-width: 1.6; }
.trace-edge-label { fill: var(--cor-texto-fraco); font-size: 10px; font-family: inherit; }
.trace-node rect { fill: #fff; stroke: #ded8cc; stroke-width: 1.4; }
.trace-node.is-focus rect { stroke: #d79a52; stroke-width: 2.4; fill: #fdf6ec; }
.trace-node.is-upstream rect { stroke: #c8d2ce; }
.trace-node.is-downstream rect { stroke: #b6d3c3; }
.trace-code { fill: #173d35; font-size: 13px; font-weight: 800; font-family: inherit; }
.trace-lot { fill: #4c5b55; font-size: 12px; font-family: inherit; }
.trace-meta { fill: var(--cor-texto-fraco); font-size: 10.5px; font-family: inherit; }

.trace-detail { display: grid; gap: 4px; }
.trace-row { display: grid; grid-template-columns: 92px minmax(0, 1fr) minmax(0, 170px) 140px; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 9px; font-size: .82rem; }
.trace-row:nth-child(odd) { background: #faf8f4; }
.trace-row.is-focus { background: #fdf6ec; border: 1px solid #ecd7a8; }
.depth-badge { padding: 3px 8px; border-radius: 99px; background: #efeae0; color: #5c675f; font-size: .68rem; font-weight: 800; text-align: center; text-transform: uppercase; }
.trace-row-main small, .trace-row-origin small { display: block; color: var(--cor-texto-fraco); font-size: .72rem; }
.trace-row-when { color: var(--cor-texto-fraco); text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 1100px) {
    .op-console, .trace-layout { grid-template-columns: 1fr; }
    .step-rail { grid-auto-flow: column; grid-auto-columns: minmax(180px, 1fr); overflow-x: auto; }
    .trace-row { grid-template-columns: 80px minmax(0, 1fr); }
    .trace-row-when { display: none; }
}

@media (max-width: 820px) {
    .step-head { display: grid; }
    .timer-block { text-align: left; }
}

/* Paragens de produção -------------------------------------------------- */

.stoppage-banner {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    margin-bottom: 14px;
    border: 1px solid #ecd7a8;
    border-radius: 12px;
    background: #fdf8ee;
}

.stoppage-banner > div { display: grid; gap: 2px; min-width: 0; }
.stoppage-banner strong { font-size: .95rem; font-variant-numeric: tabular-nums; }
.stoppage-banner small { color: var(--cor-texto-fraco); font-size: .78rem; }
.stoppage-banner.is-breakdown, .stoppage-banner.is-quality { border-color: #f0c2bc; background: #fdf1ef; }

.stoppage-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #d79a52;
    animation: stoppage-pulse 1.6s ease-in-out infinite;
}

.stoppage-banner.is-breakdown .stoppage-dot, .stoppage-banner.is-quality .stoppage-dot { background: #c2554a; }

@keyframes stoppage-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .25; }
}

@media (prefers-reduced-motion: reduce) {
    .stoppage-dot { animation: none; }
}

.timer-block .over-plan { color: #a8632a; font-weight: 600; }

.efficiency {
    padding: 5px 12px;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.efficiency.is-good { background: #dcece4; color: #1f5f43; }
.efficiency.is-fair { background: #f4ead3; color: #8a6414; }
.efficiency.is-poor { background: #f6e2e0; color: #8f3f38; }

.time-split { display: grid; gap: 9px; margin: 4px 0 16px; }

.time-bar {
    display: flex;
    height: 13px;
    border-radius: 7px;
    overflow: hidden;
    background: #efeae0;
}

.time-bar .running { background: #3f7d5f; }
.time-bar .stopped { background: #d79a52; }

.time-legend { display: flex; flex-wrap: wrap; gap: 18px; font-size: .8rem; }
.time-legend .muted { color: var(--cor-texto-fraco); }
.time-legend .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.time-legend .swatch.running { background: #3f7d5f; }
.time-legend .swatch.stopped { background: #d79a52; }

.downtime-table tr.is-open > td { background: #fdf8ee; font-weight: 600; }

.reason-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 11px;
    margin: 6px 0 16px;
}

.reason-card {
    display: grid;
    gap: 3px;
    padding: 15px 16px;
    text-align: left;
    border: 1px solid #e2ddd2;
    border-left-width: 4px;
    border-radius: 11px;
    background: #fff;
    cursor: pointer;
    font: inherit;
    transition: border-color .12s ease, background .12s ease;
}

.reason-card:hover { background: #faf8f4; }
.reason-card strong { font-size: .9rem; }
.reason-card small { color: var(--cor-texto-fraco); font-size: .74rem; }
.reason-card.is-selected { border-color: #2f5c48; background: #f2f9f5; box-shadow: 0 0 0 1px #2f5c48; }

.reason-card.is-planned { border-left-color: #7f9ec4; }
.reason-card.is-breakdown { border-left-color: #c2554a; }
.reason-card.is-waiting { border-left-color: #d79a52; }
.reason-card.is-changeover { border-left-color: #8d7bb5; }
.reason-card.is-quality { border-left-color: #b8863b; }

@media (max-width: 720px) {
    .stoppage-banner { grid-template-columns: auto 1fr; }
    .stoppage-banner .button { grid-column: 2; justify-self: start; }
}

/* Quadro de planeamento -------------------------------------------------- */

.board-panel { overflow-x: auto; }

.planning-board {
    display: grid;
    grid-template-columns: 150px repeat(var(--days, 7), minmax(140px, 1fr));
    gap: 1px;
    min-width: 900px;
    background: #e8e3d9;
    border: 1px solid #e2ddd2;
    border-radius: 11px;
    overflow: hidden;
}

.board-corner, .board-day, .board-line, .board-cell { background: #fff; padding: 10px 12px; }

.board-day { display: grid; gap: 1px; text-align: center; background: #faf8f4; }
.board-day strong { font-size: .78rem; text-transform: capitalize; }
.board-day small { color: var(--cor-texto-fraco); font-size: .72rem; }
.board-day.is-today { background: #f2f9f5; box-shadow: inset 0 -3px 0 #3f7d5f; }

.board-line { display: grid; gap: 1px; align-content: start; background: #faf8f4; }
.board-line strong { font-size: .84rem; }
.board-line small { color: var(--cor-texto-fraco); font-size: .72rem; }

.board-cell { display: grid; gap: 6px; align-content: start; min-height: 92px; }
.board-cell.is-closed { background: #f7f5f1; }
.board-cell.is-overloaded { background: #fdf1ef; }

.load-bar { height: 5px; border-radius: 3px; background: #efeae0; overflow: hidden; }
.load-bar span { display: block; height: 100%; background: #3f7d5f; }
.is-overloaded .load-bar span { background: #c2554a; }
.load-label { color: #5b6862; font-size: .68rem; font-variant-numeric: tabular-nums; }

.board-step {
    display: grid;
    gap: 1px;
    padding: 7px 9px;
    text-align: left;
    border: 1px solid #d9e3dd;
    border-left: 3px solid #3f7d5f;
    border-radius: 7px;
    background: #f4f8f6;
    cursor: pointer;
    font: inherit;
}

.board-step:hover { background: #eaf2ed; }
.board-step strong { font-size: .78rem; }
.board-step small { color: var(--cor-texto-fraco); font-size: .68rem; font-variant-numeric: tabular-nums; }
.board-step .changeover { color: #8a6414; }
.board-step.is-late { border-left-color: #c2554a; background: #fdf1ef; }
.board-step.is-urgent { border-left-color: #d79a52; }
.board-step.is-low { border-left-color: #a8b0aa; }

.shift-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin: 4px 0 14px; }
.shift-day { display: grid; gap: var(--e-1); padding: var(--e-3); border: 1px solid var(--cor-linha); border-radius: var(--raio-m); background: var(--cor-superficie); }
.shift-day.is-closed { background: var(--cor-superficie-fria); }
.shift-day strong { font-size: .78rem; }
.shift-day small { color: var(--cor-texto-fraco); font-size: .74rem; }
/* O «auto-fit» acima escolhe quantas colunas cabem a 130px, mas nada obriga o conteúdo a caber
   nelas: com um formato de hora mais largo — 12 horas, «05:00 AM» — os dois campos e o «até»
   passavam dos 130px e os sete cartões transbordavam por cima uns dos outros. A deixar quebrar,
   o cartão estreita em vez de empurrar. */
.shift-times { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.shift-times input { width: 100%; padding: 5px 7px; font-size: .78rem; }
.shift-times span { color: var(--cor-texto-fraco); font-size: var(--t-s); }
