/* Pricing Engine: shared parts of the redesigned pages (Approvals, Models,
   Partners, Ask). Values come only from the Uliverse block in tokens.css. */

/* Buttons: one red primary per screen, everything else quiet. */
.btn-decide, .btn-second {
    min-height: var(--target);
    padding: 0 var(--space-6);
    border-radius: var(--radius-pill);
    font-family: var(--font-family);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 140ms var(--ease-out), color 140ms var(--ease-out);
}
.btn-decide { background: var(--red-aa); color: #fff; border: 1px solid var(--red-aa); }
.btn-decide:hover { background: var(--red-hover); border-color: var(--red-hover); color: #fff; }
.btn-second { background: var(--card); color: var(--ink); border: 1px solid var(--border); }
.btn-second:hover { background: var(--container); color: var(--ink); }
.btn-decide:active, .btn-second:active { transform: scale(.97); }
.btn-decide[aria-disabled="true"], .btn-decide:disabled { background: var(--container); border-color: var(--border); color: var(--ink-2); cursor: not-allowed; pointer-events: none; }
.btn-quiet { background: none; border: none; padding: var(--space-2) 0; font-family: var(--font-family); font-size: 14px; color: var(--ink-2); text-decoration: underline; cursor: pointer; min-height: 32px; }
.btn-quiet:hover { color: var(--ink); }

/* Status: one dot plus a word. The word is always ink; colour is never the signal. */
.status { display: inline-flex; align-items: center; gap: var(--space-2); font-size: 13px; color: var(--ink); white-space: nowrap; }
.status::before { content: ''; width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.status-info::before { background: var(--info); }
.status-up::before { background: var(--up); }
.status-amber::before { background: var(--amber); }
.status-muted::before { background: var(--ink-3); }

.money-lg { font-size: 32px; font-weight: 600; line-height: 40px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; color: var(--ink); }

/* Loading is a skeleton at the real height, never a spinner. */
.q-skeleton { height: 56px; border-radius: var(--radius-soft); background: var(--container); }
@media (prefers-reduced-motion: no-preference) {
    .q-skeleton { animation: skel 1.6s var(--ease-io) infinite; }
}
@keyframes skel { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

/* Overlay plane for dialogs: warm scrim, soft blur, above the nav and top bar. */
.scrim { z-index: 300; background: rgba(26, 23, 20, 0.55); backdrop-filter: blur(6px) saturate(90%); -webkit-backdrop-filter: blur(6px) saturate(90%); }
@media (prefers-reduced-transparency: reduce) {
    .scrim { background: rgba(26, 23, 20, 0.72); backdrop-filter: none; -webkit-backdrop-filter: none; }
}
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Page frame */
.page { display: flex; flex-direction: column; gap: var(--space-6); }
.page-top { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; }
.page-top h1 { margin: 0; }
.page-count { font-size: 15px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.page-back { display: inline-flex; align-items: center; min-height: 32px; font-size: 14px; color: var(--ink-2); }
.page-back:hover { color: var(--ink); }
.page-sub { font-size: 15px; color: var(--ink-2); display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.page-actions { display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap; }

/* Panels: raised cards on the warm ground. */
.panel { background: var(--card); border-radius: var(--radius-panel); box-shadow: var(--shadow-sm); padding: var(--space-6); display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
.panel > h2 { font-size: 17px; font-weight: 600; line-height: 24px; }
.panel-flush { padding: 0; overflow: hidden; gap: 0; }
.panel-flush > h2 { padding: var(--space-5) var(--space-6) var(--space-2); }
.panel-note { font-size: 14px; color: var(--ink-2); }
.panel details > summary, details.panel > summary { min-height: var(--target); display: flex; align-items: center; font-size: 15px; font-weight: 600; color: var(--ink); cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::after { content: ''; width: 8px; height: 8px; margin-left: var(--space-3); border-right: 2px solid var(--ink-2); border-bottom: 2px solid var(--ink-2); transform: rotate(45deg) translateY(-2px); transition: transform 140ms var(--ease-out); }
details[open] > summary::after { transform: rotate(-135deg) translateY(-2px); }

/* Filters */
.filters { display: flex; gap: var(--space-3); flex-wrap: wrap; align-items: center; }
.filters .form-input, .filters .form-select { width: auto; min-height: var(--target); padding: 0 var(--space-4); font-size: 15px; border-color: var(--border); border-radius: var(--radius-soft); background-color: var(--card); color: var(--ink); }
.filters .form-input { flex: 1; min-width: 240px; max-width: 360px; }
.filters .form-input::placeholder { color: var(--ink-2); }
.toggle { display: inline-flex; align-items: center; gap: var(--space-2); min-height: var(--target); padding: 0 var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-soft); background: var(--card); font-size: 15px; color: var(--ink); cursor: pointer; }
.toggle input { width: 18px; height: 18px; accent-color: var(--red-aa); }
.toggle:has(input:checked) { border-color: var(--ink); }
.filters-clear { margin-left: auto; }

/* Tables: 48px rows, text left, numbers right in tabular figures, no zebra. */
.tbl { width: 100%; border-collapse: collapse; font-size: 15px; }
.tbl th { text-align: left; font-size: 13px; font-weight: 500; color: var(--ink-2); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { height: 48px; padding: var(--space-2) var(--space-4); border-bottom: 1px solid var(--border); color: var(--ink); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; white-space: nowrap; }
.tbl .code { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.tbl .nil { color: var(--ink-2); }
.tbl tr.is-link { cursor: pointer; }
@media (hover: hover) and (pointer: fine) { .tbl tr.is-link:hover td { background: var(--container); } }
.tbl a.row-name { color: var(--ink); font-weight: 600; }
.tbl a.row-name:hover { color: var(--ink); text-decoration: underline; }
.tbl-scroll { overflow-x: auto; }
.tbl td > .code { margin-left: var(--space-2); }

/* Detail pages and dialogs */
.model-head { display: flex; flex-direction: column; gap: var(--space-2); }
.sub-h { font-size: 15px; font-weight: 600; margin-top: var(--space-2); }
.model-dialog { position: fixed; inset: 0; align-items: center; justify-content: center; padding: var(--space-4); }
.dialog { background: var(--card); border-radius: var(--radius-panel); box-shadow: var(--shadow-lg); padding: var(--space-8); width: 480px; max-width: 100%; max-height: 100%; overflow-y: auto; display: flex; flex-direction: column; gap: var(--space-3); }
.dialog h3 { font-size: 20px; font-weight: 600; }
.dialog .form-input, .dialog .form-select { border-color: var(--border); min-height: var(--target); }
.dialog-actions { display: flex; justify-content: flex-end; gap: var(--space-3); margin-top: var(--space-2); }
.dialog-pair { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.dialog-pair.three { grid-template-columns: 1fr 1fr 1fr; }

/* States */
.state { padding: var(--space-12) var(--space-6); text-align: center; color: var(--ink-2); display: flex; flex-direction: column; align-items: center; gap: var(--space-3); }
.state strong { font-size: 17px; font-weight: 600; color: var(--ink); }
.state-error { text-align: left; align-items: flex-start; padding: var(--space-5) var(--space-6); border-inline-start: 2px solid var(--amber); color: var(--ink); }
.partial { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.is-loading { opacity: .55; transition: opacity 140ms var(--ease-out); }
.htmx-request.results, .htmx-request .results { opacity: .55; transition: opacity 140ms var(--ease-out); }

/* Pager: words, not a row of numbered buttons. */
.pager { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border); font-size: 14px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.pager a { display: inline-flex; align-items: center; min-height: var(--target); padding: 0 var(--space-3); color: var(--ink); font-weight: 600; }
.pager a:hover { color: var(--ink); text-decoration: underline; }
.pager .off { visibility: hidden; }

.kv { display: flex; flex-direction: column; }
.kv > div { display: flex; justify-content: space-between; gap: var(--space-4); min-height: 40px; align-items: center; border-bottom: 1px solid var(--border); font-size: 15px; }
.kv > div:last-child { border-bottom: none; }
.kv dt { color: var(--ink-2); }
.kv dd { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }
.kv dd.strong { font-weight: 600; }
.kv dd a, .panel-note a { color: var(--ink); text-decoration: underline; }

@media (max-width: 768px) {
    .page { gap: var(--space-4); }
    .page-top h1 { font-size: 24px; line-height: 32px; }
    .panel { padding: var(--space-5); }
    .panel-flush { padding: 0; }
    .panel-flush > h2 { padding: var(--space-4) var(--space-4) var(--space-2); }
    .filters { display: grid; grid-template-columns: 1fr 1fr; }
    .filters .form-input { grid-column: 1 / -1; max-width: none; min-width: 0; width: 100%; }
    .filters .form-select, .filters .toggle { width: 100%; min-width: 0; }
    .filters-clear { margin-left: 0; justify-self: start; }
    .tbl { font-size: 14px; }
    .tbl th, .tbl td { padding-left: var(--space-3); padding-right: var(--space-3); }
    .tbl .hide-sm { display: none; }
    .tbl td > .code { display: block; margin-left: 0; }
    .dialog { padding: var(--space-5); }
    .dialog-pair, .dialog-pair.three { grid-template-columns: 1fr; }
    .money-lg { font-size: 28px; line-height: 36px; }
}

/* hidden means hidden, whatever display a class sets. */
[hidden] { display: none !important; }
.tbl .sku-code { white-space: nowrap; }
.form-input::placeholder { color: var(--ink-2); }
/* One focus ring, the doctrine one; not the legacy double red border. */
.form-input:focus, .form-select:focus { border: 1px solid var(--ink-2); outline: none; }
.form-input:focus-visible, .form-select:focus-visible { outline: 2px solid var(--red-aa); outline-offset: 2px; }

/* ===== Phase 3: forms, tabs, dialogs, messages. Moved off the old
   components.css onto the Uliverse block, so that file could go. ===== */

/* Forms: labels on top, "Optional" in words, errors under the field. */
.form-label { display: block; font-size: 13px; font-weight: 500; line-height: 20px; color: var(--ink-2); margin-bottom: var(--space-1); }
.form-input, .form-select { width: 100%; min-height: var(--target); padding: 0 var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-soft); background-color: var(--card); font-family: var(--font-family); font-size: 15px; color: var(--ink); }
textarea.form-input { padding: var(--space-3) var(--space-4); resize: vertical; line-height: 1.5; }
.form-input:disabled, .form-select:disabled { background: var(--container); color: var(--ink-2); cursor: not-allowed; }
.form-input[aria-invalid="true"], .form-select[aria-invalid="true"] { border-color: var(--amber); box-shadow: 0 0 0 1px var(--amber); }
.num-input { font-variant-numeric: tabular-nums; max-width: 200px; }
.field { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; border: none; }
.field > .form-label { margin-bottom: 0; }
.optional { font-weight: 400; color: var(--ink-2); margin-left: var(--space-1); }
.field-help { font-size: 13px; color: var(--ink-2); }
.field-error { display: flex; align-items: center; gap: var(--space-2); font-size: 13px; color: var(--amber-text); }
.field-error::before { content: '!'; flex-shrink: 0; width: 16px; height: 16px; border-radius: 50%; background: var(--amber); color: var(--card); font-size: 11px; font-weight: 700; line-height: 16px; text-align: center; }

/* Inline messages: alert for what failed, notice for what to know. */
.alert, .notice { padding: var(--space-3) var(--space-4); border-radius: var(--radius-soft); background: var(--container); color: var(--ink); font-size: 14px; display: flex; flex-direction: column; gap: var(--space-2); }
.alert { border-inline-start: 2px solid var(--amber); }
.notice-actions { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }

/* Tabs: ink and weight carry the selection; the red mark is the one accent. */
.tab-bar { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tab-bar::-webkit-scrollbar { display: none; }
.tab-item { min-height: var(--target); padding: 0 var(--space-4); background: none; border: none; border-bottom: 2px solid transparent; font-family: var(--font-family); font-size: 15px; font-weight: 500; color: var(--ink-2); cursor: pointer; white-space: nowrap; flex-shrink: 0; }
.tab-item:hover { color: var(--ink); }
.tab-item.active { color: var(--ink); font-weight: 600; border-bottom-color: var(--red-aa); }

/* Segmented choice: the picked one is ink-bordered, never filled red. */
.segmented { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.segmented > button, .segmented > label { position: relative; display: inline-flex; align-items: center; min-height: 40px; padding: 0 var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-pill); background: var(--card); font-family: var(--font-family); font-size: 14px; color: var(--ink-2); cursor: pointer; }
.segmented > button.active, .segmented > label:has(input:checked) { border-color: var(--ink); color: var(--ink); font-weight: 600; }
.segmented > label input { position: absolute; opacity: 0; pointer-events: none; }
.segmented > label:has(input:focus-visible) { outline: 2px solid var(--red-aa); outline-offset: 2px; }

/* Dialogs: 480 by default, 640 for the proposal; one primary action. */
.model-dialog { display: flex; }
body.has-dialog { overflow: hidden; }
.dialog { gap: var(--space-4); }
.dialog h3 { line-height: 28px; }
.dialog-640 { width: 640px; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); }
.dialog-close { flex-shrink: 0; width: 40px; height: 40px; margin: calc(var(--space-2) * -1) calc(var(--space-2) * -1) 0 0; display: inline-flex; align-items: center; justify-content: center; border: none; border-radius: var(--radius-pill); background: none; color: var(--ink-2); cursor: pointer; }
.dialog-close:hover { background: var(--container); color: var(--ink); }
.dialog-close svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.dialog-actions { position: sticky; bottom: calc(var(--space-8) * -1); background: var(--card); padding: var(--space-3) 0 var(--space-1); }
.kv-basis { display: block; font-size: 12px; font-weight: 400; color: var(--ink-2); }
.model-info p { font-size: 14px; }
.model-info p > :not(:first-child):not(:empty)::before { content: ', '; font-weight: 400; }
.create-preview:empty { display: none; }
.create-preview { display: flex; flex-direction: column; gap: var(--space-4); border-top: 1px solid var(--border); padding-top: var(--space-4); }
@media (prefers-reduced-motion: no-preference) {
    .scrim[role="dialog"]:not([hidden]) > .dialog { animation: dialog-in 250ms var(--ease-out); }
}
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Price preview */
.preview-figs { display: flex; gap: var(--space-8); flex-wrap: wrap; }
.preview-figs > div { display: flex; flex-direction: column; }
.money-md { font-size: 24px; font-weight: 600; line-height: 32px; font-variant-numeric: tabular-nums; color: var(--ink); }
.preview-cols { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-6); }
.preview-cols .kv > div { min-height: 32px; font-size: 14px; }

/* Lists of signals: one row each, a status, a line, quiet actions. */
.signal-list { list-style: none; display: flex; flex-direction: column; }
.signal-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-1) var(--space-4); padding: var(--space-3) 0; border-bottom: 1px solid var(--border); }
.signal-list li:last-child { border-bottom: none; }
.signal-main { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; min-width: 0; }
.signal-sub { grid-column: 1; font-size: 14px; color: var(--ink-2); }
.signal-actions { grid-column: 2; grid-row: 1 / span 2; display: flex; gap: var(--space-4); align-items: center; }
a.row-name { color: var(--ink); font-weight: 600; }
a.row-name:hover { color: var(--ink); text-decoration: underline; }
.code { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.cell-sub { display: block; font-size: 13px; color: var(--ink-2); }
.row-actions { white-space: nowrap; }
.row-actions .btn-quiet + .btn-quiet { margin-left: var(--space-3); }
.comp { display: flex; flex-direction: column; gap: var(--space-4); }

/* Toast: one at a time, bottom centre, a dot and a sentence. */
.toast { position: fixed; left: 50%; bottom: var(--space-8); transform: translateX(-50%); z-index: 400; max-width: min(480px, calc(100vw - 32px)); display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-5); border-radius: var(--radius-pill); background: var(--ink); color: var(--card); font-size: 14px; font-weight: 500; box-shadow: var(--shadow-lg); }
.toast::before { content: ''; width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; background: var(--info); }
.toast-success::before { background: var(--up); }
.toast-error::before { background: var(--amber); }
@media (prefers-reduced-motion: no-preference) { .toast:not([hidden]) { animation: toast-in 200ms var(--ease-out); } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

@media (max-width: 768px) {
    .preview-cols { grid-template-columns: 1fr; }
    .preview-figs { gap: var(--space-5); }
    .money-md { font-size: 20px; line-height: 28px; }
    .toast { bottom: calc(80px + env(safe-area-inset-bottom)); }
    .model-dialog { align-items: flex-end; padding: 0; }
    .model-dialog > .dialog { border-radius: var(--radius-panel) var(--radius-panel) 0 0; max-height: 92vh; }
    .dialog-actions { bottom: calc(var(--space-5) * -1); }
    .dialog-actions > * { flex: 1; }
    .signal-list li { grid-template-columns: 1fr; }
    .row-actions .btn-quiet { display: block; margin-left: auto; }
    .signal-actions { grid-column: 1; grid-row: auto; }
}
