/* ==========================================================
   korAccount Web stylesheet
   Sections: fonts, design tokens (light and dark), base,
   Blazor infrastructure, welcome and storage setup, app shell
   (rail, drawer, header), form primitives, settings, dashboard,
   import wizard, bank download and download setup guide.
   ========================================================== */

/* --- Fonts: IBM Plex (self-hosted, OFL-1.1 — see fonts/OFL.txt) --- */
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/IBMPlexSans-Regular-Latin1.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/IBMPlexSans-Medium-Latin1.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/IBMPlexSans-SemiBold-Latin1.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/IBMPlexSans-Bold-Latin1.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/IBMPlexMono-Regular-Latin1.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/IBMPlexMono-Medium-Latin1.woff2") format("woff2");
}

/* --- Design tokens ---
   Colours, type sizes and radii. The dark theme redefines only the colours; it follows the
   system unless the page sets data-theme on <html>. */
:root {
  color-scheme: light;

  --font-sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --fs-xs: 11px;
  --fs-sm: 12px;
  --fs-md: 13px;
  --fs-base: 14px;
  --fs-lg: 16px;
  --fs-xl: 20px;
  --fs-2xl: 30px;

  --c-primary: #3370c7;
  --c-primary-hover: #1a52a1;
  --c-primary-100: #b9d3f9;
  --c-primary-200: #8bb5ef;
  --c-primary-300: #70a6f5;
  --c-on-primary: #ffffff;
  --c-accent: #da7a3f;

  --c-mark-large: #1a52a1;
  --c-mark-middle: #3370c7;
  --c-mark-small: #6d9adc;
  --c-mark-piece: #da7a3f;

  --c-text: #0f172a;
  --c-text-2: #475569;
  --c-text-3: #5f6d82;
  /* Even the faintest text reaches 4.5 : 1 on every surface and tint, as WCAG AA asks of small text. */
  --c-text-4: #647186;

  --c-neg: #d92d20;
  --c-neg-bg: #fdeceb;
  --c-pos: #067647;
  --c-pos-bg: #e7f5ee;
  --c-warn: #b54708;
  --c-warn-bg: #fef4e6;
  --c-chip-bg: #f0f6fd;
  --c-chip-bg-hover: #dce9fc;
  --c-mark: #fee1d2;

  --c-surface: #ffffff;
  --c-surface-2: #f8fafc;
  --c-surface-raised: #ffffff;
  --c-track: #eef1f4;
  --c-seg-bg: #f1f5f9;
  --c-border: #e6e8ec;
  --c-border-2: #eef1f4;
  --c-input-border: #e2e8f0;
  --c-row-hover: #f8fafc;
  --c-row-sel-bg: #f0f6fd;
  --c-row-sel-border: #dce9fc;
  --c-dark: #0f172a;
  --c-overlay: rgba(15, 23, 42, .32);
  --c-scrollbar: #e2e8f0;
  --c-scrollbar-hover: #94a3b8;

  --r-card: 11px;
  --r-input: 8px;
  --r-chip: 6px;
  --r-nav: 8px;
  --r-pill: 20px;

  --focus-ring: 0 0 0 3px rgba(51, 112, 199, .14);
  --sh-menu: 0 8px 24px rgba(15, 23, 42, .12);
  --sh-cmdk: 0 6px 20px rgba(51, 112, 199, .13);
  --sh-fab: 0 5px 14px rgba(51, 112, 199, .4);
  --sh-sticky: 0 2px 4px rgba(15, 23, 42, .05);

  --nav-w: 212px;
  --nav-w-collapsed: 56px;
  --panel-w: 384px;
}

/* Dark colours, set once for the system preference and once for an explicit choice. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --c-primary: #4c80cd;
    --c-mark-large: #4c80cd;
    --c-mark-middle: #70a6f5;
    --c-mark-small: #abcdfe;
    --c-mark-piece: #f9a870;
    --c-primary-hover: #70a6f5;
    --c-primary-100: #112d55;
    --c-primary-200: #1a52a1;
    --c-primary-300: #70a6f5;
    --c-text: #e6e8ec;
    --c-text-2: #c3c9d4;
    --c-text-3: #9aa3b2;
    --c-text-4: #8a93a3;
    --c-neg: #f97066;
    --c-neg-bg: #3a1d1b;
    --c-pos: #47cd89;
    --c-pos-bg: #13301f;
    --c-warn: #fdb022;
    --c-warn-bg: #3a2a0f;
    --c-chip-bg: #14233d;
    --c-chip-bg-hover: #18417c;
    --c-mark: #5a3118;
    --c-surface: #111318;
    --c-surface-2: #171a21;
    --c-surface-raised: #1c2028;
    --c-track: #232832;
    --c-seg-bg: #1e222b;
    --c-border: #2a303b;
    --c-border-2: #20252e;
    --c-input-border: #323946;
    --c-row-hover: #181c24;
    --c-row-sel-bg: #132036;
    --c-row-sel-border: #18417c;
    --c-dark: #05070a;
    --c-overlay: rgba(0, 0, 0, .55);
    --c-scrollbar: #2a303b;
    --c-scrollbar-hover: #4a5262;
    --focus-ring: 0 0 0 3px rgba(112, 166, 245, .3);
    --sh-menu: 0 8px 24px rgba(0, 0, 0, .5);
    --sh-cmdk: 0 6px 20px rgba(0, 0, 0, .4);
    --sh-fab: 0 5px 14px rgba(0, 0, 0, .5);
    --sh-sticky: 0 2px 4px rgba(0, 0, 0, .3);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --c-primary: #4c80cd;
  --c-mark-large: #4c80cd;
  --c-mark-middle: #70a6f5;
  --c-mark-small: #abcdfe;
  --c-mark-piece: #f9a870;
  --c-primary-hover: #70a6f5;
  --c-primary-100: #112d55;
  --c-primary-200: #1a52a1;
  --c-primary-300: #70a6f5;
  --c-text: #e6e8ec;
  --c-text-2: #c3c9d4;
  --c-text-3: #9aa3b2;
  --c-text-4: #8a93a3;
  --c-neg: #f97066;
  --c-neg-bg: #3a1d1b;
  --c-pos: #47cd89;
  --c-pos-bg: #13301f;
  --c-warn: #fdb022;
  --c-warn-bg: #3a2a0f;
  --c-chip-bg: #14233d;
  --c-chip-bg-hover: #18417c;
  --c-mark: #5a3118;
  --c-surface: #111318;
  --c-surface-2: #171a21;
  --c-surface-raised: #1c2028;
  --c-track: #232832;
  --c-seg-bg: #1e222b;
  --c-border: #2a303b;
  --c-border-2: #20252e;
  --c-input-border: #323946;
  --c-row-hover: #181c24;
  --c-row-sel-bg: #132036;
  --c-row-sel-border: #18417c;
  --c-dark: #05070a;
  --c-overlay: rgba(0, 0, 0, .55);
  --c-scrollbar: #2a303b;
  --c-scrollbar-hover: #4a5262;
  --focus-ring: 0 0 0 3px rgba(112, 166, 245, .3);
  --sh-menu: 0 8px 24px rgba(0, 0, 0, .5);
  --sh-cmdk: 0 6px 20px rgba(0, 0, 0, .4);
  --sh-fab: 0 5px 14px rgba(0, 0, 0, .5);
  --sh-sticky: 0 2px 4px rgba(0, 0, 0, .3);
}

/* --- Base --- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  color: var(--c-text);
  background: var(--c-surface);
}

#app { height: 100vh; }

h1:focus { outline: none; }

code { color: var(--c-text-2); }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--c-scrollbar); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--c-scrollbar-hover); }

/* --- Blazor infrastructure --- */
#blazor-error-ui {
  background: var(--c-surface-raised);
  border-top: 2px solid var(--c-neg);
  bottom: 0;
  box-shadow: var(--sh-menu);
  box-sizing: border-box;
  display: none;
  left: 0;
  padding: 0.6rem 1.25rem 0.7rem 1.25rem;
  position: fixed;
  width: 100%;
  z-index: 1000;
  color: var(--c-text);
  font-size: var(--fs-base);
}

#blazor-error-ui .reload {
  color: var(--c-primary);
  text-decoration: underline;
}

#blazor-error-ui .dismiss {
  cursor: pointer;
  position: absolute;
  right: 0.75rem;
  top: 0.5rem;
  opacity: 0.5;
}

.blazor-error-boundary {
  background: var(--c-neg-bg);
  padding: 1rem;
  color: var(--c-neg);
  border-radius: var(--r-input);
}

.blazor-error-boundary::after { content: "Ein Fehler ist aufgetreten."; }

/* --- Welcome and storage setup --- */
.welcome-full-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 4rem 1.5rem 3rem;
  gap: 2.5rem;
  background: var(--c-surface);
}

.welcome-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
  gap: 1rem;
}

.welcome-container h1 {
  font-size: var(--fs-2xl);
  font-weight: 900;
  letter-spacing: -0.04em;
  color: var(--c-text);
  margin: 0;
}

.welcome-hero { text-align: center; }

.welcome-tagline {
  font-size: var(--fs-lg);
  color: var(--c-text-2);
  margin: 0;
  font-weight: 400;
}

.storage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 360px));
  gap: 1rem;
  justify-content: center;
  width: 100%;
  max-width: 1100px;
}

.storage-card {
  background: var(--c-surface);
  border: 1.5px solid var(--c-input-border);
  border-radius: 16px;
  padding: 1.5rem;
  display: flex;
  gap: 1.125rem;
  align-items: flex-start;
  box-shadow: var(--sh-sticky);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.storage-card:hover {
  border-color: var(--c-text-4);
  box-shadow: var(--sh-menu);
}

.storage-card-connected {
  border-color: var(--c-primary);
  background: linear-gradient(135deg, var(--c-chip-bg) 0%, var(--c-surface) 100%);
}

.storage-icon-box {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: var(--r-card);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: var(--fs-xl);
}

.storage-icon-box.local-icon    { background: var(--c-pos-bg); }
.storage-icon-box.onedrive-icon { background: var(--c-chip-bg); }
.storage-icon-box.google-icon   { background: var(--c-warn-bg); }

.storage-card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0;
}

.provider-badge {
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--c-text-4);
}

.storage-card-title {
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--c-text);
  margin: 0;
  letter-spacing: -0.01em;
}

.storage-card-desc {
  font-size: var(--fs-md);
  color: var(--c-text-2);
  margin: 0;
  line-height: 1.5;
}

.folder-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  background: var(--c-chip-bg);
  color: var(--c-primary-hover);
  border: 1px solid color-mix(in srgb, var(--c-primary) 25%, transparent);
  border-radius: var(--r-chip);
  padding: 0.25rem 0.625rem;
  font-size: var(--fs-sm);
  font-weight: 600;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 0.125rem;
}

/* Full page while the app starts and while the data opens: the mark with its piece moving in
   and out (AppLogo Loading), the progress or a line of text below it. */
.page-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  gap: 1.25rem;
}

.page-loading-text {
  color: var(--c-text-2);
  font-size: var(--fs-base);
  margin: 0;
}

.page-loading-progress::after { content: var(--blazor-load-percentage-text, ""); }

@media (max-width: 767px) {
  .welcome-full-page { padding: 2.5rem 1rem 2rem; gap: 2rem; }
  .storage-grid { grid-template-columns: 1fr; }
  .storage-card { max-width: 100%; }
}

.tnum { font-variant-numeric: tabular-nums; }

/* --- Logo --- */
.app-logo {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.app-logo-mark { flex: none; }
.app-logo-mark .mark-large { fill: var(--c-mark-large); }
.app-logo-mark .mark-middle { fill: var(--c-mark-middle); }
.app-logo-mark .mark-small { fill: var(--c-mark-small); }
.app-logo-mark .mark-piece { fill: var(--c-mark-piece); }
.app-logo-dark { --c-mark-large: #4c80cd; --c-mark-middle: #70a6f5; --c-mark-small: #abcdfe; --c-mark-piece: #f9a870; }
.app-logo-mono .app-logo-mark path { fill: currentColor; }

/* Loading: the lifted piece settles into the pie and lifts out again. It moves back along its
   bisector by the lift of the construction (8 units at 36 degrees, brands/koraccount/build.mjs). */
.mark-loading .mark-piece { animation: mark-settle 2.4s cubic-bezier(.45, 0, .55, 1) infinite; }

@keyframes mark-settle {
  0%, 15% { transform: none; }
  45%, 70% { transform: translate(-4.7px, 6.47px); }
  100% { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .mark-loading .mark-piece { animation: mark-breathe 2.4s ease-in-out infinite; }
}

@keyframes mark-breathe { 50% { opacity: .4; } }

.app-logo-wordmark {
  font-size: var(--fs-lg);
  font-weight: 400;
  color: var(--c-text-2);
  letter-spacing: -.01em;
}

.app-logo-wordmark b { font-weight: 700; }

.app-logo-dark .app-logo-wordmark { color: var(--c-on-primary); opacity: .85; }
.app-logo-dark .app-logo-wordmark b { color: var(--c-on-primary); opacity: 1; }

/* --- Icons --- */
.icon {
  flex: none;
  vertical-align: -0.125em;
}

/* --- Shell layout --- */
.shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--c-surface);
}

.shell-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.shell-content {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.onboarding-main { min-height: 100vh; }

/* --- Desktop rail --- */
.rail {
  width: var(--nav-w);
  flex: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--c-surface-2);
  border-right: 1px solid var(--c-border);
  padding: 16px 0 14px;
  overflow-y: auto;
}

.shell.nav-collapsed .rail { width: var(--nav-w-collapsed); }

.rail-logo {
  display: flex;
  align-items: center;
  padding: 0 16px 16px;
  text-decoration: none;
}

.shell.nav-collapsed .rail-logo { justify-content: center; padding: 0 0 12px; }

.rail-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 10px;
}

.rail-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--r-nav);
  font-size: var(--fs-base);
  color: var(--c-text-2);
  text-decoration: none;
  white-space: nowrap;
}

.rail-item:hover { background: var(--c-track); color: var(--c-text); }

.rail-item.is-active {
  background: var(--c-primary);
  color: var(--c-on-primary);
  font-weight: 600;
}

.shell.nav-collapsed .rail-nav { padding: 0 10px; align-items: center; }
.shell.nav-collapsed .rail-item { width: 36px; height: 36px; padding: 0; justify-content: center; }
.shell.nav-collapsed .rail-item-label { display: none; }

.rail-item-icononly {
  width: 36px;
  height: 36px;
  padding: 0;
  justify-content: center;
}

.rail-group-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--c-text-4);
  padding: 20px 20px 8px;
}

.rail-accounts {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 0 10px;
}

.rail-account {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 7px;
  font-size: var(--fs-base);
  color: var(--c-text-2);
  text-decoration: none;
}

.rail-account:hover { background: var(--c-track); color: var(--c-text); }
.rail-account.is-active { background: var(--c-primary); color: var(--c-on-primary); font-weight: 600; }
.rail-account.is-active .rail-dot { background: var(--c-on-primary); }
.rail-account.is-active .rail-account-balance,
.drawer-item.is-active .rail-account-balance { color: inherit; }
.drawer-item.is-active .rail-dot { background: var(--c-on-primary); }

.rail-account-balance {
  margin-left: auto;
  padding-left: 8px;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--c-text-4);
  white-space: nowrap;
}

.rail-account-balance.is-neg { color: var(--c-neg); }

.rail-sep { height: 1px; margin: 14px 20px 10px; background: var(--c-border); }

.shell.nav-collapsed .rail-group-label { padding: 14px 0 6px; text-align: center; font-size: 0; }
.shell.nav-collapsed .rail-group-label::after { content: ""; display: block; width: 20px; height: 1px; margin: 0 auto; background: var(--c-border); }
.shell.nav-collapsed .rail-accounts { align-items: center; padding: 0; gap: 4px; }
.shell.nav-collapsed .rail-account { width: 36px; height: 36px; padding: 0; justify-content: center; }
.shell.nav-collapsed .rail-sep { margin: 10px 14px; }

.rail-account-badge {
  font-size: var(--fs-sm);
  font-weight: 700;
  letter-spacing: -.01em;
}

.drawer-item-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.rail-account-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rail-account-add { color: var(--c-text-3); }

.rail-dot {
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: color-mix(in srgb, var(--c-text-4) 60%, transparent);
}

.rail-dot.is-active { background: var(--c-primary); }
.rail-dot.is-negative { background: color-mix(in srgb, var(--c-neg) 35%, transparent); }

.rail-footer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 14px 0;
  border-top: 1px solid var(--c-border);
  margin-top: 14px;
}

.shell.nav-collapsed .rail-footer { align-items: center; padding: 12px 0 0; }

.rail-user {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.rail-avatar {
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 50%;
  background: var(--c-primary);
  color: var(--c-on-primary);
  font-size: var(--fs-sm);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rail-username {
  flex: 1;
  min-width: 0;
  font-size: var(--fs-base);
  font-weight: 500;
  color: var(--c-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rail-settings-btn {
  width: 32px;
  height: 32px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--c-border);
  border-radius: var(--r-nav);
  background: var(--c-surface);
  color: var(--c-text-2);
  text-decoration: none;
}

.rail-settings-btn:hover { border-color: var(--c-primary); color: var(--c-primary); }

.rail-collapse-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: flex-end;
  border: 1px solid var(--c-border);
  border-radius: var(--r-nav);
  background: var(--c-surface);
  color: var(--c-primary);
  cursor: pointer;
}

.shell.nav-collapsed .rail-collapse-btn { align-self: center; }

/* --- Save indicator --- */
.save-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: var(--fs-sm);
  color: var(--c-pos);
  opacity: 0;
  transition: opacity .25s ease;
  pointer-events: none;
  min-height: 17px;
}

.save-indicator.is-visible { opacity: 1; }
.save-indicator-error { background: var(--c-neg-bg); color: var(--c-neg); }

/* --- Save problem bar: stays until the changes are saved or given up --- */
.save-problem {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 12px 16px 0;
  padding: 12px 14px;
  border: 1px solid var(--c-neg);
  border-radius: 10px;
  background: var(--c-neg-bg);
  color: var(--c-text);
  font-size: var(--fs-md);
}

.save-problem > svg { color: var(--c-neg); flex-shrink: 0; margin-top: 2px; }
.save-problem-body { flex: 1; min-width: 0; }
.save-problem-body p { margin: 0 0 6px; overflow-wrap: anywhere; }
.save-problem-title { font-weight: 600; }
.save-problem-detail { color: var(--c-neg); }
.save-problem-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

/* --- Mobile header --- */
.mobile-header {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--c-border);
  background: var(--c-surface);
}

.mobile-menu-btn {
  width: 44px;
  height: 44px;
  margin: -6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: none;
  color: var(--c-text);
  cursor: pointer;
}

.mobile-title {
  flex: 1;
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--c-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-balance {
  font-size: var(--fs-base);
  font-weight: 700;
  color: var(--c-text);
}

.mobile-balance.is-negative { color: var(--c-neg); }

/* --- Mobile full-page drawer --- */
.drawer {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  background: var(--c-surface);
  padding: 12px 0 14px;
  overflow-y: auto;
}

body.drawer-open { overflow: hidden; }

.drawer-head {
  display: flex;
  align-items: center;
  padding: 10px 18px 14px;
}

.drawer-close {
  margin-left: auto;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: none;
  color: var(--c-text-3);
  cursor: pointer;
}

.drawer-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 12px;
}

.drawer-item {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 12px 14px;
  border-radius: 9px;
  font-size: var(--fs-lg);
  color: var(--c-text-2);
  text-decoration: none;
}

.drawer-item.is-active {
  background: var(--c-primary);
  color: var(--c-on-primary);
  font-weight: 600;
}

.drawer-item-add { color: var(--c-text-3); }

.drawer-footer {
  margin-top: auto;
  padding: 12px 12px 0;
  border-top: 1px solid var(--c-border);
}

/* --- Coming soon --- */
.coming-soon {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 14px;
  padding: 80px 24px;
}

.coming-soon-title {
  font-size: var(--fs-xl);
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--c-text);
  margin: 0;
}

.coming-soon-text {
  font-size: var(--fs-base);
  color: var(--c-text-3);
  max-width: 380px;
  margin: 0;
}

/* --- Form / button primitives --- */
.k-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-input);
  background: var(--c-surface);
  color: var(--c-text-2);
  font-size: var(--fs-base);
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  text-decoration: none;
}

.k-btn:hover { border-color: var(--c-text-4); color: var(--c-text); }

.k-btn-primary {
  background: var(--c-primary);
  border-color: var(--c-primary);
  color: var(--c-on-primary);
}

.k-btn-primary:hover { background: var(--c-primary-hover); border-color: var(--c-primary-hover); color: var(--c-on-primary); }

.k-btn-danger-link {
  border: 0;
  background: none;
  color: var(--c-neg);
  font-size: var(--fs-md);
  cursor: pointer;
}

.k-icon-btn {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--c-border);
  border-radius: 7px;
  background: var(--c-surface);
  color: var(--c-text-3);
  cursor: pointer;
}

.k-icon-btn:hover { border-color: var(--c-primary); color: var(--c-primary); }
.k-icon-btn-danger:hover { border-color: var(--c-neg); color: var(--c-neg); }

.k-field { display: flex; flex-direction: column; gap: 6px; }

.k-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--c-text-4);
}

.k-label-hint {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 6px;
  color: var(--c-primary);
  letter-spacing: 0;
  text-transform: none;
}

.k-input {
  padding: 10px 11px;
  border: 1px solid var(--c-input-border);
  border-radius: var(--r-input);
  background: var(--c-surface);
  font-size: var(--fs-base);
  font-family: var(--font-sans);
  color: var(--c-text);
}

.k-input:focus {
  outline: none;
  border: 1.5px solid var(--c-primary);
  box-shadow: var(--focus-ring);
  padding: 9.5px 10.5px;
}

.k-chip {
  display: inline-flex;
  align-items: center;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--c-primary);
  background: var(--c-chip-bg);
  border-radius: var(--r-chip);
  padding: 3px 8px;
  white-space: nowrap;
}

.k-chip-pos { color: var(--c-pos); background: var(--c-pos-bg); }

.k-error {
  font-size: var(--fs-md);
  color: var(--c-neg);
  background: var(--c-neg-bg);
  border-radius: var(--r-input);
  padding: 8px 11px;
}

.k-btn-danger {
  background: var(--c-neg);
  border-color: var(--c-neg);
  color: var(--c-on-primary);
}

.k-btn-danger:hover { filter: brightness(1.08); color: var(--c-on-primary); border-color: var(--c-neg); }

.k-btn:disabled { opacity: .5; cursor: default; }

.k-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

kbd {
  display: inline-block;
  min-width: 18px;
  padding: 1px 5px;
  border: 1px solid var(--c-border);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--c-surface);
  font: 500 var(--fs-xs) var(--font-mono);
  color: var(--c-text-4);
  text-align: center;
}

.settings-radios { display: inline-flex; gap: 4px; padding: 4px; border-radius: var(--r-input); background: var(--c-seg-bg); }

.settings-radio {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--c-text-3);
  cursor: pointer;
}

.settings-radio input { position: absolute; opacity: 0; pointer-events: none; }
.settings-radio.is-active { background: var(--c-surface); color: var(--c-text); box-shadow: var(--sh-sticky); }
.settings-radio:focus-within { box-shadow: var(--focus-ring); }

/* --- Toast --- */
.k-toast-region {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 300;
  pointer-events: none;
}

.k-toast {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 260px;
  max-width: min(520px, calc(100vw - 24px));
  padding: 8px 8px 8px 16px;
  border-radius: var(--r-card);
  background: var(--c-dark);
  color: var(--c-on-primary);
  box-shadow: var(--sh-menu);
  font-size: var(--fs-base);
  pointer-events: auto;
  animation: k-toast-in .18s ease-out;
}

:root[data-theme="dark"] .k-toast { background: var(--c-surface-raised); color: var(--c-text); border: 1px solid var(--c-border); }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .k-toast { background: var(--c-surface-raised); color: var(--c-text); border: 1px solid var(--c-border); }
}

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

.k-toast-text { flex: 1; }

.k-toast-action {
  border: 0;
  background: none;
  padding: 6px 8px;
  border-radius: 6px;
  font: 700 var(--fs-base) var(--font-sans);
  color: var(--c-primary-300);
  cursor: pointer;
}

.k-toast-action:hover { background: color-mix(in srgb, var(--c-primary) 22%, transparent); }

.k-toast-close {
  display: inline-flex;
  border: 0;
  background: none;
  padding: 6px;
  border-radius: 6px;
  color: inherit;
  opacity: .7;
  cursor: pointer;
}

.k-toast-close:hover { opacity: 1; }

/* --- Dialog --- */
.k-dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--c-border);
  border-radius: 14px;
  background: var(--c-surface-raised);
  color: var(--c-text);
  box-shadow: var(--sh-menu);
}

.k-dialog::backdrop { background: var(--c-overlay); }

.k-dialog-form { display: flex; flex-direction: column; gap: 14px; padding: 20px; margin: 0; }
.k-dialog-title { margin: 0; font-size: var(--fs-lg); font-weight: 700; }
.k-dialog-body { font-size: var(--fs-base); color: var(--c-text-2); line-height: 1.5; }
.k-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* --- Settings page --- */
.settings-page {
  max-width: 760px;
  margin: 0 auto;
  padding: 26px 22px 60px;
}

.settings-title {
  font-size: var(--fs-xl);
  font-weight: 700;
  letter-spacing: -.01em;
  margin: 0 0 16px;
}

.settings-tabs {
  display: inline-flex;
  gap: 3px;
  background: var(--c-seg-bg);
  border-radius: 9px;
  padding: 3px;
  margin-bottom: 18px;
}

.settings-tab {
  padding: 6px 14px;
  border: 0;
  border-radius: 6px;
  background: none;
  font-size: var(--fs-md);
  font-weight: 600;
  font-family: var(--font-sans);
  color: var(--c-text-3);
  cursor: pointer;
}

.settings-tab.is-active {
  background: var(--c-surface);
  color: var(--c-primary);
  box-shadow: var(--sh-sticky);
}

.settings-card {
  border: 1px solid var(--c-border-2);
  border-radius: 12px;
  background: var(--c-surface);
  padding: 16px 18px;
}

.settings-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.settings-card-title {
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: -.01em;
  margin: 0;
}

.settings-card-foot {
  font-size: var(--fs-sm);
  color: var(--c-text-4);
  padding-top: 10px;
  border-top: 1px solid var(--c-border-2);
  margin-top: 8px;
}

.settings-hint {
  font-size: var(--fs-base);
  color: var(--c-text-3);
  margin: 0 0 14px;
}

.cat-list { display: flex; flex-direction: column; }

.cat-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 2px;
  border-bottom: 1px solid var(--c-border-2);
}

.cat-row:last-child { border-bottom: 0; }

.cat-row.is-sub { padding-left: 26px; }

.cat-row-name {
  flex: 1;
  font-size: var(--fs-base);
  font-weight: 500;
  color: var(--c-text);
}

.cat-row-actions { display: flex; gap: 6px; }

.cat-form {
  display: grid;
  grid-template-columns: 1fr 160px;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--c-border-2);
  border-radius: var(--r-card);
  background: var(--c-surface-2);
  margin-bottom: 12px;
}

.cat-form-wide { grid-column: 1 / -1; }

.cat-form-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 9px;
}

/* --- Responsive shell --- */
@media (max-width: 767px) {
  .rail { display: none; }
  .mobile-header { display: flex; }
}

@media (min-width: 768px) {
  .drawer { display: none; }
}

/* --- Dashboard --- */
.dash4b {
  max-width: 1080px;
  margin: 0 auto;
  padding: 22px 22px 60px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.dash4b-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

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

.dash4b-nav-title {
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: -.01em;
  min-width: 130px;
  text-align: center;
}

.dash4b-seg { margin-bottom: 0; }

.dash4b-loading {
  padding: 60px;
  text-align: center;
  color: var(--c-text-4);
}

.dash4b-card {
  border: 1px solid var(--c-border-2);
  border-radius: 12px;
  background: var(--c-surface);
  padding: 16px 18px;
}

.dash4b-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
}

.dash4b-card-title {
  font-size: var(--fs-base);
  font-weight: 700;
  letter-spacing: -.01em;
}

/* Hero */
.dash4b-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  padding: 18px 20px;
}

.dash4b-hero-total {
  font-size: var(--fs-2xl);
  font-weight: 700;
  letter-spacing: -.02em;
  margin: 4px 0 6px;
}

.dash4b-hero-netline { font-size: var(--fs-md); color: var(--c-text-3); }

.dash4b-hero-ratio { width: 230px; flex: none; }

.dash4b-ratio-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.dash4b-ratio-saved {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--c-pos);
}

.dash4b-ratio-bar {
  height: 10px;
  border-radius: 6px;
  overflow: hidden;
}

.dash4b-ratio-bar > div { height: 100%; border-radius: 6px; }

.dash4b-ratio-income { background: var(--c-pos-bg); }
.dash4b-ratio-income > div { background: var(--c-pos); }

.dash4b-ratio-expense { background: var(--c-neg-bg); margin-top: 5px; }
.dash4b-ratio-expense > div { background: var(--c-neg); }

.dash4b-ratio-values {
  display: flex;
  justify-content: space-between;
  font-size: var(--fs-xs);
  font-weight: 700;
  margin-top: 6px;
}

/* KPI strip */
.dash4b-kpis {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

.dash4b-kpi {
  border: 1px solid var(--c-border-2);
  border-radius: 10px;
  background: var(--c-surface);
  padding: 12px 13px;
}

.dash4b-kpi-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--c-text-4);
}

.dash4b-kpi-value {
  font-size: var(--fs-xl);
  font-weight: 700;
  margin: 3px 0 2px;
}

.dash4b-kpi-blue { color: var(--c-primary); }

.dash4b-kpi-sub { font-size: var(--fs-xs); color: var(--c-text-4); }

/* Panels */
.dash4b-panels {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 14px;
  align-items: start;
}

/* Bar pairs */
.barpairs {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  height: 170px;
  padding-bottom: 20px;
  position: relative;
}

.barpairs-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  position: relative;
}

.barpairs-stack {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: stretch;
  width: 70%;
  height: 100%;
  gap: 1px;
}

.barpairs-seg { width: 100%; }

.barpairs-seg-income { background: var(--c-primary); border-radius: 4px 4px 0 0; }
.barpairs-seg-expense { background: var(--c-primary-100); border-radius: 0 0 4px 4px; }

.barpairs-label {
  position: absolute;
  bottom: -20px;
  font-size: var(--fs-xs);
  color: var(--c-text-4);
  white-space: nowrap;
}

.barpairs-label.is-current { color: var(--c-text); font-weight: 700; }

/* Category rows */
.dash4b-cats { display: flex; flex-direction: column; gap: 12px; }

.dash4b-cat-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dash4b-cat-name {
  width: 84px;
  flex: none;
  font-size: var(--fs-md);
  color: var(--c-text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dash4b-cat-bar {
  flex: 1;
  height: 6px;
  background: var(--c-track);
  border-radius: 3px;
  overflow: hidden;
}

.dash4b-cat-bar > span {
  display: block;
  height: 100%;
  background: var(--c-primary);
  border-radius: 3px;
}

.barspark { flex: none; }

.dash4b-cat-amount {
  width: 64px;
  flex: none;
  text-align: right;
  font-size: var(--fs-md);
  font-weight: 600;
}

/* Responsive */
@media (max-width: 900px) {
  .dash4b-panels { grid-template-columns: 1fr; }
  .dash4b-kpis { grid-template-columns: repeat(2, 1fr); }
  .dash4b-hero { flex-direction: column; }
  .dash4b-hero-ratio { width: 100%; }
}

/* --- Settings: subtitle and new account --- */
.settings-subtitle {
  font-size: var(--fs-md);
  font-weight: 700;
  margin: 6px 0 4px;
  color: var(--c-text);
}

.new-account-card {
  max-width: 460px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.new-account-balance { max-width: 220px; }


/* --- Small helpers --- */
.session-notice {
  background: var(--c-chip-bg);
  border: 1px solid var(--c-row-sel-border);
  border-radius: var(--r-card);
  color: var(--c-text-2);
  font-size: var(--fs-base);
  padding: 10px 14px;
}

.mobile-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--fs-base);
  color: var(--c-text-3);
  text-decoration: none;
  margin-bottom: 10px;
}

#blazor-error-ui .reload {
  color: var(--c-primary);
  text-decoration: underline;
}

/* --- Import wizard --- */
.imp-page { max-width: 1100px; display: flex; flex-direction: column; gap: 16px; }
.imp-page > .settings-title { margin-bottom: 0; }

.imp-head { display: flex; flex-direction: column; gap: 14px; }
.imp-head .settings-title { margin: 0; }

/* Progress: one quiet bar per step, the names below; narrow screens keep only the line above. */
.imp-progress { display: flex; flex-direction: column; gap: 8px; }

.imp-progress-label { display: none; font-size: var(--fs-md); color: var(--c-text-3); }
.imp-progress-label b { color: var(--c-text); font-weight: 600; }

.imp-progress-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.imp-progress-steps li { display: flex; flex-direction: column; gap: 7px; min-width: 0; }

.imp-progress-bar {
  height: 4px;
  border-radius: 2px;
  background: var(--c-track);
  transition: background .2s;
}

.imp-progress-name {
  font-size: var(--fs-md);
  font-weight: 500;
  color: var(--c-text-4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.imp-progress-steps li.is-done .imp-progress-bar { background: var(--c-primary-200); }
.imp-progress-steps li.is-done .imp-progress-name { color: var(--c-text-3); }
.imp-progress-steps li.is-active .imp-progress-bar { background: var(--c-primary); }
.imp-progress-steps li.is-active .imp-progress-name { color: var(--c-text); font-weight: 600; }

.imp-card-meta {
  font-size: var(--fs-md);
  color: var(--c-text-4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  margin-left: 12px;
}

/* Empty states: centred icon, title, one sentence, one action. */
.imp-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding: 36px 24px;
  color: var(--c-text-4);
}

.imp-empty-title { margin: 6px 0 0; font-size: var(--fs-lg); font-weight: 700; color: var(--c-text); }
.imp-empty .settings-hint { max-width: 440px; margin-bottom: 8px; }

/* Step 1: target account and drop zone */
.imp-select { display: flex; flex-direction: column; gap: 16px; }
.imp-select .settings-hint { margin: 0; }
.imp-account { max-width: 360px; }

.imp-drop {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 180px;
  padding: 24px;
  border: 1.5px dashed var(--c-input-border);
  border-radius: var(--r-card);
  background: var(--c-surface-2);
  text-align: center;
  transition: border-color .15s, background .15s;
}

.imp-drop:hover, .imp-drop:focus-within { border-color: var(--c-primary-300); }
.imp-drop:focus-within { box-shadow: var(--focus-ring); }
.imp-drop.is-over { border-color: var(--c-primary); background: var(--c-chip-bg); }

.imp-drop.has-file {
  flex-direction: row;
  justify-content: flex-start;
  gap: 14px;
  min-height: 0;
  padding: 16px 18px;
  border-style: solid;
  border-color: var(--c-border);
  background: var(--c-surface);
  text-align: left;
}

/* The file input covers the whole zone, so a click picks and a drop hands over the file. */
.imp-drop-input,
.imp-drop input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.imp-drop-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-bottom: 6px;
  border-radius: 50%;
  background: var(--c-chip-bg);
  color: var(--c-primary);
  flex: none;
}

.imp-drop-icon.is-file { margin: 0; border-radius: 10px; }

.imp-drop-title { font-size: var(--fs-lg); font-weight: 600; color: var(--c-text); }
.imp-drop-text { font-size: var(--fs-base); color: var(--c-text-3); }
.imp-drop-text u { color: var(--c-primary); text-decoration-thickness: 1px; text-underline-offset: 2px; }
.imp-drop-formats { margin-top: 6px; font-size: var(--fs-sm); color: var(--c-text-4); }

.imp-file { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.imp-file-name { font-weight: 600; color: var(--c-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.imp-file-meta { font-size: var(--fs-md); color: var(--c-text-3); }
.imp-drop-change { font-size: var(--fs-md); font-weight: 600; color: var(--c-primary); white-space: nowrap; }

/* Preview tables in the look of the register */
.imp-preview-card { padding-bottom: 12px; }

.imp-table-scroll {
  overflow: auto;
  max-height: 420px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-input);
  background: var(--c-surface);
}

.imp-table-scroll:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.imp-table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: var(--fs-base);
}

.imp-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  height: 34px;
  padding: 0 12px;
  background: var(--c-surface-2);
  border-bottom: 1px solid var(--c-border);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  text-align: left;
  color: var(--c-text-3);
  white-space: nowrap;
}

.imp-table td {
  height: 40px;
  padding: 0 12px;
  border-bottom: 1px solid var(--c-border-2);
  color: var(--c-text);
  white-space: nowrap;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.imp-table tbody tr:last-child td { border-bottom: 0; }
.imp-table tbody tr:hover td { background: var(--c-row-hover); }

.imp-table .is-num { text-align: right; }
.imp-table td.is-amount { font-weight: 600; }
.imp-table td.is-income { color: var(--c-pos); }
.imp-table td.is-date, .imp-table .is-rowno { color: var(--c-text-3); font-size: var(--fs-md); }
.imp-table .is-rowno { width: 1%; text-align: right; color: var(--c-text-4); }
.imp-table .reg-cat { vertical-align: middle; }

.imp-th-state, .imp-td-state { width: 1%; padding-right: 0 !important; }

.imp-table tr.is-skipped td { color: var(--c-text-4); }
.imp-table tr.is-skipped td.is-income { color: var(--c-text-4); }
.imp-table tr.is-skipped .reg-cat { opacity: .6; }

.imp-table-foot { padding: 10px 2px 0; font-size: var(--fs-sm); color: var(--c-text-4); }

/* Marker inside a row: already in the account, pending at the bank */
.imp-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 7px;
  border-radius: var(--r-chip);
  background: var(--c-seg-bg);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--c-text-3);
  white-space: nowrap;
}

.imp-tag.is-warn { background: var(--c-warn-bg); color: var(--c-warn); }

/* Step 2: format options */
.imp-format-grid {
  display: flex;
  gap: 18px 22px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.imp-delims { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }

.imp-delim {
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--c-input-border);
  border-radius: var(--r-input);
  background: var(--c-surface);
  font: 500 var(--fs-md) var(--font-sans);
  color: var(--c-text-2);
  cursor: pointer;
  white-space: nowrap;
}

.imp-delim:hover { border-color: var(--c-text-4); color: var(--c-text); }
.imp-delim.is-on { border-color: var(--c-primary); background: var(--c-chip-bg); color: var(--c-primary); font-weight: 600; }

.imp-input-char { width: 52px; text-align: center; }
.imp-input-num { width: 88px; text-align: right; }
.imp-field-encoding { flex: 1; min-width: 180px; max-width: 280px; }
.imp-field-encoding .k-input { width: 100%; }

.imp-format-foot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--c-border-2);
}

.imp-format-checks { display: flex; flex-direction: column; gap: 8px; }
.imp-format-apply { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-left: auto; }

.imp-pending-note {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-md);
  color: var(--c-warn);
}

.imp-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-base);
  color: var(--c-text-2);
  cursor: pointer;
}

.imp-check input { width: 16px; height: 16px; margin: 0; accent-color: var(--c-primary); flex: none; }

/* Step 3: mapping */
.imp-assign-grid {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 28px;
}

.imp-assign-headrow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px minmax(0, 1fr);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--c-border-2);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--c-text-4);
}

.imp-assign-rules .imp-assign-headrow { grid-template-columns: 1fr; margin-bottom: 10px; }

.imp-assign-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px minmax(0, 1fr);
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid var(--c-border-2);
}

.imp-assign-row .k-input { width: 100%; min-width: 0; padding-top: 8px; padding-bottom: 8px; }
.imp-assign-row .k-input:focus { padding-top: 7.5px; padding-bottom: 7.5px; }
.imp-assign-row.is-unmapped .k-input { color: var(--c-text-4); }

.imp-assign-source { display: flex; flex-direction: column; gap: 1px; min-width: 0; padding-right: 8px; }
.imp-assign-name { font-weight: 600; color: var(--c-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.imp-assign-sample { font-size: var(--fs-md); color: var(--c-text-4); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.imp-assign-arrow { display: flex; justify-content: center; color: var(--c-text-4); }

.imp-rules-empty { margin: 0; font-size: var(--fs-md); color: var(--c-text-4); line-height: 1.5; }

.imp-rule-card {
  border: 1px solid var(--c-border);
  border-radius: var(--r-input);
  padding: 12px 14px;
  margin-bottom: 10px;
  background: var(--c-surface-2);
}

.imp-rule-title { font-weight: 600; font-size: var(--fs-base); margin-bottom: 8px; }

.imp-rule-modes {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 10px;
}

.imp-rule-sep {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 24px;
  font-size: var(--fs-md);
  color: var(--c-text-3);
}

.imp-rule-sources { margin: 0; padding: 0; list-style: none; counter-reset: imp-src; }

.imp-rule-source {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 0;
  border-top: 1px solid var(--c-border-2);
  font-size: var(--fs-md);
  color: var(--c-text-2);
  counter-increment: imp-src;
}

.imp-rule-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.imp-rule-name::before { content: counter(imp-src) ". "; color: var(--c-text-4); }
.imp-rule-source .k-icon-btn:disabled { opacity: .35; cursor: default; border-color: var(--c-border); color: var(--c-text-4); }

.imp-assign-checks { margin-top: 16px; }

/* Step 4: summary and notes */
.imp-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.imp-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 16px;
  border: 1px solid var(--c-border-2);
  border-radius: 12px;
  background: var(--c-surface);
  min-width: 0;
}

.imp-stat-label { font-size: var(--fs-xs); font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--c-text-4); }
.imp-stat-value { font-size: var(--fs-2xl); font-weight: 700; letter-spacing: -.02em; color: var(--c-text); line-height: 1.2; }
.imp-stat-sub { font-size: var(--fs-md); color: var(--c-text-3); }
.imp-stat.is-primary { border-color: var(--c-row-sel-border); background: var(--c-row-sel-bg); }
.imp-stat.is-warn .imp-stat-value { color: var(--c-warn); }
.imp-stat.is-ok .imp-stat-value { color: var(--c-text-4); }

.imp-problems {
  border: 1px solid color-mix(in srgb, var(--c-warn) 35%, var(--c-warn-bg));
  border-radius: 12px;
  background: var(--c-warn-bg);
  padding: 12px 16px;
}

.imp-problems summary {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 600;
  color: var(--c-warn);
}

.imp-problems ul {
  margin: 10px 0 0;
  padding: 0 0 0 23px;
  max-height: 220px;
  overflow-y: auto;
  font-size: var(--fs-md);
  line-height: 1.6;
  color: var(--c-text-2);
}

.imp-problems-more { list-style: none; color: var(--c-text-4); }

.imp-duplicates { margin-top: 14px; }

.imp-error, .yaxi-error {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.45;
  white-space: pre-line;
}

.imp-error .icon, .yaxi-error .icon { flex: none; margin-top: 2px; }

/* Actions stay at hand at the bottom of the window while the step scrolls. */
.imp-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
  padding-bottom: 24px;
}

.imp-page > .imp-actions {
  position: sticky;
  bottom: 0;
  z-index: 20;
  margin: 0 -4px;
  padding: 12px 4px max(12px, env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, transparent, var(--c-surface) 14px);
}

.k-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: k-spin .7s linear infinite;
  flex: none;
}

@keyframes k-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .k-spinner { animation-duration: 2.4s; }
}

@media (max-width: 760px) {
  .imp-progress-label { display: block; }
  .imp-progress-name { display: none; }
  .imp-assign-grid { grid-template-columns: 1fr; gap: 20px; }
  .imp-assign-headrow { display: none; }
  .imp-assign-rules .imp-assign-headrow { display: grid; }
  .imp-assign-row { grid-template-columns: 1fr; gap: 6px; padding: 10px 0; }
  .imp-assign-arrow { display: none; }
  .imp-format-grid { align-items: stretch; flex-direction: column; }
  .imp-field-encoding { max-width: none; }
  .imp-format-apply { margin-left: 0; width: 100%; }
  .imp-format-apply .k-btn { flex: 1; justify-content: center; }
  .imp-summary { grid-template-columns: 1fr 1fr; }
  .imp-summary .imp-stat.is-primary { grid-column: 1 / -1; }
  .imp-stat-value { font-size: var(--fs-xl); }
  .imp-table td { height: 38px; padding: 0 10px; max-width: 200px; }
  .imp-table th { padding: 0 10px; }
  .imp-drop { min-height: 150px; }
  .imp-actions { flex-wrap: wrap; }
  .imp-actions .k-btn { flex: 1; justify-content: center; }
}

/* --- Bank download (YAXI) --- */
.yaxi-page { max-width: 900px; display: flex; flex-direction: column; gap: 16px; }

.yaxi-head { display: flex; flex-direction: column; gap: 6px; }
.yaxi-head .settings-title { margin: 0; }

.yaxi-account {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 7px;
  font-size: var(--fs-base);
  color: var(--c-text-3);
}

.yaxi-account b { color: var(--c-text); font-weight: 600; }
.yaxi-account-sep { color: var(--c-text-4); }
.yaxi-iban { font-family: var(--font-mono); font-size: var(--fs-md); }

/* Period: two date fields, Von preset to the newest entry */
.yaxi-dates {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 200px));
  gap: 14px;
}

.yaxi-dates .k-input { width: 100%; min-width: 0; }
.yaxi-dates-hint { margin: 10px 0 0; font-size: var(--fs-md); color: var(--c-text-4); }

.yaxi-load-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-top: 18px;
}

.yaxi-privacy { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-md); color: var(--c-text-4); }

.yaxi-status {
  margin-top: 12px;
  padding-left: 12px;
  border-left: 2px solid var(--c-primary-200);
  font-size: var(--fs-md);
  color: var(--c-text-3);
}

.yaxi-error { margin-top: 14px; flex-wrap: wrap; }
.yaxi-error > span { flex: 1; min-width: 200px; }
.yaxi-error-action { margin-left: auto; }

/* History of the download: what the service reported, step by step */
.yaxi-log { margin-top: 14px; }

.yaxi-log summary {
  cursor: pointer;
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--c-text-3);
}

.yaxi-log-list {
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  font-size: var(--fs-md);
  color: var(--c-text-2);
}

.yaxi-log-list li {
  position: relative;
  padding: 3px 0 3px 18px;
}

.yaxi-log-list li::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 10px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--c-text-4);
}

.yaxi-log-list li:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 5.5px;
  top: 18px;
  bottom: -9px;
  width: 1px;
  background: var(--c-border);
}

.yaxi-log-list li:last-child::before { background: var(--c-primary); }

.yaxi-log-tech { margin-top: 10px; }
.yaxi-log-tech summary { font-weight: 500; color: var(--c-text-4); }

.yaxi-log-tech pre {
  margin: 8px 0 0;
  padding: 10px;
  max-height: 220px;
  overflow: auto;
  border-radius: var(--r-input);
  background: var(--c-surface-2);
  font: var(--fs-sm) / 1.5 var(--font-mono);
  color: var(--c-text-3);
  white-space: pre-wrap;
  word-break: break-word;
}

/* Reconciliation: bank balance against the balance after the import */
.yaxi-recon {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 28px;
  padding: 12px 16px;
  margin-bottom: 14px;
  border: 1px solid var(--c-border-2);
  border-radius: var(--r-input);
  background: var(--c-surface-2);
}

.yaxi-recon-item { display: flex; flex-direction: column; gap: 1px; }
.yaxi-recon-label { font-size: var(--fs-xs); font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--c-text-4); }
.yaxi-recon-value { font-size: var(--fs-lg); font-weight: 700; color: var(--c-text); }

.yaxi-recon-verdict {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  font-weight: 600;
  font-size: var(--fs-base);
}

.yaxi-recon.is-ok .yaxi-recon-verdict { color: var(--c-pos); }

.yaxi-recon.is-off {
  border-color: color-mix(in srgb, var(--c-warn) 40%, var(--c-warn-bg));
  background: var(--c-warn-bg);
}

.yaxi-recon.is-off .yaxi-recon-verdict { color: var(--c-warn); }

/* Transactions in the look of the register */
.yaxi-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--c-border);
  max-height: 60vh;
  overflow-y: auto;
}

.yaxi-row {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto 112px;
  grid-template-areas: "date main tags amount";
  align-items: center;
  column-gap: 12px;
  min-height: 52px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--c-border-2);
}

.yaxi-row:last-child { border-bottom: 0; }
.yaxi-row:hover { background: var(--c-row-hover); }

.yaxi-c-date { grid-area: date; display: flex; flex-direction: column; font-size: var(--fs-md); color: var(--c-text-3); line-height: 1.25; }
.yaxi-c-date small { font-size: var(--fs-xs); color: var(--c-text-4); }

.yaxi-c-main { grid-area: main; display: flex; flex-direction: column; gap: 1px; min-width: 0; }

.yaxi-recipient, .yaxi-purpose { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.yaxi-recipient { font-weight: 600; color: var(--c-text); }
.yaxi-purpose { font-size: var(--fs-md); color: var(--c-text-3); }

.yaxi-c-tags { grid-area: tags; display: flex; gap: 4px; justify-content: flex-end; }

.yaxi-c-amount { grid-area: amount; text-align: right; font-weight: 600; color: var(--c-text); white-space: nowrap; }
.yaxi-c-amount.is-income { color: var(--c-pos); }

.yaxi-row.is-off .yaxi-recipient,
.yaxi-row.is-off .yaxi-c-amount { color: var(--c-text-4); }
.yaxi-row.is-off .yaxi-purpose { color: var(--c-text-4); }

.yaxi-none {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 4px;
  color: var(--c-text-3);
}

.yaxi-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  padding: 14px 0 2px;
  border-top: 1px solid var(--c-border);
}

.yaxi-actions { padding: 16px 0 0; border-top: 1px solid var(--c-border-2); margin-top: 0; }

/* Credentials dialog: fields stacked so the PIN keeps inside the dialog at every width */
.yaxi-cred-hint { margin: 0 0 14px; }
.yaxi-cred { display: flex; flex-direction: column; gap: 12px; }
.yaxi-cred .k-input, .yaxi-modal .k-input { width: 100%; min-width: 0; }

.yaxi-bank-row {
  display: flex;
  gap: 8px;
}

.yaxi-bank-row .k-input { flex: 1; }

.yaxi-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--c-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.yaxi-modal {
  width: min(440px, 100%);
  max-height: 86vh;
  overflow-y: auto;
  background: var(--c-surface);
  border-radius: 12px;
  border: 1px solid var(--c-border);
  box-shadow: var(--sh-menu);
  padding: 20px;
}

.yaxi-modal .imp-actions { padding-bottom: 0; margin-top: 16px; }

.yaxi-modal-image {
  display: block;
  max-width: 220px;
  max-height: 220px;
  margin: 0 0 12px;
}

.yaxi-modal-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
  margin-bottom: 8px;
}

.yaxi-modal-option {
  align-items: flex-start;
  border: 1px solid var(--c-border-2);
  border-radius: var(--r-input);
  padding: 8px 10px;
}

.yaxi-modal-option:has(input:checked) { border-color: var(--c-primary); background: var(--c-row-sel-bg); }

/* Caution tone for the account picker and the "current account" badge. */
.yaxi-picker-warning {
  font-size: var(--fs-md);
  color: var(--c-warn);
  background: var(--c-warn-bg);
  border: 1px solid color-mix(in srgb, var(--c-warn) 40%, var(--c-warn-bg));
  border-radius: var(--r-input);
  padding: 8px 11px;
  margin-bottom: 10px;
}

.yaxi-current-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: var(--fs-xs);
  font-weight: 600;
  white-space: nowrap;
  vertical-align: middle;
  color: var(--c-pos);
  background: var(--c-pos-bg);
  border: 1px solid color-mix(in srgb, var(--c-pos) 40%, var(--c-pos-bg));
  border-radius: var(--r-chip);
}

@media (max-width: 760px) {
  .yaxi-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "main amount"
      "date tags";
    row-gap: 3px;
    padding: 9px 10px;
  }

  .yaxi-c-date { flex-direction: row; gap: 0; font-size: var(--fs-sm); }
  .yaxi-c-date small { font-size: inherit; color: inherit; }
  .yaxi-c-tags { justify-content: flex-end; }
  .yaxi-recon-verdict { margin-left: 0; width: 100%; }
  .yaxi-dates { grid-template-columns: 1fr 1fr; }
  .yaxi-list { max-height: none; }
}

/* --- Download setup guide --- */
.dls-page { max-width: 780px; }

.dls-text { font-size: var(--fs-base); color: var(--c-text); margin: 0 0 12px; }

.dls-methods {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.dls-method {
  align-items: flex-start;
  border: 1px solid var(--c-border-2);
  border-radius: var(--r-input);
  padding: 9px 11px;
}

.dls-method.is-active {
  border-color: var(--c-row-sel-border);
  background: var(--c-row-sel-bg);
}

/* Methods the browser cannot perform itself: recordable here, run on the desktop. */
.dls-desktop-note {
  margin-top: 4px;
  font-size: var(--fs-md);
  color: var(--c-warn);
}

.dls-desktop-note-block {
  background: var(--c-warn-bg);
  border: 1px solid color-mix(in srgb, var(--c-warn) 40%, var(--c-warn-bg));
  border-radius: var(--r-input);
  padding: 8px 11px;
  margin-top: 10px;
}

.dls-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 14px;
  margin-bottom: 12px;
}

.dls-connection { margin-bottom: 12px; }

.dls-status {
  font-size: var(--fs-md);
  font-weight: 600;
  margin: 0 0 10px;
}

.dls-ok { color: var(--c-pos); font-weight: 600; }
.dls-missing { color: var(--c-neg); font-weight: 600; }

.dls-check-row { margin-bottom: 10px; }

.dls-inline-link { margin-left: 4px; }

.dls-error { margin-top: 12px; }

.dls-nav {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 14px;
  padding-bottom: 24px;
  flex-wrap: wrap;
}

.dls-nav-right { display: flex; gap: 8px; margin-left: auto; }

@media (max-width: 760px) {
  .dls-fields { grid-template-columns: 1fr; }
  .dls-nav { flex-direction: column-reverse; }
  .dls-nav-right { flex-wrap: wrap; }
  .dls-nav .k-btn, .dls-nav-right .k-btn { flex: 1; justify-content: center; }
}
