/* =========================================================
   森林执行力工作台 · 极简淡绿森林风
   ========================================================= */
:root {
  --bg: #EEF4EC;
  --bg-2: #E4EEE0;
  --panel: #FFFFFF;
  --forest: #3E7B57;        /* 主深绿 */
  --forest-d: #2F5E43;
  --leaf: #7FB069;          /* 嫩叶绿 */
  --leaf-soft: #DCEAD6;
  --mint: #BFE3C8;
  --ink: #26352B;           /* 主文字（深墨绿） */
  --ink-soft: #6A7B6E;
  --line: #E1EBDD;
  --warn: #C97A3A;          /* 大餐/警示 暖棕 */
  --warn-soft: #F6E6D6;
  --up: #D8463B;            /* 涨=红（中国习惯） */
  --down: #2E9E5B;          /* 跌=绿 */
  --shadow: 0 6px 22px rgba(46, 94, 67, 0.10);
  --shadow-sm: 0 2px 8px rgba(46, 94, 67, 0.08);
  --tap: 46px;              /* iPhone 触控最小尺寸 */
  --radius: 18px;
  --radius-sm: 12px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
.hidden { display: none !important; }
.muted { color: var(--ink-soft); font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.col { display: flex; flex-direction: column; }
.center { justify-content: center; align-items: center; }

/* ---------- 启动页 ---------- */
.boot {
  position: fixed; inset: 0; z-index: 50;
  background: linear-gradient(160deg, #F2F7EF, #DCEAD6);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  transition: opacity .4s;
}
.boot.hidden { opacity: 0; pointer-events: none; }
.boot-leaf { font-size: 54px; animation: sway 2.4s ease-in-out infinite; }
@keyframes sway { 0%,100%{transform:rotate(-8deg)} 50%{transform:rotate(8deg)} }
.boot-text { color: var(--forest-d); font-weight: 600; letter-spacing: .5px; }

/* ---------- 布局 ---------- */
.app { display: flex; height: 100%; }
.scrim { display: none; position: fixed; inset: 0; background: rgba(38,53,43,.35); z-index: 30; backdrop-filter: blur(1px); }
.scrim.show { display: block; }

/* ---------- 侧边栏 ---------- */
.sidebar {
  width: 248px; flex: 0 0 248px; background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: calc(14px + var(--safe-t)) 12px calc(12px + var(--safe-b));
  z-index: 40; transition: transform .28s ease;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 14px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { font-size: 26px; }
.brand-text strong { display: block; font-size: 15px; color: var(--forest-d); }
.brand-text small { font-size: 11px; color: var(--ink-soft); }
.sidebar-close { display: none; }

.nav { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; padding-right: 2px; }
.nav-item { border-radius: var(--radius-sm); }
.nav-link {
  width: 100%; min-height: var(--tap); display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border: none; background: transparent; color: var(--ink);
  font-size: 15px; font-weight: 600; cursor: pointer; border-radius: var(--radius-sm);
  text-align: left; transition: background .15s, color .15s;
}
.nav-link:active { background: var(--leaf-soft); }
.nav-item.active > .nav-link { background: var(--forest); color: #fff; }
.ni-ico { font-size: 20px; width: 24px; text-align: center; }
.ni-arrow { margin-left: auto; font-size: 10px; color: var(--ink-soft); transition: transform .2s; }
.nav-item.open > .nav-link .ni-arrow { transform: rotate(90deg); }
.nav-item.active > .nav-link .ni-arrow { color: rgba(255,255,255,.8); }
.subnav { display: none; padding: 2px 0 4px 36px; flex-direction: column; gap: 2px; }
.nav-item.open > .subnav { display: flex; }
.sub-link {
  min-height: 40px; text-align: left; border: none; background: transparent; cursor: pointer;
  color: var(--ink-soft); font-size: 13.5px; padding: 8px 12px; border-radius: 10px;
}
.sub-link:active { background: var(--leaf-soft); }
.sub-link.active { color: var(--forest-d); font-weight: 700; background: var(--leaf-soft); }

.sidebar-foot { padding-top: 10px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.sync-state { font-size: 11.5px; color: var(--ink-soft); }
.ghost-btn { min-height: 40px; border: 1px solid var(--line); background: var(--bg); color: var(--forest-d); border-radius: 12px; font-size: 13px; cursor: pointer; font-weight: 600; }
.ghost-btn:active { background: var(--leaf-soft); }

/* ---------- 主区域 ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.topbar {
  display: flex; align-items: center; gap: 10px; padding: calc(10px + var(--safe-t)) 14px 10px;
  background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10;
}
.icon-btn {
  min-width: var(--tap); min-height: var(--tap); border: none; background: transparent;
  font-size: 20px; color: var(--forest-d); cursor: pointer; border-radius: 12px;
}
.icon-btn:active { background: var(--leaf-soft); }
.crumb { font-size: 16px; font-weight: 700; color: var(--forest-d); flex: 1; }
.topbar-actions { display: flex; gap: 2px; }
.view { flex: 1; overflow-y: auto; padding: 16px 14px calc(28px + var(--safe-b)); -webkit-overflow-scrolling: touch; }

/* ---------- 卡片 ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm); margin-bottom: 14px; }
.card.tap { cursor: pointer; transition: transform .12s, box-shadow .12s; }
.card.tap:active { transform: scale(.985); box-shadow: var(--shadow); }
.card h3 { margin: 0 0 10px; font-size: 15px; color: var(--forest-d); }
.card .sub { font-size: 12.5px; color: var(--ink-soft); margin: -6px 0 10px; }

/* ---------- 进度环 / 条 ---------- */
.ring { position: relative; display: inline-flex; align-items: center; justify-content: center; }
.ring svg { transform: rotate(-90deg); }
.ring-num { position: absolute; font-size: 14px; font-weight: 800; color: var(--forest-d); }
.ring-sm .ring-num { font-size: 11px; }
.bar { height: 10px; background: var(--leaf-soft); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--leaf), var(--forest)); border-radius: 99px; transition: width .4s; }
.bar.warn > i { background: linear-gradient(90deg, #E8B07A, var(--warn)); }

/* ---------- 按钮 ---------- */
.btn {
  min-height: var(--tap); padding: 0 18px; border: none; border-radius: 14px;
  background: var(--forest); color: #fff; font-size: 14.5px; font-weight: 700; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  box-shadow: var(--shadow-sm); transition: transform .1s, filter .1s;
}
.btn:active { transform: scale(.96); filter: brightness(.96); }
.btn.block { width: 100%; }
.btn.soft { background: var(--leaf-soft); color: var(--forest-d); box-shadow: none; }
.btn.ghost { background: var(--bg); color: var(--forest-d); border: 1px solid var(--line); box-shadow: none; }
.btn.sm { min-height: 38px; padding: 0 13px; font-size: 13px; border-radius: 11px; }
.btn.danger { background: #E7C3B0; color: #9A4B2C; box-shadow: none; }

/* ---------- 表单 ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
input, textarea, select {
  font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line);
  border-radius: 12px; padding: 11px 12px; min-height: var(--tap); width: 100%; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--leaf); background: #fff; }
textarea { resize: vertical; min-height: 84px; }

/* ---------- 吐司 ---------- */
.toast-root { position: fixed; left: 50%; bottom: calc(28px + var(--safe-b)); transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--forest-d); color: #fff; padding: 10px 16px; border-radius: 14px; font-size: 13.5px; display: flex; align-items: center; gap: 8px; box-shadow: var(--shadow); animation: pop .25s ease; }
@keyframes pop { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- 弹窗 ---------- */
.modal-root { position: fixed; inset: 0; z-index: 70; display: none; }
.modal-root.show { display: block; }
.modal-mask { position: absolute; inset: 0; background: rgba(38,53,43,.4); }
.modal { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); width: min(92vw, 460px); max-height: 84vh; overflow-y: auto; background: var(--panel); border-radius: 22px; padding: 20px; box-shadow: var(--shadow); }
.modal h3 { margin: 0 0 14px; font-size: 17px; color: var(--forest-d); }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-actions .btn { flex: 1; }

/* ---------- 空态 ---------- */
.empty { text-align: center; color: var(--ink-soft); padding: 36px 10px; }
.empty .emo { font-size: 42px; margin-bottom: 8px; }

/* ---------- 板块 landing（点击板块先展示子模块） ---------- */
.landing-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.landing-title { font-size: 22px; font-weight: 800; color: var(--forest-d); }
.landing-sub { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
.sub-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sub-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; cursor: pointer; box-shadow: var(--shadow-sm); transition: transform .12s; }
.sub-card:active { transform: scale(.97); }
.sub-card .ico { font-size: 30px; }
.sub-card .ttl { font-weight: 700; color: var(--forest-d); margin: 8px 0 2px; font-size: 15px; }
.sub-card .dsc { font-size: 12px; color: var(--ink-soft); }

/* ---------- 通用小组件 ---------- */
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 4px 10px; border-radius: 99px; background: var(--leaf-soft); color: var(--forest-d); font-weight: 600; }
.pill.dot { background: var(--bg-2); }
.checkrow { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.checkrow:last-child { border-bottom: none; }
.cbx { width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--leaf); flex: 0 0 26px; display: flex; align-items: center; justify-content: center; font-size: 16px; color: #fff; cursor: pointer; transition: background .15s; }
.cbx.on { background: var(--forest); border-color: var(--forest); }
.stat-row { display: flex; gap: 10px; flex-wrap: wrap; }
.stat { flex: 1; min-width: 90px; background: var(--bg-2); border-radius: 14px; padding: 12px; text-align: center; }
.stat b { font-size: 20px; color: var(--forest-d); display: block; }
.stat span { font-size: 11.5px; color: var(--ink-soft); }
.leaf-badge { display:inline-flex; align-items:center; gap:4px; font-size:11px; color:var(--leaf); font-weight:700; }
.divider { height: 1px; background: var(--line); margin: 14px 0; }

/* ---------- 周日历（运动拖拽） ---------- */
.week-cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.wd { border: 1px dashed var(--line); border-radius: 12px; min-height: 92px; padding: 6px; background: var(--bg); transition: background .12s, border-color .12s; }
.wd.dragover { background: var(--leaf-soft); border-color: var(--leaf); }
.wd .wd-h { font-size: 11px; color: var(--ink-soft); font-weight: 700; text-align: center; margin-bottom: 4px; }
.wd.today .wd-h { color: var(--forest); }
.pill-part { display: block; background: var(--panel); border: 1px solid var(--leaf); color: var(--forest-d); border-radius: 9px; font-size: 11.5px; padding: 4px 6px; margin-bottom: 4px; cursor: grab; text-align: center; }
.pill-part.done { background: var(--leaf-soft); color: var(--ink-soft); text-decoration: line-through; border-color: var(--line); }
.pill-part:active { cursor: grabbing; }

/* ---------- 列表/记录 ---------- */
.rec-item { display: flex; align-items: flex-start; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.rec-item:last-child { border-bottom: none; }
.rec-item .body { flex: 1; min-width: 0; }
.rec-item .ttl { font-weight: 600; }
.rec-item .meta { font-size: 12px; color: var(--ink-soft); }
.rec-del { color: #C97A6A; font-size: 18px; min-width: 36px; min-height: 36px; }
.chip { display:inline-block; font-size:11px; padding:2px 8px; border-radius:8px; background:var(--bg-2); color:var(--ink-soft); margin-right:4px; }

/* ---------- 行情面板 ---------- */
.quote-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quote { background: var(--bg-2); border-radius: 14px; padding: 12px; }
.quote .nm { font-size: 12.5px; color: var(--ink-soft); }
.quote .pr { font-size: 18px; font-weight: 800; margin-top: 2px; }
.quote .cg { font-size: 12.5px; font-weight: 700; }
.up { color: var(--up); }
.down { color: var(--down); }
.sec-title { display:flex; align-items:center; gap:8px; font-size:13px; font-weight:700; color:var(--forest-d); margin:14px 0 8px; }

/* ---------- AI 助手 ---------- */
.ai-msgs { min-height: 260px; max-height: 56vh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 6px 2px; margin: 10px 0; }
.ai-welcome { text-align: center; color: var(--ink-soft); padding: 26px 10px; }
.ai-bubble { max-width: 86%; padding: 10px 13px; border-radius: 16px; line-height: 1.6; font-size: 14px; word-break: break-word; white-space: pre-wrap; }
.ai-bubble.bot { align-self: flex-start; background: var(--bg-2); color: var(--ink); border-bottom-left-radius: 4px; }
.ai-bubble.me { align-self: flex-end; background: var(--forest); color: #fff; border-bottom-right-radius: 4px; }
.ai-input { display: flex; gap: 8px; align-items: flex-end; }
.ai-input textarea { flex: 1; resize: none; min-height: 44px; max-height: 120px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 14px; font: inherit; background: #fff; }
.ai-help { margin-top: 6px; padding: 12px; background: var(--bg-2); border-radius: 14px; font-size: 13px; }
.ai-help h4 { color: var(--forest-d); margin: 8px 0 4px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); margin-bottom: 5px; }
.field input { width: 100%; padding: 11px 12px; min-height: 44px; border: 1px solid var(--line); border-radius: 12px; font: inherit; background: #fff; box-sizing: border-box; }

/* ---------- 今日总览 ---------- */
.ov-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.ov-card { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow-sm); cursor: pointer; transition: transform .12s; }
.ov-card:active { transform: scale(.98); }
.ov-ico { font-size: 26px; }
.ov-body { flex: 1; min-width: 0; }
.ov-name { font-weight: 700; color: var(--forest-d); font-size: 14px; }
.ov-sub { font-size: 11.5px; color: var(--ink-soft); margin: 2px 0 6px; }
.ov-ring { flex: 0 0 auto; }
.stamp { display: inline-flex; align-items: center; padding: 4px 10px; border: 2px solid var(--leaf); color: var(--forest); border-radius: 99px; font-size: 12px; font-weight: 800; transform: rotate(-6deg); }

/* ---------- 拖拽幽灵（iPhone 触屏拖拽） ---------- */
.drag-ghost { position: fixed; z-index: 90; pointer-events: none; transform: translate(-50%, -50%); background: var(--forest); color: #fff; border-radius: 10px; padding: 6px 12px; font-size: 13px; font-weight: 700; box-shadow: var(--shadow); opacity: .92; }
.part-pool { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0; }
.pill-part.pool { cursor: grab; }
.pill-part.pool:active { cursor: grabbing; }

/* ---------- 财经日历 ---------- */
.fin-cal { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; -webkit-overflow-scrolling: touch; }
.fin-day { flex: 0 0 84px; background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 8px; }
.fin-day.today { background: var(--leaf-soft); border-color: var(--leaf); }
.fin-dow { font-size: 11px; color: var(--ink-soft); font-weight: 700; }
.fin-date { font-size: 20px; font-weight: 800; color: var(--forest-d); line-height: 1.2; }
.fin-evs { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; }
.fin-ev { font-size: 10.5px; line-height: 1.3; color: var(--forest-d); background: #fff; border-radius: 6px; padding: 3px 5px; border: 1px solid var(--line); }
.fin-ev.muted { color: var(--ink-soft); background: transparent; border: none; }

/* ---------- 媒体查询：窄屏折叠侧栏 ---------- */
@media (max-width: 820px) {
  .sidebar { position: fixed; top: 0; bottom: 0; left: 0; transform: translateX(-100%); box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: inline-flex; }
  .sub-grid { grid-template-columns: 1fr; }
  .ov-grid { grid-template-columns: 1fr; }
  .quote-grid { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 821px) {
  #menuBtn { display: none; }
}
