/* PlanWealth — AI CFP Financial Planner */
:root {
  --pw-primary: #0E5E4E;
  --pw-primary-dark: #093F34;
  --pw-primary-light: #E3F0EC;
  --pw-accent: #C9A227;
  --pw-accent-light: #F7EFD8;
  --pw-bg: #F4F7F6;
  --pw-card: #FFFFFF;
  --pw-text: #1F2937;
  --pw-muted: #6B7280;
  --pw-border: #E5E7EB;
  --pw-danger: #DC2626;
  --pw-warn: #D97706;
  --pw-ok: #059669;
  --pw-radius: 14px;
  --pw-shadow: 0 1px 3px rgba(15, 60, 50, .08), 0 4px 16px rgba(15, 60, 50, .06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* line-minimal icons (icons.js) */
.ico-line { vertical-align: -0.18em; flex-shrink: 0; }
.sidebar nav button .ico-line, h3 .ico-line { vertical-align: -0.22em; }
.callout .ico-line { vertical-align: -0.2em; margin-right: 2px; }

body {
  font-family: 'Kanit', 'Segoe UI', sans-serif;
  background: var(--pw-bg);
  color: var(--pw-text);
  font-size: 15px;
  line-height: 1.55;
}

a { color: var(--pw-primary); text-decoration: none; }

/* ===== Landing ===== */
.landing-hero {
  background: linear-gradient(135deg, var(--pw-primary-dark) 0%, var(--pw-primary) 55%, #14735F 100%);
  color: #fff;
  padding: 72px 24px 88px;
  text-align: center;
}
.landing-hero .logo { font-size: 28px; font-weight: 700; letter-spacing: .5px; margin-bottom: 36px; }
.landing-hero .logo span { color: var(--pw-accent); }
.landing-hero h1 { font-size: clamp(30px, 5vw, 52px); font-weight: 700; max-width: 820px; margin: 0 auto 18px; }
.landing-hero p.sub { font-size: clamp(16px, 2.2vw, 20px); opacity: .9; max-width: 640px; margin: 0 auto 36px; font-weight: 300; }
.btn {
  display: inline-block; padding: 13px 32px; border-radius: 999px; font-weight: 600;
  font-size: 16px; border: none; cursor: pointer; transition: transform .15s, box-shadow .15s;
  font-family: inherit;
}
.btn:hover { transform: translateY(-2px); }
.btn-gold { background: var(--pw-accent); color: #2B2410; box-shadow: 0 4px 18px rgba(201,162,39,.45); }
.btn-outline-w { background: transparent; color: #fff; border: 1.5px solid rgba(255,255,255,.6); margin-left: 12px; }

.features { max-width: 1080px; margin: -48px auto 0; padding: 0 24px 64px; display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 18px; }
.feature-card { background: var(--pw-card); border-radius: var(--pw-radius); box-shadow: var(--pw-shadow); padding: 26px 22px; }
.feature-card .ico { width: 46px; height: 46px; border-radius: 12px; background: var(--pw-primary-light); color: var(--pw-primary); display: flex; align-items: center; justify-content: center; font-size: 22px; margin-bottom: 14px; }
.feature-card h3 { font-size: 17px; margin-bottom: 6px; font-weight: 600; }
.feature-card p { color: var(--pw-muted); font-size: 13.5px; font-weight: 300; }

.landing-footer { text-align: center; padding: 28px; color: var(--pw-muted); font-size: 13px; border-top: 1px solid var(--pw-border); }

/* ===== App layout ===== */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; background: var(--pw-primary-dark); color: #fff; flex-shrink: 0;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .brand { padding: 22px 20px 16px; font-size: 20px; font-weight: 700; }
.sidebar .brand span { color: var(--pw-accent); }
.sidebar nav { flex: 1; padding: 6px 10px 20px; }
.sidebar nav button {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: none; border: none; color: rgba(255,255,255,.78); padding: 10px 12px;
  border-radius: 10px; cursor: pointer; font-family: inherit; font-size: 14.5px; margin-bottom: 2px;
}
.sidebar nav button:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar nav button.active { background: var(--pw-accent); color: #2B2410; font-weight: 600; }
.sidebar .side-foot { padding: 14px 20px; font-size: 11.5px; color: rgba(255,255,255,.45); }

/* auth area */
.auth-area { padding: 10px 14px; border-top: 1px solid rgba(255,255,255,.12); }
.auth-login {
  width: 100%; background: var(--pw-accent); color: #2B2410; border: none; border-radius: 10px;
  padding: 10px 12px; font-family: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
}
.auth-hint { font-size: 11px; color: rgba(255,255,255,.5); margin-top: 6px; line-height: 1.4; }
.auth-row { display: flex; align-items: center; gap: 10px; }
.auth-info { min-width: 0; }
.auth-name { font-size: 13.5px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.auth-sync { font-size: 11px; color: rgba(255,255,255,.55); }

.main { flex: 1; padding: 26px 30px 120px; max-width: 1100px; }
.page-title { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.page-sub { color: var(--pw-muted); font-weight: 300; margin-bottom: 22px; font-size: 14px; }

.card { background: var(--pw-card); border-radius: var(--pw-radius); box-shadow: var(--pw-shadow); padding: 22px; margin-bottom: 18px; }
.card h3 { font-size: 16.5px; font-weight: 600; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--pw-muted); margin-bottom: 4px; }
.field input, .field select {
  width: 100%; padding: 9px 12px; border: 1px solid var(--pw-border); border-radius: 9px;
  font-family: inherit; font-size: 14.5px; background: #fff; color: var(--pw-text);
}
.field input:focus, .field select:focus { outline: 2px solid var(--pw-primary-light); border-color: var(--pw-primary); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* stat tiles */
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-tile { background: var(--pw-card); border-radius: var(--pw-radius); box-shadow: var(--pw-shadow); padding: 16px 18px; }
.stat-tile .lbl { font-size: 12.5px; color: var(--pw-muted); }
.stat-tile .val { font-size: 22px; font-weight: 700; margin-top: 2px; }
.stat-tile .val.ok { color: var(--pw-ok); }
.stat-tile .val.bad { color: var(--pw-danger); }
.stat-tile .val.warn { color: var(--pw-warn); }
.stat-tile .hint { font-size: 11.5px; color: var(--pw-muted); margin-top: 2px; }

/* health score ring */
.score-wrap { display: flex; align-items: center; gap: 26px; flex-wrap: wrap; }
.score-ring { width: 140px; height: 140px; border-radius: 50%; display: flex; align-items: center; justify-content: center; position: relative; flex-shrink: 0; }
.score-ring .inner { width: 108px; height: 108px; border-radius: 50%; background: var(--pw-card); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.score-ring .num { font-size: 32px; font-weight: 700; line-height: 1; }
.score-ring .of { font-size: 11px; color: var(--pw-muted); }

.ratio-list { flex: 1; min-width: 260px; }
.ratio-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px dashed var(--pw-border); font-size: 14px; }
.ratio-item:last-child { border-bottom: none; }
.ratio-item .name { color: var(--pw-text); }
.ratio-item .bench { color: var(--pw-muted); font-size: 12px; }
.badge { padding: 2px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; }
.badge.ok { background: #D1FAE5; color: #065F46; }
.badge.warn { background: #FEF3C7; color: #92400E; }
.badge.bad { background: #FEE2E2; color: #991B1B; }

/* tables */
table.pw { width: 100%; border-collapse: collapse; font-size: 14px; }
table.pw th { text-align: left; padding: 8px 10px; background: var(--pw-primary-light); color: var(--pw-primary-dark); font-weight: 600; font-size: 13px; }
table.pw td { padding: 8px 10px; border-bottom: 1px solid var(--pw-border); }
table.pw td.num, table.pw th.num { text-align: right; font-variant-numeric: tabular-nums; }

.callout { border-left: 4px solid var(--pw-accent); background: var(--pw-accent-light); padding: 12px 16px; border-radius: 0 10px 10px 0; font-size: 13.5px; margin-top: 12px; }
.callout.green { border-color: var(--pw-ok); background: #ECFDF5; }
.callout.red { border-color: var(--pw-danger); background: #FEF2F2; }

.note { font-size: 12px; color: var(--pw-muted); margin-top: 10px; font-weight: 300; }

.btn-primary { background: var(--pw-primary); color: #fff; padding: 10px 22px; border-radius: 10px; font-size: 14.5px; }
.btn-ghost { background: #fff; color: var(--pw-primary); border: 1px solid var(--pw-primary); padding: 9px 20px; border-radius: 10px; font-size: 14px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }

canvas.chart { max-height: 280px; }

/* what-if sliders + monte carlo */
.slider-row { margin-bottom: 16px; }
.slider-row label { display: block; font-size: 13.5px; color: var(--pw-text); margin-bottom: 6px; }
.slider-row strong { color: var(--pw-primary); }
.slider-row input[type=range] {
  width: 100%; height: 6px; appearance: none; -webkit-appearance: none; background: var(--pw-border);
  border-radius: 999px; outline: none; cursor: pointer;
}
.slider-row input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%;
  background: var(--pw-primary); border: 3px solid #fff; box-shadow: 0 1px 6px rgba(0,0,0,.25);
}
.mc-prob-label { font-size: 13.5px; color: var(--pw-muted); margin-top: 8px; }
.mc-prob { font-size: 58px; font-weight: 700; line-height: 1.15; }
.mc-note { font-size: 13px; color: var(--pw-muted); max-width: 260px; margin: 0 auto; }

/* goals */
.goal-templates { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.goal-tpl {
  background: var(--pw-primary-light); color: var(--pw-primary-dark); border: none; border-radius: 999px;
  padding: 7px 14px; font-family: inherit; font-size: 13px; cursor: pointer;
}
.goal-tpl:hover { background: #D5E8E2; }
.goal-card { }
.goal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.goal-name { font-size: 16.5px; font-weight: 600; }
.goal-progress { background: #E5E7EB; border-radius: 999px; height: 14px; overflow: hidden; }
.goal-progress.sm { height: 8px; }
.goal-bar { height: 100%; background: linear-gradient(90deg, var(--pw-primary), var(--pw-accent)); border-radius: 999px; transition: width .3s; }
.goal-stats { display: flex; justify-content: space-between; font-size: 13.5px; color: var(--pw-muted); margin-top: 8px; }
.goal-need { font-size: 14px; margin-top: 8px; }
.goal-need strong { color: var(--pw-primary); }
.goal-actions { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.goal-topup { width: 140px; padding: 7px 10px; border: 1px solid var(--pw-border); border-radius: 9px; font-family: inherit; font-size: 13.5px; }
.goal-del { background: none; border: none; cursor: pointer; font-size: 16px; margin-left: auto; opacity: .55; }
.goal-del:hover { opacity: 1; }
.dash-goal { margin-bottom: 10px; }

/* slip dropzone */
.dropzone {
  display: flex; align-items: center; gap: 14px; padding: 22px 18px; cursor: pointer;
  border: 2px dashed var(--pw-primary); border-radius: 12px; background: var(--pw-primary-light);
  transition: background .15s; font-size: 14px; color: var(--pw-primary-dark);
}
.dropzone:hover { background: #D5E8E2; }
.dropzone .dz-icon { font-size: 34px; }
.dropzone .dz-hint { font-size: 12px; color: var(--pw-muted); }

/* ===== AI Chat ===== */
.chat-fab {
  position: fixed; right: 26px; bottom: 26px; width: 60px; height: 60px; border-radius: 50%;
  background: var(--pw-primary); color: #fff; border: none; cursor: pointer; font-size: 26px;
  box-shadow: 0 6px 24px rgba(9,63,52,.4); z-index: 60; transition: transform .15s;
}
.chat-fab:hover { transform: scale(1.06); }
.chat-panel {
  position: fixed; right: 26px; bottom: 100px; width: 390px; max-width: calc(100vw - 40px);
  height: 540px; max-height: calc(100vh - 140px); background: #fff; border-radius: 18px;
  box-shadow: 0 12px 48px rgba(0,0,0,.22); z-index: 61; display: none; flex-direction: column; overflow: hidden;
}
.chat-panel.open { display: flex; }
.chat-head { background: var(--pw-primary-dark); color: #fff; padding: 14px 18px; display: flex; align-items: center; gap: 10px; }
.chat-head .t { font-weight: 600; font-size: 15px; }
.chat-head .s { font-size: 11.5px; opacity: .75; font-weight: 300; }
.chat-head .close { margin-left: auto; background: none; border: none; color: #fff; font-size: 18px; cursor: pointer; }
.chat-body { flex: 1; overflow-y: auto; padding: 16px; background: #F7FAF9; }
.msg { max-width: 85%; padding: 10px 14px; border-radius: 14px; margin-bottom: 10px; font-size: 13.8px; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { background: var(--pw-primary); color: #fff; margin-left: auto; border-bottom-right-radius: 4px; }
.msg.ai { background: #fff; border: 1px solid var(--pw-border); border-bottom-left-radius: 4px; }
.msg.typing { color: var(--pw-muted); font-style: italic; background: #fff; border: 1px dashed var(--pw-border); }
.chat-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--pw-border); background: #fff; }
.chat-input textarea {
  flex: 1; resize: none; border: 1px solid var(--pw-border); border-radius: 10px; padding: 9px 12px;
  font-family: inherit; font-size: 13.8px; height: 42px; max-height: 100px;
}
.chat-input button { background: var(--pw-accent); border: none; border-radius: 10px; width: 46px; cursor: pointer; font-size: 17px; }
.chat-suggest { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 12px 10px; background: #fff; }
.chat-suggest button {
  background: var(--pw-primary-light); color: var(--pw-primary-dark); border: none; border-radius: 999px;
  padding: 5px 12px; font-size: 12px; cursor: pointer; font-family: inherit;
}

/* mobile */
@media (max-width: 760px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .sidebar nav { display: flex; overflow-x: auto; padding: 0 8px 10px; }
  .sidebar nav button { white-space: nowrap; width: auto; }
  .main { padding: 18px 14px 120px; }
}
