/* ---------------------------------------------------------------- wizard and design agent (wizard.js, agent.js, importers.js)
   Step 4 of the wizard (mockup C): the matching table with reasons, a searchable field picker and the sample form
   with numbered markers; the agent's wide panel; the import window with two main options (M7). */
:root {
  --wm-ok: #15803d; --wm-ok-bg: #dcfce7; --wm-ok-mark: #2563eb;
  --wm-warn: #b45309; --wm-warn-bg: #fff4e5; --wm-warn-mark: #c2410c;
  --wm-bad: #b91c1c; --wm-bad-bg: #fdecea;
}

/* the matching step uses the whole width: the table and the sample beside it */
.wiz[data-step="match"] { width: min(1320px, 100%); }
.wiz-foot .spacer { display: flex; align-items: center; min-width: 0; padding-inline: 8px; }
.wiz-foot-note { font-size: 12.5px; color: #374151; line-height: 1.4; }
.wiz-foot-note.ok { color: var(--wm-ok); }

.wm { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 34%); gap: 18px; align-items: start; }
.wm-main { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.wm-sum { display: flex; align-items: center; gap: 12px; }
.wm-sum p { margin: 0; font-size: 13px; line-height: 1.45; }
.wm-bar { flex: none; display: flex; width: 120px; height: 8px; border-radius: 999px; overflow: hidden; background: #e5e7eb; }
.wm-bar i { display: block; height: 100%; }
.wm-bar .ok { background: #16a34a; }
.wm-bar .warn { background: #f59e0b; }
.wm-bar .bad { background: #cbd5e1; }
.wm-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.wm-tabs { display: inline-flex; gap: 4px; }
.wm-tab { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 5px 12px; font-size: 13px; min-height: 32px; }
.wm-tab b { margin-inline-start: 2px; }
.wm-tab.on { background: #111827; border-color: #111827; color: #fff; }
.wm-search { flex: 1 1 160px; min-width: 140px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; min-height: 32px; background: var(--panel); }
.wm-approve-all:not(:disabled) { border-color: #86efac; background: #f0fdf4; color: var(--wm-ok); font-weight: 600; }

.wm-table td { padding: 7px 10px; }
.wm-table th:nth-child(1) { width: 30%; }
.wm-table th:nth-child(2) { width: 34%; }
.wm-row { cursor: pointer; }
.wm-row:hover td { background: #fafbfc; }
.wm-row.active td { background: #eff6ff; }
.wm-row.g-none td:first-child { box-shadow: inset -3px 0 0 #ea580c; }
html[dir="ltr"] .wm-row.g-none td:first-child { box-shadow: inset 3px 0 0 #ea580c; }
.wm-row.g-none td { background: #fffbf5; }
.wm-row.g-none.active td { background: #fff3e0; }
.wm-label { display: flex; align-items: flex-start; gap: 8px; }
.wm-label > span { display: flex; flex-direction: column; min-width: 0; }
.wm-num { flex: none; width: 24px; height: 24px; border-radius: 50%; border: 0; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #fff; background: var(--wm-ok-mark); padding: 0; }
.wm-num.g-decide, .wm-num.g-none { background: var(--wm-warn-mark); }
.wm-status { line-height: 1.45; }
.wm-chip { display: inline-block; font-size: 11.5px; font-weight: 600; border-radius: 999px; padding: 1px 9px; white-space: nowrap; }
.wm-chip.ok { background: var(--wm-ok-bg); color: var(--wm-ok); }
.wm-chip.warn { background: var(--wm-warn-bg); color: var(--wm-warn); }
.wm-chip.bad { background: var(--wm-bad-bg); color: var(--wm-bad); }
.wm-why { font-size: 12px; color: #4b5563; }
.wm-status .link { font-size: 12px; margin-inline-start: 4px; }
.wm-foot { margin: 0; }

/* the searchable field picker */
.wm-pick { position: relative; }
.wm-pick-btn { width: 100%; display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); padding: 5px 8px; min-height: 32px; text-align: start; }
.wm-pick-btn:hover { border-color: #93c5fd; }
.wm-pick.empty .wm-pick-btn { border-style: dashed; border-color: #f59e0b; background: #fffbeb; }
.wm-pick-btn .wm-path { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wm-pick-btn small { color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.wm-caret { margin-inline-start: auto; color: var(--muted); font-size: 11px; }
.wm-pop { position: absolute; z-index: 30; inset-inline-start: 0; top: calc(100% + 4px); width: max(100%, 380px); max-width: 80vw; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px rgba(15, 23, 42, .18); padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.wm-pop input { width: 100%; border: 1px solid #93c5fd; border-radius: 8px; padding: 7px 10px; box-shadow: 0 0 0 3px #dbeafe; }
.wm-pop ul { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow: auto; }
.wm-pop-head { font-size: 11.5px; color: var(--muted); padding: 6px 8px 2px; }
.wm-opt { display: flex; align-items: baseline; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.wm-opt bdi { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.wm-opt small { margin-inline-start: auto; color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45%; }
.wm-opt:hover, .wm-opt.active { background: #eff6ff; }
.wm-opt.on { font-weight: 600; }
.wm-opt.on::before { content: '✓'; color: var(--accent); }
.wm-opt.new { color: #1d4ed8; }
.wm-opt.new b { font-weight: 600; }

/* the sample form beside the table */
.wm-side { position: sticky; top: 0; display: flex; flex-direction: column; gap: 8px; }
.wm-side-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.wm-side-head small { color: var(--muted); font-size: 11.5px; }
.wm-pages { display: flex; gap: 4px; flex-wrap: wrap; }
.wm-pages button { border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 2px 8px; font-size: 12px; min-height: 26px; }
.wm-pages button.on { border-color: var(--accent); color: var(--accent); }
.wm-paper { position: relative; width: 100%; background: #fff; border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 4px 14px rgba(15, 23, 42, .1); overflow: hidden; max-height: calc(100vh - 330px); }
.wm-paper img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; }
/* the markers sit on the page in its own coordinates, whatever the interface direction */
.wm-mark { position: absolute; direction: ltr; border: 2px solid var(--wm-ok-mark); background: rgba(37, 99, 235, .08); border-radius: 4px; padding: 0; cursor: pointer; }
.wm-mark.g-decide, .wm-mark.g-none { border-color: var(--wm-warn-mark); background: rgba(234, 88, 12, .12); }
.wm-mark span { position: absolute; top: -9px; right: -9px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--wm-ok-mark); color: #fff; font-size: 10.5px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; padding: 0 4px; }
.wm-mark.g-decide span, .wm-mark.g-none span { background: var(--wm-warn-mark); }
.wm-mark.active { outline: 3px solid #fde047; outline-offset: 1px; z-index: 2; }
.wm-mark:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
.wm-legend { margin: 0; font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.wm-legend span { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.wm-legend .g-ready { background: var(--wm-ok-mark); }
.wm-legend .g-decide { background: var(--wm-warn-mark); }
.wm-legend .g-none { background: #fff; border: 2px solid var(--wm-warn-mark); }

/* narrow windows (iPad portrait, small laptops): the sample goes under the table */
@media (max-width: 1000px) {
  .wm { grid-template-columns: minmax(0, 1fr); }
  .wm-side { position: static; }
  .wm-paper { max-width: 380px; max-height: none; }
  .wiz-foot-note { font-size: 11.5px; }
}
@media (max-width: 820px) {
  .wm-table thead { display: none; }
  .wm-table, .wm-table tbody { display: block; }
  .wm-table tr { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--line-2); }
  .wm-table td { border: 0; }
  .wm-table td.wm-status { grid-column: 1 / -1; padding-top: 0; }
}
@media (pointer: coarse) {
  .wm-tab, .wm-search, .wm-pick-btn, .wm-pages button { min-height: 44px; }
  .wm-opt { min-height: 44px; align-items: center; }
  .wm-num { width: 32px; height: 32px; }
  .wm-status .link { display: inline-flex; align-items: center; min-height: 44px; }
}

/* ---------------------------------------------------------------- import window (M7): two main ways, the rest folded */
.imp-q { margin: 0 0 8px; }
.imp-main { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.imp-main-opt { position: relative; padding: 14px 16px; gap: 6px; min-height: 120px; }
.imp-main-opt b { font-size: 15px; }
.imp-main-opt small { color: var(--muted); font-size: 11.5px; margin-top: auto; }
.imp-main-opt.rec { border-color: #93c5fd; box-shadow: 0 0 0 2px #dbeafe; }
.imp-badge { position: absolute; top: 10px; inset-inline-end: 12px; font-size: 11px !important; font-weight: 600; color: #1d4ed8 !important; background: #dbeafe; border-radius: 999px; padding: 1px 8px; }
.imp-adv { margin: 12px 0 4px; }
.imp-adv summary { cursor: pointer; color: var(--muted); font-size: 13px; padding: 4px 0; }
.imp-adv[open] summary { margin-bottom: 8px; }
.imp-adv .choice { padding: 9px 12px; }
@media (max-width: 640px) { .imp-main { grid-template-columns: 1fr; } }
@media (pointer: coarse) { .imp-adv summary { min-height: 44px; display: flex; align-items: center; } }

/* ---------------------------------------------------------------- the design agent: one-line basic mode, wide panel */
.ag-basic { padding: 6px 10px; }
.ag-basic summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12.5px; }
.ag-basic summary::-webkit-details-marker { display: none; }
.ag-basic p { margin: 6px 0 0; }
.ag-badge-basic { font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 8px; background: #fed7aa; color: #9a3412; }
.ag-wizard-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.ag-wizard-top .link { font-size: 12px; white-space: nowrap; }
.ag-elsewhere { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; padding: 6px 2px; font-size: 13px; }
.ag-elsewhere p { margin: 0; color: var(--muted); }
.ag-at { font-size: 10.5px; color: var(--muted); margin-inline-start: 6px; }
.ag-msg.user .ag-at { display: block; margin: 2px 0 0; }

.ag-dock { position: fixed; z-index: 60; display: flex; background: var(--panel); border-inline-end: 1px solid var(--line); box-shadow: 0 0 0 1px rgba(15, 23, 42, .04), 0 18px 40px rgba(15, 23, 42, .18); }
.ag-dock[hidden] { display: none; }
.ag-dock-grip { position: absolute; inset-block: 0; inset-inline-end: -5px; width: 10px; cursor: col-resize; z-index: 2; touch-action: none; }
.ag-dock-grip::after { content: ''; position: absolute; inset-block: 0; inset-inline-start: 4px; width: 2px; background: transparent; transition: background .15s; }
.ag-dock-grip:hover::after, .ag-dock-grip:focus-visible::after { background: var(--accent); }
.ag-dock-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; overflow: hidden; }
.ag-dock-head { display: flex; align-items: center; gap: 6px; }
.ag-dock-head h2 { margin: 0; font-size: 15px; }
.ag-dock-head .spacer { flex: 1; }
.ag-dock-head .icon-btn { border: 0; background: none; width: 32px; height: 32px; border-radius: 8px; font-size: 15px; color: var(--muted); }
.ag-dock-head .icon-btn:hover { background: var(--panel-2); color: var(--text); }
.ag-dock-tools summary { cursor: pointer; font-size: 12.5px; color: var(--muted); }
.ag-dock-tools[open] { display: flex; flex-direction: column; gap: 6px; }
.ag-history { flex: 1; min-height: 120px; display: flex; flex-direction: column; gap: 6px; border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.ag-history-head { display: flex; align-items: baseline; gap: 8px; }
.ag-history-head .link { margin-inline-start: auto; font-size: 12px; }
.ag-dock .ag-chat { max-height: none; flex: 1; min-height: 0; }
.ag-dock .ag-msg { font-size: 13px; }
.ag-preview { border: 1px solid #93c5fd; background: #f5f9ff; border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.ag-preview-head { display: flex; flex-direction: column; gap: 1px; font-size: 13px; }
.ag-preview-head .muted { font-size: 12px; }
.ag-preview ul { list-style: none; margin: 0; padding: 0; max-height: 150px; overflow: auto; display: flex; flex-direction: column; gap: 2px; }
.ag-chg .link { text-align: start; font-size: 12.5px; color: var(--text); text-decoration: none; }
.ag-chg .link:hover { text-decoration: underline; }
.ag-chg.added b { color: var(--ok); }
.ag-chg.updated b { color: #1d4ed8; }
.ag-chg.deleted b { color: var(--danger); }
.ag-chg small { color: var(--muted); }
.ag-preview p { margin: 0; font-size: 12px; }
.ag-compose { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--line-2); padding-top: 8px; }
.ag-ctx small { color: var(--muted); font-size: 11.5px; display: block; margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-ctx-chips { display: flex; flex-wrap: wrap; gap: 4px; max-height: 92px; overflow: auto; }
.ag-ctx-chips .chip { text-align: start; }
.ag-compose textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; resize: vertical; background: var(--panel-2); min-height: 64px; }
.ag-compose .btn-row { align-items: center; }
.ag-compose .spacer { flex: 1; }
.ag-prev-opt { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); cursor: pointer; }
@media (pointer: coarse) {
  .ag-dock-grip { width: 24px; inset-inline-end: -12px; }
  .ag-dock-head .icon-btn { width: 44px; height: 44px; }
  .ag-ctx-chips .chip, .ag-chg .link { min-height: 44px; }
}
