:root {
  color-scheme: light;
  --border: #d8dde3;
  --text: #1c2733;
  --muted: #5b6b7c;
  --accent: #2e5ce6;
  --danger: #c2372e;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: #f7f8fa;
}

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* Landing page opts out of the constrained admin layout for a full-bleed
   hero; see BodyClass in internal/webapp/helpers.go. */
body.landing main {
  max-width: none;
  padding: 0;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.site-header .brand {
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}

.site-header nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.site-header nav a {
  color: var(--muted);
  text-decoration: none;
}

@media (max-width: 640px) {
  .site-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
  .site-header nav {
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
  }
}

.inline-form {
  display: inline;
}

.inline-form button {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  padding: 0;
}

h1 { font-size: clamp(1.3rem, 1rem + 1.2vw, 1.75rem); }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.auth-form {
  max-width: 320px;
  margin: 4rem auto;
  padding: 0 1.5rem;
}

/* --- Landing page: fractal hero --- */

.fractal-hero {
  position: relative;
  min-height: 46vh;
  overflow: hidden;
  background: #05050f;
}

.fractal-hero canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  filter: blur(0.5px) saturate(1.15);
}

.fractal-overlay {
  position: relative;
  min-height: 46vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
}

@media (max-width: 640px) {
  .fractal-hero,
  .fractal-overlay {
    min-height: 34vh;
  }
}

.fractal-card {
  text-align: center;
  padding: 2.5rem 2rem;
  border-radius: 16px;
  background: rgba(8, 6, 20, 0.45);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  max-width: min(90vw, 420px);
}

.fractal-card h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.75rem, 1.2rem + 3vw, 2.75rem);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #fdfaf3;
  text-shadow: 0 2px 24px rgba(235, 130, 210, 0.35);
}

.fractal-card .tagline {
  margin: 0;
  color: rgba(240, 235, 250, 0.75);
  font-size: clamp(0.95rem, 0.85rem + 0.4vw, 1.1rem);
}

.page-loading {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(247, 248, 250, 0.72);
  backdrop-filter: blur(2px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

body.page-loading-active .page-loading {
  opacity: 1;
  visibility: visible;
}

.page-loading-inner {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.5rem 0.8rem;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 500;
  box-shadow: 0 10px 26px rgba(28, 39, 51, 0.14);
}

.page-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid #c8d0dc;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: page-spin 0.8s linear infinite;
}

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

/* --- Landing page: market data --- */

.market-section {
  max-width: 960px;
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
}

.source-switcher {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.period-switcher {
  margin-top: -0.5rem;
}

.source-switcher h2 {
  margin-top: 0;
}

.source-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.source-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.92rem;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.source-tab:hover {
  color: var(--text);
  border-color: #b7c0cb;
}

.source-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.market-section h2 {
  margin: 2rem 0 0.25rem;
  font-size: clamp(1.2rem, 1rem + 0.8vw, 1.5rem);
}

.market-section h2:first-child { margin-top: 0; }

.market-caption {
  color: var(--muted);
  margin: 0 0 1.25rem;
}

.heatmap {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 6px;
}

.heat-cell {
  border-radius: 6px;
  padding: 0.6rem 0.4rem;
  text-align: center;
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.heat-code {
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.03em;
}

.heat-change {
  font-size: 0.75rem;
  opacity: 0.9;
  font-variant-numeric: tabular-nums;
}

.market-table td:nth-child(n+2) {
  font-variant-numeric: tabular-nums;
}

.rub-summary {
  margin-top: 1rem;
}

.rub-table td:nth-child(3),
.rub-table td:nth-child(4),
.rub-table td:nth-child(6) {
  font-variant-numeric: tabular-nums;
}

.change-up { color: #1f9d55; font-weight: 600; }
.change-down { color: var(--danger); font-weight: 600; }

#crypto-widget {
  position: relative;
}

.crypto-loading {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: rgba(247, 248, 250, 0.78);
  backdrop-filter: blur(1px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

#crypto-widget.is-loading .crypto-loading {
  opacity: 1;
  visibility: visible;
}

.crypto-loading-inner {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.45rem 0.7rem;
  box-shadow: 0 8px 20px rgba(28, 39, 51, 0.08);
}

.crypto-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid #c8d0dc;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: crypto-spin 0.8s linear infinite;
}

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

.crypto-summary {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
  margin: 0 0 1rem;
}

.crypto-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.8rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.crypto-card span {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.crypto-card strong {
  font-variant-numeric: tabular-nums;
  font-size: 1.05rem;
}

.crypto-row {
  cursor: pointer;
}

.crypto-row.active {
  background: #e9efff;
}

.crypto-chart-wrap {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  margin: 0 0 1rem;
}

.crypto-chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.crypto-chart-head h3 {
  margin: 0;
  font-size: 1rem;
}

.crypto-chart {
  width: 100%;
  height: 220px;
  display: block;
  margin-top: 0.5rem;
}

.crypto-chart-grid {
  stroke: #d6dce7;
  stroke-width: 1;
}

.crypto-chart-line {
  fill: none;
  stroke: #2e5ce6;
  stroke-width: 2.4;
}

.crypto-chart-dot {
  fill: #2e5ce6;
}

/* --- Landing page: API description --- */

.api-section {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
}

.api-section h2 {
  margin: 0 0 0.25rem;
  font-size: clamp(1.2rem, 1rem + 0.8vw, 1.5rem);
}

.endpoint {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  margin-top: 1rem;
}

.endpoint-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.endpoint-method {
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
}

.endpoint p {
  color: var(--muted);
  margin: 0.5rem 0;
}

.endpoint code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9rem;
}

.endpoint pre {
  background: #1c2733;
  color: #e7ecf2;
  border-radius: 4px;
  padding: 0.6rem 0.75rem;
  margin: 0.5rem 0 0;
  overflow-x: auto;
}

.endpoint pre code {
  color: inherit;
  font-size: 0.85rem;
}

form label {
  display: block;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  color: var(--muted);
}

form input,
form select,
form textarea {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font: inherit;
}

button,
.button {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 0.5rem 1rem;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}

button.danger { background: var(--danger); }

.error {
  background: #fdecea;
  color: var(--danger);
  border: 1px solid #f5c6c3;
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
  background: #fff;
}

th, td {
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.stat-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.stat {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem 1.5rem;
}

.stat-value {
  display: block;
  font-size: 1.75rem;
  font-weight: 600;
}

.stat-label {
  color: var(--muted);
  font-size: 0.85rem;
}

.subscription {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
