:root {
    color-scheme: light;
    --ink: #17191b;
    --ink-soft: #4f585f;
    --muted: #778188;
    --line: #d8dde0;
    --line-strong: #c5ccd0;
    --surface: #ffffff;
    --surface-alt: #f5f7f8;
    --canvas: #eceff1;
    --sidebar: #17191b;
    --sidebar-soft: #24282b;
    --yellow: #f5c400;
    --yellow-dark: #c79f00;
    --yellow-soft: #fff6cf;
    --green: #23875a;
    --green-soft: #e7f5ee;
    --red: #c84f47;
    --red-soft: #fcecea;
    --amber: #b77900;
    --amber-soft: #fff4d6;
    --blue: #3f6f88;
    --blue-soft: #e7f0f5;
    --shadow: 0 8px 28px rgba(24, 29, 32, 0.08);
    --sidebar-width: 236px;
    --topbar-height: 78px;
    font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html {
    min-width: 320px;
    background: var(--canvas);
}

body {
    margin: 0;
    color: var(--ink);
    background: var(--canvas);
    font-size: 14px;
    line-height: 1.45;
    letter-spacing: 0;
}

button,
input,
select {
    font: inherit;
    letter-spacing: 0;
}

button,
summary,
select {
    cursor: pointer;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
    outline: 3px solid rgba(245, 196, 0, 0.45);
    outline-offset: 2px;
}

a {
    color: inherit;
    text-decoration: none;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1,
h2,
h3 {
    letter-spacing: 0;
}

h1 {
    margin-bottom: 0;
    font-size: 22px;
    line-height: 1.15;
}

h2 {
    margin-bottom: 0;
    font-size: 24px;
    line-height: 1.2;
}

h3 {
    margin-bottom: 0;
    font-size: 16px;
    line-height: 1.25;
}

.eyebrow {
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.12em;
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 44px;
}

.brand-symbol {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    color: var(--ink);
    background: var(--yellow);
    border: 2px solid var(--yellow);
    border-radius: 4px;
    font-size: 25px;
    font-weight: 950;
    line-height: 1;
}

.brand-copy {
    display: flex;
    flex-direction: column;
    line-height: 1;
}

.brand-copy strong {
    color: #fff;
    font-size: 20px;
    font-weight: 900;
}

.brand-copy small {
    margin-top: 5px;
    color: var(--yellow);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.22em;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    display: flex;
    width: var(--sidebar-width);
    flex-direction: column;
    padding: 20px 14px 16px;
    color: #e9edef;
    background: var(--sidebar);
    border-right: 1px solid #2d3235;
    transition: width 220ms ease, padding 220ms ease;
}

.sidebar-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 34px;
    align-items: center;
    gap: 8px;
    min-height: 58px;
    padding: 0 2px 14px 8px;
    border-bottom: 1px solid #313638;
}

.sidebar-collapse {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    padding: 0;
    color: #bfc7cb;
    background: var(--sidebar-soft);
    border: 1px solid #363d41;
    border-radius: 5px;
}

.sidebar-collapse:hover { color: #fff; border-color: #626c72; }
.sidebar .sidebar-collapse {
    box-shadow: 3px 3px 6px #0006, -2px -2px 5px #ffffff09, inset 1px 1px 0 #ffffff0b;
    transition: box-shadow 180ms ease, color 140ms ease;
}
.sidebar .sidebar-collapse:hover,
.sidebar .sidebar-collapse:active {
    box-shadow: inset 3px 3px 6px #0008, inset -2px -2px 5px #ffffff0c;
}
.sidebar-collapse svg { width: 18px; height: 18px; }
.sidebar-collapse-mark { display: none; }

.primary-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 18px;
}

.nav-item {
    display: flex;
    width: 100%;
    min-height: 42px;
    align-items: center;
    gap: 11px;
    padding: 9px 11px;
    color: #bfc7cb;
    background: transparent;
    border: 0;
    border-radius: 5px;
    text-align: left;
    transition: color 140ms ease, background 140ms ease;
}

.nav-item svg {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
}

.nav-item:hover {
    color: #fff;
    background: #252a2d;
}

.nav-item.is-active {
    color: var(--ink);
    background: var(--yellow);
    font-weight: 750;
}

/* Sidebar relief only: no changes to icons, palette, dimensions or navigation. */
@property --sidebar-rim-angle {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}
.sidebar {
    box-shadow: inset -1px 0 0 #ffffff09, 3px 0 8px #00000014;
}
.sidebar .nav-item {
    position: relative;
    isolation: isolate;
    box-shadow: inset 0 0 0 #0000, inset 0 0 0 #fff0;
    transition: color 140ms ease, background 140ms ease, box-shadow 180ms ease;
}
.sidebar .nav-item::after {
    content: '';
    position: absolute;
    inset: 0;
    padding: 1px;
    border-radius: inherit;
    pointer-events: none;
    background: linear-gradient(135deg, #00000055, #ffffff12 42%, #f5c40020 68%, #00000066);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
    opacity: .55;
    transition: opacity 180ms ease;
}
.sidebar .nav-item:hover::after,
.sidebar .nav-item:focus-visible::after {
    opacity: 1;
    background: conic-gradient(from var(--sidebar-rim-angle), #00000055 0deg, #ffffff10 85deg, #f5c40038 130deg, #ffe875bb 165deg, #f5c40066 190deg, #ffffff12 230deg, #00000055 300deg);
    animation: sidebar-rim-orbit 3.2s linear infinite;
}
@keyframes sidebar-rim-orbit { to { --sidebar-rim-angle: 360deg; } }
.sidebar .nav-item:hover,
.sidebar .nav-item:focus-visible {
    box-shadow: inset 4px 4px 8px #0008, inset -3px -3px 7px #ffffff0b;
}
.sidebar .nav-item.is-active {
    box-shadow: 3px 3px 7px #0006, -2px -2px 5px #ffffff08, inset 1px 1px 1px #ffffff60, inset -1px -1px 2px #0003;
}
.sidebar .nav-item.is-active:hover,
.sidebar .nav-item.is-active:focus-visible,
.sidebar .nav-item:active {
    box-shadow: inset 3px 3px 7px #0004, inset -3px -3px 7px #ffffff30;
}
.sidebar .nav-item:focus-visible,
.sidebar .sidebar-collapse:focus-visible {
    outline: 2px solid var(--yellow);
    outline-offset: 2px;
}
.sidebar .sidebar-head { box-shadow: 0 1px 0 #ffffff05; }
.sidebar .sidebar-admin,
.sidebar .sidebar-footer { box-shadow: inset 0 1px 0 #0005; }
@media (prefers-reduced-motion: reduce) {
    .sidebar .nav-item, .sidebar .sidebar-collapse { transition: none; }
    .sidebar .nav-item::after { animation: none !important; transition: none; }
}

.sidebar-admin {
    margin-top: 22px;
    padding-top: 16px;
    border-top: 1px solid #313638;
}

.sidebar-admin > p {
    margin: 0 11px 7px;
    color: #778084;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.12em;
}

.sidebar-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 0;
    padding: 14px 10px 2px;
    border-top: 1px solid #313638;
}

.sidebar-footer > span:last-child {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.sidebar-footer strong,
.sidebar-footer small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-footer strong {
    font-size: 12px;
}

.sidebar-footer small {
    color: #899297;
    font-size: 10px;
}

.status-dot {
    width: 8px;
    height: 8px;
    flex: 0 0 auto;
    background: var(--green);
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(35, 135, 90, 0.17);
}

.app-shell {
    min-height: 100vh;
    margin-left: var(--sidebar-width);
    transition: margin-left 220ms ease;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: grid;
    min-height: var(--topbar-height);
    grid-template-columns: minmax(180px, 0.8fr) minmax(400px, 1.3fr) auto;
    align-items: center;
    gap: 22px;
    padding: 12px 24px;
    background: rgba(255, 255, 255, 0.98);
    border-bottom: 1px solid var(--line);
}

@media (min-width: 821px) {
    .app-body.sidebar-collapsed { --sidebar-width: 76px; }
    .app-body.sidebar-collapsed .sidebar { padding-inline: 10px; }
    .app-body.sidebar-collapsed .sidebar-head { display: flex; justify-content: center; padding-inline: 0; }
    .app-body.sidebar-collapsed .sidebar-head .brand { display: none; }
    .app-body.sidebar-collapsed .sidebar-collapse { width: 38px; height: 38px; flex: 0 0 auto; background: transparent; border: 0; }
    .app-body.sidebar-collapsed .sidebar-collapse svg { display: none; }
    .app-body.sidebar-collapsed .sidebar-collapse-mark { display: grid; }
    .app-body.sidebar-collapsed .primary-nav { align-items: center; }
    .app-body.sidebar-collapsed .nav-item { justify-content: center; gap: 0; padding-inline: 0; }
    .app-body.sidebar-collapsed .nav-item > span,
    .app-body.sidebar-collapsed .sidebar-admin > p,
    .app-body.sidebar-collapsed .sidebar-footer > span:last-child { display: none; }
    .app-body.sidebar-collapsed .sidebar-admin { width: 100%; }
    .app-body.sidebar-collapsed .sidebar-footer { justify-content: center; padding-inline: 0; }
}

.topbar-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar .sidebar-toggle {
    display: none;
}

.global-filters {
    display: grid;
    grid-template-columns: minmax(280px, 1.5fr) minmax(180px, 1fr) 36px;
    align-items: end;
    gap: 8px;
}

.global-filters label,
.period-filter,
.seller-filter,
.field {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 5px;
}

.global-filters label > span,
.period-filter > span,
.seller-filter > span,
.field > span:first-child {
    color: var(--ink-soft);
    font-size: 11px;
    font-weight: 700;
}

.period-filter {
    position: relative;
}

.seller-filter {
    position: relative;
}

.period-trigger {
    display: grid;
    width: 100%;
    min-height: 38px;
    grid-template-columns: 18px minmax(0, 1fr) 16px;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 5px;
    text-align: left;
}

.period-trigger:hover,
.period-trigger[aria-expanded="true"] {
    border-color: var(--yellow-dark);
}

.period-trigger strong {
    overflow: hidden;
    font-size: 12px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.period-trigger svg {
    width: 16px;
    height: 16px;
    color: var(--muted);
}

.seller-filter-trigger {
    display: grid;
    width: 100%;
    min-height: 38px;
    grid-template-columns: 18px minmax(0, 1fr) 16px;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 5px;
    text-align: left;
}

.seller-filter-trigger:hover,
.seller-filter-trigger[aria-expanded="true"] {
    border-color: var(--yellow-dark);
}

.seller-filter-trigger strong {
    overflow: hidden;
    font-size: 12px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.seller-filter-trigger svg {
    width: 16px;
    height: 16px;
    color: var(--muted);
}

.seller-picker {
    position: absolute;
    z-index: 61;
    top: calc(100% + 8px);
    right: 0;
    width: min(340px, calc(100vw - 32px));
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    box-shadow: 0 18px 48px rgba(20, 25, 28, 0.18);
}

.seller-picker > header,
.seller-picker > footer {
    display: flex;
    min-height: 48px;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 12px;
}

.seller-picker > header {
    border-bottom: 1px solid var(--line);
}

.seller-picker > footer {
    justify-content: flex-end;
    border-top: 1px solid var(--line);
}

.seller-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
    max-height: 310px;
    overflow: auto;
    padding: 10px;
}

.seller-option {
    display: grid;
    grid-template-columns: 16px minmax(0, 1fr);
    align-items: center;
    gap: 7px;
    min-width: 0;
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
}

.seller-option:hover {
    background: var(--surface-alt);
}

.seller-option:first-child {
    grid-column: 1 / -1;
    border-bottom: 1px solid var(--line);
}

.seller-option input {
    width: 16px;
    height: 16px;
    min-height: 16px;
    margin: 0;
    padding: 0;
    accent-color: var(--ink);
}

.seller-option span {
    overflow: hidden;
    font-size: 12px;
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.period-picker {
    position: absolute;
    z-index: 60;
    top: calc(100% + 8px);
    left: 0;
    width: min(660px, calc(100vw - 32px));
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    box-shadow: 0 18px 48px rgba(20, 25, 28, 0.18);
}

.period-picker-header,
.period-picker-actions {
    display: flex;
    min-height: 48px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 14px;
    border-bottom: 1px solid var(--line);
}

.period-picker-header strong {
    font-size: 13px;
}

.period-calendars {
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.calendar-panel {
    min-width: 0;
    padding: 10px 14px 14px;
}

.calendar-panel + .calendar-panel {
    border-left: 1px solid var(--line);
}

.calendar-heading {
    display: grid;
    min-height: 38px;
    grid-template-columns: 32px minmax(0, 1fr) 32px;
    align-items: center;
    text-align: center;
}

.calendar-heading strong {
    font-size: 13px;
}

.calendar-heading button {
    display: grid;
    width: 30px;
    height: 30px;
    place-items: center;
    padding: 0;
    color: var(--muted);
    background: transparent;
    border: 0;
    border-radius: 4px;
}

.calendar-heading button:hover {
    color: var(--ink);
    background: var(--surface-alt);
}

.calendar-heading svg {
    width: 16px;
    height: 16px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(30px, 1fr));
    gap: 2px 0;
}

.calendar-weekday,
.calendar-day {
    display: grid;
    min-width: 0;
    height: 34px;
    place-items: center;
    font-size: 11px;
}

.calendar-weekday {
    color: var(--muted);
    font-weight: 600;
}

.calendar-day {
    position: relative;
    padding: 0;
    color: var(--ink-soft);
    background: transparent;
    border: 0;
    border-radius: 0;
}

.calendar-day:hover {
    z-index: 1;
    background: var(--yellow-soft);
    border-radius: 4px;
}

.calendar-day.is-outside {
    color: #bec2c6;
}

.calendar-day.is-today::after {
    position: absolute;
    right: 7px;
    bottom: 3px;
    left: 7px;
    height: 2px;
    background: var(--yellow-dark);
    content: "";
}

.calendar-day.is-range {
    background: var(--yellow-soft);
}

.calendar-day.is-start,
.calendar-day.is-end {
    z-index: 2;
    color: var(--ink);
    background: var(--yellow);
    border-radius: 4px;
    font-weight: 800;
}

.period-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    padding: 10px 14px;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.period-presets button {
    padding: 4px 10px;
    color: #155fc5;
    background: transparent;
    border: 0;
    border-right: 1px solid var(--line);
    font-size: 11px;
}

.period-presets button:hover {
    color: var(--ink);
    text-decoration: underline;
}

.period-picker-actions {
    min-height: 54px;
    justify-content: flex-end;
    border-bottom: 0;
}

input,
select {
    width: 100%;
    min-height: 38px;
    padding: 8px 10px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 5px;
}

input:hover,
select:hover {
    border-color: #9aa4a9;
}

input:focus,
select:focus {
    border-color: var(--yellow-dark);
}

.icon-button {
    display: inline-grid;
    width: 36px;
    height: 36px;
    flex: 0 0 auto;
    place-items: center;
    padding: 0;
    color: var(--ink-soft);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 5px;
}

.icon-button:hover {
    color: var(--ink);
    border-color: var(--line-strong);
    background: var(--surface-alt);
}

.icon-button svg,
.button svg {
    width: 17px;
    height: 17px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
    min-width: 0;
}
#quick-pipe-refresh { flex: 0 0 auto; }
#quick-pipe-message { flex-basis: 100%; max-width: 360px; font-size: 11px; overflow-wrap: anywhere; }
#quick-pipe-message:empty { display: none; }

.sync-chip {
    display: flex;
    min-height: 42px;
    align-items: center;
    gap: 10px;
    padding: 5px 10px;
    color: var(--ink);
    background: var(--surface-alt);
    border: 1px solid var(--line);
    border-radius: 5px;
}

.sync-chip > span:nth-child(2) {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.sync-chip small {
    color: var(--muted);
    font-size: 9px;
}

.sync-chip strong {
    font-size: 11px;
}

.user-menu {
    position: relative;
}

.user-menu summary {
    display: flex;
    min-width: 170px;
    align-items: center;
    gap: 8px;
    list-style: none;
}

.user-menu summary::-webkit-details-marker {
    display: none;
}

.user-avatar {
    display: grid;
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    place-items: center;
    color: var(--ink);
    background: var(--yellow);
    border-radius: 50%;
    font-weight: 850;
}

.user-copy,
.table-user > span:last-child,
.admin-user > span:last-child {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.user-copy strong,
.user-copy small {
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-copy strong {
    font-size: 12px;
}

.user-copy small {
    color: var(--muted);
    font-size: 10px;
}

.user-menu summary > svg {
    width: 14px;
}

.user-popover {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    z-index: 70;
    width: 210px;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
    box-shadow: var(--shadow);
}

.user-popover a,
.user-popover button {
    display: flex;
    width: 100%;
    min-height: 38px;
    align-items: center;
    gap: 9px;
    padding: 8px 9px;
    color: var(--ink);
    background: transparent;
    border: 0;
    border-radius: 4px;
    text-align: left;
}

.user-popover a:hover,
.user-popover button:hover {
    background: var(--surface-alt);
}

.user-popover svg {
    width: 16px;
}

.dashboard-main {
    width: 100%;
    max-width: 1640px;
    margin: 0 auto;
    padding: 24px;
}

.section-heading {
    display: flex;
    min-height: 48px;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.section-heading-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.button-compact {
    min-height: 34px;
    padding: 7px 10px;
    font-size: 11px;
    white-space: nowrap;
}

.data-mode,
.source-pill,
.status-badge {
    display: inline-flex;
    min-height: 26px;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 750;
}

.data-mode,
.status-reference {
    color: #6f5700;
    background: var(--amber-soft);
    border: 1px solid #e8cd7e;
}

.source-pill {
    color: var(--blue);
    background: var(--blue-soft);
    border: 1px solid #bdd2df;
}

.source-pill svg {
    width: 14px;
}

.kpi-grid {
    display: grid;
    gap: 10px;
    margin-bottom: 18px;
}

.kpi-grid-primary {
    grid-template-columns: repeat(6, minmax(138px, 1fr));
}

.kpi-grid-small {
    grid-template-columns: repeat(4, minmax(160px, 1fr));
}

.kpi-grid-quality {
    grid-template-columns: repeat(5, minmax(160px, 1fr));
}

.kpi-grid-nomus {
    grid-template-columns: repeat(6, minmax(150px, 1fr));
}

.kpi-grid-nomus .kpi strong {
    font-size: 19px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.kpi {
    position: relative;
    display: flex;
    min-width: 0;
    min-height: 116px;
    flex-direction: column;
    justify-content: center;
    padding: 16px;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
}

.kpi::before {
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: var(--line-strong);
    content: "";
}

.kpi-featured::before {
    background: var(--yellow);
}

.kpi-warning::before {
    background: var(--amber);
}

.kpi-danger::before {
    background: var(--red);
}

.kpi > span:first-child {
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.kpi strong {
    display: block;
    min-width: 0;
    color: var(--ink);
    font-size: 23px;
    font-weight: 800;
    line-height: 1.08;
    overflow-wrap: anywhere;
}

.kpi small {
    margin-top: 7px;
    color: var(--muted);
    font-size: 10px;
}

.kpi-compact {
    min-height: 88px;
}

.kpi-compact strong {
    font-size: 18px;
}

.progress {
    display: block;
    width: 100%;
    height: 5px;
    margin-top: 12px;
    overflow: hidden;
    appearance: none;
    background: #e6e9eb;
    border: 0;
    border-radius: 2px;
}

.progress::-webkit-progress-bar {
    background: #e6e9eb;
    border-radius: 2px;
}

.progress::-webkit-progress-value {
    background: var(--yellow);
    border-radius: 2px;
    transition: width 300ms ease;
}

.progress::-moz-progress-bar {
    background: var(--yellow);
    border-radius: 2px;
}

.chart-grid {
    display: grid;
    gap: 12px;
}

.chart-grid-main {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.chart-grid-halves {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.chart-card,
.table-section,
.commission-scale,
.nomus-balance,
.freshness-panel,
.definition-panel,
.admin-section {
    min-width: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
}

.chart-card {
    min-height: 330px;
    padding: 16px;
}

.chart-card > header,
.table-section > header,
.freshness-panel > header,
.definition-panel > header,
.commission-scale > header {
    display: flex;
    min-height: 43px;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.chart-card > header > span {
    color: var(--muted);
    font-size: 11px;
}

.chart-wide {
    grid-column: span 2;
}

.chart-full {
    min-height: 420px;
    margin-bottom: 14px;
}

.chart-frame {
    position: relative;
    width: 100%;
    height: 248px;
}

.chart-frame-tall {
    height: 340px;
}

.year-comparison-card {
    margin-top: 12px;
}

.year-comparison-card > header {
    flex-wrap: wrap;
}

.year-comparison-summary {
    flex: 1 1 420px;
    max-width: min(620px, 62%);
    line-height: 1.5;
    text-align: right;
}

.year-comparison-chart-scroll,
.year-comparison-table-scroll {
    width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
}

.year-comparison-chart-scroll:focus-visible,
.year-comparison-table-scroll:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
}

.year-comparison-chart-frame {
    min-width: 720px;
    height: 290px;
}

.year-comparison-table-scroll {
    margin-top: 10px;
}

.year-comparison-table {
    min-width: 1460px;
    font-variant-numeric: tabular-nums;
}

.year-comparison-table caption {
    padding: 0 0 7px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    text-align: left;
    text-transform: uppercase;
}

.year-comparison-table th,
.year-comparison-table td {
    min-width: 108px;
    padding: 8px 9px;
    text-align: right;
}

.year-comparison-table th:first-child,
.year-comparison-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    min-width: 92px;
    text-align: left;
}

.year-comparison-table tbody th {
    color: var(--ink);
    background: var(--surface);
    font-size: 11px;
}

.year-comparison-table td.is-positive {
    color: #147342;
    font-weight: 800;
}

.year-comparison-table td.is-negative {
    color: #b42318;
    font-weight: 800;
}

.year-comparison-table td.is-neutral {
    color: var(--muted);
    font-weight: 700;
}

.year-comparison-table td.is-pending {
    color: var(--muted);
    background: var(--surface-alt);
    font-style: italic;
}

.year-comparison-empty {
    display: grid;
    min-height: 310px;
    margin: 0;
    place-items: center;
    color: var(--muted);
    text-align: center;
}

.chart-card canvas {
    max-width: 100%;
}

.goal-gauge {
    position: relative;
    width: min(230px, 100%);
    height: 240px;
    margin: 0 auto;
}

.goal-gauge > div {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    pointer-events: none;
}

.goal-gauge strong {
    font-size: 28px;
}

.goal-gauge span {
    color: var(--muted);
    font-size: 11px;
}

.table-section {
    padding: 16px;
}

.table-scroll {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

th,
td {
    padding: 11px 10px;
    border-bottom: 1px solid #e6e9eb;
    text-align: left;
    white-space: nowrap;
}

th {
    color: var(--muted);
    background: var(--surface-alt);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
}

tbody tr:last-child td {
    border-bottom: 0;
}

tbody tr:hover td {
    background: #fafbfb;
}

.rank-number {
    display: inline-grid;
    width: 24px;
    height: 24px;
    place-items: center;
    background: var(--surface-alt);
    border: 1px solid var(--line);
    border-radius: 50%;
    font-weight: 800;
}

.goal-inline {
    display: flex;
    min-width: 160px;
    align-items: center;
    gap: 8px;
}

.goal-inline .progress {
    margin: 0;
}

.goal-inline strong {
    min-width: 42px;
    font-size: 11px;
}

.split-lists {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.split-lists > section {
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
}

.split-lists ol {
    margin: 14px 0 0;
    padding: 0;
    list-style: none;
}

.split-lists li {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) auto;
    align-items: center;
    gap: 9px;
    padding: 9px 0;
    border-bottom: 1px solid #e9ecee;
}

.split-lists li:last-child {
    border-bottom: 0;
}

.split-lists li > span:nth-child(2) {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.list-index {
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
}

.goal-layout,
.quality-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(280px, 0.7fr);
    gap: 12px;
    margin-bottom: 14px;
}

.commission-scale {
    padding: 16px;
}

.scale-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 39px;
    padding: 7px 9px;
    border-bottom: 1px solid #e9ecee;
}

.scale-row:last-child {
    border-bottom: 0;
}

.scale-row.is-target {
    background: var(--amber-soft);
    border-left: 3px solid var(--yellow);
}

.context-banner,
.dashboard-error {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
    padding: 14px 16px;
    background: var(--blue-soft);
    border: 1px solid #bfd3df;
    border-left: 4px solid var(--blue);
    border-radius: 5px;
}

.context-banner > svg,
.dashboard-error > svg {
    width: 24px;
    height: 24px;
    flex: 0 0 auto;
    color: var(--blue);
}

.context-banner strong,
.context-banner p,
.dashboard-error strong,
.dashboard-error p {
    margin: 0;
}

.context-banner p,
.dashboard-error p {
    color: var(--ink-soft);
    font-size: 12px;
}

.nomus-balance {
    padding: 18px;
}

.finance-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) repeat(2, minmax(230px, 0.55fr));
    gap: 12px;
    margin-bottom: 14px;
}

.order-kind-summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) repeat(2, minmax(150px, 0.24fr));
    gap: 0;
    margin: 0 0 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
}

.order-kind-rule,
.order-kind-count {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 10px;
    padding: 13px 16px;
}

.order-kind-count {
    border-left: 1px solid var(--line);
}

.order-kind-rule > svg,
.order-kind-count > svg {
    width: 19px;
    height: 19px;
    flex: 0 0 auto;
    color: var(--green);
}

.order-kind-count > svg {
    color: var(--muted);
}

.order-kind-rule span,
.order-kind-count span {
    display: grid;
    min-width: 0;
    gap: 2px;
    color: var(--ink-soft);
    font-size: 11px;
}

.order-kind-rule strong,
.order-kind-count strong {
    color: var(--ink);
    font-size: 12px;
}

.order-kind-rule small {
    color: var(--muted);
    font-size: 10px;
}

.finance-layout .chart-card {
    min-height: 400px;
}

.finance-layout .nomus-balance {
    display: flex;
    min-height: 260px;
    align-items: flex-start;
    flex-direction: column;
}

.overdue-summary {
    display: flex;
    width: 100%;
    flex-direction: column;
    gap: 5px;
    margin: 34px 0 26px;
}

.overdue-summary > strong {
    color: var(--red);
    font-size: 29px;
    line-height: 1.1;
}

.overdue-summary > span {
    color: var(--muted);
    font-size: 12px;
}

.nomus-upcoming .overdue-summary > strong {
    color: var(--ink);
}

.source-note {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
}

.finance-card-footer {
    display: grid;
    width: 100%;
    gap: 10px;
    margin-top: auto;
}

.source-note svg {
    width: 15px;
    height: 15px;
}

.finance-layout .nomus-balance .button {
    width: 100%;
    margin-top: 0;
}

.finance-seller-table {
    margin-bottom: 14px;
}

.column-help {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    outline: none;
    cursor: help;
}

.column-help > svg {
    width: 14px;
    height: 14px;
    color: var(--muted);
}

.column-help [role="tooltip"] {
    position: absolute;
    z-index: 8;
    top: calc(100% + 9px);
    left: 50%;
    width: 245px;
    padding: 9px 10px;
    visibility: hidden;
    color: #fff;
    background: var(--ink);
    border-radius: 4px;
    box-shadow: 0 8px 24px rgba(15, 18, 20, 0.22);
    font-size: 11px;
    font-weight: 500;
    line-height: 1.4;
    text-align: left;
    text-transform: none;
    white-space: normal;
    overflow-wrap: break-word;
    opacity: 0;
    transform: translateX(-50%) translateY(-3px);
    transition: opacity 120ms ease, transform 120ms ease, visibility 120ms;
    pointer-events: none;
}

.column-help-end [role="tooltip"] {
    right: 0;
    left: auto;
    transform: translateY(-3px);
}

.column-help:hover [role="tooltip"],
.column-help:focus [role="tooltip"] {
    visibility: visible;
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.column-help-end:hover [role="tooltip"],
.column-help-end:focus [role="tooltip"] {
    transform: translateY(0);
}

.column-help:focus-visible {
    border-radius: 2px;
    outline: 2px solid var(--blue);
    outline-offset: 3px;
}

.finance-dialog {
    width: min(1180px, calc(100vw - 32px));
    max-width: none;
    max-height: min(760px, calc(100vh - 32px));
    padding: 0;
    overflow: hidden;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    box-shadow: 0 22px 65px rgba(10, 14, 16, 0.26);
}

.finance-dialog::backdrop {
    background: rgba(15, 18, 20, 0.58);
}

.finance-dialog > header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 20px 12px;
    border-bottom: 1px solid var(--line);
}

.finance-dialog .dialog-actions {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 8px;
}

.finance-dialog .dialog-summary {
    margin: 0;
    padding: 11px 20px;
    color: var(--muted);
    background: var(--surface-alt);
    border-bottom: 1px solid var(--line);
    font-size: 12px;
}

.finance-dialog .table-scroll {
    max-height: calc(100vh - 185px);
}

.finance-dialog th {
    position: sticky;
    z-index: 1;
    top: 0;
}

.finance-dialog td a {
    color: #155fc5;
    font-weight: 700;
}

.commission-seller-link {
    padding: 6px 0;
    border: 0;
    background: transparent;
    color: #155fc5;
    font: inherit;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.commission-seller-link:focus-visible { outline: 2px solid #155fc5; outline-offset: 4px; }
.commission-dialog[open] { display: flex; flex-direction: column; }
.commission-dialog > header, .commission-dialog > .dialog-summary { flex: 0 0 auto; }
.commission-dialog > header > div:first-child { min-width: 0; overflow-wrap: anywhere; }
.commission-dialog h2 { font-size: 22px; }
.commission-dialog .table-scroll { flex: 1 1 auto; min-height: 0; max-height: none; }
.commission-orders { min-width: 950px; width: 100%; table-layout: fixed; }
.commission-orders th:nth-child(1) { width: 12%; }
.commission-orders th:nth-child(2) { width: 10%; }
.commission-orders th:nth-child(3) { width: 22%; }
.commission-orders th:nth-child(4) { width: 15%; }
.commission-orders th:nth-child(5) { width: 25%; }
.commission-orders th:nth-child(6) { width: 16%; }
.commission-orders td, .commission-orders th { white-space: normal; overflow-wrap: anywhere; vertical-align: top; }
.commission-orders .commission-money { text-align: right; font-variant-numeric: tabular-nums; }
.commission-orders tfoot { font-weight: 800; background: var(--surface-alt); }
.commission-orders tfoot td { text-align: right; }
.commission-release + .commission-release { margin-top: 8px; }
.commission-release small { display: block; color: var(--muted); font-size: 12px; }
.own-commission-section { min-width: 0; }
.own-commission-section > header { flex-wrap: wrap; gap: 12px; }
.finance-permission-fields .field { margin-top: 10px; }

.balance-bar {
    width: 100%;
    height: 16px;
    margin: 18px 0 10px;
    overflow: hidden;
    background: var(--yellow);
    border-radius: 3px;
}

.balance-bar span {
    display: block;
    width: 0;
    height: 100%;
    background: var(--green);
}

.balance-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
}

.legend-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 5px;
    border-radius: 50%;
}

.legend-green { background: var(--green); }
.legend-yellow { background: var(--yellow); }

.freshness-panel,
.definition-panel {
    padding: 16px;
}

.source-row {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 13px 0;
    border-bottom: 1px solid #e7eaec;
}

.source-row:last-child {
    border-bottom: 0;
}

.source-row > span:nth-child(2) {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.source-row small {
    color: var(--muted);
}

.source-icon {
    display: inline-grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border-radius: 5px;
}

.source-icon svg {
    width: 19px;
}

.source-pipe {
    color: var(--blue);
    background: var(--blue-soft);
}

.source-nomus {
    color: #765d00;
    background: var(--amber-soft);
}

.status-ok {
    color: #176a45;
    background: var(--green-soft);
    border: 1px solid #b9dfcd;
}

.status-off {
    color: #953830;
    background: var(--red-soft);
    border: 1px solid #e8bbb6;
}

.queue-section {
    margin-top: 20px;
}

.queue-section > header {
    align-items: center;
}

.queue-live-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #667085;
    font-size: 13px;
    font-weight: 700;
}

.queue-live-label::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #a86418; flex-shrink: 0; }
.queue-live-label[data-active="1"]::before { background: #179b63; box-shadow: 0 0 0 3px rgba(23, 155, 99, 0.12); }
.queue-attempt-note, .queue-error-note { display: block; max-width: 420px; white-space: normal; overflow-wrap: anywhere; font-size: 11px; line-height: 1.5; margin-top: 4px; }
.queue-error-note { color: #a02025; }

.queue-duration {
    color: #344054;
    font-variant-numeric: tabular-nums;
    font-weight: 750;
}

.queue-status {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-width: 112px;
    font-size: 13px;
    font-weight: 800;
}

.queue-status svg {
    width: 18px;
    height: 18px;
}

.queue-status-pending {
    color: #8a6412;
}

.queue-status-processing {
    color: #236b95;
}

.queue-status-processing svg {
    animation: queue-spin 1s linear infinite;
}

.queue-status-done {
    color: #087443;
}

.queue-status-failed {
    color: #b42318;
}

.queue-status-cancelled {
    color: #667085;
}

.queue-action-heading,
.queue-cancel-cell {
    width: 64px;
    text-align: center;
}

.queue-cancel-form {
    display: inline-flex;
    margin: 0;
}

.queue-cancel-button {
    color: #b42318;
    border-color: #e8bbb6;
    background: var(--red-soft);
}

.queue-cancel-button:hover {
    color: #7a271a;
    border-color: #d98f87;
    background: #fbe3e0;
}

@keyframes queue-spin {
    to { transform: rotate(360deg); }
}

.definition-panel dl {
    margin: 0;
}

.definition-panel dl > div {
    padding: 11px 0;
    border-bottom: 1px solid #e7eaec;
}

.definition-panel dl > div:last-child {
    border-bottom: 0;
}

.definition-panel dt {
    margin-bottom: 3px;
    font-weight: 800;
}

.definition-panel dd {
    margin: 0;
    color: var(--ink-soft);
    font-size: 12px;
}

.loading-state {
    display: flex;
    min-height: calc(100vh - var(--topbar-height) - 48px);
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 12px;
    color: var(--muted);
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--line);
    border-top-color: var(--yellow-dark);
    border-radius: 50%;
    animation: spin 700ms linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.dashboard-error {
    background: var(--red-soft);
    border-color: #e3b2ad;
    border-left-color: var(--red);
}

.dashboard-error > svg {
    color: var(--red);
}

.dashboard-error .button {
    margin-left: auto;
}

.button {
    display: inline-flex;
    min-height: 38px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 13px;
    border: 1px solid transparent;
    border-radius: 5px;
    font-weight: 750;
}

.button-primary {
    color: var(--ink);
    background: var(--yellow);
    border-color: var(--yellow-dark);
}

.button-primary:hover {
    background: #ffd322;
}

.button-secondary {
    color: var(--ink);
    background: var(--surface);
    border-color: var(--line-strong);
}

.button-secondary:hover {
    background: var(--surface-alt);
}

.button-wide {
    width: 100%;
}

.alert {
    margin-bottom: 16px;
    padding: 11px 13px;
    border-radius: 5px;
    font-size: 12px;
}

.alert-error {
    color: #812f29;
    background: var(--red-soft);
    border: 1px solid #e4b8b3;
}

.alert-success {
    color: #176a45;
    background: var(--green-soft);
    border: 1px solid #b9dfcd;
}

.login-body {
    min-height: 100vh;
    color: #fff;
    background: var(--sidebar);
}

.login-layout {
    display: grid;
    min-height: 100vh;
    grid-template-columns: minmax(320px, 0.9fr) minmax(420px, 1.1fr);
}

.login-identity {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 24px;
    overflow: hidden;
    background: #121416;
    border-right: 1px solid #303538;
}

.brand-login .brand-symbol {
    width: 58px;
    height: 58px;
    font-size: 38px;
}

.brand-login .brand-copy strong {
    font-size: 34px;
}

.brand-login .brand-copy small {
    font-size: 11px;
}

.login-identity > p {
    color: #8d969b;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.login-signal {
    display: flex;
    width: 240px;
    height: 78px;
    align-items: flex-end;
    justify-content: center;
    gap: 12px;
}

.login-signal span {
    width: 28px;
    background: var(--yellow);
    border-radius: 3px 3px 0 0;
}

.login-signal span:nth-child(1) { height: 24%; background: #586167; }
.login-signal span:nth-child(2) { height: 42%; background: var(--blue); }
.login-signal span:nth-child(3) { height: 65%; }
.login-signal span:nth-child(4) { height: 88%; background: var(--green); }
.login-signal span:nth-child(5) { height: 54%; background: #9ea6aa; }

.login-form-panel,
.password-layout {
    display: grid;
    place-items: center;
    padding: 32px;
    color: var(--ink);
    background: var(--canvas);
}

.login-form {
    width: min(420px, 100%);
    padding: 30px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
    box-shadow: var(--shadow);
}

.hp-field {
    position: absolute !important;
    left: -10000px !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
}

.login-form header {
    margin-bottom: 22px;
}

.login-form header h1 {
    margin-bottom: 8px;
    font-size: 28px;
}

.login-form header > p:last-child {
    margin-bottom: 0;
    color: var(--muted);
}

.login-form .field {
    margin-bottom: 15px;
}

.ownership-mark {
    display: block;
    margin-top: 20px;
    padding-top: 14px;
    color: #879096;
    border-top: 1px solid var(--line);
    font-size: 10px;
    font-weight: 700;
    line-height: 1.5;
    text-align: center;
}

.ownership-mark span {
    display: block;
    color: #a0a7ab;
    font-weight: 500;
}

.ownership-mark-app {
    margin: 0 28px 18px;
    padding-top: 0;
    border-top: 0;
    text-align: right;
}

.input-with-icon,
.input-action,
.currency-input {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-icon > svg {
    position: absolute;
    left: 11px;
    z-index: 1;
    width: 17px;
    color: var(--muted);
    pointer-events: none;
}

.input-with-icon input {
    padding-left: 38px;
    padding-right: 44px;
}

.input-with-icon .password-toggle,
.input-action .icon-button {
    position: absolute;
    right: 2px;
    width: 34px;
    height: 34px;
    border: 0;
}

.password-layout {
    min-height: 100vh;
}

.password-form {
    color: var(--ink);
}

.admin-shell {
    min-height: 100vh;
    margin-left: var(--sidebar-width);
}

.admin-topbar {
    display: flex;
    min-height: 82px;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 14px 26px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.admin-user {
    display: flex;
    align-items: center;
    gap: 9px;
}

.admin-user small,
.table-user small {
    color: var(--muted);
}

.admin-main {
    max-width: 1380px;
    margin: 0 auto;
    padding: 26px;
}

.admin-section {
    padding: 18px;
}

.narrow-section {
    max-width: 680px;
}

.table-user {
    display: flex;
    align-items: center;
    gap: 9px;
}

.table-user .user-avatar {
    width: 30px;
    height: 30px;
    font-size: 11px;
}

.align-right {
    text-align: right;
}

.row-actions {
    display: inline-flex;
    gap: 5px;
}

.inline-form select {
    min-width: 130px;
    min-height: 32px;
    padding: 5px 8px;
    font-size: 11px;
}

.pending-label {
    display: block;
    margin-top: 3px;
    color: var(--amber);
    font-size: 9px;
}

.app-dialog {
    width: min(520px, calc(100vw - 32px));
    padding: 0;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    box-shadow: 0 22px 70px rgba(16, 20, 22, 0.28);
}

.app-dialog::backdrop {
    background: rgba(17, 20, 22, 0.62);
}

.app-dialog form > header,
.app-dialog form > footer {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 18px;
}

.app-dialog form > header {
    border-bottom: 1px solid var(--line);
}

.app-dialog form > header p:last-child {
    margin: 4px 0 0;
    color: var(--muted);
}

.app-dialog form > footer {
    justify-content: flex-end;
    border-top: 1px solid var(--line);
}

.dialog-fields {
    display: grid;
    gap: 14px;
    padding: 18px;
}

.permission-fieldset {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.permission-fieldset legend {
    margin-bottom: 3px;
    color: var(--ink);
    font-size: 14px;
    font-weight: 800;
}

.permission-fieldset > p {
    margin: 0 0 12px;
    color: var(--muted);
    font-size: 12px;
}

.permission-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.permission-option {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    align-items: start;
    gap: 9px;
    min-width: 0;
    padding: 11px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--surface-alt);
    cursor: pointer;
}

.permission-option input {
    width: 16px;
    height: 16px;
    min-height: 16px;
    margin: 2px 0 0;
    accent-color: var(--ink);
}

.permission-option span {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 2px;
}

.permission-option strong,
.permission-option small {
    overflow-wrap: anywhere;
}

.permission-option small {
    color: var(--muted);
    line-height: 1.35;
}

.access-summary {
    display: flex;
    min-width: 150px;
    max-width: 270px;
    flex-wrap: wrap;
    gap: 4px;
}

.access-summary > span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 6px;
    color: #42474d;
    background: #eef0f2;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
}

.access-summary .access-total {
    color: #146c43;
    background: #e5f5ec;
}

.access-summary svg {
    width: 14px;
    height: 14px;
}

.settings-form {
    max-width: 480px;
}

.admin-settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.settings-panel {
    min-width: 0;
}

.settings-form .field {
    margin-bottom: 10px;
}

.settings-form > p {
    color: var(--ink-soft);
    font-size: 12px;
}

.seller-goal-fields {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(150px, 0.75fr);
    gap: 10px;
}

.seller-directory {
    margin-top: 16px;
}

.seller-directory .section-heading > div > p:last-child {
    max-width: 660px;
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 11px;
}

.seller-avatar {
    color: #171a1c;
    background: var(--yellow);
}

.mapping-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--ink-soft);
    font-size: 11px;
    font-weight: 700;
}

.mapping-badge svg {
    width: 14px;
    height: 14px;
}

.muted-copy,
.empty-state-inline {
    color: var(--muted);
    font-size: 11px;
}

.empty-state-inline {
    margin: 4px 0 0;
}

.seller-table th:nth-child(2) {
    min-width: 145px;
}

.seller-table th:nth-child(3) {
    min-width: 150px;
}

.currency-input > span {
    display: grid;
    align-self: stretch;
    padding: 0 11px;
    place-items: center;
    color: var(--ink-soft);
    background: var(--surface-alt);
    border: 1px solid var(--line-strong);
    border-right: 0;
    border-radius: 5px 0 0 5px;
    font-weight: 750;
}

.currency-input input {
    border-radius: 0 5px 5px 0;
}

.refresh-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.source-monitor { margin-bottom: 24px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.monitor-clock { display: grid; gap: 4px; text-align: right; color: var(--muted); font-size: 12px; }
.source-monitor-table { table-layout: fixed; min-width: 920px; }
.source-monitor-table th:nth-child(1) { width: 21%; }
.source-monitor-table th:nth-child(2) { width: 27%; }
.source-monitor-table th:nth-child(3) { width: 19%; }
.source-monitor-table th:nth-child(4) { width: 17%; }
.source-monitor-table th:nth-child(5) { width: 16%; }
.source-monitor-table td { vertical-align: top; white-space: normal; overflow-wrap: anywhere; }
.source-monitor-table small { display: block; margin-top: 5px; font-size: 12px; line-height: 1.5; color: var(--muted); }
.source-monitor-table small:empty { display: none; }
.source-monitor-table .queue-status { min-width: 0; }
.source-monitor-table .queue-error-note, .monitor-status-failed { color: #b42318; }
.monitor-status-done { color: #087443; }
.monitor-status-processing { color: #236b95; }
.monitor-status-pending, .monitor-status-warning { color: #8a6412; }
.monitor-status-off { color: #667085; }
@media (max-width: 700px) {
    .source-monitor .section-heading { flex-direction: column; }
    .monitor-clock { text-align: left; }
    .source-monitor .table-scroll { overflow: visible; }
    .source-monitor-table { min-width: 0; table-layout: auto; }
    .source-monitor-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
    .source-monitor-table tbody, .source-monitor-table tr { display: block; }
    .source-monitor-table tr { padding: 12px 0; border-bottom: 1px solid var(--line); }
    .source-monitor-table td { display: block; width: auto; padding: 6px 0; border: 0; }
    .source-monitor-table td::before { content: attr(data-label); display: block; margin-bottom: 3px; color: var(--muted); font-size: 11px; font-weight: 750; }
    .source-monitor-table td:first-child::before { display: none; }
    .queue-live-label { white-space: normal; }
}

.source-panel {
    background: var(--surface-alt);
    border: 1px solid var(--line);
    border-radius: 5px;
    overflow: hidden;
}

.source-refresh-row {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 14px;
}

.source-refresh-row p,
.credential-form > p {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 11px;
}

.credential-form {
    padding: 13px 14px 14px;
    background: var(--surface);
    border-top: 1px solid var(--line);
}

.credential-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.credential-heading label {
    color: var(--ink-soft);
    font-size: 11px;
    font-weight: 800;
}

.credential-input-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
}

.credential-input-row .input-with-icon {
    min-width: 0;
}

.empty-cell {
    padding: 30px;
    color: var(--muted);
    text-align: center;
}

.mobile-nav,
.admin-mobile-nav,
.sidebar-backdrop {
    display: none;
}

@media (max-width: 1280px) {
    .topbar {
        grid-template-columns: auto 1fr auto;
    }
    .sync-chip {
        display: none;
    }
    .kpi-grid-primary {
        grid-template-columns: repeat(4, minmax(140px, 1fr));
    }
    .kpi-grid-quality,
    .kpi-grid-nomus {
        grid-template-columns: repeat(3, minmax(150px, 1fr));
    }
}

@media (max-width: 1040px) {
    :root { --sidebar-width: 210px; }
    .topbar {
        grid-template-columns: auto 1fr;
    }
    .topbar-actions { display: none; }
    .chart-grid-main { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .chart-wide { grid-column: span 2; }
    .goal-layout,
    .quality-layout,
    .finance-layout,
    .order-kind-summary { grid-template-columns: 1fr; }
    .order-kind-count { border-top: 1px solid var(--line); border-left: 0; }
    .admin-settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
    :root { --topbar-height: auto; }
    .sidebar {
        width: min(280px, 86vw);
        transform: translateX(-102%);
        transition: transform 180ms ease;
    }
    .sidebar.is-open { transform: translateX(0); }
    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 35;
        display: block;
        background: rgba(15, 18, 20, 0.58);
    }
    .app-shell,
    .admin-shell { margin-left: 0; }
    .topbar {
        position: static;
        display: flex;
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
        padding: 14px 16px;
    }
    .topbar .sidebar-toggle { display: inline-grid; }
    .global-filters {
        width: 100%;
        grid-template-columns: minmax(260px, 1.5fr) minmax(150px, 1fr) 36px;
    }
    .dashboard-main,
    .admin-main { padding: 16px; }
    .kpi-grid-primary,
    .kpi-grid-small,
    .kpi-grid-quality,
    .kpi-grid-nomus { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .chart-grid-main,
    .chart-grid-halves { grid-template-columns: 1fr; }
    .chart-wide { grid-column: span 1; }
    .split-lists { grid-template-columns: 1fr; }
    .mobile-nav {
        position: fixed;
        inset: auto 0 0 0;
        z-index: 32;
        display: grid;
        height: 62px;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        background: var(--surface);
        border-top: 1px solid var(--line);
        box-shadow: 0 -7px 22px rgba(24, 29, 32, 0.08);
    }
    .mobile-nav-cols-1 { grid-template-columns: minmax(0, 1fr); }
    .mobile-nav-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .mobile-nav-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .mobile-nav-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .mobile-nav-cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
    .mobile-nav-cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
    .mobile-nav-cols-7 { grid-template-columns: repeat(7, minmax(0, 1fr)); }
    .mobile-nav button {
        display: flex;
        min-width: 0;
        align-items: center;
        justify-content: center;
        flex-direction: column;
        gap: 3px;
        padding: 5px 2px;
        color: var(--muted);
        background: transparent;
        border: 0;
        border-top: 3px solid transparent;
        font-size: 9px;
    }
    .mobile-nav button.is-active {
        color: var(--ink);
        border-top-color: var(--yellow);
    }
    .mobile-nav svg { width: 18px; height: 18px; }
    .dashboard-main { padding-bottom: 78px; }
    .admin-sidebar { transform: none; }
    .admin-body .admin-sidebar { display: none; }
    .admin-topbar { padding: 14px 16px; }
    .admin-mobile-nav {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        border-bottom: 1px solid var(--line);
        background: var(--surface);
    }
    .admin-mobile-nav a {
        display: flex;
        min-height: 54px;
        align-items: center;
        justify-content: center;
        gap: 6px;
        color: var(--muted);
        border-bottom: 3px solid transparent;
        font-size: 11px;
        font-weight: 700;
        text-decoration: none;
    }
    .admin-mobile-nav a.is-active {
        color: var(--ink);
        border-bottom-color: var(--yellow);
    }
    .admin-mobile-nav svg { width: 16px; height: 16px; }
    .refresh-actions { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
    h1 { font-size: 19px; }
    h2 { font-size: 21px; }
    .global-filters {
        grid-template-columns: minmax(0, 1fr) 36px;
    }
    .global-filters > label,
    .global-filters > .seller-filter {
        grid-column: 1;
        grid-row: 2;
    }
    .filter-reset {
        grid-column: 2;
        grid-row: 1 / span 2;
        align-self: center;
    }
    .period-picker {
        position: fixed;
        inset: 12px 12px auto;
        width: auto;
        max-height: calc(100vh - 24px);
        overflow: auto;
    }
    .period-calendars { grid-template-columns: 1fr; }
    .calendar-panel + .calendar-panel { display: none; }
    .section-heading { align-items: flex-start; flex-direction: column; }
    .section-heading-actions { justify-content: flex-start; width: 100%; }
    .kpi-grid-primary,
    .kpi-grid-small,
    .kpi-grid-quality,
    .kpi-grid-nomus { grid-template-columns: 1fr 1fr; }
    .kpi { min-height: 104px; padding: 13px; }
    .kpi strong { font-size: 19px; }
    .kpi-grid-nomus .kpi strong { font-size: 17px; }
    .kpi-compact { min-height: 84px; }
    .chart-card { min-height: 310px; padding: 13px; }
    .chart-frame { height: 235px; }
    .chart-frame-tall { height: 310px; }
    .year-comparison-summary {
        flex-basis: 100%;
        max-width: 100%;
        text-align: left;
    }
    .login-layout { grid-template-columns: 1fr; }
    .login-identity { min-height: 210px; border-right: 0; border-bottom: 1px solid #303538; }
    .login-signal { display: none; }
    .brand-login .brand-symbol { width: 48px; height: 48px; font-size: 31px; }
    .brand-login .brand-copy strong { font-size: 28px; }
    .login-identity > p { margin-bottom: 0; }
    .login-form-panel { padding: 18px 14px 28px; }
    .login-form { padding: 22px 18px; }
    .admin-user { display: none; }
    .seller-goal-fields { grid-template-columns: 1fr; }
    .seller-directory .section-heading .button { width: 100%; }
    .seller-directory .table-scroll { overflow: visible; }
    .seller-table,
    .seller-table tbody,
    .seller-table tr,
    .seller-table td { display: block; width: 100%; }
    .seller-table thead { display: none; }
    .seller-table tr {
        position: relative;
        padding: 12px 46px 12px 0;
        border-bottom: 1px solid var(--line);
    }
    .seller-table tr:last-child { border-bottom: 0; }
    .seller-table td {
        padding: 4px 0;
        border: 0;
        text-align: left;
    }
    .seller-table td:first-child { padding-bottom: 8px; }
    .seller-table td[data-label]::before {
        display: block;
        margin-bottom: 2px;
        color: var(--muted);
        content: attr(data-label);
        font-size: 9px;
        font-weight: 800;
        text-transform: uppercase;
    }
    .seller-table td:last-child {
        position: absolute;
        top: 12px;
        right: 0;
        width: auto;
    }
    .source-refresh-row { grid-template-columns: 38px minmax(0, 1fr); }
    .source-refresh-row .button { grid-column: 1 / -1; }
    .credential-input-row { grid-template-columns: 1fr; }
    .credential-input-row .button { width: 100%; }
    .finance-dialog {
        width: calc(100vw - 16px);
        max-height: calc(100vh - 16px);
    }
    .finance-dialog > header { padding: 14px; }
    .finance-dialog .dialog-summary { padding: 10px 14px; }
}

@media (max-width: 420px) {
    .kpi-grid-primary,
    .kpi-grid-small,
    .kpi-grid-quality,
    .kpi-grid-nomus { grid-template-columns: 1fr; }
    .kpi { min-height: 90px; }
    .kpi-grid-nomus .kpi strong { font-size: 19px; }
    .balance-legend { flex-direction: column; gap: 5px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@media print {
    @page {
        size: landscape;
        margin: 12mm;
    }

    body.finance-print-active {
        min-width: 0;
        color: #111;
        background: #fff;
    }

    body.finance-print-active > * {
        display: none !important;
    }

    body.finance-print-active > .finance-dialog.is-print-target {
        position: static !important;
        inset: auto !important;
        display: block !important;
        width: 100% !important;
        max-width: none !important;
        max-height: none !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: visible !important;
        color: #111 !important;
        background: #fff !important;
        border: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
    }

    .finance-dialog.is-print-target::backdrop {
        display: none;
    }

    .finance-dialog.is-print-target > header {
        display: block;
        padding: 0 0 5mm;
        border-bottom: 2px solid #111;
    }

    .finance-dialog.is-print-target > header .eyebrow,
    .finance-dialog.is-print-target .dialog-actions {
        display: none !important;
    }

    .finance-dialog.is-print-target > header h2 {
        margin: 0;
        color: #111;
        font-size: 18pt;
    }

    .finance-dialog.is-print-target .dialog-summary {
        margin: 0;
        padding: 4mm 0;
        color: #333;
        background: #fff;
        border-bottom: 1px solid #777;
        font-size: 10pt;
    }

    .finance-dialog.is-print-target .table-scroll {
        max-height: none;
        overflow: visible;
    }

    .finance-dialog.is-print-target table {
        width: 100%;
        color: #111;
        border-collapse: collapse;
        font-size: 8.5pt;
    }

    .finance-dialog.is-print-target .commission-orders { min-width: 0; }
    .finance-dialog.is-print-target .commission-release small { font-size: 8pt; color: #333; }
    .finance-dialog.is-print-target .commission-orders tfoot { display: table-row-group; }

    .finance-dialog.is-print-target thead {
        display: table-header-group;
    }

    .finance-dialog.is-print-target tr {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .finance-dialog.is-print-target th {
        position: static;
        padding: 3mm 2mm;
        color: #111;
        background: #e9ecef !important;
        border-bottom: 1px solid #777;
        print-color-adjust: exact;
    }

    .finance-dialog.is-print-target td {
        padding: 2.5mm 2mm;
        border-bottom: 1px solid #ccc;
    }

    .finance-dialog.is-print-target td a {
        color: #111;
        text-decoration: none;
    }
}
.commission-base { display: block; margin-top: 6px; font-size: 11px; white-space: normal; color: var(--muted, #57636b); }
.commission-scale summary { cursor: pointer; font-weight: 700; margin: 12px 0; font-size: 13px; }
.commission-scale .scale-row { gap: 12px; }

.production-heading-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
.production-import-dialog { width: min(840px, calc(100vw - 24px)); }
.production-import-dialog > header, .production-import-dialog > footer { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 18px; }
.production-import-dialog > header { border-bottom: 1px solid var(--line); }
.production-import-dialog > footer { justify-content: flex-end; border-top: 1px solid var(--line); }
.production-import-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.production-import-card { display: flex; flex-direction: column; gap: 14px; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-soft, #f7f8f8); }
.production-import-card h3 { margin: 0 0 6px; font-size: 16px; }
.production-import-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.production-export-modes { display: flex; flex-wrap: wrap; gap: 10px 18px; margin: 0; padding: 0; border: 0; }
.production-export-modes legend { width: 100%; margin-bottom: 4px; font-size: 12px; font-weight: 800; }
.production-export-modes label { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 700; }
.production-import-card .button { align-self: flex-start; margin-top: auto; }
#production-import-result { grid-column: 1 / -1; }
#production-import-result details { margin: 12px 0; padding: 12px; border: 1px solid var(--line); border-radius: 8px; }
#production-import-result summary { cursor: pointer; font-weight: 600; }
#production-import-result details p { white-space: pre-wrap; overflow-wrap: anywhere; }
#production-import-result details label { display: flex; align-items: flex-start; gap: 8px; margin-top: 12px; }
#production-import-result input[type="checkbox"] { width: 18px; height: 18px; flex: 0 0 18px; }
/* Let header groups wrap instead of overflowing their grid tracks. */
@media (min-width: 821px) {
    .topbar { display: flex; flex-flow: row wrap; }
    .topbar-title { flex: 0 1 auto; min-width: 0; }
    .topbar .global-filters {
        flex: 1 1 470px;
        min-width: 0;
        grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) 36px;
    }
    .topbar .topbar-actions { display: flex; flex: 0 1 auto; margin-left: auto; }
}
/* Shared depth, deliberately low specificity: module status highlights win. */
@media screen {
    :where(.app-body, .admin-body) :where(button, .button, [role="button"], input[type="submit"], input[type="button"]):not(:where(.sidebar *)) {
        box-shadow: 2px 3px 6px #00000018, -1px -1px 3px #ffffff70, inset 1px 1px 0 #ffffff38, inset -1px -1px 1px #00000012;
    }
    :where(.app-body, .admin-body) :where(button, .button, [role="button"], input[type="submit"], input[type="button"]):not(:where(.sidebar *, :disabled, [aria-disabled="true"])):where(:hover, :focus-visible) {
        box-shadow: inset 3px 3px 6px #00000024, inset -2px -2px 5px #ffffff55;
    }
    :where(.app-body, .admin-body) :where(button, .button, [role="button"], input[type="submit"], input[type="button"]):not(:where(.sidebar *, :disabled, [aria-disabled="true"])):where(:active) {
        box-shadow: inset 4px 4px 7px #00000030, inset -2px -2px 4px #ffffff40;
    }
    :where(.app-body, .admin-body) :where(button, .button, [role="button"], input[type="submit"], input[type="button"]):not(:where(.sidebar *)):where(:disabled, [aria-disabled="true"]) {
        box-shadow: none;
    }
}
@media (max-width: 760px) {
    .production-heading-actions { justify-content: flex-start; width: 100%; }
    .production-heading-actions .button { flex: 1 1 170px; }
    .production-import-options { grid-template-columns: 1fr; }
}
