:root {
  font: 15px/1.42 "Segoe UI", Arial, sans-serif;
  --ink: #182c41; --muted: #526779; --line: #d8e2e9; --paper: #fff;
  --blue: #135d91; --blue-light: #e9f4fb; --plum: var(--blue);
  color: var(--ink); background: #f1f5f8;
}
.frame { width: min(95.8%, calc(30% + 952px)); }
body[data-width=standard] .frame { width: min(94%, 1360px); }
body[data-width=max] .frame { width: calc(100% - 16px); }
button, select { min-height: 34px; border-color: #c9d5df; font: inherit; }
button:hover:not(:disabled), select:hover { background: #edf5fa; border-color: #90aec2; }
:focus-visible { outline: 2px solid #157ac0; outline-offset: 2px; }
input[type=checkbox], input[type=radio] { accent-color: var(--blue); }
input[type=search], input[type=month], .stack input { min-width: 0; padding: 6px 9px; border: 1px solid #c5d2dc; border-radius: 6px; background: white; color: var(--ink); font: inherit; }
.icon-library { position:absolute; width:0; height:0; overflow:hidden; }
.icon { width:17px; height:17px; flex:none; fill:none; stroke:currentColor; stroke-width:1.6; stroke-linecap:round; stroke-linejoin:round; }
.chevron { width:6px; height:6px; flex:none; margin:0 2px 3px; border:solid currentColor; border-width:0 1.5px 1.5px 0; transform:rotate(45deg); }

.report-bar { background:#173954; color:#fff; }
.bar-inner, .identity, .sync-actions, .period-mode, .issue-tools, .display-tools { display:flex; align-items:center; }
.bar-inner { min-height:40px; justify-content:space-between; gap:12px; }
.identity,.sync-actions { gap:15px; }
.identity .brand { font:italic bold 24px/1 Georgia,serif; letter-spacing:-.07em; white-space:nowrap; }
.area-name { padding-left:14px; border-left:1px solid #648094; font-size:13px; }
.sync-actions { font-size:12px; }
#stamp { color:#c4d6e2; font-variant-numeric:tabular-nums; }
#refresh,.settings-link { color:white; }
#refresh { display:flex; align-items:center; gap:6px; padding:3px 8px; min-height:29px; background:transparent; border:1px solid #698398; font-size:12px; }
#refresh:hover:not(:disabled) { background:#28516c; }
.settings-link { text-underline-offset:3px; }
main.frame { padding-top:10px; }
.visually-hidden { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }
.period-mode { gap:10px; min-width:0; }
#open-calendar,.tool-button { display:inline-flex; align-items:center; justify-content:center; gap:7px; padding:4px 10px; font-size:13px; white-space:nowrap; }
#open-calendar { min-width:0; min-height:32px; padding:4px 6px; color:var(--blue); background:transparent; border:0; font-weight:600; }
#open-calendar:hover:not(:disabled) { background:var(--blue-light); }
#period-label { overflow:hidden; text-overflow:ellipsis; }
#status { color:var(--muted); }
#status:not(:empty) { padding:6px 0; }
.totals { display:flex; margin:0 0 10px; border:1px solid var(--line); border-radius:9px; background:white; }
.totals>div { flex:1; min-width:0; padding:7px 16px 8px; color:var(--muted); font-size:12px; }
.totals>div+div { border-left:1px solid var(--line); }
.totals strong { display:block; margin-top:1px; color:var(--ink); font-size:clamp(18px,1.6vw,24px); font-weight:650; line-height:1.16; letter-spacing:-.025em; font-variant-numeric:tabular-nums; }
#amount { color:#105985; }
.results.matrix { overflow:clip; }
.table-toolbar { display:flex; align-items:center; flex-wrap:wrap; gap:6px 12px; padding:8px 12px; }
.tabs,.segments { display:inline-flex; gap:2px; padding:2px; background:#ecf1f5; border-radius:7px; }
.tabs button { border:1px solid transparent; padding:4px 10px; min-height:29px; color:var(--muted); background:transparent; font-weight:600; font-size:13px; white-space:nowrap; }
.tabs button[aria-pressed=true] { color:#135886; background:#fff; border-color:#c6d9e6; box-shadow:0 1px 2px #17395312; }
.issue-tools,.display-tools { gap:6px; flex-wrap:wrap; }
.display-tools { margin-left:auto; }
.tool-button { min-height:32px; background:white; }
.tool-button .icon,.issue-filter .icon { color:var(--blue); }
#selected-count { padding:0 4px; border-radius:4px; background:#eff4f7; font-size:12px; color:var(--muted); }
.issue-filter { position:relative; display:flex; align-items:center; }
.issue-filter .icon { position:absolute; left:8px; pointer-events:none; width:15px; }
#issue-column-search { width:105px; height:32px; padding:4px 7px 4px 28px; font-size:13px; }
#toggle-issue-statistics[aria-pressed=true] { background:var(--blue-light); border-color:#a8cbe1; color:var(--blue); }
.shade-option { display:inline-flex; align-items:center; gap:6px; min-height:32px; cursor:pointer; padding:4px 8px; border:1px solid var(--line); border-radius:6px; color:var(--ink); font-size:13px; white-space:nowrap; }
.shade-option:has(:checked) { background:#fff5f5; border-color:#e5b9bd; color:#8a2539; }
.shade-option input { appearance:none; display:grid; place-content:center; width:14px; height:14px; margin:0; border:1.5px solid #ad3448; border-radius:3px; }
.shade-option input:checked { background:#ad3448; }
.shade-option input:checked::after { content:""; width:6px; height:3px; border:solid white; border-width:0 0 2px 2px; transform:translateY(-1px) rotate(-45deg); }
.matrix-note { padding:0 12px 7px; color:var(--muted); font-size:13px; }

.report-popover { position:fixed; inset:auto; margin:0; width:min(346px,calc(100% - 16px)); max-height:80dvh; overflow-y:auto; padding:14px 16px 16px; background:white; color:var(--ink); border:1px solid #c3d3df; border-radius:10px; box-shadow:0 8px 32px #16344930; }
.panel-title,.dialog-title { display:flex; gap:12px; align-items:center; justify-content:space-between; }
.panel-title h2,.dialog-title h2 { font:650 18px/1.25 "Segoe UI",Arial,sans-serif; letter-spacing:-.025em; }
.panel-title button,.dialog-title button { min-width:30px; min-height:30px; padding:0; color:var(--muted); font-size:21px; }
.report-popover fieldset { border:0; padding:0; margin:12px 0 0; }
.report-popover legend { padding:0; margin-bottom:4px; color:var(--muted); font-size:13px; font-weight:600; }
.segments,.metric-controls { display:flex; }
.segments label { flex:1; position:relative; }
.segments input { position:absolute; opacity:0; width:1px; height:1px; }
.segments span { display:grid; place-items:center; min-height:32px; padding:3px 5px; border:1px solid transparent; border-radius:5px; cursor:pointer; text-align:center; font-size:13px; }
.segments input:checked+span { background:white; border-color:#b7cedd; color:#095789; font-weight:600; }
.segments input:focus-visible+span { outline:2px solid #157ac0; outline-offset:0; }
.sort-choices label,.order-filter { display:flex; align-items:center; gap:8px; min-height:33px; cursor:pointer; }
.sort-choices label { border-radius:5px; padding:2px 6px; }
.sort-choices label:hover,.sort-choices label:has(:checked) { background:var(--blue-light); }
.sort-choices input,.order-filter input { margin:0; width:16px; height:16px; }
.order-filter { margin-top:14px; border-top:1px solid var(--line); padding-top:10px; font-size:14px; }
.metric-controls { gap:5px; }
.metric-controls button { flex:1; min-height:32px; padding:3px 6px; font-size:13px; }
.metric-controls button[aria-pressed=true] { color:var(--blue); background:var(--blue-light); border-color:#a8cbe1; }
.metric-controls button[aria-pressed=true]::before { content:"✓ "; }
.hide-orders [data-metric=orders],.hide-units [data-metric=units],.hide-amount [data-metric=amount],.names-only #matrix :is(td,th):not(:first-child),.names-only .card-totals { display:none!important; }

.matrix-window { position:relative; display:flow-root; }
#partner-scroll { max-height:max(50dvh,calc(100dvh - 236px)); overflow:auto; }
#partner-scroll::-webkit-scrollbar { height:0; width:10px; }
#partner-scroll::-webkit-scrollbar:horizontal { display:none; }
#partner-scroll::-webkit-scrollbar-thumb:vertical { border:2px solid transparent; border-radius:8px; background:#a8b6c2; background-clip:padding-box; }
#matrix { table-layout:auto; width:max-content; }
#matrix thead { position:sticky; top:0; z-index:2; }
#matrix th,#matrix td { width:auto; padding:7px 9px; text-align:right; font-size:14px; line-height:1.32; white-space:nowrap; font-variant-numeric:tabular-nums; border-bottom:1px solid #e1e8ee; }
#matrix th { white-space:normal; color:#435a6a; max-width:155px; background:#eef4f8; font-weight:600; }
#matrix th:first-child,#matrix td:first-child { position:sticky; left:0; text-align:left; width:250px; min-width:190px; max-width:280px; background:white; z-index:1; box-shadow:1px 0 #dce5ec; white-space:normal; }
#matrix th#partner-heading { background:#eef4f8; z-index:3; padding:4px 8px; }
#matrix .period-cell,#matrix th:nth-child(2) { border-right:2px solid #d6e2eb; }
#matrix .without-company > :is(td:first-child,.period-cell) { background-color:#fff9e5; }
#matrix #issue-statistics > * { background-color:#f4f8fb; font-size:13px; }
#issue-statistics [data-metric] { display:block; }
.issue-statistics-label { display:flex; flex-wrap:wrap; align-items:center; gap:2px 8px; }
#hide-issue-statistics { min-height:28px; padding:2px 6px; background:transparent; color:var(--blue); font-size:12px; }
.names-only #issue-statistics { display:none; }
#matrix .issue-title { display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:3; overflow:hidden; width:max-content; max-width:13ch; margin-left:auto; overflow-wrap:anywhere; }
#matrix .month-cell,#matrix .issue-cell { min-width:74px; }
#matrix .issue-cell,#matrix th:has(.issue-title,.issue-cover) { padding-inline:6px; }
#partner-scroll tbody tr:hover td { background-image:linear-gradient(#17659412,#17659412); }
#matrix td.active-column { box-shadow:inset 0 0 0 999px #296e9815; }
#matrix th.active-column { background:#dfedf6; color:#204e6d; }
#matrix .partner { display:block; min-height:22px; padding:0; text-align:left; border:0; background:transparent; color:#14567f; font-size:14px; font-weight:600; overflow-wrap:anywhere; }
#matrix .partner:hover { text-decoration:underline; }
.partner-meta,.company-count { display:flex; align-items:center; gap:5px; }
.partner-meta { flex-wrap:wrap; margin-top:2px; color:var(--muted); font-size:12px; }
.company-count { gap:3px; white-space:nowrap; }
.shade-gaps #matrix .gap1{background-color:#fff0f1}
.shade-gaps #matrix .gap2{background-color:#ffdedf}
.shade-gaps #matrix .gap3{background-color:#ffc8cb}
.shade-gaps #matrix .gap4{background-color:#ffb0b5}
.shade-gaps #matrix .gap5{background-color:#ff959c}
.shade-gaps #matrix .gap6{background-color:#fb7782}
.shade-gaps #matrix .gap7{background-color:#ef5867;color:#210c13}
.shade-gaps #matrix .gap8{background-color:#da3449;color:#fff}
.shade-gaps #matrix .gap9{background-color:#ca2338;color:#fff}
.shade-gaps #matrix .gap10{background-color:#b31329;color:#fff}
#matrix .issue-cover { display:block; width:57px; height:76px; margin-inline:auto; object-fit:contain; }
#matrix .before,#matrix .prior-purchase { color:var(--muted); }
#matrix .prior-purchase { font-size:13px; }
.prior-purchase time { margin-top:2px; }
#matrix td:has(.order-cell-button) { cursor:pointer; }
.order-cell-button { display:block; width:100%; min-height:24px; padding:0; border:0; border-radius:3px; background:transparent; color:inherit; font:inherit; text-align:right; }
.order-cell-button>* { display:block; }
#matrix td:hover .order-cell-button { color:inherit; background:transparent; text-decoration:underline; text-underline-offset:3px; }
#open-partner-search,#partner-search-editor { width:100%; display:flex; align-items:center; min-height:30px; }
#open-partner-search { justify-content:space-between; gap:6px; padding:3px 4px; background:transparent; border:1px solid transparent; text-align:left; color:inherit; font:inherit; }
#open-partner-search svg { flex:none; color:var(--blue); }
#open-partner-search span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
#open-partner-search:hover,#open-partner-search.filtered { background:#e4f0f8; border-color:#bdd2e0; }
#partner-search-editor { position:relative; }
#partner-search-editor input { width:100%; height:32px; padding:4px 27px 4px 7px; font-weight:400; }
#partner-search-editor input::-webkit-search-cancel-button { appearance:none; }
#clear-partner-search { position:absolute; right:2px; min-height:28px; width:25px; padding:0; background:transparent; border:0; color:var(--blue); font-size:18px; }
.matrix-navigation { position:sticky; bottom:0; z-index:4; display:flex; align-items:center; gap:10px; padding:0 10px; background:white; border-top:1px solid var(--line); }
#scroll-position { --rail:#e6ecf1; --handle:#788e9e; display:block; flex:1; min-width:0; appearance:none; height:24px; margin:0; background:transparent; cursor:pointer; }
#scroll-position:is(:hover,:focus-visible) { --handle:#486980; }
#scroll-position:disabled { --handle:#c9d4dc; cursor:default; }
#scroll-position::-webkit-slider-runnable-track { height:8px; background:var(--rail); border-radius:8px; }
#scroll-position::-webkit-slider-thumb { appearance:none; width:var(--thumb-size,28px); height:8px; background:var(--handle); border:0; border-radius:8px; cursor:inherit; }
#scroll-position::-moz-range-track { height:8px; background:var(--rail); border-radius:8px; }
#scroll-position::-moz-range-thumb { box-sizing:border-box; width:var(--thumb-size,28px); height:8px; background:var(--handle); border:0; border-radius:8px; cursor:inherit; }
#scroll-position:not(:disabled):active { cursor:grabbing; }
#scroll-caption { flex:0 0 6em; font-size:11px; color:var(--muted); text-align:right; }
@supports not selector(::-webkit-scrollbar) {
  #partner-scroll { padding-bottom:24px; clip-path:inset(0 0 24px); }
  .matrix-navigation { margin-top:-24px; }
}
.pager { padding:4px 12px 7px; font-size:12px; }
.foot { display:flex; align-items:baseline; justify-content:space-between; flex-wrap:wrap; gap:8px; margin:10px 0 24px; color:var(--muted); font-size:12px; }
.foot p { max-width:76ch; margin-top:5px; }
.foot a,.links a,.order-list a { color:var(--blue); text-underline-offset:3px; }
summary { cursor:pointer; }
dialog { border-color:#cad9e4; box-shadow:0 12px 48px #16344930; }
dialog::backdrop { background:#17344955; }
.primary { background:var(--blue); border-color:var(--blue); color:white; }
button.primary:hover:not(:disabled) { background:#12496c; color:white; }
#period-calendar { width:min(375px,94vw); padding:18px; }
.calendar-ends { display:grid; grid-template-columns:1fr 1fr; gap:3px; padding:3px; border-radius:8px; background:#edf3f7; }
.calendar-ends button { text-align:left; padding:6px 9px; background:transparent; border:1px solid transparent; }
.calendar-ends span,.calendar-ends strong { display:block; }
.calendar-ends span { color:var(--muted); font-size:12px; }
.calendar-ends button[aria-pressed=true] { background:white; border-color:#b8ccda; color:var(--blue); }
.calendar-year { display:grid; grid-template-columns:34px 1fr 34px; align-items:center; gap:8px; margin:13px 0 8px; }
.calendar-year button { font-size:22px; padding:0; line-height:1; }
.calendar-year select { justify-self:center; appearance:auto; padding:4px 8px; font-weight:600; }
#calendar-months { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:4px; }
#calendar-months button { padding:5px 2px; min-height:36px; border-color:transparent; }
#calendar-months button.in-period { background:var(--blue-light); color:var(--blue); }
#calendar-months button.endpoint { background:var(--blue); border-color:var(--blue); color:white; font-weight:600; }
.manual-period { margin-top:12px; font-size:13px; }
.manual-period>div { display:flex; gap:7px; }
.manual-period label { display:grid; flex:1; min-width:0; gap:2px; }
#period-error:not(:empty) { margin-top:5px; color:#96263a; }
#period-calendar .dialog-footer { gap:4px; }
#period-calendar .dialog-footer button { padding-inline:9px; font-size:13px; }
#all { margin-right:auto; color:var(--blue); border-color:transparent; }
#issue-search { width:100%; }
.issue-actions { display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin:10px 0 8px; }
.issue-actions button,.drag-hint { font-size:13px; }
#issue-count { margin-left:auto; color:var(--muted); font-size:13px; }
.drag-hint { color:var(--muted); }
@media(pointer:coarse) { .drag-hint { display:none; } }
#issue-options { user-select:none; overscroll-behavior:contain; }
#issue-options .choice { align-items:center; cursor:pointer; padding:7px 5px; border-radius:4px; }
#issue-options .choice:hover,#issue-options .choice:has(:checked) { background:var(--blue-light); }
#issues-dialog form,#group form,#card,#order-details { padding:20px; }
#card { width:min(760px,95vw); }
#order-details { width:min(620px,95vw); }
#order-context { font-weight:650; overflow-wrap:anywhere; }
#order-scope { margin:4px 0 14px; }
.options { max-height:40dvh; overflow:auto; margin:10px 0; border-block:1px solid var(--line); }
.stack { display:grid; gap:4px; margin:10px 0; }
#primary-company { appearance:auto; width:100%; padding:6px 9px; }
.company-role { margin-inline-start:6px; font-size:12px; color:var(--muted); }
#group-error { color:#993735; }
.card-totals,.order-list { width:100%; table-layout:auto; margin-block:10px; }
.card-totals :is(td,th),.order-list :is(td,th) { width:auto; padding:8px; text-align:right; }
.card-totals :is(td,th):first-child,.order-list :is(td,th):first-child { width:auto; text-align:left; padding:8px; }
.order-list td:last-child { white-space:nowrap; }
#order-total { text-align:right; font-weight:650; padding-top:10px; }
.links { padding-left:20px; }
#card-name { overflow-wrap:anywhere; }
#link-form { padding:20px; }
.partner-links { margin-top:18px; border-top:1px solid var(--line); }
.partner-links .relation-field { display:flex; flex-wrap:wrap; align-items:baseline; justify-content:space-between; gap:5px 12px; padding:10px 0 0; }
.partner-links .relation-field h3 { margin:0; font-size:.96rem; }
.partner-links .relation-action { color:var(--blue); font-size:14px; }
.partner-links .relation-field .relation-action { border-color:transparent; padding-inline:6px; }
.partner-links .company-node { display:flex; gap:4px 8px; align-items:center; flex-wrap:wrap; min-height:31px; }
.partner-links .company-node a { overflow-wrap:anywhere; color:var(--blue); text-decoration:none; }
.partner-links .company-node a:hover { text-decoration:underline; }
.partner-links > .company-node { font-size:1.12rem; font-weight:650; }
.partner-links .current-company { padding:2px 8px; border-radius:12px; background:var(--blue-light); color:var(--blue); font-size:12px; font-weight:600; }
.company-branches { list-style:none; margin:0 0 0 9px; padding:0; }
.company-branches > li { position:relative; padding:3px 0 3px 24px; }
.company-branches > li::before, .company-branches > li:not(:last-child)::after { content:""; position:absolute; left:0; border-left:1px solid #92aab8; }
.company-branches > li::before { top:0; height:50%; width:16px; border-bottom:1px solid #92aab8; border-bottom-left-radius:3px; }
.company-branches > li:not(:last-child)::after { top:50%; bottom:0; }
.partner-links > .relation-action { margin-top:8px; }
.company-branches + .relation-action { margin-left:33px; }
#link-options { max-height:30dvh; }
#link-options label { padding:7px 5px; align-items:baseline; cursor:pointer; }
#link-options label span { min-width:0; overflow-wrap:anywhere; }
#link-context { overflow-wrap:anywhere; }
#link-options input { accent-color:var(--blue); }
#link-options .muted { padding:6px; }
#link-preview:not(:empty) { border-left:3px solid var(--blue); padding:7px 12px; background:var(--blue-light); }
#link-preview p { margin:2px 0; overflow-wrap:anywhere; }
#link-error { color:#993735; }

@media(max-width:480px) {
  .card-totals { table-layout:fixed; font-size:13px; }
  .card-totals :is(td,th) { width:21%; padding:6px 4px; overflow-wrap:anywhere; }
  .card-totals :is(td,th):first-child { width:37%; padding:6px 4px; }
}

@media(max-width:760px) {
  .sync-actions { gap:8px; }
  #stamp { display:none; }
  #matrix td:first-child,#matrix th:first-child { width:155px; min-width:125px; max-width:160px; }
  #matrix .partner { font-size:13px; }
  .table-toolbar { gap:6px; padding:6px 8px; }
  .display-tools { margin-left:0; }
}
@media(max-width:580px) {
  .area-name { display:none; }
  .totals { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); margin-bottom:6px; }
  .totals>div { padding:4px 9px; border:0; }
  .totals>div+div { border:0; }
  .totals strong { font-size:17px; }
  main.frame { padding-top:6px; }
  .table-toolbar { flex-direction:column; align-items:stretch; gap:5px; }
  .period-mode { gap:6px; justify-content:space-between; }
  #open-calendar { font-size:12px; gap:4px; }
  .tabs,.shade-option,#open-view { flex:none; }
  .display-tools,.issue-tools { flex-wrap:nowrap; gap:4px; }
  .issue-tools { flex-wrap:wrap; }
  .issue-filter { flex:1 1 100px; min-width:0; }
  #open-sort { min-width:0; margin-left:auto; }
  #sort-caption { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .tool-button,.tabs button,.shade-option { font-size:12px; padding-inline:7px; }
  .tool-button .icon { width:14px; }
  .issue-filter #issue-column-search { width:100%; }
  #matrix td,#matrix th { padding:6px 8px; }
  .manual-period>div { flex-wrap:wrap; }
}
@media(forced-colors:active) {
  .shade-option input,#scroll-position { appearance:auto; }
  .shade-option input:checked::after { display:none; }
  .segments input:checked+span { outline:2px solid Highlight; }
}
