/* Admin UI kit. Components follow the FPS studio patterns; colors come from brand.css. */

* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 var(--font); background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
a { color: var(--brand); }
h1 { margin: 0 0 20px; font-size: 26px; font-weight: 700; letter-spacing: -.03em; }
h2 { margin: 28px 0 12px; font-size: 16px; font-weight: 700; }
.muted { color: var(--muted); }
svg.icon { width: 17px; height: 17px; flex: 0 0 auto; stroke: currentColor; stroke-width: 1.6; fill: none; stroke-linecap: round; stroke-linejoin: round; }

/* Shell */
.topbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 0 24px; min-height: 64px; background: var(--card); border-bottom: 1px solid var(--line); }
.topbar .brand { color: var(--text); text-decoration: none; display: flex; align-items: center; gap: 8px; margin-right: 18px; font-size: 15px; font-weight: 700; }
.topbar nav { display: flex; gap: 2px; flex-wrap: wrap; }
.topbar nav a { display: flex; align-items: center; height: 36px; padding: 0 12px; border-radius: var(--radius); color: var(--muted); text-decoration: none; }
.topbar nav a:hover { background: var(--hover); color: var(--text); }
.topbar nav a.active { background: var(--brand-50); color: var(--brand); font-weight: 700; }
.topbar form { margin-left: auto; }
main { max-width: 1200px; margin: 0 auto; padding: 32px 24px; }

/* Surfaces */
.card { margin-bottom: 16px; padding: 20px 22px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.grid--wide { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.card form input:not([type="checkbox"]):not([type="hidden"]), .card form select, .card form .select { width: 100%; }
.amount-field { display: grid; grid-template-columns: minmax(0, 1fr) 96px; gap: 8px; }
.card > h2:first-child { margin-top: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin: 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 8px; }
/* .kpi (read-only number, may link to a list) and .stage-card (quick filter) share one card look. */
.kpi, .stage-card { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); color: var(--text); text-decoration: none; }
a.kpi:hover, .stage-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-pop); transform: translateY(-1px); }
.kpi-label { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-label svg.icon { width: 15px; height: 15px; }
.kpi .stat { font-size: 24px; white-space: nowrap; }
.kpi--bad .stat { color: var(--bad); }
.quiet-link.text-bad { color: var(--bad); font-weight: 700; }
.note { margin-top: 12px; font-size: 12px; }
.check-cell { width: 44px; padding-right: 0; }
input[type="checkbox"].row-check { appearance: none; width: 18px; height: 18px; margin: 0; padding: 0; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--card) center / 12px no-repeat; cursor: pointer; vertical-align: middle; }
input[type="checkbox"].row-check::after { content: none; }
input[type="checkbox"].row-check:checked, input[type="checkbox"].row-check:indeterminate { border-color: var(--brand); background-color: var(--brand); }
input[type="checkbox"].row-check:checked { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12 5 5 9-10'/%3E%3C/svg%3E"); }
input[type="checkbox"].row-check:indeterminate { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M6 12h12'/%3E%3C/svg%3E"); }
tbody tr.selected td, tbody tr.selected:hover td { background: var(--brand-50); }
.bulk-bar { position: fixed; left: 50%; bottom: 24px; z-index: 40; transform: translateX(-50%); display: flex; flex-wrap: wrap; align-items: center; gap: 8px; width: max-content; max-width: calc(100% - 32px); padding: 10px 12px; background: var(--card); border: 1px solid var(--brand-200); border-radius: var(--radius); box-shadow: 0 24px 60px rgba(31,35,49,.22); animation: popover-in var(--duration) var(--ease); }
.bulk-bar[hidden], .bulk-param[hidden] { display: none; }
.bulk-bar .select { min-width: 220px; }
.bulk-bar input[type="number"] { width: 90px; }
.bulk-param { display: inline-flex; align-items: center; gap: 6px; }
.bulk-count { margin-right: 4px; color: var(--muted); }
.bulk-bar .icon-button { width: 38px; height: 38px; }
.bulk-count b { color: var(--text); }
.lead { font-size: 15px; }
.stage-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stage-card { align-items: flex-start; }
.stage-card.active { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-50); }
.stage-card .stat { font-size: 24px; }
.quiet-link { color: inherit; text-decoration: none; }
.quiet-link:hover { color: var(--brand); text-decoration: underline; }
.account-title { display: flex; align-items: center; gap: 10px; }
.account-title .pill { margin-top: 0; font-size: 12px; height: 22px; }
p.copyable { display: flex; align-items: center; gap: 4px; }
p.copyable .copy { opacity: 1; }
.stat { font-size: 28px; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; }
dt { color: var(--muted); }
dd { margin: 0; }

/* Notices */
.alert, .errors { display: flex; flex-direction: column; gap: 2px; margin-bottom: 18px; padding: 12px 14px; border-radius: var(--radius); font-size: 13px; }
.alert { background: var(--highlight-50); color: var(--highlight-900); }
.errors { background: var(--bad-50); color: var(--bad); }

/* Badges */
.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: var(--radius-sm); background: var(--hover); color: var(--muted); font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge svg.icon { width: 13px; height: 13px; margin-right: 4px; }
.with-icon { display: inline-flex; align-items: center; gap: 6px; }
.with-icon svg.icon, .option svg.icon, .select-trigger .label svg.icon { width: 16px; height: 16px; color: var(--muted); }
.option svg.icon { margin-right: 8px; }
.option.selected svg.icon { color: var(--brand); }
.select-trigger .label { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.pill { display: inline-flex; align-items: center; height: 18px; margin-top: 3px; padding: 0 7px; border-radius: 9px; font-size: 11px; font-weight: 700; letter-spacing: .01em; }
.pill--kommo { background: var(--kommo-50); color: var(--kommo); }
.pill--amocrm { background: var(--amocrm-50); color: var(--amocrm); }
.badge.ok { background: var(--brand-50); color: var(--brand); }
.badge.warn { background: var(--highlight-50); color: var(--highlight-900); }
.badge.bad { background: var(--bad-50); color: var(--bad); }
/* Spec 011: where an installation lives; staging stands out so it is not mistaken for a client. */
.sub .place--stage { color: var(--bad); font-weight: 700; }
.stage-banner { padding: 8px 24px; background: var(--bad); color: #fff; font-weight: 700; text-align: center; }
.stage-banner a { color: inherit; }
/* Spec 011 amendment: old copies of a widget, folded under its live installation. */
.copies summary { cursor: pointer; margin-top: 2px; color: var(--muted); font-size: 12px; }
.copies summary:hover { color: var(--text); }
.stage-banner a:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* Buttons */
button, .button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 16px; border: 1px solid var(--brand); border-radius: var(--radius); background: var(--brand); color: #fff; font-weight: 700; text-decoration: none; cursor: pointer; }
button:hover, .button:hover { background: var(--brand-900); border-color: var(--brand-900); }
button.secondary, .button.secondary { border-color: var(--line); background: var(--card); color: var(--text); }
button.secondary:hover, .button.secondary:hover { border-color: var(--line-strong); background: var(--hover); }
button.link, .link-action { height: auto; padding: 0; border: 0; background: none; color: var(--brand); font-weight: 700; text-decoration: none; }
button.link:hover { background: none; color: var(--brand-900); }
button:disabled { opacity: .5; pointer-events: none; }
button.danger { border-color: var(--bad); background: var(--bad); }
button.danger:hover { border-color: var(--bad); background: var(--bad); filter: brightness(.9); }
button:focus-visible, .button:focus-visible, .topbar nav a:focus-visible { outline: none; box-shadow: 0 0 0 1px var(--brand), 0 0 0 4px var(--brand-50); }

/* Form controls */
label { display: block; margin: 12px 0 6px; color: var(--muted); font-size: 12px; }
label.check { display: flex; align-items: center; gap: 8px; margin: 12px 0 0; color: var(--text); font-size: 14px; }
label.check--wrap { align-items: flex-start; font-size: 13px; }
input, select, textarea { height: 38px; padding: 0 11px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--text); outline: none; }
textarea { height: auto; padding: 9px 11px; }
input:hover, select:hover { border-color: var(--line-strong); }
input:focus, select:focus, textarea:focus, .select-trigger:focus-visible, .date-control:focus-visible, .date-range:focus-visible { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-50); outline: none; }
input[aria-invalid="true"], .invalid > .date-control { border-color: var(--bad); }
input:disabled, select:disabled { background: var(--bg); color: var(--muted); }
input[type="checkbox"] { appearance: none; position: relative; flex: 0 0 auto; width: 36px; height: 20px; margin: 0; padding: 0; border: 0; border-radius: 10px; background: var(--line-strong); cursor: pointer; vertical-align: middle; }
input[type="checkbox"]::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(31,35,49,.2); transition-property: transform; }
input[type="checkbox"]:checked { background: var(--brand); }
input[type="checkbox"]:checked::after { transform: translateX(16px); }
input[type="checkbox"]:focus-visible { box-shadow: 0 0 0 3px var(--brand-50); }
input[type="checkbox"]:disabled { opacity: .5; cursor: default; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.form-grid > * { min-width: 0; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid--3 { grid-template-columns: repeat(3, 1fr); }
.form-actions { display: flex; gap: 8px; margin-top: 18px; }
.native-hidden { display: none !important; }

/* Filter row */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 18px; }
.filters .select { min-width: 0; }
.filters .select-trigger, .filters .date-range { width: auto; min-width: 0; gap: 6px; padding: 0 10px 0 12px; }
.filters .select-trigger:not(.applied) svg:last-child { color: var(--subtle); }
.filters .select-trigger.applied > svg.icon { display: none; }
.filters .select-trigger.applied, .filters .date-range.filled, .search-field:has(input:not(:placeholder-shown)) { border-color: var(--brand-200); background: var(--brand-50); color: var(--brand); }
.filters .select-trigger.applied:hover, .filters .date-range.filled:hover { border-color: var(--brand); background: var(--brand-50); }
.filters .select-trigger.applied .label, .filters .date-range.filled span:not(.clear) { font-weight: 700; }
.filters .select-trigger.applied svg, .filters .date-range.filled svg, .search-field:has(input:not(:placeholder-shown)) svg { color: var(--brand); }
.filters > [hidden] { display: none !important; }
.add-filter { position: relative; }
.add-filter-trigger { gap: 6px; padding: 0 12px 0 10px; border-style: dashed; color: var(--muted); font-weight: 400; }
.add-filter-trigger:hover { border-style: solid; color: var(--text); }
.add-filter-menu { width: max-content; min-width: 190px; }
.add-filter-menu .option { justify-content: space-between; gap: 16px; }
.add-filter-menu .option svg.icon { width: 14px; height: 14px; margin: 0; color: var(--subtle); }
.filters .reset-filters { width: 38px; height: 38px; color: var(--muted); border-radius: var(--radius); }
.chip-clear, .date-range .clear { display: grid; place-items: center; width: 20px; height: 20px; margin-left: auto; border-radius: 50%; color: var(--brand); }
.chip-clear:hover, .date-range .clear:hover { background: var(--card); }
.chip-clear svg.icon { width: 13px; height: 13px; }
.search-field { display: flex; align-items: center; gap: 8px; height: 38px; width: 210px; padding: 0 11px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--muted); }
.search-field:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-50); }
.search-field input { flex: 1; min-width: 0; height: 100%; padding: 0; border: 0; background: transparent; box-shadow: none !important; }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
/* Owner 2026-09-24: every table fits its container with fixed columns; long names are clipped with the full text in the tooltip.
   Below the minimum width the wrapper scrolls instead of squeezing (FR-T1: no column is hidden). */
.table-wrap > table { table-layout: fixed; min-width: 640px; }
.table-wrap th { overflow: hidden; white-space: normal; line-height: 1.25; }
.table-wrap td { overflow-wrap: anywhere; }
.row-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.row-meta .pill { margin-top: 0; }
.table-filters { margin-bottom: 12px; }
.tabs:has(.tabs-tools) { height: 41px; overflow: visible; }
.tabs .tabs-tools { flex-wrap: nowrap; align-items: center; align-self: center; height: 32px; margin: 0 0 0 auto; }
.tabs .tabs-tools .select { height: 32px; }
.tabs .tabs-tools[hidden] { display: none; }
.tabs .tabs-tools .search-field { width: 180px; }
.tabs .tabs-tools .search-field, .tabs .tabs-tools .select-trigger { height: 32px; min-height: 32px; }
.clip { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
col.c-check { width: 44px; } col.c-act { width: 56px; } col.c-act2 { width: 88px; } col.c-xs { width: 76px; } col.c-s { width: 96px; }
col.c-date { width: 112px; } col.c-thumb { width: 84px; }
.widgets-table .widget-logo { width: 56px; border-radius: var(--radius-sm); border: 1px solid var(--line); }
.widgets-table .widget-logo--empty img { width: 18px; height: 18px; }
/* One widget, an archive a line: the second archive stands under the first, with no rule between them. */
.widgets-table tr.widget-family > td { border-bottom-color: transparent; }
.widgets-table tr.widget-sibling > td { padding-top: 0; }
.widgets-table tr.widget-sibling > td:nth-child(2) > a { font-weight: 400; color: var(--muted); }
.widgets-table form { display: inline; } col.c-m { width: 124px; } col.c-l { width: 152px; }
th, td { padding: 0 14px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line); }
th { height: 44px; color: var(--muted); font-size: 12px; font-weight: 400; white-space: nowrap; }
td { height: 52px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--bg); }
.nowrap { white-space: nowrap; }
.pre-line { white-space: pre-line; }
.sort-link { display: inline-flex; align-items: center; gap: 4px; color: inherit; text-decoration: none; }
.sort-link:hover { color: var(--text); }
th.num .sort-link { flex-direction: row-reverse; }
.sort-arrow { opacity: 0; font-size: 11px; }
.sort-link:hover .sort-arrow { opacity: .5; }
.sort-arrow.active { opacity: 1; color: var(--brand); }
th[aria-sort="ascending"], th[aria-sort="descending"] { color: var(--text); }
td .sub { display: block; white-space: normal; margin-top: 2px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
td .sub--warn { color: var(--highlight-900); }
.date, .calendar-grid, .time-column, .date-control, .date-range { font-variant-numeric: tabular-nums; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.pagination { margin-top: 16px; }
.copyable { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; }
.copyable .clip { min-width: 0; }
.copy { width: 24px; height: 24px; padding: 0; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--subtle); opacity: 0; }
tr:hover .copy, .copy:focus-visible, .copy.done { opacity: 1; }
.copy:hover { background: var(--hover); color: var(--text); }
.copy.done { color: var(--brand); }
/* Entity page (owner 2026-09-24): a metrics strip, the main tabs and a side panel of properties; changes open in dialogs. */
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.entity-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: -12px 0 20px; color: var(--muted); font-size: 13px; }
.entity-meta .sep { color: var(--line-strong); }
.stat-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1px; margin-bottom: 24px; overflow: hidden; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.stat-cell { display: flex; flex-direction: column; gap: 4px; min-width: 0; padding: 14px 18px; background: var(--card); }
.stat-value { display: flex; align-items: center; gap: 8px; font-size: 20px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat-sub { overflow: hidden; color: var(--muted); font-size: 12px; white-space: nowrap; text-overflow: ellipsis; }
.page-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start; }
.page-layout > .page-main > .tabs:first-child { margin-top: 0; }
/* The side panel starts level with the table, not with the tabs above it. */
.page-layout > .side-panel { margin-top: 59px; }
.page-layout--no-tabs > .side-panel { margin-top: 0; }
.activity { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.activity::before { content: ""; width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: var(--line-strong); }
.activity--ok::before { background: var(--brand); }
.activity--warn::before { background: var(--highlight-50); box-shadow: inset 0 0 0 1.5px var(--highlight-900); }
.side-panel { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.side-section { padding: 16px 18px; }
.side-section + .side-section { border-top: 1px solid var(--line); }
.side-section h3 { margin: 0 0 10px; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .02em; }
.props { grid-template-columns: 112px minmax(0, 1fr); gap: 7px 12px; font-size: 13px; }
.props dd { overflow-wrap: anywhere; }
.side-section .form-actions { margin-top: 12px; }
@media (max-width: 960px) { .page-layout { grid-template-columns: 1fr; } .page-layout > .side-panel { margin-top: 0; } }
.modal-body form input:not([type="checkbox"]):not([type="hidden"]), .modal-body form select, .modal-body form .select { width: 100%; }
.modal-rule { margin: 20px 0 12px; border: 0; border-top: 1px solid var(--line); }

/* Drawer: a widget of a project opens over the project page, from the right. */
dialog.drawer { position: fixed; inset: 0 0 0 auto; width: min(720px, 100%); height: 100%; max-width: 100%; max-height: 100%; margin: 0 0 0 auto; padding: 0; overflow: hidden; background: var(--bg); color: var(--text); border: 0; border-left: 1px solid var(--line); box-shadow: -24px 0 60px rgba(31,35,49,.18); }
dialog.drawer::backdrop { background: rgba(31,35,49,.28); }
dialog.drawer[open] { animation: drawer-in 220ms var(--ease); }
@keyframes drawer-in { from { opacity: 0; transform: translateX(32px); } }
.drawer-body { height: 100%; overflow-y: auto; }
.drawer-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 18px 24px 14px; background: var(--card); border-bottom: 1px solid var(--line); }
.drawer-head h2 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 20px; letter-spacing: -.02em; }
.drawer-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.drawer-sub .sep { color: var(--line-strong); }
.drawer-sub .with-icon svg.icon { width: 14px; height: 14px; }
.drawer-content { padding: 18px 24px 32px; }
.drawer-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.drawer-bar .entity-meta { margin: 0; }
.drawer-content .stat-strip { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 16px; }
.drawer-props { margin-bottom: 4px; }
.drawer-content .tabs { margin-top: 20px; }
.drawer-standalone { max-width: 760px; }
.drawer-standalone .drawer-head { position: static; border: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; }
.drawer-standalone [data-drawer-close] { display: none; }
.props .sub { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.inline-form { display: inline; }
button.link-like { height: auto; padding: 0; border: 0; background: none; color: var(--brand); font-weight: 400; text-decoration: underline; cursor: pointer; }
button.link-like:hover { background: none; color: var(--brand-900); }

.contact-row { display: flex; flex-direction: column; gap: 2px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 13px; }
.contact-row .sub { color: var(--muted); font-size: 12px; }

/* Partners */
.partner-logo { display: inline-grid; place-items: center; width: 32px; height: 32px; flex: 0 0 auto; object-fit: contain; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--card); }
.partner-logo--empty { background: var(--hover); color: var(--muted); font-size: 14px; font-weight: 700; }
.file-field { display: flex; align-items: center; gap: 10px; }
.modal-body form .file-field input[type="file"] { height: auto; padding: 0; border: 0; background: none; box-shadow: none; }
input[type="file"]::file-selector-button { height: 34px; margin-right: 10px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--text); font: inherit; font-weight: 700; cursor: pointer; }
input[type="file"]::file-selector-button:hover { background: var(--hover); }
.account-title .partner-logo { width: 40px; height: 40px; }

/* Dashboard charts (spec 006 FR-D1): small multiples, one series each, brand columns on a recessive grid. */
.charts { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; margin-bottom: 16px; }
.chart { margin: 0; padding: 14px 16px 8px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.chart-svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-grid, .chart-axis { stroke: var(--line); stroke-width: 1; }
.chart-axis { stroke: var(--line-strong); }
.chart-tick { fill: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.chart-col { fill: var(--brand); }
.chart-col--neg { fill: var(--muted); }
.chart-hit { fill: transparent; }
.chart-bar:hover .chart-col { fill: var(--brand-900); }
.chart-bar:hover .chart-hit { fill: var(--hover); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 28px 0 12px; }
.section-head h2 { margin: 0; }
.chart-table { margin-bottom: 8px; }
.chart-table summary { cursor: pointer; color: var(--brand); margin-bottom: 10px; }
.period-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.segmented-links { display: inline-flex; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.segmented-links a { display: inline-flex; align-items: center; height: 32px; padding: 0 12px; border-radius: var(--radius-sm); color: var(--muted); text-decoration: none; }
.segmented-links a.active { background: var(--brand-50); color: var(--brand); font-weight: 700; }

/* Toasts: notices over the page, top right. */
.toasts { position: fixed; top: 76px; right: 24px; z-index: 60; display: flex; flex-direction: column; gap: 10px; width: min(420px, calc(100% - 32px)); pointer-events: none; }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 12px 10px 12px 14px; background: var(--card); border: 1px solid var(--line); border-left: 3px solid var(--brand); border-radius: var(--radius); box-shadow: var(--shadow-pop); font-size: 13px; pointer-events: auto; animation: popover-in var(--duration) var(--ease); }
.toast--bad { border-left-color: var(--bad); }
.toast-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; overflow-wrap: anywhere; }
.toast-close { width: 26px; height: 26px; flex: 0 0 auto; }
.toast .toast-copy { opacity: 1; color: var(--muted); }
.toast.leaving { opacity: 0; transform: translateY(-4px); transition: opacity var(--duration) var(--ease), transform var(--duration) var(--ease); }
.copy svg.icon { width: 15px; height: 15px; }

/* Popover shared by select, calendar and menus */
.select, .date-picker, .date-range-wrap { position: relative; }
.popover { position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; padding: 6px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-pop); }
.popover[hidden] { display: none; }
.popover--right { left: auto; right: 0; }
.popover.popover--up { top: auto; bottom: calc(100% + 6px); animation-name: popover-in-up; }
@keyframes popover-in-up { from { opacity: 0; transform: translateY(4px) scale(.98); } }

/* Select */
.select-trigger { justify-content: space-between; width: 100%; padding: 0 11px; border-color: var(--line); background: var(--card); color: var(--text); font-weight: 400; }
.select-trigger:hover { border-color: var(--line-strong); background: var(--card); }
.select-trigger span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.select-trigger svg { color: var(--muted); }
.select-options { width: max-content; min-width: 100%; max-height: 300px; overflow-y: auto; }
.option { display: flex; width: 100%; height: 34px; justify-content: flex-start; padding: 0 10px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text); font-weight: 400; white-space: nowrap; }
.option:hover, .option.focused { background: var(--hover); color: var(--text); border: 0; }
.option.selected { background: var(--brand-50); color: var(--brand); font-weight: 700; }
.option--check { gap: 10px; }
.option--check.selected { background: transparent; color: var(--text); font-weight: 400; }
.option--check.selected:hover, .option--check.focused { background: var(--hover); }
.option--check .check { display: grid; place-items: center; flex: 0 0 18px; width: 18px; height: 18px; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--card); }
.option--check .check svg.icon { width: 12px; height: 12px; margin: 0; color: #fff; opacity: 0; stroke-width: 2.4; }
.option--check.selected .check { border-color: var(--brand); background: var(--brand); }
.option--check.selected .check svg.icon { opacity: 1; }
.option-text { display: inline-flex; align-items: center; }

/* Date and date-time */
.datetime { display: flex; flex-wrap: wrap; gap: 8px; }
.datetime .date-picker { flex: 1 1 150px; min-width: 0; }
.time-picker { position: relative; flex: 1 0 100px; max-width: 116px; }
.datetime .date-control { min-width: 0; }
.time-control { min-width: 0; }
.time-popover { display: flex; gap: 4px; }
.time-column { display: flex; flex-direction: column; gap: 2px; width: 56px; max-height: 232px; overflow-y: auto; scrollbar-width: none; }
.time-column .option { flex: 0 0 32px; justify-content: center; padding: 0; font-variant-numeric: tabular-nums; }
.date-control, .date-range { justify-content: flex-start; gap: 8px; width: 100%; min-width: 150px; padding: 0 11px; border-color: var(--line); background: var(--card); color: var(--text); font-weight: 400; }
.date-control:hover, .date-range:hover { border-color: var(--line-strong); background: var(--card); }
.date-control svg, .date-range svg { color: var(--muted); }
.date-control .placeholder, .date-range .placeholder { color: var(--muted); }
.date-range { min-width: 210px; }
.date-range.filled { border-color: var(--line-strong); background: var(--hover); }

.calendar { width: 280px; padding: 10px; }
.calendar-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-size: 13px; font-weight: 700; }
.calendar-top button, .icon-button { width: 28px; height: 28px; padding: 0; border: 0; background: transparent; color: var(--muted); }
.calendar-top button:hover, .icon-button:hover { background: var(--hover); color: var(--text); }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px 0; text-align: center; }
.calendar-grid span { display: grid; place-items: center; height: 28px; color: var(--muted); font-size: 11px; font-weight: 700; }
.calendar-grid button { height: 32px; padding: 0; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text); font-size: 13px; font-weight: 400; }
.calendar-grid button:hover { background: var(--hover); }
.calendar-grid button.outside { color: var(--subtle); }
.calendar-grid button.today { font-weight: 700; box-shadow: inset 0 0 0 1px var(--line); }
.calendar-grid button.in-range { border-radius: 0; background: var(--brand-50); }
.calendar-grid button.selected, .calendar-grid button.range-start, .calendar-grid button.range-end { background: var(--brand); color: #fff; font-weight: 700; box-shadow: none; }
.calendar-grid button.range-start { border-radius: 6px 0 0 6px; }
.calendar-grid button.range-end { border-radius: 0 6px 6px 0; }
.calendar-grid button.range-start.range-end { border-radius: var(--radius-sm); }
.calendar-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.calendar-actions .draft { white-space: nowrap; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.calendar-actions .buttons { display: flex; align-items: center; gap: 12px; }
.calendar-actions button { height: 30px; padding: 0 12px; font-size: 12px; }
.calendar-actions button.link { height: auto; padding: 0; }

.range-popover { display: flex; gap: 4px; width: max-content; padding: 10px; }
.range-presets { flex: 0 0 auto; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; gap: 2px; padding-right: 8px; border-right: 1px solid var(--line); }
.range-presets .option { font-size: 13px; }
.range-popover .calendar { width: 320px; padding: 0 0 0 6px; }

/* Tabs */
.tabs { display: flex; gap: 24px; margin: 28px 0 18px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { position: relative; display: inline-flex; flex-direction: column; align-items: flex-start; justify-content: center; height: 40px; padding: 0; border: 0; border-radius: 0; background: transparent; color: var(--muted); font-weight: 400; white-space: nowrap; }
.tab::before { content: attr(data-label); height: 0; overflow: hidden; visibility: hidden; font-weight: 700; }
.tab:hover { background: transparent; color: var(--text); }
.tab.active { color: var(--text); font-weight: 700; }
[data-tab-panel][hidden] { display: none; }

/* Segmented control */
.segmented { display: inline-flex; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.segmented button { height: 28px; padding: 0 11px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--muted); font-size: 13px; font-weight: 400; }
.segmented button.active { background: var(--brand-50); color: var(--brand); font-weight: 700; }

/* Modal */
dialog.modal { width: min(460px, calc(100% - 32px)); padding: 0; overflow: visible; background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 24px 60px rgba(31,35,49,.2); }
dialog.modal::backdrop { background: rgba(31,35,49,.28); backdrop-filter: blur(2px); }
dialog.modal[open] { animation: popover-in var(--duration) var(--ease); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 20px 22px 4px; }
.modal-head h2 { margin: 0; font-size: 18px; overflow-wrap: anywhere; }
.modal-body { padding: 0 22px 22px; }
.modal-body > .muted:first-child { margin-top: 4px; }
.icon-button { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: var(--radius); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Motion: one duration and easing for every hover, focus and state change. */
button, .button, input, select, textarea, .search-field, .topbar nav a, .option, .copy, tbody td, a.card, .widget-card, .stage-card, a.kpi, label.check {
    transition: background-color var(--duration) var(--ease), border-color var(--duration) var(--ease), color var(--duration) var(--ease), box-shadow var(--duration) var(--ease), opacity var(--duration) var(--ease), transform var(--duration) var(--ease);
}
input[type="checkbox"], input[type="checkbox"]::after { transition-duration: 220ms; transition-timing-function: var(--ease); }
button:active, .button:active { transform: translateY(1px); }
.popover:not([hidden]) { animation: popover-in var(--duration) var(--ease); }
@keyframes popover-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.tab::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; border-radius: 2px; background: var(--brand); transform: scaleX(0); transition: transform 240ms var(--ease); }
.tab.active::after { transform: scaleX(1); }
.select-trigger svg { transition: transform var(--duration) var(--ease); }
.select-trigger[aria-expanded="true"] svg { transform: rotate(180deg); }
a.card:hover, .widget-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-pop); transform: translateY(-2px); }
[data-tab-panel]:not([hidden]) { animation: panel-in 220ms var(--ease); }
@keyframes panel-in { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (max-width: 650px) {
    .stage-banner { padding: 8px 16px; }
    main { padding: 20px 16px; }
    .topbar { padding: 10px 16px; }
    .form-grid { grid-template-columns: 1fr; }
    .filters > *, .filters .select, .date-range-wrap, .search-field { width: 100%; }
    .filters .select-trigger, .filters .date-range { width: 100%; }
    .range-popover { position: fixed; top: 90px; left: 16px; right: 16px; width: auto; flex-direction: column; }
    .range-presets { padding: 0 0 8px; border-right: 0; border-bottom: 1px solid var(--line); }
    .range-popover .calendar { width: 100%; padding: 0; }
}

/* Widget cards (spec 005) */
.widget-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.widget-card { display: flex; flex-direction: column; overflow: hidden; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); color: var(--text); text-decoration: none; }
.widget-card:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-50), 0 0 0 1px var(--brand); }
.widget-card-wrap { position: relative; display: flex; }
.widget-card-wrap > .widget-card { flex: 1; }
.widget-hide { position: absolute; z-index: 1; top: 10px; right: 10px; opacity: 0; transition: opacity var(--duration) var(--ease); }
.widget-card-wrap:hover .widget-hide, .widget-hide:focus-within { opacity: 1; }
@media (hover: none) { .widget-hide { opacity: 1; } }
.widget-card-body { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px 16px; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.widget-logo { display: block; width: 100%; aspect-ratio: 400 / 272; object-fit: cover; background: var(--bg); border-radius: var(--radius-sm); }
.widget-card .widget-logo { border-radius: 0; border-bottom: 1px solid var(--line); }
.widget-logo--empty { display: grid; place-items: center; }
.card > .widget-logo { margin-bottom: 16px; }
.widget-logo--empty img { opacity: .35; filter: grayscale(1); }
.steps { margin: 0; padding: 0; list-style: none; }
.steps-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px; border-bottom: 1px solid var(--line); color: var(--muted); }
.steps-item--done { color: var(--text); }
.steps-item--current { color: var(--brand); font-weight: 700; }
.steps-item--current svg.icon { color: var(--brand); }
.missing { margin: 0; padding-left: 18px; color: var(--highlight-900); }
.missing li { margin-bottom: 4px; }
.widget-card-body .sub { color: var(--muted); font-size: 12px; }
