/* Farma — everything the CRM's base.css and list-view.css do not already cover.
   Zero hardcoded colours: var(--token, #fallback) only, so the six themes in
   base.css keep working. */

/* ---- sidebar bits the CRM base.css expects ---------------------------- */

.brand-logo-icon { font-size: 22px; color: var(--sidebar-accent-bar, #0ea5e9); }

.sidebar .nav-link[data-model].active,
.sidebar .nav-link[data-model]:hover { color: var(--ent-color, var(--sidebar-text, #fff)); }

/* ---- list view -------------------------------------------------------- */

.list-view-container .lv-cmd-bar { box-shadow: inset 0 3px 0 var(--rec-color); }
.list-view-container .lv-cmd-btn.accent { color: var(--rec-color); }

.farma-search { position: relative; display: flex; align-items: center; }
.farma-search i {
    position: absolute;
    left: 8px;
    font-size: 15px;
    color: var(--text-muted, #94a3b8);
}
.farma-search input {
    width: 240px;
    height: 30px;
    padding: 0 10px 0 28px;
    font-size: 12px;
    border-radius: 6px;
    color: var(--text-primary, #0f172a);
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
}
.farma-search input:focus { outline: none; border-color: var(--rec-color, var(--primary-color)); }

.farma-select {
    height: 30px;
    padding: 0 8px;
    font-size: 12px;
    border-radius: 6px;
    color: var(--text-primary, #0f172a);
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
}

.farma-count {
    font-size: 11px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted, #94a3b8);
}

.farma-sort { color: inherit; text-decoration: none; white-space: nowrap; }
.farma-sort:hover { color: var(--rec-color, var(--primary-color)); }
.farma-sort.is-active { color: var(--rec-color, var(--primary-color)); }

.lv-table tbody tr { cursor: pointer; }
.lv-table td { vertical-align: middle; }

.farma-right { text-align: right; }
.farma-num { font-variant-numeric: tabular-nums; }
.farma-nowrap { white-space: nowrap; }
.farma-muted { color: var(--text-secondary, #475569); }
.farma-sub {
    display: block;
    margin-top: 1px;
    font-size: 11px;
    color: var(--text-muted, #94a3b8);
}
.farma-empty {
    padding: 28px 12px !important;
    text-align: center;
    color: var(--text-muted, #94a3b8);
}

.farma-pager {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
    padding: 10px 16px;
    font-size: 12px;
    color: var(--text-secondary, #475569);
}

/* ---- pills ------------------------------------------------------------ */

.farma-pill {
    display: inline-flex;
    align-items: center;
    height: 20px;
    padding: 0 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    background: color-mix(in srgb, var(--text-muted, #94a3b8) 16%, transparent);
    color: var(--text-secondary, #475569);
}
.farma-pill--bio,
.farma-pill--reviewed {
    background: color-mix(in srgb, var(--success-color, #10b981) 14%, transparent);
    color: var(--success-color, #10b981);
}
.farma-pill--nije_radio,
.farma-pill--submitted {
    background: color-mix(in srgb, var(--notice-color, #3b82f6) 14%, transparent);
    color: var(--notice-color, #3b82f6);
}
.farma-pill--odbio {
    background: color-mix(in srgb, var(--danger-color, #ef4444) 12%, transparent);
    color: var(--danger-color, #ef4444);
}

/* ---- detail view ------------------------------------------------------ */

.farma-detail { padding: 20px; }

.farma-detail__head {
    padding-bottom: 14px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
}
.farma-back {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    margin-bottom: 8px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    text-decoration: none;
    color: var(--text-muted, #94a3b8);
}
.farma-back:hover { color: var(--rec-color, var(--primary-color)); }
.farma-detail__title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary, #0f172a);
}
.farma-detail__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-top: 5px;
    font-size: 12px;
    color: var(--text-secondary, #475569);
}
.farma-badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--rec-color, var(--primary-color));
    background: color-mix(in srgb, var(--rec-color, #0ea5e9) 12%, transparent);
}

.farma-detail__body {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}
@media (max-width: 1100px) {
    .farma-detail__body { grid-template-columns: minmax(0, 1fr); }
}

.farma-panels { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.farma-card {
    overflow: hidden;
    border-radius: 8px;
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
}
.farma-card__head {
    padding: 10px 14px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--text-secondary, #475569);
    background: var(--bg-tertiary, #f1f5f9);
    border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.farma-kv { display: grid; grid-template-columns: 110px minmax(0, 1fr); margin: 0; }
.farma-kv dt,
.farma-kv dd {
    padding: 7px 14px;
    margin: 0;
    font-size: 12px;
    border-bottom: 1px solid color-mix(in srgb, var(--border-color, #e2e8f0) 60%, transparent);
}
.farma-kv dt { font-weight: 500; color: var(--text-muted, #94a3b8); }
.farma-kv dd { color: var(--text-primary, #0f172a); overflow-wrap: anywhere; }
.farma-kv dt:last-of-type, .farma-kv dd:last-of-type { border-bottom: 0; }

/* ---- login ------------------------------------------------------------ */

.farma-login {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-secondary, #f8fafc);
}
.farma-login-card {
    width: 320px;
    padding: 28px;
    border-radius: 12px;
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
    box-shadow: 0 12px 32px rgba(0, 0, 0, .08);
}
.farma-login-brand {
    margin-bottom: 20px;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary, #0f172a);
}
.farma-login-brand i { color: var(--primary-color, #0ea5e9); }
.farma-login-error {
    padding: 8px 10px;
    margin-bottom: 14px;
    border-radius: 6px;
    font-size: 12px;
    color: var(--danger-color, #ef4444);
    background: color-mix(in srgb, var(--danger-color, #ef4444) 10%, transparent);
}
.farma-field { display: block; margin-bottom: 14px; }
.farma-field span {
    display: block;
    margin-bottom: 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--text-secondary, #475569);
}
.farma-field input {
    width: 100%;
    height: 34px;
    padding: 0 10px;
    font-size: 13px;
    border-radius: 6px;
    color: var(--text-primary, #0f172a);
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
}
.farma-field input:focus { outline: none; border-color: var(--primary-color, #0ea5e9); }

/* Panel tables sit inside a card, so they need the compact list header
   explicitly — outside .list-view-container they would inherit the page
   heading size instead. */
.farma-card .lv-table th {
    padding: 8px 14px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--text-secondary, #475569);
    background: var(--bg-secondary, #f8fafc);
}
.farma-card .lv-table td { padding: 8px 14px; font-size: 12px; }
.farma-card .lv-table tbody tr:last-child td { border-bottom: 0; }

/* ---- record view (detail) -------------------------------------------- */

/* The record is the window: header and tab strip hold still, and whichever
   tab is open scrolls inside itself. A page that scrolls as a whole carries
   the tab strip off the top, which takes away the one control that would
   bring the reader back. */
.rv {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
}

.rv-head {
    flex-shrink: 0;
    display: flex;
    gap: 14px;
    align-items: center;
    padding: 18px 24px;
    background: var(--bg-primary, #fff);
    border-bottom: 1px solid var(--border-color, #e2e8f0);
}
.rv-back {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    font-size: 18px;
    text-decoration: none;
    color: var(--text-secondary, #475569);
}
.rv-back:hover { background: var(--bg-tertiary, #f1f5f9); color: var(--rec-color); }
.rv-avatar {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    font-size: 18px;
    font-weight: 600;
    color: var(--rec-color);
    background: color-mix(in srgb, var(--rec-color) 14%, transparent);
}
.rv-ident { min-width: 0; flex: 1; }
.rv-title {
    margin: 0;
    font-size: 21px;
    font-weight: 600;
    line-height: 1.25;
    color: var(--text-primary, #0f172a);
}
.rv-sub {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin-top: 2px;
    font-size: 12px;
    color: var(--text-muted, #94a3b8);
}
.rv-sub i { color: var(--rec-color); }
.rv-dot { opacity: .5; }

.rv-actions { display: flex; gap: 8px; }
.rv-btn {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    height: 32px;
    padding: 0 12px;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    color: var(--text-secondary, #475569);
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
}
.rv-btn:hover { background: var(--bg-tertiary, #f1f5f9); color: var(--text-primary, #0f172a); }
.rv-btn.is-on { color: var(--rec-color); border-color: color-mix(in srgb, var(--rec-color) 40%, transparent); }
.rv-btn.danger { color: var(--danger-color, #ef4444); }
.rv-btn.danger:hover { background: color-mix(in srgb, var(--danger-color, #ef4444) 10%, transparent); }


.rv-section { padding: 14px 0 4px; }
.rv-section-title {
    padding-left: 8px;
    margin-bottom: 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-secondary, #475569);
    border-left: 3px solid var(--rec-color);
}
.rv-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 40px; }
@media (max-width: 900px) { .rv-grid { grid-template-columns: minmax(0, 1fr); } }

.rv-row {
    display: grid;
    grid-template-columns: 170px minmax(0, 1fr);
    gap: 12px;
    align-items: baseline;
    padding: 9px 8px;
    border-bottom: 1px solid color-mix(in srgb, var(--border-color, #e2e8f0) 60%, transparent);
}
.rv-row:hover { background: var(--bg-secondary, #f8fafc); }
.rv-label {
    display: flex;
    gap: 7px;
    align-items: center;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--text-muted, #94a3b8);
}
.rv-label i { font-size: 14px; }
.rv-value { font-size: 13px; color: var(--text-primary, #0f172a); overflow-wrap: anywhere; }

.rv-tabs {
    display: flex;
    gap: 4px;
    padding: 0 24px;
    flex-shrink: 0;
    overflow-x: auto;
    background: var(--bg-primary, #fff);
    border-bottom: 1px solid var(--border-color, #e2e8f0);
}
.rv-tabs::-webkit-scrollbar { height: 3px; }
.rv-tab i { font-size: 15px; }
.rv-tab {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    color: var(--text-secondary, #475569);
    background: none;
    border: 0;
    border-bottom: 2px solid transparent;
}
.rv-tab:hover { color: var(--text-primary, #0f172a); }
.rv-tab.is-active { color: var(--rec-color); border-bottom-color: var(--rec-color); }
.rv-tab-count {
    padding: 1px 6px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary, #475569);
    background: var(--bg-tertiary, #f1f5f9);
}
.rv-tab.is-active .rv-tab-count {
    color: var(--rec-color);
    background: color-mix(in srgb, var(--rec-color) 14%, transparent);
}

/* The panes own the page's only scrollbar. */
.rv-panels {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 18px 24px 24px;
}
.rv-panel { display: none; }
.rv-panel.is-active { display: block; }

/* Details reads as one card of the record's own fields, the way every other
   tab is one object. */
.rv-card {
    padding: 6px 18px 18px;
    border-radius: 12px;
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
}
/* Whatever a tab spawns is a box of its own: bordered, inset from the sidebar,
   and — this is the point — a fixed height it scrolls inside. A hundred rows
   that push the page down carry the tab strip off screen, so the reader loses
   the one control that would take them back. */
.rv-panel .lv-table-wrap {
    margin-top: 14px;
    max-height: min(62vh, 720px);
    overflow: auto;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 8px;
    background: var(--bg-primary, #fff);
}
/* Sticky, because a column header that scrolls away turns row 40 into numbers
   with no names. `background` is on the cell, not the row: a transparent
   header would let the rows print through it. */
.rv-panel .lv-table th {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 9px 14px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--text-secondary, #475569);
    background: var(--bg-secondary, #f8fafc);
    box-shadow: inset 0 -1px 0 var(--border-color, #e2e8f0);
}
.rv-panel .lv-table td { padding: 9px 14px; font-size: 12.5px; }
.rv-panel .lv-table tbody tr:last-child td { border-bottom: 0; }

/* ---- custom fields form ---------------------------------------------- */

.cf-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    padding: 16px 0;
}
.cf-form input, .cf-form select {
    height: 32px;
    padding: 0 10px;
    font-size: 12px;
    border-radius: 6px;
    color: var(--text-primary, #0f172a);
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
}
.cf-form input[name="choices"] { flex: 1; min-width: 220px; }
.cf-form input:focus, .cf-form select:focus { outline: none; border-color: var(--rec-color); }

/* ---- list view: dropdowns must sit above the table --------------------
   `.lv-table-wrap` is positioned, so without an explicit stacking context on
   the command bar the rows paint over an open dropdown. */

.list-view-container { position: relative; }
.list-view-container .lv-cmd-bar { position: relative; z-index: 60; }
.list-view-container .lv-dropdown-wrapper { position: relative; z-index: 61; }
.list-view-container .lv-smart-dropdown {
    z-index: 62;
    background: var(--bg-primary, #fff);
    backdrop-filter: none;
}
.list-view-container .lv-table-wrap { position: relative; z-index: 0; }
.list-view-container .lv-column-dropdown,
#lv-column-dropdown { z-index: 200; background: var(--bg-primary, #fff); }

/* Related-column chrome the CRM theme leaves to the host app. */
.lv-rel-pill {
    display: inline-block;
    max-width: 100%;
    padding: 2px 8px;
    overflow: hidden;
    border-radius: 999px;
    font-size: 11px;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: var(--text-secondary, #475569);
    background: var(--bg-tertiary, #f1f5f9);
}
.lv-rel-count { font-variant-numeric: tabular-nums; font-weight: 600; }
.lv-rel-count.zero { color: var(--text-muted, #94a3b8); font-weight: 400; }
.lv-rel-name-tags-wrap { display: flex; flex-wrap: wrap; gap: 3px; }
.lv-rel-name-tag {
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 11px;
    text-decoration: none;
    color: var(--rec-color, var(--primary-color));
    background: color-mix(in srgb, var(--rec-color, #0ea5e9) 12%, transparent);
}
.lv-rel-name-tag:hover { text-decoration: underline; }
.lv-rel-overflow-tag {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    color: var(--text-muted, #94a3b8);
    background: var(--bg-tertiary, #f1f5f9);
}
.lv-rel-tag {
    margin-left: 5px;
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .04em;
    color: var(--text-muted, #94a3b8);
    background: var(--bg-tertiary, #f1f5f9);
}

/* ---- notes and comments ---------------------------------------------- */

.th-compose {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 720px;
    padding: 14px;
    margin: 16px 0;
    border-radius: 8px;
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
}
.th-compose textarea, .th-compose .th-title {
    width: 100%;
    padding: 8px 10px;
    font: inherit;
    font-size: 13px;
    border-radius: 6px;
    resize: vertical;
    color: var(--text-primary, #0f172a);
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
}
.th-compose textarea:focus, .th-compose .th-title:focus {
    outline: none;
    border-color: var(--rec-color, var(--primary-color));
}
.th-compose-actions { display: flex; gap: 8px; align-items: center; justify-content: flex-end; }
.th-color {
    height: 32px;
    padding: 0 8px;
    font-size: 12px;
    border-radius: 6px;
    color: var(--text-primary, #0f172a);
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
}

.th-notes { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.th-note {
    padding: 12px 14px;
    border-radius: 8px;
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-left: 3px solid var(--note-color, var(--text-muted, #94a3b8));
}
.th-note[data-color="indigo"] { --note-color: #4f46e5; }
.th-note[data-color="blue"]   { --note-color: #2563eb; }
.th-note[data-color="green"]  { --note-color: #059669; }
.th-note[data-color="red"]    { --note-color: #dc2626; }
.th-note[data-color="teal"]   { --note-color: #0d9488; }
.th-note[data-color="gray"]   { --note-color: #64748b; }
.th-note header { display: flex; gap: 8px; align-items: flex-start; justify-content: space-between; }
.th-note h4 { margin: 0 0 4px; font-size: 13px; font-weight: 600; color: var(--text-primary, #0f172a); }
.th-note p { margin: 0 0 8px; font-size: 13px; line-height: 1.5; color: var(--text-primary, #0f172a); }
.th-note footer { font-size: 11px; color: var(--text-muted, #94a3b8); }
.th-note-actions { display: flex; gap: 2px; margin-left: auto; }
.th-note-actions button {
    padding: 2px 4px;
    font-size: 14px;
    cursor: pointer;
    color: var(--text-muted, #94a3b8);
    background: none;
    border: 0;
}
.th-note-actions button:hover { color: var(--rec-color, var(--primary-color)); }

.th-comments { max-width: 820px; }
.th-comment { margin-left: calc(var(--depth, 0) * 26px); }
.th-comment-body {
    padding: 10px 12px;
    margin-bottom: 8px;
    border-radius: 8px;
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
}
.th-comment[style*="--depth:0"] > .th-comment-body { border-left: 3px solid var(--rec-color); }
.th-comment-head { display: flex; gap: 8px; align-items: baseline; margin-bottom: 3px; }
.th-who { font-size: 12px; font-weight: 600; color: var(--text-primary, #0f172a); }
.th-when { font-size: 11px; color: var(--text-muted, #94a3b8); }
.th-comment-body p { margin: 0; font-size: 13px; line-height: 1.5; color: var(--text-primary, #0f172a); }
.th-comment-actions { display: flex; gap: 10px; margin-top: 6px; }
.th-comment-actions button {
    padding: 0;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-muted, #94a3b8);
    background: none;
    border: 0;
}
.th-comment-actions button:hover { color: var(--rec-color, var(--primary-color)); }
.th-reply { display: flex; gap: 8px; align-items: flex-start; margin-top: 8px; }
.th-reply textarea {
    flex: 1;
    padding: 7px 9px;
    font: inherit;
    font-size: 12.5px;
    border-radius: 6px;
    resize: vertical;
    color: var(--text-primary, #0f172a);
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
}
.th-empty { padding: 24px 0; font-size: 13px; color: var(--text-muted, #94a3b8); }

/* ---- inline editing on the record page -------------------------------- */

.rv-input {
    width: 100%;
    padding: 5px 8px;
    font: inherit;
    font-size: 13px;
    border-radius: 6px;
    color: var(--text-primary, #0f172a);
    background: transparent;
    border: 1px solid transparent;
    transition: border-color .12s ease, background .12s ease;
}
.rv-row.is-editable:hover .rv-input { border-color: var(--border-color, #e2e8f0); }
.rv-input:focus {
    outline: none;
    background: var(--bg-primary, #fff);
    border-color: var(--rec-color, var(--primary-color));
}
.rv-input.is-saved { border-color: var(--success-color, #10b981); }
.rv-input.is-failed { border-color: var(--danger-color, #ef4444); }
select.rv-input { cursor: pointer; }
textarea.rv-input { resize: vertical; }

.rv-tab-actions { display: flex; justify-content: flex-end; padding-top: 14px; }

.rv-attach {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-start;
    padding: 14px;
    margin-top: 12px;
    border-radius: 8px;
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
}
.rv-attach-pick { position: relative; flex: 1 1 260px; }
.rv-attach input {
    width: 100%;
    height: 32px;
    padding: 0 10px;
    font-size: 12.5px;
    border-radius: 6px;
    color: var(--text-primary, #0f172a);
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
}
.rv-attach input:focus { outline: none; border-color: var(--rec-color, var(--primary-color)); }
.rv-attach-results {
    position: absolute;
    z-index: 30;
    width: 100%;
    max-height: 240px;
    margin-top: 4px;
    overflow-y: auto;
    border-radius: 8px;
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
}
.rv-attach-results button {
    display: flex;
    gap: 8px;
    align-items: baseline;
    justify-content: space-between;
    width: 100%;
    padding: 7px 10px;
    font-size: 12.5px;
    text-align: left;
    cursor: pointer;
    color: var(--text-primary, #0f172a);
    background: none;
    border: 0;
}
.rv-attach-results button:hover { background: var(--bg-tertiary, #f1f5f9); }
.rv-attach-results span { font-size: 11px; color: var(--text-muted, #94a3b8); }
.rv-attach-new { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; flex: 2 1 420px; }
.rv-attach-new > span { font-size: 12px; color: var(--text-muted, #94a3b8); }
.rv-attach-new input { width: 130px; }

.rv-detach-cell { width: 40px; text-align: right; }
.rv-detach {
    padding: 2px 5px;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    color: var(--text-muted, #94a3b8);
    background: none;
    border: 0;
}
.rv-detach:hover { color: var(--danger-color, #ef4444); }

/* ---- add / edit / import dialogs -------------------------------------- */

.fx-modal {
    color: var(--text-primary, #0f172a);
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 10px;
}
.fx-modal .modal-header, .fx-modal .modal-footer {
    align-items: center;
    border-color: var(--border-color, #e2e8f0);
}
.fx-modal .modal-title { font-size: 15px; font-weight: 600; }
.fx-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.fx-field { display: flex; flex-direction: column; gap: 4px; }
.fx-field > span {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--text-secondary, #475569);
}
.fx-field em { font-style: normal; color: var(--danger-color, #ef4444); }
.fx-field input, .fx-field select, .fx-field textarea, #edit-value {
    width: 100%;
    padding: 7px 9px;
    font: inherit;
    font-size: 13px;
    border-radius: 6px;
    color: var(--text-primary, #0f172a);
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
}
.fx-field input:focus, .fx-field select:focus, .fx-field textarea:focus, #edit-value:focus {
    outline: none;
    border-color: var(--primary-color, #0ea5e9);
}
.fx-hint, .fx-result { grid-column: 1 / -1; font-size: 12px; color: var(--text-muted, #94a3b8); }
/* An unfilled hint must not open a gap under every field in the dialog. */
.fx-hint:empty { display: none; }
.fx-hint.warn { color: var(--danger-color, #ef4444); }
.fx-result ul { margin: 6px 0 0; padding-left: 18px; }
.fx-bad { color: var(--danger-color, #ef4444); }
.fx-error { margin-right: auto; font-size: 12px; color: var(--danger-color, #ef4444); }

/* The dialog form owns the whole modal body, so header/body/footer stack. */
.fx-modal form { display: flex; flex-direction: column; min-width: 0; }
.fx-modal .modal-body { width: 100%; }
.fx-modal .modal-footer { display: flex; justify-content: flex-end; width: 100%; }
@media (max-width: 640px) { .fx-form { grid-template-columns: minmax(0, 1fr); } }

/* Review pills reuse the outcome palette. */
.farma-pill--reviewed {
    background: color-mix(in srgb, var(--success-color, #10b981) 14%, transparent);
    color: var(--success-color, #10b981);
}
.farma-pill--pending {
    background: color-mix(in srgb, var(--notice-color, #3b82f6) 14%, transparent);
    color: var(--notice-color, #3b82f6);
}

/* ---- review chip and dialog ------------------------------------------- */

.rvw-chip {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    height: 22px;
    padding: 0 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    color: var(--text-secondary, #475569);
    background: var(--bg-tertiary, #f1f5f9);
    border: 1px solid transparent;
}
.rvw-chip:hover { border-color: var(--border-color, #e2e8f0); }
.rvw-chip.is-done {
    color: var(--success-color, #10b981);
    background: color-mix(in srgb, var(--success-color, #10b981) 14%, transparent);
}

.rvw-subject { margin: 0 0 10px; font-size: 12px; color: var(--text-muted, #94a3b8); }
.rvw-meta { margin-bottom: 4px; font-size: 12px; font-weight: 600; color: var(--text-primary, #0f172a); }
.rvw-meta span:last-child { font-weight: 400; color: var(--text-muted, #94a3b8); }
.rvw-text { margin: 0; font-size: 13px; line-height: 1.5; color: var(--text-primary, #0f172a); }
.rvw-locked { margin: 10px 0 0; font-size: 12px; color: var(--text-muted, #94a3b8); }
#rvw-comment {
    width: 100%;
    padding: 9px 11px;
    font: inherit;
    font-size: 13px;
    border-radius: 6px;
    resize: vertical;
    color: var(--text-primary, #0f172a);
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
}
#rvw-comment:focus { outline: none; border-color: var(--primary-color, #0ea5e9); }

/* ---- review card ------------------------------------------------------ */

.rvw-card {
    margin-top: 18px;
    overflow: hidden;
    border-radius: 10px;
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-top: 3px solid var(--notice-color, #3b82f6);
}
.rvw-card.is-done { border-top-color: var(--success-color, #10b981); }

.rvw-card__head {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 12px 14px;
    background: var(--bg-secondary, #f8fafc);
    border-bottom: 1px solid var(--border-color, #e2e8f0);
}
.rvw-card__head > i { font-size: 17px; color: var(--notice-color, #3b82f6); }
.rvw-card.is-done .rvw-card__head > i { color: var(--success-color, #10b981); }
.rvw-card__title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-secondary, #475569);
}
.rvw-card__state {
    margin-left: auto;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    color: var(--notice-color, #3b82f6);
    background: color-mix(in srgb, var(--notice-color, #3b82f6) 14%, transparent);
}
.rvw-card.is-done .rvw-card__state {
    color: var(--success-color, #10b981);
    background: color-mix(in srgb, var(--success-color, #10b981) 14%, transparent);
}

.rvw-card__body { padding: 14px; }
.rvw-card__who { display: flex; gap: 9px; align-items: center; margin-bottom: 10px; }
.rvw-card__avatar {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 600;
    color: var(--success-color, #10b981);
    background: color-mix(in srgb, var(--success-color, #10b981) 14%, transparent);
}
.rvw-card__name { font-size: 13px; font-weight: 600; color: var(--text-primary, #0f172a); }
.rvw-card__when { font-size: 11px; color: var(--text-muted, #94a3b8); }
.rvw-card__text {
    padding-left: 10px;
    margin: 0;
    font-size: 13px;
    line-height: 1.55;
    color: var(--text-primary, #0f172a);
    border-left: 2px solid color-mix(in srgb, var(--success-color, #10b981) 35%, transparent);
}
.rvw-card__empty { margin: 0; font-size: 13px; color: var(--text-muted, #94a3b8); }

.rvw-card__foot {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
    padding: 12px 14px;
    border-top: 1px solid color-mix(in srgb, var(--border-color, #e2e8f0) 60%, transparent);
}
.rvw-card__locked { margin-right: auto; font-size: 11px; color: var(--text-muted, #94a3b8); }
.rv-btn.accent {
    color: var(--rec-color, var(--primary-color));
    border-color: color-mix(in srgb, var(--rec-color, #0ea5e9) 35%, transparent);
}
.rv-btn.accent:hover { background: color-mix(in srgb, var(--rec-color, #0ea5e9) 10%, transparent); }

/* ---- review dialog: distinct surface over the blurred page ------------ */

/* No backdrop-filter. Blurring a full-screen layer makes the compositor
   re-filter the whole page every frame: measured on the visits list, opening
   this dialog ran at ~39fps with a 62ms worst frame, against ~61fps and 18ms
   with it off. A flat dark scrim recedes the page just as well for free. */
.modal-backdrop:not([id]) {
    --bs-backdrop-bg: #060b16;
    --bs-backdrop-opacity: 0.72;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.rvw-modal {
    border: 3px solid var(--sidebar-bg, #0f172a);
    border-radius: 14px;
    /* A hairline of light outside the ink border, so the border reads as an
       edge instead of merging into the darkened backdrop. */
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, .14),
        0 30px 80px rgba(0, 0, 0, .5);
}
.rvw-modal .modal-header {
    padding: 16px 22px;
    background: var(--bg-secondary, #f8fafc);
    border-bottom: 1px solid var(--border-color, #e2e8f0);
}
.rvw-modal .modal-title { font-size: 16px; }
.rvw-modal .modal-body {
    /* Held steady so filling the dialog does not resize it under the cursor. */
    min-height: 190px;
    padding: 20px 22px;
}
.rvw-modal .modal-footer { padding: 14px 22px; }

.rvw-modal .rvw-subject {
    padding-bottom: 12px;
    margin-bottom: 14px;
    font-size: 13px;
    color: var(--text-secondary, #475569);
    border-bottom: 1px solid color-mix(in srgb, var(--border-color, #e2e8f0) 70%, transparent);
}
.rvw-modal .rvw-text { font-size: 14px; line-height: 1.6; }
.rvw-modal #rvw-comment { min-height: 130px; font-size: 14px; }
.rvw-loading {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 26px 0;
    font-size: 13px;
    color: var(--text-muted, #94a3b8);
}
#rvw-view, #rvw-form { animation: rvwIn .14s ease-out both; }
@keyframes rvwIn { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
    #rvw-view, #rvw-form { animation: none; }
}

/* Snappier than the Bootstrap default, which is most of the "slow". */
#reviewModal.fade .modal-dialog { transition: transform .12s ease-out, opacity .12s ease-out; }
#reviewModal.fade { transition: opacity .1s linear; }


/* The calendar, travel log and map bring their own bar, so the panel does not
   wrap them in a second one — but it does box them. Full-bleed, the bar ran
   into the sidebar and read as part of the shell rather than as this tab's
   content. */
.rv-panel--flush { padding: 14px 24px 0; }
.rv-panel--flush > .cal-container,
.rv-panel--flush > .tl-container,
.rv-panel--flush > .rvd,
.rv-panel--flush > .vm-container {
    overflow: hidden;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 8px;
    background: var(--bg-primary, #fff);
}
.rv-panel--flush .cal-bar { border-top: 0; }
/* The calendar reloads itself in place; this is the only sign that a click
   landed while the new grid is on its way. */
.rv-panel.is-loading { opacity: .55; transition: opacity .1s linear; }
@media (prefers-reduced-motion: reduce) { .rv-panel.is-loading { transition: none; } }
/* Boxed, the container's own bottom padding is dead space inside a border. */
.rv-panel--flush > .cal-container { padding-bottom: 0; }
/* In a tab the grid scrolls inside its own box, like the travel log: a month of
   a busy rep is taller than the screen, and a grid that pushes the page down
   takes the scope controls and the tab strip with it. */
.rv-panel--flush .cal-scroll { max-height: min(62vh, 720px); overflow: auto; }

/* Notes and comments grow with use like every other tab, so they scroll in a
   box of their own rather than pushing the page down forever. */
.rv-panel .th-notes, .rv-panel .th-comments {
    max-height: min(52vh, 620px);
    overflow: auto;
    padding: 14px;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 8px;
    background: var(--bg-primary, #fff);
}
.rv-panel .th-comments { max-width: 820px; }

/* ---- visit access ------------------------------------------------------
   The mode decides which editor is on screen. Open draws nothing, because a
   place with no schedule has nothing to schedule. */
/* The same box every other tab gets: this panel is content, not chrome. */
.ax {
    padding: 16px;
    margin-top: 14px;
    max-height: min(62vh, 720px);
    overflow: auto;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 8px;
    background: var(--bg-primary, #fff);
}

.ax-modes {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
}
.ax-mode {
    height: 28px;
    padding: 0 11px;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-secondary, #475569);
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
    transition: color .12s ease, background .12s ease, border-color .12s ease;
}
.ax-mode:hover { background: var(--bg-tertiary, #f1f5f9); color: var(--text-primary, #0f172a); }
/* Tinted, like the active tab above it — a solid fill made the one mode you
   are already in the loudest thing on the panel. */
.ax-mode.is-on {
    color: var(--rec-color, var(--primary-color));
    background: color-mix(in srgb, var(--rec-color, var(--primary-color)) 14%, transparent);
    border-color: color-mix(in srgb, var(--rec-color, var(--primary-color)) 40%, transparent);
}
.ax-mode:focus-visible, .ax-day:focus-visible, .ax-del:focus-visible {
    outline: 2px solid var(--primary-color, #0ea5e9);
    outline-offset: 2px;
}
.ax-summary {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-muted, #94a3b8);
}

.ax-body { padding-top: 18px; }
.ax-none, .ax-hint {
    margin: 0;
    font-size: 13px;
    color: var(--text-muted, #94a3b8);
    max-width: 62ch;
}
.ax-hint { padding-bottom: 14px; }

/* The strip answers "which days" without reading a single word. */
.ax-strip { display: flex; gap: 8px; padding-bottom: 20px; }
.ax-day {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-muted, #94a3b8);
    background: var(--bg-secondary, #f8fafc);
    border: 1px solid var(--border-color, #e2e8f0);
    transition: background .12s, color .12s, border-color .12s;
}
.ax-day:hover { border-color: var(--text-muted, #94a3b8); color: var(--text-primary, #0f172a); }
.ax-day.is-on {
    color: var(--rec-color, var(--primary-color));
    background: color-mix(in srgb, var(--rec-color, var(--primary-color)) 16%, transparent);
    border-color: color-mix(in srgb, var(--rec-color, var(--primary-color)) 45%, transparent);
}
/* Open, but nobody has pinned the hours down: a dotted edge says "not settled"
   without spending a second colour on it. */
.ax-day.is-on.is-vague {
    border-style: dashed;
    border-color: color-mix(in srgb, var(--rec-color, var(--primary-color)) 60%, transparent);
}

.ax-dayrow {
    display: grid;
    grid-template-columns: 110px 1fr auto;
    gap: 12px;
    align-items: start;
    padding: 12px 0;
    border-top: 1px solid var(--border-color, #e2e8f0);
}
.ax-dayname {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary, #0f172a);
    padding-top: 7px;
}
.ax-blocks { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
/* One row stays one row: wrapping split a time range across two lines and left
   the delete button stranded on a third. */
.ax-block { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ax-block.is-past { opacity: .5; }
.ax-dash { color: var(--text-muted, #94a3b8); }

.ax-note { flex: 1 1 auto; min-width: 0; }
.ax-num { width: 76px; }

.ax-del {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 7px;
    cursor: pointer;
    color: var(--text-muted, #94a3b8);
    background: transparent;
}
.ax-del:hover {
    color: var(--danger-color, #ef4444);
    background: color-mix(in srgb, var(--danger-color, #ef4444) 10%, transparent);
}
/* The buttons keep their labels on one line; "Add\Ahours" over two lines in a
   squeezed column was the tell that the row had run out of room. */
.ax-dayactions { display: flex; gap: 8px; }
.ax-dayactions .rv-btn { white-space: nowrap; }

.ax-word { font-size: 13px; color: var(--text-secondary, #475569); }

@media (max-width: 900px) {
    .ax-dayrow { grid-template-columns: 1fr; }
    .ax-dayname { padding-top: 0; }
    .ax-block { flex-wrap: wrap; }
    .ax-note { flex-basis: 100%; }
}



/* ---- typed fields and chips -------------------------------------------
   No dropdowns in this panel. Times and dates are typed because they are
   values the rep already knows; the repeat pattern is chips and a grid
   because those are recognised on sight. */

/* A field here is a field of the record page, not the browser's own box. */
.ax-input {
    height: 28px;
    padding: 0 8px;
    font: inherit;
    font-size: 12.5px;
    border-radius: 6px;
    color: var(--text-primary, #0f172a);
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
    transition: border-color .12s ease, box-shadow .12s ease;
}
.ax-input::placeholder { color: var(--text-muted, #94a3b8); }
.ax-input:hover { border-color: var(--text-muted, #94a3b8); }
.ax-input:focus {
    outline: none;
    border-color: var(--rec-color, var(--primary-color));
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--rec-color, var(--primary-color)) 15%, transparent);
}

.ax-clock { width: 72px; text-align: center; font-variant-numeric: tabular-nums; }
.ax-date { width: 108px; font-variant-numeric: tabular-nums; }
.ax-num { width: 48px; text-align: center; }

.ax-block { flex-direction: column; align-items: stretch; gap: 10px; }
.ax-when { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ax-rule { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.ax-pat { display: inline-flex; align-items: center; gap: 6px; }
.ax-pat[hidden] { display: none; }
.ax-inline { gap: 6px; }

/* Segmented buttons: one row, always visible, no list to open. */
.ax-seg { display: inline-flex; }
.ax-segbtn {
    height: 28px;
    padding: 0 12px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-secondary, #475569);
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-right-width: 0;
}
.ax-seg .ax-segbtn:first-child { border-radius: 7px 0 0 7px; }
.ax-seg .ax-segbtn:last-child { border-radius: 0 7px 7px 0; border-right-width: 1px; }
.ax-segbtn:hover { background: var(--bg-tertiary, #f1f5f9); }
.ax-segbtn.is-on {
    color: var(--rec-color, var(--primary-color));
    background: color-mix(in srgb, var(--rec-color, var(--primary-color)) 14%, transparent);
    border-color: color-mix(in srgb, var(--rec-color, var(--primary-color)) 40%, transparent);
}
.ax-segbtn:focus-visible, .ax-cell:focus-visible {
    outline: 2px solid var(--primary-color, #0ea5e9);
    outline-offset: 2px;
    position: relative;
}

/* The month as a grid, not a list: "the 15th, 16th and 20th" is three clicks. */
.ax-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(34px, 1fr));
    gap: 4px;
    max-width: 300px;
}
.ax-cell {
    height: 30px;
    border-radius: 6px;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    color: var(--text-secondary, #475569);
    background: var(--bg-secondary, #f8fafc);
    border: 1px solid var(--border-color, #e2e8f0);
}
.ax-cell:hover { border-color: var(--text-muted, #94a3b8); }
.ax-cell.is-on {
    color: var(--rec-color, var(--primary-color));
    background: color-mix(in srgb, var(--rec-color, var(--primary-color)) 16%, transparent);
    border-color: color-mix(in srgb, var(--rec-color, var(--primary-color)) 45%, transparent);
}

/* The repeat row reuses the weekly strip's chips, one size down. */
.ax-strip--sm { padding-bottom: 0; gap: 4px; }
.ax-strip--sm .ax-day { width: 32px; height: 32px; font-size: 12px; }


/* Dashboards tab
   ------------------------------------------------------------------------
   One Superset dashboard per frame, each already filtered to the record the
   page is about. The frame gets a fixed viewport-relative height because an
   iframe has no intrinsic size: left to itself it collapses to 150px and the
   charts inside it render into a letterbox. */
.rvd { display: flex; flex-direction: column; }
.rvd-pills {
    display: flex; flex-wrap: wrap; gap: 6px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    background: var(--bg-secondary, #f8fafc);
}
.rvd-pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 12px; border-radius: 999px;
    border: 1px solid var(--border-color, #e2e8f0);
    background: var(--bg-primary, #fff); color: var(--text-secondary, #475569);
    font: inherit; font-size: .82rem; cursor: pointer;
    transition: background .12s, color .12s, border-color .12s;
}
.rvd-pill:hover { background: var(--bg-tertiary, #f1f5f9); color: var(--text-primary, #0f172a); }
.rvd-pill.is-active {
    border-color: transparent; color: #fff;
    background: var(--rec-color, var(--primary-color, #0ea5e9));
}
.rvd-pill i { font-size: 1rem; }

.rvd-panel { display: none; }
.rvd-panel.is-active { display: flex; flex-direction: column; }
.rvd-frame {
    display: block; width: 100%; border: 0;
    /* Tall enough for a row of charts without the page scrolling twice; the
       dashboard scrolls inside it. */
    height: min(78vh, 900px);
}

/* The dashboard's own controls: a date range the CRM draws because Superset's
   filter bar cannot show one filter while hiding the record pin next to it,
   and the way out to full screen. */
.rvd-bar {
    display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    background: var(--bg-secondary, #f8fafc);
}
.rvd-when { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.rvd-when i { font-size: 1rem; color: var(--text-muted, #64748b); }
.rvd-bar select,
.rvd-bar input[type="date"] {
    padding: 4px 8px; border-radius: 6px;
    border: 1px solid var(--border-color, #e2e8f0);
    background: var(--bg-primary, #fff); color: var(--text-secondary, #475569);
    font: inherit; font-size: .8rem;
}
.rvd-bar select:focus-visible,
.rvd-bar input:focus-visible,
.rvd-bar button:focus-visible {
    outline: 2px solid var(--rec-color, var(--primary-color, #0ea5e9)); outline-offset: 1px;
}
/* Two native date inputs will not shrink below their own picker, so at a
   phone width they wrap onto their own line rather than running off the
   panel's right edge. */
.rvd-custom { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.rvd-custom[hidden] { display: none; }
.rvd-custom input[type="date"] { flex: 1 1 128px; min-width: 0; }
.rvd-custom span { font-size: .78rem; color: var(--text-muted, #64748b); }
.rvd-apply,
.rvd-full {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 12px; border-radius: 999px;
    border: 1px solid var(--border-color, #e2e8f0);
    background: var(--bg-primary, #fff); color: var(--text-secondary, #475569);
    font: inherit; font-size: .8rem; cursor: pointer;
    transition: background .12s, color .12s, border-color .12s;
}
.rvd-apply:hover,
.rvd-full:hover { background: var(--bg-tertiary, #f1f5f9); color: var(--text-primary, #0f172a); }
.rvd-full { margin-left: auto; }
.rvd-full i { font-size: 1rem; }

/* Full screen, whether the browser granted it or the panel is pinned over the
   viewport instead. The frame takes the remaining height rather than its usual
   fixed one — that height exists to stop a page scrolling twice, and here
   there is no page behind it. */
.rvd-panel:fullscreen,
.rvd-panel.is-max {
    display: flex; flex-direction: column;
    background: var(--bg-primary, #fff);
}
.rvd-panel.is-max { position: fixed; inset: 0; z-index: 1080; }
.rvd-panel:fullscreen .rvd-frame,
.rvd-panel.is-max .rvd-frame { flex: 1 1 auto; height: auto; min-height: 0; }
/* Admin-only, and the one thing on this tab that is not a chart: a chart the
   pin could not reach is showing the whole business under one record's name. */
.rvd-warn {
    display: flex; align-items: flex-start; gap: 8px;
    margin: 0; padding: 9px 14px;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    background: color-mix(in srgb, var(--danger-color, #ef4444) 7%, transparent);
    color: var(--danger-color, #ef4444);
    font-size: .8rem; line-height: 1.45;
}
.rvd-warn i { flex: none; margin-top: .1em; font-size: 1rem; }
