.mes-card {
    border: 1px solid rgb(229 231 235);
    border-radius: 0.75rem;
    padding: 1.25rem;
    background: #fff;
}

.dark .mes-card {
    border-color: rgb(55 65 81);
    background: rgb(31 41 55);
}

.mes-muted {
    color: rgb(107 114 128);
    font-size: 0.875rem;
}

.mes-card__title {
    margin-bottom: 1rem;
    font-size: 1.125rem;
    font-weight: 600;
}

.mes-tree__root,
.mes-tree__row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
}

.mes-tree__root {
    background: rgb(239 246 255);
}

.dark .mes-tree__root {
    background: rgb(30 58 138 / 0.25);
}

.mes-tree__row:hover {
    background: rgb(249 250 251);
}

.dark .mes-tree__row:hover {
    background: rgb(55 65 81 / 0.5);
}

.mes-tree__toggle {
    width: 1.25rem;
    border: 0;
    background: none;
    color: rgb(156 163 175);
    cursor: pointer;
}

.mes-tree__bullet {
    width: 1.25rem;
    text-align: center;
    color: rgb(209 213 219);
}

.mes-tree__name {
    font-size: 0.875rem;
    font-weight: 500;
}

.mes-tree__badge {
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    background: rgb(254 243 199);
    color: rgb(180 83 9);
    font-size: 0.75rem;
}

.mes-tree__total,
.mes-tree__figures {
    margin-left: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.875rem;
}

.mes-tree__figures {
    display: flex;
    gap: 1rem;
}

.mes-tree__line {
    font-weight: 600;
}

.mes-compare__heads {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.mes-compare__head {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    padding: 0.75rem;
    border-radius: 0.5rem;
    background: rgb(249 250 251);
}

.dark .mes-compare__head {
    background: rgb(55 65 81 / 0.5);
}

.mes-compare table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.mes-compare th,
.mes-compare td {
    padding: 0.5rem 0.75rem;
    text-align: left;
}

.mes-compare th {
    border-bottom: 1px solid rgb(229 231 235);
    color: rgb(107 114 128);
    font-weight: 500;
}

.mes-compare .mes-num {
    text-align: right;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.mes-row--added { background: rgb(240 253 244); }
.mes-row--removed { background: rgb(254 242 242); }
.mes-row--changed { background: rgb(255 251 235); }
.dark .mes-row--added { background: rgb(20 83 45 / 0.25); }
.dark .mes-row--removed { background: rgb(127 29 29 / 0.25); }
.dark .mes-row--changed { background: rgb(120 53 15 / 0.25); }

.mes-pill {
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
}

.mes-pill--added { background: rgb(220 252 231); color: rgb(21 128 61); }
.mes-pill--removed { background: rgb(254 226 226); color: rgb(185 28 28); }
.mes-pill--changed { background: rgb(254 243 199); color: rgb(180 83 9); }

.mes-compare__total {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgb(229 231 235);
    text-align: right;
    font-weight: 500;
}

.mes-diff--up { color: rgb(220 38 38); }
.mes-diff--down { color: rgb(22 163 74); }

.mes-card__subtitle {
    margin: 1rem 0 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
}

.mes-button {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    border: 0;
    border-radius: 0.5rem;
    color: #fff;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
}

.mes-button:disabled { opacity: 0.5; cursor: not-allowed; }
.mes-button--primary { background: rgb(37 99 235); }
.mes-button--success { background: rgb(22 163 74); }
.mes-button--warning { background: rgb(217 119 6); }
.mes-button--danger { background: rgb(220 38 38); }
.mes-button--gray { background: rgb(107 114 128); }

.mes-timer__clock {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    margin-bottom: 1rem;
}

.mes-timer__display {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 2.25rem;
    font-weight: 700;
}

.mes-timer__actions {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
}

.mes-timer__entries {
    max-height: 16rem;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    list-style: none;
}

.mes-timer__entry {
    display: flex;
    gap: 0.75rem;
    justify-content: space-between;
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
}

.mes-timer__entry:nth-child(odd) { background: rgb(249 250 251); }
.dark .mes-timer__entry:nth-child(odd) { background: rgb(55 65 81 / 0.5); }

.mes-num {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.mes-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
}

.mes-field__label {
    color: rgb(55 65 81);
    font-size: 0.75rem;
    font-weight: 500;
}

.dark .mes-field__label { color: rgb(209 213 219); }

.mes-field__error {
    color: rgb(220 38 38);
    font-size: 0.75rem;
}

.mes-input {
    width: 100%;
    padding: 0.375rem 0.625rem;
    border: 1px solid rgb(209 213 219);
    border-radius: 0.5rem;
    background: #fff;
    color: inherit;
    font-size: 0.875rem;
}

.dark .mes-input {
    border-color: rgb(75 85 99);
    background: rgb(55 65 81);
}

.mes-inspection__checkpoint {
    margin: 0 0 1rem;
    padding: 0.75rem 1rem;
    border: 1px solid rgb(229 231 235);
    border-radius: 0.5rem;
}

.mes-inspection__checkpoint--missing { border-color: rgb(252 211 77); background: rgb(255 251 235); }
.dark .mes-inspection__checkpoint { border-color: rgb(55 65 81); }
.dark .mes-inspection__checkpoint--missing { border-color: rgb(217 119 6); background: rgb(120 53 15 / 0.15); }

.mes-inspection__name {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    padding: 0 0.25rem;
    font-weight: 600;
}

.mes-inspection__criteria {
    margin: 0.5rem 0;
    padding: 0.375rem 0.625rem;
    border-radius: 0.375rem;
    background: rgb(239 246 255);
    color: rgb(29 78 216);
    font-size: 0.75rem;
}

.dark .mes-inspection__criteria { background: rgb(30 58 138 / 0.25); color: rgb(147 197 253); }

.mes-inspection__fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
    gap: 0.75rem;
}

.mes-inspection__actions {
    display: flex;
    justify-content: flex-end;
}

.mes-lot__timeline {
    position: relative;
    margin: 0;
    padding: 0 0 0 1.5rem;
    list-style: none;
}

.mes-lot__timeline::before {
    position: absolute;
    top: 0.25rem;
    bottom: 0.25rem;
    left: 0.4rem;
    width: 2px;
    background: rgb(229 231 235);
    content: "";
}

.dark .mes-lot__timeline::before { background: rgb(55 65 81); }

.mes-lot__event {
    position: relative;
    margin-bottom: 1rem;
}

.mes-lot__dot {
    position: absolute;
    top: 0.3rem;
    left: -1.35rem;
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 9999px;
    background: rgb(156 163 175);
}

.mes-lot__event--created .mes-lot__dot { background: rgb(37 99 235); }
.mes-lot__event--inspection .mes-lot__dot { background: rgb(22 163 74); }

.mes-lot__description {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 500;
}

.mes-board__toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 1rem;
}

.mes-board__filter { width: auto; min-width: 12rem; }

.mes-board {
    display: flex;
    gap: 1rem;
    padding-bottom: 1rem;
    overflow-x: auto;
}

.mes-board__column {
    /* Kitölti a szélességet, így 1440 px-en mind az öt állapot látszik; keskenyebb kijelzőn a tábla görget. */
    flex: 1 1 12rem;
    min-width: 12rem;
}

.mes-board__header {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.75rem;
    padding: 0 0.5rem;
}

.mes-board__title {
    flex: 1;
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
}

.mes-board__dot { width: 0.75rem; height: 0.75rem; border-radius: 9999px; background: rgb(107 114 128); }
.mes-board__dot--info { background: rgb(37 99 235); }
.mes-board__dot--warning { background: rgb(217 119 6); }
.mes-board__dot--success { background: rgb(22 163 74); }
.mes-board__dot--danger { background: rgb(220 38 38); }

.mes-board__cards {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 12rem;
    padding: 0.5rem;
    border: 1px dashed rgb(229 231 235);
    border-radius: 0.5rem;
    background: rgb(249 250 251);
}

.dark .mes-board__cards { border-color: rgb(55 65 81); background: rgb(31 41 55 / 0.5); }

.mes-board__card {
    padding: 0.75rem;
    border: 1px solid rgb(229 231 235);
    border-radius: 0.5rem;
    background: #fff;
    cursor: grab;
}

.dark .mes-board__card { border-color: rgb(75 85 99); background: rgb(55 65 81); }
.mes-board__card--ghost { opacity: 0.3; }

.mes-board__card-head,
.mes-board__meta {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.75rem;
}

.mes-board__card-head { flex-wrap: wrap; }

/* A kódok nem törnek: szűk oszlopban a rendelésszám a munkalapszám alá kerül. */
.mes-board__card-head > * { white-space: nowrap; }

.mes-board__code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-weight: 600;
}

.mes-board__operation {
    margin: 0.5rem 0;
    font-size: 0.875rem;
    font-weight: 500;
}

.mes-board__assignee { margin-top: 0.5rem; font-size: 0.75rem; }

.mes-gantt { min-height: 24rem; overflow-x: auto; }
/* A frappe a konténert pontosan a sorok magasságára méretezi: a vízszintes görgetősáv a legalsó sorra
   kerülne (vagy belső függőleges görgetést okozna). Az alsó belső margó a görgetősáv helye. */
.mes-gantt .gantt-container { box-sizing: content-box; padding-bottom: 1.25rem; }
/* Legfeljebb képernyőnyi magas: sok munkalapnál a diagram belül görget függőlegesen (a frappe dátumfejléce
   sticky, fent marad), a vízszintes görgetősáv pedig a képernyőn belül, a diagram alján látszik. A frappe a
   magasságot inline adja meg, a max-height ezt korlátozza. */
.mes-gantt .gantt-container { max-height: calc(100vh - 22rem); min-height: 16rem; overflow: auto; overscroll-behavior: auto; }
.mes-gantt__zoom {display: flex; align-items: center; justify-content: flex-end; gap: 0.5rem; margin-bottom: 0.75rem; }
.mes-gantt__zoom .mes-button { padding: 0.25rem 0.75rem; background: rgb(75 85 99); font-size: 1rem; line-height: 1.25rem; }
.mes-gantt__zoom-level { min-width: 3.5rem; text-align: center; font-size: 0.875rem; font-variant-numeric: tabular-nums; }
/* A frappe .gantt .bar-wrapper .bar szabálya a később betöltött mes-gantt.css-ben van: ezért erősebb szelektor. */
.mes-gantt .gantt .bar-wrapper.mes-gantt-bar--pending .bar { fill: rgb(107 114 128); }
.mes-gantt .gantt .bar-wrapper.mes-gantt-bar--in_progress .bar { fill: rgb(217 119 6); }
.mes-gantt .gantt .bar-wrapper.mes-gantt-bar--done .bar { fill: rgb(22 163 74); }
.mes-gantt .gantt .bar-wrapper.mes-gantt-bar--cancelled .bar { fill: rgb(220 38 38); opacity: 0.6; }
.mes-gantt .gantt .bar-wrapper.mes-gantt-bar--ready .bar { fill: rgb(37 99 235); }
/* A haladás áttetsző sötétítés, hogy alatta az állapot színe látsszon (a kész munkalap 100%-os). */
.mes-gantt .gantt .bar-wrapper .bar-progress { fill: rgb(0 0 0 / 0.25); }

.mes-capacity__row { margin-bottom: 1rem; }

.mes-capacity__head {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
}

.mes-capacity__name { font-weight: 500; }
.mes-capacity__minutes { margin-left: auto; }
.mes-capacity__value { font-weight: 600; }
.mes-capacity__value--high { color: rgb(220 38 38); }

.mes-capacity__track {
    width: 100%;
    height: 0.75rem;
    border-radius: 9999px;
    background: rgb(229 231 235);
}

.dark .mes-capacity__track { background: rgb(55 65 81); }

.mes-capacity__bar { height: 0.75rem; border-radius: 9999px; background: rgb(37 99 235); }
.mes-capacity__bar--normal { background: rgb(22 163 74); }
.mes-capacity__bar--medium { background: rgb(217 119 6); }
.mes-capacity__bar--high { background: rgb(220 38 38); }

.mes-capacity__conflicts { margin-top: 1.5rem; border-color: rgb(254 202 202); }

.mes-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.mes-table th,
.mes-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid rgb(229 231 235);
    text-align: left;
}

.dark .mes-table th,
.dark .mes-table td { border-color: rgb(55 65 81); }

.mes-scanner__input {
    display: flex;
    gap: 0.5rem;
}

.mes-scanner__input .mes-input { font-size: 1.125rem; }

.mes-scanner__result {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    border: 1px solid rgb(229 231 235);
    border-radius: 0.5rem;
    font-size: 0.875rem;
}

.mes-scanner__result p { margin: 0.25rem 0; }
.mes-scanner__result--work-order { border-color: rgb(191 219 254); background: rgb(239 246 255); }
.mes-scanner__result--found { border-color: rgb(187 247 208); background: rgb(240 253 244); }
.mes-scanner__result--warning { border-color: rgb(253 230 138); background: rgb(255 251 235); }
.mes-scanner__result--missing { border-color: rgb(254 202 202); background: rgb(254 242 242); }
.dark .mes-scanner__result { background: rgb(31 41 55); }

.mes-scanner__code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 1.5rem;
    font-weight: 700;
}

.mes-scanner__title { font-weight: 600; }

.mes-scanner__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.mes-scanner__actions .mes-button {
    min-width: 9rem;
    justify-content: center;
    padding: 0.875rem 1.25rem;
    font-size: 1rem;
}

/* A lezárás kétlépéses megerősítése a gomb helyén (tableten a natív confirm-ablak nehezen kezelhető). */
.mes-scanner__confirm,
.mes-scanner__confirm-prompt {
    display: contents;
}

.mes-scanner__confirm-prompt > span {
    align-self: center;
    flex-basis: 100%;
    font-weight: 600;
}

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