/**
 * Low-confidence review modal (lcr-*)
 *
 * Editorial skin: cream ground, hairline rules, 2px radii, Fraunces display,
 * JetBrains Mono for figures. Nothing here relies on the legacy
 * .codeiq-modal-* rules; the markup uses its own namespace throughout.
 * Fallback values are given so the sheet also stands alone in a testbed.
 */

.lcr-overlay {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(26, 22, 18, 0);
    opacity: 0;
    pointer-events: auto;              /* #codeiq-modal-container is pointer-events:none */
    transition: opacity 180ms ease, background 180ms ease;
    font-family: var(--sans, 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif);
    color: var(--ed-ink, #1a1a1a);
    -webkit-font-smoothing: antialiased;
}
.lcr-overlay.is-open {
    opacity: 1;
    background: rgba(26, 22, 18, 0.45);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

.lcr-modal {
    display: flex;
    flex-direction: column;
    width: min(1040px, 100%);
    max-height: min(88vh, 960px);
    background: #fff;
    border: 1px solid var(--ed-rule, #d4d0c8);
    border-radius: 2px;
    box-shadow: var(--ed-lift-lg, 0 1px 0 #d4d0c8, 0 48px 80px -48px rgba(26, 22, 18, 0.4));
    transform: translateY(12px);
    transition: transform 220ms cubic-bezier(0.2, 0.7, 0.2, 1);
    outline: none;
    overflow: hidden;
}
.lcr-overlay.is-open .lcr-modal { transform: none; }
.lcr-overlay.is-busy .lcr-body,
.lcr-overlay.is-busy .lcr-toolbar { pointer-events: none; opacity: 0.6; }

/* ---- Header ---------------------------------------------------------- */

.lcr-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    padding: 26px 30px 20px;
    border-bottom: 1px solid var(--ed-rule-soft, #e8e4de);
}
.lcr-kicker {
    font-family: var(--mono, 'JetBrains Mono', monospace);
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ed-wine, #9a4054);
    margin-bottom: 8px;
}
.lcr-title {
    margin: 0 0 6px;
    font-family: var(--serif, 'Fraunces', Georgia, serif);
    font-size: 24px;
    font-weight: 400;
    letter-spacing: -0.02em;
    line-height: 1.15;
    color: var(--ed-ink, #1a1a1a);
}
.lcr-lede {
    margin: 0;
    max-width: 62ch;
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--ed-ink-3, #6b6b6b);
}
.lcr-close {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--ed-rule, #d4d0c8);
    border-radius: 999px;
    background: transparent;
    color: var(--ed-ink-3, #6b6b6b);
    cursor: pointer;
    transition: color 160ms ease, border-color 160ms ease, background 160ms ease;
}
.lcr-close:hover { color: var(--ed-ink, #1a1a1a); border-color: var(--ed-rule-strong, #8a8578); background: var(--ed-ivory, #f5f2ed); }

/* ---- Stats strip ----------------------------------------------------- */

.lcr-stats {
    display: flex;
    border-bottom: 1px solid var(--ed-rule-soft, #e8e4de);
    background: var(--ed-cream, #faf8f5);
}
.lcr-stat {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 30px;
    border-right: 1px solid var(--ed-rule-soft, #e8e4de);
    min-width: 0;
}
.lcr-stat:last-child { border-right: 0; }
.lcr-stat[hidden] { display: none; }
.lcr-stat-label {
    font-family: var(--mono, 'JetBrains Mono', monospace);
    font-size: 10px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ed-ink-4, #999);
}
.lcr-stat-value {
    font-family: var(--serif, 'Fraunces', Georgia, serif);
    font-size: 20px;
    line-height: 1;
    color: var(--ed-ink, #1a1a1a);
}
.lcr-stat[data-stat="critical"] .lcr-stat-value { color: var(--ed-rust, #b04a3a); }
.lcr-stat-progress { flex: 1.4 1 0; }
.lcr-meter {
    display: block;
    height: 3px;
    margin-top: 4px;
    background: var(--ed-rule-soft, #e8e4de);
    border-radius: 2px;
    overflow: hidden;
}
.lcr-meter-fill {
    display: block;
    height: 100%;
    width: 0;
    background: var(--ed-sage, #4a7c4a);
    transition: width 260ms ease;
}

/* ---- Toolbar --------------------------------------------------------- */

.lcr-toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 30px;
    border-bottom: 1px solid var(--ed-rule-soft, #e8e4de);
}
.lcr-search {
    flex: 1 1 280px;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 34px;
    padding: 0 12px;
    border: 1px solid var(--ed-rule, #d4d0c8);
    border-radius: 2px;
    background: var(--ed-cream, #faf8f5);
    color: var(--ed-ink-4, #999);
    transition: border-color 160ms ease, background 160ms ease;
}
.lcr-search:focus-within { border-color: var(--ed-salmon, #c4576a); background: #fff; }
.lcr-search input {
    flex: 1;
    min-width: 0;
    border: 0;
    background: transparent;
    font: inherit;
    font-size: 13px;
    color: var(--ed-ink, #1a1a1a);
    outline: none;
}
.lcr-search input::placeholder { color: var(--ed-ink-4, #999); }
.lcr-search input::-webkit-search-cancel-button { -webkit-appearance: none; }

.lcr-filters {
    display: inline-flex;
    border: 1px solid var(--ed-rule, #d4d0c8);
    border-radius: 2px;
    background: #fff;
    overflow: hidden;
}
.lcr-filter {
    appearance: none;
    border: 0;
    border-right: 1px solid var(--ed-rule-soft, #e8e4de);
    background: transparent;
    height: 32px;
    padding: 0 14px;
    font: inherit;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--ed-ink-3, #6b6b6b);
    cursor: pointer;
    transition: background 140ms ease, color 140ms ease;
    white-space: nowrap;
}
.lcr-filter:last-child { border-right: 0; }
.lcr-filter:hover { background: var(--ed-ivory, #f5f2ed); color: var(--ed-ink, #1a1a1a); }
.lcr-filter.is-active { background: var(--ed-ink, #1a1a1a); color: var(--ed-cream, #faf8f5); }

/* ---- Body / list ----------------------------------------------------- */

.lcr-body {
    flex: 1 1 auto;
    min-height: 160px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--ed-rule, #d4d0c8) transparent;
}
.lcr-body::-webkit-scrollbar { width: 8px; }
.lcr-body::-webkit-scrollbar-thumb { background: var(--ed-rule, #d4d0c8); border-radius: 4px; }
.lcr-empty {
    padding: 48px 30px;
    text-align: center;
    font-size: 13.5px;
    color: var(--ed-ink-4, #999);
}

/* Shared row grid: meter | text | amount | account | state */
.lcr-row,
.lcr-group-head {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr) 104px 272px 96px;
    gap: 0 18px;
    align-items: center;
    padding: 12px 30px;
    border-bottom: 1px solid var(--ed-rule-soft, #e8e4de);
}
.lcr-row { min-height: 60px; transition: background 160ms ease; }
.lcr-row:hover { background: var(--ed-cream, #faf8f5); }
.lcr-row.is-decided { background: var(--ed-sage-wash, #edf3ec); }
.lcr-row.is-decided:hover { background: #e5eee4; }
.lcr-row.in-group { padding-left: 62px; background: var(--ed-cream, #faf8f5); }
.lcr-row.in-group:hover { background: var(--ed-ivory, #f5f2ed); }
.lcr-row.in-group.is-decided { background: var(--ed-sage-wash, #edf3ec); }

.lcr-row-main { min-width: 0; }
.lcr-desc {
    font-size: 13.5px;
    font-weight: 500;
    color: var(--ed-ink, #1a1a1a);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.lcr-row-meta,
.lcr-group-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
    margin-top: 3px;
    font-size: 12px;
    color: var(--ed-ink-3, #6b6b6b);
}
.lcr-row-meta > span,
.lcr-group-meta > span { white-space: nowrap; }
.lcr-method { color: var(--ed-ink-4, #999); }
.lcr-group-meta strong { font-weight: 500; color: var(--ed-ink-2, #3d3d3d); }

.lcr-mono { font-family: var(--mono, 'JetBrains Mono', monospace); font-variant-numeric: tabular-nums; }
.lcr-amount {
    text-align: right;
    font-size: 13px;
    color: var(--ed-ink, #1a1a1a);
    white-space: nowrap;
}
.lcr-amount.is-in { color: var(--ed-sage-deep, #3a6238); }

/* Confidence meter */
.lcr-conf { display: flex; flex-direction: column; gap: 5px; }
.lcr-meter-pct {
    font-family: var(--mono, 'JetBrains Mono', monospace);
    font-size: 12px;
    line-height: 1;
    color: var(--ed-ink-2, #3d3d3d);
    font-variant-numeric: tabular-nums;
}
.lcr-meter-track {
    display: block;
    height: 3px;
    width: 48px;
    background: var(--ed-rule-soft, #e8e4de);
    border-radius: 2px;
    overflow: hidden;
}
.lcr-meter-bar { display: block; height: 100%; background: var(--ed-gold, #8a621a); }
.lcr-conf-critical .lcr-meter-bar { background: var(--ed-rust, #b04a3a); }
.lcr-conf-critical .lcr-meter-pct { color: var(--ed-rust, #b04a3a); }
.lcr-conf-unscored .lcr-meter-pct { color: var(--ed-ink-4, #999); }

/* Account select trigger */
.lcr-select {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    height: 34px;
    padding: 0 10px 0 12px;
    border: 1px solid var(--ed-rule, #d4d0c8);
    border-radius: 2px;
    background: #fff;
    font: inherit;
    font-size: 12.5px;
    color: var(--ed-ink, #1a1a1a);
    text-align: left;
    cursor: pointer;
    transition: border-color 140ms ease, background 140ms ease;
}
.lcr-select:hover { border-color: var(--ed-rule-strong, #8a8578); }
.lcr-select.is-active,
.lcr-select:focus-visible { border-color: var(--ed-salmon, #c4576a); outline: none; box-shadow: 0 0 0 2px rgba(196, 87, 106, 0.14); }
.lcr-select.is-empty { color: var(--ed-ink-4, #999); border-style: dashed; }
.lcr-select-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lcr-select svg { flex: 0 0 auto; color: var(--ed-ink-4, #999); }

/* Row state column */
.lcr-row-state { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }

.lcr-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 22px;
    padding: 0 8px;
    border: 1px solid var(--ed-rule, #d4d0c8);
    border-radius: 2px;
    font-family: var(--mono, 'JetBrains Mono', monospace);
    font-size: 10.5px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ed-ink-3, #6b6b6b);
    background: #fff;
    white-space: nowrap;
}
.lcr-tag-done { color: var(--ed-sage-deep, #3a6238); border-color: rgba(74, 124, 74, 0.35); background: var(--ed-sage-wash, #edf3ec); }
.lcr-tag-error { color: var(--ed-rust, #b04a3a); border-color: rgba(176, 74, 58, 0.35); background: var(--ed-rust-wash, #f9ebe7); }
.lcr-tag-busy { color: var(--ed-ink-3, #6b6b6b); }
.lcr-spinner {
    width: 10px;
    height: 10px;
    border: 1.5px solid var(--ed-rule, #d4d0c8);
    border-top-color: var(--ed-ink-2, #3d3d3d);
    border-radius: 50%;
    animation: lcr-spin 700ms linear infinite;
}
@keyframes lcr-spin { to { transform: rotate(360deg); } }

/* ---- Groups ---------------------------------------------------------- */

.lcr-group-head {
    grid-template-columns: 20px 64px minmax(0, 1fr) 272px 96px;
    background: #fff;
    position: relative;
}
.lcr-group.is-done .lcr-group-head { background: var(--ed-sage-wash, #edf3ec); }
.lcr-group-toggle {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
    color: var(--ed-ink-4, #999);
    cursor: pointer;
    border-radius: 2px;
    transition: transform 160ms ease, color 140ms ease;
}
.lcr-group-toggle:hover { color: var(--ed-ink, #1a1a1a); background: var(--ed-ivory, #f5f2ed); }
.lcr-group.is-open .lcr-group-toggle { transform: rotate(90deg); }
.lcr-group-main { min-width: 0; }
.lcr-group-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.lcr-merchant {
    font-family: var(--serif, 'Fraunces', Georgia, serif);
    font-size: 16px;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.lcr-count {
    font-family: var(--mono, 'JetBrains Mono', monospace);
    font-size: 11px;
    color: var(--ed-ink-4, #999);
    white-space: nowrap;
}
.lcr-group-actions {
    grid-column: 4 / span 2;
    display: grid;
    grid-template-columns: 272px 96px;
    gap: 18px;
    align-items: center;
    justify-items: end;
}
.lcr-group-actions .lcr-select { justify-self: stretch; }
.lcr-group-rows[hidden] { display: none; }

/* ---- Buttons --------------------------------------------------------- */

.lcr-btn {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 36px;
    padding: 0 16px;
    border-radius: 2px;
    border: 1px solid var(--ed-rule, #d4d0c8);
    background: #fff;
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.01em;
    color: var(--ed-ink-2, #3d3d3d);
    cursor: pointer;
    white-space: nowrap;
    transition: background 180ms ease, color 180ms ease, border-color 180ms ease, transform 180ms ease;
}
.lcr-btn:disabled { opacity: 0.45; cursor: default; }
.lcr-btn:focus-visible { outline: 2px solid var(--ed-salmon, #c4576a); outline-offset: 1px; }
.lcr-btn-primary {
    background: var(--ed-ink, #1a1a1a);
    border-color: var(--ed-ink, #1a1a1a);
    color: var(--ed-cream, #faf8f5);
    padding: 0 20px;
}
.lcr-btn-primary:hover:not(:disabled) { background: var(--ed-wine, #9a4054); border-color: var(--ed-wine, #9a4054); transform: translateY(-1px); }
.lcr-btn-secondary:hover:not(:disabled) { background: var(--ed-ivory, #f5f2ed); border-color: var(--ed-rule-strong, #8a8578); color: var(--ed-ink, #1a1a1a); }
.lcr-btn-ghost {
    height: 30px;
    padding: 0 12px;
    font-size: 12.5px;
    background: transparent;
}
.lcr-btn-ghost:hover:not(:disabled) { background: #fff; border-color: var(--ed-rule-strong, #8a8578); color: var(--ed-ink, #1a1a1a); }

/* ---- Footer ---------------------------------------------------------- */

.lcr-foot {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 30px;
    border-top: 1px solid var(--ed-rule-soft, #e8e4de);
    background: var(--ed-cream, #faf8f5);
}
.lcr-foot-note {
    flex: 1;
    text-align: right;
    font-size: 12.5px;
    color: var(--ed-ink-3, #6b6b6b);
}
.lcr-foot-note.is-warn { color: var(--ed-gold, #8a621a); }

/* ---- Picker panel ---------------------------------------------------- */

.lcr-picker {
    position: fixed;
    z-index: 100001;
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid var(--ed-rule-strong, #8a8578);
    border-radius: 2px;
    box-shadow: var(--ed-lift-lg, 0 1px 0 #d4d0c8, 0 48px 80px -48px rgba(26, 22, 18, 0.4));
    overflow: hidden;
    animation: lcr-pop 120ms ease-out;
}
.lcr-picker[hidden] { display: none; }
@keyframes lcr-pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.lcr-picker.opens-up { animation-name: lcr-pop-up; }
@keyframes lcr-pop-up { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.lcr-picker-search {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    height: 40px;
    border-bottom: 1px solid var(--ed-rule-soft, #e8e4de);
    color: var(--ed-ink-4, #999);
    background: var(--ed-cream, #faf8f5);
}
.lcr-picker-search input {
    flex: 1;
    min-width: 0;
    border: 0;
    background: transparent;
    font: inherit;
    font-size: 13px;
    color: var(--ed-ink, #1a1a1a);
    outline: none;
}
.lcr-picker-list {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 4px 0;
    scrollbar-width: thin;
}
.lcr-picker-type {
    position: sticky;
    top: 0;
    padding: 8px 14px 4px;
    font-family: var(--mono, 'JetBrains Mono', monospace);
    font-size: 10px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ed-ink-4, #999);
    background: #fff;
}
.lcr-picker-item {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 7px 14px;
    font-size: 13px;
    cursor: pointer;
    color: var(--ed-ink, #1a1a1a);
}
.lcr-picker-item.is-active { background: var(--ed-wash, #fbecee); }
.lcr-picker-item.is-current .lcr-picker-name::after {
    content: 'current';
    margin-left: 8px;
    font-family: var(--mono, 'JetBrains Mono', monospace);
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ed-ink-4, #999);
}
.lcr-picker-code {
    flex: 0 0 52px;
    font-family: var(--mono, 'JetBrains Mono', monospace);
    font-size: 11.5px;
    color: var(--ed-ink-3, #6b6b6b);
}
.lcr-picker-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lcr-picker-empty { padding: 24px 14px; text-align: center; font-size: 13px; color: var(--ed-ink-4, #999); }

/* ---- Responsive ------------------------------------------------------ */

@media (max-width: 900px) {
    .lcr-overlay { padding: 12px; }
    .lcr-modal { max-height: calc(100vh - 24px); }
    .lcr-head, .lcr-toolbar, .lcr-foot, .lcr-row, .lcr-group-head { padding-left: 18px; padding-right: 18px; }
    .lcr-stat { padding: 10px 18px; }
    .lcr-stat-value { font-size: 17px; }
    .lcr-toolbar { flex-wrap: wrap; }
    .lcr-filters { width: 100%; }
    .lcr-filter { flex: 1; padding: 0 6px; }

    .lcr-row {
        grid-template-columns: 56px minmax(0, 1fr) auto;
        grid-template-areas:
            "conf main amount"
            "conf select state";
        gap: 10px 12px;
    }
    .lcr-row .lcr-conf { grid-area: conf; }
    .lcr-row .lcr-row-main { grid-area: main; }
    .lcr-row .lcr-amount { grid-area: amount; }
    .lcr-row .lcr-row-select { grid-area: select; }
    .lcr-row .lcr-row-state { grid-area: state; }
    .lcr-row.in-group { padding-left: 18px; }

    .lcr-group-head {
        grid-template-columns: 20px 56px minmax(0, 1fr);
        grid-template-areas:
            "toggle conf main"
            "toggle actions actions";
        gap: 10px 12px;
    }
    .lcr-group-toggle { grid-area: toggle; align-self: start; margin-top: 2px; }
    .lcr-group-head .lcr-conf { grid-area: conf; }
    .lcr-group-main { grid-area: main; }
    .lcr-group-actions { grid-area: actions; grid-template-columns: minmax(0, 1fr) auto; width: 100%; }
    .lcr-merchant { font-size: 15px; }
    .lcr-foot { flex-wrap: wrap; }
    .lcr-foot-note { flex-basis: 100%; order: -1; text-align: left; }
}

@media (max-width: 560px) {
    .lcr-stats { flex-wrap: wrap; }
    .lcr-stat { flex-basis: 50%; border-bottom: 1px solid var(--ed-rule-soft, #e8e4de); }
    .lcr-stat-progress { flex-basis: 100%; }
    .lcr-title { font-size: 20px; }
    .lcr-foot .lcr-btn { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .lcr-overlay, .lcr-modal, .lcr-meter-fill, .lcr-picker, .lcr-group-toggle { transition: none; animation: none; }
}

/* The wrapper carries the focus ring; the inner input must show none of the
   global input[type=search]:focus border/glow (main.css) or the dashboard
   :focus-visible outline (codeiq-editorial.css). */
.lcr-overlay .lcr-search input[type="search"],
.lcr-overlay .lcr-search input[type="search"]:hover,
.lcr-overlay .lcr-search input[type="search"]:focus,
.lcr-overlay .lcr-search input[type="search"]:focus-visible,
.lcr-overlay .lcr-picker-search input[type="text"],
.lcr-overlay .lcr-picker-search input[type="text"]:hover,
.lcr-overlay .lcr-picker-search input[type="text"]:focus,
.lcr-overlay .lcr-picker-search input[type="text"]:focus-visible {
    border: 0;
    box-shadow: none;
    outline: none;
    padding: 0;
    border-radius: 0;
    background: transparent;
}
