:root {
  --bg: #f4f6f3; --card: #fff; --ink: #18211c; --muted: #66706a; --line: #e2e7e2;
  --pri: #1f7a4d; --pri-ink: #fff; --pri-soft: #e3f2e9;
  --rest: #2f6fd1; --rest-soft: #e5eefc; --leave: #b5651d; --leave-soft: #fbeedf;
  --warn: #9a6200; --warn-soft: #fff4dc; --err: #c0392b; --err-soft: #fde8e6; --ok: #1f7a4d;
  --r: 14px; --tab-h: 62px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111613; --card: #1b221e; --ink: #e8eee9; --muted: #98a39c; --line: #2b352f;
    --pri: #3fae76; --pri-ink: #06140c; --pri-soft: #183526;
    --rest: #7aa8f0; --rest-soft: #1c2a40; --leave: #e6a465; --leave-soft: #3a2a19;
    --warn: #f0b84e; --warn-soft: #3a2e14; --err: #ff7b6e; --err-soft: #3d1e1b; --ok: #3fae76;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 16px/1.45 system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; margin-bottom: 10px; }
h3.sub { margin: 22px 4px 8px; color: var(--muted); font-size: .9rem; text-transform: uppercase; letter-spacing: .03em; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); }
.top h1 { font-size: 1.35rem; }
.who { color: var(--muted); font-size: .9rem; }
main { max-width: 720px; margin: 0 auto; padding: 4px 16px calc(var(--tab-h) + env(safe-area-inset-bottom) + 24px); display: flex; flex-direction: column; gap: 14px; }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); }
.tab { flex: 1; position: relative; height: var(--tab-h); border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: .72rem; color: var(--muted); cursor: pointer; }
.tab-ic { font-size: 1.3rem; filter: grayscale(1); opacity: .7; }
.tab.on { color: var(--pri); font-weight: 600; }
.tab.on .tab-ic { filter: none; opacity: 1; }
.dot { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--err); color: #fff; font-size: .7rem; line-height: 18px; text-align: center; font-weight: 700; }

.card { background: var(--card); border-radius: var(--r); padding: 16px; box-shadow: 0 1px 0 var(--line), 0 1px 3px rgba(0,0,0,.04); }
.card.pad0 { padding: 8px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; }
.row.gap, .gap { gap: 8px; }
.row.end { justify-content: flex-end; }
.center-v { align-items: center; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; justify-content: center; }
.pad { padding: 32px 16px; }
.right { text-align: right; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.err { color: var(--err); margin: 0; min-height: 0; }
.err:empty { display: none; }
.warn { background: var(--warn-soft); color: var(--warn); padding: 10px 12px; border-radius: 10px; margin: 0; font-size: .92rem; }
.warn-t { color: var(--warn); }
.ok-t { color: var(--ok); margin: 0; }
.note { color: var(--leave); }

.lbl { display: flex; flex-direction: column; gap: 5px; font-size: .85rem; color: var(--muted); }
.input { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font-size: 16px; color: var(--ink); }
.input:focus { outline: 2px solid var(--pri); outline-offset: -1px; border-color: transparent; }
.input.qty { width: 74px; text-align: center; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }

.btn { min-height: 46px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; white-space: nowrap; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--pri); color: var(--pri-ink); }
.btn.ghost { background: var(--bg); border-color: var(--line); color: var(--ink); }
.btn.outline { background: transparent; border-color: var(--pri); color: var(--pri); }
.btn.danger { background: var(--err-soft); color: var(--err); }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: .88rem; }
.btn.sq { width: 46px; padding: 0; font-size: 1.3rem; }
.icon-btn { width: 40px; height: 40px; border: 0; border-radius: 10px; background: transparent; font-size: 1.15rem; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: var(--bg); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0; scrollbar-width: none; }
.chips.center { justify-content: center; }
.chip { flex: none; min-height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid var(--line); background: var(--card); font-size: .9rem; cursor: pointer; }
.chip.on { background: var(--pri); color: var(--pri-ink); border-color: var(--pri); font-weight: 600; }

.seg { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { flex: 1; min-height: 40px; border: 0; border-radius: 8px; background: transparent; cursor: pointer; font-weight: 500; color: var(--ink); }
.seg button.on { background: var(--card); box-shadow: 0 1px 3px rgba(0,0,0,.12); color: var(--pri); font-weight: 700; }

.month-nav { display: flex; align-items: center; justify-content: space-between; }
.month-nav strong { font-size: 1.05rem; text-transform: capitalize; }
.month-nav .icon-btn { font-size: 1.6rem; background: var(--card); }

.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.cal-h { text-align: center; font-size: .75rem; color: var(--muted); padding: 4px 0; font-weight: 600; }
.cal-c { min-height: 64px; border: 0; border-radius: 8px; background: transparent; padding: 4px 2px; display: flex; flex-direction: column; align-items: stretch; gap: 2px; cursor: pointer; text-align: left; overflow: hidden; }
.cal-c.empty { cursor: default; }
.cal-c .n { font-size: .82rem; font-weight: 600; padding-left: 3px; }
.cal-c.has { background: var(--pri-soft); }
.cal-c.today .n { color: var(--pri-ink); background: var(--pri); border-radius: 10px; align-self: flex-start; padding: 0 6px; }
.cal-c.sel { outline: 2px solid var(--pri); outline-offset: -2px; }
.nm { font-size: .66rem; line-height: 1.25; background: var(--rest-soft); color: var(--rest); border-radius: 4px; padding: 1px 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nm.lv { background: var(--leave-soft); color: var(--leave); }
.nm.pend { background: transparent; border: 1px dashed currentColor; }
.more { font-size: .66rem; color: var(--muted); padding-left: 3px; }

.list { list-style: none; margin: 0; padding: 0; }
.li { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.li:last-child { border-bottom: 0; }
.li.col { flex-direction: column; align-items: stretch; gap: 6px; }
.li.tap { cursor: pointer; }
.li.off { opacity: .55; }
.chev { color: var(--muted); font-size: 1.4rem; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: .75rem; font-weight: 600; white-space: nowrap; }
.t-rest { background: var(--rest-soft); color: var(--rest); }
.t-leave { background: var(--leave-soft); color: var(--leave); }
.b-pending { background: var(--warn-soft); color: var(--warn); }
.b-approved { background: var(--pri-soft); color: var(--ok); }
.b-rejected { background: var(--err-soft); color: var(--err); }
.b-cancelled { background: var(--bg); color: var(--muted); }

.summary { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.summary > div { background: var(--card); border-radius: var(--r); padding: 12px 14px; display: flex; flex-direction: column; box-shadow: 0 1px 0 var(--line); }
.summary small { color: var(--muted); }
.summary b { font-size: 1.15rem; }

.found { margin-top: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.item-hit { display: flex; align-items: center; gap: 10px; }
.price { font-size: 1.3rem; font-weight: 700; color: var(--pri); }
.totals { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.totals > div { background: var(--bg); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; font-size: .85rem; color: var(--muted); }
.totals b { color: var(--ink); font-size: 1.1rem; }
.settle { border-top: 1px solid var(--line); padding-top: 12px; }

.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: .8rem; color: var(--muted); font-weight: 600; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 10px 4px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl .num { text-align: right; width: 64px; font-variant-numeric: tabular-nums; }
.tbl td.num { font-weight: 700; font-size: 1.05rem; }
.tbl tr.dates td { background: var(--bg); font-size: .85rem; padding: 8px; }
.tbl tr.dates div + div { margin-top: 4px; }
.tap { cursor: pointer; }

.sheet-wrap { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.4); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet { width: 100%; max-width: 560px; max-height: 92vh; background: var(--card); border-radius: 18px 18px 0 0; display: flex; flex-direction: column; animation: up .2s ease-out; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 12px 6px 18px; }
.sheet-body { overflow-y: auto; padding: 8px 18px calc(env(safe-area-inset-bottom) + 20px); }
@media (min-width: 640px) { .sheet-wrap { align-items: center; } .sheet { border-radius: 18px; } }
@keyframes up { from { transform: translateY(30px); opacity: .5; } }
@keyframes fade { from { opacity: 0; } }

.qr { width: 100%; min-height: 260px; border-radius: 12px; overflow: hidden; background: #000; }
.qr video { width: 100% !important; display: block; }

.toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 16px); transform: translate(-50%, 20px); opacity: 0; z-index: 30;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: .92rem; max-width: calc(100% - 32px); transition: .25s; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.toast.err { background: var(--err); color: #fff; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

.auth { max-width: 420px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 40px) 20px 40px; display: flex; flex-direction: column; gap: 18px; }
.auth h2 { text-align: center; }
.logo { display: flex; justify-content: center; }
.logo img { width: 72px; height: 72px; border-radius: 18px; }
.install h3 { margin-bottom: 6px; }
.install p { margin: 0; }
.me strong { font-size: 1.2rem; }

:focus-visible { outline: 2px solid var(--pri); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
