:root {
  --terra-bg: #f4f1eb;
  --terra-surface: rgba(255, 255, 255, 0.96);
  --terra-surface-soft: rgba(255, 255, 255, 0.82);
  --terra-panel: #ffffff;
  --terra-text: #243243;
  --terra-muted: #6a7684;
  --terra-border: rgba(36, 50, 67, 0.11);
  --terra-accent: #1ca5a3;
  --terra-accent-strong: #157f7e;
  --terra-accent-soft: rgba(28, 165, 163, 0.12);
  --terra-primary: #f3a33e;
  --terra-primary-strong: #d98919;
  --terra-dark: #132333;
  --terra-shadow-soft: 0 18px 40px rgba(36, 50, 67, 0.1);
  --terra-shadow-panel: 0 26px 60px rgba(21, 32, 44, 0.18);
  --terra-shadow-accent: 0 16px 34px rgba(28, 165, 163, 0.18);
  --terra-radius-xl: 28px;
  --terra-radius-lg: 22px;
  --terra-radius-md: 16px;
  --terra-transition: 180ms ease;
  --terra-container: 1280px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", sans-serif;
  color: var(--terra-text);
  background:
    radial-gradient(circle at 16% 8%, rgba(28, 165, 163, 0.12), transparent 24%),
    radial-gradient(circle at 84% 16%, rgba(243, 163, 62, 0.1), transparent 20%),
    linear-gradient(180deg, #f8f5ef 0%, #efeae2 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 8% 10%, rgba(255, 255, 255, 0.45), transparent 38%),
    repeating-radial-gradient(
      circle at 20% 18%,
      rgba(36, 50, 67, 0.02) 0,
      rgba(36, 50, 67, 0.02) 1px,
      transparent 1px,
      transparent 18px
    );
  opacity: 0.48;
}

body.has-overlay-modal {
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.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;
}

.flow-app {
  position: relative;
  min-height: 100vh;
  z-index: 1;
}

.flow-container {
  width: min(var(--terra-container), calc(100% - 40px));
  margin: 0 auto;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(18px);
  background: rgba(248, 246, 241, 0.84);
  border-bottom: 1px solid rgba(36, 50, 67, 0.08);
}

.app-header__inner {
  width: min(var(--terra-container), calc(100% - 40px));
  min-height: 76px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.app-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  text-transform: lowercase;
}

.app-brand img {
  width: 32px;
  height: 32px;
}

.app-nav,
.app-actions {
  display: flex;
  align-items: center;
  gap: 1.1rem;
}

.app-nav a,
.app-actions a,
.app-actions button,
.app-actions span {
  color: var(--terra-muted);
  font-size: 0.83rem;
  font-weight: 600;
  transition: color var(--terra-transition);
}

.app-nav a:hover,
.app-actions a:hover,
.app-actions button:hover {
  color: var(--terra-text);
}

.app-nav a {
  pointer-events: none;
  cursor: default;
  opacity: 0.74;
}

.app-nav a[aria-current="page"] {
  opacity: 1;
}

.app-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(28, 165, 163, 0.16), rgba(21, 127, 126, 0.28));
  border: 1px solid rgba(28, 165, 163, 0.2);
}

.page-shell {
  width: min(var(--terra-container), calc(100% - 40px));
  margin: 0 auto;
  padding: 1.5rem 0 2rem;
}

.section-card,
.surface-card,
.metric-card {
  background: var(--terra-surface);
  border: 1px solid rgba(36, 50, 67, 0.08);
  box-shadow: var(--terra-shadow-soft);
}

.section-card,
.surface-card {
  border-radius: var(--terra-radius-lg);
}

.metric-card {
  border-radius: 18px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 46px;
  padding: 0.85rem 1.25rem;
  border-radius: 12px;
  border: 1px solid transparent;
  font-weight: 600;
  white-space: nowrap;
  transition:
    transform var(--terra-transition),
    background var(--terra-transition),
    border-color var(--terra-transition),
    color var(--terra-transition),
    box-shadow var(--terra-transition);
}

.button:hover {
  transform: translateY(-1px);
}

.button--primary {
  color: #ffffff;
  background: var(--terra-primary);
  box-shadow: 0 16px 30px rgba(243, 163, 62, 0.22);
}

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

.button--accent {
  color: #ffffff;
  background: var(--terra-accent);
  box-shadow: var(--terra-shadow-accent);
}

.button--accent:hover {
  background: var(--terra-accent-strong);
}

.button--ghost {
  color: var(--terra-muted);
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(36, 50, 67, 0.1);
}

.button--ghost:hover {
  color: var(--terra-text);
  border-color: rgba(28, 165, 163, 0.24);
}

.button--subtle {
  color: var(--terra-accent-strong);
  background: rgba(28, 165, 163, 0.08);
  border-color: rgba(28, 165, 163, 0.18);
}

.button--subtle:hover {
  background: rgba(28, 165, 163, 0.14);
}

.button--small {
  min-height: 40px;
  padding: 0.7rem 0.95rem;
  font-size: 0.82rem;
}

.button--icon {
  width: 42px;
  min-width: 42px;
  padding-inline: 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 40px;
  padding: 0.7rem 0.95rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(36, 50, 67, 0.08);
  color: var(--terra-muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.chip strong {
  color: var(--terra-text);
}

.chip--active {
  color: var(--terra-accent-strong);
  border-color: rgba(28, 165, 163, 0.18);
  background: rgba(28, 165, 163, 0.08);
}

.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.tag--accent {
  color: var(--terra-accent-strong);
  background: rgba(28, 165, 163, 0.12);
}

.tag--warm {
  color: #91510a;
  background: rgba(243, 163, 62, 0.18);
}

.tag--muted {
  color: #64748b;
  background: rgba(148, 163, 184, 0.16);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.metric-card {
  padding: 1.15rem;
}

.metric-card p {
  margin: 0;
  color: var(--terra-muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.metric-card strong {
  display: block;
  margin-top: 0.4rem;
  font-size: 1.7rem;
  letter-spacing: -0.04em;
}

.toast {
  position: fixed;
  right: 1.4rem;
  bottom: 1.4rem;
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  min-width: min(360px, calc(100vw - 2rem));
  padding: 0.95rem 1.1rem;
  border-radius: 16px;
  background: rgba(19, 35, 51, 0.92);
  color: #ffffff;
  box-shadow: var(--terra-shadow-panel);
}

.toast .material-symbols-outlined {
  color: #7ff4ce;
}

.toast[hidden] {
  display: none;
}

.terra-auth-modal[hidden] {
  display: none;
}

.terra-auth-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
}

.terra-auth-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(19, 35, 51, 0.42);
  backdrop-filter: blur(12px);
}

.terra-auth-modal__dialog {
  position: relative;
  width: min(480px, calc(100vw - 28px));
  margin: min(10vh, 72px) auto 0;
  padding: 1.25rem;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: var(--terra-shadow-panel);
}

.terra-auth-modal--with-preview .terra-auth-modal__dialog {
  width: min(560px, calc(100vw - 28px));
}

.terra-auth-modal__close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(36, 50, 67, 0.1);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--terra-muted);
}

.terra-auth-modal__header {
  display: grid;
  gap: 0.45rem;
  padding-right: 3rem;
}

.terra-auth-modal__eyebrow {
  margin: 0;
  color: var(--terra-accent-strong);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.terra-auth-modal__header h2 {
  margin: 0;
  font-size: 1.8rem;
  letter-spacing: -0.05em;
}

.terra-auth-modal__header p {
  margin: 0;
  color: var(--terra-muted);
  line-height: 1.55;
}

.terra-auth-modal__context {
  margin-top: 1rem;
  padding: 0.85rem 0.95rem;
  border-radius: 16px;
  background: rgba(28, 165, 163, 0.08);
  border: 1px solid rgba(28, 165, 163, 0.14);
  color: var(--terra-accent-strong);
  font-size: 0.88rem;
  font-weight: 600;
}

.terra-auth-modal__preview {
  margin-top: 1rem;
}

.terra-auth-preview-card {
  display: grid;
  grid-template-columns: minmax(0, 210px) minmax(0, 1fr);
  gap: 0.9rem;
  padding: 0.75rem;
  border-radius: 18px;
  background: rgba(247, 248, 249, 0.82);
  border: 1px solid rgba(36, 50, 67, 0.08);
}

.terra-auth-preview-card__media {
  position: relative;
  overflow: hidden;
  min-height: 136px;
  border-radius: 16px;
}

.terra-auth-preview-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.terra-auth-preview-card__grade {
  position: absolute;
  top: 0.6rem;
  left: 0.6rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  color: #ffffff;
  font-size: 1rem;
  font-weight: 800;
  box-shadow: 0 16px 30px rgba(21, 32, 44, 0.2);
}

.terra-auth-preview-card__grade[data-tone="accent"] {
  background: var(--terra-accent);
}

.terra-auth-preview-card__grade[data-tone="warm"] {
  background: var(--terra-primary);
}

.terra-auth-preview-card__grade[data-tone="muted"] {
  background: #6b7280;
}

.terra-auth-preview-card__saved-note {
  position: absolute;
  right: 0.6rem;
  bottom: 0.6rem;
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--terra-muted);
  font-size: 0.7rem;
  font-weight: 700;
}

.terra-auth-preview-card__body {
  display: grid;
  align-content: space-between;
  gap: 0.6rem;
  min-width: 0;
}

.terra-auth-preview-card__top {
  display: grid;
  gap: 0.7rem;
}

.terra-auth-preview-card__top strong {
  display: block;
  font-size: 2rem;
  letter-spacing: -0.05em;
}

.terra-auth-preview-card__top p,
.terra-auth-preview-card__top span,
.terra-auth-preview-card__body small {
  display: block;
  margin: 0.2rem 0 0;
  color: var(--terra-muted);
}

.terra-auth-preview-card__top p {
  color: var(--terra-text);
  font-size: 1rem;
  font-weight: 700;
}

.terra-auth-preview-card__contacts {
  display: inline-flex;
  align-items: center;
}

.terra-auth-preview-card__avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  margin-left: -8px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  background: linear-gradient(135deg, rgba(28, 165, 163, 0.18), rgba(243, 163, 62, 0.2));
  color: var(--terra-text);
  font-size: 0.72rem;
  font-weight: 800;
  box-shadow: 0 8px 18px rgba(21, 32, 44, 0.08);
}

.terra-auth-preview-card__avatar:first-child {
  margin-left: 0;
}

.terra-auth-modal__form {
  display: grid;
  gap: 0.85rem;
  margin-top: 1rem;
}

.terra-auth-modal__form label {
  display: grid;
  gap: 0.45rem;
}

.terra-auth-modal__form span {
  color: var(--terra-muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.terra-auth-modal__form input {
  width: 100%;
  min-height: 50px;
  padding: 0.9rem 1rem;
  border-radius: 14px;
  border: 1px solid rgba(36, 50, 67, 0.1);
  background: #ffffff;
  color: var(--terra-text);
  outline: none;
}

.terra-auth-modal__helper {
  margin: 0;
  color: #8b97a5;
  font-size: 0.82rem;
}

@media (max-width: 1080px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .app-nav {
    display: none;
  }

  .page-shell,
  .flow-container,
  .app-header__inner {
    width: min(var(--terra-container), calc(100% - 28px));
  }
}

@media (max-width: 720px) {
  .app-actions {
    gap: 0.7rem;
  }

  .app-actions span {
    display: none;
  }

  .page-shell {
    padding-top: 1rem;
  }

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

  .button {
    width: 100%;
  }

  .toast {
    right: 0.85rem;
    left: 0.85rem;
    bottom: 0.85rem;
    min-width: 0;
  }

  .terra-auth-preview-card {
    grid-template-columns: 1fr;
  }
}
