:root {
    --bg: #f6f8fb;
    --surface: #ffffff;
    --surface-2: #f6f8fb;
    --text: #162033;
    --muted: #64748b;
    --line: #dce4ee;
    --brand: #167f72;
    --brand-dark: #0f665d;
    --danger: #a03232;
    --success: #2f6f4e;
    --shadow: 0 16px 40px rgba(23, 37, 61, .10);
    --radius: 14px;
}

* { box-sizing: border-box; }
html { font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--text); background: var(--bg); }
body { margin: 0; min-width: 0; overflow-x: hidden; }
button, input, select, textarea { font: inherit; }
button { border: 1px solid var(--brand); border-radius: 9px; background: var(--brand); color: white; padding: .7rem 1rem; cursor: pointer; font-weight: 650; }
button:hover { background: var(--brand-dark); }
.button-link { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; border: 1px solid var(--brand); border-radius: 9px; background: var(--brand); color: white; padding: .7rem 1rem; text-decoration: none; font-weight: 650; line-height: 1; }
.button-link:hover { background: var(--brand-dark); }
button.secondary { background: white; color: var(--brand); border-color: #aab9c6; }
button.secondary:hover, button.ghost:hover, .button-link.secondary:hover { background: #e9f7f4; }
.button-link.secondary { background: white; color: var(--brand); border-color: #aab9c6; }
button.ghost { background: transparent; color: var(--text); border-color: transparent; }
button.danger { color: var(--danger); border-color: #d9a7a7; }
button.small { padding: .38rem .7rem; font-size: .85rem; }
button:disabled { opacity: .45; cursor: not-allowed; }


.app-brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: #1f2a44;
    text-decoration: none;
    min-width: 275px;
}
.app-brand-mark {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    color: var(--brand);
    flex: 0 0 auto;
}
.app-brand-mark svg { width: 46px; height: 46px; }
.app-brand-copy { display: grid; gap: 1px; line-height: 1.05; }
.app-brand-copy strong {
    font-size: 1.36rem;
    font-weight: 850;
    letter-spacing: .055em;
    color: #1f2a44;
}
.app-brand-copy small {
    color: var(--muted);
    font-size: .72rem;
    font-weight: 650;
    letter-spacing: .015em;
}
.sidebar {
    display: flex;
    flex-direction: column;
}
.sidebar-brand {
    margin-top: auto;
    padding: 18px 9px 2px;
    display: flex;
    align-items: center;
    gap: 9px;
    color: #1f2a44;
    border-top: 1px solid var(--line);
}
.sidebar-brand-link {
    display: inline-flex;
    border-radius: 8px;
    transition: transform .18s ease, box-shadow .18s ease;
}
.sidebar-brand-link:hover,
.sidebar-brand-link:focus-visible {
    transform: translateY(-1px);
    box-shadow: 0 5px 12px rgba(23, 32, 42, .14);
    outline: none;
}
.sidebar-brand img {
    display: block;
    width: 32px;
    height: 32px;
}
.sidebar-brand span { display: grid; gap: 1px; }
.sidebar-brand strong {
    font-size: .82rem;
    letter-spacing: .07em;
}
.sidebar-brand small {
    color: var(--muted);
    font-size: .66rem;
}

.app-header { height: auto; min-height: 86px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1rem 2rem; padding: 12px 28px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.app-header h1 { margin: 1px 0 0; font-size: 1.55rem; }
.eyebrow { margin: 0; color: var(--brand); text-transform: uppercase; letter-spacing: .12em; font-size: .72rem; font-weight: 800; }
.header-actions { display: flex; flex: 1 1 900px; align-items: center; justify-content: flex-end; flex-wrap: wrap; min-width: 0; gap: .65rem; }
.header-actions select { min-width: 250px; }
.session-identity { display: grid; gap: 2px; min-width: 140px; max-width: 220px; padding: 4px 2px; line-height: 1.15; }
.session-identity strong, .session-identity small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-identity small { color: var(--muted); }
.logout-form, .settings-actions form, .admin-row-actions form { margin: 0; }

.app-shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: calc(100vh - 86px); }
.sidebar { padding: 22px 16px; background: #eef4f5; border-right: 1px solid var(--line); }
.tabs { display: grid; gap: 7px; }
.tab { text-align: left; background: transparent; color: var(--text); border: 1px solid transparent; }
.tab.active { background: var(--surface); color: var(--brand); border-color: #cbd6df; box-shadow: 0 5px 12px rgba(23, 32, 42, .05); }
.summary-card { margin-top: 26px; padding: 16px; display: grid; gap: 5px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.summary-card span { font-size: .8rem; color: var(--muted); margin-top: 6px; }
.summary-card strong { font-size: 1.05rem; }
.save-state { margin-top: 15px; font-size: .82rem; color: var(--muted); text-align: center; }

.workspace { padding: 28px; overflow: hidden; }
.panel { display: none; max-width: 1500px; margin: 0 auto; }
.panel.active { display: block; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.panel-heading h2 { margin: 4px 0 0; font-size: 1.65rem; }
.intro { color: var(--muted); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; padding: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.form-row { display: flex; gap: 18px; }
.form-row > label { flex: 1; }
.form-row.compact { margin-bottom: 14px; }
label { display: grid; gap: 7px; font-size: .84rem; color: #344054; font-weight: 650; }
input, select, textarea { width: 100%; border: 1px solid #bcc7d2; border-radius: 8px; padding: .7rem .75rem; background: white; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(22, 127, 114, .16); border-color: var(--brand); }
textarea { resize: vertical; }
.span-2 { grid-column: span 2; }
.checkbox-label { display: flex; align-items: center; gap: 8px; align-self: end; min-height: 42px; }
.checkbox-label input { width: auto; }

.room-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 18px; align-items: start; }
.room-list-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; position: sticky; top: 108px; }
.room-list { display: grid; gap: 7px; }
.room-card { width: 100%; text-align: left; background: transparent; color: var(--text); border-color: transparent; padding: 12px; }
.room-card:hover { background: var(--surface-2); }
.room-card.active { background: #dff8f3; color: var(--brand-dark); border-color: #a9ddd5; }
.room-card strong, .room-card span { display: block; }
.room-card span { margin-top: 3px; color: var(--muted); font-size: .77rem; font-weight: 500; }
.room-editor { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.drawing-toolbar { display: flex; gap: 8px; align-items: end; margin-bottom: 10px; }
.drawing-toolbar label { margin-left: auto; width: 130px; }
.drawing-card { border: 1px solid var(--line); border-radius: 12px; background: #fbfcfd; overflow: hidden; }
#roomSvg { display: block; width: 100%; height: 520px; touch-action: none; cursor: crosshair; }
.drawing-help { margin: 0; padding: 10px 14px; font-size: .78rem; color: var(--muted); border-top: 1px solid var(--line); }
.metrics-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin: 14px 0; }
.metrics-grid > div { padding: 11px 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; }
.metrics-grid span, .metrics-grid strong { display: block; }
.metrics-grid span { color: var(--muted); font-size: .75rem; }
.metrics-grid strong { margin-top: 3px; }
.editor-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 14px 0; }
.subcard { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 14px; }
.subcard-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 9px; }
.subcard h3 { margin: 0; font-size: 1rem; }

.table-scroll { overflow: auto; }
.table-scroll.wide { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.data-table { width: 100%; border-collapse: collapse; font-size: .83rem; }
.data-table th, .data-table td { padding: 9px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.data-table th { color: #475467; font-size: .74rem; text-transform: uppercase; letter-spacing: .035em; background: #f8fafc; position: sticky; top: 0; z-index: 1; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table input, .data-table select { padding: .46rem .5rem; min-width: 76px; }
.data-table .money { white-space: nowrap; font-weight: 700; }
.data-table .row-actions { display: flex; gap: 5px; }
.quote-items-table { width: 100%; min-width: 1120px; table-layout: fixed; }
.quote-items-table input,
.quote-items-table select { min-width: 0; max-width: 100%; }
.quote-items-table input[data-field="adjustment"] { width: calc(100% - 1.1em); }
.quote-items-table .quote-col-room { width: 105px; }
.quote-items-table .quote-col-wall { width: 95px; }
.quote-items-table .quote-col-service { width: 200px; }
.quote-items-table .quote-col-basis { width: 125px; }
.quote-items-table .quote-col-quantity { width: 85px; }
.quote-items-table .quote-col-unit { width: 65px; }
.quote-items-table .quote-col-unit-price { width: 100px; }
.quote-items-table .quote-col-adjustment { width: 90px; }
.quote-items-table .quote-col-option { width: 62px; }
.quote-items-table .quote-col-total { width: 105px; }
.quote-items-table .quote-col-actions { width: 115px; }
.quote-items-table .option-cell { text-align: center; }
.quote-items-table .option-cell input { min-width: auto; width: 18px; height: 18px; }
.quote-items-table .option-item td { background: #fffaf0; }
.quote-items-table .items-group-row td { background: #f3ead4; color: #694f16; font-weight: 800; text-transform: uppercase; letter-spacing: .03em; }

.service-picker { display: grid; grid-template-columns: minmax(420px, 1fr) minmax(280px, .8fr) auto; align-items: end; gap: 18px; margin-bottom: 16px; }
.service-picker > div:first-child { display: grid; grid-template-columns: 1fr 1.5fr; gap: 12px; }
.service-picker .service-option-check { grid-column: 1 / -1; align-self: center; }
.service-picker .service-option-check input { width: auto; margin: 0; }
.service-preview { min-height: 62px; padding: 10px 12px; background: var(--surface-2); border-radius: 9px; color: var(--muted); font-size: .82rem; }
.service-preview strong { color: var(--text); }
.totals-card { width: 420px; margin: 18px 0 0 auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.totals-card > div { display: flex; justify-content: space-between; padding: 6px 0; }
.totals-card .grand-total { margin-top: 7px; padding-top: 12px; border-top: 2px solid var(--text); font-size: 1.15rem; }
.totals-card .options-total-heading { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); color: #694f16; font-weight: 800; }

.button-row { display: flex; gap: 8px; }
.button-row.end { justify-content: flex-end; margin-top: 14px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 50; max-width: 420px; padding: 13px 16px; background: #17202a; color: white; border-radius: 10px; box-shadow: var(--shadow); }
.toast.error { background: #7c2525; }

dialog { border: 0; border-radius: 16px; padding: 0; box-shadow: 0 30px 80px rgba(23, 32, 42, .28); }
dialog::backdrop { background: rgba(23, 32, 42, .45); }
.dialog-form { width: 420px; padding: 22px; display: grid; gap: 15px; }
.dialog-form.large { width: 720px; }
.dialog-form h2 { margin: 0 0 4px; }

.svg-grid-major { stroke: #d7e0e8; stroke-width: 1; }
.svg-grid-minor { stroke: #edf1f4; stroke-width: 1; }
.svg-room { fill: rgba(34, 87, 122, .10); stroke: #167f72; stroke-width: 3; }
.svg-wall { stroke: #167f72; stroke-width: 3; }
.svg-point { fill: white; stroke: #0f665d; stroke-width: 3; cursor: grab; }
.svg-point.dragging { cursor: grabbing; fill: #d8e9f4; }
.svg-label-bg { fill: white; stroke: #c7d2dc; stroke-width: 1; }
.svg-label { font-size: 14px; font-weight: 700; fill: #17202a; text-anchor: middle; dominant-baseline: middle; }
.svg-empty { font-size: 18px; fill: #667085; text-anchor: middle; }

@media print {
    .app-header, .sidebar { display: none !important; }
    .app-shell { display: block; }
    .workspace { padding: 0; }
}

/* Éditeur polygonal avancé */
body { min-width: 0; }
.room-layout { grid-template-columns: 260px minmax(0, 1fr); }
.room-main-fields > label { min-width: 180px; }
.drawing-toolbar { flex-wrap: wrap; align-items: center; }
.drawing-toolbar label { margin-left: 0; width: auto; min-width: 120px; }
.drawing-toolbar .toolbar-check { display: flex; align-items: center; gap: 7px; min-height: 40px; padding: 0 4px; }
.drawing-toolbar .toolbar-check input { width: auto; }
.compact-button { min-width: 42px; padding-left: .65rem; padding-right: .65rem; font-size: 1.1rem; }
#roomSvg { height: 600px; background: #fbfcfd; }
.validation-message { margin-top: 10px; padding: 10px 12px; border: 1px solid #d9a7a7; border-radius: 9px; background: #fff3f3; color: #8b2e2e; font-size: .84rem; font-weight: 650; }
.metrics-grid-wide { grid-template-columns: repeat(7, minmax(115px, 1fr)); }
.ceiling-card { margin-top: 14px; }
.ceiling-fields { display: grid; grid-template-columns: repeat(5, minmax(130px, 1fr)); gap: 12px; }
.wall-card { margin-top: 14px; }
.wall-table { min-width: 1080px; }
.wall-table input[data-field="label"] { min-width: 120px; }
.wall-table input[data-field="length"], .wall-table input[data-field="angle"], .wall-table input[data-field="height"] { width: 90px; min-width: 80px; }
.selected-row td { background: #e9f7f4 !important; }
.vertices-openings-columns { grid-template-columns: .7fr 1.8fr; }
.object-table { min-width: 1450px; }
.object-table input, .object-table select { min-width: 72px; }
.object-table input[type="checkbox"] { min-width: auto; width: 18px; height: 18px; }
.service-picker > div:first-child { grid-template-columns: 1fr 1fr 1.6fr; }
.service-picker .service-option-check { grid-column: 1 / -1; }
.muted-small { color: var(--muted); font-size: .76rem; font-weight: 500; }
.empty-cell { text-align: center !important; color: var(--muted); padding: 22px !important; }

.svg-open-polyline { fill: none; stroke: #167f72; stroke-width: 3; stroke-dasharray: 8 5; }
.svg-wall-hit { stroke: transparent; stroke-width: 18; cursor: pointer; }
.svg-wall { stroke: #167f72; stroke-width: 3; pointer-events: none; }
.svg-wall.selected { stroke: #b05a00; stroke-width: 5; }
.svg-label-bg.selected { fill: #fff4e8; stroke: #b05a00; }
.svg-label-bg, .svg-label, .svg-opening-gap, .svg-window, .svg-door, .svg-door-arc, .svg-opening, .svg-ceiling-opening, .svg-object, .svg-object-label, .svg-vertex-label { pointer-events: none; }
.svg-opening-gap { stroke: #fbfcfd; stroke-width: 9; }
.svg-window { stroke: #167f72; stroke-width: 3; }
.svg-door { stroke: #7b4b26; stroke-width: 3; }
.svg-door-arc { fill: none; stroke: #9b6a42; stroke-width: 1.5; stroke-dasharray: 4 3; }
.svg-opening { stroke: #8b5aa8; stroke-width: 5; stroke-dasharray: 6 3; }
.svg-ceiling-opening { fill: rgba(22, 129, 166, .12); stroke: #167f72; stroke-width: 2; stroke-dasharray: 5 3; }
.svg-object { fill: rgba(176, 90, 0, .16); stroke: #8b4d16; stroke-width: 2; }
.svg-object.circle { fill: rgba(120, 86, 160, .17); stroke: #6f4a91; }
.svg-object-label { font-size: 11px; font-weight: 700; fill: #344054; paint-order: stroke; stroke: #fff; stroke-width: 3; stroke-linejoin: round; }
.svg-object-label.centered { text-anchor: middle; dominant-baseline: middle; }
.svg-vertex-label { font-size: 12px; font-weight: 750; fill: #17202a; paint-order: stroke; stroke: #fff; stroke-width: 3; }
.svg-mode-label { font-size: 14px; font-weight: 750; fill: #b05a00; }

@media (max-width: 1500px) {
    .metrics-grid-wide { grid-template-columns: repeat(4, 1fr); }
    .ceiling-fields { grid-template-columns: repeat(3, 1fr); }
    .vertices-openings-columns { grid-template-columns: 1fr; }
}

.dialog-intro { margin: -4px 0 2px; color: var(--muted); line-height: 1.5; }
.sending-state { padding: 10px 12px; border-radius: 8px; background: #e9f7f4; color: #0f665d; font-weight: 700; }
button:disabled { opacity: .6; cursor: wait; }

/* Responsive layout — v1.6.0 */
html, body { max-width: 100%; }
img, svg { max-width: 100%; }
.table-scroll {
    max-width: 100%;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable;
}
.app-header, .app-shell, .workspace, .panel, .room-editor, .subcard { min-width: 0; }
.app-shell > *,
.workspace > *,
.service-picker,
.service-picker > *,
.service-picker > div > *,
#panel-items,
#panel-items > * { min-width: 0; }
.workspace,
.panel,
#panel-items,
.quote-table-responsive { width: 100%; max-width: 100%; }
.quote-table-responsive {
    display: block;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
}
.quote-table-responsive:focus-visible {
    outline: 3px solid rgba(22, 127, 114, .22);
    outline-offset: 2px;
}

/* Authentification et administration multi-entreprises — v1.6.0 */
.auth-page { min-height: 100vh; min-height: 100dvh; background: radial-gradient(circle at top left, #dff8f3 0, transparent 42%), var(--bg); }
.auth-shell { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(100%, 460px); display: grid; gap: 22px; padding: 30px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.auth-brand { min-width: 0; width: max-content; max-width: 100%; }
.auth-card h1, .settings-title h1, .settings-card h1 { margin: 5px 0 0; }
.auth-form, .settings-form { display: grid; gap: 15px; }
.auth-form button, .settings-form > button { width: max-content; min-width: 180px; }
.auth-help, .field-help { margin: 0; color: var(--muted); font-size: .8rem; line-height: 1.5; }
.form-alert { padding: 12px 14px; border: 1px solid; border-radius: 9px; line-height: 1.45; }
.form-alert.error { color: #7c2525; background: #fff3f3; border-color: #e5b6b6; }
.form-alert.success { color: #155f43; background: #edfbf5; border-color: #a9ddc7; }

.settings-page { min-height: 100vh; background: var(--bg); }
.settings-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 24px; background: var(--surface); border-bottom: 1px solid var(--line); }
.settings-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.settings-main { width: min(100%, 1280px); margin: 0 auto; padding: 28px; display: grid; gap: 20px; }
.settings-main.narrow { width: min(100%, 720px); }
.settings-title { min-width: 0; }
.settings-card { min-width: 0; padding: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.settings-card h2 { margin: 0 0 18px; }
.settings-form.grid-two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.settings-form.grid-two > button { grid-column: 1 / -1; }
.account-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 18px 0; }
.account-summary > div { min-width: 0; padding: 12px; background: var(--surface-2); border-radius: 9px; }
.account-summary dt { color: var(--muted); font-size: .78rem; }
.account-summary dd { margin: 4px 0 0; overflow-wrap: anywhere; font-weight: 700; }
.admin-table { min-width: 980px; }
.admin-row-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.reset-form { display: flex; align-items: center; gap: 6px; }
.reset-form input { width: 230px; min-width: 180px; padding: .4rem .5rem; }


.ral-workspace { display: grid; grid-template-columns: minmax(320px, 410px) minmax(0, 1fr); gap: 18px; align-items: start; }
.ral-selection-editor { position: sticky; top: 108px; box-shadow: var(--shadow); }
.ral-current-choice { display: flex; align-items: center; gap: 13px; margin-bottom: 16px; padding: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px; }
.ral-current-choice small, .ral-current-choice strong { display: block; }
.ral-current-choice small { color: var(--muted); font-size: .72rem; margin-bottom: 3px; }
.ral-current-choice strong { font-size: 1rem; }
.ral-current-swatch { width: 66px; height: 66px; flex: 0 0 66px; border-radius: 10px; border: 1px dashed #aab7c5; background: repeating-linear-gradient(45deg,#f5f7fa,#f5f7fa 8px,#e9edf2 8px,#e9edf2 16px); box-shadow: inset 0 0 0 1px rgba(255,255,255,.45); }
.ral-current-swatch.has-color { border-style: solid; border-color: rgba(22,32,51,.18); }
.ral-form-grid { padding: 0; border: 0; box-shadow: none; gap: 13px; }
.ral-browser { min-width: 0; }
.ral-filters { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(180px, 260px); gap: 12px; margin-bottom: 12px; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.ral-palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 9px; max-height: 650px; overflow: auto; padding: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); scrollbar-width: thin; }
.ral-swatch-button { min-width: 0; padding: 0; overflow: hidden; border: 2px solid transparent; background: var(--surface); color: var(--text); border-radius: 9px; text-align: left; box-shadow: 0 2px 8px rgba(22,32,51,.08); }
.ral-swatch-button:hover { background: var(--surface); border-color: #9ab8b2; transform: translateY(-1px); }
.ral-swatch-button.selected { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(22,127,114,.18); }
.ral-swatch-color { display: grid; place-content: center; min-height: 78px; text-align: center; line-height: 1; text-shadow: 0 1px 3px rgba(0,0,0,.16); }
.ral-swatch-color strong { font-size: .65rem; letter-spacing: .18em; opacity: .86; }
.ral-swatch-color span { margin-top: 5px; font-size: 1rem; font-weight: 850; letter-spacing: .04em; }
.ral-swatch-button small { display: block; min-height: 31px; padding: 6px 7px; color: var(--muted); font-size: .62rem; line-height: 1.25; background: var(--surface); }
.ral-empty-palette { grid-column: 1 / -1; color: var(--muted); text-align: center; padding: 24px; }
.ral-selections-section { margin-top: 22px; }
.section-heading-inline { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.section-heading-inline h3 { margin: 0; }
.count-badge { display: inline-grid; place-items: center; min-width: 28px; height: 28px; padding: 0 8px; border-radius: 99px; background: #dff8f3; color: var(--brand-dark); font-weight: 800; font-size: .78rem; }
.ral-selection-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; }
.ral-selection-card { display: grid; grid-template-columns: 118px minmax(0, 1fr); min-width: 0; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 5px 16px rgba(22,32,51,.07); }
.ral-selection-swatch { display: grid; place-content: center; min-height: 132px; text-align: center; text-shadow: 0 1px 3px rgba(0,0,0,.16); }
.ral-selection-swatch small { font-size: .7rem; letter-spacing: .2em; font-weight: 800; }
.ral-selection-swatch strong { margin-top: 6px; font-size: 1.5rem; letter-spacing: .05em; }
.ral-selection-copy { min-width: 0; padding: 13px; }
.ral-selection-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.ral-selection-title > div { min-width: 0; }
.ral-selection-title strong, .ral-selection-title span { display: block; }
.ral-selection-title strong { overflow-wrap: anywhere; }
.ral-selection-title > div > span { margin-top: 4px; color: var(--muted); font-size: .74rem; line-height: 1.35; }
.ral-selection-copy p { margin: 10px 0; color: #475467; font-size: .82rem; line-height: 1.45; white-space: pre-wrap; }
.ral-selection-copy .row-actions { display: flex; gap: 6px; margin-top: 10px; }
.ral-status { flex: 0 0 auto; padding: 4px 7px; border-radius: 99px; font-size: .66rem; font-weight: 800; white-space: nowrap; background: #eef2f6; color: #475467; }
.ral-status-selected { background: #fff5d9; color: #8a5b00; }
.ral-status-approved { background: #e6f7ef; color: #176044; }
.ral-disclaimer { margin: 16px 0 0; padding: 11px 13px; border-left: 4px solid #d8a22d; background: #fff9e9; color: #6d5520; border-radius: 0 9px 9px 0; font-size: .78rem; line-height: 1.5; }
.ral-presentation-dialog { width: min(1180px, calc(100vw - 34px)); max-width: 1180px; max-height: calc(100vh - 34px); padding: 0; border: 0; border-radius: 16px; overflow: hidden; }
.ral-presentation-dialog::backdrop { background: rgba(12,20,35,.72); backdrop-filter: blur(4px); }
.ral-presentation-shell { padding: 22px; max-height: calc(100vh - 34px); overflow: auto; background: #f7f9fb; }
.ral-presentation-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; margin-bottom: 18px; }
.ral-presentation-header h2 { margin: 4px 0 5px; font-size: 1.8rem; }
.ral-presentation-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 15px; }
.ral-selection-card.presentation { grid-template-columns: 155px minmax(0, 1fr); min-height: 180px; }
.ral-selection-card.presentation .ral-selection-swatch { min-height: 180px; }
.ral-selection-card.presentation .ral-selection-swatch strong { font-size: 2rem; }
.ral-selection-card.presentation .ral-selection-copy { padding: 18px; }
.ral-selection-card.presentation .ral-selection-title strong { font-size: 1.1rem; }

@media (max-width: 1240px) {
    .ral-workspace { grid-template-columns: 340px minmax(0, 1fr); }
    .app-header {
        height: auto;
        min-height: 86px;
        padding: 12px 20px;
        flex-wrap: wrap;
        gap: 12px;
    }
    .app-brand { min-width: 230px; }
    .header-actions {
        flex: 1 1 650px;
        justify-content: flex-end;
        flex-wrap: wrap;
    }
    .header-actions select { min-width: 220px; flex: 1 1 240px; }
    .session-identity { flex: 1 1 220px; }
    .app-shell { grid-template-columns: 190px minmax(0, 1fr); min-height: calc(100vh - 86px); }
    .workspace { padding: 20px; }
    .room-layout { grid-template-columns: 220px minmax(0, 1fr); }
    .editor-columns, .vertices-openings-columns { grid-template-columns: 1fr; }
    .service-picker { grid-template-columns: 1fr; }
    .service-picker > div:first-child { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .service-picker > button { justify-self: end; }
}

@media (max-width: 1024px) {
    .ral-workspace { grid-template-columns: 1fr; }
    .ral-selection-editor { position: static; top: auto; }
    .ral-palette { max-height: 520px; }
    .app-header { position: relative; top: auto; }
    .app-shell { display: block; min-height: 0; }
    .sidebar {
        position: relative;
        top: auto;
        z-index: 10;
        flex-direction: row;
        align-items: center;
        gap: 12px;
        padding: 10px 16px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }
    .tabs {
        display: flex;
        flex: 1 1 auto;
        gap: 6px;
        min-width: 0;
        overflow-x: auto;
        padding-bottom: 2px;
        scrollbar-width: thin;
    }
    .tab { flex: 0 0 auto; white-space: nowrap; text-align: center; }
    .summary-card { display: none; }
    .save-state { margin: 0; white-space: nowrap; }
    .sidebar-brand {
        margin: 0 0 0 auto;
        padding: 0;
        border-top: 0;
        flex: 0 0 auto;
    }
    .room-layout { grid-template-columns: 1fr; }
    .room-list-wrap {
        position: static;
        top: auto;
        overflow-x: auto;
        padding: 8px;
    }
    .room-list { display: flex; min-width: max-content; }
    .room-card { width: 190px; min-height: 66px; }
    .ceiling-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .metrics-grid-wide { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .totals-card { width: min(100%, 520px); }
}

@media (max-width: 760px) {
    .ral-filters { grid-template-columns: 1fr; }
    .ral-palette { grid-template-columns: repeat(auto-fill, minmax(82px, 1fr)); padding: 7px; gap: 7px; max-height: 480px; }
    .ral-selection-list, .ral-presentation-grid { grid-template-columns: 1fr; }
    .ral-presentation-dialog { width: calc(100vw - 20px); max-width: calc(100vw - 20px); }
    .ral-presentation-shell { padding: 14px; }
    .ral-presentation-header { flex-direction: column; }
    .ral-presentation-header button { width: 100%; }
    :root { --radius: 11px; --shadow: 0 8px 24px rgba(23, 37, 61, .09); }
    body { font-size: 15px; }
    button { min-height: 44px; }
    input, select, textarea { font-size: 16px; }

    .app-header {
        display: grid;
        grid-template-columns: 1fr;
        align-items: stretch;
        padding: 12px;
        gap: 12px;
    }
    .app-brand { min-width: 0; width: 100%; }
    .app-brand-mark, .app-brand-mark svg { width: 40px; height: 40px; }
    .app-brand-copy strong { font-size: 1.2rem; }
    .app-brand-copy small { font-size: .68rem; }
    .header-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
        gap: 8px;
    }
    .header-actions select { grid-column: 1 / -1; min-width: 0; }
    .header-actions button { width: 100%; padding-inline: .55rem; }
    .header-actions .button-link { width: 100%; padding-inline: .55rem; }
    .header-actions .session-identity { grid-column: 1 / -1; width: 100%; max-width: none; }
    .header-actions .logout-form, .header-actions .logout-form button { width: 100%; }

    .sidebar { display: block; padding: 8px 10px; }
    .tabs { width: 100%; }
    .tab { min-height: 40px; padding: .55rem .8rem; }
    .save-state { display: none; }
    .sidebar-brand { display: none; }

    .workspace { padding: 12px; }
    .panel-heading {
        align-items: stretch;
        flex-direction: column;
        gap: 12px;
        margin-bottom: 14px;
    }
    .panel-heading h2 { font-size: 1.35rem; }
    .panel-heading > button { width: 100%; }
    .intro { line-height: 1.55; }

    .form-grid { grid-template-columns: 1fr; gap: 14px; padding: 14px; }
    .form-grid .span-2, .span-2 { grid-column: auto; }
    .form-row { flex-direction: column; gap: 12px; }
    .form-row > label { width: 100%; min-width: 0; }

    .room-editor { padding: 12px; }
    .drawing-toolbar {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        align-items: stretch;
    }
    .drawing-toolbar > button { width: 100%; padding-inline: .5rem; }
    .drawing-toolbar > label,
    .drawing-toolbar .toolbar-check {
        grid-column: 1 / -1;
        width: 100%;
        min-width: 0;
    }
    .drawing-toolbar .toolbar-check { padding: 7px 3px; }
    #roomSvg {
        height: min(58vh, 470px);
        min-height: 340px;
    }
    .drawing-help { line-height: 1.45; }
    .metrics-grid, .metrics-grid-wide { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .metrics-grid > div { min-width: 0; }
    .editor-columns, .vertices-openings-columns { grid-template-columns: 1fr; }
    .ceiling-fields { grid-template-columns: 1fr; }
    .subcard { padding: 11px; }
    .subcard-heading { gap: 8px; flex-wrap: wrap; }
    .subcard-heading button { margin-left: auto; }

    .table-scroll {
        width: 100%;
        border: 1px solid var(--line);
        border-radius: 10px;
        background: var(--surface);
    }
    .table-scroll.wide { box-shadow: none; }
    .data-table th, .data-table td { padding: 8px 7px; }
    .data-table th { position: static; }
    .data-table .row-actions { flex-wrap: wrap; }

    .service-picker { display: grid; grid-template-columns: 1fr; padding: 12px; gap: 12px; }
    .service-picker > div:first-child { grid-template-columns: 1fr; }
    .service-picker .service-option-check { grid-column: auto; }
    .service-picker > button { width: 100%; justify-self: stretch; }
    .service-preview { min-height: 0; }
    .totals-card { width: 100%; margin-top: 14px; padding: 13px; }

    .button-row { flex-wrap: wrap; }
    .button-row.end > button { flex: 1 1 160px; }
    .toast {
        left: 12px;
        right: 12px;
        bottom: 12px;
        max-width: none;
    }

    dialog {
        width: calc(100vw - 20px);
        max-width: calc(100vw - 20px);
        max-height: calc(100vh - 20px);
        max-height: calc(100dvh - 20px);
        overflow: auto;
        border-radius: 12px;
    }
    .dialog-form, .dialog-form.large { width: 100%; padding: 16px; }
    .auth-shell { padding: 12px; }
    .auth-card { padding: 22px 18px; }
    .settings-header { align-items: stretch; flex-direction: column; padding: 14px; }
    .settings-header .app-brand { min-width: 0; }
    .settings-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .settings-actions > *, .settings-actions form button { width: 100%; }
    .settings-main { padding: 14px; }
    .settings-card { padding: 16px; }
    .settings-form.grid-two { grid-template-columns: 1fr; }
    .settings-form.grid-two .span-2, .settings-form.grid-two > button { grid-column: auto; }
    .account-summary { grid-template-columns: 1fr; }
    .auth-form button, .settings-form > button { width: 100%; }
}

@media (max-width: 480px) {
    .ral-selection-card, .ral-selection-card.presentation { grid-template-columns: 96px minmax(0, 1fr); }
    .ral-selection-swatch, .ral-selection-card.presentation .ral-selection-swatch { min-height: 150px; }
    .ral-selection-title { flex-direction: column; }
    .ral-status { white-space: normal; }
    .header-actions { grid-template-columns: 1fr; }
    .header-actions select { grid-column: auto; }
    .app-brand-copy small { display: none; }
    .workspace { padding: 9px; }
    .room-card { width: 165px; }
    .drawing-toolbar { grid-template-columns: 1fr; }
    .drawing-toolbar > label,
    .drawing-toolbar .toolbar-check { grid-column: auto; }
    #roomSvg { min-height: 300px; height: 52vh; }
    .metrics-grid, .metrics-grid-wide { grid-template-columns: 1fr 1fr; gap: 7px; }
    .metrics-grid > div { padding: 9px; }
    .button-row.end > button { flex-basis: 100%; }
    .totals-card > div { gap: 10px; }
    .totals-card strong { text-align: right; }
    .settings-actions { grid-template-columns: 1fr; }
}

@media (hover: none) and (pointer: coarse) {
    .svg-wall-hit { stroke-width: 28; }
    .svg-point { stroke-width: 4; }
    button.small { min-height: 40px; }
}
