:root {
  --blue: #1f3fb6;
  --blue-d: #142c86;
  --blue-l: #e8edfd;
  --orange: #f58220;
  --orange-l: #fff1e3;
  --ink: #17203a;
  --muted: #6b7489;
  --line: #e4e7ef;
  --bg: #f4f6fb;
  --card: #ffffff;
  --good: #14915a;
  --bad: #d23b3b;
  --r: 16px;
  --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; background: var(--bg); color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif; }
body { min-height: 100vh; overscroll-behavior-y: none; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); }

/* top bar */
.top { position: sticky; top: 0; z-index: 10; background: var(--blue); color: #fff;
  padding: calc(var(--safe-t) + 12px) 16px 12px; display: flex; align-items: center; gap: 10px; }
.top h1 { font-size: 18px; margin: 0; flex: 1; font-weight: 700; letter-spacing: .2px; }
.top .sub { font-size: 12px; opacity: .8; font-weight: 400; display: block; }
.top button { background: rgba(255,255,255,.15); border: 0; color: #fff; border-radius: 10px; padding: 6px 10px; }
.logo { width: 32px; height: 32px; border-radius: 9px; background: var(--orange); display: grid; place-items: center;
  font-weight: 800; color: #fff; font-size: 17px; flex: none; }

main { padding: 14px 14px calc(88px + var(--safe-b)); max-width: 720px; margin: 0 auto; }

/* bottom tabs */
.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; background: #fff; border-top: 1px solid var(--line);
  display: flex; padding-bottom: var(--safe-b); }
.tabs a { flex: 1; text-align: center; padding: 8px 2px 7px; text-decoration: none; color: var(--muted); font-size: 11px; }
.tabs a .i { display: block; font-size: 21px; line-height: 1.15; filter: grayscale(1); opacity: .65; }
.tabs a.on { color: var(--blue); font-weight: 600; }
.tabs a.on .i { filter: none; opacity: 1; }

/* cards */
.card { background: var(--card); border-radius: var(--r); padding: 14px; margin-bottom: 12px; box-shadow: 0 1px 2px rgba(20,30,70,.06); }
.card h2 { font-size: 15px; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.card h2 .r { margin-left: auto; font-weight: 400; font-size: 12px; color: var(--muted); }
.hero { background: linear-gradient(135deg, var(--blue) 0%, #2d55d8 100%); color: #fff; }
.hero .muted { color: rgba(255,255,255,.75); }
.muted { color: var(--muted); font-size: 13px; }
.small { font-size: 12px; }
.row { display: flex; gap: 10px; align-items: center; }
.row > .grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sep { height: 1px; background: var(--line); margin: 12px 0; }

/* KPI */
.kpi { background: var(--card); border-radius: 14px; padding: 12px; box-shadow: 0 1px 2px rgba(20,30,70,.06); }
.kpi .l { font-size: 12px; color: var(--muted); }
.kpi .v { font-size: 21px; font-weight: 750; margin: 2px 0; letter-spacing: -.3px; }
.kpi .c { font-size: 12px; color: var(--muted); }
.up { color: var(--good); font-weight: 600; }
.down { color: var(--bad); font-weight: 600; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.badge.up { background: #e3f6ec; }
.badge.down { background: #fde8e8; }
.badge.new { background: var(--orange-l); color: var(--orange); }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 12px; background: #eef0f5; color: var(--muted); }
.pill.ok { background: #e3f6ec; color: var(--good); }
.pill.warn { background: var(--orange-l); color: #b85b07; }
.pill.err { background: #fde8e8; color: var(--bad); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: #c5cad6; }
.dot.ok { background: var(--good); }

.bar { height: 10px; background: #eceff6; border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--orange), #ffb35c); border-radius: 99px; }

/* forms */
label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
input[type=text], input[type=tel], input[type=password], input[type=number], input[type=search], input[type=datetime-local], select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; background: #fff; outline: none; font-size: 16px; }
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-l); }
.pin { letter-spacing: 8px; text-align: center; font-size: 22px; font-weight: 700; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 12px;
  padding: 11px 16px; font-weight: 600; background: var(--blue); color: #fff; cursor: pointer; text-decoration: none; }
.btn.block { width: 100%; }
.btn.orange { background: var(--orange); }
.btn.ghost { background: var(--blue-l); color: var(--blue); }
.btn.light { background: #eef0f5; color: var(--ink); }
.btn.danger { background: #fde8e8; color: var(--bad); }
.btn.sm { padding: 7px 11px; font-size: 13px; border-radius: 10px; }
.btn[disabled] { opacity: .5; }

.seg { display: flex; background: #e9ecf4; border-radius: 12px; padding: 3px; margin-bottom: 12px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 8px 6px; border-radius: 9px; font-weight: 600; color: var(--muted); font-size: 14px; }
.seg button.on { background: #fff; color: var(--blue); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 5px 11px; font-size: 13px; }
.chip.on { background: var(--blue); border-color: var(--blue); color: #fff; }
.chip.add { background: var(--orange-l); border-color: transparent; color: #b85b07; font-weight: 600; }

/* lists */
.list { margin: 0; padding: 0; list-style: none; }
.list li { display: flex; gap: 10px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .t { font-weight: 600; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--blue-l); color: var(--blue); display: grid; place-items: center; font-weight: 700; flex: none; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { padding: 7px 4px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl th { color: var(--muted); font-weight: 500; font-size: 12px; }
.scroll-x { overflow-x: auto; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(15,20,40,.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: #fff; width: 100%; max-width: 720px; max-height: 92vh; overflow: auto; border-radius: 20px 20px 0 0;
  padding: 16px 16px calc(18px + var(--safe-b)); animation: up .18s ease-out; }
.modal h3 { margin: 0 0 12px; font-size: 17px; display: flex; align-items: center; }
.modal h3 button { margin-left: auto; border: 0; background: #eef0f5; border-radius: 50%; width: 30px; height: 30px; font-size: 16px; }
@keyframes up { from { transform: translateY(30px); opacity: .5; } to { transform: none; opacity: 1; } }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(86px + var(--safe-b)); background: #1c2440; color: #fff;
  padding: 10px 16px; border-radius: 12px; z-index: 60; font-size: 14px; max-width: 90vw; box-shadow: 0 6px 20px rgba(0,0,0,.2); }

.code { font-size: 34px; font-weight: 800; letter-spacing: 6px; text-align: center; color: var(--blue); background: var(--blue-l);
  border-radius: 14px; padding: 14px; font-family: ui-monospace, Menlo, monospace; }
.qr { display: block; margin: 8px auto; width: 240px; max-width: 80%; border-radius: 12px; border: 1px solid var(--line); }
.steps { padding-left: 20px; margin: 8px 0; font-size: 14px; }
.steps li { margin-bottom: 4px; }
.note { background: var(--orange-l); color: #8a4706; border-radius: 12px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px; }
.note.blue { background: var(--blue-l); color: var(--blue-d); }
.note.red { background: #fde8e8; color: var(--bad); }

.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch i { position: absolute; inset: 0; background: #cfd4df; border-radius: 99px; transition: .2s; }
.switch i::after { content: ""; position: absolute; width: 24px; height: 24px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + i { background: var(--good); }
.switch input:checked + i::after { left: 23px; }

.bubble { max-width: 82%; padding: 8px 11px; border-radius: 14px; margin: 4px 0; white-space: pre-wrap; font-size: 14px; }
.bubble.in { background: #eef0f5; border-top-left-radius: 4px; }
.bubble.out { background: #dcf8c6; margin-left: auto; border-top-right-radius: 4px; }
.bubble.me { background: var(--blue-l); margin-left: auto; border-top-right-radius: 4px; }
.chatbox { display: flex; flex-direction: column; max-height: 50vh; overflow: auto; padding: 4px 0; }

.auth { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: calc(var(--safe-t) + 20px) 18px calc(var(--safe-b) + 20px); max-width: 460px; margin: 0 auto; }
.brand { text-align: center; margin-bottom: 18px; }
.brand .logo { width: 64px; height: 64px; font-size: 32px; border-radius: 18px; margin: 0 auto 10px; box-shadow: 0 8px 24px rgba(245,130,32,.35); }
.brand h1 { margin: 0; font-size: 24px; color: var(--blue); }
.spinner { width: 34px; height: 34px; border: 4px solid var(--blue-l); border-top-color: var(--blue); border-radius: 50%; animation: spin 1s linear infinite; margin: 14px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0; }
.thumbs .th { position: relative; width: 74px; height: 74px; border-radius: 10px; background: #eef0f5; overflow: hidden; display: grid; place-items: center; font-size: 11px; text-align: center; padding: 4px; }
.thumbs .th img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.thumbs .th button { position: absolute; top: 2px; right: 2px; border: 0; background: rgba(0,0,0,.55); color: #fff; border-radius: 50%; width: 22px; height: 22px; font-size: 12px; z-index: 2; }
.chk { width: 20px; height: 20px; accent-color: var(--blue); flex: none; }
.right { text-align: right; }
.center { text-align: center; }
.mt { margin-top: 10px; }
.hidden { display: none !important; }
svg text { font-family: inherit; }
.list li > .grow { flex: 1; min-width: 0; }
