/* ===========================================================================
   NEXTFIN — AURORA LIGHT FINTECH DESIGN SYSTEM
   ===========================================================================
   Единый source-of-truth для всех визуальных токенов и компонентов проекта.
   Построен на 4pt-сетке, семантических цветовых токенах и адаптивной
   типографике.  Сохраняет все существующие CSS-классы, используемые
   шаблонами; расширяет их и переопределяет визуал.
   =========================================================================== */


/* ===========================================================================
   1. FOUNDATIONS — DESIGN TOKENS
   ===========================================================================
   Primitive и semantic токены.  Компоненты ссылаются только на semantic-слой,
   что позволяет заменить палитру в одном месте.
   =========================================================================== */
:root {
  /* ---- Primitive colors ---- */
  --color-white: #FFFFFF;
  --color-black: #0B0F14;

  --color-bg-page: #FFFFFF;
  --color-bg-app: #F6F8FB;
  --color-bg-surface: #FFFFFF;
  --color-bg-surface-alt: #F2F6FB;
  --color-bg-soft: #F8FAFC;
  --color-bg-muted: #EEF3F8;

  --color-text-primary: #0B0F14;
  --color-text-secondary: #243140;
  --color-text-muted: #52606D;
  --color-text-soft: #6B7280;
  --color-text-inverse: #FFFFFF;

  --color-border-default: #E5E7EB;
  --color-border-soft: #EEF2F7;
  --color-border-strong: #D7DEE7;

  --color-primary: #10B981;
  --color-primary-hover: #0EA472;
  --color-primary-pressed: #0B8A61;
  --color-primary-soft: #ECFDF3;

  --color-accent-blue: #3B82F6;
  --color-accent-blue-hover: #2563EB;
  --color-accent-blue-pressed: #1D4ED8;
  --color-accent-blue-soft: #EFF6FF;

  --color-success: #16A34A;
  --color-success-soft: #ECFDF3;

  --color-warning: #F59E0B;
  --color-warning-soft: #FFF7ED;

  --color-danger: #DC2626;
  --color-danger-hover: #B91C1C;
  --color-danger-soft: #FEF2F2;

  --color-info: #2563EB;
  --color-info-soft: #EFF6FF;

  --color-gradient-start: #3B82F6;
  --color-gradient-end: #10B981;

  --color-overlay: rgba(11, 15, 20, 0.48);
  --color-overlay-strong: rgba(11, 15, 20, 0.64);

  --color-focus-ring: rgba(59, 130, 246, 0.24);
  --color-focus-ring-strong: rgba(16, 185, 129, 0.22);

  /* ---- Semantic tokens ---- */
  --bg-page: var(--color-bg-app);
  --bg-surface: var(--color-bg-surface);
  --bg-surface-elevated: var(--color-white);
  --bg-card: var(--color-white);
  --bg-card-hover: var(--color-bg-soft);
  --bg-input: var(--color-white);
  --bg-input-disabled: var(--color-bg-muted);
  --bg-table-head: var(--color-bg-surface-alt);
  --bg-table-row-hover: rgba(16, 185, 129, 0.05);
  --bg-chip: var(--color-bg-surface-alt);
  --bg-badge-success: var(--color-success-soft);
  --bg-badge-danger: var(--color-danger-soft);

  --text-primary: var(--color-text-primary);
  --text-secondary: var(--color-text-secondary);
  --text-muted: var(--color-text-muted);
  --text-link: var(--color-accent-blue);
  --text-on-primary: var(--color-white);

  --border-default: var(--color-border-default);
  --border-strong: var(--color-border-strong);

  /* ---- Spacing — 4pt system ---- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-14: 56px;
  --space-16: 64px;
  --space-20: 80px;
  --space-24: 96px;

  /* ---- Radius ---- */
  --radius-2xs: 8px;
  --radius-xs: 10px;
  --radius-sm: 12px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-pill: 999px;

  /* Legacy alias used by many templates */
  --radius: var(--radius-lg);

  /* ---- Shadows — soft & premium ---- */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 8px 24px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 16px 40px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 24px 60px rgba(15, 23, 42, 0.10);
  --shadow-focus: 0 0 0 4px rgba(59, 130, 246, 0.16);

  /* Legacy aliases kept for any template referencing them */
  --shadow-inner: none;
  --shadow-outer: var(--shadow-sm);
  --ring: var(--shadow-focus);

  /* ---- Motion ---- */
  --ease-standard: cubic-bezier(0.2, 0.8, 0.2, 1);
  --duration-fast: 120ms;
  --duration-normal: 180ms;
  --duration-slow: 240ms;
  --transition: var(--duration-normal) var(--ease-standard);

  /* ---- Z-index scale ---- */
  --z-base: 1;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-modal-backdrop: 1050;
  --z-modal: 1060;
  --z-menu: 1100;
  --z-preloader: 9999;

  /* ---- Layout constants ---- */
  --content-max: 1280px;
  --reading-max: 760px;

  /* ---- Typography ---- */
  --fw-heading: 700;
  --fw-semibold: 600;
  --fw-normal: 400;

  /* Legacy variables kept so templates using them still work */
  --bg: var(--bg-page);
  --panel: var(--bg-card);
  --muted: var(--text-muted);
  --text: var(--text-primary);
  --accent: var(--color-primary);
  --accent-2: var(--color-accent-blue);
  --danger: var(--color-danger);
  --success: var(--color-success);
  --line: var(--border-default);
  --glass: var(--color-bg-surface-alt);
  --gap: var(--space-5);
}


/* ===========================================================================
   2. RESET
   =========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

img, svg, video, canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

button, input, select, textarea {
  margin: 0;
  font: inherit;
  color: inherit;
}

a {
  color: var(--text-link);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--color-accent-blue-hover);
}

ul, ol {
  padding-left: var(--space-5);
}

hr {
  border: 0;
  height: 1px;
  background: var(--border-default);
  margin: var(--space-6) 0;
}


/* ===========================================================================
   3. BASE TYPOGRAPHY
   ===========================================================================
   Inter с tabular-nums для финансовых данных.  Адаптивная шкала через
   media queries (секция 18).
   =========================================================================== */
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.625;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 var(--space-3);
  font-weight: var(--fw-heading);
  line-height: 1.2;
  color: var(--text-primary);
}

h1 { font-size: 44px; line-height: 52px; letter-spacing: -0.03em; }
h2 { font-size: 36px; line-height: 44px; letter-spacing: -0.025em; }
h3 { font-size: 28px; line-height: 36px; letter-spacing: -0.02em; }
h4 { font-size: 22px; line-height: 30px; font-weight: var(--fw-semibold); letter-spacing: -0.015em; }
h5 { font-size: 18px; line-height: 26px; font-weight: var(--fw-semibold); letter-spacing: -0.01em; }
h6 { font-size: 16px; line-height: 24px; font-weight: var(--fw-semibold); letter-spacing: -0.01em; }

p { margin: 0 0 var(--space-4); }

/* Named type classes */
.display-xl { font-size: 60px; line-height: 64px; font-weight: 800; letter-spacing: -0.04em; }
.display-lg { font-size: 52px; line-height: 58px; font-weight: 800; letter-spacing: -0.03em; }
.h1 { font-size: 44px; line-height: 52px; font-weight: 700; letter-spacing: -0.03em; }
.h2 { font-size: 36px; line-height: 44px; font-weight: 700; letter-spacing: -0.025em; }
.h3 { font-size: 28px; line-height: 36px; font-weight: 700; letter-spacing: -0.02em; }
.h4 { font-size: 22px; line-height: 30px; font-weight: 600; letter-spacing: -0.015em; }
.h5 { font-size: 18px; line-height: 26px; font-weight: 600; letter-spacing: -0.01em; }
.body-lg { font-size: 18px; line-height: 30px; font-weight: 400; }
.body-md { font-size: 16px; line-height: 26px; font-weight: 400; }
.body-sm { font-size: 14px; line-height: 22px; font-weight: 400; }
.caption { font-size: 12px; line-height: 18px; font-weight: 500; }
.label { font-size: 13px; line-height: 18px; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; color: var(--text-muted); }
.metric { font-size: 28px; line-height: 36px; font-weight: 700; font-variant-numeric: tabular-nums; }
.metric-lg { font-size: 36px; line-height: 44px; font-weight: 700; font-variant-numeric: tabular-nums; }
.button-md { font-size: 14px; line-height: 20px; font-weight: 600; }
.button-sm { font-size: 13px; line-height: 18px; font-weight: 600; }

.lead {
  font-size: 18px;
  line-height: 30px;
  color: var(--text-secondary);
}

.muted,
.text-muted {
  color: var(--text-muted) !important;
}

.text-success { color: var(--color-success) !important; }
.text-danger { color: var(--color-danger) !important; }
.text-info { color: var(--color-info) !important; }
.text-warning { color: var(--color-warning) !important; }
.text-white { color: var(--color-text-primary) !important; }

.fw-bold { font-weight: 700; }
.fw-semibold { font-weight: 600; }

::selection {
  background: rgba(16, 185, 129, 0.18);
  color: var(--text-primary);
}

.eyebrow {
  font-size: 13px;
  line-height: 18px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-primary);
  margin-bottom: var(--space-2);
}


/* ===========================================================================
   4. LAYOUT — CONTAINER / GRID / PAGE SHELL
   =========================================================================== */
.container {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding-inline: var(--space-8);
  padding-block: var(--space-8);
}

.page {
  display: block;
  flex: 1;
}

.page-container {
  display: grid;
  gap: var(--space-6);
}

.section {
  display: block;
  margin-bottom: var(--space-6);
}

/* Row / Column grid — compatible with existing col-* classes */
.row {
  display: flex;
  flex-wrap: wrap;
  margin-left: -0.625rem;
  margin-right: -0.625rem;
}

.row > * {
  padding-left: 0.625rem;
  padding-right: 0.625rem;
}

.g-2 { row-gap: var(--space-2); }
.g-3 { row-gap: var(--space-4); }
.g-4 { row-gap: var(--space-6); }

.col { flex: 1 0 0%; }
.col-12 { width: 100%; }
.col-md-3, .col-md-4, .col-md-6, .col-md-8,
.col-lg-4, .col-lg-6, .col-lg-8,
.col-xl-4, .col-sm-6 {
  width: 100%;
}

/* Utility grid layouts */
.flex { display: flex; }
.stack { display: flex; flex-direction: column; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-5); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-5); }
.gap-sm { gap: var(--space-3); }
.gap-md { gap: var(--space-5); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-4); }

.vstack {
  display: flex;
  flex-direction: column;
}

.divider {
  height: 1px;
  background: var(--border-default);
  margin: var(--space-6) 0;
}


/* ===========================================================================
   5. HEADER
   ===========================================================================
   Sticky, light, with subtle bottom border. No heavy glass effects.
   =========================================================================== */
.app-header {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  border-bottom: 1px solid var(--border-default);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding-top: var(--space-3);
  padding-bottom: var(--space-3);
  min-height: 56px;
}

.header-main-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-3);
  flex: 0 1 auto;
  min-width: 0;
}

/* Brand */
.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 800;
  font-size: 18px;
  color: var(--text-primary);
  flex-shrink: 0;
}
.brand:hover { color: var(--text-primary); }

.brand-mark {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-2xs);
  background: linear-gradient(135deg, var(--color-gradient-start), var(--color-gradient-end));
  color: var(--color-white);
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

.brand-text {
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--color-gradient-start), var(--color-gradient-end));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 700;
  color: var(--text-primary);
}

.logo-mark {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
  background: linear-gradient(135deg, var(--color-gradient-start), var(--color-gradient-end));
  color: var(--color-white);
}

/* Navigation */
.nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.nav-item { list-style: none; }

.nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: color var(--transition), background var(--transition), border-color var(--transition);
}

.nav-link:hover {
  color: var(--text-primary);
  background: var(--color-bg-surface-alt);
}

.nav-divider {
  width: 1px;
  height: 20px;
  background: var(--border-default);
  margin: 0 var(--space-1);
}

/* --------------------------------------------------------------------------
   Header: мобильная версия сайта (body.ui-variant-mobile) — гамбургер-меню
   -------------------------------------------------------------------------- */
.header-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.header-menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--color-bg-surface-alt);
  color: var(--text-primary);
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition), border-color var(--transition);
}

.header-menu-toggle:hover {
  background: var(--color-white);
  border-color: var(--color-border-soft);
}

.header-menu-toggle:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.header-menu-bars {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 20px;
  height: 16px;
}

.header-menu-bar {
  display: block;
  height: 2px;
  width: 100%;
  border-radius: 1px;
  background: currentColor;
  transition: transform 0.2s ease, opacity 0.2s ease;
  transform-origin: center;
}

body.ui-variant-mobile .header-menu-toggle {
  display: inline-flex;
}

body.ui-variant-mobile .nav--header-inline {
  display: none !important;
}

body.ui-variant-mobile .header-inner {
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
}

body.ui-variant-mobile .header-main-row {
  flex: 1 1 auto;
  justify-content: space-between;
  width: 100%;
  min-width: 0;
}

body:not(.ui-variant-mobile) .header-mobile-backdrop,
body:not(.ui-variant-mobile) .header-mobile-drawer {
  display: none !important;
}

.header-mobile-backdrop {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-menu) - 1);
  background: rgba(15, 23, 42, 0.48);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

body.ui-variant-mobile.header-drawer-open .header-mobile-backdrop {
  opacity: 1;
  visibility: visible;
}

.header-mobile-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-menu);
  width: min(100vw, 360px);
  max-width: 100%;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-default);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  pointer-events: none;
  transition: transform 0.28s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
  .header-mobile-drawer,
  .header-mobile-backdrop {
    transition: none;
  }

  .header-mobile-drawer {
    transition: none;
  }
}

body.ui-variant-mobile.header-drawer-open .header-mobile-drawer {
  transform: translateX(0);
  pointer-events: auto;
}

.header-mobile-drawer-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.header-mobile-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-default);
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.96);
}

.header-mobile-drawer-title {
  font-weight: 700;
  font-size: 1.05rem;
}

.header-drawer-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-primary);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.header-drawer-close:hover {
  background: var(--color-bg-surface-alt);
}

body.ui-variant-mobile .nav--drawer {
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  flex-wrap: nowrap;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  -webkit-overflow-scrolling: touch;
}

body.ui-variant-mobile .nav--drawer .nav-link,
body.ui-variant-mobile .nav--drawer .btn {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  justify-content: center;
  min-height: 48px;
  white-space: normal;
  text-align: center;
}

body.ui-variant-mobile .nav--drawer .nav-tier-badge {
  display: flex;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  justify-content: center;
  align-self: stretch;
  text-align: center;
}

body.ui-variant-mobile .nav--drawer .nav-divider {
  width: 100%;
  height: 1px;
  margin: var(--space-2) 0;
  align-self: stretch;
}

body.header-drawer-open {
  overflow: hidden;
}


/* ===========================================================================
   6. FOOTER
   =========================================================================== */
.app-footer {
  border-top: 1px solid var(--border-default);
  background: var(--bg-surface);
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding-top: var(--space-4);
  padding-bottom: var(--space-4);
  flex-wrap: wrap;
  min-height: 48px;
}

.footer-mini {
  font-size: 13px;
  color: var(--text-muted);
}

.footer-nav {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.footer-end {
  flex: 1 1 auto;
  justify-content: flex-end;
}

.footer-ui-variants {
  text-align: right;
}

.footer-ui-variants-title {
  font-weight: 600;
  letter-spacing: 0.02em;
}

.footer-ui-variant-btn {
  flex-shrink: 0;
}

.footer-link {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  transition: color var(--transition);
}

.footer-link:hover {
  color: var(--text-primary);
}


/* ===========================================================================
   7. BUTTONS
   ===========================================================================
   Unified button system.  Sizes: sm / default(md) / lg.
   Variants: primary, secondary, info, success, warning, danger, ghost,
   outline-light, outline-secondary, outline-danger, outline-success,
   outline-warning, link, icon.
   =========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
  cursor: pointer;
  white-space: nowrap;
  transition:
    background var(--transition),
    border-color var(--transition),
    color var(--transition),
    box-shadow var(--transition);
}

.btn:hover {
  background: var(--color-bg-soft);
  border-color: var(--border-strong);
}

.btn:active {
  background: var(--color-bg-muted);
}

.btn:disabled,
.btn[disabled] {
  cursor: not-allowed;
  opacity: 0.5;
  pointer-events: none;
}

/* Primary — green CTA */
.btn-primary,
.btn-accent {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-white);
}

.btn-primary:hover,
.btn-accent:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
  color: var(--color-white);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

.btn-primary:active,
.btn-accent:active {
  background: var(--color-primary-pressed);
  border-color: var(--color-primary-pressed);
}

/* Secondary — muted blue tint */
.btn-secondary {
  background: var(--color-bg-surface-alt);
  border-color: var(--border-default);
  color: var(--text-secondary);
}

.btn-secondary:hover {
  background: var(--color-bg-muted);
  border-color: var(--border-strong);
}

/* Info — blue accent */
.btn-info {
  background: var(--color-accent-blue);
  border-color: var(--color-accent-blue);
  color: var(--color-white);
}

.btn-info:hover {
  background: var(--color-accent-blue-hover);
  border-color: var(--color-accent-blue-hover);
  color: var(--color-white);
}

/* Success */
.btn-success {
  background: var(--color-success);
  border-color: var(--color-success);
  color: var(--color-white);
}

.btn-success:hover {
  background: #15803D;
  border-color: #15803D;
  color: var(--color-white);
}

/* Warning */
.btn-warning {
  background: var(--color-warning);
  border-color: var(--color-warning);
  color: var(--color-black);
}

.btn-warning:hover {
  background: #D97706;
  border-color: #D97706;
}

/* Danger */
.btn-danger {
  background: var(--color-danger);
  border-color: var(--color-danger);
  color: var(--color-white);
}

.btn-danger:hover {
  background: var(--color-danger-hover);
  border-color: var(--color-danger-hover);
  color: var(--color-white);
}

/* Ghost — transparent, for secondary actions */
.btn-ghost {
  background: transparent;
  border-color: var(--border-default);
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--color-bg-surface-alt);
  border-color: var(--border-strong);
}

/* Outline variants */
.btn-outline-light {
  background: transparent;
  border-color: var(--border-default);
  color: var(--text-secondary);
}

.btn-outline-light:hover {
  background: var(--color-bg-surface-alt);
  border-color: var(--border-strong);
}

.btn-outline-secondary {
  background: transparent;
  border-color: var(--border-default);
  color: var(--text-muted);
}

.btn-outline-secondary:hover {
  background: var(--color-bg-surface-alt);
  border-color: var(--border-strong);
  color: var(--text-secondary);
}

.btn-outline-danger {
  background: transparent;
  border-color: rgba(220, 38, 38, 0.3);
  color: var(--color-danger);
}

.btn-outline-danger:hover {
  background: var(--color-danger-soft);
  border-color: var(--color-danger);
}

.btn-outline-success {
  background: transparent;
  border-color: rgba(22, 163, 74, 0.3);
  color: var(--color-success);
}

.btn-outline-success:hover {
  background: var(--color-success-soft);
  border-color: var(--color-success);
}

.btn-outline-warning {
  background: transparent;
  border-color: rgba(245, 158, 11, 0.3);
  color: var(--color-warning);
}

.btn-outline-warning:hover {
  background: var(--color-warning-soft);
  border-color: var(--color-warning);
}

/* Link button */
.btn-link {
  background: transparent;
  border-color: transparent;
  color: var(--text-link);
  padding: var(--space-1) var(--space-2);
  min-height: auto;
}

.btn-link:hover {
  color: var(--color-accent-blue-hover);
  background: transparent;
  border-color: transparent;
  text-decoration: underline;
}

/* Sizes */
.btn-sm {
  min-height: 36px;
  padding: var(--space-1) var(--space-3);
  font-size: 13px;
  line-height: 18px;
  border-radius: var(--radius-xs);
}

.btn-lg {
  min-height: 52px;
  padding: var(--space-3) var(--space-6);
  font-size: 16px;
  border-radius: var(--radius-md);
}

/* Icon button */
.btn-icon {
  width: 40px;
  height: 40px;
  min-height: 40px;
  padding: 0;
  border-radius: var(--radius-xs);
}

.btn-icon.btn-sm {
  width: 36px;
  height: 36px;
  min-height: 36px;
}

.btn-icon.btn-lg {
  width: 44px;
  height: 44px;
  min-height: 44px;
}

/* Legacy pressed animation class — kept as no-op for JS compatibility */
.btn-accent.pressed {
  /* intentionally empty — no scale animations in Aurora Light */
}

.btn-close {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: var(--space-1);
  border-radius: var(--radius-2xs);
  transition: color var(--transition), background var(--transition);
}

.btn-close:hover {
  color: var(--text-primary);
  background: var(--color-bg-muted);
}

.d-grid { display: grid; }


/* ===========================================================================
   8. FORMS — INPUTS / SELECTS / TEXTAREAS
   =========================================================================== */
.form-label {
  display: block;
  margin-bottom: var(--space-2);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-control,
.form-select,
textarea,
input[type="text"],
input[type="number"],
input[type="date"],
input[type="email"],
input[type="password"],
select {
  width: 100%;
  min-height: 48px;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 15px;
  line-height: 22px;
  transition:
    border-color var(--transition),
    box-shadow var(--transition),
    background var(--transition);
}

.form-control:hover,
.form-select:hover,
textarea:hover,
input:hover,
select:hover {
  border-color: var(--border-strong);
}

.form-control:focus,
.form-control:focus-visible,
.form-select:focus,
textarea:focus,
input:focus,
select:focus {
  outline: none;
  border-color: var(--color-accent-blue);
  box-shadow: 0 0 0 4px var(--color-focus-ring);
  background: var(--bg-input);
}

.form-control:disabled,
.form-select:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  background: var(--bg-input-disabled);
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.7;
}

.form-control::placeholder,
textarea::placeholder,
input::placeholder {
  color: var(--color-text-soft);
}

.form-text {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: var(--space-1);
}

.form-check {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-2) 0;
}

.form-check-input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--color-primary);
  cursor: pointer;
  flex-shrink: 0;
}

.form-check-label {
  font-size: 15px;
  line-height: 22px;
  color: var(--text-secondary);
  cursor: pointer;
}

.input-group {
  display: flex;
  align-items: stretch;
  width: 100%;
}

.input-group > .form-control {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.input-group-text {
  display: inline-flex;
  align-items: center;
  padding: 0 var(--space-4);
  border: 1px solid var(--border-default);
  border-left: 0;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  background: var(--color-bg-surface-alt);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
}

/* Smaller variant for date inputs and filter controls */
.form-control-sm {
  min-height: 36px;
  padding: var(--space-1) var(--space-3);
  font-size: 13px;
}

.input, .select, .date-input {
  width: 100%;
  min-height: 48px;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  color: var(--text-primary);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.input:focus, .input:focus-visible,
.select:focus, .date-input:focus {
  outline: none;
  border-color: var(--color-accent-blue);
  box-shadow: 0 0 0 4px var(--color-focus-ring);
}

/* Inline helper for ms-2 class used on "Сегодня" button */
.ms-2 { margin-left: var(--space-2); }
.ps-3 { padding-left: var(--space-4); }


/* ===========================================================================
   9. CARDS / SURFACES
   =========================================================================== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding-bottom: var(--space-4);
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-default);
}

.card-body {
  display: block;
}

.card-footer {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-default);
}

.card-grid {
  display: grid;
  gap: var(--space-5);
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.bg-surface {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}

.bg-dark {
  background: var(--color-bg-surface-alt) !important;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
}

.bg-primary {
  background: var(--color-accent-blue-soft) !important;
  border-color: rgba(59, 130, 246, 0.2) !important;
}

.accent-glow {
  border-color: rgba(16, 185, 129, 0.2);
}

.profit-up {
  color: var(--color-success);
  font-weight: 600;
}

.profit-down {
  color: var(--color-danger);
  font-weight: 600;
}


/* ===========================================================================
   10. TABLES
   ===========================================================================
   Clean light data-table style.  .table-dark is visually identical to .table
   in Aurora Light — no dark rows.
   =========================================================================== */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
  font-size: 14px;
}

.table thead th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.02em;
  border-bottom: 2px solid var(--border-default);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-table-head);
  white-space: nowrap;
}

.table tbody td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border-soft);
  color: var(--text-secondary);
  vertical-align: middle;
}

.table tbody tr {
  background: transparent;
  transition: background var(--transition);
}

.table-hover tbody tr:hover,
.table tbody tr:hover {
  background: var(--bg-table-row-hover);
}

/* table-dark — kept for backwards compat but styled as light */
.table-dark {
  width: 100%;
  border-collapse: collapse;
  background: transparent;
}

.table-dark thead th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.02em;
  border-bottom: 2px solid var(--border-default);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-table-head);
  white-space: nowrap;
}

.table-dark tbody td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border-soft);
  color: var(--text-secondary);
  vertical-align: middle;
}

.table-dark tbody tr:hover {
  background: var(--bg-table-row-hover);
}

.table-sm thead th,
.table-sm tbody td {
  padding: var(--space-2) var(--space-3);
}

.table-striped tbody tr:nth-child(even) {
  background: var(--color-bg-soft);
}

.table-info {
  background: var(--color-accent-blue-soft) !important;
}

.table-primary {
  background: var(--color-primary-soft) !important;
}

.table-light {
  background: var(--color-bg-surface-alt);
}

.sticky-top {
  position: sticky;
  top: 0;
  z-index: var(--z-base);
}

/* Portfolio table — compact layout */
.portfolio-table-wrap {
  overflow-x: auto;
}

.portfolio-table {
  table-layout: fixed;
  width: 100%;
}

.portfolio-table thead th,
.portfolio-table tbody td {
  padding: var(--space-2) var(--space-3);
  font-size: 13px;
  vertical-align: middle;
  white-space: nowrap;
}

.portfolio-table th:nth-child(1), .portfolio-table td:nth-child(1) { width: 10%; }
.portfolio-table th:nth-child(2), .portfolio-table td:nth-child(2) { width: 11%; }
.portfolio-table th:nth-child(3), .portfolio-table td:nth-child(3) { width: 14%; }
.portfolio-table th:nth-child(4), .portfolio-table td:nth-child(4) { width: 11%; }
.portfolio-table th:nth-child(5), .portfolio-table td:nth-child(5) { width: 12%; }
.portfolio-table th:nth-child(6), .portfolio-table td:nth-child(6) { width: 14%; }
.portfolio-table th:nth-child(7), .portfolio-table td:nth-child(7) { width: 13%; }
.portfolio-table th:nth-child(8), .portfolio-table td:nth-child(8) { width: 15%; }

.align-middle { vertical-align: middle; }

/* Numbers in tables should be right-aligned */
.text-end { text-align: right !important; }


/* ===========================================================================
   11. BADGES / CHIPS / STATUS
   =========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  line-height: 18px;
  white-space: nowrap;
}

.badge.bg-primary {
  background: var(--color-accent-blue-soft) !important;
  color: var(--color-accent-blue) !important;
  border: 1px solid rgba(59, 130, 246, 0.15);
}

.badge.bg-success {
  background: var(--color-success-soft) !important;
  color: var(--color-success) !important;
  border: 1px solid rgba(22, 163, 74, 0.15);
}

.badge.bg-danger {
  background: var(--color-danger-soft) !important;
  color: var(--color-danger) !important;
  border: 1px solid rgba(220, 38, 38, 0.15);
}

.badge.bg-warning {
  background: var(--color-warning-soft) !important;
  color: #92400E !important;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge.bg-info {
  background: var(--color-info-soft) !important;
  color: var(--color-info) !important;
  border: 1px solid rgba(37, 99, 235, 0.15);
}

.badge.bg-secondary,
.badge.text-bg-secondary {
  background: var(--color-bg-muted) !important;
  color: var(--text-muted) !important;
  border: 1px solid var(--border-default);
}

.badge.text-dark {
  color: var(--text-primary) !important;
}

.badge.text-light {
  color: var(--text-secondary) !important;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-default);
  background: var(--bg-chip);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
}

.chip .badge {
  padding: 2px var(--space-2);
  font-size: 11px;
}

/* Badge sizes used in profile */
.fs-6 { font-size: 14px !important; }
.py-2 { padding-top: var(--space-2) !important; padding-bottom: var(--space-2) !important; }
.px-3 { padding-left: var(--space-4) !important; padding-right: var(--space-4) !important; }


/* ===========================================================================
   12. ALERTS / MESSAGES
   ===========================================================================
   Left accent bar style.  Soft background, prominent title.
   =========================================================================== */
.alerts {
  display: grid;
  gap: var(--space-3);
}

.alert {
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: var(--space-4) var(--space-5);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 22px;
  position: relative;
  border-left: 4px solid var(--color-accent-blue);
}

.alert-success {
  border-left-color: var(--color-success);
  background: var(--color-success-soft);
}

.alert-danger,
.alert-error {
  border-left-color: var(--color-danger);
  background: var(--color-danger-soft);
}

.alert-warning {
  border-left-color: var(--color-warning);
  background: var(--color-warning-soft);
}

.alert-info {
  border-left-color: var(--color-accent-blue);
  background: var(--color-accent-blue-soft);
}

.alert-text {
  flex: 1;
}

.alert-close {
  min-height: 28px !important;
  padding: 2px 8px !important;
}

.alert-dismissible { position: relative; }
.fade.show { opacity: 1; }


/* ===========================================================================
   13. MODALS
   ===========================================================================
   Centralized modal styles — replaced inline <style> blocks in templates.
   All modal ids and JS hooks preserved.
   =========================================================================== */
.modal-backdrop-custom {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--color-overlay);
  z-index: var(--z-modal-backdrop);
  padding: var(--space-4);
}

.modal-backdrop-custom.show {
  display: flex;
}

.modal-dialog-custom {
  width: min(720px, 100%);
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
}

.debt-new-modal-dialog {
  width: min(920px, 100%);
}

.modal-content-custom {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-lg);
  font-size: 15px;
  line-height: 1.6;
}

.modal-header-custom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.modal-close-btn {
  background: none;
  border: 1px solid var(--border-default);
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-2xs);
  transition: background var(--transition), color var(--transition);
}

.modal-close-btn:hover {
  color: var(--text-primary);
  background: var(--color-bg-muted);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

.modal-body { /* semantic container for modal content */ }

/* Компактный вывод ответов ИИ (страницы отрасль / стратегия и т.п.) */
.ai-response-text {
  line-height: 1.45;
}

.ai-response-text p {
  margin: 0 0 0.65em;
}

.ai-response-text p:last-child {
  margin-bottom: 0;
}

.ai-response-readable {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-secondary);
}

.ai-response-readable ul,
.ai-response-readable ol {
  margin-bottom: var(--space-3);
}

/* Полноэкранная загрузка при долгом ИИ-запросе (форма → сервер) */
.ai-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 1080;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  background: var(--color-overlay);
}

.ai-loading-overlay[hidden] {
  display: none !important;
}

.ai-loading-overlay-card {
  max-width: 360px;
  text-align: center;
  padding: var(--space-8) var(--space-6);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
}

.ai-loading-overlay-card .preloader-spinner {
  margin: 0 auto var(--space-4);
}

.ai-loading-overlay-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

/* Загрузка внутри модалки ИИ портфеля */
.ai-analysis-main-stack {
  position: relative;
  min-height: 200px;
}

.ai-modal-loading {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-6);
  border-radius: var(--radius-lg);
  background: var(--color-overlay);
  backdrop-filter: blur(2px);
}

.ai-modal-loading.show {
  display: flex;
}

/* Body scroll lock when modal is open */
body.modal-open {
  overflow: hidden;
}

.nav-tier-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  background: var(--color-primary-soft);
  color: var(--color-primary-pressed);
  border: 1px solid var(--color-primary);
  align-self: center;
}

.pricing-cards-row .pricing-card {
  border: 1px solid var(--border-default);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.pricing-card-featured {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
}

.pricing-price {
  font-size: 1.5rem;
  font-weight: 700;
  margin: var(--space-2) 0 var(--space-3);
  color: var(--text-primary);
}

.modal-panel {
  width: min(720px, 100%);
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-lg);
}

.modal-panel-wide {
  width: min(960px, 100%);
}


/* ===========================================================================
   14. ACTION MENUS / DROPDOWNS
   ===========================================================================
   Floating white menus for portfolio/debt row actions.
   =========================================================================== */
.action-menu-wrap {
  position: relative;
}

.action-menu {
  position: fixed;
  min-width: 220px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  box-shadow: var(--shadow-md);
  display: none;
  z-index: var(--z-menu);
}

.action-menu.show {
  display: block;
}

.action-menu .btn {
  justify-content: center;
}

.action-menu-buttons {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  align-items: center;
}

/* Debt action menu — same concept, different class */
.debt-action-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.debt-action-menu {
  position: fixed;
  min-width: 320px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  box-shadow: var(--shadow-md);
  display: none;
  z-index: var(--z-menu);
}

.debt-action-menu.show {
  display: block;
}


/* ===========================================================================
   15. PROGRESS BARS
   =========================================================================== */
.progress {
  background: var(--color-bg-muted);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: var(--radius-pill);
  transition: width 0.4s ease;
}

.progress-bar.bg-success {
  background: var(--color-primary) !important;
}


/* ===========================================================================
   16. PRELOADER
   =========================================================================== */
#preloader {
  position: fixed;
  inset: 0;
  z-index: var(--z-preloader);
  display: grid;
  place-items: center;
  background: var(--bg-page);
  opacity: 1;
  visibility: visible;
  transition: opacity 260ms ease, visibility 260ms ease;
  will-change: opacity;
}

#preloader.is-hidden {
  opacity: 0;
  visibility: hidden;
}

.preloader-card {
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  box-shadow: var(--shadow-md);
  min-width: min(420px, 92vw);
  padding: var(--space-8) var(--space-6);
  text-align: center;
}

.preloader-title {
  margin-top: var(--space-4);
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--color-gradient-start), var(--color-gradient-end));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.preloader-subtitle {
  margin-top: var(--space-2);
  color: var(--text-muted);
  font-size: 14px;
}

.preloader-spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto;
  border-radius: var(--radius-pill);
  border: 3px solid var(--color-bg-muted);
  border-top-color: var(--color-primary);
  animation: spin 850ms linear infinite;
}


/* ===========================================================================
   17. ANIMATIONS
   =========================================================================== */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Legacy pulse animation kept for JS compat but gentler */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

@keyframes shimmer {
  0% { background-position: -180% 0; }
  100% { background-position: 180% 0; }
}

.reveal {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--duration-slow) var(--ease-standard), transform var(--duration-slow) var(--ease-standard);
  will-change: opacity, transform;
}

.reveal.is-visible {
  opacity: 1;
  transform: none;
}

.shimmer {
  background-image: linear-gradient(
    100deg,
    rgba(0, 0, 0, 0.0) 35%,
    rgba(0, 0, 0, 0.04) 50%,
    rgba(0, 0, 0, 0.0) 65%
  );
  background-size: 180% 100%;
  animation: shimmer 2.1s linear infinite;
}


/* ===========================================================================
   18. UTILITIES
   =========================================================================== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.d-flex { display: flex !important; }
.d-inline { display: inline !important; }
.d-inline-flex { display: inline-flex !important; }
.d-none { display: none !important; }
.d-block { display: block !important; }
.d-inline-block { display: inline-block !important; }
.justify-content-between { justify-content: space-between !important; }
.justify-content-center { justify-content: center !important; }
.justify-content-end { justify-content: flex-end !important; }
.align-items-center { align-items: center !important; }
.align-items-start { align-items: flex-start !important; }
.align-items-end { align-items: flex-end !important; }
.flex-wrap { flex-wrap: wrap !important; }
.flex-column { flex-direction: column !important; }
.text-center { text-align: center !important; }
.w-100 { width: 100% !important; }
.h-100 { height: 100% !important; }
.rounded { border-radius: var(--radius-lg) !important; }
.rounded-4 { border-radius: var(--radius-xl) !important; }
.small { font-size: 13px !important; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: var(--space-1) !important; }
.mb-2 { margin-bottom: var(--space-2) !important; }
.mb-3 { margin-bottom: var(--space-4) !important; }
.mb-4 { margin-bottom: var(--space-6) !important; }
.mb-6 { margin-bottom: var(--space-8) !important; }
.mt-1 { margin-top: var(--space-1) !important; }
.mt-2 { margin-top: var(--space-2) !important; }
.mt-3 { margin-top: var(--space-4) !important; }
.mt-4 { margin-top: var(--space-6) !important; }
.my-4 { margin-top: var(--space-6) !important; margin-bottom: var(--space-6) !important; }
.p-2 { padding: var(--space-2) !important; }
.p-3 { padding: var(--space-4) !important; }
.p-4 { padding: var(--space-6) !important; }
.p-5 { padding: var(--space-12) !important; }
.px-3 { padding-left: var(--space-4) !important; padding-right: var(--space-4) !important; }
.py-2 { padding-top: var(--space-2) !important; padding-bottom: var(--space-2) !important; }

.position-relative { position: relative; }

.border { border: 1px solid var(--border-default); }

/* List utilities */
.list-group {
  list-style: none;
  margin: 0;
  padding: 0;
}

.list-group-item {
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-2);
  background: var(--bg-surface);
}

.list-unstyled {
  list-style: none;
  padding-left: 0;
}

.collapse { display: none; }
.collapse.show { display: block; }

/* Topbar — used in some templates for page-level action bars */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
  padding: var(--space-3) 0;
}

.topbar-actions {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

/* Sidebar — preserved for future use */
.sidebar {
  width: 280px;
  min-height: 100%;
  border-right: 1px solid var(--border-default);
  background: var(--bg-surface);
  padding: var(--space-4);
}

.sidebar[data-collapsed="true"] {
  width: 84px;
  overflow: hidden;
}

.sidebar-title {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}

/* Asset row (alternative card layout for portfolio) */
.asset-row {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 0.8fr auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
}

.asset-row + .asset-row {
  margin-top: var(--space-2);
}

.asset-meta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* Content text — used in learning detail */
.content-text {
  font-size: 16px;
  line-height: 28px;
  color: var(--text-secondary);
  max-width: var(--reading-max);
}

/* Placeholder containers */
[data-media-placeholder] {
  border: 1px dashed var(--border-default);
  border-radius: var(--radius-lg);
  background: var(--color-bg-soft);
}


/* ===========================================================================
   19. ACCESSIBLE FOCUS STATES
   =========================================================================== */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

/* Disabled elements should never show focus/hover */
.btn:disabled:hover,
.btn:disabled:focus,
.btn[disabled]:hover,
.btn[disabled]:focus {
  box-shadow: none;
  background: inherit;
  border-color: inherit;
}


/* ===========================================================================
   20. RESPONSIVE BREAKPOINTS
   ===========================================================================
   xs: 360  |  sm: 480  |  md: 768  |  lg: 1024  |  xl: 1280  |  xxl: 1440
   =========================================================================== */

/* ---- Mobile: up to 479px ---- */
@media (max-width: 479px) {
  .container {
    padding-inline: var(--space-4);
    padding-block: var(--space-4);
  }

  h1 { font-size: 32px; line-height: 40px; }
  h2 { font-size: 28px; line-height: 36px; }
  h3 { font-size: 22px; line-height: 30px; }
  h4 { font-size: 18px; line-height: 26px; }
  body { font-size: 15px; line-height: 24px; }

  .btn { min-height: 40px; padding: var(--space-2) var(--space-4); }
  .btn-lg { min-height: 46px; }
  .btn-sm { min-height: 34px; }

  .form-control, .form-select, input, select, textarea {
    min-height: 44px;
  }

  .card { padding: var(--space-4); }
  .modal-content-custom { padding: var(--space-4); }
  .preloader-card { padding: var(--space-6) var(--space-4); }

  .table { font-size: 13px; }
  .table thead th { font-size: 11px; padding: var(--space-2) var(--space-2); }
  .table tbody td { padding: var(--space-2) var(--space-2); font-size: 13px; }

  .table-dark { font-size: 13px; }
  .table-dark thead th { font-size: 11px; padding: var(--space-2) var(--space-2); }
  .table-dark tbody td { padding: var(--space-2) var(--space-2); font-size: 13px; }

  .table-sm thead th,
  .table-sm tbody td {
    padding: var(--space-1) var(--space-2);
    font-size: 12px;
  }

  .portfolio-table thead th,
  .portfolio-table tbody td {
    padding: var(--space-1) var(--space-1);
    font-size: 11px;
  }

  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }

  /* Header: stack brand above nav, nav wraps into rows */
  .header-inner {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-2);
    padding-top: var(--space-3);
    padding-bottom: var(--space-3);
  }

  .brand {
    font-size: 16px;
  }

  .brand-mark {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }

  .nav {
    justify-content: flex-start;
    gap: var(--space-2);
    row-gap: var(--space-2);
    width: 100%;
  }

  .nav .btn {
    font-size: 12px;
    min-height: 34px;
    padding: var(--space-1) var(--space-3);
  }

  .nav-link {
    font-size: 13px;
    min-height: 32px;
    padding: var(--space-1) var(--space-2);
  }

  .nav-divider { display: none; }

  /* Footer: stack and center */
  .footer-inner {
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    text-align: center;
    padding-top: var(--space-3);
    padding-bottom: var(--space-3);
  }

  .footer-end {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
  }

  .footer-ui-variants {
    text-align: center;
  }

  .footer-nav {
    gap: var(--space-3);
  }

  .asset-row {
    grid-template-columns: 1fr;
    align-items: flex-start;
  }

  .display-xl { font-size: 36px; line-height: 42px; }
  .display-lg { font-size: 32px; line-height: 38px; }
}

/* ---- Small tablet / Large mobile: 480–767px ---- */
@media (min-width: 480px) and (max-width: 767px) {
  .container {
    padding-inline: var(--space-5);
    padding-block: var(--space-5);
  }

  h1 { font-size: 36px; line-height: 44px; }
  h2 { font-size: 30px; line-height: 38px; }
  h3 { font-size: 24px; line-height: 32px; }

  .btn { min-height: 42px; }

  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .col-sm-6 { width: 50%; }

  .nav .btn {
    font-size: 13px;
    min-height: 36px;
  }

  .nav-link {
    font-size: 13px;
  }

  .table { font-size: 13px; }
  .table thead th { font-size: 12px; padding: var(--space-2) var(--space-3); }
  .table tbody td { padding: var(--space-2) var(--space-3); }

  .table-dark { font-size: 13px; }
  .table-dark thead th { font-size: 12px; padding: var(--space-2) var(--space-3); }
  .table-dark tbody td { padding: var(--space-2) var(--space-3); }

  .portfolio-table thead th,
  .portfolio-table tbody td {
    padding: var(--space-1) var(--space-2);
    font-size: 12px;
  }
}

/* ---- Tablet: 768–1023px ---- */
@media (min-width: 768px) {
  .col-md-3 { width: 25%; }
  .col-md-4 { width: 33.3333%; }
  .col-md-6 { width: 50%; }
  .col-md-8 { width: 66.6667%; }
  .text-md-end { text-align: right !important; }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .container {
    padding-inline: var(--space-6);
    padding-block: var(--space-6);
  }

  h1 { font-size: 40px; line-height: 48px; }
  h2 { font-size: 32px; line-height: 40px; }
  h3 { font-size: 26px; line-height: 34px; }

  .card { padding: var(--space-5); }

  .table { font-size: 14px; }
  .table thead th { font-size: 13px; padding: var(--space-3) var(--space-3); }
  .table tbody td { padding: var(--space-3) var(--space-3); }

  .table-dark { font-size: 14px; }
  .table-dark thead th { font-size: 13px; padding: var(--space-3) var(--space-3); }
  .table-dark tbody td { padding: var(--space-3) var(--space-3); }

  .portfolio-table thead th,
  .portfolio-table tbody td {
    padding: var(--space-2) var(--space-2);
    font-size: 13px;
  }

  .table-sm thead th,
  .table-sm tbody td {
    padding: var(--space-2) var(--space-2);
    font-size: 13px;
  }
}

/* ---- Desktop: 1024–1279px ---- */
@media (min-width: 1024px) {
  .col-lg-4 { width: 33.3333%; }
  .col-lg-6 { width: 50%; }
  .col-lg-8 { width: 66.6667%; }
  .p-lg-5 { padding: var(--space-12) !important; }
}

/* ---- Large desktop: 1280+ ---- */
@media (min-width: 1280px) {
  .col-xl-4 { width: 33.3333%; }

  .container {
    max-width: var(--content-max);
  }

  .table { font-size: 15px; }
  .table thead th { font-size: 13px; padding: var(--space-4) var(--space-4); }
  .table tbody td { padding: var(--space-4) var(--space-4); }

  .table-dark { font-size: 15px; }
  .table-dark thead th { font-size: 13px; padding: var(--space-4) var(--space-4); }
  .table-dark tbody td { padding: var(--space-4) var(--space-4); }

  .portfolio-table thead th,
  .portfolio-table tbody td {
    padding: var(--space-3) var(--space-3);
    font-size: 14px;
  }
}

/* ---- Max-width for all under-768 ---- */
@media (max-width: 767px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }

  .header-inner {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-2);
  }

  .nav {
    justify-content: flex-start;
    width: 100%;
  }

  .nav-divider { display: none; }

  .nav {
    flex-wrap: wrap;
    gap: var(--space-1);
  }

  .nav .nav-link,
  .nav .btn {
    min-height: 44px;
    padding-top: var(--space-2);
    padding-bottom: var(--space-2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .modal-backdrop-custom {
    padding: 0;
    align-items: stretch;
  }

  .modal-dialog-custom,
  .modal-panel,
  .modal-panel-wide {
    width: 100%;
    max-width: none;
    max-height: none;
    min-height: 100vh;
    border-radius: 0;
  }

  .modal-content-custom {
    border-radius: 0;
    min-height: 100vh;
  }

  .modal-close-btn {
    min-width: 44px;
    min-height: 44px;
  }

  .footer-inner {
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    text-align: center;
  }

  .footer-end {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
  }

  .footer-ui-variants {
    text-align: center;
  }

  .col-md-3, .col-md-4, .col-md-6, .col-md-8 {
    width: 100%;
  }

  .action-menu-buttons {
    gap: var(--space-1);
  }

  .table { font-size: 13px; }
  .table thead th { font-size: 12px; }
  .table tbody td { font-size: 13px; }

  .table-dark { font-size: 13px; }
  .table-dark thead th { font-size: 12px; }
  .table-dark tbody td { font-size: 13px; }

  .portfolio-table thead th,
  .portfolio-table tbody td {
    padding: var(--space-1) var(--space-2);
    font-size: 12px;
  }

  .table-sm thead th,
  .table-sm tbody td {
    padding: var(--space-1) var(--space-2);
    font-size: 12px;
  }
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }

  .reveal {
    opacity: 1 !important;
    transform: none !important;
    will-change: auto;
  }
}


/* ===========================================================================
   21. PAGE-SPECIFIC REFINEMENTS
   ===========================================================================
   Minimal overrides for specific pages where global components need
   contextual tweaks.
   =========================================================================== */

/* Strategy result panel — readable AI output */
.bg-dark[style*="white-space: pre-wrap"] {
  font-family: Inter, system-ui, sans-serif;
  font-size: 14px;
  line-height: 24px;
  max-width: var(--reading-max);
  color: var(--text-secondary);
}

/* Industry panel selector + бюджет «Фильтр по категории» (тот же паттерн, что в калькуляторе стратегии) */
#ai-industries-panel,
#category-filter-panel {
  background: var(--bg-surface-elevated) !important;
  border-color: var(--border-default) !important;
  box-shadow: var(--shadow-md);
}

/* Chart container in strategy calculator */
.bg-dark.rounded.p-2 svg {
  max-width: 100%;
  height: auto;
}

/* Portfolio group filter chips */
#group-filter-chips .filter-chip {
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

#group-filter-chips .filter-chip.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-white);
}

/* Group row hover in modal */
.group-row:hover {
  background: var(--color-bg-soft);
}

/* Platform grid cards */
#platforms-grid a:hover {
  border-color: var(--color-primary) !important;
  box-shadow: var(--shadow-sm);
}

@media (max-width: 479px) {
  #platforms-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }

  #platforms-grid a {
    padding: var(--space-2) !important;
    min-height: 48px !important;
    font-size: 12px;
  }
}

/* --------------------------------------------------------------------------
   Device-specific layouts (NEXTFIN_UI / ?ui=) — бюджет, портфель, долги
   -------------------------------------------------------------------------- */

.btn-budget-touch {
  min-height: 44px;
  min-width: 44px;
  padding: var(--space-2) var(--space-3);
}

.budget-page--mobile .budget-mobile-card {
  border: 1px solid var(--color-border-soft);
}

/* Мобильный бюджет: порядок дата → сумма → кнопки; выравнивание по вертикали */
.budget-page--mobile .budget-mobile-card-toolbar {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.budget-page--mobile .budget-mobile-card-actions {
  margin-left: auto;
}

.budget-page--mobile .budget-mobile-day {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.2;
}

.budget-page--mobile .budget-mobile-amount {
  font-size: 1.05rem;
  line-height: 1.25;
}

.budget-detail-dialog {
  max-width: min(420px, 92vw);
}

.budget-detail-backdrop.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.budget-month-totals--mobile {
  font-size: 0.8rem;
}

.portfolio-page--tablet .btn-sm,
.portfolio-page--tablet .btn {
  min-height: 44px;
}

.portfolio-page--mobile .portfolio-mobile-card {
  border: 1px solid var(--color-border-soft);
}

.portfolio-page--mobile .portfolio-mobile-list {
  display: block;
}

.debt-page--mobile .bg-surface.p-4.rounded {
  padding: var(--space-4) !important;
}

.debt-page--mobile .debt-payment-scroll {
  max-height: 200px;
  overflow-y: auto;
}

.debt-page--mobile .debt-active-card,
.debt-page--mobile .debt-history-card {
  border: 1px solid var(--color-border-soft);
}

.recurring-page--mobile .border-bottom {
  border-color: var(--color-border-soft) !important;
}
