:host {
  --ink: #1c2a38;
  --ink-soft: #50647c;
  --line: rgba(23, 65, 99, 0.1);
  --card-bg: #ffffff;
  --income: #0c8d42;
  --expense: #d8443c;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(16, 38, 58, 0.04), 0 12px 32px -16px rgba(16, 38, 58, 0.22);
  display: block;
}

/* ---------- Page shell ---------- */
.fin {
  padding: 28px clamp(16px, 3vw, 36px) 48px;
  color: var(--ink);
  background:
    radial-gradient(120% 80% at 100% -10%, rgba(2, 121, 207, 0.08), transparent 55%),
    radial-gradient(90% 70% at -10% 0%, rgba(22, 212, 203, 0.07), transparent 50%),
    #f2f4f7;
  min-height: 100%;
}

/* ---------- Top band ---------- */
.fin__band {
  display: grid;
  gap: 18px;
  grid-template-columns: 1fr;
  margin-bottom: 18px;
}

.hero {
  position: relative;
  overflow: hidden;
  padding: 26px 28px;
  border-radius: var(--radius);
  color: #fff;
  background: linear-gradient(135deg, #15588e 0%, #0279cf 56%, #16a7c9 120%);
  box-shadow: 0 20px 44px -22px rgba(2, 90, 160, 0.7);
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 168px;
}

.hero__glow {
  position: absolute;
  width: 320px;
  height: 320px;
  top: -160px;
  right: -80px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.35), transparent 65%);
  pointer-events: none;
}

.hero__rings {
  position: absolute;
  right: -70px;
  bottom: -90px;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background:
    repeating-radial-gradient(circle, rgba(255, 255, 255, 0.14) 0 1px, transparent 1px 22px);
  mask: radial-gradient(circle, #000 40%, transparent 72%);
  pointer-events: none;
}

.hero__label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.82);
}

.hero__value {
  font-size: clamp(34px, 4.6vw, 52px);
  font-weight: 750;
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin: 6px 0 4px;
  font-variant-numeric: tabular-nums;

  &.is-neg { color: #ffd7d2; }
}

.hero__sub {
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.78);
  position: relative;
  z-index: 1;
}

.stat {
  position: relative;
  padding: 22px 22px 20px;
  border-radius: var(--radius);
  background: var(--card-bg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.stat__icon {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;

  svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
}

.stat--income .stat__icon { background: rgba(12, 141, 66, 0.12); svg { stroke: var(--income); } }
.stat--expense .stat__icon { background: rgba(216, 68, 60, 0.12); svg { stroke: var(--expense); } }

.stat__label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  text-transform: uppercase;
}

.stat__value {
  font-size: clamp(24px, 2.6vw, 30px);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}

.stat--income .stat__value { color: var(--income); }
.stat--expense .stat__value { color: var(--expense); }

/* ---------- Filter (projected into the system header's actions slot) ---------- */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }

.chip {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-soft);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.16s ease;

  &:hover { border-color: var(--kendo-color-primary, #0279cf); color: var(--kendo-color-primary, #0279cf); }
  &.is-active {
    background: var(--kendo-color-primary, #0279cf);
    border-color: var(--kendo-color-primary, #0279cf);
    color: #fff;
    box-shadow: 0 8px 18px -8px rgba(2, 121, 207, 0.7);
  }
}

.range { display: flex; align-items: center; gap: 6px; }
.range__sep { color: var(--ink-soft); }

/* ---------- Analytics grid ---------- */
.fin__grid {
  display: grid;
  gap: 18px;
  grid-template-columns: 1fr;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 18px 16px;
  display: flex;
  flex-direction: column;
}

.card__head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
}

.card__title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.card__zh {
  font-size: 12px;
  color: var(--ink-soft);
}

/* ---------- Donut + center overlay ---------- */
.donut {
  position: relative;
}

.donut__center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  gap: 2px;
}

.donut__cap {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.donut__num {
  font-size: 21px;
  font-weight: 750;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;

  &.is-neg { color: var(--expense); }
}

/* ---------- Custom legend ---------- */
.legend {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.legend--scroll {
  max-height: 156px;
  overflow-y: auto;
  padding-right: 2px;

  &::-webkit-scrollbar { width: 6px; }
  &::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; }
}

.legend__row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: 9px;
  font-size: 13px;
}

.legend__row--btn {
  cursor: pointer;
  transition: background 0.14s ease;
  &:hover { background: var(--kendo-color-primary-subtle, #daecfb); }
  &.is-selected {
    background: var(--kendo-color-primary-subtle, #daecfb);
    box-shadow: inset 2px 0 0 var(--kendo-color-primary, #0279cf);
  }
}

.legend__dot {
  width: 11px;
  height: 11px;
  border-radius: 4px;
  flex: none;
}

.legend__name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
}

.legend__pct {
  font-size: 12px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  width: 38px;
  text-align: right;
}

.legend__val {
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.hint {
  margin-top: 10px;
  font-size: 11.5px;
  color: var(--ink-soft);
  text-align: center;
}

/* ---------- Breadcrumb ---------- */
.crumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin: 4px 0 10px;
}

.crumb {
  border: none;
  background: var(--kendo-color-base-subtle, #e6eaef);
  color: var(--ink-soft);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 11px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.14s ease;

  &:hover:not(:disabled) { background: var(--kendo-color-primary-subtle, #daecfb); color: var(--kendo-color-primary-emphasis, #15588e); }
  &.is-current {
    background: var(--kendo-color-primary, #0279cf);
    color: #fff;
    cursor: default;
  }
}

.crumb__sep { color: var(--ink-soft); font-size: 13px; }

/* ---------- Empty states ---------- */
.empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);

  span { font-weight: 400; font-size: 12px; }
}

.empty--grid {
  position: static;
  padding: 36px 0;
}

/* ---------- Detail grid (Kendo overrides) ---------- */
.detail {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
}

:host ::ng-deep .detail {
  .k-grid-header, .k-grid-header-wrap { border: none; background: transparent; }
  .k-table-th {
    border: none;
    background: transparent;
    color: var(--ink-soft);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding-block: 8px;
  }
  .k-grid-content { background: transparent; }
  td.k-table-td {
    border: none;
    border-top: 1px solid var(--line);
    padding-block: 9px;
    vertical-align: middle;
  }
  .k-table-row:hover td.k-table-td { background: var(--kendo-color-primary-subtle, #daecfb); }
  .k-grid-pager {
    border: none;
    background: transparent;
    color: var(--ink-soft);
    padding-top: 10px;
  }
  col:last-child, .k-table-td:last-child, .k-table-th:last-child { text-align: right; }
}

.cell-item { display: flex; flex-direction: column; line-height: 1.3; }
.cell-item__desc { font-weight: 600; color: var(--ink); }
.cell-item__sub { font-size: 11.5px; color: var(--ink-soft); }

.cell-amt {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  letter-spacing: 0.02em;

  &.is-paid { background: var(--kendo-color-success-subtle, #d9fce8); color: #0c8d42; }
  &.is-approved { background: var(--kendo-color-primary-subtle, #daecfb); color: var(--kendo-color-primary-emphasis, #15588e); }
}

/* ---------- Responsive escalation ---------- */
@media (min-width: 760px) {
  .fin__band { grid-template-columns: 1fr 1fr; }
  .hero { grid-column: 1 / -1; }
  .fin__grid { grid-template-columns: 1fr 1fr; }
  .card--wide { grid-column: 1 / -1; }
}

@media (min-width: 1200px) {
  .fin__band { grid-template-columns: 1.7fr 1fr 1fr; }
  .hero { grid-column: auto; }
  .fin__grid { grid-template-columns: 320px minmax(0, 1fr) minmax(0, 1.25fr); }
  .card--wide { grid-column: auto; }
}

/* ---------- Entrance ---------- */
.rise {
  opacity: 0;
  transform: translateY(14px);
  animation: rise 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  animation-delay: var(--d, 0ms);
}

@keyframes rise {
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .rise { animation: none; opacity: 1; transform: none; }
}
