:root {
  color-scheme: light;
  --canvas: #f3f5ef;
  --paper: #fff;
  --ink: #172820;
  --muted: #56665c;
  --line: #e2e8de;
  --dark: #172d24;
  --green: #245d43;
  --soft: #e8f0e2;
  --gold: #d7ed9f;
  --radius: 16px;
  font: 16px/1.5 "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100dvh; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 3px solid #64975b; outline-offset: 3px; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 235px; padding: 34px 18px 22px; background: var(--dark); color: #e9f2e7; display: flex; flex-direction: column; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 10px 0 10px; align-self: flex-start; }
.brand strong { display: block; font-size: 1.16rem; line-height: 1.15; letter-spacing: -.025em; }
.brand small { color: #b7c9b9; font-size: .85rem; display: block; margin-top: 5px; }
.brand-mark { background: var(--gold); border-radius: 12px; width: 42px; height: 42px; display: flex; align-items: end; justify-content: center; gap: 3px; padding-bottom: 11px; }
.brand-mark i { width: 4px; background: var(--dark); border-radius: 2px; height: 9px; }
.brand-mark i:nth-child(2) { height: 15px; }
.brand-mark i:nth-child(3) { height: 20px; }
nav { display: grid; gap: 5px; margin-top: 46px; }
nav a { display: flex; align-items: center; gap: 13px; padding: 12px; border-radius: 9px; color: #c5d5c9; font-size: .91rem; font-weight: 500; white-space: nowrap; }
nav a:hover { background: #254637; }
nav a[aria-current] { color: #efffdd; background: #304c39; box-shadow: inset 3px 0 var(--gold); }
.nav-icon { position: relative; display: inline-block; flex: 0 0 16px; height: 16px; }
.nav-icon.tiles { border: 1.5px solid currentColor; border-radius: 3px; }
.nav-icon.tiles::before, .nav-icon.tiles::after { content: ""; position: absolute; background: currentColor; }
.nav-icon.tiles::before { width: 1px; inset: 0 auto 0 6px; }
.nav-icon.tiles::after { height: 1px; inset: 6px 0 auto; }
.nav-icon.list { border: 1.5px solid currentColor; border-radius: 3px; }
.nav-icon.list::before { content: ""; position: absolute; inset: 4px 3px auto; height: 1px; box-shadow: 0 4px currentColor; background: currentColor; }
.nav-icon.box { border: 1.5px solid currentColor; border-radius: 3px; }
.nav-icon.box::before { content: ""; position: absolute; border: 1px solid currentColor; border-top: 0; top: 0; width: 4px; height: 5px; left: 4px; }
.nav-icon.upload { border: 1.5px solid currentColor; border-top: 0; border-radius: 3px; height: 9px; margin-top: 6px; }
.nav-icon.upload::before { content: ""; position: absolute; height: 10px; width: 1.5px; background: currentColor; left: 6px; top: -6px; }
.nav-icon.upload::after { content: ""; position: absolute; border-top: 1.5px solid; border-left: 1.5px solid; width: 5px; height: 5px; left: 4px; top: -6px; transform: rotate(45deg); }
.sidebar-footer { margin-top: auto; color: #b7c9b9; border-top: 1px solid #3c5246; padding: 17px 10px 0; font-size: .86rem; display: flex; align-items: center; gap: 8px; }
.sidebar-footer span { width: 7px; height: 7px; background: var(--gold); border-radius: 50%; }
main { margin-left: 235px; }
.workspace { max-width: 1540px; margin: 0 auto; padding: 37px clamp(22px, 3.2vw, 48px) 55px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 32px; }
.page-head h1 { margin: 0; font-size: clamp(2rem, 3.35vw, 3.05rem); font-weight: 630; line-height: 1.07; letter-spacing: -.06em; }
.page-head p { color: var(--muted); margin: 10px 0 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn { min-height: 42px; padding: 8px 14px; border-radius: 9px; border: 1px solid #d5ded2; background: white; color: var(--ink); font-size: .89rem; font-weight: 640; display: inline-flex; gap: 7px; align-items: center; justify-content: center; }
.btn:hover { background: #eef4ea; }
.btn.primary { background: var(--green); color: #fff; border-color: var(--green); }
.btn.primary:hover { background: #1c4935; }
.btn.compact { padding: 5px 10px; min-height: 34px; }
.btn .plus { font-size: 1.22em; line-height: 1; }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin-bottom: 18px; }
input, select { color: var(--ink); background: white; border: 1px solid #d5ded2; border-radius: 8px; padding: 8px 10px; min-height: 42px; max-width: 100%; }
select { padding-right: 32px; appearance: none; background-image: linear-gradient(45deg, transparent 50%, #435c4c 50%), linear-gradient(135deg, #435c4c 50%, transparent 50%); background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
input[type=search] { min-width: 190px; }
.filters select, .filters input { font-size: .9rem; }
.filters .scope { margin-left: auto; color: var(--muted); font-size: .87rem; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; }
.hero-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; margin-bottom: 16px; }
.kpi { padding: 17px 17px 15px; min-height: 125px; }
.kpi h2 { font-size: .93rem; font-weight: 600; margin: 0 0 8px; }
.kpi .value { display: block; font-size: clamp(1.34rem, 2.45vw, 2.15rem); font-weight: 650; letter-spacing: -.055em; line-height: 1.12; white-space: nowrap; font-variant-numeric: tabular-nums; }
.kpi p { margin: 9px 0 0; font-size: .78rem; color: var(--muted); }
.kpi.accent { background: var(--dark); border-color: var(--dark); color: #fff; }
.kpi.accent .value { color: #f1f8e6; }
.kpi.accent p { color: #c5d5c9; }
.kpi .delta { display: inline-block; color: var(--gold); font-weight: 630; margin-right: 4px; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 15px; margin-bottom: 15px; }
.panel-head { padding: 19px 20px 14px; display: flex; align-items: flex-start; justify-content: space-between; gap: 9px; }
.panel-head h2, .section-title { margin: 0; font-size: 1.14rem; letter-spacing: -.024em; font-weight: 680; }
.panel-head p, .section-note { margin: 4px 0 0; color: var(--muted); font-size: .87rem; }
.chart { display: grid; grid-template-columns: 58px minmax(0, 1fr); padding: 10px 20px 15px 14px; }
.chart-scroll { overflow-x: auto; min-width: 0; padding: 4px; margin: -4px; }
.axis { display: flex; flex-direction: column; justify-content: space-between; height: 175px; padding-right: 8px; align-items: flex-end; color: var(--muted); font-size: .73rem; font-variant-numeric: tabular-nums; transform: translateY(-8px); }
.bars { min-width: max(100%, calc(var(--count) * 47px)); height: 175px; position: relative; display: grid; grid-template-columns: repeat(var(--count), minmax(0, 1fr)); gap: 6px; background: repeating-linear-gradient(to top, var(--line) 0 1px, transparent 1px 25%); border-top: 1px solid var(--line); }
.bars .bar-col { display: flex; position: relative; align-items: end; justify-content: center; }
.bar { z-index: 1; align-self: end; height: max(2px, var(--h)); border-radius: 6px 6px 0 0; width: min(52%, 70px); margin-bottom: calc(var(--base) - var(--shift)); border: 0; background: #6a9c79; padding: 0; }
.bar.latest { background: #245d43; }
.bar:hover, .bar:focus { filter: brightness(1.22); }
.bar.missing { background: #d9e3da; height: 3px; }
.bar.zero { background: #6a9c79; }
.month-axis { display: grid; grid-template-columns: repeat(var(--count), minmax(0, 1fr)); gap: 6px; min-width: max(100%, calc(var(--count) * 47px)); margin-top: 8px; color: var(--muted); font-size: .75rem; text-align: center; }
.zero-line { position: absolute; left: 0; right: 0; bottom: var(--base); border-top: 1px solid #bac9bb; }
.family-list { list-style: none; padding: 3px 20px 14px; margin: 0; display: grid; gap: 10px; }
.family-row { display: grid; width: 100%; grid-template-columns: minmax(0,1fr) max-content; gap: 4px 8px; text-align: left; background: none; border: 0; padding: 2px 0; color: var(--ink); font-size: .875rem; }
.family-row:hover .rank-name { text-decoration: underline; }
.family-row .rank-name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 580; }
.family-row .rank-val { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.rank-track { height: 5px; border-radius: 5px; overflow: hidden; background: #ecf1e9; grid-column: 1 / -1; }
.rank-track i { display: block; width: var(--w); height: 100%; border-radius: 5px; background: var(--bar-color, var(--green)); }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: 10px 15px; border-top: 1px solid var(--line); text-align: left; }
th { background: #f8faf6; color: #465a4d; font-weight: 610; white-space: nowrap; }
td small { display: block; color: var(--muted); font-size: .8rem; }
.number { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tr:hover td { background: #fafcf9; }
.pill { display: inline-flex; border-radius: 30px; background: #ebf1e9; padding: 3px 8px; font-size: .78rem; color: #294d3a; white-space: nowrap; }
.pill.warm { background: #f4eddd; color: #674510; }
.pill.gray { background: #f0f1ee; color: #49534b; }
.empty { padding: 25px; color: var(--muted); }
.meta { color: var(--muted); font-size: .86rem; }
.table-footer { display: flex; justify-content: space-between; align-items: center; padding: 10px 15px; gap: 7px; border-top: 1px solid var(--line); }
.grid-catalogue { display: grid; grid-template-columns: minmax(220px, .7fr) minmax(0, 1.9fr); gap: 15px; align-items: start; }
.grid-catalogue .filters { padding: 0 15px; }
.family-select { display: flex; align-items: center; gap: 5px; border-top: 1px solid var(--line); padding: 5px 13px; }
.family-select > button:first-child { flex: 1; border: 0; text-align: left; padding: 9px 5px; background: none; color: var(--ink); }
.family-select.active { background: #edf4e9; }
.family-select > button:first-child:hover { text-decoration: underline; }
.icon-btn { background: none; border: 1px solid transparent; border-radius: 7px; min-width: 34px; min-height: 34px; color: var(--muted); font-size: 1rem; }
.icon-btn:hover { border-color: var(--line); background: #fff; }
.import-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(245px, 1fr); gap: 15px; align-items: start; }
.import-body { padding: 0 20px 20px; }
.file-zone { border: 1px dashed #9bb19c; border-radius: 12px; display: grid; place-items: center; gap: 8px; text-align: center; background: #f8faf6; padding: 25px 10px; }
.file-zone input { width: min(360px, 100%); background: #fff; }
.file-zone.drag { background: #eaf3e4; border-color: var(--green); }
.preview { margin-top: 18px; }
.preview .actions { margin-top: 14px; }
.error { color: #a42b24; font-size: .9rem; margin: 8px 0; }
.import-history { margin: 0; padding: 0; list-style: none; }
.import-history li { padding: 12px 20px; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.import-history strong { display: block; }
dialog { width: min(calc(100vw - 24px), 510px); max-height: calc(100dvh - 24px); overflow-y: auto; border: 1px solid var(--line); border-radius: 17px; color: var(--ink); padding: 0; box-shadow: 0 20px 65px #13281c40; }
dialog::backdrop { background: #10251c75; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 21px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 0; letter-spacing: -.03em; font-size: 1.32rem; }
dialog form { display: grid; gap: 13px; padding: 17px 21px 21px; }
dialog fieldset { display: grid; border: 0; margin: 0; padding: 0; gap: 13px; }
.field { display: grid; gap: 4px; font-size: .9rem; font-weight: 610; }
.two-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-actions { justify-content: flex-end; }
#notice { display: none; position: fixed; right: 20px; bottom: 20px; z-index: 4; max-width: calc(100vw - 40px); background: var(--dark); color: #fff; padding: 12px 17px; border-radius: 9px; box-shadow: 0 4px 14px #0e201f20; }
#notice.visible { display: block; }
@media (max-width: 1050px) {
  .sidebar { width: 191px; padding-inline: 12px; }
  main { margin-left: 191px; }
  .hero-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .value { font-size: 1.85rem; }
}
@media (max-width: 790px) {
  .sidebar { width: auto; position: sticky; inset: 0 0 auto; z-index: 3; padding: 10px 12px 0; display: block; overflow: visible; }
  .brand { display: inline-flex; padding: 0; gap: 8px; }
  .brand-mark { width: 32px; height: 32px; border-radius: 8px; padding-bottom: 7px; }
  .brand strong { font-size: 1rem; }
  .brand small { display: inline; font-size: .8rem; margin: 0; }
  .sidebar-footer { display: none; }
  nav { display: flex; overflow-x: auto; margin: 6px -12px 0; padding: 0 12px 7px; }
  nav a { padding: 8px 9px; gap: 6px; font-size: .82rem; }
  nav a[aria-current] { box-shadow: inset 0 -2px var(--gold); }
  .nav-icon { display: none; }
  main { margin-left: 0; }
  .workspace { padding: 25px 14px 35px; }
}
@media (max-width: 600px) {
  .page-head { display: grid; margin-bottom: 22px; gap: 11px; }
  .dashboard-grid, .grid-catalogue, .import-layout { grid-template-columns: minmax(0, 1fr); }
  .hero-grid { gap: 8px; }
  .kpi { padding: 13px 10px 11px; min-height: 108px; }
  .kpi .value { font-size: 1.48rem; }
  .kpi h2 { font-size: .84rem; }
  .kpi p { font-size: .74rem; }
  .filters .scope { margin-left: 0; flex-basis: 100%; }
  .panel-head { padding: 15px 13px 11px; }
  .family-list { padding-inline: 13px; }
  th, td { padding: 8px 10px; }
  .table-footer .btn { padding: 5px 7px; font-size: .81rem; }
}
.text-btn { padding: 0; border: 0; background: none; color: var(--green); text-align: left; font-weight: 630; }
.text-btn:hover { text-decoration: underline; }
.bar-label { position: absolute; top: max(4px, calc(100% - var(--base) - var(--h) - 24px)); left: 50%; transform: translateX(-50%); white-space: nowrap; color: #355347; font-size: .79rem; font-weight: 650; }
.bars[style] .bar-label { display: block; }
.bars:has(.bar-col:nth-child(5)) .bar-label { display: none; }
.bars:has(.bar-col:nth-child(5)) .bar:hover .bar-label, .bars:has(.bar-col:nth-child(5)) .bar:focus .bar-label { display: block; background: white; z-index: 3; }
.summary-grid { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
.summary-grid .table-scroll { max-height: 390px; }
.summary-grid thead th { position: sticky; top: 0; z-index: 2; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.preview-banner { margin-bottom: 17px; color: #3a5543; font-size: .86rem; }
@media (max-width: 700px) { .summary-grid { grid-template-columns: minmax(0,1fr); } }
