/* hidden 属性必须绝对优先：任何 display 规则都不能覆盖它
   （否则 .gate/.sheet 这类带 display 的遮罩层会永久盖住页面） */
[hidden] { display: none !important; }

:root {
  --brand: #E85D26;
  --brand-dark: #C94815;
  --brand-soft: #FDF0EA;
  --ink: #17191C;
  --ink-2: #444A52;
  --muted: #8A9199;
  --line: #E9ECEF;
  --line-2: #F1F3F5;
  --bg: #F4F5F7;
  --card: #FFFFFF;
  --green: #1F9D6B;
  --green-soft: #E8F6F0;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 24, 30, .04), 0 6px 18px rgba(20, 24, 30, .05);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

body { padding-bottom: calc(96px + var(--safe-b)); }

/* ======================= 顶部 ======================= */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 12px;
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
  background: rgba(244, 245, 247, .92);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.logo {
  width: 38px; height: 38px;
  flex: 0 0 38px;
  border-radius: 11px;
  background: linear-gradient(145deg, #F0703A, #D94E18);
  color: #fff;
  display: grid; place-items: center;
  font-size: 18px; font-weight: 700;
  letter-spacing: -.5px;
  box-shadow: 0 4px 12px rgba(232, 93, 38, .28);
}

.brand-text { min-width: 0; }
.brand-text h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.2px;
  white-space: nowrap;
}
.brand-text p {
  margin: 1px 0 0;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ghost-btn {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-2);
  font-size: 13px;
  padding: 7px 12px;
  border-radius: 9px;
  font-family: inherit;
  cursor: pointer;
}
.ghost-btn:active { background: var(--line-2); }

/* ======================= 我的 / 全部 ======================= */
.scope-bar {
  display: flex;
  gap: 6px;
  padding: 0 16px 12px;
}
.scope-pill {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-2);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 15px;
  border-radius: 20px;
  cursor: pointer;
  transition: .18s;
}
.scope-pill.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

/* ======================= 统计 ======================= */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 0 16px 4px;
}
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px 12px 11px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.stat-card.wide { grid-column: 1 / -1; flex-direction: row; align-items: baseline; gap: 10px; }
.stat-label { font-size: 11.5px; color: var(--muted); letter-spacing: .2px; }
.stat-value {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.6px;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.stat-card.wide .stat-value { font-size: 24px; }
.stat-value.money { color: var(--brand); }
.stat-unit { font-size: 11px; color: var(--muted); }
.stat-card.wide .stat-unit { margin-left: auto; }

/* ======================= 工具栏 ======================= */
.toolbar {
  display: flex;
  gap: 8px;
  padding: 14px 16px 10px;
}
.search-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}
.search-wrap .ic {
  position: absolute;
  left: 11px;
  width: 16px; height: 16px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  stroke-linecap: round;
  pointer-events: none;
}
.search-wrap input {
  width: 100%;
  height: 40px;
  padding: 0 12px 0 34px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  outline: none;
  -webkit-appearance: none;
}
.search-wrap input::placeholder { color: #A9B0B8; }
.search-wrap input:focus { border-color: #D3D8DE; }

.toolbar select {
  height: 40px;
  padding: 0 26px 0 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238A9199' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 7px center / 14px;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--ink-2);
  -webkit-appearance: none;
  appearance: none;
  outline: none;
  max-width: 45%;
}

/* ======================= 列表 ======================= */
.list { padding: 0 16px; display: flex; flex-direction: column; gap: 9px; }

.record {
  background: var(--card);
  border-radius: var(--radius);
  padding: 13px 14px 12px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .12s;
  border: 1px solid transparent;
}
.record:active { transform: scale(.988); }

.rec-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
}
.rec-customer {
  font-size: 15.5px;
  font-weight: 650;
  letter-spacing: -.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.tag {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 500;
  padding: 2.5px 7px;
  border-radius: 6px;
  background: var(--line-2);
  color: var(--ink-2);
  white-space: nowrap;
}
.tag.platform { background: #EFF4FF; color: #3B6BE0; }
.tag.deal { background: #FDECE9; color: #C0392B; }
.tag.visit { background: #FFF6E5; color: #B4761A; }

.rec-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 12.5px;
  color: var(--muted);
}
.rec-meta b { color: var(--ink-2); font-weight: 500; }
.rec-amount {
  margin-left: auto;
  font-size: 16px;
  font-weight: 700;
  font-style: normal;
  color: var(--brand);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.3px;
}
.rec-demand {
  margin: 7px 0 0;
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.empty {
  text-align: center;
  padding: 56px 24px;
  color: var(--muted);
}
.empty .big { font-size: 15px; color: var(--ink-2); margin-bottom: 6px; font-weight: 500; }
.empty p { margin: 0; font-size: 13px; }

/* ======================= 悬浮按钮 ======================= */
.fab {
  position: fixed;
  right: 18px;
  bottom: calc(20px + var(--safe-b));
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 50px;
  padding: 0 20px 0 16px;
  border: none;
  border-radius: 25px;
  background: linear-gradient(145deg, #F0703A, #D94E18);
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  box-shadow: 0 6px 20px rgba(217, 78, 24, .35);
  cursor: pointer;
}
.fab:active { transform: scale(.96); }
.fab svg {
  width: 19px; height: 19px;
  fill: none; stroke: #fff;
  stroke-width: 2.6; stroke-linecap: round;
}

/* ======================= 抽屉表单 ======================= */
.sheet-mask {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(16, 20, 26, .38);
  animation: fadein .2s ease;
}
@keyframes fadein { from { opacity: 0 } to { opacity: 1 } }

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  max-height: 93vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 40px rgba(16, 20, 26, .16);
  animation: slideup .26s cubic-bezier(.32, .72, .3, 1);
}
@keyframes slideup { from { transform: translateY(100%) } to { transform: translateY(0) } }

.sheet-head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 15px 52px 11px;
  background: var(--bg);
  border-radius: 20px 20px 0 0;
  flex: 0 0 auto;
}
.sheet-head::before {
  content: "";
  position: absolute;
  top: 6px; left: 50%;
  transform: translateX(-50%);
  width: 36px; height: 4px;
  border-radius: 2px;
  background: #D8DCE1;
}
.sheet-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -.2px;
}
.sheet-step {
  position: absolute;
  right: 16px;
  font-size: 11.5px;
  color: var(--muted);
}
.sheet-close {
  position: absolute;
  left: 12px;
  width: 32px; height: 32px;
  border: none;
  background: var(--line-2);
  border-radius: 50%;
  display: grid; place-items: center;
  cursor: pointer;
}
.sheet-close svg {
  width: 15px; height: 15px;
  fill: none; stroke: var(--ink-2);
  stroke-width: 2.2; stroke-linecap: round;
}

.sheet-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 16px 20px;
}

.field { margin-bottom: 14px; }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; min-width: 0; }

.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--ink-2);
  margin-bottom: 6px;
  letter-spacing: .1px;
}
.field label i { color: var(--brand); font-style: normal; }
.field label .hint { color: var(--muted); font-weight: 400; font-size: 11.5px; }

.field input[type=text],
.field input[type=date],
.field input[type=number],
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  padding: 11px 13px;
  font-family: inherit;
  font-size: 14.5px;
  color: var(--ink);
  outline: none;
  -webkit-appearance: none;
  transition: border-color .15s, box-shadow .15s;
}
.field select {
  /* 自绘下拉箭头，避免 iOS 原生控件样式不统一 */
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%238A9198' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  padding-right: 34px;
}
.field input[readonly] { background: #F7F8FA; color: #6B7178; }
.field input::placeholder, .field textarea::placeholder { color: #AFB6BD; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: #E3A98C;
  box-shadow: 0 0 0 3px rgba(232, 93, 38, .09);
}
.field textarea { resize: none; line-height: 1.5; }

.chip-group { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-2);
  font-family: inherit;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 9px;
  cursor: pointer;
  transition: .15s;
}
.chip.active {
  background: var(--brand-soft);
  border-color: #EFBDA6;
  color: var(--brand-dark);
  font-weight: 600;
}

.segment {
  display: flex;
  background: #EDEFF2;
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.segment button {
  flex: 1;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--ink-2);
  padding: 8px 4px;
  border-radius: 8px;
  cursor: pointer;
  transition: .15s;
  white-space: nowrap;
}
.segment button.active {
  background: #fff;
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(20, 24, 30, .1);
}
.segment.accent button.active { color: var(--green); }

.money-input { position: relative; }
.money-input .prefix {
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 15px;
}
.money-input input { padding-left: 30px !important; font-size: 17px !important; font-weight: 600; }

.form-error {
  background: #FDECEC;
  color: #C0392B;
  font-size: 13px;
  padding: 10px 13px;
  border-radius: 10px;
  margin-bottom: 6px;
}

.sheet-foot {
  flex: 0 0 auto;
  display: flex;
  gap: 10px;
  padding: 10px 16px;
  padding-bottom: calc(10px + var(--safe-b));
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.btn-primary {
  flex: 1;
  height: 46px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(145deg, #F0703A, #D94E18);
  color: #fff;
  font-family: inherit;
  font-size: 15.5px;
  font-weight: 650;
  letter-spacing: .5px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(217, 78, 24, .26);
}
.btn-primary:active { transform: scale(.985); }
.btn-primary:disabled { opacity: .55; box-shadow: none; }
.btn-secondary {
  flex: 0 0 auto;
  padding: 0 18px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: #B03A2E;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
}

/* ======================= Toast ======================= */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(110px + var(--safe-b));
  transform: translateX(-50%);
  z-index: 90;
  background: rgba(23, 25, 28, .9);
  color: #fff;
  font-size: 13.5px;
  padding: 10px 18px;
  border-radius: 10px;
  white-space: nowrap;
  animation: fadein .16s;
  max-width: 82vw;
}
.toast.err { background: rgba(176, 58, 46, .94); }

/* ======================= 登录门 ======================= */
.gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  display: grid;
  place-items: center;
  padding: 28px;
}
.gate-card {
  background: #fff;
  border-radius: 18px;
  padding: 26px 22px;
  max-width: 340px;
  width: 100%;
  box-shadow: var(--shadow);
  text-align: center;
}
.gate-card h2 { margin: 0 0 8px; font-size: 17px; }
.gate-card p { margin: 0; font-size: 13.5px; color: var(--muted); line-height: 1.6; }
.gate-dev { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.gate-dev .dev-title { font-size: 12px; color: var(--muted); margin-bottom: 8px; text-align: left; }
.gate-dev input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  margin-bottom: 10px;
  outline: none;
}
.gate-err { color: #C0392B !important; font-size: 12.5px; margin-top: 12px !important; }
