/* 盛浩机械 · 移动端 H5 */
:root {
    --green: #0F5132;
    --green-accent: #1B7A4B;
    --green-soft: #E6F4EC;
    --amber: #B26A00;
    --amber-soft: #FDF3E2;
    --red: #B3261E;
    --red-soft: #FBEAE8;
    --blue: #1D5FAF;
    --blue-soft: #EAF1FB;
    --ink: #1A1C1E;
    --muted: #6B7280;
    --line: #E4E9E6;
    --bg: #F4F6F5;
    --card: #FFFFFF;
    --radius: 14px;
    --nav-h: 58px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

body { min-height: 100vh; min-height: 100dvh; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
input, select, textarea { outline: none; }
a { color: var(--green-accent); text-decoration: none; }

/* ---------------------------------------------------------------- 登录 */
.login {
    min-height: 100vh;
    min-height: 100dvh;
    background: linear-gradient(160deg, #0F5132 0%, #15804D 46%, #F4F6F5 46.2%, #F4F6F5 100%);
    padding: calc(48px + env(safe-area-inset-top)) 22px calc(24px + env(safe-area-inset-bottom));
}
.login-brand { color: #fff; text-align: center; padding-bottom: 28px; }
.login-logo {
    width: 64px; height: 64px;
    margin: 0 auto 12px;
    border-radius: 18px;
    background: rgba(255, 255, 255, .16);
    border: 1px solid rgba(255, 255, 255, .28);
    display: flex; align-items: center; justify-content: center;
    font-size: 28px; font-weight: 700;
}
.login-brand h1 { margin: 0; font-size: 22px; letter-spacing: 1px; }
.login-brand p { margin: 6px 0 0; font-size: 12px; opacity: .85; }
.login-card {
    background: #fff;
    border-radius: 18px;
    padding: 22px 20px;
    box-shadow: 0 12px 34px rgba(9, 52, 32, .16);
}
.login-card .field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 11px 12px;
    background: #FAFBFA;
    font-size: 15px;
}
.field input:focus, .field select:focus, .field textarea:focus {
    border-color: var(--green-accent);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(27, 122, 75, .10);
}
.login-error { color: var(--red); font-size: 12px; min-height: 18px; margin: 2px 0 8px; }
.login-foot { text-align: center; color: var(--muted); font-size: 11px; margin-top: 22px; }

/* ---------------------------------------------------------------- 框架 */
.app-shell { min-height: 100vh; min-height: 100dvh; }
.app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(255, 255, 255, .96);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
    padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.app-header h1 { margin: 0; font-size: 17px; font-weight: 600; flex: 1; }
.app-header .sub { font-size: 11px; color: var(--muted); margin-top: 1px; }
.icon-btn {
    width: 34px; height: 34px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: var(--green);
    background: var(--green-soft);
}
.app-main { padding: 12px 12px calc(var(--nav-h) + 20px + env(safe-area-inset-bottom)); }
.app-main.flush { padding-top: 0; }

.app-nav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 30;
    display: flex;
    background: rgba(255, 255, 255, .98);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -4px 18px rgba(15, 81, 50, .06);
}
.app-nav button {
    flex: 1;
    height: var(--nav-h);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--muted);
    font-size: 10px;
}
.app-nav button svg { width: 21px; height: 21px; }
.app-nav button.active { color: var(--green); font-weight: 600; }
.app-nav .badge {
    position: absolute;
    transform: translate(14px, -12px);
    background: var(--red);
    color: #fff;
    border-radius: 9px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    font-size: 10px;
    line-height: 16px;
    font-weight: 600;
}

/* ---------------------------------------------------------------- 通用 */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 12px;
}
.card-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}
.card-head h2 { margin: 0; font-size: 14px; font-weight: 600; flex: 1; }
.card-head .count { font-size: 11px; color: var(--muted); }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.stat {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 13px 14px;
}
.stat span { font-size: 11px; color: var(--muted); }
.stat strong { display: block; font-size: 23px; line-height: 1.25; margin-top: 2px; color: var(--green); }
.stat em { font-style: normal; font-size: 11px; color: var(--muted); }

.empty { text-align: center; color: var(--muted); font-size: 12px; padding: 26px 10px; }

.pill {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
}
.pill.pending { background: #EEF1F0; color: #4B5563; }
.pill.in_progress { background: var(--green-soft); color: var(--green-accent); }
.pill.paused { background: var(--amber-soft); color: var(--amber); }
.pill.completed { background: var(--blue-soft); color: var(--blue); }
.pill.draft { background: #EEF1F0; color: #4B5563; }
.pill.released { background: var(--green-soft); color: var(--green-accent); }
.pill.shipped { background: var(--blue-soft); color: var(--blue); }
.pill.closed, .pill.cancelled { background: #EEF1F0; color: #9AA3AD; }
.pill.urgent { background: var(--red-soft); color: var(--red); }

.progress {
    height: 6px;
    background: #EDF1EF;
    border-radius: 999px;
    overflow: hidden;
    margin: 8px 0 6px;
}
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, #1B7A4B, #34A46A); border-radius: 999px; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: 10px;
    background: #F1F4F2;
    color: var(--ink);
    font-size: 14px;
    font-weight: 500;
}
.btn:active { opacity: .82; }
.btn-primary { background: var(--green); color: #fff; }
.btn-ghost { background: #fff; border: 1px solid var(--line); color: var(--green); }
.btn-danger { background: var(--red-soft); color: var(--red); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 12px; border-radius: 8px; }
.btn:disabled { opacity: .5; }

.filterbar {
    position: sticky;
    top: calc(54px + env(safe-area-inset-top));
    z-index: 15;
    background: var(--bg);
    padding: 8px 0;
    margin: -4px 0 4px;
}
.chips { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
    flex-shrink: 0;
    padding: 6px 12px;
    border-radius: 999px;
    background: #fff;
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: 12px;
}
.chip.active { background: var(--green); border-color: var(--green); color: #fff; font-weight: 500; }

.searchbar { position: relative; margin: 8px 0 10px; }
.searchbar input {
    width: 100%;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 10px;
    padding: 10px 12px 10px 34px;
    font-size: 13px;
}
.searchbar svg {
    position: absolute;
    left: 11px; top: 50%;
    transform: translateY(-50%);
    width: 15px; height: 15px;
    color: var(--muted);
}

.task-card, .order-card {
    display: block;
    width: 100%;
    text-align: left;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 10px;
}
.task-card:active, .order-card:active { background: #FAFCFB; }
.row1 { display: flex; align-items: center; gap: 8px; }
.row1 strong { font-size: 14px; font-weight: 600; }
.row1 .order-no { margin-left: auto; font-size: 11px; color: var(--muted); }
.row2 { font-size: 12px; color: #39423D; margin-top: 4px; }
.row3 { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 3px; }
.row4 { font-size: 11px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.row4 .money { color: var(--green-accent); font-weight: 600; }
.row-actions { display: flex; gap: 8px; margin-top: 10px; }
.row-actions .btn { flex: 1; }

.simple-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 0;
    border-bottom: 1px dashed var(--line);
    font-size: 12px;
}
.simple-row:last-child { border-bottom: none; }
.simple-row .grow { flex: 1; min-width: 0; }
.simple-row .grow strong { display: block; font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.simple-row .grow span { color: var(--muted); font-size: 11px; }
.simple-row .right { text-align: right; color: var(--muted); font-size: 11px; white-space: nowrap; }

/* ---------------------------------------------------------------- 弹层 */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(13, 30, 22, .42);
    z-index: 50;
    opacity: 0;
    transition: opacity .2s ease;
}
.overlay.show { opacity: 1; }
.sheet {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 51;
    background: var(--bg);
    border-radius: 18px 18px 0 0;
    max-height: 92vh;
    max-height: 92dvh;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform .24s cubic-bezier(.22, .8, .3, 1);
}
.sheet.show { transform: translateY(0); }
.sheet-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px 10px;
    background: #fff;
    border-radius: 18px 18px 0 0;
    border-bottom: 1px solid var(--line);
}
.sheet-head h2 { margin: 0; font-size: 15px; flex: 1; font-weight: 600; }
.sheet-body { overflow-y: auto; padding: 12px 14px calc(20px + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.kv:last-child { border-bottom: none; }
.kv span { color: var(--muted); flex-shrink: 0; font-size: 12px; }
.kv strong { font-weight: 500; text-align: right; }

.section-title { font-size: 12px; color: var(--muted); margin: 14px 0 6px; }

/* ---------------------------------------------------------------- 扫码 */
.scan-hero {
    background: linear-gradient(140deg, #0F5132, #1B7A4B);
    color: #fff;
    border-radius: 16px;
    padding: 18px;
    margin-bottom: 12px;
}
.scan-hero h2 { margin: 0 0 4px; font-size: 16px; }
.scan-hero p { margin: 0; font-size: 12px; opacity: .85; }
.scan-input { display: flex; gap: 8px; margin-top: 12px; }
.scan-input input {
    flex: 1;
    border: none;
    border-radius: 10px;
    padding: 11px 12px;
    background: rgba(255, 255, 255, .94);
    color: var(--ink);
    font-size: 14px;
}
.scan-input .btn { background: #fff; color: var(--green); font-weight: 600; }
.scan-tip { font-size: 11px; color: var(--muted); margin: 6px 2px 0; }

.camera-mask {
    position: fixed;
    inset: 0;
    z-index: 60;
    background: #000;
    display: flex;
    flex-direction: column;
}
.camera-mask video { flex: 1; width: 100%; object-fit: cover; }
.camera-mask .cam-bar {
    padding: calc(10px + env(safe-area-inset-top)) 16px 18px;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(0, 0, 0, .55);
}
.camera-mask .cam-bar strong { flex: 1; font-size: 14px; font-weight: 500; }
.camera-frame {
    position: absolute;
    left: 12%; right: 12%; top: 32%;
    height: 32%;
    border: 2px solid rgba(255, 255, 255, .9);
    border-radius: 16px;
    box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35);
}

/* ---------------------------------------------------------------- 我的 */
.profile-card {
    background: linear-gradient(140deg, #0F5132, #1B7A4B);
    color: #fff;
    border-radius: 16px;
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 12px;
}
.profile-avatar {
    width: 52px; height: 52px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .18);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; font-weight: 700;
    flex-shrink: 0;
}
.profile-card strong { display: block; font-size: 17px; }
.profile-card span { font-size: 11px; opacity: .85; }
.menu-list { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: left;
    padding: 13px 14px;
    border-bottom: 1px solid var(--line);
    font-size: 14px;
    color: var(--ink);
}
.menu-item:last-child { border-bottom: none; }
.menu-item:active { background: #F8FAF9; }
.menu-item .chev { margin-left: auto; color: #B9C1BC; }
.menu-item .hint { margin-left: auto; font-size: 11px; color: var(--muted); }

/* ---------------------------------------------------------------- 提示 */
.toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--nav-h) + 26px + env(safe-area-inset-bottom));
    transform: translate(-50%, 12px);
    z-index: 80;
    background: rgba(20, 32, 26, .92);
    color: #fff;
    font-size: 13px;
    padding: 9px 16px;
    border-radius: 999px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease, transform .2s ease;
    max-width: 82vw;
    text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.loading-bar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 2px;
    z-index: 90;
    background: transparent;
    overflow: hidden;
    display: none;
}
.loading-bar.show { display: block; }
.loading-bar::before {
    content: "";
    display: block;
    width: 40%;
    height: 100%;
    background: var(--green-accent);
    animation: loading 1.1s ease-in-out infinite;
}
@keyframes loading {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(260%); }
}

.skeleton {
    background: linear-gradient(90deg, #EDF1EF 25%, #F6F8F7 37%, #EDF1EF 63%);
    background-size: 400% 100%;
    animation: shimmer 1.3s ease infinite;
    border-radius: 10px;
    height: 68px;
    margin-bottom: 10px;
}
@keyframes shimmer {
    0% { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}

@media (min-width: 640px) {
    .app-main { max-width: 640px; margin: 0 auto; }
    .sheet { max-width: 640px; margin: 0 auto; border-radius: 18px 18px 0 0; }
    .app-nav { max-width: 640px; margin: 0 auto; }
}
