/* Kronos Finance UX — sticky navigation, cash visualization and statement import.
   This layer intentionally does not own finance persistence or calculations. */

#financeView #kFinanceNav {
  position: sticky;
  top: 8px;
  z-index: 60;
  margin-top: 2px;
  margin-bottom: 12px;
  border-color: color-mix(in srgb, var(--k-fin-border, #dfe2e7) 90%, transparent);
  background: color-mix(in srgb, #f4f4f6 90%, transparent);
  box-shadow: 0 8px 24px rgba(22, 27, 36, 0.06);
  backdrop-filter: blur(16px) saturate(145%);
  -webkit-backdrop-filter: blur(16px) saturate(145%);
}

#financeView .k-finance-v2-subnav.k-finance-ux-hidden-subnav {
  display: none !important;
}

#financeView .k-fin-kpi.is-zero > strong {
  color: var(--k-fin-text, #171a21) !important;
}

#financeView .k-fin-panel.k-fin-empty-panel {
  min-height: 0 !important;
}

#financeView .k-fin-panel.k-fin-empty-panel .k-fin-empty {
  min-height: 64px;
  padding: 14px 0 2px;
}

#financeView .k-fin-period-nav {
  padding: 3px;
  border: 1px solid var(--k-fin-border, #dfe2e7);
  border-radius: 11px;
  background: #fff;
}

#financeView .k-fin-period-nav > button {
  min-width: 30px;
  min-height: 30px;
  background: transparent;
}

#financeView .k-fin-period-nav > strong {
  min-width: 148px;
}

.k-fin-import-entry {
  display: flex;
  justify-content: flex-end;
  margin: 0 0 12px;
}

.k-fin-import-entry button {
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--k-fin-border, #dfe2e7);
  border-radius: 10px;
  background: #fff;
  color: var(--k-fin-text, #171a21);
  font: inherit;
  font-size: 0.76rem;
  font-weight: 720;
  cursor: pointer;
}

/* Cash — replace long technical lists with compact decision surfaces. */
#financeView .k-fin-cash-ranked {
  overflow: hidden;
}

#financeView .k-fin-cash-ranked .fin-timeline {
  display: grid;
  gap: 8px;
}

#financeView .k-fin-cash-ranked .fin-timeline-row {
  position: relative;
  display: grid;
  grid-template-columns: 32px 74px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 46px;
  padding: 7px 10px;
  overflow: hidden;
  border: 1px solid var(--k-fin-border, #dfe2e7);
  border-radius: 11px;
  background: #fff;
}

#financeView .k-fin-cash-ranked .fin-timeline-row::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--k-fin-bar, 0%);
  max-width: 100%;
  background: linear-gradient(90deg, rgba(194, 57, 45, 0.08), rgba(194, 57, 45, 0.025));
  pointer-events: none;
}

#financeView .k-fin-cash-rank {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: #f0f1f3;
  color: var(--k-fin-muted, #69717d);
  font-size: 0.68rem;
  font-weight: 760;
}

#financeView .k-fin-cash-ranked .fin-timeline-date,
#financeView .k-fin-cash-ranked .k-fin-cash-desc,
#financeView .k-fin-cash-ranked .fin-status-pill {
  position: relative;
  z-index: 1;
}

#financeView .k-fin-cash-ranked .fin-timeline-date {
  color: var(--k-fin-muted, #69717d);
  font-size: 0.7rem;
}

#financeView .k-fin-cash-ranked .k-fin-cash-desc {
  min-width: 0;
  overflow: hidden;
  color: var(--k-fin-text, #171a21);
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#financeView .k-fin-cash-ranked .fin-status-pill {
  border-color: rgba(194, 57, 45, 0.22);
  background: rgba(194, 57, 45, 0.06);
  color: var(--k-fin-negative, #c2392d);
}

#financeView .k-fin-cash-empty-compact .fin-empty-state {
  min-height: 0;
  padding: 16px 18px;
  border-style: solid;
  border-color: var(--k-fin-border, #dfe2e7);
  border-radius: 12px;
  background: #fff;
  color: var(--k-fin-muted, #69717d);
  text-align: left;
}

.k-fin-cash-stable {
  display: grid;
  gap: 5px;
  padding: 18px;
  border: 1px solid var(--k-fin-border, #dfe2e7);
  border-radius: 14px;
  background: linear-gradient(135deg, #fff, #fafafb);
}

.k-fin-cash-stable strong {
  color: var(--k-fin-text, #171a21);
  font-size: 1rem;
}

.k-fin-cash-stable span {
  color: var(--k-fin-muted, #69717d);
  font-size: 0.76rem;
  line-height: 1.45;
}

.k-fin-cash-chart {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.k-fin-cash-chart svg {
  width: 100%;
  height: auto;
  min-height: 220px;
  overflow: visible;
}

.k-fin-cash-chart .k-fin-grid-line {
  stroke: #e6e8ec;
  stroke-width: 1;
}

.k-fin-cash-chart .k-fin-area {
  fill: rgba(49, 95, 145, 0.07);
}

.k-fin-cash-chart .k-fin-line {
  fill: none;
  stroke: var(--k-fin-info, #315f91);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.k-fin-cash-chart .k-fin-dot {
  fill: #fff;
  stroke: var(--k-fin-info, #315f91);
  stroke-width: 2.5;
}

.k-fin-cash-chart text {
  fill: var(--k-fin-muted, #69717d);
  font-family: var(--k-font-family, Inter, sans-serif);
  font-size: 12px;
}

.k-fin-cash-change-list {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.k-fin-cash-change-list span {
  flex: 0 0 auto;
  padding: 6px 9px;
  border-radius: 999px;
  background: #f1f2f4;
  color: var(--k-fin-muted, #69717d);
  font-size: 0.68rem;
}

/* Statement import */
#kFinanceImportDialog {
  width: min(1120px, calc(100vw - 34px));
  max-height: calc(100vh - 34px);
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 18px;
  background: #fff;
  color: var(--k-color-text, #171a21);
  box-shadow: 0 24px 80px rgba(17, 24, 39, 0.24);
}

#kFinanceImportDialog::backdrop {
  background: rgba(17, 24, 39, 0.38);
  backdrop-filter: blur(3px);
}

.k-fin-import-shell {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  max-height: calc(100vh - 34px);
}

.k-fin-import-head,
.k-fin-import-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  background: #fff;
}

.k-fin-import-head {
  border-bottom: 1px solid var(--k-color-border, #dfe2e7);
}

.k-fin-import-head h2 {
  margin: 0;
  font-size: 1.05rem;
}

.k-fin-import-head p {
  margin: 4px 0 0;
  color: var(--k-color-text-muted, #69717d);
  font-size: 0.74rem;
}

.k-fin-import-close {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 9px;
  background: #f1f2f4;
  color: #171a21;
  font: inherit;
  cursor: pointer;
}

.k-fin-import-controls {
  display: grid;
  grid-template-columns: minmax(200px, 1.5fr) minmax(140px, .7fr) minmax(180px, 1fr) auto;
  gap: 10px;
  align-items: end;
  padding: 14px 18px;
  border-bottom: 1px solid var(--k-color-border, #dfe2e7);
  background: #fafafb;
}

.k-fin-import-controls label {
  display: grid;
  gap: 5px;
  color: var(--k-color-text-muted, #69717d);
  font-size: 0.69rem;
  font-weight: 650;
}

.k-fin-import-controls input,
.k-fin-import-controls select {
  min-height: 38px;
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--k-color-border, #dfe2e7);
  border-radius: 9px;
  background: #fff;
  color: #171a21;
  font: inherit;
}

.k-fin-import-controls button,
.k-fin-import-footer button,
.k-fin-import-empty button {
  min-height: 38px;
  padding: 8px 12px;
  border: 0;
  border-radius: 9px;
  background: #171a21;
  color: #fff;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
}

.k-fin-import-controls button:disabled,
.k-fin-import-footer button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.k-fin-import-body {
  min-height: 300px;
  overflow: auto;
  padding: 14px 18px 18px;
}

.k-fin-import-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.k-fin-import-summary span {
  padding: 6px 9px;
  border-radius: 999px;
  background: #f1f2f4;
  color: #5f6772;
  font-size: 0.69rem;
  font-weight: 650;
}

.k-fin-import-summary span.is-good { color: #087a43; background: rgba(8,122,67,.08); }
.k-fin-import-summary span.is-warn { color: #9c650d; background: rgba(156,101,13,.09); }
.k-fin-import-summary span.is-bad { color: #c2392d; background: rgba(194,57,45,.08); }

.k-fin-import-warning {
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(156, 101, 13, .22);
  border-radius: 10px;
  background: rgba(156, 101, 13, .06);
  color: #80520b;
  font-size: .72rem;
  line-height: 1.45;
}

.k-fin-import-table-wrap {
  overflow: auto;
  border: 1px solid var(--k-color-border, #dfe2e7);
  border-radius: 12px;
}

.k-fin-import-table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
}

.k-fin-import-table th,
.k-fin-import-table td {
  padding: 8px 9px;
  border-bottom: 1px solid #eceef1;
  text-align: left;
  vertical-align: middle;
}

.k-fin-import-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f7f7f8;
  color: #69717d;
  font-size: .66rem;
  font-weight: 720;
}

.k-fin-import-table td {
  color: #303641;
  font-size: .72rem;
}

.k-fin-import-table tr.is-duplicate td {
  opacity: .62;
  background: #fafafb;
}

.k-fin-import-table tr.is-invalid td {
  background: rgba(194,57,45,.035);
}

.k-fin-import-table .is-income { color: #087a43; font-weight: 720; }
.k-fin-import-table .is-expense { color: #c2392d; font-weight: 720; }

.k-fin-import-table select {
  max-width: 190px;
  min-height: 32px;
  border: 1px solid #dfe2e7;
  border-radius: 8px;
  background: #fff;
  font: inherit;
}

.k-fin-import-empty {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 240px;
  color: #69717d;
  text-align: center;
}

.k-fin-import-empty strong {
  color: #171a21;
}

.k-fin-import-footer {
  border-top: 1px solid var(--k-color-border, #dfe2e7);
}

.k-fin-import-footer small {
  color: #69717d;
  line-height: 1.4;
}

@media (max-width: 760px) {
  #financeView {
    width: min(100%, calc(100vw - 20px)) !important;
  }

  #financeView #kFinanceNav {
    top: 6px;
    display: flex;
    overflow-x: auto;
    padding: 4px;
    scrollbar-width: none;
  }

  #financeView #kFinanceNav::-webkit-scrollbar { display: none; }
  #financeView #kFinanceNav button { flex: 0 0 auto; min-width: 112px; }

  #financeView .k-fin-cash-ranked .fin-timeline-row {
    grid-template-columns: 28px 62px minmax(110px, 1fr) auto;
    gap: 7px;
    padding-inline: 7px;
  }

  .k-fin-cash-chart svg { min-height: 180px; }

  .k-fin-import-controls {
    grid-template-columns: 1fr;
  }

  .k-fin-import-head,
  .k-fin-import-footer {
    align-items: flex-start;
  }

  .k-fin-import-footer {
    flex-direction: column;
  }

  .k-fin-import-footer button { width: 100%; }
}
