/* ===================== Phase 2 additions ===================== */
.modal.lg { width: min(1080px, 100%); }

/* multi-select dropdown */
.msel { position: relative; display: inline-block; min-width: 150px; }
.msel-btn { width: 100%; display: flex; align-items: center; gap: 8px; padding: 8px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; font: inherit; font-size: 13px; cursor: pointer; text-align: left; color: var(--muted); }
.msel.has-value .msel-btn { border-color: var(--accent); color: var(--text); background: #f0f9ff; font-weight: 600; }
.msel-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msel-badge:not(:empty) { background: var(--accent); color: #fff; border-radius: 999px; font-size: 11px; padding: 0 7px; font-weight: 700; }
.msel-caret { color: var(--muted-2); font-size: 11px; }
.msel-panel { display: none; position: absolute; z-index: 40; top: calc(100% + 4px); left: 0; min-width: 100%; width: 260px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: 8px; }
.msel.open .msel-panel { display: block; }
.msel-list { max-height: 250px; overflow-y: auto; margin: 6px 0; }
.msel-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.msel-item:hover { background: var(--surface-2); }
.msel-item input { accent-color: var(--accent); }
.msel-foot { display: flex; justify-content: space-between; border-top: 1px solid var(--border); padding-top: 6px; }

/* search box with clear button */
.search-clear { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); border: none; background: #e2e8f0; color: var(--muted); width: 20px; height: 20px; border-radius: 50%; cursor: pointer; font-size: 13px; line-height: 1; display: none; }
.search.has-text .search-clear { display: block; }
.toolbar .search input { padding-right: 34px; }

/* filter panel + active filter chips */
.filter-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; display: none; }
.filter-panel.open { display: block; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px 14px; }
.filter-grid .field label { margin-bottom: 3px; }
.filter-grid .msel { display: block; }
.range-pair { display: flex; gap: 6px; }
.range-pair .input { min-width: 0; }
.active-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.fchip { display: inline-flex; align-items: center; gap: 6px; background: #e0f2fe; color: #075985; border-radius: 999px; padding: 3px 6px 3px 11px; font-size: 12px; font-weight: 600; }
.fchip button { border: none; background: rgba(7,89,133,.15); color: #075985; width: 18px; height: 18px; border-radius: 50%; cursor: pointer; font-size: 12px; line-height: 1; }
.chip-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chip-group .chip-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--muted-2); margin-right: 2px; }
.preset-row { display: flex; flex-wrap: wrap; gap: 6px 22px; margin-bottom: 12px; }
.result-bar { display: flex; align-items: center; gap: 10px; margin: 4px 0 10px; font-size: 13px; color: var(--muted); }
.result-bar b { color: var(--text); }
.cell-note { max-width: 320px; white-space: normal; font-size: 12.5px; color: var(--text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cell-sub { font-size: 11px; color: var(--muted-2); }
.opp-no { font-family: Consolas, monospace; font-size: 12px; color: var(--brand-600); font-weight: 700; white-space: nowrap; }

/* detail panel: contact block + notes */
.detail-panel .detail-grid { grid-template-columns: repeat(4, minmax(0,1fr)); }
.detail-panel .d-item.wide2 { grid-column: span 2; }
.detail-panel .d-item.wide4 { grid-column: 1 / -1; }
.notes-box { margin-top: 16px; border-top: 1px dashed var(--border); padding-top: 14px; display: grid; grid-template-columns: minmax(260px, 1fr) minmax(300px, 1.6fr); gap: 18px; }
.notes-box h4 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.note-history { max-height: 300px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.note-item { background: #fff; border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 8px; padding: 8px 12px; }
.note-item.legacy { border-left-color: var(--muted-2); background: var(--surface-2); }
.note-item .note-meta { font-size: 11px; color: var(--muted-2); margin-bottom: 3px; display: flex; gap: 8px; flex-wrap: wrap; }
.note-item .note-body { white-space: pre-wrap; font-size: 13px; }
.note-tag { background: #e2e8f0; color: #475569; border-radius: 999px; padding: 0 7px; font-size: 10px; font-weight: 700; }

/* opportunity form sections */
.form-section { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; overflow: hidden; }
.form-section > .fs-head { background: var(--surface-2); padding: 9px 14px; font-weight: 700; font-size: 13px; color: var(--brand-700); border-bottom: 1px solid var(--border); }
.form-section > .fs-body { padding: 14px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field .hint { font-size: 11px; color: var(--muted-2); margin-top: 3px; }
.field .err { font-size: 11.5px; color: var(--red); margin-top: 3px; }
.input.invalid, .select.invalid { border-color: var(--red); background: #fef2f2; }

/* lookup manager */
.lk-layout { display: grid; grid-template-columns: 230px 1fr; gap: 16px; align-items: start; }
.lk-types { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; position: sticky; top: 76px; }
.lk-types a { display: flex; justify-content: space-between; padding: 9px 12px; border-radius: 8px; color: var(--text); cursor: pointer; font-weight: 600; font-size: 13px; }
.lk-types a:hover { background: var(--surface-2); text-decoration: none; }
.lk-types a.active { background: var(--brand); color: #fff; }
.lk-types a small { opacity: .7; font-weight: 500; }
.lk-table td { vertical-align: middle; }
.lk-table .input, .lk-table .select { padding: 5px 8px; font-size: 12.5px; }
.lk-handle { cursor: grab; color: var(--muted-2); user-select: none; font-size: 15px; }
tr.lk-drag-over td { border-top: 2px solid var(--accent); }
tr.lk-inactive td { opacity: .55; }
.swatches { display: flex; flex-wrap: wrap; gap: 4px; max-width: 220px; }
.swatch { width: 18px; height: 18px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; }
.swatch.on { border-color: var(--brand-700); box-shadow: 0 0 0 2px #fff inset; }
.toggle { position: relative; display: inline-block; width: 34px; height: 19px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .slider { position: absolute; inset: 0; background: #cbd5e1; border-radius: 999px; transition: .15s; cursor: pointer; }
.toggle .slider::before { content: ''; position: absolute; width: 15px; height: 15px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: .15s; }
.toggle input:checked + .slider { background: var(--green); }
.toggle input:checked + .slider::before { transform: translateX(15px); }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tabs .chip { padding: 7px 16px; }
@media (max-width: 960px) {
  .lk-layout { grid-template-columns: 1fr; } .lk-types { position: static; }
  .notes-box { grid-template-columns: 1fr; } .detail-panel .detail-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .form-grid.three { grid-template-columns: 1fr; }
}
