/* ============================================================
   Components — cards, buttons, inputs, chips, table, insights
   ============================================================ */

/* Card */
.card {
  background: var(--surface);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--sp-5);
  transition: box-shadow var(--dur-mid) var(--ease-out),
    transform var(--dur-mid) var(--ease-spring),
    border-color var(--dur-mid) var(--ease-out);
}
.card--hover {
  transition: box-shadow var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-spring),
    border-color var(--dur-fast) var(--ease-out);
}
.card--hover:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--border-strong);
}
.card__title {
  font-size: 13px; font-weight: 600; color: var(--text-2);
  letter-spacing: 0.01em; text-transform: none;
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--sp-3);
}

/* KPI card */
.kpi { position: relative; overflow: hidden; }
.kpi__label { font-size: 13px; color: var(--text-2); font-weight: 500; }
.kpi__value {
  font-size: 30px; font-weight: 700; letter-spacing: -0.03em;
  margin-top: var(--sp-2); line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.kpi__value small { font-size: 16px; font-weight: 600; color: var(--text-2); }
.kpi__delta {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: var(--sp-2); font-size: 12.5px; font-weight: 600;
  padding: 2px 8px; border-radius: var(--r-pill);
}
.kpi__delta.up { color: var(--neg); background: rgba(255, 59, 48, 0.12); }
.kpi__delta.down { color: var(--pos); background: rgba(52, 199, 89, 0.14); }
.kpi__delta.flat { color: var(--text-2); background: var(--surface-2); }
.kpi__sub { font-size: 12px; color: var(--text-3); margin-top: 6px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px;
  border-radius: var(--r-pill);
  font-size: 13.5px; font-weight: 550;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  transition: transform var(--dur-fast) var(--ease-spring),
    background var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast);
}
.btn:hover { background: var(--surface-solid); box-shadow: var(--shadow-sm); }
.btn:active { transform: scale(0.96); }
.btn--primary {
  background: var(--accent); color: #fff; border-color: transparent;
}
.btn--primary:hover { background: var(--accent-hover); }
.btn--icon { padding: 8px; width: 38px; height: 38px; justify-content: center; }
.btn--ghost { background: transparent; }

/* Segmented control */
.segmented {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-pill);
}
.segmented button {
  padding: 6px 14px; font-size: 13px; font-weight: 550;
  border-radius: var(--r-pill); color: var(--text-2);
  transition: color var(--dur-fast), background var(--dur-fast);
}
.segmented button.is-active {
  background: var(--surface-solid); color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* Form controls */
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label {
  font-size: 12px; font-weight: 600; color: var(--text-2);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.input, .select {
  width: 100%;
  padding: 9px 12px;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
  font-size: 14px;
}
.input:focus, .select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input--search { padding-left: 34px; }
.search-wrap { position: relative; }
.search-wrap svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-3); }

.range-row { display: flex; align-items: center; gap: var(--sp-2); }
.range-row .input { flex: 1; }
.range-row span { color: var(--text-3); font-size: 13px; }

/* Chips (category filter) */
.chips { display: flex; flex-wrap: wrap; gap: 6px; max-height: 220px; overflow-y: auto; padding-right: 4px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; font-size: 12.5px; font-weight: 550;
  border-radius: var(--r-pill);
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-2);
  transition: all var(--dur-fast) var(--ease-out);
  user-select: none;
}
.chip:hover { border-color: var(--border-strong); }
.chip.is-active {
  background: var(--accent); color: #fff;
  border-color: transparent;
}
.chip.is-active .chip__dot { box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.55); }
.chip__dot { width: 8px; height: 8px; border-radius: 50%; }

/* Rail group */
.rail__group { display: flex; flex-direction: column; gap: var(--sp-3); }
.rail__title {
  font-size: 12px; font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.06em;
  display: flex; align-items: center; justify-content: space-between;
}
.rail__reset {
  font-size: 12px; font-weight: 600; color: var(--accent);
  background: none; padding: 0;
}

/* Chart canvas holder */
.chart-box { position: relative; height: 300px; }
.chart-box--tall { height: 360px; }
.chart-box--short { height: 240px; }

/* Insights */
.insights { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--sp-3); }
.insight {
  display: flex; gap: var(--sp-3); align-items: flex-start;
  padding: var(--sp-4);
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: transform var(--dur-mid) var(--ease-spring);
}
.insight:hover { transform: translateY(-2px); }
.insight__icon {
  flex: none; width: 38px; height: 38px; border-radius: 11px;
  display: grid; place-items: center; font-size: 19px;
  background: var(--accent-soft);
}
.insight__body { min-width: 0; }
.insight__title { font-size: 13.5px; font-weight: 650; margin-bottom: 2px; }
.insight__text { font-size: 13px; color: var(--text-2); }
.insight__text b { color: var(--text); font-weight: 650; }

/* Table */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
}
table.tx {
  width: 100%; border-collapse: collapse; font-size: 13.5px;
  min-width: 640px;
}
table.tx thead th {
  position: sticky; top: 0;
  text-align: left; font-weight: 600; color: var(--text-2);
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em;
  padding: 12px 14px;
  background: var(--surface-solid);
  border-bottom: 1px solid var(--border);
  cursor: pointer; user-select: none; white-space: nowrap;
}
table.tx thead th .arrow { opacity: 0.4; margin-left: 4px; font-size: 10px; }
table.tx thead th.sorted .arrow { opacity: 1; color: var(--accent); }
table.tx tbody td {
  padding: 11px 14px; border-bottom: 1px solid var(--border);
  color: var(--text); white-space: nowrap;
}
table.tx tbody tr { transition: background var(--dur-fast); }
table.tx tbody tr:hover { background: var(--surface-2); }
table.tx tbody tr:last-child td { border-bottom: none; }
.tx .amt { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.tx .amt.expense { color: var(--text); }
.tx .amt.income { color: var(--pos); }
.tag {
  display: inline-block; padding: 2px 9px; border-radius: var(--r-pill);
  font-size: 11.5px; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--border);
}
.tag--cat { display: inline-flex; align-items: center; gap: 6px; }

/* Pagination */
.pager {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3); margin-top: var(--sp-3); flex-wrap: wrap;
}
.pager__info { font-size: 13px; color: var(--text-2); }
.pager__controls { display: flex; align-items: center; gap: var(--sp-2); }

/* Toast */
.toast-host {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.toast {
  padding: 11px 18px; border-radius: var(--r-pill);
  background: var(--surface-solid); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); font-size: 13.5px; font-weight: 550;
  display: flex; align-items: center; gap: 8px;
  animation: toast-in var(--dur-mid) var(--ease-spring);
}
.toast.err { color: var(--neg); }
.toast.ok { color: var(--pos); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Upload modal */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  display: none; place-items: center;
  padding: var(--sp-4);
  background: rgba(0, 0, 0, 0.42);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.modal-overlay.is-open { display: grid; animation: fade-in var(--dur-mid) var(--ease-out); }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  position: relative;
  width: min(520px, 94vw);
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--sp-6);
  animation: pop var(--dur-mid) var(--ease-spring);
}
.modal-close {
  position: absolute; top: 14px; right: 16px;
  width: 34px; height: 34px; border-radius: 50%;
  font-size: 22px; line-height: 1; color: var(--text-2);
  display: grid; place-items: center;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }
.upload-drop {
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-3);
  text-align: center;
  padding: var(--sp-10) var(--sp-6);
  border: 2px dashed var(--border-strong);
  border-radius: var(--r-lg);
  transition: border-color var(--dur-fast), background var(--dur-fast);
}
.upload-drop.is-hot { border-color: var(--accent); background: var(--accent-soft); }
.upload-drop__icon {
  width: 64px; height: 64px; border-radius: 18px;
  display: grid; place-items: center; color: var(--accent);
  background: var(--accent-soft); margin-bottom: var(--sp-1);
}
.upload-drop h3 { font-size: 20px; }
.upload-drop__sub { color: var(--text-2); font-size: 14px; }
.upload-drop__btn { margin-top: var(--sp-1); cursor: pointer; }
.upload-drop__hint { color: var(--text-3); font-size: 12px; margin-top: var(--sp-2); max-width: 340px; }

/* Dropzone (upload overlay) */
.dropzone {
  position: fixed; inset: 0; z-index: 150;
  display: none; place-items: center;
  background: rgba(0,0,0,0.35);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.dropzone.is-visible { display: grid; }
.dropzone__inner {
  padding: 60px 80px; border-radius: var(--r-xl);
  border: 2.5px dashed var(--accent);
  background: var(--surface-solid);
  text-align: center; box-shadow: var(--shadow-lg);
  animation: pop var(--dur-mid) var(--ease-spring);
}
.dropzone__inner h3 { font-size: 22px; margin-bottom: 8px; }
.dropzone__inner p { color: var(--text-2); }
@keyframes pop { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Empty state */
.empty { text-align: center; padding: var(--sp-10); color: var(--text-2); }

/* Reveal-on-load animation */
.reveal { opacity: 0; transform: translateY(14px); }
.reveal.in {
  opacity: 1; transform: none;
  transition: opacity var(--dur-slow) var(--ease-out),
    transform var(--dur-slow) var(--ease-spring);
}

/* Transactions filter toolbar */
.txbar {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--sp-3);
  padding-bottom: var(--sp-4); margin-bottom: var(--sp-4);
  border-bottom: 1px solid var(--border);
}
.txbar__field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.txbar__label {
  font-size: 11px; font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.txbar__spacer { flex: 1 1 auto; }
.select--sm { padding: 7px 10px; font-size: 13px; min-width: 116px; }
.txbar .input { padding: 7px 10px; font-size: 13px; min-width: 150px; }
.txbar .btn { align-self: flex-end; }

/* Focus banner (drill-down indicator) */
.focus-banner {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3); padding: 12px 18px;
  border-radius: var(--r-md);
  background: var(--accent-soft);
  border: 1px solid transparent;
  animation: banner-in var(--dur-mid) var(--ease-spring);
}
.focus-banner__label { font-size: 14px; color: var(--text); }
.focus-banner__label b { color: var(--accent); font-weight: 700; }
@keyframes banner-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

/* Loading shimmer */
.loading-bar {
  position: fixed; top: 0; left: 0; height: 2.5px; width: 0;
  background: linear-gradient(90deg, var(--accent), #5ac8fa);
  z-index: 300; transition: width var(--dur-slow) var(--ease-out), opacity var(--dur-mid);
  box-shadow: 0 0 8px var(--accent);
}
