/* ══════════════════════════════════════════════════════════════════════════════
   WHOOP Insights Dashboard - Styles
   Organic Minimalism Design System
   ══════════════════════════════════════════════════════════════════════════════ */

:root {
      --clay: #B565A7;
      --clay-deep: #8B4A80;
      --sage: #7B6FA0;
      --sage-light: #9A8FBB;
      --stone: #D4C2D9;
      --stone-light: #EDE2F0;
      --sand: #F5EEF7;
      --sand-warm: #FBF7FC;
      --olive: #6B5580;
      --charcoal: #362A3E;
      --charcoal-soft: #5A4D63;
      --warm-white: #FDFAFD;
      --shadow-soft: 0 8px 32px rgba(54, 42, 62, 0.08);
      --shadow-warm: 0 16px 48px rgba(181, 101, 167, 0.12);
      --shadow-float: 0 24px 64px rgba(54, 42, 62, 0.10);
    }
    * { margin: 0; padding: 0; box-sizing: border-box; }
    body {
      font-family: 'Outfit', sans-serif;
      font-weight: 300;
      background: var(--sand-warm);
      color: var(--charcoal);
      min-height: 100vh;
      overflow-x: hidden;
    }
    body::before {
      content: '';
      position: fixed;
      inset: 0;
      opacity: 0.03;
      background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
      pointer-events: none;
      z-index: 9999;
    }
    .bg-shape { position: fixed; border-radius: 50%; filter: blur(80px); opacity: 0.15; pointer-events: none; z-index: 0; }
    .bg-shape--sage { width: 600px; height: 600px; background: var(--sage); top: -200px; right: -100px; animation: drift 20s ease-in-out infinite; }
    .bg-shape--clay { width: 400px; height: 400px; background: var(--clay); bottom: -100px; left: -80px; animation: drift 25s ease-in-out infinite reverse; }
    .bg-shape--stone { width: 300px; height: 300px; background: var(--stone); top: 40%; left: 50%; animation: drift 18s ease-in-out infinite 3s; }
    @keyframes drift {
      0%, 100% { transform: translate(0, 0) scale(1); }
      33% { transform: translate(30px, -20px) scale(1.05); }
      66% { transform: translate(-20px, 15px) scale(0.95); }
    }

    /* ── Top Navigation ── */
    .tab-nav {
      position: fixed; top: 0; left: 0; right: 0; z-index: 100;
      display: flex; align-items: center; padding: 0 2rem;
      background: rgba(253, 250, 253, 0.85); backdrop-filter: blur(16px);
      border-bottom: 1px solid rgba(212, 194, 217, 0.3); height: 56px;
    }
    .tab-nav-brand { display: flex; align-items: center; gap: 10px; margin-right: 2.5rem; }
    .tab-nav-brand .brand-mark-sm {
      width: 32px; height: 32px; background: var(--clay); border-radius: 9px;
      display: flex; align-items: center; justify-content: center;
      box-shadow: 0 3px 8px rgba(181, 101, 167, 0.2);
    }
    .tab-nav-brand .brand-mark-sm svg { width: 17px; height: 17px; fill: var(--warm-white); }
    .tab-nav-brand span { font-family: 'DM Serif Display', serif; font-size: 1rem; color: var(--charcoal); }
    .tab-btn {
      font-family: 'Outfit', sans-serif; font-size: 0.88rem; font-weight: 400;
      color: var(--charcoal-soft); background: none; border: none;
      padding: 0 1.25rem; height: 56px; cursor: pointer; position: relative;
      transition: color 0.25s ease; letter-spacing: 0.02em;
    }
    .tab-btn:hover { color: var(--charcoal); }
    .tab-btn.active { color: var(--clay-deep); font-weight: 500; }
    .tab-btn.active::after {
      content: ''; position: absolute; bottom: 0; left: 1.25rem; right: 1.25rem;
      height: 2px; background: var(--clay); border-radius: 2px 2px 0 0;
    }

    .logout-btn {
      margin-left: auto;
      font-family: 'Outfit', sans-serif;
      font-size: 0.85rem;
      font-weight: 500;
      color: var(--charcoal-soft);
      background: rgba(255,255,255,0.6);
      border: 1px solid rgba(212,194,217,0.35);
      padding: 0.5rem 1rem;
      border-radius: 10px;
      cursor: pointer;
      display: flex;
      align-items: center;
      gap: 0.5rem;
      transition: all 0.2s ease;
    }
    .logout-btn:hover {
      background: rgba(255,255,255,0.85);
      color: var(--clay-deep);
      border-color: var(--clay);
      transform: translateY(-1px);
    }
    .logout-btn svg {
      width: 18px;
      height: 18px;
      fill: currentColor;
    }

    .whoop-connect-btn {
      margin-left: 0.5rem;
      font-family: 'Outfit', sans-serif;
      font-size: 0.85rem;
      font-weight: 500;
      color: var(--warm-white);
      background: linear-gradient(135deg, var(--clay), var(--clay-deep));
      border: none;
      padding: 0.5rem 1rem;
      border-radius: 10px;
      cursor: pointer;
      display: flex;
      align-items: center;
      gap: 0.5rem;
      transition: all 0.2s ease;
      box-shadow: 0 2px 8px rgba(181,101,167,0.3);
    }
    .whoop-connect-btn:hover {
      transform: translateY(-1px);
      box-shadow: 0 4px 12px rgba(181,101,167,0.4);
    }
    .whoop-connect-btn svg {
      width: 18px;
      height: 18px;
      fill: currentColor;
    }
    .whoop-connect-btn.connected {
      background: linear-gradient(135deg, var(--sage), var(--sage-light));
    }

    /* ── Views ── */
    .view { display: none; }
    .view.active { display: block; }

    /* ── Chat Agent View ── */
    .page-chat {
      position: relative; z-index: 1; display: grid;
      grid-template-columns: 1fr 1fr; min-height: 100vh; padding-top: 56px;
    }
    .panel-left {
      display: flex; flex-direction: column; justify-content: center;
      padding: 4rem 5rem; position: relative;
    }
    .brand-hero { display: flex; align-items: center; gap: 12px; margin-bottom: 3rem; opacity: 0; animation: fadeUp 0.8s ease-out 0.2s forwards; }
    .brand-hero .brand-mark {
      width: 40px; height: 40px; background: var(--clay); border-radius: 12px;
      display: flex; align-items: center; justify-content: center;
      box-shadow: 0 4px 12px rgba(181, 101, 167, 0.25);
    }
    .brand-hero .brand-mark svg { width: 22px; height: 22px; fill: var(--warm-white); }
    .brand-hero .brand-name { font-family: 'DM Serif Display', serif; font-size: 1.15rem; color: var(--charcoal); letter-spacing: 0.02em; }
    .hero-title { font-family: 'DM Serif Display', serif; font-size: 3.2rem; line-height: 1.15; color: var(--charcoal); margin-bottom: 1.5rem; opacity: 0; animation: fadeUp 0.8s ease-out 0.4s forwards; }
    .hero-title span { color: var(--clay); }
    .hero-desc { font-size: 1.1rem; line-height: 1.7; color: var(--charcoal-soft); max-width: 440px; margin-bottom: 3rem; opacity: 0; animation: fadeUp 0.8s ease-out 0.6s forwards; }
    .metrics { display: flex; gap: 2rem; opacity: 0; animation: fadeUp 0.8s ease-out 0.8s forwards; }
    .metric {
      padding: 1.25rem 1.5rem; background: rgba(255,255,255,0.6); backdrop-filter: blur(12px);
      border-radius: 20px; border: 1px solid rgba(212,194,217,0.4); min-width: 130px;
      transition: transform 0.3s ease, box-shadow 0.3s ease;
    }
    .metric:hover { transform: translateY(-4px); box-shadow: var(--shadow-soft); }
    .metric-value { font-family: 'DM Serif Display', serif; font-size: 1.8rem; color: var(--clay-deep); margin-bottom: 0.25rem; }
    .metric-label { font-size: 0.78rem; font-weight: 400; color: var(--charcoal-soft); text-transform: uppercase; letter-spacing: 0.08em; }
    .divider-organic { position: absolute; right: 0; top: 0; height: 100%; width: 80px; z-index: 2; }
    .panel-right {
      position: relative; display: flex; align-items: center; justify-content: center;
      padding: 2rem 2.5rem 2rem 1rem;
      background: linear-gradient(180deg, rgba(237,226,240,0.3) 0%, rgba(245,238,247,0.5) 100%);
    }
    .chat-container {
      width: 100%; height: calc(100vh - 4rem - 56px); max-height: 780px;
      border-radius: 28px; overflow: hidden; background: var(--warm-white);
      box-shadow: var(--shadow-float); border: 1px solid rgba(212,194,217,0.35);
      position: relative; opacity: 0; animation: fadeScale 0.9s ease-out 0.5s forwards;
    }
    .chat-container::before {
      content: ''; position: absolute; inset: 0; border-radius: 28px; padding: 1px;
      background: linear-gradient(135deg, rgba(181,101,167,0.2), transparent 50%, rgba(123,111,160,0.15));
      -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
      -webkit-mask-composite: xor; mask-composite: exclude; pointer-events: none;
    }
    .chat-header {
      padding: 1rem 1.5rem; background: linear-gradient(135deg, var(--stone-light), var(--sand));
      border-bottom: 1px solid rgba(212,194,217,0.3); display: flex; align-items: center; gap: 10px;
    }
    .chat-status { width: 8px; height: 8px; background: var(--sage); border-radius: 50%; animation: pulse 2s ease-in-out infinite; }
    .chat-header-text { font-size: 0.82rem; font-weight: 400; color: var(--charcoal-soft); letter-spacing: 0.04em; }
    .chat-container iframe { width: 100%; height: calc(100% - 52px); border: none; display: block; }

    /* ── Dashboard View ── */
    .page-dashboard {
      position: relative; z-index: 1; padding-top: 56px; height: 100vh;
      display: grid;
      grid-template-columns: 320px 1fr;
      gap: 0;
      overflow: hidden;
    }

    /* ── Login Modal ── */
    .login-modal {
      position: fixed;
      top: 56px;
      left: 0;
      right: 0;
      bottom: 0;
      background: var(--sand-warm);
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 200;
      padding: 2rem;
    }

    .login-container {
      width: 100%;
      max-width: 420px;
      background: rgba(255,255,255,0.75);
      backdrop-filter: blur(20px);
      border-radius: 28px;
      border: 1px solid rgba(212,194,217,0.4);
      padding: 2.5rem;
      box-shadow: var(--shadow-float);
      opacity: 0;
      animation: fadeScale 0.6s ease-out 0.2s forwards;
    }

    .login-header {
      text-align: center;
      margin-bottom: 2rem;
    }

    .login-brand {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 10px;
      margin-bottom: 1.5rem;
    }

    .login-brand .brand-mark {
      width: 40px;
      height: 40px;
      background: var(--clay);
      border-radius: 12px;
      display: flex;
      align-items: center;
      justify-content: center;
      box-shadow: 0 4px 12px rgba(181, 101, 167, 0.25);
    }

    .login-brand .brand-mark svg {
      width: 22px;
      height: 22px;
      fill: var(--warm-white);
    }

    .login-brand-name {
      font-family: 'DM Serif Display', serif;
      font-size: 1.15rem;
      color: var(--charcoal);
      letter-spacing: 0.02em;
    }

    .login-header h2 {
      font-family: 'DM Serif Display', serif;
      font-size: 2rem;
      color: var(--charcoal);
      margin-bottom: 0.5rem;
    }

    .login-header p {
      font-size: 0.95rem;
      color: var(--charcoal-soft);
    }

    .login-form {
      display: flex;
      flex-direction: column;
      gap: 1.25rem;
    }

    .form-group {
      display: flex;
      flex-direction: column;
      gap: 0.5rem;
    }

    .form-group label {
      font-size: 0.85rem;
      font-weight: 500;
      color: var(--charcoal);
      letter-spacing: 0.02em;
    }

    .form-group input {
      font-family: 'Outfit', sans-serif;
      font-size: 0.95rem;
      padding: 0.85rem 1.15rem;
      border-radius: 14px;
      border: 1px solid rgba(212,194,217,0.4);
      background: rgba(255,255,255,0.6);
      color: var(--charcoal);
      transition: all 0.2s ease;
    }

    .form-group input:focus {
      outline: none;
      border-color: var(--clay);
      background: rgba(255,255,255,0.85);
      box-shadow: 0 0 0 3px rgba(181,101,167,0.1);
    }

    .form-group input::placeholder {
      color: var(--charcoal-soft);
      opacity: 0.6;
    }

    .form-options {
      display: flex;
      justify-content: space-between;
      align-items: center;
      font-size: 0.85rem;
    }

    .remember-me {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      cursor: pointer;
      color: var(--charcoal-soft);
    }

    .remember-me input[type="checkbox"] {
      width: 18px;
      height: 18px;
      cursor: pointer;
      accent-color: var(--clay);
    }

    .forgot-password {
      color: var(--clay-deep);
      text-decoration: none;
      transition: color 0.2s ease;
    }

    .forgot-password:hover {
      color: var(--clay);
    }

    .login-btn {
      font-family: 'Outfit', sans-serif;
      font-size: 1rem;
      font-weight: 500;
      padding: 1rem 1.5rem;
      border-radius: 14px;
      border: none;
      background: linear-gradient(135deg, var(--clay), var(--clay-deep));
      color: var(--warm-white);
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 0.5rem;
      transition: all 0.3s ease;
      box-shadow: 0 4px 16px rgba(181,101,167,0.3);
      margin-top: 0.5rem;
    }

    .login-btn:hover {
      transform: translateY(-2px);
      box-shadow: 0 6px 20px rgba(181,101,167,0.4);
    }

    .login-btn:active {
      transform: translateY(0);
    }

    .login-btn svg {
      width: 20px;
      height: 20px;
      fill: var(--warm-white);
    }

    .login-error {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      padding: 0.75rem 1rem;
      border-radius: 12px;
      background: rgba(201,112,100,0.1);
      border: 1px solid rgba(201,112,100,0.3);
      color: #C97064;
      font-size: 0.85rem;
      margin-top: 0.5rem;
    }

    .login-error svg {
      width: 18px;
      height: 18px;
      fill: #C97064;
      flex-shrink: 0;
    }

    .login-footer {
      text-align: center;
      margin-top: 1.5rem;
      padding-top: 1.5rem;
      border-top: 1px solid rgba(212,194,217,0.3);
      font-size: 0.9rem;
      color: var(--charcoal-soft);
    }

    .login-footer a {
      color: var(--clay-deep);
      text-decoration: none;
      font-weight: 500;
      transition: color 0.2s ease;
    }

    .login-footer a:hover {
      color: var(--clay);
    }

    @media (max-width: 480px) {
      .login-container {
        padding: 2rem 1.5rem;
      }
      .login-header h2 {
        font-size: 1.6rem;
      }
    }

    .dashboard-sidebar {
      padding: 2rem 1.5rem;
      background: linear-gradient(180deg, rgba(237,226,240,0.3) 0%, rgba(245,238,247,0.5) 100%);
      border-right: 1px solid rgba(212,194,217,0.3);
      display: flex;
      flex-direction: column;
      gap: 1.5rem;
      overflow-y: auto;
    }
    .dashboard-main {
      padding: 2rem 2.5rem;
      overflow-y: auto;
      display: flex;
      flex-direction: column;
    }
    .dashboard-header {
      margin-bottom: 1.5rem;
      opacity: 0; animation: fadeUp 0.6s ease-out 0.15s forwards;
    }
    .dashboard-header h2 {
      font-family: 'DM Serif Display', serif; font-size: 1.8rem; color: var(--charcoal); margin-bottom: 0.35rem;
    }
    .dashboard-header p { font-size: 0.88rem; color: var(--charcoal-soft); }
    .dashboard-date { font-weight: 500; color: var(--clay); }

    .charts-row {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 1.5rem;
      margin-bottom: 1.5rem;
    }
    .chart-card {
      background: rgba(255,255,255,0.65); backdrop-filter: blur(14px);
      border-radius: 20px; border: 1px solid rgba(212,194,217,0.35);
      padding: 1.5rem 1.25rem 1.25rem; text-align: center;
      box-shadow: var(--shadow-soft);
      transition: transform 0.35s ease, box-shadow 0.35s ease;
      opacity: 0;
    }
    .chart-card:nth-child(1) { animation: fadeUp 0.7s ease-out 0.25s forwards; }
    .chart-card:nth-child(2) { animation: fadeUp 0.7s ease-out 0.4s forwards; }
    .chart-card:nth-child(3) { animation: fadeUp 0.7s ease-out 0.55s forwards; }
    .chart-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-warm); }

    .progress-ring { position: relative; width: 120px; height: 120px; margin: 0 auto 1rem; }
    .progress-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
    .progress-ring .ring-bg {
      fill: none; stroke: var(--stone-light); stroke-width: 8; stroke-linecap: round;
    }
    .progress-ring .ring-fill {
      fill: none; stroke-width: 8; stroke-linecap: round;
      stroke-dasharray: 440; stroke-dashoffset: 440;
      transition: stroke-dashoffset 1.5s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .progress-ring .ring-value {
      position: absolute; inset: 0; display: flex; flex-direction: column;
      align-items: center; justify-content: center;
    }
    .ring-number {
      font-family: 'DM Serif Display', serif; font-size: 1.8rem; line-height: 1;
    }
    .ring-unit { font-size: 0.7rem; color: var(--charcoal-soft); margin-top: 3px; letter-spacing: 0.04em; }

    .chart-label {
      font-family: 'DM Serif Display', serif; font-size: 1rem; color: var(--charcoal); margin-bottom: 0.25rem;
    }
    .chart-sub { font-size: 0.75rem; color: var(--charcoal-soft); }

    /* ── User Profile Card ── */
    .user-card {
      background: rgba(255,255,255,0.65); backdrop-filter: blur(14px);
      border-radius: 18px; border: 1px solid rgba(212,194,217,0.35);
      padding: 1.25rem; box-shadow: var(--shadow-soft);
      opacity: 0; animation: fadeUp 0.6s ease-out 0.1s forwards;
    }
    .user-avatar {
      width: 56px; height: 56px; border-radius: 50%;
      background: linear-gradient(135deg, var(--clay), var(--sage));
      display: flex; align-items: center; justify-content: center;
      margin: 0 auto 1rem; box-shadow: 0 4px 16px rgba(181,101,167,0.2);
    }
    .user-avatar svg { width: 28px; height: 28px; fill: var(--warm-white); }
    .user-info { text-align: center; }
    .user-name {
      font-family: 'DM Serif Display', serif; font-size: 1.1rem;
      color: var(--charcoal); margin-bottom: 0.15rem;
    }
    .user-email { font-size: 0.75rem; color: var(--charcoal-soft); margin-bottom: 1rem; }
    .user-stats { display: flex; flex-direction: column; gap: 0.75rem; }
    .user-stat-item { 
      display: flex; justify-content: space-between; align-items: center;
      padding: 0.5rem 0.75rem; background: rgba(255,255,255,0.4);
      border-radius: 10px;
    }
    .user-stat-label {
      font-size: 0.7rem; color: var(--charcoal-soft); text-transform: uppercase;
      letter-spacing: 0.06em;
    }
    .user-stat-val {
      font-family: 'DM Serif Display', serif; font-size: 0.95rem; color: var(--clay-deep);
    }

    /* ── Section Headers ── */
    .section-header {
      margin-bottom: 1rem;
      opacity: 0; animation: fadeUp 0.6s ease-out 0.7s forwards;
    }
    .section-header h3 {
      font-family: 'DM Serif Display', serif; font-size: 1.3rem; color: var(--charcoal); margin-bottom: 0.25rem;
    }
    .section-header p { font-size: 0.8rem; color: var(--charcoal-soft); }

    .section-title-row {
      display: flex; justify-content: space-between; align-items: center;
      gap: 1rem; flex-wrap: wrap;
    }

    .week-navigation {
      display: flex; align-items: center; gap: 0.75rem;
    }
    .week-nav-btn {
      width: 32px; height: 32px; border-radius: 10px;
      background: rgba(255,255,255,0.6); backdrop-filter: blur(8px);
      border: 1px solid rgba(212,194,217,0.35);
      display: flex; align-items: center; justify-content: center;
      cursor: pointer; transition: all 0.2s ease;
      box-shadow: 0 2px 8px rgba(54,42,62,0.06);
    }
    .week-nav-btn:hover:not(:disabled) {
      background: rgba(255,255,255,0.85);
      transform: translateY(-2px);
      box-shadow: 0 4px 12px rgba(54,42,62,0.1);
    }
    .week-nav-btn:active:not(:disabled) {
      transform: translateY(0);
    }
    .week-nav-btn:disabled {
      opacity: 0.4;
      cursor: not-allowed;
    }
    .week-nav-btn svg {
      width: 20px; height: 20px; fill: var(--clay-deep);
    }
    .week-label {
      font-family: 'DM Serif Display', serif;
      font-size: 0.95rem; color: var(--charcoal);
      min-width: 120px; text-align: center;
    }

    @media (max-width: 768px) {
      .section-title-row {
        flex-direction: column;
        align-items: flex-start;
      }
      .week-navigation {
        width: 100%;
        justify-content: center;
      }
    }

    /* ── Sleep Stages ── */
    .sleep-stages {
      margin-bottom: 1.5rem;
      opacity: 0; animation: fadeUp 0.7s ease-out 0.8s forwards;
    }
    .stage-bar {
      display: flex; height: 48px; border-radius: 14px; overflow: hidden;
      box-shadow: var(--shadow-soft); margin-bottom: 1rem;
      background: rgba(255,255,255,0.4);
    }
    .stage-segment {
      position: relative; transition: transform 0.3s ease;
      cursor: pointer;
    }
    .stage-segment:hover { transform: scaleY(1.08); z-index: 1; }
    .stage-awake { background: linear-gradient(135deg, #E8D5E0, #D4C2D9); }
    .stage-light { background: linear-gradient(135deg, #9A8FBB, #7B6FA0); }
    .stage-deep { background: linear-gradient(135deg, #6B5580, #5A4D63); }
    .stage-rem { background: linear-gradient(135deg, #B565A7, #8B4A80); }

    .stage-legend {
      display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem;
    }
    .legend-item {
      display: flex; align-items: center; gap: 8px; font-size: 0.78rem; color: var(--charcoal-soft);
    }
    .legend-dot {
      width: 12px; height: 12px; border-radius: 4px; flex-shrink: 0;
    }

    /* ── Stats Comparison ── */
    .stats-comparison {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 1.5rem;
      margin-bottom: 2rem;
    }
    .comparison-card {
      background: rgba(255,255,255,0.65); backdrop-filter: blur(14px);
      border-radius: 20px; border: 1px solid rgba(212,194,217,0.35);
      padding: 1.5rem; box-shadow: var(--shadow-soft);
      transition: transform 0.35s ease, box-shadow 0.35s ease;
      opacity: 0;
    }
    .comparison-card:nth-child(1) { animation: fadeUp 0.7s ease-out 0.95s forwards; }
    .comparison-card:nth-child(2) { animation: fadeUp 0.7s ease-out 1.1s forwards; }
    .comparison-card:nth-child(3) { animation: fadeUp 0.7s ease-out 1.25s forwards; }
    .comparison-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-warm); }

    .comparison-header {
      display: flex; align-items: center; gap: 1rem; margin-bottom: 1.25rem;
    }
    .comparison-icon {
      width: 44px; height: 44px; border-radius: 12px;
      display: flex; align-items: center; justify-content: center;
      flex-shrink: 0; box-shadow: 0 3px 12px rgba(123,111,160,0.2);
    }
    .comparison-icon svg { width: 22px; height: 22px; fill: var(--warm-white); }
    .comparison-title { flex: 1; }
    .comparison-title h4 {
      font-family: 'DM Serif Display', serif; font-size: 1rem;
      color: var(--charcoal); margin-bottom: 0.25rem;
    }
    .comparison-current {
      font-family: 'DM Serif Display', serif; font-size: 1.5rem;
      color: var(--clay-deep); margin: 0;
    }

    .comparison-periods {
      display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 1rem;
    }
    .period-stat {
      display: flex; align-items: center; justify-content: space-between;
      padding: 0.65rem 0.85rem; background: rgba(255,255,255,0.4);
      border-radius: 10px; transition: background 0.2s ease;
    }
    .period-stat:hover { background: rgba(255,255,255,0.6); }
    .period-label {
      font-size: 0.75rem; color: var(--charcoal-soft);
      text-transform: uppercase; letter-spacing: 0.06em; flex: 1;
    }
    .period-value {
      font-family: 'DM Serif Display', serif; font-size: 0.95rem;
      color: var(--charcoal); margin-right: 0.75rem;
    }
    .trend-indicator {
      font-size: 0.7rem; font-weight: 500; padding: 0.25rem 0.5rem;
      border-radius: 6px; letter-spacing: 0.02em;
    }
    .trend-up {
      color: var(--sage); background: rgba(123,111,160,0.12);
    }
    .trend-down {
      color: #C97064; background: rgba(201,112,100,0.12);
    }

    .mini-chart {
      height: 40px; margin-top: 0.5rem; position: relative;
    }
    .mini-chart svg {
      width: 100%; height: 100%; display: block;
    }

    @media (max-width: 1200px) {
      .stats-comparison {
        grid-template-columns: 1fr;
        gap: 1rem;
      }
    }

    /* ── Weekly Line Graph ── */
    .weekly-graph-container {
      background: rgba(255,255,255,0.65); backdrop-filter: blur(14px);
      border-radius: 20px; border: 1px solid rgba(212,194,217,0.35);
      padding: 1.5rem; box-shadow: var(--shadow-soft);
      margin-bottom: 2rem;
      opacity: 0;
      animation: fadeUp 0.7s ease-out 1.4s forwards;
    }

    .graph-legend {
      display: flex; gap: 2rem; justify-content: center;
      margin-bottom: 1.5rem;
    }
    .legend-item-graph {
      display: flex; align-items: center; gap: 0.5rem;
      font-size: 0.85rem; color: var(--charcoal-soft);
    }
    .legend-line {
      width: 32px; height: 3px; border-radius: 2px;
    }
    .legend-recovery { background: var(--clay); }
    .legend-strain { background: var(--sage-light); }

    .line-graph {
      width: 100%; height: 300px;
      position: relative;
    }
    .line-graph svg {
      width: 100%; height: 100%;
    }

    .line-path {
      stroke-dasharray: 1000;
      stroke-dashoffset: 1000;
      animation: drawLine 1.5s ease-out forwards;
    }
    .recovery-path {
      animation-delay: 0.3s;
    }
    .strain-path {
      animation-delay: 0.6s;
    }

    @keyframes drawLine {
      to {
        stroke-dashoffset: 0;
      }
    }

    .data-point {
      opacity: 0;
      animation: fadeInPoint 0.4s ease-out forwards;
      transition: r 0.2s ease, opacity 0.2s ease;
      cursor: pointer;
    }
    .data-point:hover {
      r: 7;
      opacity: 1;
    }

    .recovery-line-group .data-point:nth-child(2) { animation-delay: 0.5s; }
    .recovery-line-group .data-point:nth-child(3) { animation-delay: 0.6s; }
    .recovery-line-group .data-point:nth-child(4) { animation-delay: 0.7s; }
    .recovery-line-group .data-point:nth-child(5) { animation-delay: 0.8s; }
    .recovery-line-group .data-point:nth-child(6) { animation-delay: 0.9s; }
    .recovery-line-group .data-point:nth-child(7) { animation-delay: 1s; }
    .recovery-line-group .data-point:nth-child(8) { animation-delay: 1.1s; }

    .strain-line-group .data-point:nth-child(2) { animation-delay: 0.8s; }
    .strain-line-group .data-point:nth-child(3) { animation-delay: 0.9s; }
    .strain-line-group .data-point:nth-child(4) { animation-delay: 1s; }
    .strain-line-group .data-point:nth-child(5) { animation-delay: 1.1s; }
    .strain-line-group .data-point:nth-child(6) { animation-delay: 1.2s; }
    .strain-line-group .data-point:nth-child(7) { animation-delay: 1.3s; }
    .strain-line-group .data-point:nth-child(8) { animation-delay: 1.4s; }

    @keyframes fadeInPoint {
      from {
        opacity: 0;
        transform: scale(0);
      }
      to {
        opacity: 1;
        transform: scale(1);
      }
    }

    @media (max-width: 960px) {
      .line-graph {
        height: 250px;
      }
      .graph-legend {
        gap: 1rem;
      }
    }

    /* ── Workouts Grid ── */
    .workouts-grid {
      display: flex; flex-direction: column; gap: 1rem;
    }
    .workout-card {
      background: rgba(255,255,255,0.65); backdrop-filter: blur(14px);
      border-radius: 16px; border: 1px solid rgba(212,194,217,0.35);
      padding: 1rem 1.25rem; box-shadow: var(--shadow-soft);
      transition: transform 0.3s ease, box-shadow 0.3s ease;
      opacity: 0; display: flex; align-items: center; gap: 1rem;
    }
    .workout-card:nth-child(1) { animation: fadeUp 0.7s ease-out 0.9s forwards; }
    .workout-card:nth-child(2) { animation: fadeUp 0.7s ease-out 1.05s forwards; }
    .workout-card:nth-child(3) { animation: fadeUp 0.7s ease-out 1.2s forwards; }
    .workout-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-warm); }

    .workout-icon {
      width: 40px; height: 40px; border-radius: 12px;
      background: linear-gradient(135deg, var(--sage-light), var(--sage));
      display: flex; align-items: center; justify-content: center;
      flex-shrink: 0; box-shadow: 0 3px 10px rgba(123,111,160,0.2);
    }
    .workout-icon svg { width: 22px; height: 22px; fill: var(--warm-white); }

    .workout-info { flex: 1; min-width: 0; }
    .workout-type {
      font-family: 'DM Serif Display', serif; font-size: 0.95rem; color: var(--charcoal); margin-bottom: 0.15rem;
    }
    .workout-time { font-size: 0.7rem; color: var(--charcoal-soft); }

    .workout-stats {
      display: flex; gap: 1rem;
    }
    .workout-stat { display: flex; flex-direction: column; align-items: flex-end; }
    .stat-val {
      font-family: 'DM Serif Display', serif; font-size: 0.95rem; color: var(--clay-deep);
    }
    .stat-unit {
      font-size: 0.65rem; color: var(--charcoal-soft); text-transform: uppercase; letter-spacing: 0.06em;
    }

    /* ── Dashboard Chat Sidebar ── */
    .dash-chat-toggle {
      position: fixed; top: 72px; right: 1.5rem; z-index: 90;
      width: 44px; height: 44px; border-radius: 14px; border: 1px solid rgba(212,194,217,0.4);
      background: rgba(255,255,255,0.75); backdrop-filter: blur(12px);
      cursor: pointer; display: flex; align-items: center; justify-content: center;
      box-shadow: var(--shadow-soft); transition: transform 0.2s ease, box-shadow 0.2s ease;
    }
    .dash-chat-toggle:hover { transform: scale(1.06); box-shadow: var(--shadow-warm); }
    .dash-chat-toggle svg { width: 22px; height: 22px; fill: var(--clay-deep); }

    .dash-sidebar {
      position: fixed; top: 56px; right: 0; bottom: 0; width: 420px; z-index: 80;
      background: linear-gradient(180deg, rgba(237,226,240,0.5) 0%, rgba(245,238,247,0.7) 100%);
      backdrop-filter: blur(10px);
      border-left: 1px solid rgba(212,194,217,0.3);
      transform: translateX(100%);
      transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
      padding: 1.25rem;
      display: none;
    }
    .dash-sidebar.visible { display: block; }
    .dash-sidebar.open { transform: translateX(0); }

    .dash-sidebar .sidebar-chat {
      width: 100%; height: 100%; border-radius: 22px; overflow: hidden;
      background: var(--warm-white); box-shadow: var(--shadow-float);
      border: 1px solid rgba(212,194,217,0.35); display: flex; flex-direction: column;
    }
    .dash-sidebar .sidebar-chat-header {
      padding: 0.85rem 1.25rem; background: linear-gradient(135deg, var(--stone-light), var(--sand));
      border-bottom: 1px solid rgba(212,194,217,0.3); display: flex; align-items: center; gap: 10px;
    }
    .dash-sidebar .sidebar-chat-header .chat-status { width: 8px; height: 8px; background: var(--sage); border-radius: 50%; animation: pulse 2s ease-in-out infinite; }
    .dash-sidebar .sidebar-chat-header span { font-size: 0.82rem; font-weight: 400; color: var(--charcoal-soft); letter-spacing: 0.04em; }
    .sidebar-close {
      margin-left: auto; background: none; border: none; cursor: pointer;
      width: 28px; height: 28px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
      transition: background 0.2s ease;
    }
    .sidebar-close:hover { background: rgba(212,194,217,0.3); }
    .sidebar-close svg { width: 16px; height: 16px; fill: var(--charcoal-soft); }
    .dash-sidebar iframe { flex: 1; width: 100%; border: none; display: block; }

    /* Shift dashboard content when sidebar is open */
    .page-dashboard.sidebar-active .dashboard-main {
      padding-right: 440px;
      transition: padding-right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    }

    @media (max-width: 1200px) {
      .page-dashboard {
        grid-template-columns: 280px 1fr;
      }
      .dashboard-sidebar { padding: 1.5rem 1rem; }
      .dashboard-main { padding: 1.5rem 2rem; }
    }

    @media (max-width: 960px) {
      .page-dashboard {
        grid-template-columns: 1fr;
        display: flex;
        flex-direction: column;
      }
      .dashboard-sidebar {
        border-right: none;
        border-bottom: 1px solid rgba(212,194,217,0.3);
        max-height: 40vh;
      }
      .dashboard-main { padding: 1.5rem; }
      .dash-sidebar { width: 100%; }
      .page-dashboard.sidebar-active .dashboard-main { padding-right: 1.5rem; }
      .charts-row { grid-template-columns: 1fr; }
    }

    /* Ring colors */
    .ring-sleep { stroke: var(--sage); }
    .ring-recovery { stroke: var(--clay); }
    .ring-strain { stroke: var(--sage-light); }
    .num-sleep { color: var(--sage); }
    .num-recovery { color: var(--clay); }
    .num-strain { color: var(--sage-light); }

    /* ── Animations ── */
    @keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.5; transform: scale(0.85); } }
    @keyframes fadeUp { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }
    @keyframes fadeScale { from { opacity: 0; transform: scale(0.96) translateY(12px); } to { opacity: 1; transform: scale(1) translateY(0); } }

    /* ── Responsive ── */
    @media (max-width: 960px) {
      .page-chat { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
      .panel-left { padding: 2.5rem 2rem; text-align: center; align-items: center; }
      .hero-title { font-size: 2.2rem; }
      .hero-desc { max-width: 100%; }
      .metrics { justify-content: center; }
      .divider-organic { display: none; }
      .panel-right { padding: 0 1rem 1.5rem; }
      .chat-container { height: 70vh; max-height: 700px; border-radius: 22px; }
      .charts-row { gap: 1.5rem; }
      .chart-card { min-width: 200px; padding: 2rem 1.5rem 1.5rem; }
      .progress-ring { width: 140px; height: 140px; }
    }


/* ══════════════════════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE ENHANCEMENTS
   ══════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  /* Typography scaling */
  .hero-title { font-size: 2rem; line-height: 1.2; }
  .hero-desc { font-size: 0.95rem; }
  .section-title { font-size: 1.3rem; }
  
  /* Layout adjustments */
  .panel-left { padding: 2rem 1.5rem; }
  .panel-right { padding: 0 1rem 1rem; }
  .dashboard-main { padding: 1rem; }
  
  /* Cards and containers */
  .chart-card { 
    padding: 1.5rem 1rem; 
    min-width: unset;
  }
  .progress-ring { 
    width: 120px; 
    height: 120px; 
  }
  .ring-number { font-size: 2rem; }
  .ring-label { font-size: 0.75rem; }
  
  /* Stats grid */
  .stats-grid { 
    grid-template-columns: 1fr; 
    gap: 1rem; 
  }
  
  /* Trends section */
  .trends-overview { 
    grid-template-columns: 1fr; 
    gap: 1rem; 
  }
  .trend-card { padding: 1.25rem; }
  
  /* Weekly graph */
  .weekly-graph { 
    padding: 1.5rem 1rem; 
    height: 320px;
  }
  .graph-header { 
    flex-direction: column; 
    align-items: flex-start; 
    gap: 1rem; 
  }
  .graph-nav { width: 100%; justify-content: space-between; }
  
  /* Sleep stages */
  .sleep-stages { padding: 1.5rem 1rem; }
  .stages-grid { 
    grid-template-columns: repeat(2, 1fr); 
    gap: 1rem; 
  }
  
  /* Workouts */
  .workouts-list { gap: 1rem; }
  .workout-card { padding: 1.25rem; }
  
  /* User profile */
  .user-profile { 
    flex-direction: column; 
    text-align: center; 
    gap: 1rem; 
  }
  .user-avatar { margin: 0 auto; }
  .user-info { align-items: center; }
  
  /* Buttons */
  .btn-primary, .btn-secondary { 
    padding: 0.875rem 1.5rem; 
    font-size: 0.9rem; 
  }
  
  /* Chat container */
  .chat-container { 
    height: 60vh; 
    max-height: 600px; 
    border-radius: 18px; 
  }
  
  /* Metrics */
  .metrics { 
    flex-wrap: wrap; 
    gap: 1.5rem; 
    justify-content: center; 
  }
  .metric { min-width: 120px; }
  
  /* Login modal */
  .login-modal { 
    padding: 2rem 1.5rem; 
    max-width: 90%; 
  }
  
  /* Sidebar */
  .dash-sidebar { 
    width: 85vw; 
    max-width: 320px; 
  }
  
  /* Navigation tabs */
  .nav-tabs { 
    gap: 0.5rem; 
    padding: 0 1rem; 
  }
  .nav-tab { 
    padding: 0.75rem 1rem; 
    font-size: 0.85rem; 
  }
}

@media (max-width: 480px) {
  /* Extra small screens */
  .hero-title { font-size: 1.75rem; }
  .hero-desc { font-size: 0.9rem; }
  
  .panel-left { padding: 1.5rem 1rem; }
  .panel-right { padding: 0 0.75rem 0.75rem; }
  .dashboard-main { padding: 0.75rem; }
  
  .chart-card { padding: 1.25rem 0.875rem; }
  .progress-ring { 
    width: 100px; 
    height: 100px; 
  }
  .ring-number { font-size: 1.75rem; }
  .ring-label { font-size: 0.7rem; }
  
  .stages-grid { 
    grid-template-columns: 1fr; 
  }
  
  .btn-primary, .btn-secondary { 
    padding: 0.75rem 1.25rem; 
    font-size: 0.85rem; 
    width: 100%;
  }
  
  .metric { 
    min-width: 100px; 
    font-size: 0.85rem; 
  }
  .metric-value { font-size: 1.5rem; }
  
  .login-modal { 
    padding: 1.5rem 1rem; 
    max-width: 95%; 
  }
  
  .brand-mark { 
    width: 50px; 
    height: 50px; 
  }
  
  .nav-tabs { 
    gap: 0.25rem; 
    padding: 0 0.5rem; 
  }
  .nav-tab { 
    padding: 0.625rem 0.75rem; 
    font-size: 0.8rem; 
  }
  
  .weekly-graph { 
    height: 280px; 
    padding: 1.25rem 0.75rem; 
  }
  
  .graph-legend { 
    flex-direction: column; 
    gap: 0.5rem; 
  }
}

/* Landscape mobile optimization */
@media (max-width: 960px) and (max-height: 500px) {
  .chat-container { 
    height: 70vh; 
    max-height: none; 
  }
  .panel-left { 
    padding: 1.5rem; 
  }
  .hero-title { font-size: 1.75rem; }
  .metrics { gap: 1rem; }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
  .btn-primary, .btn-secondary, .nav-tab, .workout-card {
    min-height: 44px; /* iOS touch target minimum */
  }
  
  .nav-tab {
    padding: 0.875rem 1.25rem;
  }
  
  .btn-icon {
    width: 44px;
    height: 44px;
  }
}
