/* MapTrax MMS — shared modal styling.
   Used by the "Create Prospect from selection" flow first; other MMS
   dialogs reuse the same primitives. Fortress reskin: navy command
   header, white body, gold primary CTA, outline secondary. */

.mms-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 15, 0.55);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(2px);
}

.mms-modal {
    width: min(520px, 100%);
    max-height: calc(100vh - 80px);
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.32);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.mms-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 16px;
    background: linear-gradient(180deg, var(--ink-800), var(--ink-950));
    color: var(--text-inverse);
    border-bottom: 1px solid var(--ink-950);
}
.mms-modal-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    font-family: var(--font-display);
    /* Explicit — a global `h3 { color:#333 }` (overlays-controls.css)
       targets the element directly and would otherwise beat the white
       inherited from .mms-modal-header. */
    color: var(--text-inverse);
}
.mms-modal-close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    opacity: 0.85;
}
.mms-modal-close:hover {
    opacity: 1;
}

.mms-modal-body {
    padding: 16px 18px;
    background: var(--bg-surface);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mms-modal-summary {
    background: var(--gold-050);
    border: 1px solid color-mix(in srgb, var(--gold, #c9a962) 40%, transparent);
    color: var(--text-secondary);
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 13px;
}
.mms-modal-empty {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.5;
    padding: 8px;
}
/* v2.13.12.0 — informational note shown when some tracts on the map
 * are already part of an existing asset/prospect (excluded from the
 * new-prospect selection). Quieter visual than the main summary. */
.mms-modal-summary-note {
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 12px;
    font-style: italic;
    padding: 4px 12px;
}

.mms-modal-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12.5px;
    color: var(--text-secondary);
}
.mms-modal-field > span {
    font-weight: 600;
    color: var(--text-primary);
}
.mms-modal-field em {
    font-style: normal;
    font-weight: 400;
    color: var(--text-muted);
    font-size: 11.5px;
}
.mms-modal-field input,
.mms-modal-field select,
.mms-modal-field textarea {
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 8px 10px;
    font-size: 13px;
    background: #fff;
    color: var(--text-primary);
    font-family: inherit;
}
.mms-modal-field input:focus,
.mms-modal-field select:focus,
.mms-modal-field textarea:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px var(--gold-subtle);
}

.mms-modal-status {
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12.5px;
}
.mms-modal-status--info {
    background: #fffbe6;
    color: #6c5500;
    border: 1px solid #f0d878;
}
.mms-modal-status--error {
    background: #fce8e8;
    color: #a02020;
    border: 1px solid #f0b0b0;
}
.mms-modal-status--success {
    background: #e6f5e6;
    color: #2e7a2e;
    border: 1px solid #b3d9b3;
}

.mms-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 4px;
}

.mms-btn {
    padding: 8px 14px;
    border-radius: 4px;
    border: 1px solid var(--border-strong);
    background: #fff;
    color: var(--text-primary);
    box-shadow: var(--shadow-xs);
    font-size: 13px;
    cursor: pointer;
    font-weight: 600;
}
.mms-btn:hover {
    background: var(--bg-tertiary);
}
.mms-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.mms-btn-primary {
    background: var(--gold);
    color: #241c08;
    border-color: var(--gold-muted);
}
.mms-btn-primary:hover {
    background: var(--gold-400);
}
.mms-btn-secondary {
    background: #fff;
}

/* v2.13.7.0 — per-tract financials editor: two-column form grid so
 * the 11 fields don't make the modal a mile long. */
.mms-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 14px;
}
.mms-form-grid > .mms-modal-field {
    margin: 0;
}
@media (max-width: 540px) {
    .mms-form-grid {
        grid-template-columns: 1fr;
    }
}

/* v2.13.7.3 — Inline tract editing in the asset-detail dialog.
 * Replaces the earlier ✏-button-opens-a-modal flow. Every editable
 * cell on an MMS-backed row renders as a compact <input> / <select>
 * that saves on blur (or change, for selects). The classes below
 * style the inputs to look like cells (not form fields) so the table
 * doesn't look noisy. */
.asset-detail-tract-list td.mms-cell {
    padding: 2px 4px !important;
}
.mms-tract-input {
    width: 100%;
    box-sizing: border-box;
    font: inherit;
    color: inherit;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 3px;
    padding: 2px 6px;
    min-width: 50px;
    transition: border-color 0.12s ease, background 0.12s ease;
}
.mms-tract-input:hover {
    border-color: #e0d4b8;
    background: #fff;
}
.mms-tract-input:focus {
    outline: none;
    border-color: #b96c28;
    background: #fff;
    box-shadow: 0 0 0 2px rgba(185, 108, 40, 0.18);
}
.mms-tract-input--num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    min-width: 80px;
    /* v2.13.7.16: per user, no spinner arrows. We use type="text"
       inputmode="decimal" by default now; these rules also strip
       spinners off any stray type="number" so we never regress. */
    -moz-appearance: textfield;
    appearance: textfield;
}
.mms-tract-input--num::-webkit-outer-spin-button,
.mms-tract-input--num::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.mms-tract-input--select {
    cursor: pointer;
    padding: 1px 4px;
    min-width: 70px;
}

/* Save-status visual feedback */
.mms-tract-input.mms-saving {
    border-color: #d4b53a;
    background: #fffbe6;
}
.mms-tract-input.mms-saved {
    border-color: #2e7a2e;
    background: #e6f5e6;
}
.mms-tract-input.mms-failed {
    border-color: #a02020;
    background: #fce8e8;
    color: #6b0000;
}

/* v2.13.7.4 — Edit Tract ✏ button in the first column of MMS rows.
 * Click opens the Quarter Call Editor on top of the asset-detail
 * dialog. mms-above-modal CSS rule below lifts the QC editor's
 * z-index temporarily so it floats in front. */
.mms-edit-tract-cell {
    text-align: center;
    width: 32px;
    padding: 2px 4px !important;
}
.mms-edit-tract-btn {
    background: transparent;
    border: 1px solid transparent;
    color: #7a4d27;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    padding: 3px 7px;
    border-radius: 4px;
}
.mms-edit-tract-btn:hover {
    background: #faf5ed;
    border-color: #d4c5b0;
}

/* Boost the Quarter Call Editor above the asset-detail modal backdrop
 * (z-index 9100). Class is added by mms/editTract.js on launch and
 * removed when the editor closes. */
#quarter-editor.mms-above-modal {
    z-index: 9200 !important;
}

/* ============================================================
   v2.13.15.0 — Kill Outcome modal
   ============================================================
   Opened when the user clicks ✕ Kill on the lifecycle pill bar.
   Asks Killed / Lost / Passed + a date + optional notes. Same
   brown palette as the other MMS modals.
*/
.kill-outcome-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(40, 28, 14, 0.55);
    z-index: 9150;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(2px);
}
.kill-outcome-backdrop.visible {
    display: flex;
}
.kill-outcome-modal {
    width: min(460px, 100%);
    max-height: calc(100vh - 80px);
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.32);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.kill-outcome-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 16px;
    background: linear-gradient(to bottom, #b96c28, #7a4d27);
    color: #fff;
}
.kill-outcome-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}
.kill-outcome-close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    opacity: 0.85;
}
.kill-outcome-close:hover {
    opacity: 1;
}
.kill-outcome-body {
    padding: 16px 18px;
    background: #fbf7f1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.kill-outcome-hint {
    font-size: 12px;
    color: #5c4429;
    line-height: 1.4;
}
.kill-outcome-fieldset {
    border: 1px solid #e0d4c2;
    border-radius: 5px;
    background: #fff;
    padding: 8px 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0;
}
.kill-outcome-fieldset legend {
    font-size: 11px;
    font-weight: 600;
    color: #7a4d27;
    padding: 0 4px;
}
.kill-outcome-radio {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 4px 6px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}
.kill-outcome-radio:hover {
    background: #faf5ed;
}
.kill-outcome-radio input[type="radio"] {
    margin-top: 3px;
    accent-color: #b96c28;
}
.kill-outcome-radio-label strong {
    display: block;
    color: #5c4429;
    font-weight: 600;
}
.kill-outcome-radio-label small {
    display: block;
    color: #7a6a55;
    font-size: 11px;
    margin-top: 1px;
}
.kill-outcome-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.kill-outcome-field label {
    font-size: 11px;
    font-weight: 600;
    color: #7a4d27;
}
.kill-outcome-field input[type="date"],
.kill-outcome-field textarea {
    border: 1px solid #d4c5b0;
    border-radius: 4px;
    padding: 6px 8px;
    font-size: 13px;
    background: #fff;
    color: #2a2118;
    font-family: inherit;
}
.kill-outcome-field input[type="date"]:focus,
.kill-outcome-field textarea:focus {
    outline: none;
    border-color: #b96c28;
    box-shadow: 0 0 0 2px rgba(185, 108, 40, 0.15);
}
.kill-outcome-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 10px 16px;
    background: #f5efe8;
    border-top: 1px solid #e0d4c2;
}
.kill-outcome-btn-secondary,
.kill-outcome-btn-primary {
    padding: 7px 14px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
}
.kill-outcome-btn-secondary {
    background: #fff;
    color: #7a4d27;
    border-color: #d4c5b0;
}
.kill-outcome-btn-secondary:hover {
    background: #faf5ed;
    border-color: #b96c28;
}
.kill-outcome-btn-primary {
    background: #b96c28;
    color: #fff;
}
.kill-outcome-btn-primary:hover {
    background: #9d5820;
}

/* ============================================================
   Revert / Kill Asset stage picker (v1.11.4.0)
   ============================================================
   Admin-only modal opened from ⚙ Actions on an ASSET. Reuses the
   .kill-outcome-* shell (backdrop, header, fields, buttons) and adds
   the stage ladder + the "this will be cleared" impact summary.

   Wider than the kill modal because each ladder row carries a label,
   a hint line, and the currently-recorded signal value.
*/
.revert-stage-modal {
    width: min(560px, 100%);
}
.revert-stage-fieldset {
    max-height: 46vh;
    overflow-y: auto;
}
.revert-stage-radio {
    border: 1px solid transparent;
    margin-bottom: 2px;
}
.revert-stage-radio:has(input:checked) {
    background: #fdf6ec;
    border-color: #e0c9a6;
}
/* Fallback for engines without :has() — the checked row still reads as
   selected via the accent-coloured radio itself. */
.revert-stage-recorded {
    display: block;
    font-size: 11px;
    color: #4a7a3c;
    margin-top: 2px;
}
.revert-stage-unrecorded {
    display: block;
    font-size: 11px;
    color: #a89880;
    margin-top: 2px;
}
.revert-stage-impact {
    border: 1px solid #e6d3b8;
    background: #fdf8f0;
    border-radius: 5px;
    padding: 8px 10px;
    font-size: 12px;
    color: #5c4429;
}
.revert-stage-impact-head {
    font-weight: 600;
    color: #8a4b1e;
    margin-bottom: 4px;
}
.revert-stage-impact-list {
    margin: 0;
    padding-left: 18px;
    max-height: 108px;
    overflow-y: auto;
}
.revert-stage-impact-list li {
    margin: 1px 0;
}
.revert-stage-impact-foot {
    margin-top: 5px;
    font-size: 11px;
    color: #7a6a55;
    font-style: italic;
}
.revert-stage-impact-none {
    color: #7a6a55;
    font-style: italic;
}
/* The recorded-deed preview failed to load. Reads as a blocker, not a
   note — Revert and Kill are disabled while this shows. */
.revert-stage-impact-error {
    color: #a33b2a;
}
.revert-stage-actions button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
/* Kill is the destructive of the two commits — red, so it can't be
   confused with the neutral "Revert to Prospect" primary next to it. */
.revert-stage-btn-kill {
    background: #a33b2a;
}
.revert-stage-btn-kill:hover {
    background: #8a2f20;
}
.revert-stage-actions {
    flex-wrap: wrap;
}

/* v1.11.4.1 (codex P2) — stages whose own signal was never recorded can't
   be rewound to; the picker greys them out and the API 409s if one is
   requested anyway. */
.revert-stage-radio-disabled {
    opacity: 0.55;
    cursor: not-allowed;
}
.revert-stage-radio-disabled:hover {
    background: transparent;
}
.revert-stage-unreachable {
    display: block;
    font-size: 11px;
    color: #a33b2a;
    margin-top: 2px;
}
