/* ── 本心 Tathata · invest.tathata.live ─────────────── */
:root {
  --gold:    #8C7558;
  --gold-l:  #C4A882;
  --gold-d:  #6B4F32;
  --cream:   #F7F3EC;
  --warm:    #EDE4D3;
  --night:   #18120C;
  --night-m: #2E2418;
  --night-l: #3D2B18;
  --text:    #2A1F14;
  --text-m:  #5C4A35;
  --text-mu: #9E8870;
  --serif:   'Noto Serif TC', serif;
  --sans:    'Noto Sans TC', sans-serif;
  --mono:    'JetBrains Mono', monospace;
  --r:       6px;
  --shadow:  0 2px 16px rgba(0,0,0,0.12);
}
*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { font-family: var(--sans); color: var(--text); background: var(--cream); line-height: 1.75; font-size: 15px; }
a { color: var(--gold-d); text-decoration: none; }
a:hover { color: var(--gold); }
img { max-width: 100%; }

/* ── Layout ─────────────────────────────────────────── */
.container { max-width: 980px; margin: 0 auto; padding: 0 1.5rem; }
.container-wide { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; }

/* ── Nav ────────────────────────────────────────────── */
.site-nav {
  background: var(--night); border-bottom: 1px solid var(--night-l);
  position: sticky; top: 0; z-index: 100;
  height: 54px; display: flex; align-items: center;
}
.nav-inner {
  width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 1.5rem;
  display: flex; align-items: center; justify-content: space-between;
}
.nav-brand {
  font-family: var(--serif); font-size: 1rem; color: var(--gold-l);
  letter-spacing: 0.12em; white-space: nowrap;
}
.nav-brand small { font-size: 0.72rem; color: rgba(196,168,130,0.45); margin-left: 0.5rem; }
.nav-right { display: flex; align-items: center; gap: 1rem; }
.nav-user { font-size: 0.8rem; color: rgba(196,168,130,0.55); }
.nav-user strong { color: var(--gold-l); }
.nav-badge {
  font-size: 0.65rem; padding: 0.15rem 0.6rem; border-radius: 99px;
  font-family: var(--mono); letter-spacing: 0.05em;
}
.badge-subscriber { background: rgba(139,117,88,0.25); color: var(--gold-l); }
.badge-investor    { background: rgba(31,107,31,0.25); color: #6BCF6B; }
.badge-admin       { background: rgba(192,57,43,0.25); color: #E87878; }
.btn-logout {
  font-size: 0.75rem; color: rgba(196,168,130,0.4); background: none;
  border: 1px solid rgba(139,117,88,0.2); padding: 0.3rem 0.75rem;
  border-radius: var(--r); cursor: pointer; transition: all 0.2s;
}
.btn-logout:hover { color: var(--gold-l); border-color: var(--gold); }

/* ── Hero ───────────────────────────────────────────── */
.hero {
  background: var(--night); padding: 5rem 1.5rem 4rem;
  position: relative; overflow: hidden;
}
.hero::before {
  content: '本心'; position: absolute; right: -0.05em; top: 50%;
  transform: translateY(-50%);
  font-family: var(--serif); font-size: clamp(10rem,20vw,20rem);
  font-weight: 700; color: rgba(139,117,88,0.05); line-height: 1; pointer-events: none;
}
.hero-inner { max-width: 780px; position: relative; }
.hero-eyebrow { font-size: 0.72rem; letter-spacing: 0.3em; color: var(--gold-l); margin-bottom: 1.25rem; }
.hero-title { font-family: var(--serif); font-size: clamp(2rem,4vw,3.5rem); font-weight: 300; color: #fff; line-height: 1.2; }
.hero-title em { font-style: normal; color: var(--gold-l); }
.hero-desc { color: rgba(255,255,255,0.5); margin-top: 1rem; font-size: 0.9rem; max-width: 480px; line-height: 1.8; }
.hero-actions { display: flex; gap: 0.75rem; margin-top: 2.5rem; flex-wrap: wrap; }

/* ── Buttons ────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.7rem 1.5rem; border-radius: var(--r);
  font-size: 0.88rem; font-family: var(--sans); font-weight: 500;
  cursor: pointer; transition: all 0.2s; border: none; text-decoration: none;
  white-space: nowrap;
}
.btn-primary   { background: var(--gold-d); color: #fff; }
.btn-primary:hover { background: var(--gold); color: #fff; }
.btn-ghost     { background: transparent; color: var(--gold-l); border: 1px solid rgba(196,168,130,0.35); }
.btn-ghost:hover { border-color: var(--gold-l); }
.btn-dark      { background: var(--night-m); color: var(--gold-l); border: 1px solid var(--night-l); }
.btn-dark:hover { background: var(--night-l); }
.btn-danger    { background: rgba(192,57,43,0.15); color: #E87878; border: 1px solid rgba(192,57,43,0.3); }
.btn-success   { background: rgba(31,107,31,0.15); color: #6BCF6B; border: 1px solid rgba(31,107,31,0.3); }
.btn-sm        { padding: 0.4rem 0.9rem; font-size: 0.78rem; }
.btn-full      { width: 100%; justify-content: center; }

/* ── Card ───────────────────────────────────────────── */
.card { background: var(--cream); border: 1px solid var(--warm); border-radius: var(--r); padding: 1.5rem; }
.card-dark { background: var(--night-m); border-color: var(--night-l); }

/* ── Section ────────────────────────────────────────── */
.sec { padding: 4rem 1.5rem; }
.sec-alt { background: #fff; }
.sec-inner { max-width: 980px; margin: 0 auto; }
.sec-tag { font-size: 0.7rem; letter-spacing: 0.3em; color: var(--gold); margin-bottom: 0.5rem; }
.sec-h { font-family: var(--serif); font-size: clamp(1.4rem,2.5vw,2rem); font-weight: 400; color: var(--text); margin-bottom: 0.5rem; }
.sec-h-dark { color: #fff; }
.sec-h em { font-style: normal; color: var(--gold); }
.rule { width: 2rem; height: 2px; background: var(--gold-l); margin: 1rem 0 2rem; }
.rule-dark { background: var(--gold); }

/* ── Forms ──────────────────────────────────────────── */
.form-wrap {
  max-width: 440px; margin: 3rem auto 0;
  background: var(--night-m); border-radius: var(--r);
  padding: 2rem; border: 1px solid var(--night-l);
}
.form-title { font-family: var(--serif); font-size: 1.2rem; color: var(--gold-l); margin-bottom: 0.25rem; }
.form-subtitle { font-size: 0.8rem; color: rgba(196,168,130,0.45); margin-bottom: 1.75rem; }
.form-group { margin-bottom: 1.25rem; }
.form-label { font-size: 0.8rem; color: rgba(196,168,130,0.65); display: block; margin-bottom: 0.4rem; }
.form-input, .form-select, .form-textarea {
  width: 100%; background: var(--night-l); border: 1px solid rgba(139,117,88,0.2);
  color: #fff; padding: 0.65rem 0.85rem; border-radius: 4px;
  font-size: 0.9rem; font-family: var(--sans);
  transition: border-color 0.2s; outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--gold); background: rgba(139,117,88,0.06);
}
.form-input::placeholder { color: rgba(196,168,130,0.3); }
.form-select option { background: var(--night); color: #fff; }
.form-textarea { min-height: 80px; resize: vertical; }
.form-hint { font-size: 0.75rem; color: rgba(196,168,130,0.35); margin-top: 0.3rem; }
.form-error { font-size: 0.78rem; color: #E87878; margin-top: 0.5rem; display: none; }
.form-error.show { display: block; }
.form-divider { text-align: center; font-size: 0.78rem; color: rgba(196,168,130,0.3); margin: 1rem 0; }
.phone-row { display: flex; gap: 0.5rem; }
.phone-prefix { background: var(--night-l); border: 1px solid rgba(139,117,88,0.2); color: var(--gold-l); padding: 0.65rem 0.75rem; border-radius: 4px; font-family: var(--mono); font-size: 0.9rem; white-space: nowrap; }

/* ── OTP Box ────────────────────────────────────────── */
.otp-section { display: none; }
.otp-section.show { display: block; }
.otp-hint { font-size: 0.8rem; color: rgba(196,168,130,0.5); margin-bottom: 1rem; }
#otp-input { text-align: center; letter-spacing: 0.4em; font-family: var(--mono); font-size: 1.4rem; }

/* ── Alert ──────────────────────────────────────────── */
.alert { padding: 0.85rem 1rem; border-radius: var(--r); font-size: 0.85rem; margin-bottom: 1rem; }
.alert-info    { background: rgba(139,117,88,0.12); color: var(--gold-l); border: 1px solid rgba(139,117,88,0.2); }
.alert-success { background: rgba(31,107,31,0.12); color: #6BCF6B; border: 1px solid rgba(31,107,31,0.2); }
.alert-error   { background: rgba(192,57,43,0.12); color: #E87878; border: 1px solid rgba(192,57,43,0.2); }

/* ── Tables ─────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.data-table th { background: var(--night); color: var(--gold-l); padding: 0.75rem 1rem; text-align: left; font-weight: 500; }
.data-table td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--warm); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(139,117,88,0.04); }

/* ── Chatbot Widget ──────────────────────────────────── */
.chat-widget {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 999;
}
.chat-toggle {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--gold-d); color: #fff; border: none;
  cursor: pointer; font-size: 1.3rem; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px rgba(107,79,50,0.5); transition: all 0.2s;
}
.chat-toggle:hover { background: var(--gold); transform: scale(1.05); }
.chat-box {
  display: none; position: absolute; bottom: 64px; right: 0;
  width: 340px; background: var(--night-m); border: 1px solid var(--night-l);
  border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden;
}
.chat-box.open { display: flex; flex-direction: column; }
.chat-header {
  padding: 0.9rem 1rem; background: var(--night);
  display: flex; align-items: center; justify-content: space-between;
}
.chat-header-name { font-family: var(--serif); font-size: 0.9rem; color: var(--gold-l); }
.chat-header-sub  { font-size: 0.7rem; color: rgba(196,168,130,0.4); }
.chat-close { background: none; border: none; color: rgba(196,168,130,0.4); cursor: pointer; font-size: 1rem; }
.chat-close:hover { color: var(--gold-l); }
.chat-messages { height: 320px; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: 0.75rem; }
.chat-msg { max-width: 85%; }
.chat-msg.user { align-self: flex-end; }
.chat-msg.assistant { align-self: flex-start; }
.chat-bubble {
  padding: 0.65rem 0.9rem; border-radius: var(--r); font-size: 0.83rem; line-height: 1.6;
}
.chat-msg.user .chat-bubble     { background: var(--gold-d); color: #fff; }
.chat-msg.assistant .chat-bubble{ background: var(--night-l); color: rgba(255,255,255,0.85); }
.chat-typing { opacity: 0.5; font-style: italic; font-size: 0.78rem; }
.chat-footer { padding: 0.75rem; border-top: 1px solid var(--night-l); display: flex; gap: 0.5rem; }
.chat-input {
  flex: 1; background: var(--night-l); border: 1px solid rgba(139,117,88,0.2);
  color: #fff; padding: 0.5rem 0.75rem; border-radius: 4px;
  font-size: 0.85rem; font-family: var(--sans); outline: none;
}
.chat-input:focus { border-color: var(--gold); }
.chat-send {
  background: var(--gold-d); color: #fff; border: none; border-radius: 4px;
  padding: 0.5rem 0.85rem; cursor: pointer; font-size: 0.85rem; transition: background 0.2s;
}
.chat-send:hover { background: var(--gold); }

/* ── Overview 財務摘要 ───────────────────────────────── */
.fin-summary { display: grid; grid-template-columns: repeat(3,1fr); gap: 1px; background: var(--warm); margin: 1.5rem 0; }
.fin-cell { background: var(--cream); padding: 1.25rem 1rem; text-align: center; }
.fin-cell-yr { font-family: var(--mono); font-size: 0.68rem; color: var(--text-mu); margin-bottom: 0.5rem; }
.fin-cell-n { font-family: var(--serif); font-size: 1.5rem; font-weight: 700; color: var(--gold-d); }
.fin-cell-l { font-size: 0.75rem; color: var(--text-mu); margin-top: 0.2rem; }
.fin-lock { text-align: center; padding: 2rem; background: rgba(139,117,88,0.06); border: 1px dashed rgba(139,117,88,0.3); border-radius: var(--r); }
.fin-lock-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.fin-lock-text { font-size: 0.88rem; color: var(--text-m); margin-bottom: 1rem; }

/* ── DataRoom 財務試算 ───────────────────────────────── */
.scenario-tabs { display: flex; gap: 0; margin: 1.5rem 0; }
.sc-tab {
  flex: 1; padding: 0.65rem; text-align: center; background: var(--night-m);
  color: rgba(196,168,130,0.4); border: 1px solid var(--night-l); border-right: none;
  cursor: pointer; font-size: 0.82rem; font-family: var(--sans); transition: all 0.2s;
}
.sc-tab:last-child { border-right: 1px solid var(--night-l); }
.sc-tab:hover { color: var(--gold-l); }
.sc-tab.active { background: var(--gold-d); color: #fff; border-color: var(--gold-d); }
.sc-tab.pessimistic.active { background: #7B2D26; border-color: #7B2D26; }
.sc-tab.optimistic.active  { background: #1F4B1F; border-color: #1F4B1F; }
.fin-layout { display: grid; grid-template-columns: 300px 1fr; gap: 1.5rem; align-items: start; }
.fin-panel { background: var(--night-m); border: 1px solid var(--night-l); border-radius: var(--r); overflow: hidden; }
.fin-panel-hdr { padding: 0.75rem 1rem; background: var(--night-l); font-family: var(--mono); font-size: 0.68rem; color: var(--gold-l); letter-spacing: 0.12em; }
.fin-group-hdr { padding: 0.65rem 1rem; background: rgba(139,117,88,0.08); font-size: 0.8rem; color: var(--gold-l); cursor: pointer; display: flex; justify-content: space-between; border-bottom: 1px solid rgba(139,117,88,0.1); }
.fin-group-hdr::after { content: '▾'; font-size: 0.65rem; color: var(--gold); }
.fin-group.collapsed .fin-group-hdr::after { content: '▸'; }
.fin-group.collapsed .fin-group-body { display: none; }
.fin-param { padding: 0.5rem 1rem; border-bottom: 1px solid rgba(139,117,88,0.05); }
.fin-param-lbl { font-size: 0.72rem; color: rgba(196,168,130,0.4); margin-bottom: 0.3rem; }
.fin-input-row { display: grid; grid-template-columns: repeat(3,1fr); gap: 3px; }
.yr-h { font-family: var(--mono); font-size: 0.6rem; color: rgba(139,117,88,0.35); text-align: center; margin-bottom: 2px; }
.fin-inp {
  width: 100%; background: var(--night-l); border: 1px solid rgba(139,117,88,0.15);
  color: var(--gold-l); font-family: var(--mono); font-size: 0.75rem;
  padding: 0.35rem 0.4rem; text-align: right; border-radius: 3px; outline: none;
}
.fin-inp:focus { border-color: var(--gold); background: rgba(139,117,88,0.08); }
.fin-inp-scalar { width: 100%; background: var(--night-l); border: 1px solid rgba(139,117,88,0.15); color: var(--gold-l); font-family: var(--mono); font-size: 0.75rem; padding: 0.35rem 0.4rem; text-align: right; border-radius: 3px; outline: none; }
.pl-yr-hdr { display: grid; grid-template-columns: 1.8fr repeat(3,1fr); gap: 0; padding: 0.5rem 1rem; border-bottom: 1px solid rgba(139,117,88,0.1); }
.pl-yr-lbl { font-family: var(--mono); font-size: 0.65rem; color: rgba(196,168,130,0.35); text-align: right; }
.pl-row { display: grid; grid-template-columns: 1.8fr repeat(3,1fr); padding: 0.45rem 1rem; border-bottom: 1px solid rgba(139,117,88,0.05); }
.pl-row:hover { background: rgba(139,117,88,0.03); }
.pl-row.total { background: rgba(139,117,88,0.1); border-top: 1px solid rgba(139,117,88,0.15); }
.pl-row.gp-row { background: rgba(139,117,88,0.12); }
.pl-row.ebitda { background: rgba(107,79,50,0.35); border-top: 1px solid var(--gold-d); }
.pl-row.net { background: rgba(107,79,50,0.5); }
.pl-lbl { font-size: 0.8rem; color: rgba(196,168,130,0.55); }
.pl-lbl.bold { color: rgba(255,255,255,0.85); font-weight: 500; }
.pl-lbl.indent { padding-left: 0.85rem; font-size: 0.75rem; color: rgba(196,168,130,0.38); }
.pl-val { font-family: var(--mono); font-size: 0.78rem; color: rgba(255,255,255,0.6); text-align: right; }
.pl-val.bold { color: #fff; font-weight: 500; }
.pl-val.pct  { color: var(--gold-l); font-size: 0.72rem; }
.pl-val.pos  { color: #6BCF6B; font-weight: 500; }
.pl-val.neg  { color: #E87878; font-weight: 500; }
.pl-sec-hdr  { padding: 0.4rem 1rem; font-size: 0.68rem; letter-spacing: 0.15em; color: var(--gold); background: rgba(139,117,88,0.05); }

/* ── Admin ──────────────────────────────────────────── */
.admin-wrap { max-width: 1100px; margin: 0 auto; padding: 2rem 1.5rem; }
.admin-nav { background: var(--night); padding: 0.75rem 1.5rem; display: flex; gap: 1.5rem; align-items: center; margin-bottom: 2rem; border-radius: var(--r); }
.admin-nav a { font-size: 0.85rem; color: rgba(196,168,130,0.55); }
.admin-nav a:hover, .admin-nav a.active { color: var(--gold-l); }
.admin-stats { display: grid; grid-template-columns: repeat(4,1fr); gap: 1rem; margin-bottom: 2rem; }
.stat-card { background: var(--night-m); border: 1px solid var(--night-l); border-radius: var(--r); padding: 1.25rem; text-align: center; }
.stat-n { font-family: var(--serif); font-size: 2rem; color: var(--gold-l); }
.stat-l { font-size: 0.75rem; color: rgba(196,168,130,0.4); margin-top: 0.25rem; }

/* ── Footer ──────────────────────────────────────────── */
.site-footer { background: var(--night); padding: 2rem 1.5rem; margin-top: 4rem; border-top: 1px solid var(--night-l); text-align: center; }
.site-footer p { font-size: 0.78rem; color: rgba(196,168,130,0.3); }
.site-footer strong { color: var(--gold-l); }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 768px) {
  .fin-layout { grid-template-columns: 1fr; }
  .admin-stats { grid-template-columns: repeat(2,1fr); }
  .fin-summary { grid-template-columns: 1fr; }
  .chat-box { width: 300px; }
  .hero-actions { flex-direction: column; }
  .btn-full-mobile { width: 100%; justify-content: center; }
}

/* ── Loading spinner ─────────────────────────────────── */
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.2); border-top-color: #fff; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
