.mg-note,.mg-copy-intro,.mg-import-intro{grid-column:1/-1;padding:10px 12px;border:1px solid #ead6c9;border-left:3px solid var(--orange);border-radius:7px;background:#fff7f1;color:#70442f;font-size:12px;line-height:1.5}
.mg-note p,.mg-copy-intro p,.mg-import-intro p{margin-top:4px}
.mg-wide{grid-column:1/-1}
.mg-muted{color:var(--muted);font-size:12px;line-height:1.5}
.mg-history{display:grid;gap:9px;padding:11px;border:1px solid var(--line);border-radius:8px;background:var(--surface-soft)}
.mg-history h3,.mg-panel-title h2,.mg-selection h3,.mg-selective h3{font-size:13px}
.mg-history-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.mg-history-grid>div{display:grid;align-content:start;gap:6px}
.mg-history-row{display:flex;min-width:0;justify-content:space-between;gap:9px;padding:7px 0;border-top:1px solid var(--line);font-size:12px}
.mg-history-row small{overflow-wrap:anywhere;text-align:right}
.mg-protection{padding:11px;border:1px solid var(--line);border-radius:8px;background:var(--surface-soft)}
.mg-protection>p{margin:4px 0 8px;color:var(--muted);font-size:12px}
.mg-unit-list{display:grid;grid-template-columns:repeat(auto-fill,minmax(145px,1fr));gap:6px;max-height:220px;overflow:auto}
.mg-unit{display:flex;min-width:0;flex-wrap:wrap;align-items:center;gap:5px 8px;padding:8px;border:1px solid var(--line);border-radius:6px;background:var(--surface);font-size:12px}
.mg-unit b{overflow-wrap:anywhere}
.mg-unit span{margin-left:auto;color:var(--muted);font-size:11px}
.mg-unit small{flex-basis:100%;color:#9b4435;line-height:1.35}
.mg-unit.is-protected{background:var(--surface-soft)}
.mg-preview{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:7px;padding:10px;border:1px solid var(--line);border-radius:8px;background:var(--surface-soft)}
.mg-stat{display:grid;gap:3px;padding:8px;border-radius:6px;background:var(--surface)}
.mg-stat b{font-size:19px;font-variant-numeric:tabular-nums}
.mg-stat small{font-size:10px}
.mg-preview ul{grid-column:1/-1;margin:3px 0 0;padding:8px 0 0 18px;border-top:1px solid var(--line);font-size:12px;line-height:1.55}
.mg-critical{padding:11px;border:1px solid #e7bdb4;border-radius:8px;background:#fff1ee;color:#813d32;font-size:12px;line-height:1.5}
.mg-critical p{margin-top:4px;overflow-wrap:anywhere}
.mg-confirm,.mg-check{display:flex;min-width:0;align-items:flex-start;gap:9px;padding:8px 4px;color:var(--ink);font-size:12px;line-height:1.45}
.mg-confirm input,.mg-check input{width:18px;height:18px;flex:none;margin:0;accent-color:var(--orange)}
.mg-confirm{grid-column:1/-1;border-top:1px solid var(--line);padding-top:12px;font-weight:650}
.mg-selection{display:grid;gap:5px;padding:10px;border:1px solid var(--line);border-radius:8px;background:var(--surface-soft)}
.mg-selection h3{margin-bottom:3px}
.mg-selection .mg-check{padding:5px;border-bottom:1px solid var(--line)}
.mg-selection .mg-check:last-child{border-bottom:0}
.mg-copy-counts{display:flex;flex-wrap:wrap;align-items:center;gap:6px 12px;padding:10px;border:1px solid var(--line);border-left:3px solid var(--orange);border-radius:7px;background:var(--surface-soft);font-size:12px}
.mg-copy-counts span{color:var(--muted)}
.mg-copy-counts strong{color:var(--ink);font-variant-numeric:tabular-nums}
.mg-template-entry{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:11px 13px;border:1px solid var(--line);border-left:3px solid var(--orange);border-radius:8px;background:var(--surface)}
.mg-template-entry>div{display:grid;gap:3px}
.mg-template-entry small,.mg-template-meta small{color:var(--muted);font-size:11px}
.mg-template-list{display:grid;gap:8px;margin-bottom:12px}
.mg-template-card,.mg-batch{display:grid;gap:10px;padding:11px;border:1px solid var(--line);border-radius:8px;background:var(--surface)}
.mg-template-meta{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:3px 8px}
.mg-template-meta small{grid-column:1/-1;overflow-wrap:anywhere}
.mg-pill{display:inline-flex;align-items:center;padding:3px 7px;border-radius:99px;background:var(--surface-soft);color:var(--muted);font-size:10px}
.mg-pill.is-active{background:#e8f3ec;color:#26734e}
.mg-actions{display:flex;flex-wrap:wrap;gap:6px}
.mg-actions a,.mg-button{display:inline-flex;min-height:35px;align-items:center;padding:7px 10px;border:1px solid var(--line);border-radius:7px;background:var(--surface);color:var(--ink);font-size:12px;text-decoration:none}
.mg-mapping{display:grid;gap:11px;padding:12px;border:1px solid var(--line);border-radius:8px;background:var(--surface-soft)}
.mg-header-request input{max-width:150px}
.mg-header-request small{max-width:620px;color:var(--muted);font-size:11px;line-height:1.45}
.mg-column-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:9px}
.mg-required{margin-left:5px;color:#9b4435;font-size:10px}
.mg-required-fields{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:3px;border:1px solid var(--line);border-radius:7px}
.mg-required-fields legend{padding:0 5px;color:var(--muted);font-size:11px}
.mg-template-list+.primary{width:100%}
.mg-import-summary{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:6px}
.mg-import-summary>div{display:grid;gap:2px;padding:8px;border:1px solid var(--line);border-radius:7px;background:var(--surface-soft)}
.mg-import-summary b{font-size:18px;font-variant-numeric:tabular-nums}
.mg-import-summary small{font-size:10px}
.mg-row-list{display:grid;max-height:42dvh;gap:7px;overflow:auto}
.mg-import-row{display:grid;gap:6px;padding:9px;border:1px solid var(--line);border-radius:7px;background:var(--surface)}
.mg-import-row.has-error{border-left:3px solid #a43e37}
.mg-import-row.has-warning{border-left:3px solid #bd7727}
.mg-row-top{display:grid;grid-template-columns:65px minmax(0,1fr);gap:6px;align-items:start;font-size:12px}
.mg-row-top span{overflow-wrap:anywhere}
.mg-row-map{display:flex;flex-wrap:wrap;gap:5px 12px;color:var(--muted);font-size:11px}
.mg-row-errors,.mg-row-warnings{margin:0;padding-left:19px;font-size:11px;line-height:1.45}
.mg-row-errors{color:#9f3932}
.mg-row-warnings{color:#8d571b}
.mg-duplicates{padding:6px;border-radius:5px;background:#fff6e8;color:#80571e;font-size:11px;overflow-wrap:anywhere}
.mg-selective{display:grid;gap:5px;padding:10px;border:1px solid #ead6c9;border-radius:8px;background:#fff7f1;font-size:12px;line-height:1.5}
.mg-selective>div{color:var(--muted);font-size:11px}
.mg-import-history{margin-top:12px}
.mg-panel-title,.mg-batch-head{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:8px}
.mg-batch-head>div{display:grid;gap:3px;min-width:0}
.mg-batch-head small{color:var(--muted);font-size:11px}
.mg-empty{padding:18px;border:1px dashed var(--line);border-radius:8px;background:var(--surface-soft);color:var(--muted);font-size:12px;text-align:center}
.mg-error{color:var(--red);font-size:12px}
.dark .mg-note,.dark .mg-copy-intro,.dark .mg-import-intro,.dark .mg-selective{border-color:#705541;background:#39332d;color:#f1d2bd}
.dark .mg-critical{border-color:#79543f;background:#40352f;color:#f4d8c5}
.dark .mg-unit,.dark .mg-stat,.dark .mg-template-card,.dark .mg-batch,.dark .mg-import-row{background:var(--surface)}
.dark .mg-pill.is-active{background:#304238;color:#a9dfba}
@media(max-width:600px){
  dialog button{min-height:44px}
  .mg-history-grid,.mg-column-grid,.mg-required-fields{grid-template-columns:1fr}
  .mg-import-summary{grid-template-columns:repeat(2,minmax(0,1fr))}
  .mg-unit-list{grid-template-columns:repeat(2,minmax(0,1fr))}
  .mg-template-entry{align-items:flex-start;flex-direction:column}
  .mg-template-entry button,.mg-actions>*{min-height:44px}
  .mg-actions{display:grid;grid-template-columns:1fr}
  .mg-actions a,.mg-button{justify-content:center;min-height:44px}
  .mg-preview{grid-template-columns:repeat(3,minmax(0,1fr))}
  .mg-preview .mg-stat{padding:6px}
  .mg-stat b{font-size:16px}
  .mg-row-list{max-height:38dvh}
}
@media(prefers-reduced-motion:reduce){.mg-template-card,.mg-button{transition:none}}
@media(max-width:850px){
  #modal label:has(input[type=checkbox]){min-height:44px;padding-top:8px;padding-bottom:8px}
}
