/* ============================================================
   KONTUR — Web app UI kit styles
   Depends on ../../colors_and_type.css for tokens.
   ============================================================ */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.k-num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; letter-spacing: -0.01em; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.muted { color: var(--fg-3); }
.lbl {
  font-size: 11px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--fg-3);
}

/* ---------- App shell ---------- */
.k-app {
  display: grid;
  grid-template-columns: 252px 1fr;
  min-height: 100vh;
  background-color: var(--bg);
}
.k-main { display: flex; flex-direction: column; min-width: 0; }
.k-content { padding: 28px 40px 64px; max-width: 1180px; width: 100%; margin: 0 auto; }

/* ---------- Sidebar ---------- */
.k-side {
  background-color: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 22px 16px;
  position: sticky; top: 0; height: 100vh;
  transition: border-color var(--dur-slow) var(--ease-out);
}
.k-brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 22px; }
.k-brand img { width: 34px; height: 34px; border-radius: 9px; }
.k-brand__name { font-size: 19px; font-weight: 700; letter-spacing: -0.4px; color: var(--fg); }
.k-nav { display: flex; flex-direction: column; gap: 2px; }
.k-nav__label { font-size: 10.5px; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase; color: var(--fg-3); padding: 16px 10px 7px; }
.k-nav__item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: 10px;
  font-size: 14px; font-weight: 500; color: var(--fg-2);
  cursor: pointer; border: 0; background: transparent; width: 100%; text-align: left;
  transition: color var(--dur-fast) var(--ease-out);
}
.k-nav__item svg { width: 18px; height: 18px; stroke-width: 1.9; }
.k-nav__item:hover { background: var(--surface-inset); color: var(--fg); }
.k-nav__item.is-active { background: var(--accent-soft); color: var(--accent-press); font-weight: 600; }
.k-nav__item .k-nav__badge { margin-left: auto; font-family: var(--font-mono); font-size: 11px; color: var(--fg-3); }
.k-side__foot { margin-top: auto; }
.k-user { display: flex; align-items: center; gap: 11px; padding: 10px; border-radius: 12px; cursor: pointer; }
.k-user:hover { background: var(--surface-inset); }
.k-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 600; flex: 0 0 auto; }
.k-user__name { font-size: 13.5px; font-weight: 600; color: var(--fg); }
.k-user__sub { font-size: 11.5px; color: var(--fg-3); }

/* ---------- Top bar ---------- */
.k-top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 16px 40px; background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-faint);
}
.k-top__title { font-size: 21px; font-weight: 700; letter-spacing: -0.3px; }
.k-top__sub { font-size: 12.5px; color: var(--fg-3); margin-top: 2px; }
.k-top__spacer { flex: 1; }
.k-search {
  display: flex; align-items: center; gap: 9px;
  background: var(--surface-inset); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 13px; width: 260px; color: var(--fg-3);
}
.k-search input { border: 0; outline: 0; background: transparent; font-family: var(--font-sans); font-size: 13.5px; color: var(--fg); width: 100%; }
.k-search svg { width: 16px; height: 16px; }

/* ---------- Buttons ---------- */
.k-btn {
  font-family: var(--font-sans); font-size: 14px; font-weight: 600;
  border-radius: 12px; border: 1px solid transparent; padding: 10px 17px;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform var(--dur-fast) var(--ease-out), border-color var(--dur-fast), filter var(--dur-fast);
  white-space: nowrap;
}
.k-btn svg { width: 16px; height: 16px; stroke-width: 2; }
.k-btn:active { transform: scale(0.98); }
.k-btn--primary { background: var(--accent); color: var(--fg-on-accent); }
.k-btn--primary:hover { background: var(--accent-hover); }
.k-btn--secondary { background: var(--surface); color: var(--fg); border-color: var(--line-strong); }
.k-btn--secondary:hover { background: var(--surface-inset); }
.k-btn--ghost { background: transparent; color: var(--accent); }
.k-btn--ghost:hover { background: var(--accent-wash); }
.k-btn--danger { background: var(--neg-soft); color: var(--neg-strong); }
.k-btn--pos { background: var(--pos); color: #fff; }
.k-btn--pos:hover { filter: brightness(1.06); }
.k-btn--neg { background: var(--neg); color: #fff; }
.k-btn--neg:hover { filter: brightness(1.06); }
.k-btn--pill { border-radius: 999px; }
.k-btn--sm { padding: 7px 13px; font-size: 13px; border-radius: 10px; }
.k-btn--block { width: 100%; }
.k-icon-btn {
  width: 40px; height: 40px; border-radius: 11px; display: inline-grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line); color: var(--fg-2); cursor: pointer;
  transition: color var(--dur-fast), border-color var(--dur-fast);
}
.k-icon-btn:hover { background: var(--surface-inset); color: var(--fg); }
.k-icon-btn svg { width: 18px; height: 18px; }

/* ---------- Pills / badges ---------- */
.k-pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
}
.k-pill svg { width: 13px; height: 13px; stroke-width: 2.2; }
.k-pill .k-num { font-size: 12px; }
.k-pill--pos { background: var(--pos-soft); color: var(--pos-strong); }
.k-pill--neg { background: var(--neg-soft); color: var(--neg-strong); }
.k-pill--warn { background: var(--warn-soft); color: var(--warn); }
.k-pill--info { background: var(--accent-soft); color: var(--accent-press); }
.k-pill--neutral { background: var(--surface-inset); color: var(--fg-2); border: 1px solid var(--line); }
.k-dot { width: 6px; height: 6px; border-radius: 50%; flex: 0 0 auto; }

/* ---------- Cards ---------- */
.k-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--shadow-sm);
  transition: background-color var(--dur-base), border-color var(--dur-base);
}
.k-card--pad { padding: 22px 24px; }
.k-card__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.k-card__title { font-size: 16px; font-weight: 600; }

/* ---------- Stat / hero numbers ---------- */
.k-hero { display: flex; flex-direction: column; gap: 6px; }
.k-hero__val { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 44px; font-weight: 600; letter-spacing: -1.2px; line-height: 1; }
.k-stat { display: flex; flex-direction: column; gap: 5px; }
.k-stat__val { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 22px; font-weight: 600; letter-spacing: -0.5px; }

/* ---------- Account list ---------- */
.k-acct { display: flex; align-items: center; gap: 13px; padding: 13px 6px; border-radius: 12px; cursor: pointer; }
.k-acct:hover { background: var(--surface-inset); }
.k-acct__badge { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; flex: 0 0 auto; color: #fff; }
.k-acct__badge svg { width: 20px; height: 20px; }
.k-acct__meta { flex: 1; min-width: 0; }
.k-acct__name { font-size: 14px; font-weight: 600; }
.k-acct__sub { font-family: var(--font-mono); font-size: 11.5px; color: var(--fg-3); margin-top: 1px; }
.k-acct__bal { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 15px; font-weight: 600; }

/* ---------- Transaction rows ---------- */
.k-txn { display: flex; align-items: center; gap: 13px; padding: 11px 8px; border-radius: 11px; }
.k-txn:hover { background: var(--surface-inset); }
.k-txn__ico { width: 38px; height: 38px; border-radius: 50%; background: var(--surface-inset); display: grid; place-items: center; color: var(--fg-2); flex: 0 0 auto; }
.k-txn__ico svg { width: 17px; height: 17px; }
.k-txn__meta { flex: 1; min-width: 0; }
.k-txn__name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.k-txn__sub { font-size: 12px; color: var(--fg-3); margin-top: 1px; }
.k-txn__amt { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 14.5px; font-weight: 600; text-align: right; }
.k-divider { height: 1px; background: var(--line-faint); margin: 0 8px; border: 0; }
.k-day-label { font-size: 12px; font-weight: 600; color: var(--fg-3); padding: 16px 8px 6px; }

/* ---------- Holdings table ---------- */
.k-table { width: 100%; border-collapse: collapse; }
.k-table th { text-align: left; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-3); padding: 0 14px 12px; border-bottom: 1px solid var(--line); }
.k-table th.r, .k-table td.r { text-align: right; }
.k-table td { padding: 13px 14px; border-bottom: 1px solid var(--line-faint); font-size: 14px; }
.k-table tr { cursor: pointer; }
.k-table tbody tr:hover { background: var(--surface-inset); }
.k-tick { display: flex; align-items: center; gap: 12px; }
.k-tick__logo { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font-family: var(--font-mono); font-weight: 600; font-size: 12px; color: #fff; flex: 0 0 auto; }
.k-tick__name { font-weight: 600; font-size: 14px; }
.k-tick__sub { font-family: var(--font-mono); font-size: 11.5px; color: var(--fg-3); }

/* ---------- Allocation bar ---------- */
.k-alloc { display: flex; height: 12px; border-radius: 999px; overflow: hidden; gap: 2px; }
.k-alloc__seg { height: 100%; }
.k-alloc__legend { display: flex; flex-direction: column; gap: 11px; margin-top: 18px; }
.k-alloc__row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.k-alloc__row .k-num { margin-left: auto; font-weight: 600; }

/* ---------- Segmented control ---------- */
.k-seg { display: inline-flex; background: var(--surface-inset); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.k-seg button { font-family: var(--font-sans); font-size: 12.5px; font-weight: 600; color: var(--fg-3); background: transparent; border: 0; border-radius: 7px; padding: 6px 13px; cursor: pointer; transition: all var(--dur-fast); }
.k-seg button.is-active { background: var(--surface); color: var(--fg); box-shadow: var(--shadow-xs); }

/* ---------- Quick actions ---------- */
.k-quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.k-quick__btn { display: flex; flex-direction: column; align-items: center; gap: 9px; padding: 18px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; cursor: pointer; transition: border-color var(--dur-fast); }
.k-quick__btn:hover { background: var(--surface-inset); border-color: var(--line-strong); }
.k-quick__ico { width: 42px; height: 42px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-press); display: grid; place-items: center; }
.k-quick__ico svg { width: 20px; height: 20px; }
.k-quick__lbl { font-size: 13px; font-weight: 600; }

/* ---------- Chart ---------- */
.k-chart { width: 100%; display: block; }
.k-chart-wrap { position: relative; }

/* ---------- Modal / sheet ---------- */
.k-scrim { position: fixed; inset: 0; background: var(--overlay); display: grid; place-items: center; z-index: 50; animation: kfade var(--dur-base) var(--ease-out); padding: 24px; }
.k-modal { background: var(--surface); border-radius: 22px; box-shadow: var(--shadow-xl); width: 460px; max-width: 100%; overflow: hidden; animation: kpop var(--dur-base) var(--ease-out); border: 1px solid var(--line); }
.k-modal__head { display: flex; align-items: center; justify-content: space-between; padding: 22px 24px 14px; }
.k-modal__title { font-size: 18px; font-weight: 700; letter-spacing: -0.2px; }
.k-modal__body { padding: 6px 24px 24px; }
.k-modal__foot { display: flex; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--line-faint); background: var(--surface-2); }
@keyframes kfade { from { opacity: 0; } }
@keyframes kpop { from { opacity: 0; transform: translateY(10px) scale(0.98); } }
@media (prefers-reduced-motion: reduce) { .k-scrim, .k-modal { animation: none; } }

/* ---------- Form field ---------- */
.k-field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.k-field > label { font-size: 12px; font-weight: 600; color: var(--fg-2); }
.k-input { display: flex; align-items: center; gap: 9px; background: var(--surface-inset); border: 1px solid var(--line-strong); border-radius: 9px; padding: 11px 13px; transition: border-color var(--dur-fast), box-shadow var(--dur-fast); }
.k-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); background: var(--surface); }
.k-input input { border: 0; outline: 0; background: transparent; font-family: var(--font-sans); font-size: 14.5px; color: var(--fg); width: 100%; }
.k-input .pre { font-family: var(--font-mono); color: var(--fg-3); font-size: 15px; }
.k-input svg { width: 16px; height: 16px; color: var(--fg-3); }

/* ---------- Misc ---------- */
.k-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.k-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.k-row { display: flex; align-items: center; gap: 12px; }
.k-section-h { display: flex; align-items: center; justify-content: space-between; margin: 30px 0 14px; }
.k-section-h h2 { font-size: 17px; font-weight: 600; margin: 0; }
.k-toast { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%); background: var(--ink-900); color: #fff; padding: 13px 20px; border-radius: 12px; font-size: 14px; font-weight: 500; box-shadow: var(--shadow-lg); z-index: 60; display: flex; align-items: center; gap: 10px; animation: ktoast var(--dur-slow) var(--ease-out); }
.k-toast svg { width: 17px; height: 17px; color: var(--pos); }
@keyframes ktoast { from { opacity: 0; transform: translate(-50%, 12px); } }

/* ============================================================
   KONTUR — app extensions (live FinTS integration)
   Built on the same tokens; nothing here overrides the design.
   ============================================================ */

/* ---------- Banner (demo / status notices) ---------- */
.k-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 40px; font-size: 13px; font-weight: 500;
  border-bottom: 1px solid var(--line);
}
.k-banner svg { width: 16px; height: 16px; flex: 0 0 auto; }
.k-banner--demo { background: var(--warn-soft); color: var(--warn); }
.k-banner--info { background: var(--accent-soft); color: var(--accent-press); }
.k-banner a, .k-banner button.k-linkbtn {
  color: inherit; font-weight: 700; text-decoration: underline;
  background: none; border: 0; cursor: pointer; font-family: inherit; font-size: inherit; padding: 0;
}

/* ---------- Empty states ---------- */
.k-empty { text-align: center; padding: 46px 24px; }
.k-empty__ico {
  width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 16px;
  display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-press);
}
.k-empty__ico svg { width: 26px; height: 26px; }
.k-empty__title { font-size: 17px; font-weight: 700; letter-spacing: -0.2px; }
.k-empty__text { color: var(--fg-2); font-size: 14px; margin: 8px auto 20px; max-width: 380px; line-height: 1.55; }

/* ---------- Loading skeleton ---------- */
.k-skel { background: linear-gradient(90deg, var(--surface-inset) 25%, var(--line-faint) 37%, var(--surface-inset) 63%);
  background-size: 400% 100%; border-radius: 8px; animation: kshimmer 1.3s ease infinite; }
@keyframes kshimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
@media (prefers-reduced-motion: reduce) { .k-skel { animation: none; } }
.k-skel-row { height: 16px; margin: 14px 8px; }

.k-spinner { width: 18px; height: 18px; border: 2.5px solid var(--line-strong);
  border-top-color: var(--accent); border-radius: 50%; animation: kspin 0.7s linear infinite; }
@keyframes kspin { to { transform: rotate(360deg); } }

/* ---------- Bank search result row ---------- */
.k-bankrow { display: flex; align-items: center; gap: 12px; padding: 11px 10px; border-radius: 11px; cursor: pointer; }
.k-bankrow:hover { background: var(--surface-inset); }
.k-bankrow.is-active { background: var(--accent-soft); }
.k-bankrow__badge { width: 38px; height: 38px; border-radius: 10px; background: var(--brand); color: #fff; display: grid; place-items: center; flex: 0 0 auto; }
.k-bankrow__badge svg { width: 18px; height: 18px; }
.k-bankrow__name { font-size: 14px; font-weight: 600; }
.k-bankrow__sub { font-family: var(--font-mono); font-size: 11.5px; color: var(--fg-3); margin-top: 1px; }
.k-bankrow__list { max-height: 280px; overflow-y: auto; margin: 0 -6px; }

/* ---------- TAN challenge ---------- */
.k-tan-box { background: var(--surface-inset); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.k-tan-box__label { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-3); margin-bottom: 8px; }
.k-tan-box__text { font-size: 14px; line-height: 1.55; color: var(--fg); }
.k-tan-box img { max-width: 100%; border-radius: 8px; margin-top: 10px; background: #fff; }
.k-otp input { font-family: var(--font-mono); font-size: 22px; letter-spacing: 6px; text-align: center; }
.k-decoupled { display: flex; align-items: center; gap: 12px; justify-content: center; padding: 8px 0 4px; color: var(--fg-2); font-size: 14px; }

/* ---------- Status dot / pill helpers ---------- */
.k-conn-foot { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.k-note { font-size: 11.5px; color: var(--fg-3); line-height: 1.5; }
.k-stack > * + * { margin-top: 18px; }
.k-center { display: grid; place-items: center; min-height: 200px; }

/* ---------- Tag / kind chip ---------- */
.k-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600;
  padding: 3px 8px; border-radius: 6px; background: var(--surface-inset); color: var(--fg-2); border: 1px solid var(--line); }

/* ============================================================
   Mobile bottom tab bar + drawer chrome (hidden on desktop)
   Echoes the Kontur mobile UI kit (glass tab bar).
   ============================================================ */
.k-burger { display: none; }
.k-side-scrim { display: none; }
.k-mobnav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  justify-content: space-around; align-items: stretch;
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom, 0px));
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.k-mobnav__tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: none; border: 0; cursor: pointer; color: var(--fg-3);
  padding: 4px 0; font-family: var(--font-sans);
  transition: color var(--dur-fast) var(--ease-out);
}
.k-mobnav__tab svg { width: 22px; height: 22px; stroke-width: 1.9; }
.k-mobnav__tab span { font-size: 10.5px; font-weight: 600; }
.k-mobnav__tab.is-active { color: var(--accent); }

/* ============================================================
   Responsive — phones & small tablets
   ============================================================ */
@media (max-width: 768px) {
  .k-app { grid-template-columns: 1fr; }

  /* Sidebar → slide-in drawer */
  .k-side {
    position: fixed; left: 0; top: 0; height: 100dvh; width: 272px; z-index: 70;
    transform: translateX(-100%);
    transition: transform var(--dur-slow) var(--ease-out);
    box-shadow: var(--shadow-xl);
  }
  .k-side.is-open { transform: translateX(0); }
  .k-side-scrim { display: block; position: fixed; inset: 0; background: var(--overlay); z-index: 65; }

  /* Top bar */
  .k-top { padding: 12px 14px; gap: 10px; }
  .k-top__title { font-size: 18px; letter-spacing: -0.2px; }
  .k-top__sub { font-size: 11.5px; }
  .k-search { display: none; }
  .k-top .k-btn { display: none; }          /* action reachable via screens + bottom nav */
  .k-burger { display: inline-grid !important; }

  /* Content + room for the bottom tab bar */
  .k-content { padding: 16px 14px 100px; }
  .k-banner { padding: 10px 14px; font-size: 12.5px; }

  /* Collapse multi-column layouts (override inline grid templates) */
  .k-grid-2, .k-grid-3 { grid-template-columns: 1fr !important; gap: 14px; }
  .k-section-h { margin: 22px 0 12px; }
  .k-card--pad { padding: 18px 18px; }

  /* Hero numbers fit narrow screens */
  .k-hero__val { font-size: 31px; letter-spacing: -0.5px; }
  .k-stat__val { font-size: 20px; }

  /* Tables scroll horizontally inside their card */
  .k-card:has(table.k-table) { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .k-table { min-width: 480px; }

  /* Modals become bottom sheets */
  .k-scrim { align-items: flex-end; padding: 0; }
  .k-modal { width: 100% !important; max-width: 100%; border-radius: 22px 22px 0 0; }

  /* Show the bottom tab bar */
  .k-mobnav { display: flex !important; }
}
