/* ============================================================
 * FR-114 — Unified styles for child-entity tables.
 *
 * One file replaces (or eventually replaces) three CSS families:
 *
 *   .rvg-ic-*        (inline-children grid in form.twig)
 *   .rvg-children-*  (preview tab in _children.twig)
 *   .list-{table}-*  (standalone list in list.twig)
 *
 * Consumed by `_lines_table.twig` + `_lines_cell.twig` + `_lines_input.twig`.
 * Theme-variable-driven (no hardcoded colors) — works in light/dark/atlas.
 * Responsive at 4 breakpoints: 1024 / 768 / 520 / 380 px.
 *
 * Per-surface tweaks are expressed via modifier classes on the root:
 *
 *   .rvg-lines.is-list        — list mode (full chrome)
 *   .rvg-lines.is-preview     — preview tab (compact, no totals)
 *   .rvg-lines.is-inline      — inline grid (editable cells, mirror, BoQ pill)
 *   .rvg-lines.is-detail      — single-row detail strip
 *   .rvg-lines.is-pdf         — print mode (no chrome, no actions)
 *
 * Theme tokens used:
 *
 *   --color-bg, --color-bg-alt, --color-bg-hover
 *   --color-text, --color-text-muted
 *   --color-border, --color-accent, --color-accent-soft
 *   --color-success, --color-danger, --color-warning
 *   --space-1..--space-6, --radius-sm, --radius-md, --radius-lg
 *   --rvg-card-shadow
 *
 * No `#fff`, `#000`, or `rgba(...)` literals — every chrome color
 * resolves through the theme. PDF surface uses fixed light tokens via
 * the `.is-pdf` modifier so dark themes don't print as black-on-black.
 * ============================================================ */

/* ---------- root ------------------------------------------------ */
.rvg-lines {
    width: 100%;
    background: var(--color-bg);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg, 12px);
    overflow: hidden;
    font-family: var(--font-primary, inherit);
    box-shadow: var(--rvg-card-shadow, 0 1px 2px rgba(0, 0, 0, 0.04));
}

/* ---------- header strip --------------------------------------- */
.rvg-lines-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3, 12px);
    padding: var(--space-3, 12px) var(--space-4, 16px);
    background: var(--color-bg-alt, var(--color-bg));
    border-bottom: 1px solid var(--color-border);
}
.rvg-lines-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--color-text);
    margin: 0;
}
.rvg-lines-title .rvg-lines-count {
    margin-inline-start: 6px;
    padding: 2px 8px;
    background: color-mix(in srgb, var(--color-accent, #3b82f6) 14%, var(--color-bg));
    color: var(--color-accent, #3b82f6);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}
.rvg-lines-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2, 8px);
}

/* ---------- scroll wrap ---------------------------------------- */
.rvg-lines-scroll {
    overflow-x: auto;
    overflow-y: visible;
    /* keep horizontal scrollbar visually inside the rounded container */
    border-radius: 0;
}

/* ---------- table ---------------------------------------------- */
.rvg-lines-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
    font-size: 13px;
    color: var(--color-text);
}
.rvg-lines-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    text-align: center;
    background: var(--color-bg-alt, var(--color-bg));
    color: var(--color-text-muted);
    font-weight: 600;
    font-size: 12px;
    text-transform: none;
    padding: var(--space-2, 8px) var(--space-3, 12px);
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}
.rvg-lines-table tbody td {
    padding: var(--space-2, 8px) var(--space-3, 12px);
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
    line-height: 1.4;
    text-align: center;
}
.rvg-lines-table tbody tr:last-child td {
    border-bottom: none;
}
.rvg-lines-table tbody tr:hover {
    background: var(--color-bg-hover, var(--color-bg-alt));
}
.rvg-lines-table tbody tr.is-clickable {
    cursor: pointer;
}
/* OP-64 (2026-06-11 theme-polish): clickable rows hover with an ACCENT
   tint instead of the neutral bg-hover — "this row opens something"
   must read without relying on the cursor alone (no cursor on touch).
   :not(.is-selected) keeps the 10% is-selected tint dominant (this
   rule's (0,4,2) would otherwise out-rank it on hover). .is-pdf's
   transparent hover override comes later in source and wins at equal
   (0,4,2). Print rules unaffected.
   REVERT: delete this rule — rows fall back to the neutral tr:hover. */
.rvg-lines-table tbody tr.is-clickable:not(.is-selected):hover {
    background: color-mix(in srgb, var(--color-accent) 9%, var(--color-bg));
}
.rvg-lines-table tbody tr.is-selected {
    background: color-mix(in srgb, var(--color-accent, #3b82f6) 10%, var(--color-bg));
}
.rvg-lines-table tbody tr.is-archived {
    opacity: 0.6;
    font-style: italic;
}

/* sequence column — narrow, centered, muted (a row-number gutter, not data) */
.rvg-lines-table th.rvg-lines-seq-col,
.rvg-lines-table td.rvg-lines-seq-col {
    width: 1%;
    text-align: center;
    color: var(--color-text-muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* numeric columns — tabular figures + center align (owner preference,
   matches the "everything centered" look of the inline grid). */
.rvg-lines-table td[data-type="integer"],
.rvg-lines-table td[data-type="bigint"],
.rvg-lines-table td[data-type="decimal"],
.rvg-lines-table td[data-type="currency"],
.rvg-lines-table td[data-type="money"],
.rvg-lines-table td[data-type="percentage"],
.rvg-lines-table td[data-type="calculated"] {
    font-variant-numeric: tabular-nums;
    text-align: center;
    white-space: nowrap;
}

/* ---------- footer (totals) ----------------------------------- */
.rvg-lines-table tfoot td {
    padding: var(--space-2, 8px) var(--space-3, 12px);
    background: color-mix(in srgb, var(--color-accent, #3b82f6) 6%, var(--color-bg));
    color: var(--color-accent, #3b82f6);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    border-top: 2px solid var(--color-border);
    text-align: center;
    white-space: nowrap;
}
/* Σ-cell carries the "الإجمالي" label — same row styling but text
   colour follows the body (label, not a number). `min-width` keeps
   the colspan-merged cell from squeezing the label below readable
   size on narrow viewports. */
.rvg-lines-table tfoot td.rvg-lines-totals-label {
    color: var(--color-text);
    text-align: center;
    font-weight: 700;
    min-width: 6em;
    white-space: nowrap;
}

/* ---------- cell formats -------------------------------------- */

/* lookup with optional thumbnail */
.rvg-lines-lookup {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 260px;
}
.rvg-lines-lookup-thumb {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm, 4px);
    object-fit: cover;
    background: var(--color-bg-alt);
    flex-shrink: 0;
}
.rvg-lines-lookup-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.rvg-lines-lookup-orphan {
    color: var(--color-text-muted);
    font-style: italic;
}

/* enum pill */
.rvg-lines-tag {
    display: inline-block;
    padding: 2px 10px;
    background: color-mix(in srgb, var(--color-accent, #3b82f6) 14%, var(--color-bg));
    color: var(--color-accent, #3b82f6);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
}

/* multiselect chips */
.rvg-lines-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    max-width: 260px;
}
.rvg-lines-chip {
    display: inline-block;
    padding: 1px 8px;
    background: var(--color-bg-alt);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    font-size: 11px;
    line-height: 1.5;
}

/* boolean indicator */
.rvg-lines-bool {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 14px;
    line-height: 1;
}
.rvg-lines-bool.is-yes {
    background: color-mix(in srgb, var(--color-success, #10b981) 14%, var(--color-bg));
    color: var(--color-success, #10b981);
}
.rvg-lines-bool.is-no {
    color: var(--color-text-muted);
}

/* email/url link */
.rvg-lines-link {
    color: var(--color-accent, #3b82f6);
    text-decoration: none;
    max-width: 260px;
    display: inline-block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}
.rvg-lines-link:hover {
    text-decoration: underline;
}

/* FR-131 — file chip: icon + extension badge instead of raw filename.
   Applied to <a class="rvg-file-chip" data-ext="pdf|jpg|dwg|..."> rendered
   by _lines_cell.twig for type=file/video/audio. The filename lives in
   the title attribute (tooltip on hover). */
.rvg-file-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: var(--ui-border-radius, 6px);
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    color: var(--color-text-soft);
    text-decoration: none;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.rvg-file-chip:hover {
    background: var(--color-bg);
    border-color: var(--color-accent);
    color: var(--color-accent);
    text-decoration: none;
}
.rvg-file-chip .revogen-icon {
    width: 16px;
    height: 16px;
}
.rvg-file-chip-ext {
    font-family: var(--font-mono, monospace);
    font-size: 10px;
}
/* Per-extension accent colors. Hover keeps the type color for continuity. */
.rvg-file-chip[data-ext="pdf"]  .revogen-icon { color: #c92a2a; }
.rvg-file-chip[data-ext="jpg"]  .revogen-icon,
.rvg-file-chip[data-ext="jpeg"] .revogen-icon,
.rvg-file-chip[data-ext="png"]  .revogen-icon,
.rvg-file-chip[data-ext="gif"]  .revogen-icon,
.rvg-file-chip[data-ext="webp"] .revogen-icon,
.rvg-file-chip[data-ext="svg"]  .revogen-icon,
.rvg-file-chip[data-ext="bmp"]  .revogen-icon,
.rvg-file-chip[data-ext="tiff"] .revogen-icon { color: #16a34a; }
.rvg-file-chip[data-ext="doc"]  .revogen-icon,
.rvg-file-chip[data-ext="docx"] .revogen-icon,
.rvg-file-chip[data-ext="rtf"]  .revogen-icon,
.rvg-file-chip[data-ext="odt"]  .revogen-icon { color: #2563eb; }
.rvg-file-chip[data-ext="xls"]  .revogen-icon,
.rvg-file-chip[data-ext="xlsx"] .revogen-icon,
.rvg-file-chip[data-ext="ods"]  .revogen-icon,
.rvg-file-chip[data-ext="csv"]  .revogen-icon { color: #15803d; }
.rvg-file-chip[data-ext="ppt"]  .revogen-icon,
.rvg-file-chip[data-ext="pptx"] .revogen-icon,
.rvg-file-chip[data-ext="odp"]  .revogen-icon { color: #ea580c; }
.rvg-file-chip[data-ext="dwg"]  .revogen-icon,
.rvg-file-chip[data-ext="dxf"]  .revogen-icon,
.rvg-file-chip[data-ext="dwf"]  .revogen-icon { color: #7c3aed; }
.rvg-file-chip[data-ext="mp3"]  .revogen-icon,
.rvg-file-chip[data-ext="wav"]  .revogen-icon,
.rvg-file-chip[data-ext="ogg"]  .revogen-icon,
.rvg-file-chip[data-ext="aac"]  .revogen-icon,
.rvg-file-chip[data-ext="flac"] .revogen-icon,
.rvg-file-chip[data-ext="m4a"]  .revogen-icon { color: #a855f7; }
.rvg-file-chip[data-ext="mp4"]  .revogen-icon,
.rvg-file-chip[data-ext="avi"]  .revogen-icon,
.rvg-file-chip[data-ext="mov"]  .revogen-icon,
.rvg-file-chip[data-ext="mkv"]  .revogen-icon,
.rvg-file-chip[data-ext="webm"] .revogen-icon,
.rvg-file-chip[data-ext="wmv"]  .revogen-icon,
.rvg-file-chip[data-ext="flv"]  .revogen-icon { color: #dc2626; }
.rvg-file-chip[data-ext="zip"]  .revogen-icon,
.rvg-file-chip[data-ext="rar"]  .revogen-icon,
.rvg-file-chip[data-ext="7z"]   .revogen-icon,
.rvg-file-chip[data-ext="tar"]  .revogen-icon,
.rvg-file-chip[data-ext="gz"]   .revogen-icon { color: #a16207; }
.rvg-file-chip[data-ext="txt"]  .revogen-icon,
.rvg-file-chip[data-ext="md"]   .revogen-icon,
.rvg-file-chip[data-ext="log"]  .revogen-icon { color: var(--color-text-soft); }
.rvg-file-chip[data-ext="html"] .revogen-icon,
.rvg-file-chip[data-ext="htm"]  .revogen-icon,
.rvg-file-chip[data-ext="js"]   .revogen-icon,
.rvg-file-chip[data-ext="css"]  .revogen-icon,
.rvg-file-chip[data-ext="php"]  .revogen-icon,
.rvg-file-chip[data-ext="json"] .revogen-icon,
.rvg-file-chip[data-ext="xml"]  .revogen-icon,
.rvg-file-chip[data-ext="sql"]  .revogen-icon,
.rvg-file-chip[data-ext="sh"]   .revogen-icon,
.rvg-file-chip[data-ext="yaml"] .revogen-icon,
.rvg-file-chip[data-ext="yml"]  .revogen-icon { color: #0d9488; }

/* image thumbnail */
.rvg-lines-img {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm, 4px);
    object-fit: cover;
    background: var(--color-bg-alt);
}

/* truncated text */
.rvg-lines-trunc {
    display: inline-block;
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}

/* FR-117 — datetime split: date in normal color, time in cool teal
   so the eye reads the date first + time as a distinct secondary
   detail. Stacked column (compact in inline-grids); the same renderer
   is used by list/detail/inline surfaces (see _lines_cell.twig). */
/* OP-53 + تعديل المالك (2026-06-11): nowrap فقط — أُلغي عزل LTR لأنّ
   «صباحاً/مساءً» كلمة عربيّة قويّة تثبّت الترتيب الطبيعي بنفسها
   (الساعة يميناً ثمّ الكلمة بعدها يساراً). */
.rvg-lines-dt {
    white-space: nowrap;
}
.rvg-lines-dt {
    display: inline-flex;
    flex-direction: column;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}
.rvg-lines-dt-date { font-size: 13px; color: var(--color-text); }
.rvg-lines-dt-time {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-time, #0d9488);
}

/* audit user + ts */
.rvg-lines-audit {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--color-text-muted);
    font-size: 12px;
}

/* muted/empty placeholder */
.rvg-lines-muted {
    color: var(--color-text-muted);
}

/* detail-surface enhancements */
.rvg-lines-pre {
    margin: 0;
    padding: 8px 10px;
    font-family: inherit;
    font-size: 13px;
    white-space: pre-wrap;
    word-wrap: break-word;
    background: var(--color-bg-alt);
    border-radius: var(--radius-sm, 4px);
    color: var(--color-text);
    line-height: 1.6;
    max-height: 320px;
    overflow-y: auto;
}
.rvg-lines-richtext {
    line-height: 1.7;
    color: var(--color-text);
}
.rvg-lines-richtext p   { margin: 0 0 8px; }
.rvg-lines-richtext ul,
.rvg-lines-richtext ol  { margin: 0 0 8px; padding-inline-start: 20px; }
.rvg-lines-richtext img { max-width: 100%; height: auto; border-radius: var(--radius-sm); }
.rvg-lines-richtext a   { color: var(--color-accent, #3b82f6); text-decoration: underline; }
.rvg-lines-image-large {
    max-width: 100%;
    max-height: 480px;
    border-radius: var(--radius-md, 8px);
    background: var(--color-bg-alt);
    object-fit: contain;
}
.rvg-lines-bool-text {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}
.rvg-lines-bool-text.is-yes {
    background: color-mix(in srgb, var(--color-success, #10b981) 14%, var(--color-bg));
    color: var(--color-success, #10b981);
}
.rvg-lines-bool-text.is-no {
    color: var(--color-text-muted);
}
.rvg-lines-tafqit {
    margin-top: 4px;
    font-size: 11px;
    color: var(--color-text-muted);
    line-height: 1.6;
}

/* ---------- editable cells (inputs) -------------------------- */
.rvg-lines.is-inline .rvg-lines-table tbody td {
    padding: 4px 6px;
    vertical-align: top;
}
.rvg-lines-input,
.rvg-lines-select,
.rvg-lines-textarea {
    width: 100%;
    min-width: 80px;
    padding: 6px 8px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm, 4px);
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 13px;
    font-family: inherit;
    line-height: 1.4;
}
.rvg-lines-input:focus,
.rvg-lines-select:focus,
.rvg-lines-textarea:focus {
    outline: none;
    border-color: var(--color-accent, #3b82f6);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-accent, #3b82f6) 20%, transparent);
}
.rvg-lines-input[type="number"] {
    text-align: end;
    font-variant-numeric: tabular-nums;
}
.rvg-lines-input[disabled],
.rvg-lines-select[disabled] {
    background: var(--color-bg-alt);
    color: var(--color-text-muted);
    cursor: not-allowed;
}
.rvg-lines-checkbox {
    width: 18px;
    height: 18px;
    accent-color: var(--color-accent, #3b82f6);
    cursor: pointer;
}

/* ---------- per-row actions ---------------------------------- */
.rvg-lines-actions-col {
    width: 1%;
    white-space: nowrap;
    text-align: end;
}
.rvg-lines-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm, 4px);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
}
.rvg-lines-btn:hover {
    background: var(--color-bg-hover);
    color: var(--color-text);
    border-color: var(--color-border);
}
.rvg-lines-btn.is-danger:hover {
    color: var(--color-danger, #ef4444);
    border-color: color-mix(in srgb, var(--color-danger, #ef4444) 40%, transparent);
}

/* ---------- empty state ------------------------------------- */
.rvg-lines-empty {
    padding: var(--space-6, 32px) var(--space-4, 16px);
    text-align: center;
    color: var(--color-text-muted);
}
.rvg-lines-empty-title {
    font-size: 14px;
    margin: 0 0 8px;
}
.rvg-lines-empty-cta {
    display: inline-block;
    margin-top: 8px;
    padding: 6px 14px;
    background: var(--color-accent, #3b82f6);
    color: var(--color-bg);
    border-radius: var(--radius-sm, 4px);
    text-decoration: none;
    font-size: 13px;
}

/* ---------- BoQ pill (inline mode, FR-101) ------------------ */
.rvg-lines-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 6px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
}
.rvg-lines-pill.is-in {
    background: color-mix(in srgb, var(--color-success, #10b981) 14%, var(--color-bg));
    color: var(--color-success, #10b981);
}
.rvg-lines-pill.is-out {
    background: color-mix(in srgb, var(--color-warning, #f59e0b) 14%, var(--color-bg));
    color: var(--color-warning, #f59e0b);
}
.rvg-lines-pill.is-checking {
    color: var(--color-text-muted);
}

/* ---------- responsive --------------------------------------- */

/* 1024 — slim padding, hide tertiary columns marked with `.col-tertiary` */
@media (max-width: 1024px) {
    .rvg-lines-table thead th,
    .rvg-lines-table tbody td { padding: 6px 10px; }
    .rvg-lines-table .col-tertiary { display: none; }
}

/* 768 — hide secondary columns marked with `.col-secondary` */
@media (max-width: 768px) {
    .rvg-lines-table thead th,
    .rvg-lines-table tbody td { font-size: 12px; padding: 6px 8px; }
    .rvg-lines-table .col-secondary { display: none; }
}

/* 520 — keep horizontal table + scroll. Card-stacking was tried but proved
   unusable for invoice-style data with 10+ rows (each row → 7+ vertical
   cells = endless scroll). Horizontal pan keeps N items in N rows. */
@media (max-width: 520px) {
    .rvg-lines-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .rvg-lines-table { min-width: 640px; font-size: 12px; }
    .rvg-lines-table thead th,
    .rvg-lines-table tbody td { padding: 6px 8px; }
}

/* 380 — even tighter. */
@media (max-width: 380px) {
    .rvg-lines-header { padding: 8px 12px; }
    .rvg-lines-title { font-size: 13px; }
    .rvg-lines-table { min-width: 560px; font-size: 11px; }
    .rvg-lines-table thead th,
    .rvg-lines-table tbody td { padding: 5px 6px; }
    .rvg-lines-lookup, .rvg-lines-chips, .rvg-lines-trunc, .rvg-lines-link { max-width: 160px; }
}

/* ---------- print / PDF mode -------------------------------- */
.rvg-lines.is-pdf {
    /* Always render on a light theme for printing — dark themes
       would emit black-on-black when printed. */
    background: #ffffff;
    color: #111111;
    border: 1px solid #cccccc;
    box-shadow: none;
}
.rvg-lines.is-pdf .rvg-lines-table thead th {
    background: #f5f5f5;
    color: #555555;
    border-bottom: 1px solid #cccccc;
}
.rvg-lines.is-pdf .rvg-lines-table tbody td {
    border-bottom: 1px solid #eeeeee;
    color: #111111;
}
.rvg-lines.is-pdf .rvg-lines-table tbody tr:hover {
    background: transparent;
}
.rvg-lines.is-pdf .rvg-lines-table tfoot td {
    background: #f0f0f0;
    color: #111111;
    border-top: 2px solid #cccccc;
}
.rvg-lines.is-pdf .rvg-lines-actions-col,
.rvg-lines.is-pdg .rvg-lines-btn { display: none; }
.rvg-lines.is-pdf .rvg-lines-tag,
.rvg-lines.is-pdf .rvg-lines-chip {
    background: #f5f5f5;
    color: #333333;
    border-color: #cccccc;
}

@media print {
    .rvg-lines { box-shadow: none; border-color: #cccccc; }
    .rvg-lines-actions-col, .rvg-lines-btn { display: none; }
}

/* ============================================================
 * FR-114 — In-page list modal.
 * <dialog> opened by [data-rvg-open-list-modal] elements.
 * Hosts an iframe of the standalone list page so the user
 * stays in context while drilling into the full list view.
 * ============================================================ */
.rvg-list-modal {
    border: none;
    padding: 0;
    background: var(--color-bg);
    color: var(--color-text);
    border-radius: var(--radius-lg, 12px);
    box-shadow: 0 24px 60px -16px rgba(0, 0, 0, 0.5);
    width: 90vw;
    max-width: 1400px;
    height: 85vh;
    max-height: 900px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    font-family: var(--font-primary, inherit);
}
.rvg-list-modal::backdrop {
    background: var(--rvg-modal-backdrop-bg);
    backdrop-filter: var(--rvg-modal-backdrop-blur);
}
.rvg-list-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3, 12px);
    padding: var(--space-3, 12px) var(--space-4, 16px);
    background: var(--color-bg-alt, var(--color-bg));
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}
.rvg-list-modal-title {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--color-text);
}
.rvg-list-modal-close {
    background: transparent;
    border: 1px solid transparent;
    color: var(--color-text-muted);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.15s;
}
.rvg-list-modal-close:hover {
    background: var(--color-bg-hover);
    color: var(--color-danger, #ef4444);
    border-color: var(--color-border);
}
.rvg-list-modal-frame {
    flex: 1;
    width: 100%;
    border: none;
    background: var(--color-bg);
}
@media (max-width: 768px) {
    .rvg-list-modal {
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
}

/* ============================================================
 * FR-114 — VISUAL ALIASES.
 * The inline-grid (form.twig) still uses `.rvg-ic-*` selectors
 * because Alpine bindings + JS handlers (BoQ pill, mirror,
 * add/remove row) target those exact classes. The preview tab
 * (_children.twig) still uses `.rvg-children-*`. We let them
 * keep their structural selectors but force them to LOOK like
 * `.rvg-lines-*` so the user sees one consistent design
 * language across CREATE / EDIT / DETAIL.
 *
 * Header bar, table colors, padding, borders, hover state,
 * footer totals — all mirror the canonical `.rvg-lines-*` look.
 * ============================================================ */

/* inline-grid (form.twig) keeps its own styling owned by revogen.css —
   FR-114 unification at the cell level only. The tabbed/card visual
   languages of each surface are preserved. */

/* "Open lines modal" button. Visually paired with the sibling "+ إضافة
   بند" (`.rvg-ic-add-btn`): identical padding / gap / radius / font, the
   only delta is the colour treatment — secondary outline vs filled
   primary. Keeps the two header buttons reading as one toolbar group
   instead of two unrelated controls glued together. */
.rvg-ic-viewall-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2, 8px);
    /* MUST match `.rvg-ic-add-btn` exactly so the pair renders the
       same physical box. line-height inherits from the document so the
       text box height is identical to the sibling filled button. */
    padding: 0.4rem 0.85rem;
    background: transparent;
    color: var(--color-accent);
    border: 1px solid var(--color-accent);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.rvg-ic-viewall-link .revogen-icon {
    width: 14px;
    height: 14px;
}
.rvg-ic-viewall-link:hover {
    background: var(--color-accent);
    color: #fff;
    border-color: var(--color-accent);
}

/* preview table (_children.twig) styling is owned by _children.twig itself
   (the inline <style> block there is the canonical look). FR-114 unification
   was applied at the CELL level only — _children.twig keeps its tabbed-card
   chrome which is more polished than the bare rvg-lines look. */

/* ============================================================
 *  Lines Modal Dialog  (FR-114)
 *
 *  Mirrors the QC modal shape: native <dialog>, centered, capped
 *  to 1100px / 92vh on desktop, full-sheet on mobile. The body
 *  is the only scroll surface; the head stays anchored at top.
 * ============================================================ */

.rvg-lines-modal-dialog {
    padding: 0;
    border: 1px solid var(--color-border);
    background: transparent;
    color: inherit;
    /* Width comes from `--rvg-modal-width-large` (90vw) — the unified
       framework token shared with adv-search and QC/QE modals. NEVER
       hard-code a width here. */
    width: var(--rvg-modal-width-large);
    max-width: var(--rvg-modal-width-large);
    /* fit-content height so the modal hugs its rows on short tables. */
    height: fit-content;
    max-height: 92vh;
    overflow: hidden;
    border-radius: var(--radius-lg, 14px);
    /* Theme-aware drop shadow — darker on dark themes than the hard-coded
       black-alpha used by QC. Falls back to QC's value on browsers without
       color-mix. */
    box-shadow: 0 24px 60px -16px color-mix(in srgb, var(--color-text) 35%, transparent);
}
.rvg-lines-modal-dialog::backdrop {
    background: var(--rvg-modal-backdrop-bg);
    backdrop-filter: var(--rvg-modal-backdrop-blur);
}

.rvg-lines-modal-frame {
    display: flex;
    flex-direction: column;
    background: var(--color-bg);
    color: var(--color-text);
    border-radius: inherit;
    max-height: inherit;
    font-family: var(--font-primary);
}

.rvg-lines-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 20px 12px;
    background: var(--color-bg-alt, var(--color-bg));
    border-bottom: 1px solid var(--color-border);
    flex: 0 0 auto;
}
.rvg-lines-modal-headline {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--color-text);
}
.rvg-lines-modal-close {
    background: transparent;
    border: 0;
    color: var(--color-text-muted);
    font-size: 20px;
    line-height: 1;
    padding: 4px 10px;
    cursor: pointer;
    border-radius: var(--radius-sm, 6px);
}
.rvg-lines-modal-close:hover {
    background: var(--color-bg-hover);
    color: var(--color-text);
}

.rvg-lines-modal-body {
    padding: 16px 20px 18px;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
}

/* Inner partial chrome (rendered server-side by `_lines_modal_body.twig`) */
.rvg-lines-modal .rvg-lines-modal-context {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
}
.rvg-lines-modal .rvg-lines-modal-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text);
}
.rvg-lines-modal .rvg-lines-modal-count {
    color: var(--color-text-muted);
    font-weight: 500;
    margin-inline-start: 6px;
}
.rvg-lines-modal .rvg-lines-modal-parent {
    color: var(--color-text-muted);
    font-size: 12px;
}
.rvg-lines-modal-empty {
    text-align: center;
    color: var(--color-text-muted);
    padding: 32px 12px;
    font-size: 13px;
}
.rvg-lines-modal-loading,
.rvg-lines-modal-error {
    text-align: center;
    padding: 24px 12px;
    margin: 0;
    color: var(--color-text-muted);
    font-size: 13px;
}
.rvg-lines-modal-error {
    color: var(--color-danger, #c33);
}

/* The injected lines table inherits all `.rvg-lines-table` styling; in
   the modal body we make sure the table card itself doesn't add extra
   shadow over the dialog frame (the dialog already provides the chrome). */
.rvg-lines-modal-body .rvg-lines {
    box-shadow: none;
    border-color: var(--color-border);
}

/* Tablets + phones — STILL a floating card, NOT a full sheet. With
   only 1–2 child rows, a "full sheet" leaves a giant empty white
   area that reads as a blank page, not as a modal. So we keep the
   card look (border + radius + shadow) but tighten the side gap
   and let it auto-size to the rows. The body still scrolls when
   there are many rows; we just don't pre-allocate the whole viewport. */
@media (max-width: 900px) {
    .rvg-lines-modal-dialog {
        width: 94vw;
        max-width: 94vw;
        max-height: 86dvh;
        /* keep border + radius + shadow from the desktop rules so the
           modal still reads as a foreground card */
    }
    .rvg-lines-modal-head { padding: 12px 14px 10px; }
    .rvg-lines-modal-headline { font-size: 15px; }
    .rvg-lines-modal-body { padding: 10px 12px 14px; }
    .rvg-lines-modal-body .rvg-lines { border-radius: 8px; }
}
