.kpi-items {
  --kpi-color: #7c5cff;
  --kpi-soft: rgba(124, 92, 255, 0.09);
  border-top: 3px solid #7c5cff;
}

.kpi-stock {
  --kpi-color: var(--green);
  --kpi-soft: rgba(18, 166, 120, 0.09);
  border-top: 3px solid var(--green);
}

.kpi-low {
  --kpi-color: var(--red);
  --kpi-soft: rgba(226, 86, 86, 0.1);
  border-top: 3px solid var(--red);
}

.kpi-mutation {
  --kpi-color: var(--accent);
  --kpi-soft: rgba(47, 107, 255, 0.09);
  border-top: 3px solid var(--accent);
}

.period-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 18px;
  margin-bottom: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.period-tabs {
  display: flex;
  padding: 4px;
  border-radius: 10px;
  background: #f1f5fb;
}

.period-tab {
  padding: 8px 16px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.period-tab.active {
  background: var(--panel);
  color: var(--accent);
  box-shadow: 0 2px 8px rgba(20, 37, 70, 0.08);
}

.period-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.period-nav input[type="date"] {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fbfcfe;
  color: var(--ink);
  font-size: 12px;
  outline: none;
}

.period-nav input[type="date"]:focus {
  border-color: var(--accent);
}

.period-nav .btn-small {
  min-width: 34px;
  font-size: 16px;
  line-height: 1;
}

.period-label {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.swatch.in {
  background: var(--green);
}

.swatch.out {
  background: var(--red);
}

.mini-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.mini-stats div {
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfcfe;
}

.mini-stats span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.mini-stats strong {
  display: block;
  margin-top: 5px;
  font-size: 20px;
  letter-spacing: -0.03em;
}

.stack-form {
  display: grid;
  gap: 14px;
}

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

.form-row.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.btn.full {
  width: 100%;
}

.cancel-hidden {
  visibility: hidden;
}

.cancel-hidden.visible {
  visibility: visible;
}

.data-tools {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

.side-action {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.05);
  color: #c3d0e6;
  font-size: 11px;
  text-align: left;
  cursor: pointer;
}

.side-action:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.side-action svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.side-action.danger {
  color: #ff9d9d;
}

.compact-search,
.stock-select {
  width: min(280px, 100%);
}

.badge {
  display: inline-block;
  padding: 4px 9px;
  border-radius: 99px;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.badge.good {
  background: rgba(18, 166, 120, 0.1);
  color: var(--green);
}

.badge.warn {
  background: rgba(245, 158, 11, 0.13);
  color: #b7791f;
}

.badge.bad {
  background: rgba(226, 86, 86, 0.12);
  color: var(--red);
}

.badge.in {
  background: rgba(18, 166, 120, 0.1);
  color: var(--green);
}

.badge.out {
  background: rgba(226, 86, 86, 0.1);
  color: var(--red);
}

.icon-btn {
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
}

.icon-btn:hover {
  color: var(--ink);
  border-color: #cbd6e8;
}

.icon-btn.danger:hover {
  color: var(--red);
  border-color: rgba(226, 86, 86, 0.4);
}

.action-cell {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.chart-empty {
  display: grid;
  place-items: center;
  min-height: 220px;
  border: 1px dashed #d6dfec;
  border-radius: 12px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.chart-empty strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
  font-size: 14px;
}

.depreciation-result {
  margin-top: 18px;
  min-width: 0;
}

.depreciation-result .table-wrap {
  overflow-x: auto;
}

.dep-rules {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.dep-rules-head {
  color: var(--muted, #6f7d94);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.dep-rule-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line, #dbe3ef);
  border-radius: 10px;
  background: #fbfcfe;
  font-size: 12px;
}

#depSummary {
  min-width: 0;
  max-width: min(460px, 100%);
  overflow-wrap: anywhere;
  text-align: right;
}

.dep-final td {
  background: #f4f8ff;
}

.price-drop {
  display: block;
  margin-top: 2px;
  color: var(--muted, #6f7d94);
  font-size: 10px;
  font-weight: 500;
}

.toast-container {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 50;
  display: grid;
  gap: 8px;
}

.toast {
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--navy);
  color: #fff;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
  font-size: 12px;
  animation: toast-in 0.18s ease;
}

.toast.error {
  background: #a83d3d;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1180px) {
  .form-row.three {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .period-label {
    width: 100%;
    margin-left: 0;
  }
}

@media (max-width: 820px) {
  .period-bar {
    align-items: flex-start;
  }

  .period-nav {
    flex-wrap: wrap;
  }
}

@media (max-width: 560px) {
  .form-row,
  .form-row.three,
  .mini-stats {
    grid-template-columns: 1fr;
  }

  .compact-search,
  .stock-select {
    width: 100%;
  }
}

.export-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

@media print {
  .period-bar,
  .form-grid,
  .side-action,
  .icon-btn,
  .export-actions,
  .toast-container {
    display: none !important;
  }

  .two-col {
    grid-template-columns: 1fr;
  }
}
