body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #f4f7fb;
    color: #1f2937;
}

/* ── Planning Matrix ─────────────────────────────────────── */
.pm-toolbar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

/* Row 1: title | scenario | legend */
.pm-toolbar-row1 {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* Row 2: filters (left) | actions (right) */
.pm-toolbar-row2 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 6px 10px;
}
.pm-toolbar-row2-left  { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pm-toolbar-row2-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.pm-title {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: .04em;
    color: #111827;
    margin: 0;
    white-space: nowrap;
}
.pm-legend {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-left: auto;
}
.leg {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 4px;
}
.leg-past    { background: #16a34a; color: #fff; }
.leg-current { background: #d97706; color: #fff; }
.leg-future  { background: #374151; color: #fff; }
.leg-alert   { background: #dc2626; color: #fff; }

.pm-wrapper {
    overflow-x: auto;
    overflow-y: auto;
    max-height: calc(100vh - 110px);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,.08);
}
.pm-empty {
    text-align: center;
    padding: 48px 24px;
    color: #6b7280;
    background: white;
    border-radius: 8px;
}

/* ── Table base ── */
.pm-table {
    border-collapse: collapse;
    font-size: 12px;
    white-space: nowrap;
    min-width: 100%;
    background: #fff;
}
.pm-table .pm-th,
.pm-table .pm-td {
    border: 1px solid #d1d5db;
    padding: 4px 8px;
    text-align: center;
}

/* ── Frozen process column ── */
.pm-th-process,
.pm-td-process {
    text-align: left !important;
    min-width: 180px;
    max-width: 220px;
    white-space: normal;
    position: sticky;
    left: 0;
    z-index: 2;
    background: #fff;
    box-shadow: 2px 0 4px rgba(0,0,0,.06);
}
.pm-th-process {
    background: #1f2937 !important;
    color: #fff;
    z-index: 3;
}

/* ── Sticky header rows ── */
.pm-table thead tr:nth-child(1) th {
    position: sticky;
    top: 0;
    z-index: 2;
}
.pm-table thead tr:nth-child(2) th {
    position: sticky;
    top: 29px;   /* height of row 1 */
    z-index: 2;
}
/* Corner: frozen col + sticky header → highest z-index */
.pm-table thead tr th.pm-th-process {
    z-index: 4 !important;
}

/* ── Week label headers (row 1) ── */
.pm-week-label {
    font-weight: 700;
    font-size: 11px;
    letter-spacing: .03em;
}
.pm-wl-past    { background: #14532d; color: #fff; }
.pm-wl-current { background: #92400e; color: #fff; }
.pm-wl-future  { background: #1f2937; color: #fff; }

/* ── Sub-headers PLAN / REAL (row 2) ── */
.pm-sh { font-size: 10px; font-weight: 700; letter-spacing: .05em; }
.pm-sh-plan           { background: #f9fafb; color: #374151; }
.pm-sh-real-past      { background: #16a34a; color: #fff; }
.pm-sh-real-current   { background: #d97706; color: #fff; }
.pm-sh-real-future    { background: #6b7280; color: #fff; }

/* ── Category section row ── */
.pm-cat-row td {
    background: #1e3a2f;
    color: #d1fae5;
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: 5px 10px;
    position: sticky;
    left: 0;
}

/* ── Data rows ── */
.pm-data-row:hover { background: #f0fdf4; }
.pm-data-row:hover .pm-td-process { background: #f0fdf4; }

/* PLANEJADO cell */
.pm-td-plan { background: #fafafa; }
.pm-td-plan.pm-alert {
    background: #fff1f2;
    border-color: #fca5a5;
}

/* Suggestion sub-display inside a PLANEJADO alert cell */
.pm-val { display: block; }
.pm-suggestion {
    display: block;
    margin-top: 2px;
    color: #dc2626;
    font-weight: 700;
    font-size: 10px;
    line-height: 1.3;
}
.pm-suggestion em {
    font-style: normal;
    background: #dc2626;
    color: #fff;
    border-radius: 3px;
    padding: 1px 4px;
    margin-left: 3px;
    font-size: 9px;
}

/* REALIZADO cells */
.pm-td-real { }
.pm-td-real-past    { background: #f0fdf4; color: #166534; }
.pm-td-real-current { background: #fefce8; color: #92400e; font-weight: 600; }
.pm-td-real-future  { background: #f9fafb; color: #9ca3af; }

/* ── SUGESTÃO columns ─────────────────────────────────────── */
.leg-sugg-ok    { background: #0369a1; color: #fff; }
.leg-sugg-alert { background: #9a3412; color: #fff; }

.pm-wl-sugg {
    background: #1e3a5f;
    color: #bfdbfe;
}
.pm-sh-sugg-val,
.pm-sh-sugg-pct {
    background: #1e3a5f;
    color: #bfdbfe;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .05em;
}

/* SUGESTÃO value cell */
.pm-td-sugg {
    font-weight: 600;
    font-size: 12px;
    min-width: 70px;
}
.pm-td-sugg.pm-sugg-ok    { background: #eff6ff; color: #1e40af; }
.pm-td-sugg.pm-sugg-alert { background: #fff1f2; color: #9a3412; }

/* SUGESTÃO % cell */
.pm-td-sugg-pct {
    font-weight: 600;
    font-size: 12px;
    min-width: 64px;
}
.pm-td-sugg-pct.pm-sugg-ok    { background: #eff6ff; }
.pm-td-sugg-pct.pm-sugg-alert { background: #fff1f2; }

.pm-sugg-badge {
    display: inline-block;
    border-radius: 4px;
    padding: 2px 5px;
    font-size: 11px;
    font-weight: 700;
}
.pm-sugg-badge-ok    { background: #dbeafe; color: #1e40af; }
.pm-sugg-badge-alert { background: #fee2e2; color: #9a3412; }

.pm-sugg-n {
    font-size: 9px;
    color: #9ca3af;
    margin-left: 3px;
}

/* Suggestion legend bar */
.pm-sugg-legend {
    margin-top: 12px;
    font-size: 12px;
    color: #6b7280;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 8px 14px;
}
.pm-sugg-legend strong { color: #374151; }
/* ────────────────────────────────────────────────────────── */

/* ── Toolbar right (legacy — kept for compat) ─────────────── */

.btn-apply-ok {
    background: #0369a1;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: background .15s;
    white-space: nowrap;
}
.btn-apply-ok:hover:not(:disabled) { background: #0284c7; }
.btn-apply-ok:disabled              { background: #9ca3af; cursor: default; }
.btn-apply-ok.btn-applied           { background: #16a34a; }
.btn-archive-excluded {
    background: #e0e7ff; color: #3730a3; border: 1px solid #a5b4fc;
    border-radius: 6px; padding: 6px 12px; font-size: 12px; font-weight: 700;
    cursor: pointer; transition: background .15s; white-space: nowrap;
}
.btn-archive-excluded:hover { background: #c7d2fe; }
.btn-restore-excluded {
    background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7;
    border-radius: 6px; padding: 6px 12px; font-size: 12px; font-weight: 700;
    cursor: pointer; transition: background .15s; white-space: nowrap;
}
.btn-restore-excluded:hover { background: #a7f3d0; }

/* ── Editable planned cells ──────────────────────────────── */
.pm-editable { cursor: pointer; }
.pm-editable:hover { background: #f0f9ff !important; outline: 1px solid #bae6fd; }
.pm-editable.pm-editing { background: #eff6ff !important; padding: 0 !important; }

.pm-inline-input {
    width: 100%;
    height: 100%;
    border: 2px solid #0369a1;
    border-radius: 0;
    padding: 3px 6px;
    font-size: 12px;
    font-weight: 600;
    color: #0369a1;
    background: #eff6ff;
    text-align: center;
    box-sizing: border-box;
    outline: none;
}

/* ── Suggestion approval states ──────────────────────────── */
.pm-sugg-clickable {
    cursor: pointer;
    position: relative;
}
.pm-sugg-clickable:hover {
    filter: brightness(0.93);
}
.pm-sugg-clickable::after {
    content: '▸';
    font-size: 9px;
    margin-left: 4px;
    opacity: .6;
}

.pm-td-sugg.pm-sugg-approved,
.pm-td-sugg-pct.pm-sugg-approved {
    background: #f0fdf4 !important;
    color: #166534;
}
.pm-sugg-badge-approved {
    background: #dcfce7 !important;
    color: #166534 !important;
}

.pm-td-sugg.pm-sugg-discuss,
.pm-td-sugg-pct.pm-sugg-discuss {
    background: #fffbeb !important;
    color: #92400e;
    border-color: #fcd34d !important;
}

/* ── Approval Modal ──────────────────────────────────────── */
.sugg-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 100;
}
.sugg-backdrop.active { display: block; }

.sugg-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 101;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,.22);
    width: 380px;
    max-width: 94vw;
    overflow: hidden;
}
.sugg-modal.active { display: block; }

.sugg-modal-header {
    background: #7f1d1d;
    color: #fff;
    padding: 14px 18px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-weight: 700;
    font-size: 14px;
}
.sugg-modal-icon { font-size: 18px; margin-top: 1px; }
.sugg-modal-title { font-size: 14px; font-weight: 700; }

.sugg-modal-body { padding: 18px 20px 10px; }

.sugg-modal-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 13px;
}
.sugg-modal-label { color: #6b7280; }
.sugg-modal-val   { font-weight: 700; color: #111827; font-size: 15px; }
.sugg-modal-pct   { font-weight: 700; color: #dc2626; font-size: 14px; }

.sugg-modal-process {
    font-size: 12px;
    font-weight: 600;
    color: #fecaca;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 260px;
}

.sugg-modal-val-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}
.sugg-modal-input {
    width: 110px;
    padding: 5px 8px;
    border: 2px solid #d1d5db;
    border-radius: 7px;
    font-size: 15px;
    font-weight: 700;
    text-align: right;
    color: #111827;
    transition: border-color .15s;
}
.sugg-modal-input:focus {
    outline: none;
    border-color: #111827;
}
.sugg-modal-hint {
    font-size: 10px;
    color: #9ca3af;
    font-style: italic;
}

.sugg-modal-desc {
    font-size: 12px;
    color: #4b5563;
    margin: 12px 0 0;
    line-height: 1.5;
    border-top: 1px solid #e5e7eb;
    padding-top: 10px;
}

.sugg-modal-actions {
    padding: 14px 20px 18px;
    display: flex;
    gap: 8px;
}
.btn-sm-approve {
    flex: 1;
    padding: 10px;
    background: #166534;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background .15s;
}
.btn-sm-approve:hover:not(:disabled) { background: #16a34a; }
.btn-sm-approve:disabled { background: #9ca3af; }

.btn-sm-discuss {
    flex: 1;
    padding: 10px;
    background: #92400e;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background .15s;
}
.btn-sm-discuss:hover { background: #b45309; }

.btn-sm-cancel {
    padding: 10px 14px;
    background: #f3f4f6;
    color: #374151;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}
.btn-sm-cancel:hover { background: #e5e7eb; }

/* ── Toast ───────────────────────────────────────────────── */
.pm-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(60px);
    background: #1f2937;
    color: #fff;
    padding: 10px 22px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 4px 16px rgba(0,0,0,.2);
    z-index: 200;
    opacity: 0;
    transition: transform .25s, opacity .25s;
    pointer-events: none;
}
.pm-toast.pm-toast-show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}
.pm-toast.pm-toast-ok   { background: #166534; }
.pm-toast.pm-toast-err  { background: #7f1d1d; }
.pm-toast.pm-toast-warn { background: #92400e; }

/* ── Filter buttons (planning toolbar) ──────────────────── */
.pm-filter-group   { display:flex; align-items:center; gap:4px; }
.pm-filter-btn     { padding:5px 12px; border:1px solid #d1d5db; border-radius:20px;
                     font-size:11px; font-weight:600; cursor:pointer; background:#fff;
                     color:#6b7280; transition:all .15s; white-space:nowrap; }
.pm-filter-btn:hover      { border-color:#9ca3af; color:#111827; }
.pm-filter-btn.pm-filter-active { background:#1f2937; color:#fff; border-color:#1f2937; }
.pm-filter-btn.pm-filter-ok     { border-color:#16a34a; color:#15803d; }
.pm-filter-btn.pm-filter-ok.pm-filter-active  { background:#16a34a; color:#fff; border-color:#16a34a; }
.pm-filter-btn.pm-filter-alert  { border-color:#dc2626; color:#dc2626; }
.pm-filter-btn.pm-filter-alert.pm-filter-active { background:#dc2626; color:#fff; border-color:#dc2626; }
.pm-filter-btn.pm-filter-fav    { border-color:#f59e0b; color:#b45309; }
.pm-filter-btn.pm-filter-fav.pm-filter-active   { background:#f59e0b; color:#fff; border-color:#f59e0b; }

/* ── Category filter dropdown ───────────────────────────── */
.pm-cat-filter-select {
    padding: 5px 28px 5px 10px;
    border: 1px solid #d1d5db;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236b7280'/%3E%3C/svg%3E") no-repeat right 8px center;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
    white-space: nowrap;
}
.pm-cat-filter-select:focus { outline: none; border-color: #6366f1; }

/* ── Process cell with star, name, actions ──────────────── */
.pm-process-cell     { display:flex; align-items:center; gap:5px; }
.pm-process-name     { flex:1; min-width:0; }
.pm-star             { cursor:pointer; font-size:13px; color:#d1d5db; transition:color .15s; flex-shrink:0; user-select:none; }
.pm-star:hover       { color:#f59e0b; }
.pm-star.active      { color:#f59e0b; }
.pm-process-actions  { display:flex; gap:2px; opacity:0; transition:opacity .15s; flex-shrink:0; }
.pm-td-process:hover .pm-process-actions { opacity:1; }
.pm-btn-exclude, .pm-btn-delete, .pm-btn-archive {
    width: 19px; height: 19px; border: none; border-radius: 4px;
    cursor: pointer; font-size: 12px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    padding: 0; transition: background .15s; line-height: 1;
}
.pm-btn-exclude               { background: #fef3c7; color: #92400e; }
.pm-btn-exclude:hover         { background: #fcd34d; }
.pm-btn-delete                { background: #fee2e2; color: #991b1b; }
.pm-btn-delete:hover          { background: #fca5a5; }
.pm-btn-archive               { background: #e0e7ff; color: #3730a3; font-size: 11px; }
.pm-btn-archive:hover         { background: #c7d2fe; }

/* ── Excluded process row ───────────────────────────────── */
.pm-data-row.pm-excluded                    { opacity: 0.35; }
.pm-data-row.pm-excluded .pm-process-name   { text-decoration: line-through; }

/* ── RFQ columns ─────────────────────────────────────────── */
.pm-wl-rfq {
    background: #78350f;
    color: #fde68a;
    border-color: #92400e;
}
.pm-sh-rfq, .pm-sh-rfq-pct {
    background: #92400e;
    color: #fef3c7;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .04em;
}
.pm-td-rfq {
    background: #fffbeb;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: #78350f;
    border-left: 2px solid #fde68a;
}
.pm-td-rfq-pct {
    background: #fffbeb;
    text-align: center;
    font-size: 12px;
}
.pm-rfq-badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
}
.pm-rfq-badge-ok    { background: #d1fae5; color: #065f46; }
.pm-rfq-badge-alert { background: #fee2e2; color: #991b1b; }

/* ── Share section ─────────────────────────────────────── */

/* Nível 0 — cabeçalho SHARE geral */
.pm-share-cat-row td {
    background: #1e293b;
    color: #7dd3fc;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
    padding: 7px 14px;
}
.pm-share-cat-row td .pm-share-cat-sub {
    font-size: 10px;
    font-weight: 400;
    color: #64748b;
    margin-left: 8px;
    text-transform: none;
    letter-spacing: 0;
}

/* Nível 0.5 — grupo pai (RECEIVE, PACK, etc.) */
.pm-share-parent-row td {
    background: #0f172a;
    color: #e2e8f0;
    font-size: 11px;
    font-weight: 700;
    padding: 5px 14px;
    letter-spacing: .05em;
    text-transform: uppercase;
}

/* Nível 1 — sub-grupo (Receive Each, Receive LP, etc.) */
.pm-share-subcat-row td {
    background: #f1f5f9;
    color: #334155;
    font-size: 12px;
    font-weight: 600;
    font-style: italic;
    border-left: 3px solid #3b82f6;
    padding: 5px 10px 5px 16px !important;
    border-bottom: 1px solid #e2e8f0;
}
.pm-share-subcat-row td:first-child { padding-left: 22px !important; }
.pm-share-subcat-row.pm-excluded { opacity: 0.35; }
.pm-share-subcat-row.pm-excluded .pm-process-name { text-decoration: line-through; }

/* Nível 2 — processo individual */
.pm-share-row        { background: #fff; border-bottom: 1px solid #f1f5f9; }
.pm-share-row:hover  { background: #f8fafc; }
.pm-share-row.pm-excluded { opacity: 0.35; }
.pm-share-row.pm-excluded .pm-process-name { text-decoration: line-through; }

.pm-share-star       { cursor: pointer; font-size: 12px; color: #cbd5e1; margin-right: 3px; user-select: none; }
.pm-share-star.active { color: #f59e0b; }
.pm-share-name-cell  { font-size: 12px; padding-left: 32px !important; color: #475569; }
.pm-share-val-cell   { font-size: 12px; color: #374151; }
.pm-share-editable   { cursor: pointer; }
.pm-share-editable:hover { background: #eff6ff !important; }

/* Botões do header */
.pm-share-cfg-btn {
    margin-left: 8px;
    padding: 3px 10px;
    font-size: 11px;
    background: #1e3a5f;
    color: #93c5fd;
    border: 1px solid #2563eb;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
}
.pm-share-cfg-btn:hover { background: #2563eb; color: #fff; }

/* % realizado — texto simples */
.pm-share-pct {
    font-size: 12px;
    font-weight: 600;
    color: #1e40af;
}

/* % planejado — texto com cor roxa */
.pm-share-plan-pct {
    font-size: 12px;
    font-weight: 600;
    color: #7c3aed;
}

/* ── Discuss textarea (step 2 modal) ────────────────────── */
.sugg-modal-discuss-label {
    margin: 0 0 8px;
    font-size: 13px;
    color: #6b7280;
}
.pm-discuss-textarea {
    width: 100%;
    min-height: 80px;
    padding: 8px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    color: #374151;
    resize: vertical;
    font-family: inherit;
    box-sizing: border-box;
}
.pm-discuss-textarea:focus { outline: none; border-color: #6366f1; }

/* ── Scenario selector (planning toolbar) ───────────────── */
.pm-scenario-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}
.pm-scenario-selector select {
    padding: 6px 10px;
    border: 1px solid #d1d5db;
    border-radius: 7px;
    font-size: 12px;
    color: #374151;
    background: #fff;
    cursor: pointer;
}
.pm-scenario-selector select:focus { outline: none; border-color: #6366f1; }

.pm-sc-active-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    letter-spacing: .03em;
}
.pm-sc-clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #e5e7eb;
    color: #6b7280;
    font-size: 11px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: background .15s;
}
.pm-sc-clear:hover { background: #fecaca; color: #991b1b; }

/* ── Scenario week columns ───────────────────────────────── */
.pm-wl-scenario {
    font-size: 11px;
    font-weight: 700;
    text-align: center;
    letter-spacing: .05em;
    white-space: nowrap;
}
.pm-sh-scenario {
    font-size: 10px;
    font-weight: 700;
    text-align: center;
    color: #374151;
    white-space: nowrap;
    padding: 5px 8px;
}
.pm-td-scenario {
    text-align: right;
    font-size: 12px;
    color: #374151;
    background: #f5f3ff;
    white-space: nowrap;
    padding: 6px 10px;
    font-weight: 500;
}

/* ── History week columns (shown when no scenario active) ── */
.pm-wl-history {
    font-size: 11px;
    font-weight: 700;
    text-align: center;
    letter-spacing: .05em;
    white-space: nowrap;
    background: #f0fdf4;
    color: #166534;
    border-color: #86efac;
}
.pm-sh-history {
    font-size: 10px;
    font-weight: 700;
    text-align: center;
    color: #166534;
    white-space: nowrap;
    padding: 5px 8px;
    border-bottom: 3px solid #86efac;
}
.pm-td-history {
    text-align: right;
    font-size: 12px;
    color: #166534;
    background: #f0fdf4;
    white-space: nowrap;
    padding: 6px 10px;
    font-weight: 500;
}

/* ── Current week: PLANEJADO locked + REALIZADO clicável ──── */
.pm-td-plan-locked {
    text-align: right;
    font-size: 13px;
    color: #6b7280;
    background: #f9fafb;
    white-space: nowrap;
    padding: 6px 10px;
}
.pm-actual-editable {
    cursor: pointer;
}
.pm-actual-editable:hover {
    background: #fef9c3 !important;
}
.pm-actual-editable.pm-actual-filled {
    background: #dcfce7 !important;
    color: #166534;
    font-weight: 600;
}
.btn-close-week {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    background: #7c3aed;
    color: #fff;
    transition: background .15s, opacity .15s;
    white-space: nowrap;
}
.btn-close-week:disabled {
    background: #d1d5db;
    color: #9ca3af;
    cursor: not-allowed;
    opacity: .7;
}
.btn-close-week:not(:disabled):hover {
    background: #6d28d9;
}

.btn-export-matrix {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: .82rem;
    background: #0d6efd;
    color: #fff;
    text-decoration: none;
    transition: background .15s;
    white-space: nowrap;
}
.btn-export-matrix:hover {
    background: #0b5ed7;
    color: #fff;
}

/* ── Scenario register page ──────────────────────────────── */
.sc-pos-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #374151;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
}
.sc-list { display: flex; flex-direction: column; gap: 12px; }

.sc-card {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 14px 16px;
    background: #fafafa;
}
.sc-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    padding-left: 8px;
}
.sc-card-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.sc-card-name { font-size: 13px; font-weight: 700; color: #111827; }
.sc-card-desc { font-size: 12px; color: #6b7280; margin: 0 0 8px; }

.sc-weeks-row { display: flex; flex-wrap: wrap; gap: 6px; }
.sc-week-chip {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 12px;
    border: 1.5px solid;
    background: #fff;
}
.btn-sc-delete {
    padding: 3px 8px;
    background: transparent;
    border: 1px solid #fca5a5;
    color: #dc2626;
    border-radius: 6px;
    font-size: 11px;
    cursor: pointer;
    transition: background .15s;
}
.btn-sc-delete:hover { background: #fee2e2; }

.btn-sc-apply {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    text-decoration: none;
    transition: opacity .15s;
}
.btn-sc-apply:hover { opacity: .85; }

/* legend item for scenario */
.leg-sugg-ok    { background: #1d4ed8; color: #fff; }
.leg-sugg-alert { background: #dc2626; color: #fff; }

/* ── Process Register Page ──────────────────────────────── */
.reg-page { max-width: 900px; }

.reg-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 0;
}
.reg-tab {
    padding: 9px 20px;
    font-size: 13px;
    font-weight: 600;
    color: #6b7280;
    text-decoration: none;
    border-radius: 8px 8px 0 0;
    border: 1px solid transparent;
    border-bottom: none;
    margin-bottom: -2px;
    transition: color .15s, background .15s;
}
.reg-tab:hover { color: #111827; background: #f3f4f6; }
.reg-tab-active {
    color: #111827;
    background: #fff;
    border-color: #e5e7eb;
    border-bottom-color: #fff;
}
.reg-header { margin-bottom: 24px; }
.reg-title   { font-size: 20px; font-weight: 700; margin: 0 0 6px; color: #111827; }
.reg-subtitle { color: #6b7280; margin: 0; font-size: 14px; }

.reg-grid {
    display: grid;
    grid-template-columns: 1fr 1.4fr;
    gap: 20px;
    align-items: start;
}
@media (max-width: 700px) { .reg-grid { grid-template-columns: 1fr; } }

.reg-form-card { }
.reg-list-card { overflow-x: auto; }

.form-group { margin-bottom: 14px; }
.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.form-group select,
.form-group input[type="text"],
.form-group input[type="number"],
.form-group textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #d1d5db;
    border-radius: 7px;
    font-size: 13px;
    color: #111827;
    background: #fff;
    box-sizing: border-box;
    transition: border-color .15s;
}
.form-group select:focus,
.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #111827;
}

.category-preview {
    margin-top: 6px;
    font-size: 12px;
    color: #0369a1;
    font-weight: 600;
    min-height: 18px;
}

.btn-register {
    width: 100%;
    padding: 11px;
    background: #111827;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
    margin-top: 4px;
}
.btn-register:hover { background: #374151; }

/* ── Category remap banner ── */
.remap-banner      { padding:16px 20px; margin-bottom:20px; border-left:4px solid #f59e0b;
                     background:#fffbeb; }
.remap-banner-title{ font-size:13px; font-weight:700; color:#92400e; margin-bottom:12px; }
.remap-form        { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.remap-select      { padding:8px 12px; border:1px solid #d1d5db; border-radius:6px;
                     font-size:13px; flex:1; min-width:180px; }
.remap-arrow       { font-size:18px; color:#6b7280; font-weight:700; }
.btn-remap         { padding:8px 18px; background:#f59e0b; color:#fff; border:none;
                     border-radius:6px; font-size:13px; font-weight:600; cursor:pointer; }
.btn-remap:hover   { background:#d97706; }

/* ── Import XLSX page ─────────────────────────────────────── */
.xi-card-title { font-size:15px; font-weight:700; margin:0 0 8px; color:#111827; }
.xi-card-desc  { font-size:13px; color:#6b7280; margin:0 0 18px; line-height:1.5; }
.xi-form       { display:flex; flex-direction:column; gap:14px; }
.xi-field      { display:flex; flex-direction:column; gap:5px; }
.xi-label      { font-size:12px; font-weight:600; text-transform:uppercase;
                 letter-spacing:.05em; color:#374151; }
.xi-select     { padding:9px 12px; border:1px solid #d1d5db; border-radius:7px;
                 font-size:13px; color:#111827; background:#fff; }
.xi-select:focus { outline:none; border-color:#6366f1; box-shadow:0 0 0 3px #ede9fe; }
.xi-file-wrap  { display:flex; align-items:center; gap:10px; }
.xi-file-btn   { display:inline-block; padding:7px 14px; background:#f3f4f6;
                 border:1px solid #d1d5db; border-radius:6px; font-size:12px;
                 font-weight:600; cursor:pointer; color:#374151; }
.xi-file-btn:hover { background:#e5e7eb; }
.xi-file-wrap input[type="file"] { display:none; }
.xi-file-name  { font-size:12px; color:#6b7280; flex:1; overflow:hidden;
                 text-overflow:ellipsis; white-space:nowrap; }
.xi-hint       { margin-top:16px; padding:10px 14px; background:#f9fafb;
                 border-left:3px solid #6366f1; border-radius:4px;
                 font-size:11px; color:#6b7280; line-height:1.6; }
.xi-hint code  { background:#ede9fe; color:#4f46e5; padding:1px 5px;
                 border-radius:3px; font-size:11px; }
.xi-textarea   { width:100%; padding:9px 12px; border:1px solid #d1d5db;
                 border-radius:7px; font-size:13px; font-family:monospace;
                 resize:vertical; color:#111827; }
.xi-textarea:focus { outline:none; border-color:#6366f1; box-shadow:0 0 0 3px #ede9fe; }
.xi-btn-download { width:100%; margin-top:16px; background:#0f766e !important; }
.xi-btn-download:hover { background:#0d6660 !important; }
.xi-card       { padding:24px; }

/* ── Import XLSX page ─────────────────────────────────────── */

.reg-table { font-size: 12px; }
.reg-table th { font-size: 11px; background: #1f2937; color: #fff; }
.reg-table .badge-cat {
    display: inline-block;
    background: #1e3a2f;
    color: #d1fae5;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
}
/* ────────────────────────────────────────────────────────── */

/* ── Import / Upload Page ────────────────────────────────── */
.import-page { max-width: 1100px; }

.import-header { margin-bottom: 24px; }
.import-title  { font-size: 20px; font-weight: 700; margin: 0 0 6px; color: #111827; }
.import-subtitle { color: #6b7280; margin: 0; font-size: 14px; }

.import-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
@media (max-width: 700px) { .import-grid { grid-template-columns: 1fr; } }

.import-card { position: relative; padding-top: 28px !important; }

.import-step-badge {
    position: absolute;
    top: -14px;
    left: 20px;
    width: 28px;
    height: 28px;
    background: #111827;
    color: #fff;
    border-radius: 50%;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.import-card-title { font-size: 15px; font-weight: 700; margin: 0 0 8px; }
.import-card-desc  { font-size: 13px; color: #374151; margin: 0 0 16px; line-height: 1.5; }
.import-hint       { font-size: 11px; color: #9ca3af; margin: 10px 0 0; }

/* Format preview */
.template-format {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    font-size: 11px;
    margin-bottom: 16px;
}
.format-header, .format-row {
    display: grid;
    grid-template-columns: 1.4fr 1.8fr 1fr 0.8fr 0.8fr;
    gap: 0;
}
.format-header span, .format-row span {
    padding: 5px 8px;
    border-right: 1px solid #e5e7eb;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.format-header span:last-child, .format-row span:last-child { border-right: none; }
.format-header { background: #1f2937; color: #fff; font-weight: 700; }
.format-row-alt { background: #f9fafb; }

/* Download button */
.btn-download {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #111827;
    color: #fff;
    text-decoration: none;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    transition: background .15s;
}
.btn-download:hover { background: #374151; }

/* Drop zone */
.drop-zone {
    border: 2px dashed #d1d5db;
    border-radius: 12px;
    padding: 32px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color .2s, background .2s;
    margin-bottom: 14px;
    position: relative;
}
.drop-zone:hover, .drop-zone.dz-hover { border-color: #111827; background: #f9fafb; }
.drop-zone.dz-has-file { border-color: #16a34a; border-style: solid; background: #f0fdf4; }

.dz-icon   { font-size: 36px; margin-bottom: 8px; }
.dz-text   { font-size: 14px; font-weight: 600; color: #374151; margin: 0 0 4px; }
.dz-sub    { font-size: 12px; color: #9ca3af; margin: 0; }
.dz-ready  { color: #16a34a !important; font-weight: 600; }
.dz-selected { display: flex; flex-direction: column; align-items: center; }
.dz-filename { font-size: 13px; font-weight: 600; color: #111827; margin: 4px 0; word-break: break-all; }

/* Upload button */
.btn-upload {
    width: 100%;
    padding: 12px;
    background: #111827;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}
.btn-upload:hover:not(:disabled) { background: #374151; }
.btn-upload:disabled { background: #9ca3af; cursor: not-allowed; }

/* Progress overlay */
.upload-progress {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,.85);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: 14px;
    color: #374151;
    font-weight: 600;
}
.progress-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #e5e7eb;
    border-top-color: #111827;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Result card */
.result-card {
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
}
.result-ok   { background: #f0fdf4; border: 1px solid #86efac; }
.result-warn { background: #fffbeb; border: 1px solid #fde68a; }

.result-header {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 16px;
    color: #111827;
}
.result-icon { font-size: 20px; }

.result-stats { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }

.stat-chip {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}
.stat-saved { background: #dcfce7; color: #166534; }
.stat-total { background: #e0e7ff; color: #3730a3; }
.stat-error { background: #fee2e2; color: #991b1b; }

.error-list {
    margin-top: 12px;
    font-size: 13px;
    color: #374151;
}
.error-list summary {
    cursor: pointer;
    font-weight: 600;
    color: #b45309;
    margin-bottom: 8px;
}
.error-list ul { margin: 8px 0 0 16px; padding: 0; }
.error-list li { margin-bottom: 4px; }

.btn-link {
    display: inline-block;
    margin-top: 16px;
    font-size: 13px;
    color: #374151;
    text-decoration: none;
    font-weight: 600;
}
.btn-link:hover { color: #111827; }
/* ────────────────────────────────────────────────────────── */
.topbar {
    background: #111827;
    color: white;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.topbar nav a {
    color: white;
    margin-left: 16px;
    text-decoration: none;
}
.container {
    padding: 24px;
}
.card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    margin-bottom: 20px;
}
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}
table {
    width: 100%;
    border-collapse: collapse;
}
th, td {
    border: 1px solid #e5e7eb;
    padding: 10px;
    text-align: left;
}
th {
    background: #f9fafb;
}
.flash {
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 16px;
}
.flash.success { background: #dcfce7; }
.flash.danger { background: #fee2e2; }
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
}
.login-card {
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
input, button {
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
}
button {
    background: #111827;
    color: white;
    cursor: pointer;
}
