:root {
  --primary: #6c63ff;
  --primary-dark: #5a52d5;
  --secondary: #00c9a7;
  --danger: #ff5c7c;
  --warning: #ffa94d;
  --success: #40c057;
  --bg: #f8f9fe;
  --surface: #ffffff;
  --text: #1a1a2e;
  --muted: #6e7191;
  --border: #e4e6ef;
  --nav-w: 240px;
  --radius: 12px;
  --shadow: 0 2px 16px rgba(108,99,255,0.08);
}

*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; display: flex; }

/* NAV */
#nav {
  width: var(--nav-w); min-height: 100vh; background: var(--surface);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  position: fixed; left: 0; top: 0; z-index: 100; transition: transform 0.25s ease;
  box-shadow: var(--shadow);
}
.nav-brand { padding: 24px 20px 16px; font-size: 1.25rem; font-weight: 800; color: var(--primary); letter-spacing: -0.5px; }
.nav-list { list-style: none; flex: 1; overflow-y: auto; }
.nav-item { padding: 11px 20px; cursor: pointer; color: var(--muted); font-size: 0.88rem; font-weight: 500; border-radius: 0; transition: all 0.15s; display: flex; align-items: center; gap: 8px; }
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: linear-gradient(90deg,rgba(108,99,255,0.12) 0%,transparent 100%); color: var(--primary); font-weight: 700; border-left: 3px solid var(--primary); }
.nav-bottom { padding: 16px 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.lang-toggle { display: flex; gap: 6px; align-items: center; margin-top: 4px; }
.lang-toggle span { cursor: pointer; font-size: 0.8rem; font-weight: 600; color: var(--muted); padding: 3px 8px; border-radius: 6px; transition: all 0.15s; }
.lang-toggle span.active { background: var(--primary); color: #fff; }

/* MAIN */
#main { margin-left: var(--nav-w); flex: 1; padding: 32px; min-height: 100vh; max-width: calc(100vw - var(--nav-w)); }

/* MOBILE */
#mobile-menu-btn { display: none; position: fixed; top: 12px; left: 12px; z-index: 200; background: var(--primary); color: #fff; border: none; border-radius: 8px; width: 40px; height: 40px; font-size: 1.2rem; cursor: pointer; }

@media (max-width: 768px) {
  #nav { transform: translateX(-100%); }
  #nav.open { transform: translateX(0); }
  #main { margin-left: 0; padding: 16px; padding-top: 64px; max-width: 100vw; }
  #mobile-menu-btn { display: flex; align-items: center; justify-content: center; }
}

/* BUTTONS */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; border-radius: 8px; border: none; font-size: 0.875rem; font-weight: 600; cursor: pointer; transition: all 0.15s; text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: rgba(108,99,255,0.06); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--bg); }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-full { width: 100%; justify-content: center; }
.mt { margin-top: 12px; }

/* CARDS */
.card { background: var(--surface); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); border: 1px solid var(--border); }
.card h3 { font-size: 0.95rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 12px; }

/* PAGE HEADER */
.page-header { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }
.page-header h1 { font-size: 1.5rem; font-weight: 800; color: var(--text); flex: 1; }

/* DASHBOARD */
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.dash-item { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 0.875rem; }
.dash-item:last-child { border-bottom: none; }
.ai-card { cursor: pointer; border: 2px dashed var(--primary); background: linear-gradient(135deg,rgba(108,99,255,0.04),rgba(0,201,167,0.04)); }
.ai-card:hover { border-style: solid; }
.report-card { display: flex; flex-direction: column; gap: 8px; }

/* LISTS */
.list { display: flex; flex-direction: column; gap: 10px; }
.list-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; transition: box-shadow 0.15s; }
.list-item:hover { box-shadow: var(--shadow); }
.list-item.upcoming { border-left: 4px solid var(--secondary); }
.list-item.past { opacity: 0.65; }
.sched-item { flex-direction: row; align-items: center; justify-content: space-between; }

/* BADGES */
.badge { font-size: 0.72rem; font-weight: 700; padding: 2px 8px; border-radius: 20px; text-transform: uppercase; background: var(--bg); color: var(--muted); }
.badge-severe,.badge-sev-8,.badge-sev-9,.badge-sev-10 { background: rgba(255,92,124,0.12); color: var(--danger); }
.badge-moderate,.badge-sev-4,.badge-sev-5,.badge-sev-6,.badge-sev-7 { background: rgba(255,169,77,0.15); color: var(--warning); }
.badge-mild,.badge-sev-1,.badge-sev-2,.badge-sev-3 { background: rgba(64,192,87,0.12); color: var(--success); }
.value-badge { font-size: 0.85rem; font-weight: 700; color: var(--primary); }
.trial-badge { background: linear-gradient(90deg,var(--secondary),var(--primary)); color: #fff; font-size: 0.78rem; font-weight: 700; padding: 4px 12px; border-radius: 20px; }

/* INPUTS */
.input { width: 100%; padding: 10px 14px; border: 1.5px solid var(--border); border-radius: 8px; font-size: 0.9rem; background: var(--bg); color: var(--text); transition: border-color 0.15s; outline: none; margin-bottom: 12px; display: block; }
.input:focus { border-color: var(--primary); background: #fff; }
label { font-size: 0.82rem; font-weight: 600; color: var(--muted); margin-bottom: 4px; display: block; }
.slider { -webkit-appearance: none; height: 6px; border-radius: 3px; background: var(--border); outline: none; cursor: pointer; width: calc(100% - 40px); }
.slider::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--primary); cursor: pointer; }

/* MODAL */
#modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 500; align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--surface); border-radius: 16px; padding: 28px; width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto; position: relative; box-shadow: 0 20px 60px rgba(0,0,0,0.2); }
.modal h2 { font-size: 1.1rem; font-weight: 800; margin-bottom: 16px; }
.modal-close { position: absolute; top: 16px; right: 16px; padding: 4px 8px; }
.checkbox-group { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.checkbox-group label { display: flex; align-items: center; gap: 8px; font-size: 0.875rem; color: var(--text); cursor: pointer; }

/* AI CHAT */
.ai-container { display: flex; flex-direction: column; gap: 12px; height: calc(100vh - 160px); }
.chat-window { flex: 1; background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.chat-msg { max-width: 75%; padding: 10px 14px; border-radius: 12px; font-size: 0.9rem; line-height: 1.5; }
.chat-msg.user { background: var(--primary); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.chat-msg.assistant { background: var(--bg); color: var(--text); align-self: flex-start; border-bottom-left-radius: 4px; }
.chat-msg.thinking { opacity: 0.5; }
.chat-input-row { display: flex; gap: 8px; }
.chat-input-row .input { margin: 0; flex: 1; }
.ai-note { font-size: 0.8rem; background: rgba(108,99,255,0.08); border-left: 3px solid var(--primary); padding: 6px 10px; border-radius: 4px; margin-top: 6px; color: var(--muted); }

/* AUTH */
.auth-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.auth-card { background: var(--surface); border-radius: 20px; padding: 36px 32px; width: 100%; max-width: 400px; box-shadow: 0 8px 40px rgba(108,99,255,0.12); }
.auth-brand { font-size: 1.8rem; font-weight: 900; color: var(--primary); text-align: center; margin-bottom: 6px; }
.auth-sub { text-align: center; color: var(--muted); font-size: 0.875rem; margin-bottom: 20px; }
.auth-switch { text-align: center; color: var(--muted); font-size: 0.875rem; margin-top: 14px; }
.auth-switch a { color: var(--primary); cursor: pointer; font-weight: 600; text-decoration: underline; }
.mb { margin-bottom: 12px; }

/* SETTINGS */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.field { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 0.875rem; }
.field:last-child { border-bottom: none; }
.lang-picker { display: flex; gap: 10px; }
.plan-cards { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.plan-card { border: 1.5px solid var(--border); border-radius: 10px; padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; }
.plan-card.featured { border-color: var(--primary); background: rgba(108,99,255,0.04); }
.plan-card h4 { font-size: 0.9rem; font-weight: 700; }
.plan-card p { color: var(--primary); font-weight: 700; }

/* REPORTS */
.reports-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }

/* TOASTS */
.toast { position: fixed; bottom: 24px; right: 24px; padding: 12px 20px; border-radius: 10px; font-size: 0.875rem; font-weight: 600; z-index: 999; animation: slideIn 0.2s ease; max-width: 320px; box-shadow: 0 4px 20px rgba(0,0,0,0.15); }
.toast-info { background: var(--text); color: #fff; }
.toast-success { background: var(--success); color: #fff; }
.toast-error { background: var(--danger); color: #fff; }
.toast-warning { background: var(--warning); color: #fff; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* MISC */
.muted { color: var(--muted); font-size: 0.825rem; }
.error { color: var(--danger); }
.loading { color: var(--muted); font-size: 0.875rem; padding: 20px 0; }
.alert-flags { display: flex; gap: 8px; flex-wrap: wrap; font-size: 0.78rem; margin-top: 4px; }
