:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-soft: #f8f9fc;
  --text: #182033;
  --muted: #6d7485;
  --line: #e7e9f0;
  --primary: #5d49e8;
  --primary-dark: #4937ca;
  --primary-soft: #eeebff;
  --success: #178f64;
  --success-soft: #e9f7f1;
  --danger: #d34a5a;
  --danger-soft: #fff0f2;
  --warning: #d88323;
  --warning-soft: #fff5e9;
  --info: #326cd5;
  --info-soft: #edf4ff;
  --shadow: 0 12px 35px rgba(35, 42, 68, 0.08);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input { font: inherit; }

button { cursor: pointer; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
}

.app-shell.is-locked {
  display: block;
}

.app-shell.is-locked .sidebar,
.app-shell.is-locked .topbar {
  display: none;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 24px 20px;
  color: #fff;
  background: linear-gradient(180deg, #20233f 0%, #181b31 100%);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(135deg, #7b68ff, #5c48e8);
  font-weight: 800;
}

.brand-name { font-size: 18px; font-weight: 800; }
.brand-subtitle { margin-top: 2px; color: rgba(255,255,255,0.56); font-size: 12px; }

.primary-button,
.secondary-button,
.text-button,
.icon-button,
.nav-item,
.support-card {
  border: 0;
  background: none;
}

.primary-button,
.secondary-button {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
  border-radius: 13px;
  font-weight: 750;
}

.primary-button {
  color: #fff;
  background: var(--primary);
  box-shadow: 0 8px 20px rgba(93, 73, 232, 0.2);
}

.primary-button:hover { background: var(--primary-dark); }

.secondary-button {
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
}

.primary-button.small,
.secondary-button.small {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 10px;
  font-size: 14px;
}

.new-application-button {
  width: 100%;
  margin-bottom: 18px;
}

.button-icon { font-size: 20px; line-height: 1; }

.main-nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  min-height: 48px;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 13px;
  border-radius: 12px;
  color: rgba(255,255,255,0.66);
  text-align: left;
  font-weight: 650;
}

.nav-item:hover,
.nav-item.is-active {
  color: #fff;
  background: rgba(255,255,255,0.09);
}

.nav-icon {
  width: 22px;
  display: grid;
  place-items: center;
  color: rgba(255,255,255,0.7);
}

.nav-badge {
  margin-left: auto;
  min-width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 12px;
  background: rgba(255,255,255,0.1);
}

.sidebar-footer { margin-top: auto; }

.support-card {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  color: #fff;
  text-align: left;
  background: rgba(255,255,255,0.04);
}

.support-card small { color: rgba(255,255,255,0.5); }

.support-icon {
  flex: 0 0 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: rgba(123,104,255,0.22);
  color: #bfb6ff;
  font-weight: 800;
}

.support-panel {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  background: rgba(255,255,255,0.05);
}

.support-history {
  max-height: 220px;
  overflow-y: auto;
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.support-empty {
  color: rgba(255,255,255,0.52);
  font-size: 13px;
  line-height: 1.35;
}

.support-bubble {
  max-width: 94%;
  display: grid;
  gap: 3px;
  padding: 9px 10px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.support-bubble.is-client {
  justify-self: end;
  color: #fff;
  background: var(--primary);
}

.support-bubble.is-manager {
  justify-self: start;
  color: rgba(255,255,255,0.9);
  background: rgba(255,255,255,0.09);
}

.support-author {
  color: rgba(255,255,255,0.55);
  font-size: 11px;
  font-weight: 750;
}

.support-panel textarea {
  width: 100%;
  min-height: 88px;
  resize: vertical;
  padding: 10px 11px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  color: #fff;
  background: rgba(9, 13, 32, 0.55);
  font: inherit;
}

.support-panel textarea::placeholder {
  color: rgba(255,255,255,0.45);
}

.support-send {
  width: 100%;
  min-height: 40px;
  margin-top: 10px;
  border-radius: 12px;
}

.main-area { min-width: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 36px;
  background: rgba(246,247,251,0.9);
  border-bottom: 1px solid rgba(231,233,240,0.8);
  backdrop-filter: blur(18px);
}

.company-summary,
.topbar-actions {
  display: flex;
  align-items: center;
}

.company-summary { gap: 11px; }

.company-logo {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: var(--primary);
  background: var(--primary-soft);
  font-weight: 800;
}

.company-summary div:last-child { display: grid; gap: 2px; }
.company-summary span { color: var(--muted); font-size: 12px; }
.topbar-actions { gap: 10px; }

.page {
  display: none;
  max-width: 1450px;
  margin: 0 auto;
  padding: 34px 36px 58px;
}

.page.is-active { display: block; }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 28px;
}

.page-header.compact { margin-bottom: 24px; }

.eyebrow {
  margin: 0 0 7px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p { margin-top: 0; }

h1 {
  margin-bottom: 10px;
  font-size: 36px;
  line-height: 1.12;
}

h2 { margin-bottom: 6px; font-size: 20px; }
h3 { margin-bottom: 5px; font-size: 16px; }

.page-description,
.section-heading-row p,
.card-text,
.content-card p,
.bank-card p { color: var(--muted); line-height: 1.55; }

.page-description { max-width: 720px; margin-bottom: 0; }

.auth-panel {
  max-width: 1450px;
  margin: 24px auto 0;
  padding: 24px 36px;
}

.app-shell.is-locked .auth-panel {
  max-width: 760px;
  margin-top: 12vh;
}

.auth-grid {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) minmax(160px, 1fr) minmax(160px, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-top: 18px;
}

.auth-grid label { display: grid; gap: 6px; min-width: 0; font-weight: 700; }
.auth-grid span { color: var(--muted); font-size: 13px; }
.auth-grid input {
  min-width: 0;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 12px;
}

.status-line {
  display: none;
  max-width: 1450px;
  margin: 18px auto 0;
  padding: 12px 16px;
  color: var(--muted);
}

.status-line.is-visible { display: block; }

.auth-panel,
.status-line,
.content-card,
.metric-card,
.application-card,
.document-row,
.company-panel,
.empty-state {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 7px 24px rgba(35, 42, 68, 0.04);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.metric-card {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 18px;
}

.metric-icon {
  flex: 0 0 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  font-size: 20px;
  font-weight: 850;
}

.metric-icon.violet { color: var(--primary); background: var(--primary-soft); }
.metric-icon.green { color: var(--success); background: var(--success-soft); }
.metric-icon.orange { color: var(--warning); background: var(--warning-soft); }
.metric-card span,
.metric-card small { color: var(--muted); }
.metric-card strong { font-size: 24px; }
.metric-card small { font-size: 12px; }

.content-card { padding: 22px; }

.section-heading-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
}

.section-heading-row p { margin-bottom: 0; font-size: 14px; }

.text-button {
  color: var(--primary);
  font-weight: 750;
}

.bottom-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 16px;
  margin-top: 22px;
}

.bottom-grid > [hidden] {
  display: none !important;
}

.bottom-grid > [hidden] + .content-card {
  grid-column: 1 / -1;
}

.application-list {
  display: grid;
  gap: 12px;
}

.application-card {
  padding: 18px;
}

.application-card--detail {
  padding: 0;
  border: 0;
  box-shadow: none;
  background: transparent;
}

.application-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.application-title {
  font-weight: 800;
  font-size: 17px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
  background: #f0f1f5;
  color: #656c7c;
  white-space: nowrap;
}

.badge.action_required,
.badge.payment_required,
.badge.sign_application,
.badge.final_signing,
.badge.needs_revision { background: var(--warning-soft); color: var(--warning); }

.badge.issued,
.badge.approved { background: var(--success-soft); color: var(--success); }
.badge.rejected { background: var(--danger-soft); color: var(--danger); }

.guarantee-finale {
  position: relative;
  min-height: 250px;
  display: grid;
  align-items: center;
  overflow: hidden;
  margin: 10px 0 14px;
  padding: 24px 28px;
  border: 1px solid #bbf7d0;
  border-radius: 18px;
  background:
    linear-gradient(135deg, #f0fdf4, #eff6ff 58%, #fff7ed);
}

.guarantee-finale::before,
.guarantee-finale::after {
  content: "✦ ✧ ✦ ✧ ✦";
  position: absolute;
  top: 18px;
  color: rgba(245, 158, 11, .8);
  font-size: 22px;
  letter-spacing: 10px;
  animation: finale-sparkle 1.6s ease-in-out infinite alternate;
}

.guarantee-finale::before { left: 18px; }
.guarantee-finale::after {
  right: 18px;
  animation-delay: .45s;
}

.guarantee-finale__copy {
  position: relative;
  z-index: 2;
  max-width: 430px;
  display: grid;
  gap: 7px;
}

.guarantee-finale__eyebrow {
  width: fit-content;
  padding: 5px 10px;
  border-radius: 999px;
  background: #dcfce7;
  color: #047857;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.guarantee-finale__copy strong {
  color: var(--text);
  font-size: clamp(24px, 4vw, 38px);
  line-height: 1.05;
}

.guarantee-finale__copy span:last-child {
  color: var(--muted);
  font-size: 15px;
}

.guarantee-finale__video {
  position: absolute;

  left: 28px;
  top: 126px;
  bottom: 4px;

  width: 385px;
  height: auto;

  max-width: none;
  max-height: none;

  object-fit: cover;
  object-position: center;

  border-radius: 0 0 18px 18px;
  background: transparent;

  animation: none;
}

@keyframes cat-run-across {
  0% { transform: translateX(110%); }
  100% { transform: translateX(-235%); }
}

@keyframes finale-sparkle {
  from { opacity: .35; transform: translateY(0) scale(.98); }
  to { opacity: 1; transform: translateY(6px) scale(1.04); }
}

@media (max-width: 760px) {
  .guarantee-finale {
    min-height: 300px;
    padding: 18px;
    align-items: start;
  }

  .guarantee-finale__video {
    width: min(340px, 86vw);
    max-height: 170px;
    border-radius: 16px;
    bottom: 14px;
  }
}

.bank-grid--focus .bank-card > .guarantee-finale {
  grid-column: 1 / -1;
  justify-self: stretch;
  width: 100%;
  box-sizing: border-box;
  padding-right: 260px;
  padding-bottom: 235px;
}

.bank-grid--focus .bank-card > .guarantee-document-actions {
  grid-column: 2 / -1;
}

.guarantee-finale::before,
.guarantee-finale::after {
  content: "*** *** ***";
  z-index: 1;
}

.guarantee-finale__copy {
  z-index: 3;
  max-width: 520px;
  margin-bottom: 270px;
}

.guarantee-finale__video {
  z-index: 2;
  left: 0;
  right: auto;
  bottom: 12px;
  width: min(320px, 34vw);
  max-height: 178px;
  border-radius: 18px;
  background: #000;
  box-shadow: 0 18px 40px rgba(15, 23, 42, .18);
  animation: cat-run-across 9s linear infinite;
}

@keyframes cat-run-across {
  0% { left: 0; transform: translateX(-115%); }
  100% { left: 100%; transform: translateX(15%); }
}

@media (max-width: 760px) {
  .bank-grid--focus .bank-card > .guarantee-document-actions {
    grid-column: 1 / -1;
  }

  .guarantee-finale__video {
    left: 0;
    width: min(260px, 78vw);
  }

  @keyframes cat-run-across {
    0% { left: 0; transform: translateX(-115%); }
    100% { left: 100%; transform: translateX(15%); }
  }
}

.guarantee-finale__video {
  --cat-video-width: 360px;
  left: 24px;
  right: auto;
  bottom: 14px;
  width: var(--cat-video-width);
  height: 190px;
  object-fit: contain;
  object-position: left bottom;
  animation: none;
}

.guarantee-finale__actions {
  position: absolute;
  z-index: 4;
  top: 50%;
  right: 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 180px;
  transform: translateY(-50%);
}

.guarantee-finale__actions .secondary-button {
  justify-content: center;
  width: 100%;
}

@keyframes cat-run-strip {
  0% { left: calc(-1 * var(--cat-video-width)); transform: none; }
  100% { left: calc(100% + 40px); transform: none; }
}

@media (max-width: 760px) {
  .guarantee-finale__video {
    --cat-video-width: 260px;
    left: 18px;
    height: 160px;
  }

  .bank-grid--focus .bank-card > .guarantee-finale {
    padding-right: 18px;
    padding-bottom: 210px;
  }

  .guarantee-finale__actions {
    position: relative;
    top: auto;
    right: auto;
    margin-top: 14px;
    max-width: 260px;
    transform: none;
  }
}

.bank-grid--focus .bank-card > .guarantee-finale {
  min-height: 460px;
  padding: 34px 300px 34px 32px;
}

.guarantee-finale__eyebrow {
  display: none;
}

.guarantee-finale__video {
  left: 28px;
  bottom: 24px;
  width: 560px;
  height: 260px;
  max-width: calc(100% - 320px);
  object-fit: contain;
  object-position: center center;
  background: #f0fbf8;
}

@media (max-width: 760px) {
  .bank-grid--focus .bank-card > .guarantee-finale {
    min-height: 430px;
    padding-bottom: 300px;
  }

  .guarantee-finale__video {
    --cat-video-height: 240px;
    max-width: calc(100% - 36px);
  }
}

.guarantee-finale__video {
  width: 560px;
  height: 340px;
  aspect-ratio: auto;
}

@media (max-width: 760px) {
  .guarantee-finale__video {
    width: calc(100% - 36px);
    height: 320px;
  }
}

.bank-grid--focus .bank-card > .guarantee-finale {
  min-height: 540px;
}

.guarantee-finale__video {
  top: 160px;
  bottom: auto;
  left: 32px;
  width: 260px;
  height: 340px;
  max-width: none;
  object-fit: contain;
  object-position: center center;
  background: #f0fbf8;
  display: block;
}

@media (max-width: 760px) {
  .bank-grid--focus .bank-card > .guarantee-finale {
    min-height: 530px;
  }

  .guarantee-finale__video {
    top: 185px;
    left: 18px;
    width: 220px;
    height: 300px;
  }
}

.tracker {
  display: grid;
  grid-template-columns: repeat(9, minmax(72px, 1fr));
  gap: 8px;
  margin: 16px 0;
}

.stage {
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px;
  background: var(--surface-soft);
}

.stage.is-done {
  border-color: #9fd8c5;
  background: var(--success-soft);
}

.stage.is-current {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: inset 0 0 0 1px rgba(93, 73, 232, .15);
}

.stage-num {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  margin-bottom: 7px;
  border-radius: 999px;
  color: #fff;
  background: #a5aaba;
  font-weight: 800;
}

.stage.is-done .stage-num { background: var(--success); }
.stage.is-current .stage-num { background: var(--primary); }

.stage-name {
  font-size: 12px;
  line-height: 1.25;
}

.bank-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.bank-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: #fff;
}

.document-list { display: grid; gap: 8px; }

.document-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
}

.document-name { overflow-wrap: anywhere; }
.document-meta { color: var(--muted); font-size: 13px; white-space: nowrap; }
.company-panel,
.empty-state { padding: 16px; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(24, 27, 49, .58);
}

.widget-modal {
  width: min(1180px, 100%);
  height: min(880px, 92vh);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border-radius: 22px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 30px 80px rgba(10, 15, 30, .28);
}

.widget-modal-header {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.icon-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--line);
  font-size: 24px;
}

#application-widget-frame {
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  background: #fff;
}

/* Prototype-like first screen */
body.portal-ready .app-shell,
body.portal-ready .app-shell.is-locked {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
}

body.portal-ready .app-shell .sidebar,
body.portal-ready .app-shell.is-locked .sidebar {
  display: flex;
}

body.portal-ready .app-shell .topbar,
body.portal-ready .app-shell.is-locked .topbar {
  display: flex;
}

body.portal-ready .auth-panel {
  display: none !important;
}

.app-shell {
  grid-template-columns: 330px minmax(0, 1fr);
}

.sidebar {
  padding: 24px 25px;
  background: linear-gradient(180deg, #25264b 0%, #171a30 100%);
}

.brand-mark {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  font-size: 18px;
}

.new-application-button {
  min-height: 58px;
  margin: 34px 0 20px;
  border-radius: 15px;
  font-size: 20px;
}

.nav-item {
  min-height: 58px;
  padding: 0 20px;
  border-radius: 13px;
  font-size: 20px;
}

.support-card {
  min-height: 92px;
  border-radius: 18px;
}

.topbar {
  min-height: 88px;
  background: #f7f8fc;
}

#page-dashboard {
  max-width: none;
  padding: 28px 36px 58px 44px;
}

#page-dashboard .page-header {
  display: block;
  margin: 0 0 2px;
}

#page-dashboard .page-header h1 {
  margin: 0 0 8px;
  font-size: 48px;
  line-height: 1.08;
}

#page-dashboard .page-header h2 {
  margin: 0 0 10px;
  font-size: 24px;
}

.dashboard-all-link {
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 19px;
}

#page-dashboard .metrics-grid,
#page-dashboard > .content-card > .section-heading-row,
#page-dashboard .bottom-grid > .content-card:last-child {
  display: none;
}

#page-dashboard .bottom-grid {
  grid-template-columns: 1fr;
}

#page-dashboard > .content-card {
  padding: 0;
  border-color: #f1ccd2;
  border-radius: 28px;
  overflow: hidden;
  box-shadow: 0 18px 48px rgba(28, 34, 62, 0.08);
}

#current-application {
  padding: 34px 30px 30px;
}

.application-card--detail .application-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: start;
  gap: 20px;
  margin-bottom: 42px;
}

.application-card--detail .application-title {
  font-size: 32px;
  line-height: 1;
}

.application-subtitle {
  margin-top: 6px;
  color: var(--primary);
  font-size: 14px;
  font-weight: 850;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.application-amount-main {
  align-self: center;
  font-size: 34px;
  line-height: 1;
  white-space: nowrap;
}

.application-list-amount {
  align-self: center;
  margin-left: auto;
  color: var(--ink);
  font-size: 30px;
  line-height: 1;
  font-weight: 900;
  white-space: nowrap;
}

.application-card:not(.application-card--detail) .application-header {
  align-items: flex-start;
}

.application-card:not(.application-card--detail) .badge {
  align-self: center;
}

.application-toggle-button {
  align-self: center;
  margin-left: 4px;
}

.application-card--detail .tracker {
  position: relative;
  display: grid;
  grid-template-columns: repeat(9, minmax(86px, 1fr));
  gap: 18px;
  margin: 0 30px 34px;
}

.application-card--detail .tracker::before {
  content: "";
  position: absolute;
  left: 32px;
  right: 32px;
  top: 25px;
  height: 5px;
  border-radius: 999px;
  background: #dfe4ec;
}

.application-card--detail .stage {
  position: relative;
  z-index: 1;
  min-height: 98px;
  display: grid;
  justify-items: center;
  align-content: start;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: center;
}

.application-card--detail .stage-num {
  width: 52px;
  height: 52px;
  margin: 0 0 13px;
  border: 4px solid #d4dbe7;
  background: #fff;
  color: #8c96aa;
  box-shadow: 0 0 0 4px #f7f8fc;
}

.application-card--detail .stage.is-done .stage-num {
  border-color: #28b27e;
  background: #20a974;
  color: #fff;
}

.application-card--detail .stage.is-current .stage-num {
  border-color: #c9c2ff;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 0 0 7px rgba(93, 73, 232, .18);
}

.application-card--detail .stage-name {
  max-width: 130px;
  color: #748098;
  font-size: 13px;
  font-weight: 800;
}

.application-card--detail .stage.is-done .stage-name {
  color: #078254;
}

.application-card--detail .stage.is-current .stage-name {
  color: var(--primary);
}

.current-stage-panel {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 26px 28px;
  border: 1px solid #eadbe0;
  border-radius: 22px 22px 0 0;
  background: linear-gradient(135deg, #fff, #fbfbff);
}

.current-stage-panel > .badge {
  align-self: flex-start;
  min-height: 34px;
  padding: 0 16px;
}

.current-stage-copy h2 {
  margin: 0 0 10px;
  font-size: 28px;
}

.current-stage-copy p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 19px;
}

.bank-grid--focus {
  display: grid;
  grid-template-columns: 1fr;
  padding: 24px 26px;
  border: 1px solid #eadbe0;
  border-top: 0;
  border-radius: 0 0 22px 22px;
}

.bank-grid--focus .bank-card {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  align-items: center;
  gap: 20px;
  min-height: 116px;
  padding: 26px 30px;
  border-color: #f0dce0;
  border-radius: 20px;
}

.bank-initials {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: #fff;
  background: #ef472f;
  font-weight: 850;
}

.bank-main {
  min-width: 0;
}

.bank-grid--focus .bank-card h3 {
  margin: 0;
  font-size: 20px;
}

.bank-grid--focus .bank-card p {
  margin: 6px 0 0;
  font-size: 16px;
}

.bank-grid--focus .bank-card .badge {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
}

.bank-grid--focus .bank-card [data-signing-bank] {
  grid-column: 3;
  grid-row: 2;
  justify-self: end;
  align-self: center;
  min-width: 190px;
  min-height: 60px;
  padding: 0 28px;
  border-radius: 14px;
  font-size: 20px;
  line-height: 1;
  white-space: nowrap;
}

/* Prototype tracker */
.tracker {
  display: grid;
  grid-template-columns: repeat(9, minmax(92px, 1fr));
  gap: 0;
  margin: 26px 0 22px;
}

.stage {
  position: relative;
  min-height: 106px;
  display: grid;
  justify-items: center;
  align-content: start;
  padding: 0 6px;
  border: 0;
  border-radius: 0;
  background: transparent;
  text-align: center;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.stage:disabled {
  cursor: default;
}

.stage.is-done,
.stage.is-current {
  border: 0;
  background: transparent;
  box-shadow: none;
}

.stage::after {
  content: "";
  position: absolute;
  top: 25px;
  left: calc(50% + 26px);
  width: calc(100% - 52px);
  height: 5px;
  border-radius: 999px;
  background: #dfe4ec;
  z-index: 0;
}

.stage:last-child::after {
  display: none;
}

.stage.is-done::after {
  background: linear-gradient(90deg, #25ad78 0%, #6bd0aa 100%);
}

.stage.is-warning::after {
  background: linear-gradient(90deg, #f59e0b 0%, #fbc56a 100%);
}

.stage.is-error::after {
  background: linear-gradient(90deg, #ef4444 0%, #fb8f8f 100%);
}

.stage-num {
  position: relative;
  z-index: 1;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  margin: 0 0 12px;
  border: 4px solid #d4dbe7;
  border-radius: 999px;
  background: #fff;
  color: #8c96aa;
  box-shadow: 0 0 0 5px #f7f8fc;
  font-size: 16px;
  font-weight: 850;
  line-height: 1;
}

.stage.is-done .stage-num {
  border-color: #24ab75;
  background: linear-gradient(180deg, #2eba82 0%, #169665 100%);
  color: #fff;
  box-shadow: 0 12px 24px rgba(24, 150, 100, .22);
}

.stage.is-current .stage-num {
  border-color: #c9c2ff;
  background: linear-gradient(180deg, #7867ff 0%, #5542dc 100%);
  color: #fff;
  box-shadow: 0 0 0 8px rgba(93, 73, 232, .18), 0 16px 30px rgba(93, 73, 232, .24);
  animation: currentStageBreath 2.8s ease-in-out infinite;
}

.stage.is-warning .stage-num {
  border-color: #f59e0b;
  background: linear-gradient(180deg, #f6a623 0%, #e47a13 100%);
  color: #fff;
  box-shadow: 0 12px 24px rgba(228, 122, 19, .22);
}

.stage.is-warning.is-current .stage-num {
  box-shadow: 0 0 0 8px rgba(245, 158, 11, .18), 0 16px 30px rgba(228, 122, 19, .24);
}

.stage.is-error:not(.is-current) .stage-num {
  border-color: #ef4444;
  background: linear-gradient(180deg, #fb6f6f 0%, #dc2626 100%);
  color: #fff;
  box-shadow: 0 12px 24px rgba(220, 38, 38, .2);
}

.stage.is-selected:not(.is-current) .stage-num {
  box-shadow: 0 0 0 8px rgba(93, 73, 232, .14), 0 12px 24px rgba(93, 73, 232, .14);
}

.stage.is-current .stage-num::after {
  content: "";
  position: absolute;
  inset: -12px;
  border: 2px solid rgba(93, 73, 232, .16);
  border-radius: 999px;
  animation: currentStageHalo 2.8s ease-in-out infinite;
}

.stage.is-warning.is-current .stage-num::after {
  border-color: rgba(245, 158, 11, .24);
}

.stage-name {
  max-width: 136px;
  color: #738095;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.25;
}

.stage.is-done .stage-name {
  color: #078254;
}

.stage.is-current .stage-name {
  color: var(--primary);
}

.stage.is-warning .stage-name {
  color: #d97706;
}

.stage.is-error .stage-name {
  color: #dc2626;
}

.stage.is-selected:not(.is-current) .stage-name {
  color: var(--primary);
}

.application-card--detail .tracker {
  grid-template-columns: repeat(9, minmax(96px, 1fr));
  margin: 0 30px 36px;
}

.application-card--detail .tracker::before {
  display: none;
}

.application-card:not(.application-card--detail) .tracker {
  grid-template-columns: repeat(9, minmax(86px, 1fr));
  margin: 22px 0 18px;
}

.application-card:not(.application-card--detail) .stage {
  min-height: 104px;
}

.application-card:not(.application-card--detail) .stage-num {
  width: 46px;
  height: 46px;
  margin-bottom: 10px;
  font-size: 15px;
}

.application-card--expanded .current-stage-panel {
  margin-top: 18px;
}

.application-details {
  margin-top: 18px;
}

.stage-actions,
.layout-actions,
.invoice-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.stage-actions {
  min-width: 180px;
}

.bank-action-request {
  grid-column: 1 / -1;
  display: grid;
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
  margin-top: 8px;
  padding: 16px 18px;
  border: 1px solid #f3c46b;
  border-left: 5px solid #f59e0b;
  border-radius: 14px;
  background: #fff8e8;
}

.bank-grid--focus .bank-card > .bank-action-request {
  grid-column: 1 / -1;
  grid-row: auto;
  justify-self: stretch;
}

.bank-action-request__heading {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.bank-action-request__icon {
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: #f59e0b;
  color: #fff;
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
}

.bank-action-request__title {
  color: #9a3412;
  font-size: 15px;
  font-weight: 900;
}

.bank-action-request__subtitle {
  margin: 3px 0 0;
  color: #6b7280;
  font-size: 13px;
  font-weight: 700;
}

.bank-action-request__comment {
  padding: 12px 14px;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
  font-weight: 800;
  line-height: 1.45;
}

.bank-action-request__hint {
  color: #4b5563;
  font-size: 14px;
  font-weight: 800;
}

.bank-action-request__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.bank-action-request .stage-actions {
  min-width: 0;
}

.revision-upload-success {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid #a7e3c5;
  border-radius: 10px;
  background: #ecfdf5;
  color: #047857;
  font-size: 14px;
  font-weight: 850;
  line-height: 1.25;
}

.revision-upload-success__icon {
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #10b981;
  color: #fff;
  font-size: 13px;
  font-weight: 900;
}

@media (max-width: 560px) {
  .bank-action-request {
    padding: 14px;
  }

  .bank-action-request__actions,
  .bank-action-request .stage-actions {
    display: grid;
    width: 100%;
  }

  .bank-action-request__actions .primary-button,
  .bank-action-request__actions .secondary-button,
  .bank-action-request__actions .layout-upload-button {
    justify-content: center;
    width: 100%;
  }
}

.layout-upload-button {
  cursor: pointer;
}

.muted-small {
  color: #738095;
  font-size: 13px;
  font-weight: 700;
}

@keyframes currentStageBreath {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

@keyframes currentStageHalo {
  0%, 100% {
    opacity: .42;
    transform: scale(.86);
  }
  50% {
    opacity: .9;
    transform: scale(1.04);
  }
}

@media (prefers-reduced-motion: reduce) {
  .stage.is-current .stage-num,
  .stage.is-current .stage-num::after {
    animation: none;
  }
}

@media (max-width: 980px) {
  .app-shell { display: block; }
  .sidebar {
    position: static;
    height: auto;
    padding: 14px;
  }
  .main-nav { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .new-application-button { margin-bottom: 10px; }
  .topbar,
  .page-header,
  .bottom-grid { display: grid; }
  .page,
  .auth-panel { padding: 22px 18px 36px; }
  .metrics-grid,
  .auth-grid { grid-template-columns: 1fr; }
  .tracker { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .main-nav { grid-template-columns: 1fr; }
  .topbar { padding: 12px 18px; }
  h1 { font-size: 28px; }
  .document-row { grid-template-columns: 1fr; }
  .modal-backdrop { padding: 0; }
  .widget-modal {
    height: 100vh;
    border-radius: 0;
  }
}

/* FINAL: экран "Гарантия выпущена" */
.bank-grid--focus .bank-card > .guarantee-finale {
  position: relative;
  min-height: 500px;
}

/* Поднимаем текст наверх */
.bank-grid--focus .guarantee-finale__copy {
  position: absolute;
  top: 62px;
  left: 32px;

  margin: 0;
  max-width: 600px;

  z-index: 3;
}

/* Уменьшаем видео и опускаем под текст */
.bank-grid--focus .guarantee-finale__video {
  position: absolute;

  top: 155px;
  left: 32px;

  width: 300px;
  height: 360px;

  max-width: none;
  max-height: none;

  object-fit: contain;
  object-position: center bottom;

  border-radius: 18px;
  background: #f0fbf8;

  animation: none;
}
