/* ============================================================
   经营记账 · 前端设计系统 v1.0
   适用：430px 移动端 Web App（浅色主题）
   约定：收入/上涨 = 红，支出/下降 = 绿（中国股市惯例）
   ============================================================ */

/* ---------- 1. 设计令牌 ---------- */
:root{
  /* 品牌色：暖橙（餐饮生意的烟火气） */
  --brand-050:#FEF3EC;
  --brand-100:#FDE3D2;
  --brand-400:#F5824A;
  --brand-500:#F2662D;
  --brand-600:#E8541C;
  --brand-700:#C74312;
  --brand-grad:linear-gradient(135deg,#F2662D 0%,#F28A1B 100%);
  --brand-grad-soft:linear-gradient(135deg,#FEF3EC 0%,#FDF0DF 100%);

  /* 语义色：红涨绿跌 */
  --up-500:#E04A3A;   --up-050:#FDEEEC;   /* 收入 / 上涨 */
  --down-500:#0F9D63; --down-050:#E7F6EF; /* 支出 / 下降 */
  --warn-500:#D97706; --warn-050:#FDF3E3; /* 警告 */
  --info-500:#2563EB; --info-050:#EBF1FE; /* 提示 */

  /* 中性色 */
  --bg:#F7F5F2;
  --card:#FFFFFF;
  --ink-900:#1F2329;
  --ink-700:#41464F;
  --ink-500:#6B7280;
  --ink-400:#8A8F99;
  --ink-300:#B4B9C2;
  --line:#ECE9E4;

  /* 圆角 */
  --r-lg:20px; --r-md:14px; --r-sm:10px; --r-full:999px;

  /* 阴影 */
  --sh-card:0 2px 12px rgba(31,35,41,.05);
  --sh-pop:0 8px 28px rgba(31,35,41,.12);
  --sh-brand:0 6px 16px rgba(242,102,45,.32);

  --font:-apple-system,BlinkMacSystemFont,"PingFang SC","Hiragino Sans GB","Microsoft YaHei","Source Han Sans SC",sans-serif;
}

/* ---------- 2. 基础 ---------- */
*{margin:0;padding:0;box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html{font-size:16px}
body{
  font-family:var(--font);
  color:var(--ink-900);
  background:#EDEAE5;
  -webkit-font-smoothing:antialiased;
}
button{font-family:inherit;border:none;background:none;cursor:pointer;color:inherit}
input{font-family:inherit;border:none;outline:none;background:none;color:inherit}
ul,ol{list-style:none}
a{color:inherit;text-decoration:none}

/* 手机容器：桌面预览时居中显示 */
.app{
  max-width:430px;margin:0 auto;min-height:100vh;
  background:var(--bg);
  position:relative;
  box-shadow:0 0 40px rgba(31,35,41,.10);
}
.app-body{padding:16px 16px 110px}

/* ---------- 3. 字体层级 ---------- */
.num{font-variant-numeric:tabular-nums;letter-spacing:-.01em}
.t-display{font-size:34px;font-weight:700;line-height:1.15}
.t-h1{font-size:22px;font-weight:700}
.t-h2{font-size:18px;font-weight:600}
.t-title{font-size:16px;font-weight:600}
.t-body{font-size:14px;font-weight:400;color:var(--ink-700)}
.t-caption{font-size:12px;color:var(--ink-400)}
.t-up{color:var(--up-500)} .t-down{color:var(--down-500)}

/* ---------- 4. 按钮 ---------- */
.btn{
  display:inline-flex;align-items:center;justify-content:center;gap:6px;
  height:44px;padding:0 20px;border-radius:var(--r-full);
  font-size:15px;font-weight:600;transition:transform .08s ease,opacity .15s;
  user-select:none;
}
.btn:active{transform:scale(.97)}
.btn-primary{background:var(--brand-grad);color:#fff;box-shadow:var(--sh-brand)}
.btn-ghost{background:var(--brand-050);color:var(--brand-600)}
.btn-outline{background:#fff;border:1.5px solid var(--line);color:var(--ink-700)}
.btn-danger{background:var(--up-050);color:var(--up-500)}
.btn-block{width:100%}
.btn-sm{height:34px;padding:0 14px;font-size:13px}
.btn-lg{height:52px;font-size:16px}
.btn:disabled{opacity:.45;pointer-events:none}

/* 图标按钮 */
.icon-btn{
  width:38px;height:38px;border-radius:var(--r-full);
  display:inline-flex;align-items:center;justify-content:center;
  font-size:18px;background:rgba(255,255,255,.18);color:#fff;position:relative;
}
.icon-btn .dot{
  position:absolute;top:7px;right:8px;width:8px;height:8px;border-radius:50%;
  background:#FFDE59;border:1.5px solid rgba(255,255,255,.85);
}

/* ---------- 5. 徽标 / 标签 / 分段器 ---------- */
.badge{
  display:inline-flex;align-items:center;gap:4px;
  height:22px;padding:0 8px;border-radius:var(--r-full);
  font-size:11px;font-weight:600;
}
.badge-brand{background:var(--brand-050);color:var(--brand-600)}
.badge-up{background:var(--up-050);color:var(--up-500)}
.badge-down{background:var(--down-050);color:var(--down-500)}
.badge-warn{background:var(--warn-050);color:var(--warn-500)}
.badge-info{background:var(--info-050);color:var(--info-500)}
.badge-grey{background:#F0EDE8;color:var(--ink-500)}

.chip{
  display:inline-flex;align-items:center;gap:4px;
  height:36px;padding:0 14px;border-radius:var(--r-full);
  background:#F4F2EE;font-size:14px;color:var(--ink-700);
  border:1.5px solid transparent;transition:all .15s;
}
.chip.on{background:var(--brand-050);border-color:var(--brand-400);color:var(--brand-600);font-weight:600}

.seg{display:inline-flex;background:#F0EDE8;border-radius:var(--r-full);padding:3px;gap:2px}
.seg button{
  height:28px;padding:0 14px;border-radius:var(--r-full);
  font-size:13px;color:var(--ink-500);transition:all .15s;
}
.seg button.on{background:#fff;color:var(--ink-900);font-weight:600;box-shadow:0 1px 4px rgba(31,35,41,.10)}

/* ---------- 6. 卡片 ---------- */
.card{
  background:var(--card);border-radius:var(--r-lg);
  box-shadow:var(--sh-card);padding:16px;
}
.card + .card{margin-top:12px}
.section{
  display:flex;align-items:center;justify-content:space-between;
  margin:20px 2px 10px;
}
.section .t{font-size:16px;font-weight:700;display:flex;align-items:center;gap:6px}
.section .more{font-size:12px;color:var(--ink-400);display:flex;align-items:center;gap:2px}

/* 数据卡 */
.stat-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.stat-card{
  background:var(--card);border-radius:var(--r-md);box-shadow:var(--sh-card);
  padding:14px;
}
.stat-card .label{font-size:12px;color:var(--ink-400);margin-bottom:6px;display:flex;align-items:center;gap:4px}
.stat-card .value{font-size:20px;font-weight:700}
.stat-card .sub{font-size:11px;color:var(--ink-400);margin-top:4px}

/* ---------- 7. 预警条 ---------- */
.alert{
  display:flex;gap:10px;align-items:flex-start;
  padding:12px;border-radius:var(--r-md);
}
.alert .ic{
  width:32px;height:32px;border-radius:10px;flex-shrink:0;
  display:flex;align-items:center;justify-content:center;font-size:16px;
}
.alert .tt{font-size:14px;font-weight:600;line-height:1.35}
.alert .dd{font-size:12px;color:var(--ink-500);margin-top:2px;line-height:1.5}
.alert-p0{background:var(--up-050)}   .alert-p0 .ic{background:#fff;color:var(--up-500)}
.alert-warn{background:var(--warn-050)} .alert-warn .ic{background:#fff;color:var(--warn-500)}
.alert-good{background:var(--down-050)} .alert-good .ic{background:#fff;color:var(--down-500)}
.alert-info{background:var(--info-050)} .alert-info .ic{background:#fff;color:var(--info-500)}
.alert + .alert{margin-top:8px}

/* ---------- 8. 列表 ---------- */
.list{background:var(--card);border-radius:var(--r-lg);box-shadow:var(--sh-card);overflow:hidden}
.list-item{
  display:flex;align-items:center;gap:12px;padding:13px 16px;
}
.list-item + .list-item{border-top:1px solid var(--line)}
.list-item .ic{
  width:40px;height:40px;border-radius:12px;flex-shrink:0;
  display:flex;align-items:center;justify-content:center;font-size:19px;
  background:#F4F2EE;
}
.list-item .mid{flex:1;min-width:0}
.list-item .mid .t{font-size:14px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.list-item .mid .s{font-size:12px;color:var(--ink-400);margin-top:2px}
.list-item .amt{font-size:15px;font-weight:700;text-align:right}
.list-item .chev{color:var(--ink-300);font-size:16px;margin-left:2px}

/* ---------- 9. 图表 ---------- */
/* 环形图：JS 注入 conic-gradient */
.donut-wrap{display:flex;align-items:center;gap:18px}
.donut{
  width:128px;height:128px;border-radius:50%;flex-shrink:0;
  position:relative;display:flex;align-items:center;justify-content:center;
}
.donut::after{
  content:"";position:absolute;inset:18px;border-radius:50%;background:#fff;
}
.donut .center{position:relative;z-index:1;text-align:center}
.donut .center .v{font-size:19px;font-weight:700}
.donut .center .l{font-size:10px;color:var(--ink-400);margin-top:2px}
.legend{flex:1;min-width:0}
.legend-row{display:flex;align-items:center;gap:8px;padding:5px 0;font-size:13px}
.legend-row .sw{width:10px;height:10px;border-radius:3px;flex-shrink:0}
.legend-row .n{flex:1;color:var(--ink-700)}
.legend-row .p{font-weight:600;width:52px;text-align:right}
.legend-row .a{color:var(--ink-400);font-size:12px;width:64px;text-align:right}

/* 条形行 */
.bar-row{padding:8px 0}
.bar-row .hd{display:flex;justify-content:space-between;font-size:13px;margin-bottom:6px}
.bar-row .hd .p{font-weight:600}
.bar-track{height:8px;border-radius:var(--r-full);background:#F0EDE8;overflow:hidden;position:relative}
.bar-fill{height:100%;border-radius:var(--r-full);background:var(--brand-grad)}
.bar-track .mark{
  position:absolute;top:-2px;bottom:-2px;width:2px;background:var(--ink-900);opacity:.5;
}
.bar-note{font-size:11px;color:var(--ink-400);margin-top:5px}

/* 迷你柱状图 */
.mini-bars{display:flex;align-items:flex-end;gap:6px;height:56px}
.mini-bars .b{flex:1;border-radius:4px 4px 2px 2px;background:var(--brand-100)}
.mini-bars .b.hot{background:var(--brand-grad)}

/* ---------- 10. 表单 ---------- */
.field{margin-bottom:14px}
.field .lab{font-size:13px;color:var(--ink-500);margin-bottom:6px;font-weight:500}
.input{
  width:100%;height:46px;padding:0 14px;border-radius:var(--r-md);
  background:#F4F2EE;font-size:15px;transition:box-shadow .15s;
}
.input:focus{box-shadow:0 0 0 2px var(--brand-400);background:#fff}
.chips{display:flex;flex-wrap:wrap;gap:8px}

/* 金额大输入 */
.amount-input{display:flex;align-items:baseline;justify-content:center;gap:4px;padding:8px 0 4px}
.amount-input .cur{font-size:26px;font-weight:700;color:var(--ink-400)}
.amount-input input{
  width:220px;font-size:44px;font-weight:700;text-align:left;
  font-variant-numeric:tabular-nums;
}
.amount-input input::placeholder{color:var(--ink-300)}
.field-err{font-size:12px;color:var(--up-500);margin-top:6px;text-align:center;min-height:16px}

/* ---------- 11. 快捷操作 ---------- */
.quick-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:8px}
.quick{
  display:flex;flex-direction:column;align-items:center;gap:7px;padding:6px 0;
}
.quick .ic{
  width:48px;height:48px;border-radius:16px;
  display:flex;align-items:center;justify-content:center;font-size:22px;
  background:var(--brand-grad-soft);
}
.quick .n{font-size:12px;color:var(--ink-700);font-weight:500}
.quick:active .ic{transform:scale(.94)}

/* ---------- 12. 页面头部 ---------- */
.app-header{
  background:var(--brand-grad);
  border-radius:0 0 26px 26px;
  padding:max(18px,env(safe-area-inset-top)) 18px 64px;
  color:#fff;position:relative;overflow:hidden;
}
.app-header::before,.app-header::after{
  content:"";position:absolute;border-radius:50%;
  background:rgba(255,255,255,.10);pointer-events:none;
}
.app-header::before{width:190px;height:190px;right:-60px;top:-80px}
.app-header::after{width:120px;height:120px;left:-40px;bottom:-30px}
.hd-row{display:flex;align-items:center;gap:10px;position:relative;z-index:1}
.hd-avatar{
  width:42px;height:42px;border-radius:14px;flex-shrink:0;
  background:rgba(255,255,255,.22);
  display:flex;align-items:center;justify-content:center;font-size:21px;
}
.hd-meta{flex:1;min-width:0}
.hd-meta .name{font-size:16px;font-weight:700;display:flex;align-items:center;gap:6px}
.hd-meta .date{font-size:12px;opacity:.85;margin-top:2px}
.hd-actions{display:flex;gap:8px}

/* 头部核心数据卡（悬浮） */
.hero-card{
  margin:-48px 16px 0;position:relative;z-index:2;
  background:var(--card);border-radius:var(--r-lg);box-shadow:var(--sh-pop);
  padding:18px;
}
.hero-top{display:flex;align-items:center;justify-content:space-between;margin-bottom:4px}
.hero-label{font-size:13px;color:var(--ink-500);font-weight:500}
.hero-value{font-size:36px;font-weight:700;line-height:1.2}
.hero-delta{display:flex;align-items:center;gap:6px;margin-top:6px;font-size:12px;color:var(--ink-400)}
.hero-subs{
  display:grid;grid-template-columns:repeat(3,1fr);
  margin-top:14px;padding-top:14px;border-top:1px dashed var(--line);
}
.hero-subs .it{text-align:center}
.hero-subs .it + .it{border-left:1px solid var(--line)}
.hero-subs .v{font-size:16px;font-weight:700}
.hero-subs .l{font-size:11px;color:var(--ink-400);margin-top:3px}

/* ---------- 13. 底部导航 ---------- */
.tabbar{
  position:fixed;bottom:0;left:50%;transform:translateX(-50%);
  width:100%;max-width:430px;
  background:rgba(255,255,255,.96);backdrop-filter:blur(10px);
  border-top:1px solid var(--line);
  display:grid;grid-template-columns:repeat(5,1fr);
  padding:6px 0 calc(10px + env(safe-area-inset-bottom));
  z-index:40;
}
.tab{
  display:flex;flex-direction:column;align-items:center;gap:3px;
  font-size:10px;color:var(--ink-400);padding:4px 0;
}
.tab .ic{font-size:21px;line-height:1}
.tab.on{color:var(--brand-600);font-weight:600}
.tab-add{
  display:flex;align-items:center;justify-content:center;
}
.tab-add .plus{
  width:48px;height:48px;border-radius:50%;margin-top:-22px;
  background:var(--brand-grad);color:#fff;font-size:26px;font-weight:400;
  display:flex;align-items:center;justify-content:center;
  box-shadow:var(--sh-brand);border:4px solid #fff;
}

/* ---------- 14. 底部弹层 ---------- */
.sheet-mask{
  position:fixed;inset:0;background:rgba(31,35,41,.45);
  opacity:0;pointer-events:none;transition:opacity .25s;z-index:50;
}
.sheet-mask.open{opacity:1;pointer-events:auto}
.sheet{
  position:fixed;bottom:0;left:50%;transform:translate(-50%,105%);
  width:100%;max-width:430px;
  background:#fff;border-radius:24px 24px 0 0;
  padding:14px 18px calc(20px + env(safe-area-inset-bottom));
  transition:transform .3s cubic-bezier(.32,.72,.35,1);
  z-index:51;max-height:88vh;overflow-y:auto;
}
.sheet.open{transform:translate(-50%,0)}
.sheet .grab{width:40px;height:4px;border-radius:2px;background:var(--line);margin:0 auto 12px}
.sheet .sheet-title{font-size:17px;font-weight:700;text-align:center;margin-bottom:14px}

/* ---------- 15. Toast ---------- */
.toast{
  position:fixed;left:50%;bottom:120px;transform:translate(-50%,20px);
  background:rgba(31,35,41,.92);color:#fff;
  padding:10px 18px;border-radius:var(--r-full);font-size:13px;
  opacity:0;pointer-events:none;transition:all .25s;z-index:300;
  display:flex;align-items:center;gap:6px;max-width:80%;
}
.toast.show{opacity:1;transform:translate(-50%,0)}
.toast.err{background:rgba(200,50,40,.95)}

/* ---------- 16. 空状态 ---------- */
.empty{
  display:flex;flex-direction:column;align-items:center;gap:10px;
  padding:36px 0;color:var(--ink-300);
}
.empty .ic{font-size:44px;opacity:.6}
.empty .t{font-size:13px;color:var(--ink-400)}

/* ---------- 17. AI 入口卡 ---------- */
.ai-card{
  background:linear-gradient(120deg,#2B2F36 0%,#3D3A34 100%);
  border-radius:var(--r-lg);padding:16px;color:#fff;
  display:flex;align-items:center;gap:12px;box-shadow:var(--sh-card);
}
.ai-card .orb{
  width:40px;height:40px;border-radius:50%;flex-shrink:0;
  background:conic-gradient(#F2A61B,#F2662D,#E04A8A,#8B5CF6,#F2A61B);
  animation:spin 6s linear infinite;
  display:flex;align-items:center;justify-content:center;
}
.ai-card .orb::after{content:"";width:34px;height:34px;border-radius:50%;background:#2B2F36}
@keyframes spin{to{transform:rotate(360deg)}}
.ai-card .tt{font-size:14px;font-weight:600}
.ai-card .dd{font-size:12px;color:rgba(255,255,255,.65);margin-top:3px}

/* 骨架屏 */
.skel{border-radius:8px;background:linear-gradient(90deg,#F0EDE8 25%,#F8F6F3 50%,#F0EDE8 75%);background-size:200% 100%;animation:skel 1.2s infinite}
@keyframes skel{to{background-position:-200% 0}}

/* ---------- 18. iOS 风格 SVG 图标 ---------- */
.isvg{width:1em;height:1em;display:inline-block;vertical-align:-.1em;flex-shrink:0}
.hd-avatar .isvg{width:22px;height:22px}
.icon-btn .isvg{width:19px;height:19px}
.section .t .isvg{width:17px;height:17px;color:var(--brand-500)}
.tab .isvg{width:23px;height:23px}
.tab-add .plus .isvg{width:24px;height:24px}
.quick .ic .isvg{width:23px;height:23px;color:var(--brand-600)}
.alert .ic .isvg{width:17px;height:17px}
.list-item .ic .isvg{width:20px;height:20px}
.chip .isvg{width:15px;height:15px;vertical-align:-.15em}
.stat-card .label .isvg{width:13px;height:13px}
.chev .isvg{width:14px;height:14px}
.empty .isvg{width:46px;height:46px;color:var(--ink-300)}
.toast .isvg{width:15px;height:15px;vertical-align:-.2em}

/* AI 光环内嵌图标 */
.ai-card .orb{position:relative}
.ai-card .orb::after{content:"";position:absolute;inset:3px;border-radius:50%;background:#2B2F36}
.ai-card .orb .isvg{position:relative;z-index:1;width:17px;height:17px;color:#fff}

/* 图标着色块（iOS 设置风：彩色底 + 彩色 glyph） */
.ic-green{background:var(--down-050)!important;color:var(--down-500)}
.ic-orange{background:var(--brand-050)!important;color:var(--brand-600)}
.ic-blue{background:var(--info-050)!important;color:var(--info-500)}
.ic-purple{background:#F1EBFD!important;color:#8B5CF6}
.ic-amber{background:var(--warn-050)!important;color:var(--warn-500)}
.ic-grey{background:#F0EDE8!important;color:var(--ink-500)}
