/* Matrix Tracker - manpower portal screens. Builds on app.css tokens. */

#manpowerPage {
    display: grid;
    gap: 22px;
    padding: 28px;
}

#manpowerPage[hidden] {
    display: none;
}

.mp-hero-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.mp-panel {
    padding: 0;
}

.mp-panel-head {
    padding: 18px 22px 0;
}

.mp-panel-head h3 {
    margin: 0;
    font-size: 1rem;
}

.mp-attention {
    margin: 0;
    padding: 14px 22px 20px;
    list-style: none;
    display: grid;
    gap: 10px;
}

.mp-attention li {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--warning) 10%, var(--surface));
    border-inline-start: 3px solid var(--warning);
}

.mp-attention a {
    color: var(--primary);
    font-weight: 600;
    margin-inline-start: 6px;
}

.mp-calm {
    margin: 0;
    padding: 14px 22px 20px;
    color: var(--muted);
}

.mp-sub {
    display: block;
    color: var(--muted);
    font-size: .8rem;
    margin-top: 2px;
}

.mp-chip {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 600;
    white-space: nowrap;
}

.mp-chip-success {
    color: var(--success);
    background: color-mix(in srgb, var(--success) 12%, var(--surface));
}

.mp-chip-warning {
    color: #9a6208;
    background: color-mix(in srgb, var(--warning) 16%, var(--surface));
}

.mp-chip-danger {
    color: var(--danger);
    background: color-mix(in srgb, var(--danger) 12%, var(--surface));
}

.mp-chip-muted {
    color: var(--muted);
    background: var(--surface-soft);
}

.mp-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.mp-small {
    padding: 6px 12px;
    min-height: 0;
    font-size: .82rem;
}

.users-icon-action.mp-small {
    padding: 6px;
}

.mp-danger {
    background: var(--danger);
    border-color: var(--danger);
}

/* dialog */

.mp-overlay {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(11, 18, 32, .45);
}

.mp-dialog {
    width: min(620px, 100%);
    max-height: calc(100vh - 40px);
    overflow: auto;
    background: var(--surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: grid;
    grid-template-rows: auto 1fr auto auto;
}

.mp-dialog header,
.mp-dialog footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 18px 22px;
}

.mp-dialog header {
    border-bottom: 1px solid var(--border);
}

.mp-dialog header h3 {
    margin: 0;
    font-size: 1.05rem;
}

.mp-dialog footer {
    border-top: 1px solid var(--border);
    justify-content: flex-end;
}

.mp-dialog-body {
    padding: 18px 22px;
    display: grid;
    gap: 14px;
}

.mp-dialog-alert {
    margin: 0 22px;
}

.mp-note {
    margin: 0;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    background: var(--primary-soft);
    color: var(--text);
    font-size: .88rem;
    line-height: 1.7;
}

.mp-timeline {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 12px;
}

.mp-timeline li {
    display: grid;
    gap: 4px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.mp-timeline span,
.mp-timeline small {
    color: var(--muted);
    font-size: .85rem;
}

@media (max-width: 720px) {
    #manpowerPage {
        padding: 16px;
    }

    .mp-actions {
        justify-content: flex-start;
    }
}

/* text areas in dialogs match the drawer inputs */
.mp-dialog .drawer-field textarea {
    display: block;
    width: 100%;
    min-height: 84px;
    padding: .7rem .9rem;
    border: 1px solid #dce3eb;
    border-radius: 11px;
    background: white;
    color: var(--text);
    font: inherit;
    resize: vertical;
    outline: none;
}

.mp-dialog .drawer-field textarea:focus {
    border-color: #6bb5c7;
    box-shadow: 0 0 0 4px rgba(23, 107, 135, .08);
}

.mp-dialog .drawer-field > small {
    display: block;
    margin-top: .35rem;
    color: var(--muted);
    font-size: .75rem;
}

/* shared by provider screens */
#providerPage {
    display: grid;
    gap: 22px;
    padding: 28px;
}

#providerPage[hidden] {
    display: none;
}

.mp-inset {
    margin: 14px 22px 0;
}

.mp-form-section {
    margin: 6px 0 0;
    font-size: .9rem;
    color: var(--text);
}

@media (max-width: 720px) {
    #providerPage {
        padding: 16px;
    }
}

/* products (t201/t202) */
#productsPage { display: grid; gap: 22px; padding: 28px; }
#productsPage[hidden] { display: none; }
.pd-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; padding: 18px; }
.pd-card { display: grid; grid-template-rows: auto 1fr; text-align: start; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); padding: 0; overflow: hidden; cursor: pointer; font: inherit; color: inherit; }
.pd-card:disabled { cursor: default; }
.pd-card:hover:not(:disabled) { border-color: var(--primary); }
.pd-card-inactive { opacity: .6; }
.pd-thumb { position: relative; aspect-ratio: 1 / 1; max-width: 100%; background: var(--surface-soft); display: grid; place-items: center; overflow: hidden; }
.pd-thumb img { width: 100%; height: 100%; object-fit: contain; }
.pd-thumb-placeholder { width: 40%; height: 40%; fill: none; stroke: var(--muted-2); stroke-width: 1.5; }
.pd-thumb-loaded .pd-thumb-placeholder { display: none; }
.pd-card-body { display: grid; gap: 4px; padding: 10px 12px 12px; }
.pd-code { font-size: .75rem; color: var(--muted); direction: ltr; text-align: end; }
.pd-name { font-size: .88rem; line-height: 1.5; }
.pd-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.pd-pack { font-size: .75rem; color: var(--muted); }
.pd-price { font-weight: 700; color: var(--primary-strong); }
.pd-barcode { color: var(--muted); font-size: .72rem; }
.pd-dialog-picture { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 14px; align-items: start; }
.pd-check { display: flex; gap: 8px; align-items: center; font-size: .85rem; }
.pd-changes, .pd-notes { margin: 0; padding-inline-start: 16px; font-size: .8rem; }
.pd-from { color: var(--muted); text-decoration: line-through; }
.pd-error { color: var(--danger); }
.pd-warning { color: #9a6208; }
.pd-row-error { background: color-mix(in srgb, var(--danger) 5%, var(--surface)); }
@media (max-width: 720px) { #productsPage { padding: 16px; } .pd-dialog-picture { grid-template-columns: 1fr; } }
.pd-preview td:nth-child(5), .pd-price { white-space: nowrap; }

/* checklists (t204) */
#checklistsPage { display: grid; gap: 22px; padding: 28px; }
#checklistsPage[hidden] { display: none; }
.ck-list { display: grid; gap: 14px; }
.ck-card { padding: 18px 22px; display: grid; gap: 12px; }
.ck-head { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; align-items: flex-start; }
.ck-head h3 { margin: 0; font-size: 1rem; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ck-items { margin: 0; padding-inline-start: 20px; display: grid; gap: 6px; font-size: .9rem; }
.ck-items li { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ck-required { color: var(--danger); font-weight: 600; }
.ck-editor { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.ck-row { display: grid; grid-template-columns: 190px minmax(0, 1fr) auto 64px auto; gap: 8px; align-items: center; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.ck-row select, .ck-row input[type="text"], .ck-row input[type="number"] { min-width: 0; width: 100%; height: 38px; padding: 0 .6rem; border: 1px solid #dce3eb; border-radius: 9px; font: inherit; background: white; color: var(--text); }
.ck-row-actions { display: flex; gap: 4px; }
@media (max-width: 720px) { #checklistsPage { padding: 16px; } .ck-row { grid-template-columns: 1fr 1fr; } .ck-row .ck-label { grid-column: 1 / -1; } }
.mp-dialog:has(.ck-editor) { width: min(900px, 100%); }
.ck-row { grid-template-columns: 210px minmax(0, 1fr) auto 64px auto; }
.ck-row .users-icon-action.mp-small { width: 32px; height: 32px; padding: 0; display: grid; place-items: center; }

/* routes (t205) */
#routesPage { display: grid; gap: 22px; padding: 28px; }
#routesPage[hidden] { display: none; }
.rt-card { padding: 18px 22px; display: grid; gap: 10px; }
.rt-stops { margin: 0; padding-inline-start: 22px; display: grid; gap: 6px; font-size: .9rem; }
.rt-stops li { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.rt-removed { opacity: .55; text-decoration: line-through; }
.rt-date { display: flex; gap: 10px; align-items: center; font-weight: 600; }
.rt-date input { height: 40px; padding: 0 .7rem; border: 1px solid #dce3eb; border-radius: 10px; font: inherit; }
.rt-row { grid-template-columns: minmax(0, 1fr) 110px 110px 170px auto; }
.mp-dialog:has(.rt-editor) { width: min(980px, 100%); }
.rt-row input[type="time"] { min-width: 0; width: 100%; height: 38px; padding: 0 .5rem; border: 1px solid #dce3eb; border-radius: 9px; font: inherit; }
@media (max-width: 720px) { #routesPage { padding: 16px; } .rt-row { grid-template-columns: 1fr 1fr; } .rt-row .rt-outlet { grid-column: 1 / -1; } }

/* field review (t209) */
#fieldPage { display: grid; gap: 22px; padding: 28px; }
#fieldPage[hidden] { display: none; }
.fd-table td, .fd-table th { vertical-align: top; }
.fd-table .mp-chip + .mp-chip, .fd-table small { margin-top: 4px; }
.fd-issues { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.fd-issue { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 12px; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.fd-issue-body { display: grid; gap: 4px; align-content: start; }
.fd-price { font-size: .88rem; }
.fd-items { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.fd-items li { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; }
.fd-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.fd-photo { margin: 0; display: grid; gap: 6px; }
.fd-photo .pd-thumb { aspect-ratio: 4 / 3; }
.fd-photo figcaption { font-size: .78rem; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.fd-log summary { cursor: pointer; color: var(--primary); }
.fd-log ol { font-size: .8rem; color: var(--muted); }
.mp-dialog:has(.fd-photos), .mp-dialog:has(.fd-items) { width: min(980px, 100%); }
.link-button { background: none; border: 0; padding: 0; color: var(--primary); font: inherit; font-size: .82rem; cursor: pointer; text-align: start; }
@media (max-width: 720px) { #fieldPage { padding: 16px; } .fd-issue { grid-template-columns: 80px minmax(0, 1fr); } }

/* ---------------- merchandiser phones and face checks (t304) ---------------- */
.mp-dialog.ph-dialog { width: min(900px, 100%); }
.ph-detail { display: grid; gap: 14px; }
.ph-detail h4 { margin: 0 0 8px; font-size: .95rem; }
.ph-face { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 14px; align-items: start; }
.ph-ref { aspect-ratio: 3 / 4; border-radius: 10px; }
.ph-ref img { object-fit: cover; }
.ph-devices { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 8px; }
.ph-devices li { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; }
.ph-devices li > div:first-child { display: grid; gap: 2px; min-width: 0; }
.ph-code { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 16px; align-items: start; padding: 12px; border: 1px dashed var(--primary); border-radius: 12px; }
.ph-qr { background: #fff; padding: 8px; border-radius: 8px; line-height: 0; }
.ph-qr svg { width: 100%; height: auto; }
.ph-code-text { font-size: 1.25rem; letter-spacing: .12em; direction: ltr; unicode-bidi: isolate; }
.ph-consent p { line-height: 1.8; }
.ph-check { display: flex; gap: 8px; align-items: center; font-weight: 600; }
.ph-camera { display: grid; gap: 10px; }
.ph-stage { position: relative; width: 100%; max-width: 560px; aspect-ratio: 4 / 3; margin: 0 auto; border-radius: 14px; overflow: hidden; background: #000; }
.ph-stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.ph-guide { position: absolute; inset: 0; width: 100%; height: 100%; }
.ph-oval { fill: none; stroke: rgba(255, 255, 255, .55); stroke-width: .7; }
.ph-ring { fill: none; stroke: #9aa7b4; stroke-width: 1.6; stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: 100; transition: stroke-dashoffset .35s, stroke .2s; }
.ph-stage[data-state=near] .ph-ring { stroke: #f2b452; }
.ph-stage[data-state=ok] .ph-ring { stroke: #3fd17f; }
.ph-hint { position: absolute; inset-inline: 0; bottom: 10px; margin: 0 auto; width: max-content; max-width: 92%; padding: 6px 14px; border-radius: 999px; background: rgba(4, 12, 20, .75); color: #fff; font-weight: 600; text-align: center; }
.ph-count { position: absolute; top: 10px; inset-inline-start: 10px; padding: 3px 10px; border-radius: 999px; background: rgba(4, 12, 20, .75); color: #fff; font-size: .85rem; }
.ph-stage.ph-flash::after { content: ""; position: absolute; inset: 0; background: #fff; opacity: .7; }
.ph-shots { display: flex; gap: 8px; flex-wrap: wrap; }
.ph-shots img { width: 96px; height: 128px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.ph-file { cursor: pointer; }
.ph-zoom { display: grid; place-items: center; z-index: 1200; cursor: zoom-out; }
.ph-zoom figure { margin: 0; display: grid; gap: 8px; max-width: min(520px, 92vw); }
.ph-zoom img { width: 100%; border-radius: 12px; background: #000; min-height: 120px; }
.ph-zoom figcaption { color: #fff; text-align: center; font-size: .85rem; }
@media (max-width: 720px) {
    .ph-face, .ph-code { grid-template-columns: minmax(0, 1fr); }
    .ph-code .ph-qr { max-width: 240px; }
}
