/*
 * 报单记账系统 · 全站样式（唯一的一份）
 *
 * 长相定下来的几条（段二做页面照这个来，⛔ 别在页面里另起一套）：
 * - 手机优先：一栏卡片，⛔ 不做左侧菜单、⛔ 不做大表格网格 —— 跟礼礼（伙伴云那种左栏＋表格）整体明显不一样（红线：最高法 279 号）
 * - 底色米白纸，主色墨绿（"对上了"就是这个颜色）；红＝不平/驳回，黄＝在等，灰＝作废。⛔ 不用蓝色当主色
 * - 金额一律等宽数字（.money）；按钮、输入框至少 44px 高，手指点得准
 * - 手机上导航在底部；宽屏（≥900px）挪到顶上
 */
:root {
  --bg: #f4f2ed;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --ink: #1d211f;
  --ink-2: #535a55;
  --ink-3: #868c87;
  --line: #e2dfd7;
  --accent: #1d6b52;
  --accent-2: #155a44;
  --accent-soft: #e2f0e9;
  --red: #b3372b;
  --red-soft: #fbe8e5;
  --amber: #9a620f;
  --amber-soft: #fcf1da;
  --green: #1d6b52;
  --green-soft: #e2f0e9;
  --gray-soft: #eeece7;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(29, 33, 31, .05), 0 6px 18px rgba(29, 33, 31, .05);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Segoe UI", sans-serif;
  --tabbar-h: 58px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 var(--font);
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}
body.bare { padding-bottom: 0; }
a { color: var(--accent); }
img { max-width: 100%; }
[hidden] { display: none !important; }

/* ---- 顶栏 ---- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(244, 242, 237, .94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { max-width: 960px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 10px; min-height: 52px; }
.brand { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand .sep { color: var(--ink-3); font-weight: 400; margin: 0 6px; }
.whoami { margin-left: auto; font-size: 13px; color: var(--ink-2); white-space: nowrap; }

/* ---- 导航：手机在底部，宽屏在顶上 ---- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1; min-height: var(--tabbar-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--ink-3); text-decoration: none; font-size: 13px; position: relative;
}
.tabbar a .dot { width: 6px; height: 6px; border-radius: 50%; background: transparent; }
.tabbar a.on { color: var(--accent); font-weight: 700; }
.tabbar a.on .dot { background: var(--accent); }
.tabbar a .badge { position: absolute; top: 6px; left: calc(50% + 10px); }
@media (min-width: 900px) {
  body { padding-bottom: 0; }
  .tabbar { position: sticky; top: 53px; bottom: auto; justify-content: center; border-top: 0; border-bottom: 1px solid var(--line); background: var(--surface-2); }
  .tabbar a { flex: 0 0 auto; min-height: 46px; padding: 0 20px; flex-direction: row; font-size: 15px; }
  .tabbar a .dot { display: none; }
  .tabbar a.on { box-shadow: inset 0 -3px 0 var(--accent); }
  .tabbar a .badge { position: static; margin-left: 6px; }
}

/* ---- 页面 ---- */
.page { max-width: 960px; margin: 0 auto; padding: 16px; }
.page-title { font-size: 22px; line-height: 1.3; margin: 4px 0 14px; }
.page-sub { color: var(--ink-2); margin: -8px 0 16px; font-size: 14px; }
.section-title { font-size: 15px; color: var(--ink-2); margin: 20px 0 10px; font-weight: 700; }

/* ---- 卡片 / 列表 ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow); }
.card > h2, .card-title { font-size: 17px; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
a.card { display: block; color: inherit; text-decoration: none; }
a.card:hover { border-color: #cfcabe; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid-2 { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }

.stat .num { font-size: 28px; font-weight: 800; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat .num.small { font-size: 20px; }
.stat .label { color: var(--ink-2); font-size: 14px; }
.stat .foot { color: var(--ink-3); font-size: 13px; margin-top: 4px; }

.list { display: flex; flex-direction: column; gap: 10px; }
.item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; }
.item.clickable { cursor: pointer; }
.item.clickable:hover { border-color: #cfcabe; }
.item-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.item-title { font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.item-sub { color: var(--ink-2); font-size: 14px; margin-top: 2px; }
.item-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spacer { flex: 1; }
.right { margin-left: auto; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 700; }
.money.neg { color: var(--red); }
.money.big { font-size: 22px; }

/* ---- 按钮 ---- */
.btn {
  appearance: none; font: inherit; font-weight: 700; cursor: pointer;
  min-height: 44px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none;
  transition: background .15s ease, border-color .15s ease;
}
.btn:hover { border-color: #cfcabe; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-danger { color: var(--red); border-color: #ebc7c1; }
.btn-danger.solid { background: var(--red); border-color: var(--red); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--accent); }
.btn-small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn-block { width: 100%; }
.btn[disabled], .btn.busy { opacity: .55; cursor: not-allowed; }

/* ---- 表单 ---- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label, .field > .label { font-size: 14px; color: var(--ink-2); font-weight: 700; }
.field .must { color: var(--red); font-weight: 700; font-size: 12px; margin-left: 4px; }
.hint { font-size: 13px; color: var(--ink-3); }
input, select, textarea {
  font: inherit; color: var(--ink); background: #fff;
  min-height: 44px; width: 100%; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 10px;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible {
  outline: 3px solid var(--accent-soft); outline-offset: 1px; border-color: var(--accent);
}
input[type="file"] { padding: 10px; background: var(--surface-2); }
/* 勾选框：上面那条把所有 input 撑成整行宽、44 高 —— 勾选框放进一行字旁边时会占掉整列、把字挤成一个字一行 */
input[type="checkbox"], input[type="radio"] {
  width: 22px; height: 22px; min-height: 22px; padding: 0; margin: 0; flex: 0 0 auto; accent-color: var(--accent);
}
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.error-text { color: var(--red); font-size: 14px; }

/* 分段选择（筛选状态用） */
.seg { display: inline-flex; background: var(--gray-soft); border-radius: 12px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { appearance: none; border: 0; background: transparent; font: inherit; font-size: 14px; font-weight: 700; color: var(--ink-2); min-height: 36px; padding: 0 12px; border-radius: 9px; cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar input[type="search"] { flex: 1; min-width: 160px; }

/* ---- 标签 / 提示条 ---- */
.tag { display: inline-flex; align-items: center; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; line-height: 1.7; white-space: nowrap; }
.tag-green { background: var(--green-soft); color: var(--green); }
.tag-red { background: var(--red-soft); color: var(--red); }
.tag-amber { background: var(--amber-soft); color: var(--amber); }
.tag-gray { background: var(--gray-soft); color: var(--ink-2); }
.badge { display: inline-flex; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--red); color: #fff; font-size: 11px; font-weight: 800; align-items: center; justify-content: center; }

.notice { border-radius: var(--radius-sm); padding: 12px 14px; font-size: 14px; margin-bottom: 12px; line-height: 1.6; }
.notice-green { background: var(--green-soft); color: #14513d; }
.notice-red { background: var(--red-soft); color: #7d241b; }
.notice-amber { background: var(--amber-soft); color: #6b4608; }
.notice-gray { background: var(--gray-soft); color: var(--ink-2); }

/* ---- 键值 ---- */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 15px; margin: 0; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ---- 图 ---- */
.thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: var(--gray-soft); cursor: zoom-in; }
.photo-view { max-width: 100%; max-height: 75vh; display: block; margin: 0 auto; border-radius: 8px; }

/* ---- 弹窗（手机从底下升起来，宽屏居中） ---- */
.modal-back { position: fixed; inset: 0; z-index: 50; background: rgba(20, 24, 22, .45); display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--surface); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 18px 16px calc(16px + env(safe-area-inset-bottom)); }
.modal h3 { margin: 0 0 12px; font-size: 18px; overflow-wrap: anywhere; }
.modal .modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
@media (min-width: 640px) {
  .modal-back { align-items: center; }
  .modal { border-radius: 18px; padding: 22px; }
}

/* ---- 小提示 ---- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 60;
  bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom));
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: var(--radius-sm); pointer-events: none; line-height: 1.5;
  font-size: 14px; max-width: 90vw; box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
}
.toast.error { background: var(--red); }
/* 弹窗开着时报错挪到顶上：手机上弹窗从底部升起来，底部的提示会压住弹窗里的报错行和按钮 */
body.has-modal .toast { bottom: auto; top: calc(12px + env(safe-area-inset-top)); }
@media (min-width: 900px) { .toast { bottom: 24px; } }

/* ---- 空 / 加载 ---- */
.empty { text-align: center; color: var(--ink-3); padding: 28px 16px; }
.empty .btn { margin-top: 12px; }
.loading { color: var(--ink-3); padding: 20px 0; text-align: center; }

/* ---- 表格（只给看板的"每天一行"这种少量数字用；⛔ 别拿它做主列表） ---- */
.scroll-x { overflow-x: auto; }
table.simple { border-collapse: collapse; width: 100%; font-size: 14px; }
table.simple th, table.simple td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.simple th:first-child, table.simple td:first-child { text-align: left; }
table.simple th { color: var(--ink-2); font-weight: 700; }

/* ---- 登录 / 设密码这种没有导航的页 ---- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card .brand-big { font-size: 22px; font-weight: 800; margin-bottom: 4px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
