/* Фара'On — modern automotive search interface */

:root {
  color-scheme: dark;

  --bg-primary: #06121c;
  --bg-secondary: #091824;
  --bg-card: #0d1c28;
  --bg-card-hover: #122737;
  --bg-input: #081721;

  --border-subtle: rgba(102, 171, 205, 0.18);
  --border-input: rgba(75, 171, 215, 0.38);
  --border-strong: rgba(80, 190, 236, 0.62);

  --text-primary: #eef7fb;
  --text-secondary: #a9c0cc;
  --text-tertiary: #718b99;
  --text-accent: #ddb86e;

  --accent-primary: #ddb86e;
  --accent-primary-light: #f2d596;
  --action-primary: #20a9df;
  --action-primary-hover: #52c9f3;
  --action-ink: #03131c;

  --color-success: #7da78a;
  --color-success-bg: rgba(125, 167, 138, 0.06);
  --color-warning: #be985f;
  --color-warning-bg: rgba(190, 152, 95, 0.06);
  --color-danger: #bd7473;
  --color-danger-bg: rgba(189, 116, 115, 0.06);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 999px;

  --font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --transition-fast: 140ms ease;
}

body.tg-theme {
  --bg-primary: #06121c;
  --bg-secondary: #091824;
  --bg-card: #0d1c28;
  --bg-input: #081721;
  --text-primary: #eef7fb;
  --text-secondary: #a9c0cc;
  --text-tertiary: #718b99;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  min-height: 100%;
  overscroll-behavior-y: none;
  background-color: var(--bg-primary);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  min-height: 100svh;
  overflow-x: hidden;
  overscroll-behavior-y: none;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 15px;
  line-height: 1.5;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
summary,
a {
  -webkit-tap-highlight-color: transparent;
}

:where(button, input, select, textarea, summary, a):focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

#app {
  width: 100%;
  max-width: 1120px;
  min-height: 100vh;
  min-height: 100svh;
  margin: 0 auto;
  padding: 0 max(16px, env(safe-area-inset-left)) max(28px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
}

.header,
.input-section,
.loading-section,
.error-section,
.result-section,
.scan-progress-section,
.footer {
  width: min(100%, 760px);
  margin-left: auto;
  margin-right: auto;
}

.header {
  padding: max(25px, env(safe-area-inset-top)) 0 22px;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.logo-icon {
  width: 78px;
  height: 62px;
  flex: 0 0 78px;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.logo-icon img {
  width: 92px;
  height: 92px;
  max-width: none;
  object-fit: contain;
}

.logo-text h1 {
  color: var(--text-primary);
  font-size: clamp(1.7rem, 5vw, 2.2rem);
  font-weight: 720;
  line-height: 1.04;
  letter-spacing: -0.045em;
}

.logo-text h1 span {
  color: var(--accent-primary-light);
}

.logo-kicker {
  display: block;
  margin-bottom: 4px;
  color: #58c7f0;
  font-size: 0.59rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.logo-subtitle {
  display: block;
  margin-top: 5px;
  color: var(--text-tertiary);
  font-size: 0.7rem;
  font-weight: 400;
  line-height: 1.35;
}

.input-section {
  margin-top: 4px;
}

.input-card,
.loading-card,
.result-content,
.deal-card {
  border: 1px solid var(--border-subtle);
  background: linear-gradient(155deg, rgba(15, 35, 49, 0.98), rgba(8, 23, 34, 0.98));
  box-shadow: 0 18px 50px rgba(0, 5, 10, 0.22);
}

.input-card {
  padding: 22px;
  border-color: rgba(62, 174, 220, 0.32);
  border-radius: var(--radius-lg);
}

.input-label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-secondary);
  font-size: 0.76rem;
  font-weight: 500;
}

.mode-tabs {
  display: flex;
  gap: 5px;
  margin-bottom: 22px;
  padding: 4px;
  border: 1px solid var(--border-subtle);
  border-radius: 13px;
  background: rgba(2, 14, 22, 0.62);
}

.mode-tab {
  position: relative;
  flex: 1;
  min-height: 40px;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  border-radius: 9px;
  font-size: 0.82rem;
  font-weight: 600;
  transition: color var(--transition-fast), background var(--transition-fast);
}

.mode-tab::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 1px;
  background: transparent;
}

.mode-tab.active {
  color: var(--text-primary);
  background: rgba(28, 142, 190, 0.18);
}

.mode-tab.active::after {
  right: 16px;
  left: 16px;
  background: #35b9ee;
}

.input-wrapper,
.text-input,
.filter-control {
  border: 1px solid var(--border-input);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  color: var(--text-primary);
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 50px;
  padding: 0 13px;
}

.input-wrapper:focus-within,
.text-input:focus,
.filter-control:focus {
  border-color: #42bdec;
  outline: none;
  background: #0b1d29;
  box-shadow: 0 0 0 3px rgba(38, 173, 224, 0.09);
}

.input-icon {
  display: flex;
  flex: 0 0 auto;
  color: var(--text-tertiary);
}

.input-wrapper:focus-within .input-icon {
  color: var(--text-secondary);
}

#avito-url {
  width: 100%;
  min-width: 0;
  padding: 14px 9px;
  border: 0;
  outline: 0;
  appearance: none;
  background: transparent !important;
  color: var(--text-primary) !important;
  -webkit-text-fill-color: var(--text-primary) !important;
  font-size: 1rem;
  font-weight: 400;
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
  touch-action: auto;
}

#avito-url::placeholder,
.text-input::placeholder {
  color: var(--text-tertiary) !important;
  -webkit-text-fill-color: var(--text-tertiary) !important;
  opacity: 1;
}

.clear-btn {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: color var(--transition-fast), background var(--transition-fast);
}

.text-input {
  width: 100%;
  min-height: 120px;
  max-height: 300px;
  padding: 13px;
  resize: vertical;
  outline: none;
}

.text-hint {
  margin-top: 8px;
  color: var(--text-tertiary);
  font-size: 0.72rem;
}

.platforms-hint,
.fixed-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.platforms-hint {
  margin-top: 11px;
}

.platform-badge,
.filter-chip {
  display: inline-flex;
  align-items: center;
  min-height: 27px;
  padding: 4px 8px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  background: rgba(13, 35, 49, 0.76);
  color: var(--text-secondary);
  font-size: 0.68rem;
  font-weight: 500;
}

.platform-badge.platform-ok {
  border-color: rgba(80, 190, 236, 0.27);
  background: rgba(35, 143, 186, 0.08);
  color: #a9d9eb;
}

.platform-badge.platform-text {
  color: var(--color-warning);
}

.url-warning {
  margin-top: 12px;
  padding: 11px 12px;
  border: 1px solid rgba(190, 152, 95, 0.35);
  border-left: 3px solid var(--color-warning);
  border-radius: var(--radius-sm);
  background: var(--color-warning-bg);
  color: var(--text-secondary);
  font-size: 0.78rem;
  line-height: 1.5;
}

.url-warning strong {
  color: var(--text-primary);
  font-weight: 600;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
  margin-top: 18px;
}

.filter-field {
  min-width: 0;
  color: var(--text-secondary);
  font-size: 0.74rem;
  font-weight: 500;
}

.filter-field > span {
  display: block;
  margin-bottom: 7px;
}

.filter-field-wide {
  grid-column: 1 / -1;
}

.filter-control {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 10px 12px;
  outline: none;
  color: var(--text-primary) !important;
  -webkit-text-fill-color: var(--text-primary) !important;
  font-size: 1rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025);
}

.filter-control option {
  background: var(--bg-card);
  color: var(--text-primary) !important;
  -webkit-text-fill-color: var(--text-primary) !important;
}

.scan-scope-hint {
  margin-top: 14px;
  color: var(--text-tertiary);
  font-size: 0.72rem;
  line-height: 1.5;
}

.scan-scope-hint strong {
  color: var(--text-secondary);
  font-weight: 500;
}

.location-hint {
  position: relative;
  margin-top: 10px;
  padding-left: 19px;
  color: #83b7ca;
  font-size: 0.72rem;
  line-height: 1.45;
}

.location-hint::before {
  content: "";
  position: absolute;
  top: 0.38em;
  left: 2px;
  width: 7px;
  height: 7px;
  border: 2px solid #45bde9;
  border-radius: 50% 50% 50% 0;
  rotate: -45deg;
}

.location-hint.is-ready {
  color: #76cda2;
}

.location-hint.is-muted {
  color: var(--text-tertiary);
}

.analyze-btn,
.deal-open-btn {
  border: 1px solid var(--action-primary);
  background: linear-gradient(135deg, #168ec2, #31b9eb);
  color: var(--action-ink);
  box-shadow: 0 10px 26px rgba(13, 143, 194, 0.22);
}

.analyze-btn {
  width: 100%;
  min-height: 50px;
  margin-top: 18px;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 750;
  letter-spacing: 0.01em;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

.analyze-btn:disabled {
  border-color: var(--border-subtle);
  background: var(--bg-input);
  color: var(--text-tertiary);
  box-shadow: none;
  cursor: not-allowed;
}

.btn-icon {
  display: flex;
}

.loading-section,
.error-section,
.result-section,
.scan-progress-section,
.scan-results-section {
  margin-top: 18px;
  animation: reveal 160ms ease-out both;
}

.loading-card {
  padding: 28px 20px;
  border-radius: var(--radius-lg);
  text-align: center;
}

.scan-progress-card {
  padding: 20px;
  text-align: left;
}

.loading-spinner {
  position: relative;
  width: 42px;
  height: 42px;
  margin: 0 auto 17px;
}

.spinner-ring {
  position: absolute;
  inset: 0;
  border: 2px solid var(--border-subtle);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 850ms linear infinite;
}

.spinner-icon {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--text-tertiary);
}

.spinner-icon svg {
  width: 20px;
  height: 20px;
}

.loading-status {
  margin-bottom: 4px;
  color: var(--text-primary) !important;
  -webkit-text-fill-color: var(--text-primary) !important;
  font-size: 0.92rem;
  font-weight: 500;
}

.loading-hint {
  color: var(--text-tertiary) !important;
  -webkit-text-fill-color: var(--text-tertiary) !important;
  font-size: 0.76rem;
}

.loading-progress {
  margin-top: 20px;
}

.progress-bar {
  height: 2px;
  overflow: hidden;
  border-radius: var(--radius-full);
  background: var(--border-subtle);
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--accent-primary);
  transition: width 300ms ease;
}

.error-card {
  padding: 18px;
  border: 1px solid rgba(189, 116, 115, 0.36);
  border-left: 3px solid var(--color-danger);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  text-align: left;
}

.error-icon {
  display: flex;
  margin-bottom: 10px;
  color: var(--color-danger);
}

.error-message {
  margin-bottom: 14px;
  color: var(--text-secondary);
  font-size: 0.84rem;
  line-height: 1.55;
}

.retry-btn,
.new-analysis-btn,
.deal-retry-btn {
  border: 1px solid var(--border-input);
  background: transparent;
  color: var(--text-secondary);
}

.retry-btn {
  min-height: 40px;
  padding: 8px 15px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
}

.result-header {
  margin-bottom: 13px;
}

.result-badge {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 8px;
  color: var(--text-tertiary);
  font-size: 0.7rem;
  font-weight: 500;
}

.result-badge::before {
  content: "";
  width: 18px;
  height: 1px;
  background: var(--accent-primary);
}

.result-title {
  color: var(--text-primary);
  font-size: clamp(1.18rem, 3vw, 1.5rem);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.025em;
}

.result-content {
  padding: 21px;
  border-radius: var(--radius-lg);
  border: 2px solid var(--border-subtle);
  color: var(--text-secondary) !important;
  -webkit-text-fill-color: var(--text-secondary) !important;
  font-size: 0.86rem;
  line-height: 1.68;
  transition: border-color 0.4s ease;
}

.result-content strong,
.result-content b,
.result-content h1,
.result-content h2,
.result-content h3 {
  color: var(--text-primary) !important;
  -webkit-text-fill-color: var(--text-primary) !important;
}

.result-content strong,
.result-content b {
  font-weight: 600;
}

.result-content h1,
.result-content h2,
.result-content h3 {
  margin: 20px 0 7px;
  font-size: 0.98rem;
  font-weight: 600;
}

.result-content h1:first-child,
.result-content h2:first-child,
.result-content h3:first-child {
  margin-top: 0;
}

.result-content p,
.result-content ul,
.result-content ol {
  margin-bottom: 10px;
}

.result-content ul,
.result-content ol {
  padding-left: 18px;
}

.result-content li {
  margin-bottom: 4px;
}

.result-content.verdict-state-go {
  border-color: rgba(76, 175, 80, 0.55) !important;
}

.result-content.verdict-state-doubt {
  border-color: rgba(255, 152, 0, 0.50) !important;
}

.result-content.verdict-state-junk {
  border-color: rgba(244, 67, 54, 0.50) !important;
}

.analysis-report {
  display: grid;
  gap: 0;
}

.analysis-auto,
.analysis-verdict,
.analysis-section {
  min-width: 0;
}

.analysis-auto {
  padding-bottom: 15px;
  border-bottom: 1px solid var(--border-subtle);
}

.analysis-price-ad {
  padding: 12px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.analysis-platform-price {
  padding: 12px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.analysis-price-ad p {
  margin: 5px 0 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary) !important;
  -webkit-text-fill-color: var(--text-primary) !important;
}

.analysis-platform-price p {
  margin: 5px 0 0;
  color: var(--text-primary) !important;
  -webkit-text-fill-color: var(--text-primary) !important;
  font-size: 0.85rem;
  line-height: 1.55;
}

.analysis-auto p,
.analysis-verdict p,
.analysis-section p {
  margin: 5px 0 0;
}

.analysis-verdict-reason {
  color: var(--text-secondary) !important;
  -webkit-text-fill-color: var(--text-secondary) !important;
  font-size: 0.85rem;
  line-height: 1.6;
  margin-top: 8px !important;
}

.analysis-label {
  display: block;
  color: var(--text-tertiary) !important;
  -webkit-text-fill-color: var(--text-tertiary) !important;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  line-height: 1.35;
  text-transform: uppercase;
}

.analysis-verdict {
  position: relative;
  padding: 17px 0 18px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.analysis-verdict::before {
  content: "";
  position: absolute;
  top: 15px;
  bottom: 16px;
  left: 0;
  width: 4px;
  border-radius: 3px;
  background: var(--border-strong);
}

.analysis-verdict-name {
  display: block;
  margin-top: 4px;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.35;
  text-transform: uppercase;
}

.analysis-report.is-go .analysis-verdict-name {
  color: rgba(76, 175, 80, 0.85) !important;
  -webkit-text-fill-color: rgba(76, 175, 80, 0.85) !important;
}

.analysis-report.is-doubt .analysis-verdict-name {
  color: rgba(255, 152, 0, 0.85) !important;
  -webkit-text-fill-color: rgba(255, 152, 0, 0.85) !important;
}

.analysis-report.is-junk .analysis-verdict-name {
  color: rgba(244, 67, 54, 0.85) !important;
  -webkit-text-fill-color: rgba(244, 67, 54, 0.85) !important;
}

.analysis-report.is-go .analysis-verdict::before {
  background: rgba(76, 175, 80, 0.7);
}

.analysis-report.is-doubt .analysis-verdict::before {
  background: rgba(255, 152, 0, 0.7);
}

.analysis-report.is-junk .analysis-verdict::before {
  background: rgba(244, 67, 54, 0.7);
}

.analysis-vin {
  padding: 11px 0;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-accent) !important;
  -webkit-text-fill-color: var(--text-accent) !important;
  font-size: 0.78rem;
  line-height: 1.5;
}

.analysis-columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  border-bottom: 1px solid var(--border-subtle);
}

.analysis-section {
  padding: 16px 0;
}

.analysis-section + .analysis-section {
  padding-left: 18px;
  border-left: 1px solid var(--border-subtle);
}

.analysis-section:first-child {
  padding-right: 18px;
}

.analysis-section.estimate {
  padding-bottom: 0;
}

.analysis-section.positive .analysis-label {
  color: var(--color-success) !important;
  -webkit-text-fill-color: var(--color-success) !important;
}

.analysis-section.warning .analysis-label {
  color: var(--color-warning) !important;
  -webkit-text-fill-color: var(--color-warning) !important;
}

.analysis-report.is-junk .analysis-section.warning .analysis-label {
  color: var(--color-danger) !important;
  -webkit-text-fill-color: var(--color-danger) !important;
}

.analysis-section ul {
  display: grid;
  gap: 7px;
  margin: 7px 0 0;
  padding: 0;
  list-style: none;
}

.analysis-section li {
  position: relative;
  margin: 0;
  padding-left: 12px;
  line-height: 1.55;
}

.analysis-section li::before {
  content: "";
  position: absolute;
  top: 0.7em;
  left: 0;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-tertiary);
}

.analysis-section.positive li::before {
  background: var(--color-success);
}

.analysis-section.warning li::before {
  background: var(--color-warning);
}

.analysis-report.is-junk .analysis-section.warning li::before {
  background: var(--color-danger);
}

.new-analysis-btn {
  width: 100%;
  min-height: 46px;
  margin-top: 14px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  transition: border-color var(--transition-fast), color var(--transition-fast), background var(--transition-fast);
}

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

.scan-progress-header strong {
  display: block;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 600;
}

.scan-progress-header small,
.scan-stage small {
  display: block;
  margin-top: 3px;
  color: var(--text-tertiary);
  font-size: 0.69rem;
  line-height: 1.45;
}

#scan-percent,
#drom-scan-percent {
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.scan-stages {
  margin-top: 19px;
  list-style: none;
}

.scan-stage {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 8px 0;
  border-top: 1px solid var(--border-subtle);
  opacity: 0.48;
  text-align: left;
  transition: opacity var(--transition-fast);
}

.scan-stage strong {
  color: var(--text-secondary);
  font-size: 0.77rem;
  font-weight: 500;
}

.scan-stage-number {
  width: 25px;
  height: 25px;
  flex: 0 0 25px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-input);
  border-radius: 50%;
  color: var(--text-tertiary);
  font-size: 0.67rem;
  font-weight: 600;
}

.scan-stage.active,
.scan-stage.done {
  opacity: 1;
}

.scan-stage.active .scan-stage-number {
  border-color: var(--accent-primary);
  color: var(--accent-primary-light);
}

.scan-stage.done .scan-stage-number {
  border-color: var(--color-success);
  color: var(--color-success);
}

.scan-results-summary {
  margin-top: 7px;
  color: var(--text-tertiary);
  font-size: 0.76rem;
  line-height: 1.55;
}

.scan-results-list {
  display: grid;
  gap: 16px;
}

.deal-card {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
}

.deal-image-wrap {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-input);
}

.deal-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.deal-image-placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--text-tertiary);
  font-size: 0.72rem;
}

.deal-rank {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 1;
  padding: 4px 7px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 4px;
  background: rgba(14, 16, 18, 0.9);
  color: var(--text-primary);
  font-size: 0.67rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.deal-body {
  padding: 17px;
}

.deal-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.deal-title {
  color: var(--text-primary);
  font-size: 0.98rem;
  font-weight: 600;
  line-height: 1.38;
}

.deal-price {
  margin-top: 7px;
  color: var(--text-primary);
  font-size: 1.42rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
}

.deal-platform-assessment {
  display: grid;
  gap: 3px;
  margin-top: 11px;
  padding: 9px 11px;
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--text-tertiary);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
}

.deal-platform-assessment.is-below {
  border-left-color: var(--color-success);
}

.deal-platform-assessment.is-within,
.deal-platform-assessment.is-upper {
  border-left-color: var(--color-warning);
}

.deal-platform-assessment.is-above {
  border-left-color: var(--color-danger);
}

.deal-platform-assessment small {
  color: var(--text-tertiary) !important;
  -webkit-text-fill-color: var(--text-tertiary) !important;
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.deal-platform-assessment strong {
  color: var(--text-primary) !important;
  -webkit-text-fill-color: var(--text-primary) !important;
  font-size: 0.82rem;
  font-weight: 650;
}

.deal-platform-assessment span {
  color: var(--text-secondary) !important;
  -webkit-text-fill-color: var(--text-secondary) !important;
  font-size: 0.7rem;
  line-height: 1.45;
}

.deal-retail-market {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 12px;
  margin-top: 8px;
  padding: 9px 11px;
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--color-warning);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
}

.deal-retail-market.is-strong {
  border-left-color: var(--color-success);
}

.deal-retail-market.is-high {
  border-left-color: var(--color-danger);
}

.deal-retail-market small {
  align-self: center;
  color: var(--text-tertiary);
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.deal-retail-market strong {
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 680;
  font-variant-numeric: tabular-nums;
}

.deal-retail-market span {
  grid-column: 1 / -1;
  color: var(--text-secondary);
  font-size: 0.7rem;
  line-height: 1.45;
}

.deal-specs {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 12px;
  margin-top: 9px;
  padding: 0;
  list-style: none;
  color: var(--text-secondary);
  font-size: 0.73rem;
}

.deal-stage-summary {
  margin-top: 13px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.76rem;
  line-height: 1.55;
}

.deal-risk {
  display: block;
  margin-top: 6px;
  color: var(--color-warning);
}

.deal-bargain-reasons {
  display: block;
  margin-top: 7px;
  color: var(--text-primary);
}

.deal-analysis {
  margin-top: 13px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

.deal-analysis summary {
  color: var(--text-primary);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 500;
}

.deal-analysis-content {
  margin-top: 10px;
  color: var(--text-secondary);
  font-size: 0.76rem;
  line-height: 1.62;
}

.deal-analysis-loading,
.deal-analysis-error,
.deal-analysis-skipped {
  margin-top: 9px;
  color: var(--text-tertiary);
  font-size: 0.72rem;
  line-height: 1.5;
}

.deal-analysis-error {
  color: var(--color-danger);
}

.deal-analysis-skipped {
  color: var(--color-warning);
}

.deal-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 9px;
  margin-top: 15px;
}

.deal-open-btn,
.deal-retry-btn {
  min-height: 43px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.77rem;
  font-weight: 600;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

.deal-retry-btn {
  padding: 0 12px;
}

.deal-retry-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.footer {
  margin-top: auto;
  padding: 30px 0 4px;
  border-top: 0;
  text-align: left;
}

.footer-main {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 20px;
}

.footer-brand {
  color: var(--text-tertiary);
  font-size: 0.68rem;
  font-weight: 400;
}

.footer-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px 18px;
}

.document-link,
.support-link {
  flex: 0 0 auto;
  color: var(--text-secondary);
  font-size: 0.73rem;
  font-weight: 500;
  text-decoration: none;
  transition: color var(--transition-fast);
}

.document-link span {
  display: inline-block;
  margin-right: 3px;
  color: var(--accent-primary);
}

.footer-legal {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin-top: 10px;
}

.footer-legal a {
  color: var(--text-tertiary);
  font-size: 0.68rem;
  font-weight: 400;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 3px;
  transition: color var(--transition-fast), text-decoration-color var(--transition-fast);
}

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

@keyframes reveal {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  border-radius: var(--radius-full);
  background: var(--border-input);
}

::selection {
  background: rgba(182, 160, 120, 0.24);
  color: var(--text-primary);
}

@media (hover: hover) {
  .mode-tab:hover,
  .clear-btn:hover,
  .document-link:hover,
  .support-link:hover,
  .footer-legal a:hover {
    color: var(--text-primary);
  }

  .footer-legal a:hover {
    text-decoration-color: currentColor;
  }

  .clear-btn:hover {
    background: var(--bg-card-hover);
  }

  .analyze-btn:hover:not(:disabled),
  .deal-open-btn:hover {
    border-color: var(--action-primary-hover);
    background: var(--action-primary-hover);
  }

  .retry-btn:hover,
  .new-analysis-btn:hover,
  .deal-retry-btn:hover:not(:disabled) {
    border-color: var(--border-strong);
    background: var(--bg-card-hover);
    color: var(--text-primary);
  }
}

@media (max-width: 519px) {
  .header {
    padding-top: max(20px, env(safe-area-inset-top));
    padding-bottom: 16px;
  }

  .input-card,
  .loading-card,
  .scan-progress-card,
  .result-content {
    padding: 16px;
  }

  .mode-tabs {
    gap: 12px;
    margin-bottom: 18px;
  }

  .mode-tab {
    font-size: 0.78rem;
  }

  .filter-grid {
    grid-template-columns: 1fr;
  }

  .analysis-columns {
    grid-template-columns: 1fr;
  }

  .analysis-section:first-child {
    padding-right: 0;
  }

  .analysis-section + .analysis-section {
    padding-left: 0;
    border-top: 1px solid var(--border-subtle);
    border-left: 0;
  }

  .filter-field-wide {
    grid-column: auto;
  }

  .deal-actions {
    grid-template-columns: 1fr;
  }

  .deal-retry-btn {
    padding: 0 10px;
  }

  .footer-main {
    align-items: flex-start;
    flex-direction: column;
  }

  .footer-actions {
    flex-wrap: wrap;
  }
}

@media (min-width: 700px) {
  #app {
    padding-right: max(28px, env(safe-area-inset-right));
    padding-left: max(28px, env(safe-area-inset-left));
  }

  .header {
    padding-top: max(34px, env(safe-area-inset-top));
  }

  .input-card {
    padding: 26px;
  }

  .result-content {
    padding: 25px 27px;
  }

  .scan-results-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* ─── Liquid Glass layer ─────────────────────────────────────────────── */

:root {
  --glass-fill: rgba(16, 42, 58, 0.54);
  --glass-fill-strong: rgba(10, 30, 43, 0.76);
  --glass-stroke: rgba(183, 227, 246, 0.2);
  --glass-highlight: rgba(226, 247, 255, 0.34);
  --glass-shadow: rgba(0, 8, 16, 0.4);
  --glass-x: 50%;
  --glass-y: 50%;
}

body::before,
body::after {
  content: "";
  position: fixed;
  z-index: 0;
  width: 54rem;
  height: 54rem;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(108px);
  opacity: 0.17;
  will-change: transform;
}

body::before {
  top: -34rem;
  left: -25rem;
  background: #19a8e4;
  animation: liquid-ambient-a 18s ease-in-out infinite alternate;
}

body::after {
  right: -31rem;
  bottom: -36rem;
  background: #d5a64f;
  animation: liquid-ambient-b 22s ease-in-out infinite alternate;
}

#app {
  position: relative;
  z-index: 1;
}

.header {
  animation: glass-materialize 620ms cubic-bezier(0.22, 0.8, 0.28, 1) both;
}

.logo-icon {
  filter: drop-shadow(0 8px 18px rgba(27, 173, 224, 0.2));
}

.input-card,
.loading-card,
.result-content,
.deal-card {
  border-color: var(--glass-stroke);
  background:
    linear-gradient(145deg, rgba(27, 59, 77, 0.62), rgba(7, 23, 34, 0.72)),
    rgba(6, 22, 32, 0.62);
  -webkit-backdrop-filter: blur(28px) saturate(145%);
  backdrop-filter: blur(28px) saturate(145%);
  box-shadow:
    0 22px 65px var(--glass-shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    inset 0 -1px 0 rgba(15, 93, 124, 0.16);
}

.input-card {
  position: relative;
  overflow: hidden;
  animation: glass-materialize 720ms 70ms cubic-bezier(0.22, 0.8, 0.28, 1) both;
}

.input-card::after {
  content: "";
  position: absolute;
  top: -35%;
  left: -18%;
  width: 72%;
  height: 56%;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(115, 213, 248, 0.13), transparent 70%);
  pointer-events: none;
}

:is(
  .mode-tabs,
  .input-wrapper,
  .analyze-btn,
  .new-analysis-btn,
  .retry-btn,
  .deal-open-btn,
  .deal-retry-btn,
  .document-link,
  .support-link
) {
  --glass-x: 50%;
  --glass-y: 50%;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  -webkit-backdrop-filter: blur(18px) saturate(155%);
  backdrop-filter: blur(18px) saturate(155%);
  transition:
    transform 220ms cubic-bezier(0.2, 0.8, 0.25, 1.15),
    border-color 180ms ease,
    box-shadow 220ms ease,
    background 220ms ease;
}

:is(
  .mode-tabs,
  .input-wrapper,
  .analyze-btn,
  .new-analysis-btn,
  .retry-btn,
  .deal-open-btn,
  .deal-retry-btn,
  .document-link,
  .support-link
)::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -1px;
  border-radius: inherit;
  background:
    radial-gradient(circle 105px at var(--glass-x) var(--glass-y), rgba(232, 249, 255, 0.36), transparent 72%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.13), transparent 46%);
  opacity: 0.36;
  pointer-events: none;
  transition: opacity 180ms ease;
}

:is(
  .mode-tabs,
  .input-wrapper,
  .analyze-btn,
  .new-analysis-btn,
  .retry-btn,
  .deal-open-btn,
  .deal-retry-btn,
  .document-link,
  .support-link
).is-glass-pressed {
  transform: scale(0.975);
  box-shadow:
    0 8px 24px rgba(0, 8, 14, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

:is(
  .mode-tabs,
  .input-wrapper,
  .analyze-btn,
  .new-analysis-btn,
  .retry-btn,
  .deal-open-btn,
  .deal-retry-btn,
  .document-link,
  .support-link
).is-glass-pressed::before {
  opacity: 0.86;
}

.mode-tabs {
  border-color: rgba(174, 225, 245, 0.16);
  background: rgba(4, 18, 28, 0.46);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 10px 28px rgba(0, 7, 12, 0.18);
}

.mode-tab {
  z-index: 1;
  border: 1px solid transparent;
  transition: color 180ms ease, background 260ms ease, border-color 260ms ease, box-shadow 260ms ease;
}

.mode-tab.active {
  border-color: rgba(191, 233, 249, 0.18);
  background:
    linear-gradient(145deg, rgba(81, 190, 232, 0.25), rgba(17, 109, 150, 0.12)),
    rgba(21, 83, 111, 0.2);
  box-shadow:
    0 7px 20px rgba(1, 17, 27, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.mode-tab.active::after {
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, #62d6ff, transparent);
  box-shadow: 0 0 12px rgba(64, 199, 245, 0.7);
}

.input-wrapper,
.filter-control {
  border-color: rgba(153, 214, 239, 0.2);
  background:
    linear-gradient(145deg, rgba(29, 62, 79, 0.34), rgba(5, 21, 31, 0.44)),
    rgba(5, 18, 27, 0.45);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  backdrop-filter: blur(16px) saturate(140%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.09),
    0 7px 20px rgba(0, 8, 14, 0.12);
}

.input-wrapper:focus-within,
.filter-control:focus {
  border-color: rgba(91, 209, 251, 0.72);
  background: rgba(11, 35, 49, 0.7);
  box-shadow:
    0 0 0 4px rgba(37, 180, 230, 0.12),
    0 10px 28px rgba(0, 12, 20, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.filter-chip,
.platform-badge {
  border-color: rgba(164, 217, 238, 0.17);
  background: rgba(29, 62, 78, 0.3);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  backdrop-filter: blur(12px) saturate(140%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

.filter-chip:first-child,
.platform-badge.platform-ok:first-child {
  border-color: rgba(231, 195, 123, 0.34);
  color: #edd49f;
  background: rgba(184, 134, 52, 0.1);
}

.analyze-btn,
.deal-open-btn {
  border-color: rgba(180, 234, 255, 0.28);
  background:
    linear-gradient(145deg, rgba(87, 210, 250, 0.9), rgba(16, 142, 195, 0.9)),
    rgba(22, 155, 210, 0.82);
  box-shadow:
    0 14px 34px rgba(9, 137, 187, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    inset 0 -1px 0 rgba(0, 70, 101, 0.35);
}

.analyze-btn:not(:disabled) {
  animation: primary-glass-breathe 4.8s ease-in-out infinite;
}

.analyze-btn:disabled {
  border-color: rgba(138, 184, 204, 0.12);
  background: rgba(12, 33, 46, 0.54);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  animation: none;
}

.new-analysis-btn,
.retry-btn,
.deal-retry-btn,
.document-link,
.support-link {
  border-color: rgba(162, 216, 239, 0.18);
  background: rgba(24, 58, 76, 0.32);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 8px 22px rgba(0, 8, 14, 0.12);
}

.progress-bar {
  overflow: hidden;
  border: 1px solid rgba(151, 214, 239, 0.1);
  background: rgba(0, 12, 20, 0.42);
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.35);
}

.progress-fill {
  background: linear-gradient(90deg, #1d99d1, #63d9ff 68%, #e0bd75);
  box-shadow: 0 0 16px rgba(56, 194, 241, 0.55);
}

.scan-stage-number,
.deal-rank {
  border-color: rgba(185, 228, 246, 0.22);
  background: rgba(39, 85, 106, 0.44);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  backdrop-filter: blur(12px) saturate(140%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

.deal-card {
  transition: border-color 220ms ease, transform 260ms cubic-bezier(0.2, 0.8, 0.25, 1), box-shadow 260ms ease;
}

@media (hover: hover) {
  .deal-card:hover {
    border-color: rgba(111, 210, 247, 0.34);
    transform: translateY(-3px);
    box-shadow:
      0 28px 72px rgba(0, 7, 13, 0.42),
      inset 0 1px 0 rgba(255, 255, 255, 0.17);
  }

  :is(.analyze-btn, .deal-open-btn):hover:not(:disabled) {
    border-color: rgba(218, 246, 255, 0.48);
    background:
      linear-gradient(145deg, rgba(113, 220, 253, 0.96), rgba(28, 163, 215, 0.94)),
      rgba(29, 171, 224, 0.9);
    box-shadow:
      0 18px 42px rgba(11, 150, 202, 0.38),
      inset 0 1px 0 rgba(255, 255, 255, 0.58);
  }
}

@keyframes glass-materialize {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes liquid-ambient-a {
  from { transform: translate3d(-3vw, -2vh, 0) scale(0.92); }
  to { transform: translate3d(20vw, 11vh, 0) scale(1.08); }
}

@keyframes liquid-ambient-b {
  from { transform: translate3d(3vw, 4vh, 0) scale(1.04); }
  to { transform: translate3d(-18vw, -8vh, 0) scale(0.9); }
}

@keyframes primary-glass-breathe {
  0%, 100% { box-shadow: 0 14px 34px rgba(9, 137, 187, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.48); }
  50% { box-shadow: 0 17px 42px rgba(17, 163, 216, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.62); }
}

@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .input-card,
  .loading-card,
  .result-content,
  .deal-card,
  .mode-tabs,
  .input-wrapper,
  .filter-control {
    background: #0c2230;
  }
}

@media (prefers-reduced-transparency: reduce) {
  .input-card,
  .loading-card,
  .result-content,
  .deal-card,
  .mode-tabs,
  .input-wrapper,
  .filter-control {
    background: #0b202d;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  body::before,
  body::after,
  .input-card::after {
    display: none;
  }
}

@media (prefers-contrast: more) {
  :root {
    --glass-stroke: rgba(231, 248, 255, 0.58);
  }

  .filter-control,
  .input-wrapper,
  .mode-tabs {
    border-color: rgba(232, 248, 255, 0.58);
  }
}

@media (prefers-reduced-motion: reduce) {
  body::before,
  body::after,
  .header,
  .input-card,
  .analyze-btn:not(:disabled) {
    animation: none !important;
  }

  :is(
    .mode-tabs,
    .input-wrapper,
    .analyze-btn,
    .new-analysis-btn,
    .retry-btn,
    .deal-open-btn,
    .deal-retry-btn,
    .document-link,
    .support-link
  ).is-glass-pressed,
  .deal-card:hover {
    transform: none !important;
  }
}
