:root {
    --bg: #f7f7f5;
    --surface: #ffffff;
    --ink: #202226;
    --muted: #8a8e96;
    --line: #ecece8;
    --orange: #f26b38;
    --orange-soft: #fff0e8;
    --green: #28a475;
    --green-soft: #eaf8f1;
    --blue: #4b85ed;
    --blue-soft: #edf3ff;
    --purple: #8a6de5;
    --shadow: 0 12px 32px rgba(44, 44, 38, .06);
    --radius: 20px;
    font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
    color: var(--ink);
    background: var(--bg);
    font-synthesis: none;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--ink); }
.hidden { display: none !important; }
button, input, textarea, select { font: inherit; }
button { border: 0; cursor: pointer; color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid rgba(242, 107, 56, .25); outline-offset: 2px; }

.app-shell { min-height: 100vh; max-width: 760px; margin: 0 auto; padding-bottom: 94px; }
.topbar { height: 66px; display: flex; align-items: center; justify-content: space-between; padding: 0 22px; background: rgba(247, 247, 245, .94); position: sticky; top: 0; z-index: 10; backdrop-filter: blur(14px); }
.brand-mark { display: flex; align-items: center; gap: 9px; font-weight: 800; letter-spacing: -.03em; font-size: 18px; }
.brand-dot { width: 10px; height: 10px; display: inline-block; border-radius: 50%; background: var(--orange); box-shadow: 5px -4px 0 #ffc08d; }
.topbar-actions { display: flex; gap: 8px; }
.icon-button { background: transparent; position: relative; width: 36px; height: 36px; font-size: 26px; line-height: 1; color: #3a3d42; }
.notification span { position: absolute; top: 0; right: 0; display: grid; place-items: center; width: 17px; height: 17px; border-radius: 50%; background: var(--orange); color: #fff; font-size: 10px; font-weight: 800; }

.page { display: none; padding: 12px 20px 0; animation: page-in .25s ease-out; }
.page.active { display: block; }
@keyframes page-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
.hero-greeting, .page-heading, .profile-hero { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin: 10px 0 22px; }
.hero-greeting h1, .page-heading h1, .profile-hero h1 { margin: 3px 0 4px; font-size: clamp(27px, 6vw, 36px); letter-spacing: -.055em; line-height: 1.08; }
.eyebrow { margin: 0; color: var(--orange); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .12em; }
.muted { margin: 0; color: var(--muted); font-size: 13px; }
.avatar { flex: 0 0 auto; width: 44px; height: 44px; border-radius: 16px; display: grid; place-items: center; color: #fff; background: var(--orange); font-weight: 800; box-shadow: 0 7px 16px rgba(242, 107, 56, .23); }
.avatar.large { width: 64px; height: 64px; border-radius: 22px; font-size: 23px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); overflow: hidden; margin-bottom: 27px; padding: 20px 10px; background: var(--surface); border: 1px solid rgba(229, 229, 224, .7); border-radius: var(--radius); box-shadow: var(--shadow); }
.metric { text-align: center; padding: 0 8px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric-icon { width: 32px; height: 32px; display: grid; place-items: center; margin: 0 auto 7px; border-radius: 10px; font-size: 17px; }
.metric-icon.orange { color: var(--orange); background: var(--orange-soft); }
.metric-icon.blue { color: var(--blue); background: var(--blue-soft); }
.metric-icon.green { color: var(--green); background: var(--green-soft); }
.metric-icon.purple { color: var(--purple); background: #f2effe; }
.metric strong { display: block; font-size: 24px; letter-spacing: -.04em; line-height: 1; }
.metric span { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; white-space: nowrap; }

.section-block { margin: 0 0 25px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 11px; }
.section-heading h2 { margin: 0; font-size: 18px; letter-spacing: -.04em; }
.text-button { background: transparent; color: var(--muted); font-size: 13px; padding: 6px 0; }
.text-button span { color: var(--ink); font-size: 19px; vertical-align: -1px; margin-left: 4px; }
.count-mark { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; margin-left: 4px; color: #df5831; background: #ffe1d7; border-radius: 7px; font-size: 11px; vertical-align: 2px; }

.task-list, .customer-list, .visit-history, .timeline { display: grid; gap: 10px; }
.task-item { display: grid; grid-template-columns: 62px 1fr auto; align-items: center; gap: 12px; padding: 15px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.task-item .task-time { color: var(--orange); font-size: 14px; font-weight: 700; }
.task-item .task-main { min-width: 0; }
.task-item strong, .task-item small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-item strong { font-size: 14px; }
.task-item small { margin-top: 5px; color: var(--muted); font-size: 11px; }
.task-tag { padding: 6px 8px; color: var(--orange); background: var(--orange-soft); border-radius: 8px; font-size: 11px; white-space: nowrap; }
.task-tag.followup { color: var(--blue); background: var(--blue-soft); }
.task-item.done { opacity: .6; }
.task-item.done .task-time { color: var(--green); }
.task-check { width: 26px; height: 26px; border: 1px solid #deded8; border-radius: 50%; background: #fff; color: #fff; }
.task-check:hover { background: var(--green); border-color: var(--green); }

.overdue-block { padding: 17px; margin-left: -4px; margin-right: -4px; background: #fff8f6; border-radius: 18px; }
.overdue-list { display: grid; gap: 0; }
.overdue-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid #f6e5de; }
.overdue-row:last-child { border-bottom: 0; }
.overdue-row strong { display: block; font-size: 13px; }
.overdue-row small { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.overdue-row em { color: #e2603b; font-size: 11px; font-style: normal; white-space: nowrap; }

.timeline { position: relative; padding: 3px 4px 2px 20px; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 11px; bottom: 13px; width: 1px; background: #dcefe5; }
.timeline-item { position: relative; padding: 0 0 15px 15px; }
.timeline-dot { position: absolute; left: -18px; top: 3px; width: 12px; height: 12px; border: 3px solid var(--bg); border-radius: 50%; background: var(--green); box-shadow: 0 0 0 2px #bfe9d6; }
.timeline-dot.followup { background: var(--blue); box-shadow: 0 0 0 2px #cedeff; }
.timeline-item strong { display: block; font-size: 13px; }
.timeline-item p { margin: 4px 0; color: #565c65; font-size: 12px; line-height: 1.6; }
.timeline-item small { color: var(--muted); font-size: 11px; }

.quick-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 14px 9px 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; }
.quick-actions button { display: grid; justify-items: center; gap: 8px; padding: 4px; background: transparent; }
.quick-actions strong { font-size: 11px; font-weight: 600; white-space: nowrap; }
.quick-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 14px; font-size: 23px; }
.quick-icon.orange { color: var(--orange); background: var(--orange-soft); }
.quick-icon.blue { color: var(--blue); background: var(--blue-soft); }
.quick-icon.green { color: var(--green); background: var(--green-soft); }
.quick-icon.purple { color: var(--purple); background: #f2effe; }

.primary-small { padding: 11px 13px; color: #fff; background: var(--orange); border-radius: 12px; font-size: 12px; font-weight: 700; box-shadow: 0 7px 14px rgba(242, 107, 56, .2); }
.search-box { display: flex; align-items: center; gap: 8px; padding: 0 14px; height: 46px; margin-bottom: 13px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; color: var(--muted); }
.search-box span { font-size: 22px; line-height: 1; }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 13px; }
.filter-row { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 17px; padding-bottom: 2px; scrollbar-width: none; }
.filter-row::-webkit-scrollbar { display: none; }
.filter-chip { flex: 0 0 auto; padding: 7px 11px; background: transparent; border: 1px solid #dfdfd9; border-radius: 10px; color: var(--muted); font-size: 11px; }
.filter-chip.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.customer-card { display: grid; gap: 13px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 17px; box-shadow: 0 6px 16px rgba(40, 40, 34, .03); }
.customer-card-top, .customer-card-bottom { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.customer-card h3 { margin: 0; font-size: 15px; letter-spacing: -.03em; }
.customer-card small { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
.level-tag { padding: 5px 8px; color: var(--orange); background: var(--orange-soft); border-radius: 8px; font-size: 10px; white-space: nowrap; }
.level-tag.normal { color: #747a84; background: #f2f3f1; }
.customer-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 10px 0 0; border-top: 1px solid var(--line); }
.customer-stats span, .visit-summary span, .profile-card span { display: block; color: var(--muted); font-size: 10px; }
.customer-stats strong { display: block; margin-top: 4px; font-size: 12px; }
.customer-card-bottom { padding-top: 1px; }
.customer-card-bottom button { padding: 8px 10px; background: var(--orange-soft); border-radius: 9px; color: var(--orange); font-size: 11px; }
.empty-state { padding: 42px 20px; text-align: center; color: var(--muted); font-size: 13px; background: var(--surface); border: 1px dashed #dddcd5; border-radius: 18px; }

.visit-summary, .profile-card { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; padding: 18px 9px; margin-bottom: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; text-align: center; }
.visit-summary > div, .profile-card > div { border-right: 1px solid var(--line); }
.visit-summary > div:last-child, .profile-card > div:last-child { border-right: 0; }
.visit-summary strong, .profile-card strong { display: block; margin-top: 6px; font-size: 23px; letter-spacing: -.04em; }
.visit-history-card { padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 17px; }
.visit-history-card + .visit-history-card { margin-top: 10px; }
.visit-history-card header { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.visit-history-card h3 { margin: 0; font-size: 14px; }
.visit-history-card p { margin: 9px 0 0; color: #5e636a; font-size: 12px; line-height: 1.6; }
.visit-history-card small { color: var(--muted); font-size: 11px; }
.visit-status { padding: 5px 8px; border-radius: 7px; color: var(--green); background: var(--green-soft); font-size: 10px; }
.visit-status.in_progress { color: var(--orange); background: var(--orange-soft); }
.followup-tabs { display: flex; gap: 20px; border-bottom: 1px solid var(--line); margin-bottom: 15px; }
.followup-tabs button { padding: 0 0 11px; background: transparent; color: var(--muted); font-size: 13px; }
.followup-tabs button.active { color: var(--ink); border-bottom: 2px solid var(--orange); font-weight: 700; }
.profile-hero { justify-content: flex-start; margin-top: 25px; }
.settings-row { width: 100%; display: flex; align-items: center; gap: 11px; padding: 16px 3px; border-bottom: 1px solid var(--line); background: transparent; text-align: left; font-size: 13px; }
.settings-row span { color: var(--orange); font-size: 21px; }
.settings-row b { margin-left: auto; color: var(--muted); font-size: 20px; font-weight: 400; }
.version { margin-top: 32px; color: #b1b3b0; text-align: center; font-size: 11px; }
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 22px; background: radial-gradient(circle at 20% 10%, #fff3e9 0, transparent 34%), var(--bg); }
.login-card { width: min(100%, 410px); padding: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; box-shadow: 0 20px 54px rgba(44, 44, 38, .08); }
.login-card .brand-mark { margin-bottom: 30px; }
.login-card h1 { margin: 0 0 8px; font-size: 28px; letter-spacing: -.06em; }
.login-card > p { margin: 0 0 24px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.login-card form { display: grid; gap: 13px; }
.login-card label { display: grid; gap: 6px; color: #656a72; font-size: 11px; font-weight: 600; }
.login-card input { width: 100%; padding: 13px; border: 1px solid #dfdfda; outline: 0; border-radius: 12px; background: #fff; color: var(--ink); font-size: 14px; }
.login-error { min-height: 18px; color: #d95735; font-size: 12px; }
.login-hint { margin-top: 16px !important; color: #b1b3b0 !important; font-size: 11px !important; }

.bottom-nav { position: fixed; z-index: 20; right: 0; bottom: 0; left: 0; display: grid; grid-template-columns: repeat(4, 1fr); max-width: 760px; height: 76px; margin: 0 auto; padding: 8px 14px calc(8px + env(safe-area-inset-bottom)); background: rgba(255, 255, 255, .94); border-top: 1px solid rgba(230, 230, 225, .8); backdrop-filter: blur(18px); }
.nav-item { display: grid; justify-items: center; align-content: center; gap: 3px; background: transparent; color: #92959b; }
.nav-item span { font-size: 23px; line-height: 1; }
.nav-item small { font-size: 10px; }
.nav-item.active { color: var(--orange); font-weight: 700; }

#modal-root { position: relative; z-index: 30; }
.modal-backdrop { position: fixed; inset: 0; display: flex; align-items: flex-end; justify-content: center; padding: 0; background: rgba(30, 31, 28, .44); backdrop-filter: blur(4px); }
.modal-sheet { width: min(100%, 760px); max-height: 92vh; overflow: auto; padding: 19px 20px calc(24px + env(safe-area-inset-bottom)); background: var(--bg); border-radius: 25px 25px 0 0; box-shadow: 0 -12px 40px rgba(0,0,0,.12); animation: sheet-up .25s ease-out; }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 17px; }
.modal-head h2 { margin: 0; font-size: 20px; letter-spacing: -.04em; }
.close-button { width: 34px; height: 34px; border-radius: 50%; background: #ecece8; color: #666b72; font-size: 20px; }
.form-grid { display: grid; gap: 12px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-field { display: grid; gap: 6px; }
.form-field label { color: #656a72; font-size: 11px; font-weight: 600; }
.form-field input, .form-field textarea, .form-field select { width: 100%; padding: 12px; border: 1px solid #dfdfda; outline: 0; border-radius: 12px; background: #fff; color: var(--ink); font-size: 13px; }
.form-field textarea { min-height: 92px; resize: vertical; line-height: 1.6; }
.modal-action { width: 100%; padding: 14px; margin-top: 6px; border-radius: 13px; background: var(--orange); color: #fff; font-size: 14px; font-weight: 800; }
.hint { color: var(--muted); font-size: 11px; line-height: 1.5; }
.map-picker { display: grid; gap: 9px; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.map-picker-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.map-picker-heading strong { font-size: 13px; }
.map-picker-heading span { color: var(--muted); font-size: 10px; }
.map-search-row { display: grid; grid-template-columns: 1fr auto; gap: 7px; }
.map-search-row input { min-width: 0; padding: 10px 11px; border: 1px solid #dfdfda; outline: 0; border-radius: 10px; background: #fff; color: var(--ink); font-size: 12px; }
.map-search-row button, .map-picker-footer button { padding: 9px 12px; border-radius: 10px; background: var(--ink); color: #fff; font-size: 11px; font-weight: 700; }
.map-search-row button:disabled { opacity: .55; }
.map-place-results { display: grid; gap: 4px; }
.map-result { overflow: hidden; padding: 6px 8px; border-radius: 8px; background: #f5f5f2; color: #666b72; text-align: left; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
.map-search-empty { color: var(--muted); font-size: 10px; }
.customer-map { height: 220px; overflow: hidden; border-radius: 12px; background: #e7f0e8; }
.map-picker-footer { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.map-picker-footer span { min-width: 0; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
.map-picker-footer button { flex: 0 0 auto; background: var(--orange); }
.location-panel { overflow: hidden; padding: 13px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.location-card { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.location-card strong { display: block; font-size: 13px; }
.location-card small { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.location-ok { color: var(--green); font-size: 11px; font-weight: 700; white-space: nowrap; }
.map-preview { position: relative; height: 125px; overflow: hidden; margin-top: 12px; border-radius: 12px; background: #e7f0e8; background-image: linear-gradient(27deg, transparent 44%, rgba(255,255,255,.8) 45%, rgba(255,255,255,.8) 48%, transparent 49%), linear-gradient(115deg, transparent 45%, rgba(201,222,204,.9) 46%, rgba(201,222,204,.9) 48%, transparent 49%), linear-gradient(0deg, transparent 70%, rgba(255,255,255,.9) 71%, rgba(255,255,255,.9) 73%, transparent 74%); background-size: 110px 110px, 130px 130px, 100% 70px; }
.map-preview::after { content: ""; position: absolute; top: 50%; left: 50%; width: 25px; height: 25px; border: 5px solid #fff; border-radius: 50% 50% 50% 0; background: var(--orange); transform: translate(-50%, -65%) rotate(-45deg); box-shadow: 0 5px 14px rgba(242,107,56,.35); }
.detail-customer { display: grid; gap: 15px; }
.detail-hero { padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 17px; }
.detail-hero h3 { margin: 0; font-size: 19px; }
.detail-hero p { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.detail-chip-row { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 13px; }
.detail-chip { padding: 6px 9px; background: #f2f3f1; border-radius: 8px; color: #686d74; font-size: 10px; }
.detail-section { padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 17px; }
.detail-section h4 { margin: 0 0 11px; font-size: 13px; }
.contact-line { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 12px; }
.contact-line:first-of-type { border-top: 0; padding-top: 0; }
.contact-line span { color: var(--muted); }
.contact-line strong { text-align: right; font-weight: 600; }

.toast { position: fixed; z-index: 50; left: 50%; bottom: 92px; padding: 11px 15px; border-radius: 12px; background: #272a2d; color: #fff; font-size: 12px; box-shadow: var(--shadow); transform: translateX(-50%); animation: toast-in .2s ease-out; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

@media (min-width: 761px) {
    .app-shell { max-width: 1120px; padding-bottom: 24px; }
    .topbar { padding: 0 32px; }
    .page { margin-left: 86px; padding: 24px 32px 0; }
    .bottom-nav { position: fixed; top: 66px; right: auto; bottom: auto; left: calc(50% - 560px); display: flex; flex-direction: column; width: 72px; height: 210px; padding: 12px 8px; background: transparent; border: 0; box-shadow: none; backdrop-filter: none; }
    .nav-item { width: 56px; height: 52px; border-radius: 14px; }
    .nav-item.active { background: var(--orange-soft); }
    .metric-grid { max-width: 720px; }
    .section-block { max-width: 720px; }
    .customer-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .page-heading, .hero-greeting, .profile-hero { max-width: 900px; }
}

@media (max-width: 390px) {
    .page { padding-left: 15px; padding-right: 15px; }
    .topbar { padding-left: 16px; padding-right: 16px; }
    .metric-grid { padding-left: 4px; padding-right: 4px; }
    .metric strong { font-size: 21px; }
    .metric span { font-size: 10px; }
    .task-item { grid-template-columns: 52px 1fr auto; gap: 8px; padding-left: 11px; padding-right: 11px; }
}
