.filter-bar {
  margin-bottom: 10px;
}

.analysis-context {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 22px;
  margin-bottom: 28px;
  padding: 11px 14px;
  background: var(--ink-900);
  border: 1px solid var(--border);
  border-radius: 5px;
}

.quick-periods,
.data-evidence,
.evidence-result,
.data-evidence dl,
.data-evidence dl div {
  display: flex;
  align-items: center;
}

.quick-periods {
  gap: 10px;
}

.quick-periods > span {
  color: var(--paper-500);
  font-size: 0.68rem;
  white-space: nowrap;
}

.quick-periods > div {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
  padding: 2px;
  background: var(--ink-800);
  border-radius: 4px;
}

.quick-periods button {
  min-height: 30px;
  padding: 0 10px;
  color: var(--paper-400);
  background: transparent;
  border: 0;
  border-radius: 3px;
  font-size: 0.7rem;
  white-space: nowrap;
  transition: color 180ms var(--ease-quart), background-color 180ms var(--ease-quart), transform 100ms var(--ease-quart);
}

.quick-periods button:hover {
  color: var(--primary);
}

.quick-periods button:active {
  transform: scale(0.97);
}

.quick-periods button.is-active {
  color: #ffffff;
  background: var(--primary);
  font-weight: 600;
}

.data-evidence {
  min-width: 0;
  justify-content: flex-end;
  gap: 20px;
}

.evidence-result {
  min-width: 0;
  gap: 8px;
}

.evidence-result > svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  color: var(--good);
}

.evidence-result > span {
  display: grid;
}

.evidence-result strong {
  color: var(--paper-200);
  font-size: 0.74rem;
  font-weight: 600;
}

.evidence-result small {
  color: var(--paper-500);
  font-size: 0.63rem;
  white-space: nowrap;
}

.data-evidence dl {
  flex: 0 0 auto;
  gap: 0;
  margin: 0;
}

.data-evidence dl div {
  gap: 7px;
  padding: 0 11px;
  border-left: 1px solid var(--border);
}

.data-evidence dt,
.data-evidence dd {
  margin: 0;
  font-size: 0.66rem;
  white-space: nowrap;
}

.data-evidence dt {
  color: var(--paper-500);
}

.data-evidence dd {
  color: var(--paper-200);
  font-weight: 600;
}

.kpi-meta span:last-child {
  max-width: 58%;
  text-align: right;
}

.detail-scope {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 8px;
  margin: -4px 0 12px;
  padding: 8px 10px 8px 12px;
  color: var(--primary-dark);
  background: var(--primary-soft);
  border: 1px solid #c7d2f2;
  border-radius: 4px;
  font-size: 0.75rem;
}

.detail-scope[hidden] {
  display: none;
}

.detail-scope > svg {
  width: 15px;
  height: 15px;
}

.detail-scope strong {
  font-weight: 600;
}

.detail-scope button {
  display: grid;
  width: 32px;
  height: 32px;
  margin-left: auto;
  padding: 0;
  place-items: center;
  color: var(--primary-dark);
  background: transparent;
  border: 0;
  border-radius: 3px;
  transition: background-color 160ms var(--ease-quart), transform 100ms var(--ease-quart);
}

.detail-scope button:hover {
  background: #d6e0fb;
}

.detail-drawer {
  width: min(760px, 96vw);
}

.drawer-body {
  width: 100%;
  min-width: 0;
  gap: 20px;
}

.drawer-kpis-extended {
  min-width: 0;
  grid-template-columns: repeat(4, 1fr);
}

.drawer-comparison {
  display: flex;
  min-width: 0;
  min-height: 38px;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  color: var(--paper-400);
  background: var(--ink-850);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.7rem;
}

.drawer-comparison > svg {
  width: 15px;
  height: 15px;
  color: var(--primary);
}

.drawer-comparison strong {
  font-weight: 600;
}

.drawer-comparison small {
  margin-left: auto;
  color: var(--paper-500);
}

.correction-card {
  display: grid;
  min-width: 0;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 15px 16px;
  background: var(--warn-soft);
  border: 1px solid #efd7ad;
  border-radius: 5px;
  transition: background-color 220ms var(--ease-quart), border-color 220ms var(--ease-quart);
}

.correction-card.is-closed,
.correction-card.is-stable {
  background: var(--good-soft);
  border-color: #bdd8c9;
}

.correction-card > div > span {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #8c5b16;
  font-size: 0.68rem;
  font-weight: 600;
}

.correction-card.is-closed > div > span,
.correction-card.is-stable > div > span {
  color: var(--good);
}

.correction-status {
  padding: 2px 6px;
  color: #ffffff;
  background: var(--warn);
  border-radius: 3px;
  font-size: 0.62rem;
  font-style: normal;
  font-weight: 500;
}

.correction-card.is-closed .correction-status {
  background: var(--good);
}

.correction-card h3 {
  margin: 5px 0 3px;
  font-size: 0.9rem;
  font-weight: 600;
}

.correction-card p {
  margin: 0;
  color: #6f5a37;
  font-size: 0.72rem;
}

.correction-card.is-closed p,
.correction-card.is-stable p {
  color: #4d6c5e;
}

.correction-card.is-stable {
  grid-template-columns: 1fr 28px;
}

.correction-card.is-stable > svg {
  color: var(--good);
}

.correction-button {
  min-height: 38px;
  padding: 0 12px;
  color: #ffffff;
  background: var(--primary);
  border-color: var(--primary);
  font-size: 0.72rem;
  white-space: nowrap;
}

.correction-button:hover {
  background: var(--primary-dark);
}

.drawer-section {
  min-width: 0;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.drawer-section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.drawer-section-heading span {
  display: block;
  color: var(--paper-500);
  font-size: 0.66rem;
}

.drawer-section-heading h3 {
  margin: 3px 0 0;
  font-size: 0.9rem;
}

.drawer-section-heading > small {
  color: var(--paper-500);
  font-size: 0.68rem;
}

.drawer-legend {
  display: flex;
  gap: 12px;
}

.drawer-legend span {
  display: flex;
  align-items: center;
  gap: 5px;
}

.drawer-legend i {
  width: 14px;
  height: 2px;
  background: var(--primary);
}

.drawer-legend .is-budget {
  background: var(--paper-500);
}

.drawer-chart {
  height: 168px;
  margin-top: 12px;
}

.drawer-chart svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.drawer-chart-grid {
  stroke: var(--border);
  stroke-width: 1;
}

.drawer-chart-budget,
.drawer-chart-actual {
  fill: none;
  vector-effect: non-scaling-stroke;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.drawer-chart-budget {
  stroke: var(--paper-500);
  stroke-width: 1.5;
  stroke-dasharray: 4 4;
}

.drawer-chart-actual {
  stroke: var(--primary);
  stroke-width: 2;
}

.drawer-chart-point {
  fill: var(--ink-900);
  stroke: var(--primary);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.drawer-chart-point.is-current {
  fill: var(--primary);
}

.drawer-chart-label {
  fill: var(--paper-500);
  font-family: var(--font-body);
  font-size: 10px;
}

.object-distribution {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.object-distribution > div {
  display: grid;
  grid-template-columns: 136px 1fr 38px;
  align-items: center;
  gap: 10px;
  font-size: 0.72rem;
}

.object-distribution > div > span {
  overflow: hidden;
  color: var(--paper-200);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.object-distribution > div > div {
  height: 5px;
  overflow: hidden;
  background: var(--ink-700);
}

.object-distribution i {
  display: block;
  height: 100%;
  background: var(--primary);
  transform-origin: left;
  animation: object-bar-in 340ms var(--ease-out) both;
}

.object-distribution strong {
  color: var(--paper-400);
  font-size: 0.68rem;
  font-weight: 600;
  text-align: right;
}

.drawer-records-wrap {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  margin-top: 12px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.drawer-records {
  width: 100%;
  min-width: 690px;
  border-collapse: collapse;
  font-size: 0.68rem;
}

.drawer-records th,
.drawer-records td {
  height: 38px;
  padding: 0 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.drawer-records th {
  color: var(--paper-500);
  background: var(--ink-850);
  font-weight: 500;
}

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

.drawer-records td:nth-child(3) {
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drawer-records td:nth-child(5) {
  font-weight: 600;
  text-align: right;
}

.drawer-records td:last-child span {
  color: var(--good);
  font-weight: 600;
}

.drawer-lineage {
  display: grid;
  min-width: 0;
  grid-template-columns: 1fr 22px 1fr 22px 1fr;
  align-items: center;
  gap: 6px;
  padding: 14px;
  background: var(--ink-850);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.drawer-lineage > div {
  min-width: 0;
}

.drawer-lineage > div span,
.drawer-lineage dt,
.drawer-lineage dd {
  color: var(--paper-500);
  font-size: 0.62rem;
}

.drawer-lineage > div strong {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  font-size: 0.7rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawer-lineage > svg {
  width: 14px;
  color: var(--paper-500);
}

.drawer-lineage dl {
  display: flex;
  grid-column: 1 / -1;
  gap: 16px;
  margin: 7px 0 0;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.drawer-lineage dl div {
  display: flex;
  gap: 5px;
}

.drawer-lineage dl dt,
.drawer-lineage dl dd {
  margin: 0;
}

.drawer-lineage dl dd {
  color: var(--paper-200);
  font-weight: 600;
}

@keyframes object-bar-in {
  from { opacity: 0; transform: scaleX(0); }
  to { opacity: 1; transform: scaleX(1); }
}

@media (max-width: 1120px) {
  .analysis-context { grid-template-columns: 1fr; gap: 10px; }
  .data-evidence { justify-content: space-between; }
}

@media (max-width: 760px) {
  .filter-bar { margin-bottom: 10px; }
  .analysis-context { margin-bottom: 24px; padding: 12px; }
  .quick-periods { align-items: flex-start; flex-direction: column; gap: 6px; }
  .quick-periods > div { width: 100%; }
  .quick-periods button { min-width: 0; padding-inline: 5px; }
  .data-evidence { align-items: flex-start; flex-direction: column; gap: 10px; }
  .data-evidence dl { width: 100%; }
  .data-evidence dl div { flex: 1; justify-content: space-between; }
  .data-evidence dl div:first-child { padding-left: 0; border-left: 0; }
  .evidence-result small { white-space: normal; }
  .kpi-meta span:last-child { max-width: none; text-align: left; }
  .detail-drawer { width: 100vw; max-width: 100vw; }
  .drawer-kpis-extended { grid-template-columns: repeat(2, 1fr); }
  .drawer-comparison { align-items: flex-start; flex-wrap: wrap; }
  .drawer-comparison small { width: 100%; margin-left: 23px; }
  .correction-card { grid-template-columns: 1fr; }
  .correction-button { width: 100%; }
  .object-distribution > div { grid-template-columns: 112px 1fr 34px; }
}

@media (max-width: 460px) {
  .quick-periods > div { overflow-x: auto; grid-template-columns: repeat(4, minmax(70px, 1fr)); }
  .data-evidence dl { display: grid; grid-template-columns: repeat(3, 1fr); }
  .data-evidence dl div { display: grid; gap: 2px; padding-inline: 8px; }
  .data-evidence dl div:first-child { padding-left: 0; }
  .data-evidence dl div:last-child { padding-right: 0; }
  .drawer-section-heading { align-items: flex-start; flex-direction: column; gap: 5px; }
  .drawer-legend { align-self: flex-start; }
  .drawer-chart { height: 150px; }
  .object-distribution > div { grid-template-columns: 96px 1fr 32px; }
  .drawer-lineage { grid-template-columns: 1fr 16px 1fr 16px 1fr; padding: 10px; }
  .drawer-lineage > div strong { white-space: normal; }
}

@media (prefers-reduced-motion: reduce) {
  .object-distribution i { animation: none; }
}
