/* ChemShelf · Mike Lab — mobile first */
:root {
  --bg: #f4f6f8; --card: #fff; --ink: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --brand: #0f766e; --brand-ink: #fff; --brand-soft: #e6f4f2;
  --warn: #b45309; --warn-soft: #fef3c7; --bad: #b91c1c; --bad-soft: #fee2e2; --ok: #15803d; --ok-soft: #dcfce7;
  --radius: 14px; --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 2px 8px rgba(15, 23, 42, .04);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--font); padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
body.bare { padding-bottom: 0; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
.page-title { font-size: 1.45rem; margin: .2em 0 .6em; }
.section-title { font-size: 1.05rem; margin: 1.2em 0 .6em; }
.card .section-title:first-child { margin-top: 0; }
.muted { color: var(--muted); }
.small, small { font-size: .85rem; }
.mono { font-family: var(--mono); font-size: .95em; }
.hint { color: var(--muted); font-size: .9rem; margin: .4em 0 .8em; }
.center { text-align: center; }
.ok-text { color: var(--ok); }
[hidden] { display: none !important; }

/* header */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: rgba(255, 255, 255, .92); backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none !important; }
.brand b { display: block; font-size: 1.02rem; letter-spacing: -.01em; }
.brand small { display: block; color: var(--muted); font-size: .72rem; margin-top: -3px; }
.logo { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--brand); color: #fff; font-size: 19px; }
.logo.big { width: 64px; height: 64px; border-radius: 18px; font-size: 36px; margin: 0 auto 10px; }
.desk { display: none; gap: 4px; margin-left: 12px; }
.desk a { padding: 7px 12px; border-radius: 9px; color: var(--ink); font-size: .95rem; }
.desk a[aria-current] { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.desk a:hover { text-decoration: none; background: #f1f5f9; }
.count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--warn); color: #fff; font-size: .75rem; text-align: center; }
.me { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.ai-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.ai-dot.on { background: #22c55e; box-shadow: 0 0 0 3px #dcfce7; }
.ai-dot.off { background: #f59e0b; box-shadow: 0 0 0 3px #fef3c7; }
.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; padding: 6px 10px; border-radius: 9px; border: 1px solid var(--line); font-size: .9rem; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu summary::-webkit-details-marker { display: none; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 6px); min-width: 180px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(15, 23, 42, .12); padding: 6px; display: grid; }
.menu-pop a, .menu-pop button { display: block; width: 100%; text-align: left; padding: 9px 12px; border: 0; background: none; border-radius: 8px; color: var(--ink); font: inherit; cursor: pointer; }
.menu-pop a:hover, .menu-pop button:hover { background: #f1f5f9; text-decoration: none; }

/* layout */
.wrap { max-width: 980px; margin: 0 auto; padding: 16px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.card.narrow, .narrow { max-width: 560px; }
.stack { display: grid; gap: 12px; }
.two, .three { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.three { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 420px) { .two { grid-template-columns: 1fr; } .three { grid-template-columns: 1fr 1fr; } .three > :last-child { grid-column: span 2; } }

/* forms */
label { display: grid; gap: 4px; font-size: .88rem; color: #334155; font-weight: 500; }
label small { color: var(--muted); font-weight: 400; }
input, select, textarea { width: 100%; font: inherit; font-size: 16px; color: var(--ink); padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 10px; background: #fff; min-height: 44px; }
textarea { min-height: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
fieldset { border: 0; padding: 0; margin: 0 0 6px; display: grid; gap: 10px; }
legend { font-weight: 700; font-size: 1rem; margin-bottom: 4px; padding: 0; }
.bad { color: var(--bad); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 10px 16px; border-radius: 11px; border: 1px solid #cbd5e1; background: #fff; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none !important; }
.btn:hover { background: #f8fafc; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { background: #115e59; }
.btn.big { width: 100%; min-height: 50px; font-size: 1.05rem; }
.btn.danger-ghost { color: var(--bad); border-color: #fecaca; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions form { margin: 0; }
.actions.sticky { position: sticky; bottom: calc(68px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, #fff 30%); padding-top: 14px; margin: 0 -16px -16px; padding: 14px 16px 16px; border-radius: 0 0 var(--radius) var(--radius); }
.actions.sticky .btn.primary { flex: 1; }
.draft-extra { justify-content: center; margin: 8px 0 20px; }
.flash { padding: 11px 14px; border-radius: 11px; margin: 0 0 14px; font-size: .95rem; }
.flash.ok { background: var(--ok-soft); color: #14532d; }
.flash.warn { background: var(--warn-soft); color: #78350f; }
.notice { border-left: 4px solid var(--warn); }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: auto; min-height: 0; }

/* auth */
.auth { max-width: 400px; margin: 8vh auto 0; }
.auth-brand { text-align: center; margin-bottom: 18px; }
.auth-brand h1 { margin: 0; font-size: 1.8rem; letter-spacing: -.02em; }
.auth-brand p { color: var(--muted); margin: 4px 0 0; }
.lang-switch { text-align: center; margin-top: 10px; }
.lang-switch button { border: 0; background: none; color: var(--brand); font: inherit; cursor: pointer; }

/* home */
.hero { padding: 6px 0 4px; }
.hero h1 { font-size: 1.55rem; letter-spacing: -.01em; }
.search { position: relative; }
.search svg { position: absolute; left: 15px; top: 50%; width: 22px; height: 22px; transform: translateY(-50%); fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.search input { height: 56px; padding-left: 48px; font-size: 17px; border-radius: 16px; border: 1.5px solid #cbd5e1; box-shadow: var(--shadow); }
.hero-meta { color: var(--muted); font-size: .9rem; margin: 8px 2px 14px; }
.results-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.results-head h2 { font-size: 1rem; margin: 6px 0; }
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 8px; }
.tile { display: grid; gap: 2px; padding: 16px; border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); color: var(--ink); text-decoration: none !important; }
.tile span { font-size: 26px; }
.tile small { color: var(--muted); }
.tile.primary { background: var(--brand); color: #fff; }
.tile.primary small { color: #ccfbf1; }
@media (min-width: 720px) { .quick { grid-template-columns: repeat(4, 1fr); } }
.empty { text-align: center; padding: 28px 16px; color: var(--muted); background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); }

/* rows */
.list { display: grid; gap: 8px; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; background: #fff; box-shadow: var(--shadow); color: var(--ink); text-decoration: none !important; }
.row:hover { box-shadow: 0 0 0 1.5px var(--brand-soft), var(--shadow); }
.thumb { width: 54px; height: 54px; border-radius: 10px; object-fit: cover; flex: none; background: #f1f5f9; }
.thumb.none { display: grid; place-items: center; color: #94a3b8; font-size: 22px; }
.row-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.row-main > b { overflow-wrap: anywhere; }
.row-sub { display: flex; flex-wrap: wrap; gap: 4px 10px; color: var(--muted); font-size: .85rem; }
.place { font-size: .88rem; color: #0f5f58; font-weight: 500; }
.qty { flex: none; text-align: center; min-width: 46px; }
.qty b { display: block; font-size: 1.35rem; line-height: 1; }
.qty small { color: var(--muted); }
.qty.gone small { color: var(--bad); }
.ghs { font-size: .9rem; }

/* intake */
.step { display: flex; align-items: center; gap: 10px; font-size: 1.05rem; }
.step span { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--brand); color: #fff; font-size: .85rem; }
.field { display: grid; gap: 6px; margin-bottom: 10px; font-size: .88rem; color: #334155; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { min-width: 48px; min-height: 44px; border-radius: 11px; border: 1.5px solid #cbd5e1; background: #fff; font: inherit; font-weight: 700; cursor: pointer; }
.chips button[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.camera { position: relative; display: block; margin: 8px 0 6px; }
.camera input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.camera-btn { display: flex; align-items: center; justify-content: center; gap: 8px; height: 72px; border-radius: 16px; background: var(--brand); color: #fff; font-size: 1.25rem; font-weight: 700; box-shadow: 0 6px 18px rgba(15, 118, 110, .25); }
.camera.busy .camera-btn { opacity: .7; }
.from-album { display: block; text-align: center; color: var(--brand); font-weight: 500; position: relative; padding: 8px; }
.from-album input { position: absolute; inset: 0; opacity: 0; }
.queue { display: grid; gap: 8px; }
.q-item { display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: 12px; border: 1px solid var(--line); color: var(--ink); text-decoration: none !important; }
.q-item img { width: 56px; height: 56px; border-radius: 9px; object-fit: cover; }
.q-item span { display: grid; min-width: 0; }
.q-item small { color: var(--muted); }
.q-item.ready { border-color: #99f6e4; background: #f0fdfa; }
.q-item.uploading { opacity: .7; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: .78rem; font-weight: 600; background: #f1f5f9; color: #475569; }
.pill.done { background: var(--ok-soft); color: #166534; }
.pill.queued, .pill.working { background: #e0f2fe; color: #075985; }
.pill.failed, .pill.unavailable { background: var(--warn-soft); color: #92400e; }

/* form + photo */
.form-layout { display: grid; gap: 14px; }
.photo { margin: 0; }
.photo img { width: 100%; max-height: 46vh; object-fit: contain; border-radius: var(--radius); background: #0f172a; display: block; }
.photo.small img { max-height: 220px; }
.ai-state { margin-top: 8px; padding: 9px 12px; border-radius: 10px; font-size: .9rem; background: #e0f2fe; color: #075985; }
.ai-state.done { background: var(--ok-soft); color: #14532d; }
.ai-state.failed, .ai-state.unavailable { background: var(--warn-soft); color: #78350f; }
@media (min-width: 860px) { .form-layout { grid-template-columns: 380px 1fr; align-items: start; } .photo { position: sticky; top: 76px; } .photo img { max-height: 70vh; } }
.stepper { display: flex; }
.stepper input { text-align: center; border-radius: 0; border-left: 0; border-right: 0; min-width: 0; }
.stepper button { width: 44px; flex: none; border: 1px solid #cbd5e1; background: #f8fafc; font-size: 1.3rem; cursor: pointer; }
.stepper button:first-child { border-radius: 10px 0 0 10px; }
.stepper button:last-child { border-radius: 0 10px 10px 0; }
.ghs-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; }
.ghs-opt { display: block; }
.ghs-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.ghs-opt span { display: block; padding: 9px 10px; border-radius: 10px; border: 1.5px solid #e2e8f0; font-weight: 500; cursor: pointer; }
.ghs-opt input:checked + span { border-color: #dc2626; background: #fef2f2; color: #7f1d1d; }
.ghs-opt input:focus-visible + span { outline: 2px solid var(--brand); }

/* detail */
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.detail-head p { margin: -8px 0 12px; }
.detail { display: grid; gap: 14px; }
.detail .card { margin: 0; }
.status-pill { padding: 4px 12px; border-radius: 20px; font-size: .85rem; font-weight: 700; background: var(--ok-soft); color: #166534; white-space: nowrap; }
.status-pill.finished, .status-pill.disposed { background: #f1f5f9; color: #475569; }
.where-place { font-size: 1.1rem; font-weight: 600; margin: 0 0 10px; }
.qty-big { display: flex; align-items: center; justify-content: center; gap: 22px; margin: 6px 0 14px; }
.qty-big div { text-align: center; }
.qty-big b { display: block; font-size: 2.6rem; line-height: 1; }
.qty-big small { color: var(--muted); }
.qty-big form { margin: 0; }
.round { width: 52px; height: 52px; border-radius: 50%; border: 1.5px solid #cbd5e1; background: #fff; font-size: 1.6rem; cursor: pointer; }
.round:disabled { opacity: .4; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; }
.kv dt { color: var(--muted); font-size: .9rem; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.signal.danger { color: var(--bad); }
.signal.warning { color: var(--warn); }
.ghs-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.ghs-tag { padding: 5px 10px; border-radius: 9px; background: #fef2f2; color: #7f1d1d; font-size: .88rem; font-weight: 500; }
.history { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: .92rem; }
.history time { margin-left: 6px; font-size: .82rem; }

/* cabinets */
.cab-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); margin-bottom: 14px; }
.cab { margin: 0; display: grid; gap: 8px; }
.cab.off { opacity: .55; }
.cab-link { display: grid; gap: 2px; color: var(--ink); text-decoration: none !important; }
.cab-link b { font-size: 1.1rem; }
.cab-link small { color: var(--muted); }
.cab-count { color: var(--brand); font-weight: 600; margin-top: 4px; }
.cab-actions { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; flex-wrap: wrap; }
.cab-actions summary { cursor: pointer; color: var(--brand); }
.mini-form { margin-top: 10px; min-width: 240px; }
.shelves { display: grid; gap: 12px; }
.shelf { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px; }
.shelf h2 { font-size: 1rem; display: flex; justify-content: space-between; }
.shelf h2 small { color: var(--muted); font-weight: 400; }
.shelf .row { box-shadow: none; border: 1px solid var(--line); }

/* stats */
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
@media (min-width: 720px) { .kpis { grid-template-columns: repeat(6, 1fr); } }
.kpi { display: grid; padding: 12px; border-radius: 12px; background: #fff; box-shadow: var(--shadow); color: var(--ink); text-decoration: none !important; }
.kpi b { font-size: 1.6rem; line-height: 1.1; }
.kpi span { color: var(--muted); font-size: .82rem; }
.kpi.attn b { color: var(--warn); }
.stats-grid { display: grid; gap: 14px; }
@media (min-width: 860px) { .stats-grid { grid-template-columns: 1fr 1fr; } }
.stats-grid .card { margin: 0; }
.stats-grid h3 { font-size: .92rem; margin: 10px 0 4px; }
.bar { display: grid; grid-template-columns: 110px 1fr 36px; align-items: center; gap: 8px; font-size: .88rem; margin: 3px 0; }
.bar-track { height: 10px; border-radius: 6px; background: #f1f5f9; overflow: hidden; }
.bar-track span { display: block; height: 100%; background: var(--brand); border-radius: 6px; }
.bar-track.haz span { background: #dc2626; }
.bar-val { text-align: right; font-variant-numeric: tabular-nums; }
.warn-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; font-size: .92rem; }
.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tbl td, .tbl th { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl th { color: var(--muted); font-weight: 600; font-size: .82rem; }
.tbl tr.off td { color: var(--muted); }
.members { display: block; overflow-x: auto; }

/* bottom tab bar (phone) */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(6, 1fr); background: rgba(255, 255, 255, .96); backdrop-filter: blur(8px); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabbar a { position: relative; display: grid; justify-items: center; gap: 1px; padding: 7px 2px 6px; color: var(--muted); font-size: .7rem; text-decoration: none !important; }
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a[aria-current] { color: var(--brand); font-weight: 600; }
.tabbar .tab-add svg { width: 40px; height: 40px; padding: 8px; margin-top: -14px; border-radius: 14px; background: var(--brand); stroke: #fff; box-shadow: 0 4px 12px rgba(15, 118, 110, .35); }
.tabbar .badge { position: absolute; top: 3px; left: calc(50% + 6px); min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--warn); color: #fff; font-size: .68rem; font-style: normal; line-height: 18px; }
@media (min-width: 860px) { .tabbar { display: none; } body { padding-bottom: 24px; } .desk { display: flex; } .actions.sticky { bottom: 0; } }

/* 仪器预约 */
.btn-sm { min-height: 34px; padding: 5px 12px; font-size: .88rem; }
.inst-tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 10px; padding-bottom: 2px; }
.inst-tabs a { flex: none; padding: 8px 14px; border-radius: 20px; background: #fff; box-shadow: var(--shadow); color: var(--ink); font-weight: 600; text-decoration: none !important; }
.inst-tabs a[aria-current] { background: var(--brand); color: #fff; }
.week-nav { display: flex; align-items: center; gap: 10px; margin: 6px 0 10px; }
.week-nav .btn { min-height: 38px; padding: 4px 14px; font-size: 1.2rem; }
.cal-scroll { overflow: auto; max-height: 68vh; border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); -webkit-overflow-scrolling: touch; }
.cal { display: grid; grid-template-columns: 52px repeat(7, minmax(88px, 1fr)); min-width: 680px; position: relative; }
.cal-head { position: sticky; top: 0; z-index: 3; background: #fff; border-bottom: 1px solid var(--line); text-align: center; padding: 6px 2px; font-size: .8rem; color: var(--muted); }
.cal-head b { display: block; font-size: 1.1rem; color: var(--ink); }
.cal-head.today b { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: #fff; }
.cal-corner { left: 0; z-index: 4; }
.cal-times { grid-column: 1; position: sticky; left: 0; z-index: 2; background: #fff; }
.cal-times span { display: block; height: var(--hour); font-size: .7rem; color: var(--muted); text-align: right; padding-right: 6px; transform: translateY(-.55em); }
.cal-times span:first-child { transform: none; }
.cal-day { position: relative; height: calc(var(--hour) * 24); border-left: 1px solid var(--line); cursor: pointer;
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--hour) - 1px), #eef2f6 calc(var(--hour) - 1px), #eef2f6 var(--hour)); }
.cal-day.past { background-color: #f8fafc; }
.cal-day:hover { background-color: #f0fdfa; }
.now-line { position: absolute; left: 0; right: 0; height: 2px; background: #ef4444; z-index: 1; }
.now-line::before { content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: #ef4444; }
.bk { position: absolute; left: 3px; right: 3px; z-index: 2; overflow: hidden; border-radius: 8px; padding: 3px 6px; background: #e0e7ff; border-left: 3px solid #6366f1; font-size: .75rem; line-height: 1.25; cursor: default; }
.bk b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bk small { display: block; color: #475569; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bk.mine { background: var(--brand); border-left-color: #134e4a; color: #fff; }
.bk.mine small { color: #ccfbf1; }
.bk.done { opacity: .55; }
.my-bookings { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.my-bookings li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .93rem; }
.my-bookings form { margin: 0; flex: none; }
details.card > summary { cursor: pointer; margin: 0; }
