/* ============================================================================
   RES V2 Component Kit — the blessed residential skin (RES_DESIGN_SPEC.md,
   Phase 0.2 of RES_V2_PLAN.md).

   Eight components, composed forever: stat tile, section card, key-value row,
   read/edit field, data table, comp row, phase chip, drawer. A ninth component
   means editing RES_DESIGN_SPEC.md first — not adding a div here.
   2026-10-31 (RES_DESIGN_SPEC "Decide screen additions"): three more, at the
   bottom of this file — basis chip, ladder, price axis.

   Every color, size, radius and shadow below is either an existing app token
   (style.css :root — same set deal_card_v2.html re-declares inline) or a
   literal already used by the blessed surfaces this kit distills:
     labels        10.5px/600 uppercase .04em muted      (.quickstat-label)
     values        tabular-nums, never a mono font       (site-wide 2026-06 rule)
     primary stat  24px/700 in a 2px #334155 frame       (.uw-hero-item + .fin-tile.hero)
     tables        th 10px caps muted / td 12.5px        (.fin-tbl)
     chips         3px 9px, radius 12px, 11px/600        (.phase-badge)
     provenance    9px caps tag + dark hover tip         (.dc-src-tag / .prov-tip)
     read/edit field  blue-box input affordance (0432FF)  (Carson 9/09)
     drawer        560px right panel, rgba(15,23,42,.32) (design_system.css .ds-drawer)

   Color is STATE only (existing org phase colors, error red on a failed
   save). Never judgment: no green-profit, no verdict tints (root CLAUDE.md).
   No emoji anywhere; affordances are CSS chevrons/SVG.

   LAYOUT PRIMITIVES (added 2026-08-29 with the Deal tab V2 — RES_DESIGN_SPEC
   "Layout geometry rules", docs/design_refs/README.md transposition grid).
   These are page-GEOMETRY additions, not components — the only class of
   addition the gate allows without a spec review:
     .rk-page       two-column detail grid: main column + fixed 320px context
                    rail (Linear/Attio split); stacks rail-below-main <980px
     .rk-page-main  the main column (max 760px — geometry rule 2)
     .rk-page-rail  the context rail (inline label:value rows, ~28px each)
     .rk-cluster    compact results group, max 640px (geometry rule 3 — one
                    primary number + tight secondaries, never viewport-wide)

   Mobile: cosmetic width-query reflow only (per mobile.js header note,
   structural swaps stay body.mobile-gated; nothing here changes layout
   *architecture* below 640px — tables restack, the drawer goes full-sheet).
   ========================================================================== */

/* ---------------------------------------------------------------------------
   1. STAT TILE — label over value; states: default / primary / empty.
   Tiles sit in a .rk-stat-row: plain columns with hairline dividers, no
   boxes (the .uw-hero convention, "no boxes, no tinted fills" 2026-07-01).
   The ONE primary tile per surface carries the thick frame (Carson's Excel
   convention: thick box = the number that matters — .fin-tile.hero).
   ------------------------------------------------------------------------- */
.rk-stat-row {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 14px 0;
}
.rk-stat {
    flex: 1 1 120px;
    min-width: 0;
    /* 12px top pad = the primary tile's 10px pad + 2px border, so every
       label in a mixed row starts on the same line. */
    padding: 12px 22px 12px 0;
    margin-right: 22px;
    border-right: 1px solid var(--border-color, #E5E7EB);
}
.rk-stat:last-child { border-right: none; margin-right: 0; padding-right: 0; }
.rk-stat-label {
    font-size: 10.5px;
    font-weight: 600;
    color: var(--text-muted, #9CA3AF);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.rk-stat-value {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary, #1F2937);
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}
.rk-stat-sub {
    font-size: 11px;
    color: var(--text-muted, #9CA3AF);
    margin-top: 3px;
}
/* Phones: the deal-card 2x2 stat-grid convention (.dcm-grid) — dividers
   off, primary spans the full row. Cosmetic reflow only. */
@media (max-width: 640px) {
    .rk-stat-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
    .rk-stat { border-right: none; padding: 2px 0; margin-right: 0; }
    /* Double class beats the base .rk-stat--primary rule below (which sets a
       desktop margin-right and appears later in the file). */
    .rk-stat.rk-stat--primary { grid-column: 1 / -1; padding: 10px 16px; margin-right: 0; }
}

/* Primary: the one number the eye lands on first. Framed + one size up. */
.rk-stat--primary {
    border: 2px solid #334155;            /* .fin-tile.hero frame */
    border-radius: var(--radius-md, 8px);
    padding: 10px 16px;
    margin-right: 22px;
    background: var(--bg-card, #FFFFFF);
    flex: 0 1 auto;
}
.rk-stat--primary .rk-stat-value { font-size: 24px; font-weight: 700; }
/* Empty: value renders "–", muted — never $0 / 0.0%. */
.rk-stat--empty .rk-stat-value { color: var(--text-muted, #9CA3AF); font-weight: 500; }

/* ---------------------------------------------------------------------------
   2. SECTION CARD — title row (+ optional action) + body; states:
   expanded / collapsed / loading-skeleton. Same anatomy as the deal card's
   .card/.card-header/.card-body, distilled.
   ------------------------------------------------------------------------- */
.rk-card {
    background: var(--bg-card, #FFFFFF);
    border: 1px solid var(--border-color, #E5E7EB);
    border-radius: var(--radius-card, 10px);    /* one card radius (2026-11-12) */
    box-shadow: var(--shadow-sm, 0 1px 2px rgba(0,0,0,0.04));
    overflow: hidden;
}
.rk-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color, #E5E7EB);
}
.rk-card.is-collapsed .rk-card-header { border-bottom: none; }
.rk-card-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary, #1F2937);
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}
/* Muted sentence-case qualifier inside a title (as-of dates, counts) —
   the .uw-sec-title .uw-title-note pattern. */
.rk-card-note {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted, #9CA3AF);
    text-transform: none;
    letter-spacing: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* Quiet header action — text link, primary color (.uw-missing a). */
.rk-card-action {
    margin-left: auto;
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    color: var(--primary-color, #1E3A5F);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}
.rk-card-action:hover { text-decoration: underline; }
.rk-card-body { padding: 18px; }
.rk-card-body.rk-no-pad { padding: 0; }
.rk-card.is-collapsed .rk-card-body { display: none; }

/* Collapse affordance: plain CSS chevron (the .dcm-chev pattern — no glyph,
   no emoji). Points down when expanded, right when collapsed. */
.rk-card-toggle {
    margin-left: auto;
    background: none;
    border: none;
    padding: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}
/* When an action link is also present it takes the auto push; the chevron
   sits 8px after it (both far right, chevron outermost). */
.rk-card-action ~ .rk-card-toggle { margin-left: 8px; }
.rk-chev {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-right: 1.6px solid var(--text-muted, #9CA3AF);
    border-bottom: 1.6px solid var(--text-muted, #9CA3AF);
    transform: rotate(45deg);              /* down = expanded */
    transition: transform 120ms;
}
.rk-card.is-collapsed .rk-chev { transform: rotate(-45deg); }  /* right = collapsed */
/* Collapsed summary: key values inline with the title (.uw-sum pattern). */
.rk-card-summary {
    display: none;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary, #1F2937);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.rk-card.is-collapsed .rk-card-summary { display: block; }

/* Phones: the note drops to its own full-width line under the title so the
   title never wraps against it; action/chevron stay top-right. */
@media (max-width: 640px) {
    .rk-card-header { flex-wrap: wrap; }
    .rk-card-note {
        flex-basis: 100%;
        order: 10;
        white-space: normal;
    }
}

/* Loading skeleton — quiet pulsing bars in the body (bg-input tone). */
.rk-skeleton { display: flex; flex-direction: column; gap: 10px; }
.rk-skeleton-line {
    height: 12px;
    border-radius: var(--radius-sm, 6px);
    background: var(--bg-input, #F5F7FA);
    animation: rk-pulse 1.4s ease-in-out infinite;
}
.rk-skeleton-line.w60 { width: 60%; }
.rk-skeleton-line.w40 { width: 40%; }
.rk-skeleton-line.w80 { width: 80%; }
@keyframes rk-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

/* ---------------------------------------------------------------------------
   3. KEY-VALUE ROW — label left (muted), value right (tabular); states:
   read / edit-in-place / overridden. Mirrors .info-row.
   ------------------------------------------------------------------------- */
.rk-kv {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border-color, #E5E7EB);
    font-size: 13px;
}
.rk-kv:last-child { border-bottom: none; }
/* Bare variant: a context/meta line inside a card (subject facts + chip
   above a stat row) — same anatomy, no rule, no top pad. */
.rk-kv.rk-kv--bare { border-bottom: none; padding-top: 0; margin-bottom: 10px; }
.rk-kv-label { color: var(--text-secondary, #4B5563); font-weight: 500; min-width: 0; }
.rk-kv-value {
    font-weight: 600;
    color: var(--text-primary, #1F2937);
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
}
@media (max-width: 640px) {
    /* Long text values (financing terms) may wrap on phones; numbers have
       no break points so figures stay whole. */
    .rk-kv-value { white-space: normal; }
}
/* Project timeline (reno-draw-timeline): a compact read-only cluster above
   the loan schedule — reno phases by week. Composes .rk-kv rows; constrained
   width (compact cluster, not a viewport-wide bar) + a quiet bottom rule to
   set it off from the due-at-close block below. */
.dtv2-projtl { max-width: 520px; margin-bottom: 14px; padding-bottom: 6px;
    border-bottom: 1px solid var(--border-color, #E5E7EB); }
.dtv2-projtl .rk-kv { border-bottom: none; padding: 3px 0; font-size: 12.5px; }
/* Overridden: quiet caps tag on the label + a muted source note under the
   value ("manual override, Reno says $X" — RES_V2_PLAN 1.3). */
.rk-kv-note {
    display: block;
    font-size: 10.5px;
    font-weight: 400;
    color: var(--text-muted, #9CA3AF);
    margin-top: 1px;
    white-space: nowrap;
}

/* Provenance / source tag — the .dc-src-tag verbatim ("a data point's
   provenance, never a warning"). */
.rk-tag {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted, #9CA3AF);
    background: var(--bg-input, #F5F7FA);
    border: 1px solid var(--border-color, #E5E7EB);
    border-radius: 3px;
    padding: 0 4px;
    margin-left: 6px;
    vertical-align: middle;
    white-space: nowrap;
}

/* ---------------------------------------------------------------------------
   4. READ/EDIT FIELD — value as text; click -> input; blur/Enter saves via a
   registered callback (static/js/res_kit.js). States: read / editing /
   saving / error.

   INPUT AFFORDANCE = blue (Carson 9/09, redline: NO drawn box). Every
   residential-kit read/edit field IS a genuine input (the user types a number
   into it — purchase price, assumption %s, carry, ARV override, loan terms).
   The input signal is Carson's lifelong 0432FF marker held to a restrained
   institutional weight: BLUE TEXT + a very faint blue tint — his Excel
   convention where blue FONT means "input", NOT a bordered box. No border
   stroke, no box-shadow ring, no dashed underline anywhere.

   Read state and edit <input> are styled IDENTICALLY (Carson 9/09: clicking
   an input to edit must cause ZERO layout shift or restyle) — same font,
   colour, tint, padding, height, box-sizing and alignment. Clicking swaps a
   read span for a typeable <input> that looks exactly the same; it just gains
   a caret. Non-input values are plain text with no tint, they never carry
   .rk-field. --rk-input-blue-* fall back to literals so no :root dependency
   is assumed.
   ------------------------------------------------------------------------- */
.rk-field {
    --rk-input-blue: #0432FF;             /* Carson's input marker */
    --rk-input-blue-tint: rgba(4, 50, 255, 0.05);
    --rk-input-blue-tint-hover: rgba(4, 50, 255, 0.09);
    display: inline-flex;
    flex-direction: column;
    align-items: flex-end;
    min-width: 0;
}
/* Shared box model for read + edit so the two are pixel-identical (item 3). */
.rk-field-read,
.rk-field-input {
    box-sizing: border-box;
    border: none;
    border-radius: 6px;
    padding: 2px 8px;
    background: var(--rk-input-blue-tint);
    color: var(--rk-input-blue);          /* blue FONT = the input marker */
    font-variant-numeric: tabular-nums;
    text-align: right;
    line-height: 1.4;
}
.rk-field-read {
    cursor: text;
    display: inline-block;
    transition: background 120ms;
}
.rk-field-read:hover,
.rk-field-read:focus-visible {
    background: var(--rk-input-blue-tint-hover);
    outline: none;
}
.rk-field-input {
    font-family: inherit;
    font-size: inherit;
    font-weight: inherit;
    /* Size to typed content so clicking a read value into edit does NOT change
       the field's footprint (Carson 9/09: "why do boxes interact weird when u
       go to edit... instead of just staying as it was"). The input inherits the
       read span's font + padding, so field-sizing:content makes it land at the
       same width as the value it replaced; it grows only as you type past it.
       Browsers without field-sizing fall back to the min-width (still no border
       or height jump — only width). */
    field-sizing: content;
    width: auto;
    min-width: 3ch;
    max-width: 12ch;
}
.rk-field-input:focus { outline: none; background: var(--rk-input-blue-tint-hover); }
.rk-field.is-saving .rk-field-read { color: var(--text-muted, #9CA3AF); }
.rk-field-status {
    font-size: 10.5px;
    color: var(--text-muted, #9CA3AF);
    margin-top: 1px;
    white-space: nowrap;
}
.rk-field.is-error .rk-field-input {
    border-bottom-color: var(--error-color, #DC2626);
    box-shadow: 0 1px 0 0 var(--error-color, #DC2626);
}
.rk-field.is-error .rk-field-status { color: var(--error-color, #DC2626); }

/* ---------------------------------------------------------------------------
   5. DATA TABLE — sm-caps muted header, right-aligned numerics, row hover,
   cap + "show all (N)"; states: default / stacked (mobile) / empty.
   The .fin-tbl / .emp-table conventions distilled.
   ------------------------------------------------------------------------- */
.rk-table-wrap { min-width: 0; }
.rk-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
    font-variant-numeric: tabular-nums;
}
.rk-table th {
    text-align: left;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted, #9CA3AF);
    padding: 4px 12px 4px 0;
    border-bottom: 1px solid var(--border-color, #E5E7EB);
    white-space: nowrap;
}
.rk-table td {
    padding: 6px 12px 6px 0;
    border-bottom: 1px solid var(--bg-input, #F5F7FA);
    color: var(--text-secondary, #4B5563);
}
.rk-table th:last-child, .rk-table td:last-child { padding-right: 0; }
.rk-table tbody tr:last-child td { border-bottom: none; }
.rk-table tbody tr:hover td { background: #fafbfc; }   /* .ev-row:hover */
.rk-table th.rk-num, .rk-table td.rk-num {
    text-align: right;
    white-space: nowrap;
}
.rk-table td.rk-num { color: var(--text-primary, #1F2937); font-weight: 600; }
.rk-table td:first-child { color: var(--text-primary, #1F2937); }
/* Total row: thin top rule, bold — the subtotal convention. */
.rk-table tr.rk-total td {
    border-top: 1px solid var(--text-muted, #9CA3AF);
    border-bottom: none;
    font-weight: 700;
    color: var(--text-primary, #1F2937);
}
.rk-table tr.rk-total:hover td { background: none; }
/* Capped rows: hidden until "Show all (N)". */
.rk-table tr.rk-row-capped { display: none; }
.rk-table-wrap.is-expanded tr.rk-row-capped { display: table-row; }
.rk-table-showall {
    background: none;
    border: none;
    padding: 6px 0 0;
    font-family: inherit;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--primary-color, #1E3A5F);
    cursor: pointer;
}
.rk-table-showall:hover { text-decoration: underline; }
.rk-table-wrap.is-expanded .rk-table-showall { display: none; }
/* Empty state: one muted line, sentence case (.uw-missing). */
.rk-table-empty {
    font-size: 12px;
    color: var(--text-muted, #9CA3AF);
    line-height: 1.55;
    padding: 4px 0 6px;
}

/* Stacked rows on phones (cosmetic reflow): each row becomes a bordered
   stanza, each cell a label/value line from data-th. */
@media (max-width: 640px) {
    .rk-table thead { display: none; }
    .rk-table, .rk-table tbody, .rk-table tr, .rk-table td { display: block; width: 100%; }
    .rk-table tr {
        border-bottom: 1px solid var(--border-color, #E5E7EB);
        padding: 8px 0;
    }
    .rk-table tbody tr:last-child { border-bottom: none; }
    .rk-table td {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        gap: 12px;
        border-bottom: none;
        padding: 2px 0;
        text-align: right;
    }
    .rk-table td:empty { display: none; }   /* no orphan labels in a stack */
    .rk-table td::before {
        content: attr(data-th);
        font-size: 10px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: var(--text-muted, #9CA3AF);
        text-align: left;
        flex: 0 0 auto;
    }
    .rk-table tbody tr:hover td { background: none; }
    .rk-table tr.rk-total td { border-top: none; }
    .rk-table tr.rk-total { border-top: 1px solid var(--text-muted, #9CA3AF); }
}

/* ---------------------------------------------------------------------------
   6. COMP ROW — thumb, address, sold $ + date, $/SF, distance, quality tags,
   include toggle; states: included / excluded (dimmed, not hidden) /
   no-photo. Row anatomy follows the sidebar broker-card row grid.
   ------------------------------------------------------------------------- */
.rk-comp {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr) auto auto;
    gap: 4px 14px;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color, #E5E7EB);
}
.rk-comp:last-child { border-bottom: none; }
.rk-comp-thumb {
    width: 64px;
    height: 48px;
    border-radius: var(--radius-sm, 6px);
    border: 1px solid var(--border-color, #E5E7EB);
    background: var(--bg-input, #F5F7FA) center / cover no-repeat;
    overflow: hidden;
    flex: 0 0 auto;
}
.rk-comp-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* No-photo: dashed placeholder, tiny muted label — never a fake image. */
.rk-comp-thumb.rk-no-photo {
    border-style: dashed;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted, #9CA3AF);
}
.rk-comp-main { min-width: 0; }
.rk-comp-addr {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #1F2937);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.rk-comp-meta {
    font-size: 11px;
    color: var(--text-muted, #9CA3AF);
    margin-top: 1px;
    font-variant-numeric: tabular-nums;
}
.rk-comp-tags { margin-top: 3px; display: flex; flex-wrap: wrap; gap: 4px; }
.rk-comp-tags .rk-tag { margin-left: 0; }
.rk-comp-nums { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rk-comp-sold { font-size: 13.5px; font-weight: 700; color: var(--text-primary, #1F2937); }
.rk-comp-ppsf { font-size: 11px; color: var(--text-secondary, #4B5563); margin-top: 1px; }
/* Include toggle — plain checkbox, app accent (the Comps-panel convention). */
.rk-comp-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    cursor: pointer;
}
.rk-comp-toggle input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--primary-color, #1E3A5F);
    cursor: pointer;
}
/* Excluded: dimmed, never hidden — the row stays auditable. */
.rk-comp.is-excluded .rk-comp-thumb,
.rk-comp.is-excluded .rk-comp-main,
.rk-comp.is-excluded .rk-comp-nums { opacity: 0.45; }
.rk-comp-excl-note {
    grid-column: 2 / -1;
    font-size: 10.5px;
    color: var(--text-muted, #9CA3AF);
}
.rk-comp:not(.is-excluded) .rk-comp-excl-note { display: none; }

@media (max-width: 640px) {
    .rk-comp { grid-template-columns: 48px minmax(0, 1fr) auto; }
    .rk-comp-thumb { width: 48px; height: 40px; }
    .rk-comp-nums { grid-column: 2; text-align: left; margin-top: 2px; }
    .rk-comp-toggle { grid-row: 1; grid-column: 3; }
}

/* ---------------------------------------------------------------------------
   7. PHASE CHIP — .phase-badge geometry verbatim; colors are DATA from the
   org's dropdown_options (settings), applied inline by the macro — the same
   convention as the tracker's _getDDColor. Neutral fallback when the org has
   no color for a phase.
   ------------------------------------------------------------------------- */
.rk-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}
.rk-chip {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    background: #f3f4f6;
    color: #374151;
}

/* ---------------------------------------------------------------------------
   8. DRAWER — right panel on desktop, full-sheet on phones; one pattern for
   all secondary detail. Geometry + motion mirror design_system.css
   .ds-drawer; surfaces use the app tokens.
   ------------------------------------------------------------------------- */
.rk-drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.32);
    z-index: 9998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 160ms ease;
}
.rk-drawer-backdrop.is-open { opacity: 1; pointer-events: auto; }
.rk-drawer {
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0;
    width: 560px;
    max-width: calc(100vw - 32px);
    background: var(--bg-card, #FFFFFF);
    box-shadow: var(--shadow-lg, 0 4px 12px rgba(0,0,0,0.06));
    z-index: 9999;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 200ms cubic-bezier(0.32, 0.72, 0, 1);
    visibility: hidden;
}
.rk-drawer.is-open { transform: translateX(0); visibility: visible; }
.rk-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color, #E5E7EB);
}
.rk-drawer-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary, #1F2937);
    margin: 0;
}
.rk-drawer-close {
    background: none;
    border: none;
    padding: 4px 8px;
    font-family: inherit;
    font-size: 15px;
    line-height: 1;
    color: var(--text-muted, #9CA3AF);
    cursor: pointer;
    border-radius: var(--radius-sm, 6px);
}
.rk-drawer-close:hover { color: var(--text-primary, #1F2937); background: var(--bg-input, #F5F7FA); }
.rk-drawer-body { flex: 1; overflow-y: auto; padding: 18px; }
/* Full-sheet on phones. */
@media (max-width: 640px) {
    .rk-drawer { width: 100%; max-width: 100%; }
}

/* ---------------------------------------------------------------------------
   Provenance affordance — every computed number carries one (spec principle
   8). res_kit.js shows the dark tip (the .prov-tip look) with the data-rk-prov
   text on hover/focus. NO visible underline (Carson 9/09: "Dont have
   everything underlined like that"): the basis lives in the hover tip only —
   the value stays a clean number at rest, no dotted line drawn anywhere.
   ------------------------------------------------------------------------- */
.rk-prov {
    cursor: help;
}
.rk-prov-tip {
    position: fixed;
    z-index: 10001;
    background: #0F172A;
    color: #F8FAFC;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
    padding: 9px 12px;
    border-radius: 4px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
    max-width: 300px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 100ms ease;
    font-variant-numeric: tabular-nums;
}
.rk-prov-tip.is-visible { opacity: 1; }

/* As-of line — datasets announce their vintage (spec principle 8; the
   .dc-cached-tag / .uw-chart-note register). */
.rk-asof {
    font-size: 10.5px;
    color: var(--text-muted, #9CA3AF);
    margin-top: 10px;
}

/* ---------------------------------------------------------------------------
   PAGE GEOMETRY — .rk-page / .rk-page-main / .rk-page-rail / .rk-cluster
   (see the header note; added for the Deal tab V2). Transposes the
   docs/design_refs README grid: main content column + narrow context rail,
   label-adjacent values, results as a compact cluster. NOT a component —
   composition only; every child inside is kit vocabulary.
   ------------------------------------------------------------------------- */
.rk-page {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 24px;
    align-items: start;
}
.rk-page-main {
    min-width: 0;
    max-width: 760px;          /* geometry rule 2: main 640-760px */
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.rk-page-rail {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
/* Rail cards run tighter than main cards: ~28px label:value rows
   (Linear-rail density) without changing the kit row anatomy. */
.rk-page-rail .rk-card-body { padding: 10px 16px; }
.rk-page-rail .rk-kv { padding: 5px 0; font-size: 12.5px; }
.rk-cluster { max-width: 640px; }   /* geometry rule 3 */
/* Wide cluster (2026-10-31, the deal-card header glance strip): the same
   hugging tiles under a 960px cap — six tiles (one primary + five) on one
   line inside the full-width header band, left aligned, never stretched.
   Spec: RES_DESIGN_SPEC.md layout primitives. */
.rk-cluster.rk-cluster--wide { max-width: 960px; }
/* Inside the cluster, tiles HUG their content (no 120px flex basis, tighter
   dividers) so one primary + four half-size secondaries share one row within
   the 640px cap instead of wrapping. Desktop only — the phone 2x2 grid
   reflow below 640px keeps winning. */
@media (min-width: 641px) {
    .rk-cluster .rk-stat { flex: 0 1 auto; padding-right: 16px; margin-right: 16px; }
    .rk-cluster .rk-stat--primary { padding-right: 16px; }
}
/* Rail stacks BELOW main on narrow viewports (phones + split screens). */
@media (max-width: 980px) {
    .rk-page { grid-template-columns: minmax(0, 1fr); }
    .rk-page-main { max-width: none; }
    .rk-page-rail { order: 2; }
}

/* ============================================================================
   DEMO-PAGE SCAFFOLD (/design-kit only — no product surface uses rk-demo-*).
   Kept here so the demo template ships zero <style> blocks and the audit can
   mechanically assert "only res_kit.css + existing app stylesheets".
   ========================================================================== */
.rk-demo-page {
    max-width: 1180px;             /* res_calendar page width */
    margin: 0 auto;
    padding: 24px 24px 60px;
}
.rk-demo-header { margin-bottom: 4px; }
.rk-demo-header h1 {
    margin: 0;
    font-family: var(--font-heading, inherit);
    font-size: 20px;
    font-weight: 700;
    color: var(--primary-color, #1E3A5F);
    letter-spacing: -0.01em;
}
.rk-demo-eyebrow {
    font-size: 10.5px;
    font-weight: 600;
    color: var(--text-muted, #9CA3AF);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 2px;
}
.rk-demo-sub { font-size: 12.5px; color: var(--text-secondary, #4B5563); margin: 2px 0 0; }
.rk-demo-page > section { margin-top: 24px; }
/* State caption above each variant (label register — same 10.5 caps). */
.rk-demo-state {
    font-size: 10.5px;
    font-weight: 600;
    color: var(--text-muted, #9CA3AF);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 16px 0 8px;
}
.rk-demo-state:first-child { margin-top: 0; }
.rk-demo-cols {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    align-items: start;
}
@media (max-width: 1100px) {
    .rk-demo-page { padding: 16px 14px 48px; }
}


/* ============================================================================
   DECIDE SCREEN ADDITIONS (2026-10-31, RES_DESIGN_SPEC components 9-11)
   ========================================================================== */

/* ---- 9. BASIS CHIP -------------------------------------------------------
   The provenance of ONE computed number as a quiet inline chip: the count,
   grade, range or rule that produced it ("9 comps · grade B · range $170k to
   $260k", "2.0% of price"). Replaces explanatory sentences under numbers
   (UX_MASTER_PLAN 9.1). is-action chips open their evidence in place.      */
.rk-basis {
    display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
    border: 1px solid var(--border-color, #E5E7EB); border-radius: 10px;
    padding: 1px 8px; font-size: 11px; line-height: 16px;
    color: var(--text-secondary, #4B5563); background: var(--bg-card, #fff);
    white-space: nowrap; vertical-align: middle;
    font-variant-numeric: tabular-nums;
}
.rk-basis b { font-weight: 700; color: var(--text-primary, #1F2937); }
.rk-basis.is-action { cursor: pointer; }
.rk-basis.is-action:hover, .rk-basis.is-action:focus-visible {
    border-color: var(--text-muted, #9CA3AF); outline: none;
}
.rk-basis-tier { display: inline-flex; gap: 2px; }
.rk-basis-tier i {
    width: 7px; height: 7px; border-radius: 1px; display: inline-block;
    background: var(--border-color, #E5E7EB);
}
.rk-basis-tier i.on { background: var(--primary-color, #1E3A5F); }

/* ---- 10. LADDER ----------------------------------------------------------
   The pro forma as a statement: label · basis chip · right-aligned value.
   Group heads 10.5px caps; subtotal rows bold; the culmination (net profit)
   is a ruled total row — the surface's one framed primary number is the
   Offer card's net profit tile above it.                                   */
.rk-ladder { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.rk-ladder td {
    padding: 7px 0; border-bottom: 1px solid var(--border-color, #E5E7EB);
    vertical-align: middle;
}
.rk-ladder tr.rk-ladder-group td {
    border-bottom: none; padding: 14px 0 4px; font-size: 10.5px; font-weight: 700;
    letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted, #6B7280);
}
.rk-ladder tr.rk-ladder-group:first-child td { padding-top: 2px; }
.rk-ladder td.rk-ladder-label {
    color: var(--text-primary, #1F2937); font-weight: 500; white-space: nowrap;
    padding-right: 12px;
}
.rk-ladder td.rk-ladder-basis { color: var(--text-muted, #6B7280); font-size: 11.5px; width: 100%; }
.rk-ladder td.rk-ladder-value {
    text-align: right; font-weight: 600; white-space: nowrap; padding-left: 16px;
    font-variant-numeric: tabular-nums;
}
.rk-ladder td.rk-ladder-value.is-input { color: var(--rk-input-blue, #0432FF); }
.rk-ladder td.rk-ladder-value.is-empty { color: var(--text-muted, #9CA3AF); font-weight: 500; }
.rk-ladder tr.rk-ladder-sub td.rk-ladder-label,
.rk-ladder tr.rk-ladder-sub td.rk-ladder-value { font-weight: 700; }
.rk-ladder tr.rk-ladder-total td {
    font-weight: 700; border-top: 1px solid var(--text-primary, #1F2937);
    border-bottom: 2px solid var(--text-primary, #1F2937); padding: 10px 0;
}
.rk-ladder tr.rk-ladder-total td.rk-ladder-value { font-size: 15px; }
.rk-ladder td.rk-ladder-evidence { padding: 0 0 8px; border-bottom: none; }
.rk-ladder-link {
    color: var(--primary-color, #1E3A5F); font-weight: 600; margin-left: 8px;
    background: none; border: none; padding: 0; font: inherit; font-size: 11.5px;
    cursor: pointer; text-decoration: none; white-space: nowrap;
}
.rk-ladder-link:hover { text-decoration: underline; }
.rk-evidence {
    background: var(--bg-input, #F5F6F8); border: 1px solid var(--border-color, #E5E7EB);
    border-radius: var(--radius-sm, 6px); padding: 12px 14px; margin-top: 6px;
}
.rk-evidence-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; font-size: 12.5px; flex-wrap: wrap; }
.rk-evidence-head b { font-weight: 700; }
.rk-evidence-head .rk-card-note { font-size: 11.5px; }
.rk-evidence-row {
    display: grid; grid-template-columns: 24px minmax(0, 1fr) 90px 60px 64px; gap: 10px;
    font-size: 12px; padding: 4px 0; border-top: 1px solid var(--border-color, #E5E7EB);
    font-variant-numeric: tabular-nums;
}
.rk-evidence-row:first-of-type { border-top: none; }
.rk-evidence-row .r { text-align: right; }
.rk-evidence-row .m { color: var(--text-muted, #6B7280); }
.rk-evidence-row .m.rk-evidence-more { grid-column: 2 / 5; }
.rk-dots svg { width: 100%; height: 74px; display: block; overflow: visible; }
.rk-dots .rk-dot-band { fill: var(--primary-color, #1E3A5F); opacity: .08; }
.rk-dots .rk-dot-line { stroke: var(--border-color, #CBD2DB); }
.rk-dots .rk-dot { fill: var(--primary-color, #1E3A5F); }
.rk-dots .rk-dot.is-outline { fill: var(--bg-card, #fff); stroke: var(--primary-color, #1E3A5F); stroke-width: 1.5; }
.rk-dots .rk-dot-tick { font-size: 10px; fill: var(--text-muted, #6B7280); }
.rk-dots .rk-dot-subject { stroke: var(--text-primary, #1F2937); stroke-width: 1.5; }
.rk-dots .rk-dot-subject-label { font-size: 10.5px; font-weight: 700; fill: var(--text-primary, #1F2937); }

/* ---- 11. PRICE AXIS ------------------------------------------------------
   One horizontal price line with labelled markers (asking, max offer for the
   profit target, the 70% rule, break even) and a draggable handle = the
   purchase price. Keyboard: arrows move $1k, shift-arrows $5k. Markers are
   data, never verdicts: one ink, dashed hairlines, muted labels.            */
.rk-axis {
    position: relative; height: 108px; user-select: none; -webkit-user-select: none;
    touch-action: none; outline: none;
}
.rk-axis svg { width: 100%; height: 108px; display: block; overflow: visible; font-family: inherit; }
.rk-axis .rk-axis-line { stroke: var(--border-color, #CBD2DB); stroke-width: 2; }
.rk-axis .rk-axis-band { fill: var(--primary-color, #1E3A5F); opacity: .10; }
.rk-axis .rk-axis-tick { stroke: var(--text-muted, #9CA3AF); }
.rk-axis .rk-axis-ticklabel { font-size: 10.5px; fill: var(--text-muted, #6B7280); font-variant-numeric: tabular-nums; }
.rk-axis .rk-axis-marker { stroke: var(--text-muted, #9CA3AF); stroke-dasharray: 2 2; }
.rk-axis .rk-axis-label { font-size: 10.5px; font-weight: 600; fill: var(--text-secondary, #4B5563); font-variant-numeric: tabular-nums; }
.rk-axis .rk-axis-label.is-primary { fill: var(--primary-color, #1E3A5F); }
.rk-axis .rk-axis-handle { fill: var(--primary-color, #1E3A5F); stroke: #fff; stroke-width: 3; cursor: grab; }
.rk-axis.is-dragging .rk-axis-handle { cursor: grabbing; }
.rk-axis:focus-visible .rk-axis-handle { stroke: var(--rk-input-blue, #0432FF); }
.rk-axis .rk-axis-handle-label { font-size: 11px; font-weight: 700; fill: var(--rk-input-blue, #0432FF); font-variant-numeric: tabular-nums; }
.rk-axis .rk-axis-hit { fill: transparent; cursor: pointer; }
.rk-axis.is-empty .rk-axis-handle, .rk-axis.is-empty .rk-axis-handle-label { display: none; }
.rk-axis-empty {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    font-size: 12px; color: var(--text-muted, #6B7280); pointer-events: none;
}

/* ---- Status dot tokens (2026-11-12) ----------------------------------------
   Color that states a FACT, never a judgment: a small dot beside the plain
   word (.ui-status in res_ui.css). Document parse states reuse the app's own
   --success-color / --warning-color / --error-color (style.css :root).
   Market cycle phases are CATEGORIES, not good/bad: four muted hues with no
   green or red, so no phase reads as a verdict. */
:root {
    --phase-recovery: #4A78B0;      /* muted blue */
    --phase-expansion: #3E8A86;     /* muted teal */
    --phase-hyper-supply: #6B7686;  /* slate */
    --phase-recession: #8A5C86;     /* plum */
}
