/* =========================
   PILLAR — PREMIUM PWA UI
   Better Stitch-aligned CSS
========================= */

:root {
  --bg: #fff8f0;
  --parchment: #f5f2ea;
  --paper: #fffdf7;
  --paper-soft: #fbf3e5;
  --surface: #f5eddf;
  --surface-high: #eae1d4;

  --charcoal: #2c2c2c;
  --text: #1f1b13;
  --muted: #4d4635;
  --outline: #7f7663;
  --outline-soft: #d0c5af;

  --primary: #735c00;
  --gold: #d4af37;
  --gold-soft: #ffe088;

  --danger: #ba1a1a;
  --success: #276738;

  --shadow-soft: 0 4px 20px rgba(44, 44, 44, 0.06);
  --shadow-modal: 0 -10px 40px rgba(44, 44, 44, 0.15);

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 32px;

  --safe-bottom: env(safe-area-inset-bottom);
  --bottom-nav-height: 82px;
}

/* =========================
   RESET / BASE
========================= */

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(circle at top, rgba(212, 175, 55, 0.08), transparent 35%),
    var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

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

button {
  border: none;
  cursor: pointer;
  background: none;
  color: inherit;
}

.hidden,
.modal.hidden {
  display: none !important;
}

/* =========================
   TYPOGRAPHY
========================= */

h1,
h2,
h3 {
  font-family: "Noto Serif", Georgia, serif;
  margin: 0;
  color: var(--text);
}

p {
  margin: 0;
}

.eyebrow {
  font-size: 11px;
  line-height: 1;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--outline);
}

.eyebrow.tiny {
  font-size: 9px;
}

.muted {
  color: var(--muted);
  opacity: 0.78;
  font-size: 14px;
  line-height: 1.45;
}

/* =========================
   APP SHELL / SAFE AREAS
========================= */

.app-shell {
  width: 100%;
  max-width: 560px;
  min-height: 100dvh;
  margin: 0 auto;
  position: relative;
  background: var(--bg);
}

.screen {
  min-height: 100dvh;
  padding: 24px;
  padding-top: calc(24px + env(safe-area-inset-top));
  padding-bottom: calc(32px + var(--safe-bottom));
}

#mainApp {
  min-height: 100dvh;
  padding-bottom: calc(var(--bottom-nav-height) + var(--safe-bottom));
}

.main-content {
  padding: 24px;
  padding-bottom: calc(var(--bottom-nav-height) + 42px + var(--safe-bottom));
}

/* =========================
   BUTTONS
========================= */

.primary-btn,
.secondary-btn,
.ghost-btn,
.danger-btn,
.small-primary-btn {
  border-radius: var(--radius-md);
  min-height: 48px;
  transition:
    transform 0.15s ease,
    opacity 0.15s ease,
    background 0.15s ease,
    border-color 0.15s ease;
}

.primary-btn:active,
.secondary-btn:active,
.ghost-btn:active,
.danger-btn:active,
.small-primary-btn:active,
.icon-btn:active,
.weight-btn:active {
  transform: scale(0.98);
}

.primary-btn {
  background: var(--charcoal);
  color: var(--paper);
  padding: 16px 18px;
  font-weight: 800;
  box-shadow: 0 12px 24px rgba(44, 44, 44, 0.12);
}

.primary-btn:hover {
  opacity: 0.94;
}

.secondary-btn {
  background: rgba(44, 44, 44, 0.07);
  color: var(--charcoal);
  padding: 14px 18px;
  font-weight: 700;
}

.ghost-btn {
  background: transparent;
  color: var(--outline);
  padding: 14px 18px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 800;
}

.danger-btn {
  background: var(--danger);
  color: white;
  padding: 14px 18px;
  font-weight: 800;
}

.full {
  width: 100%;
}

.small-primary-btn {
  background: var(--charcoal);
  color: var(--paper);
  padding: 10px 13px;
  font-size: 12px;
  font-weight: 800;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.small-primary-btn .material-symbols-outlined {
  font-size: 18px;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: var(--charcoal);
  background: rgba(44, 44, 44, 0.04);
  transition:
    transform 0.15s ease,
    background 0.15s ease;
}

.icon-btn:hover {
  background: rgba(44, 44, 44, 0.08);
}

.material-symbols-outlined {
  font-family: "Material Symbols Outlined";
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  display: inline-block;
  text-transform: none;
  letter-spacing: normal;
  white-space: nowrap;
  direction: ltr;
  font-feature-settings: "liga";
  -webkit-font-feature-settings: "liga";
  font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
}

/* =========================
   CARDS
========================= */

.premium-card {
  background: rgba(255, 253, 247, 0.88);
  border: 1px solid rgba(127, 118, 99, 0.12);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 18px;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

/* =========================
   AUTH SCREEN
========================= */

.auth-screen {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  text-align: center;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  margin: 0 auto 4px;
  color: var(--primary);
}

.brand-title {
  font-size: 42px;
  letter-spacing: -0.02em;
}

.brand-subtitle {
  margin-top: -10px;
  color: var(--muted);
}

.auth-card {
  text-align: left;
  margin-top: 22px;
  padding: 22px;
}

.auth-card h2 {
  margin-top: 12px;
  margin-bottom: 14px;
  font-size: 27px;
  line-height: 1.08;
}

/* =========================
   ONBOARDING
========================= */

.onboarding-screen {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.onboarding-header {
  text-align: center;
  margin-bottom: 44px;
}

.onboarding-header h1 {
  font-size: 44px;
  margin: 14px 0 18px;
  letter-spacing: -0.03em;
}

.onboarding-header .muted {
  max-width: 340px;
  margin: 0 auto;
}

.onboarding-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.input-label {
  display: block;
  font-size: 11px;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 800;
  color: var(--muted);
  margin-bottom: 10px;
}

.line-input {
  width: 100%;
  border: 0;
  border-bottom: 1px solid rgba(44, 44, 44, 0.2);
  border-radius: 0;
  background: transparent;
  padding: 14px 0;
  font-size: 17px;
  color: var(--charcoal);
  outline: none;
}

.line-input::placeholder {
  color: rgba(127, 118, 99, 0.45);
}

.line-input:focus {
  border-bottom-color: var(--primary);
}

.select-input {
  width: 100%;
  min-height: 48px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(127, 118, 99, 0.22);
  background: rgba(255, 253, 247, 0.7);
  color: var(--charcoal);
  padding: 0 14px;
  outline: none;
}

.identity-card {
  margin-top: 14px;
  background: var(--paper-soft);
  border: 1px solid rgba(127, 118, 99, 0.12);
  padding: 26px;
  box-shadow: var(--shadow-soft);
  position: relative;
  overflow: hidden;
}

.identity-card::after {
  content: "account_balance";
  font-family: "Material Symbols Outlined";
  font-size: 190px;
  line-height: 1;
  position: absolute;
  right: -44px;
  bottom: -52px;
  color: rgba(44, 44, 44, 0.035);
}

.identity-row,
.identity-meta {
  position: relative;
  z-index: 1;
}

.identity-row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 32px;
}

.identity-row h2 {
  font-size: 23px;
  margin-top: 8px;
}

.ticker-box {
  text-align: right;
}

.ticker-box h2 {
  color: var(--primary);
  letter-spacing: 0.14em;
}

.identity-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  border-top: 1px solid rgba(127, 118, 99, 0.12);
  padding-top: 22px;
}

.identity-meta p:not(.eyebrow) {
  margin-top: 6px;
  color: var(--charcoal);
  font-size: 13px;
}

.info-strip {
  position: relative;
  z-index: 1;
  margin: 24px 0 18px;
  border-left: 2px solid var(--primary);
  background: rgba(245, 237, 223, 0.55);
  padding: 14px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.info-strip .material-symbols-outlined {
  color: var(--primary);
  font-variation-settings: "FILL" 1;
}

.info-strip p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

/* =========================
   TOP BAR
========================= */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: calc(64px + env(safe-area-inset-top));
  padding: calc(14px + env(safe-area-inset-top)) 24px 14px;
  background: rgba(245, 242, 234, 0.94);
  border-bottom: 0.5px solid rgba(44, 44, 44, 0.1);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.topbar h1 {
  font-family: "Noto Serif", Georgia, serif;
  font-size: 20px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.2em;
}

.avatar-circle {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: var(--surface-high);
  display: grid;
  place-items: center;
  color: var(--charcoal);
  border: 1px solid rgba(127, 118, 99, 0.15);
}

/* =========================
   DASHBOARD / HERO
========================= */

.view {
  animation: fadeUp 0.22s ease both;
}

.stock-hero {
  text-align: center;
  padding: 16px 0 22px;
}

.stock-line {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 9px;
  margin-bottom: 8px;
}

.ticker-chip {
  background: rgba(44, 44, 44, 0.08);
  color: var(--charcoal);
  border-radius: 7px;
  padding: 4px 8px;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.stock-hero h2 {
  font-size: 46px;
  line-height: 1.08;
  letter-spacing: -0.04em;
}

.market-change {
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  font-weight: 800;
}

.market-change.positive {
  color: var(--success);
}

.bento-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-bottom: 28px;
}

.valuation-card h3 {
  font-size: 26px;
  margin: 10px 0 14px;
}

.quote-card {
  border-left: 4px solid var(--primary);
  font-family: "Noto Serif", Georgia, serif;
  font-size: 18px;
  line-height: 1.45;
  font-style: italic;
  color: var(--muted);
}

.quote-card span {
  display: block;
  margin-top: 14px;
  font-family: "Inter", sans-serif;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-style: normal;
  color: var(--outline);
}

.section-block {
  margin-top: 28px;
}

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

.section-heading h2 {
  font-size: 24px;
}

/* =========================
   GOALS
========================= */

.goal-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.goal-item {
  background: rgba(255, 253, 247, 0.88);
  border: 1px solid rgba(127, 118, 99, 0.12);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  padding: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.goal-item strong {
  display: block;
  font-size: 16px;
  color: var(--charcoal);
  margin-bottom: 5px;
}

.checkbox {
  width: 27px;
  height: 27px;
  border: 1.5px solid var(--outline-soft);
  border-radius: 7px;
  display: grid;
  place-items: center;
  flex: 0 0 27px;
  color: var(--paper);
  font-size: 17px;
  font-weight: 900;
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    transform 0.18s ease;
}

.checkbox.checked {
  background: var(--primary);
  border-color: var(--primary);
  transform: scale(1.03);
}

.empty-state {
  background: rgba(255, 253, 247, 0.62);
  border: 1px dashed rgba(127, 118, 99, 0.25);
  border-radius: var(--radius-lg);
  padding: 28px 18px;
  text-align: center;
  color: var(--muted);
}

.empty-state .material-symbols-outlined {
  color: var(--primary);
  margin-bottom: 10px;
}

.empty-state h3 {
  font-size: 20px;
  margin-bottom: 8px;
}

/* =========================
   VIRTUE GRID
========================= */

.virtue-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.virtue-card {
  background: rgba(255, 253, 247, 0.72);
  border: 1px solid rgba(127, 118, 99, 0.12);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: var(--shadow-soft);
}

.virtue-card strong {
  font-size: 13px;
  color: var(--charcoal);
}

.virtue-card span {
  font-size: 12px;
  color: var(--outline);
  font-weight: 800;
}

.progress-track {
  width: 100%;
  height: 7px;
  background: var(--surface-high);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--primary);
  border-radius: 999px;
  transition: width 0.25s ease;
}

/* =========================
   REPORT
========================= */

.report-header {
  text-align: center;
  margin: 8px 0 28px;
}

.report-header h2 {
  font-size: 40px;
  letter-spacing: -0.035em;
  margin: 8px 0;
}

.report-performance-card {
  margin-bottom: 14px;
}

.report-topline {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.report-topline h3 {
  margin-top: 8px;
  font-size: 38px;
  letter-spacing: -0.04em;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: 999px;
  background: rgba(115, 92, 0, 0.1);
  color: var(--primary);
  padding: 7px 10px;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.status-pill span {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--primary);
}

.mini-chart {
  height: 150px;
  margin-top: 24px;
}

.mini-chart svg {
  width: 100%;
  height: 100%;
}

#reportChartLine {
  stroke: var(--primary);
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
}

#reportChartFill {
  fill: rgba(115, 92, 0, 0.06);
}

.report-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.report-grid h3 {
  margin-top: 12px;
  font-size: 30px;
}

.report-analysis {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 18px;
}

.report-output {
  margin-top: 14px;
  background: rgba(31, 27, 19, 0.96);
  color: #f8f0e2;
  padding: 16px;
  border-radius: var(--radius-md);
  white-space: pre-wrap;
  font-size: 12px;
  line-height: 1.5;
  overflow-x: auto;
}

/* =========================
   BOTTOM NAV
========================= */

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  width: 100%;
  max-width: 560px;
  transform: translateX(-50%);
  z-index: 35;
  height: calc(var(--bottom-nav-height) + var(--safe-bottom));
  padding: 8px 14px calc(8px + var(--safe-bottom));
  background: rgba(245, 242, 234, 0.96);
  border-top: 0.5px solid rgba(44, 44, 44, 0.1);
  box-shadow: 0 -4px 20px rgba(44, 44, 44, 0.04);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
}

.nav-item {
  min-width: 0;
  border-radius: 14px;
  color: rgba(44, 44, 44, 0.42);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 2px;
  transition:
    transform 0.15s ease,
    color 0.15s ease,
    background 0.15s ease;
}

.nav-item span:last-child {
  font-size: 10px;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.nav-item.active {
  color: var(--charcoal);
  font-weight: 900;
  background: rgba(212, 175, 55, 0.1);
  border-top: 2px solid var(--gold);
}

/* =========================
   MODALS — STITCH-ALIGNED
========================= */

.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(52, 48, 39, 0.48);
  backdrop-filter: blur(1px);
  -webkit-backdrop-filter: blur(1px);
}

.modal-sheet {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 560px;
  max-height: calc(92dvh - env(safe-area-inset-top));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--parchment);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: var(--shadow-modal);
  padding: 24px;
  padding-bottom: calc(28px + var(--safe-bottom));
  animation: sheetUp 0.24s ease both;
}

.drag-handle {
  width: 48px;
  height: 4px;
  border-radius: 999px;
  background: rgba(127, 118, 99, 0.32);
  margin: 0 auto 22px;
}

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

.modal-header h2 {
  font-size: 27px;
  line-height: 1.1;
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Goal suggestion card matching Stitch */
.suggestion-card {
  background: var(--paper);
  border: 1px solid rgba(115, 92, 0, 0.1);
  border-radius: var(--radius-lg);
  box-shadow: 0 2px 10px rgba(44, 44, 44, 0.04);
  padding: 16px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.suggestion-icon {
  width: 48px;
  height: 48px;
  border-radius: 999px;
  background: rgba(255, 224, 136, 0.22);
  color: var(--primary);
  display: grid;
  place-items: center;
  flex: 0 0 48px;
}

.suggestion-icon .material-symbols-outlined {
  font-variation-settings: "FILL" 1;
}

.suggestion-card h3 {
  margin: 4px 0 4px;
  font-size: 23px;
  color: var(--charcoal);
}

/* Weight buttons matching Stitch */
.weight-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.weight-btn {
  min-height: 104px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(127, 118, 99, 0.24);
  background: rgba(255, 253, 247, 0.62);
  color: var(--outline);
  padding: 14px 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 8px;
  transition:
    border-color 0.18s ease,
    background 0.18s ease,
    color 0.18s ease,
    transform 0.15s ease;
}

.weight-btn strong {
  font-family: "Noto Serif", Georgia, serif;
  font-size: 40px;
  line-height: 1;
  font-weight: 700;
}

.weight-btn span {
  font-size: 10px;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 900;
}

.weight-btn.selected {
  border: 2px solid var(--primary);
  background: rgba(255, 224, 136, 0.16);
  color: var(--primary);
}

/* =========================
   RESPONSIVE
========================= */

@media (min-width: 700px) {
  .app-shell {
    min-height: 100vh;
    border-left: 1px solid rgba(127, 118, 99, 0.12);
    border-right: 1px solid rgba(127, 118, 99, 0.12);
  }

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

  .quote-card {
    min-height: 150px;
  }
}

/* =========================
   ANIMATIONS
========================= */

@keyframes sheetUp {
  from {
    transform: translateY(18px);
    opacity: 0.86;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes fadeUp {
  from {
    transform: translateY(6px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}
.hidden,
.modal.hidden {
  display: none !important;
}