:root {
  --navy: #10233e;
  --navy-2: #1a3b60;
  --gold: #c8a45a;
  --gold-soft: #f7efdd;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f4f6f9;
  --card: #ffffff;
  --green: #16794b;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.55;
}
.hidden { display: none !important; }
.app { max-width: 560px; margin: 0 auto; min-height: 100vh; background: var(--bg); }
.muted { color: var(--muted); }
button, input, select { font: inherit; }
button { cursor: pointer; }

/* Login */
.login-view { min-height: 100vh; padding: 7vh 20px 24px; background: radial-gradient(900px 400px at 10% 0%, #dce8f7 0%, transparent 55%), var(--bg); }
.login-top { text-align: center; margin-bottom: 24px; }
.brand-mark { width: 58px; height: 58px; margin: 0 auto 10px; border-radius: 18px; display: grid; place-items: center; background: linear-gradient(145deg, var(--navy), var(--navy-2)); color: #fff; font-size: 28px; font-weight: 800; box-shadow: 0 12px 30px rgba(16,35,62,.22); }
.brand-name { font-size: 21px; font-weight: 800; color: var(--navy); letter-spacing: .5px; }
.brand-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.login-card { background: var(--card); border: 1px solid rgba(16,35,62,.08); border-radius: 20px; padding: 24px 20px; box-shadow: 0 18px 44px rgba(16,35,62,.10); }
.login-card h1 { margin: 0 0 6px; font-size: 22px; color: var(--navy); }
.login-card p { margin: 0 0 18px; font-size: 13px; line-height: 1.6; }
label { display: block; font-size: 12px; font-weight: 700; color: #374151; margin: 0 0 7px; }
input, select { width: 100%; height: 48px; border: 1px solid var(--line); border-radius: 12px; padding: 0 13px; background: #fff; color: var(--ink); outline: none; }
input:focus, select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(200,164,90,.16); }
.phone-row { display: flex; gap: 9px; }
.phone-row input { flex: 1; min-width: 0; }
.ghost-btn { flex: 0 0 112px; height: 48px; border: 1px solid var(--navy); border-radius: 12px; background: #fff; color: var(--navy); font-size: 13px; font-weight: 700; }
.ghost-btn:disabled { opacity: .45; cursor: default; }
.primary-btn { width: 100%; height: 50px; margin-top: 18px; border: 0; border-radius: 13px; background: linear-gradient(135deg, var(--navy), var(--navy-2)); color: #fff; font-size: 16px; font-weight: 800; letter-spacing: .5px; }
.primary-btn:disabled { opacity: .55; }
.field-gap { height: 14px; }
.notice { display: none; margin-top: 12px; padding: 10px 12px; border-radius: 10px; font-size: 12px; line-height: 1.6; }
.notice.show { display: block; }
.notice.info { background: #f0f7ff; border: 1px solid #d6e6fb; color: #1e4f8a; }
.notice.error { background: #fff1f2; border: 1px solid #fecdd3; color: #b42318; }
.notice code { font-size: 17px; letter-spacing: 3px; font-weight: 800; color: var(--navy); }
.login-foot { text-align: center; font-size: 11px; line-height: 1.7; color: #9ca3af; margin-top: 18px; }

/* Demo-only login: no SMS gateway in local demos. */
.demo-login { margin-top: 2px; }
.demo-badge { display: inline-block; padding: 4px 10px; border-radius: 999px; background: var(--gold-soft); color: #7a5a1e; font-size: 11px; font-weight: 800; letter-spacing: .4px; }
.demo-copy { margin: 10px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.demo-account { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; padding: 12px 14px; border: 1px dashed #cbd5e1; border-radius: 12px; background: #f8fafc; }
.demo-account strong { color: var(--navy); font-size: 16px; }
.demo-account span { color: #334155; font-size: 15px; font-weight: 700; letter-spacing: 1px; }
.demo-login .primary-btn { margin-top: 14px; }

/* Main */
.main-view, .detail-view { padding: 0 16px 28px; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 20px 2px 14px; }
.topbar-kicker { font-size: 11px; color: var(--gold); font-weight: 800; letter-spacing: 1.4px; }
.topbar-title { font-size: 22px; font-weight: 800; color: var(--navy); line-height: 1.25; }
.icon-btn { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 50%; background: #fff; color: var(--navy); font-size: 22px; line-height: 1; display: grid; place-items: center; }
.identity-strip { display: flex; align-items: center; justify-content: space-between; background: #fff; border: 1px solid rgba(16,35,62,.07); border-radius: 16px; padding: 13px 15px; margin-bottom: 14px; }
.identity-strip strong { display: block; font-size: 15px; }
.identity-strip .muted { font-size: 12px; }
.count-pill { background: var(--gold-soft); color: #7a5a1e; border-radius: 999px; padding: 5px 11px; font-size: 12px; font-weight: 700; }
.case-list { display: grid; gap: 12px; }
.case-card { width: 100%; text-align: left; border: 1px solid rgba(16,35,62,.08); border-radius: 18px; background: #fff; padding: 16px; box-shadow: 0 8px 22px rgba(16,35,62,.05); }
.case-card:active { transform: scale(.995); }
.case-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.case-no { font-size: 11px; color: var(--gold); font-weight: 800; letter-spacing: .4px; }
.case-title { font-size: 16px; font-weight: 800; color: var(--navy); margin: 3px 0 0; line-height: 1.4; }
.stage-badge { flex: 0 0 auto; background: #eef4fb; color: #1d4f80; border-radius: 999px; padding: 5px 10px; font-size: 11px; font-weight: 700; }
.progress { height: 7px; border-radius: 999px; background: #edf1f5; margin: 14px 0 8px; overflow: hidden; }
.progress span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--gold), #d9bd83); }
.case-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--muted); }
.case-next { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); font-size: 12px; color: #475569; }
.case-next b { color: var(--navy); }
.empty-state { text-align: center; padding: 50px 18px; color: var(--muted); }
.empty-mark { width: 50px; height: 50px; border-radius: 50%; background: #e9eef5; color: #8ba0b8; display: grid; place-items: center; margin: 0 auto 12px; font-weight: 800; }
.empty-state h3 { margin: 0 0 4px; color: var(--navy); font-size: 16px; }
.empty-state p { margin: 0; font-size: 12px; }
.page-note { text-align: center; color: #9ca3af; font-size: 11px; line-height: 1.7; margin: 22px 8px 0; }

/* Detail */
.detail-topbar { justify-content: flex-start; gap: 10px; padding-top: 16px; }
.detail-topbar-main { min-width: 0; }
.detail-topbar .topbar-title { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.detail-body { display: grid; gap: 12px; }
.hero-card { background: linear-gradient(145deg, var(--navy), var(--navy-2)); color: #fff; border-radius: 20px; padding: 20px 18px 16px; box-shadow: 0 16px 34px rgba(16,35,62,.22); }
.hero-card .case-no { color: #e6cf9e; }
.hero-card h2 { margin: 5px 0 8px; font-size: 20px; line-height: 1.4; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.hero-meta span { background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.16); border-radius: 999px; padding: 4px 9px; font-size: 11px; color: #f2f6fb; }
.hero-progress { height: 6px; background: rgba(255,255,255,.16); border-radius: 999px; margin-top: 16px; overflow: hidden; }
.hero-progress span { display: block; height: 100%; border-radius: 999px; background: var(--gold); }
.hero-progress-label { display: flex; justify-content: space-between; font-size: 11px; color: #c9d6e6; margin-top: 6px; }
.card { background: #fff; border: 1px solid rgba(16,35,62,.08); border-radius: 18px; padding: 16px; box-shadow: 0 8px 22px rgba(16,35,62,.04); }
.card h3 { margin: 0 0 10px; font-size: 14px; color: var(--navy); }
.next-step { border-left: 3px solid var(--gold); background: #fffaf0; border-radius: 0 12px 12px 0; padding: 11px 12px; font-size: 13px; line-height: 1.65; color: #5b4a27; }
.stage-map { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin-top: 4px; }
.stage-cell { border-radius: 10px; background: #f5f7fa; color: #9aa7b6; padding: 7px 4px; text-align: center; font-size: 10px; line-height: 1.3; }
.stage-cell.done { background: #edf7f1; color: var(--green); }
.stage-cell.current { background: var(--navy); color: #fff; font-weight: 700; box-shadow: 0 4px 10px rgba(16,35,62,.18); }
.appointment { display: flex; gap: 11px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.appointment:last-child { border-bottom: 0; padding-bottom: 0; }
.appointment-time { flex: 0 0 78px; font-size: 12px; font-weight: 800; color: var(--navy); line-height: 1.4; }
.appointment-main { min-width: 0; flex: 1; }
.appointment-main strong { display: block; font-size: 13px; }
.appointment-main span { font-size: 11px; color: var(--muted); }
.appointment-action { flex: 0 0 auto; align-self: center; text-align: right; }
.appt-cancel {
    border: 1px solid #e0b0a4;
    background: #fff;
    color: #a9442b;
    border-radius: 999px;
    padding: 4px 9px;
    font-size: 11px;
    line-height: 1.4;
    cursor: pointer;
}
.appt-cancel:hover { background: #a9442b; color: #fff; }
.appt-hint { font-size: 10px; color: var(--muted); line-height: 1.4; }
.timeline { position: relative; margin: 2px 0 0 6px; padding-left: 18px; }
.timeline::before { content: ""; position: absolute; left: 4px; top: 4px; bottom: 4px; width: 1px; background: var(--line); }
.timeline-item { position: relative; padding: 0 0 14px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before { content: ""; position: absolute; left: -18px; top: 4px; width: 9px; height: 9px; border-radius: 50%; background: #cbd5e1; border: 2px solid #fff; box-shadow: 0 0 0 1px #cbd5e1; }
.timeline-item:first-child::before { background: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.timeline-item strong { display: block; font-size: 13px; color: var(--navy); }
.timeline-item span { font-size: 11px; color: var(--muted); }
.team-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.team-row:last-child { border-bottom: 0; }
.team-row strong { font-size: 13px; }
.team-row span { font-size: 11px; color: var(--muted); }
.kv-row { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 12px; }
.kv-row:last-child { border-bottom: 0; }
.kv-row span { color: var(--muted); flex: 0 0 auto; }
.kv-row strong { text-align: right; font-weight: 600; color: #334155; word-break: break-all; }
.contact-card { background: #f8fafc; }
.contact-card p { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.7; }
.detail-foot { text-align: center; font-size: 11px; color: #9ca3af; line-height: 1.7; padding: 8px 16px 24px; }
@media (min-width: 560px) {
  .app { min-height: 100vh; box-shadow: 0 0 60px rgba(16,35,62,.10); }
  .login-view { min-height: 100vh; }
}

/* Service closure: messages, shared documents, uploads, appointment request */
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card-head h3 { margin: 0; }
.card-head .muted { font-size: 11px; line-height: 1.5; text-align: right; }
.message-card { margin-bottom: 14px; }
.message-list, .service-list { display: grid; gap: 8px; }
.message-row, .service-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.message-row:last-child, .service-row:last-child { border-bottom: 0; padding-bottom: 0; }
.message-type { flex: 0 0 auto; border-radius: 999px; padding: 3px 8px; background: var(--gold-soft); color: #7a5a1e; font-size: 10px; font-weight: 800; }
.message-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.message-main strong { font-size: 13px; color: var(--navy); line-height: 1.4; }
.message-main span { font-size: 11px; color: var(--muted); }
.section-label { margin: 4px 2px 9px; color: #8a97a8; font-size: 11px; font-weight: 800; letter-spacing: 1.2px; }
.service-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.service-main strong { font-size: 13px; color: var(--navy); line-height: 1.4; }
.service-main span { font-size: 11px; color: var(--muted); line-height: 1.5; }
.service-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.service-status, .service-done { flex: 0 0 auto; border-radius: 999px; padding: 3px 8px; background: #edf7f1; color: var(--green); font-size: 10px; font-weight: 700; }
.service-done { background: #eef4fb; color: #1d4f80; }
.service-empty { margin: 0; font-size: 12px; }
.mini-btn { height: 30px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--navy); font-size: 11px; font-weight: 700; }
.mini-btn.primary { border-color: var(--navy); background: var(--navy); color: #fff; }
.mini-btn:disabled { opacity: .55; }
.service-form { display: grid; gap: 8px; margin-top: 10px; }
.service-form label { margin: 0; }
.service-btn { height: 42px; border: 0; border-radius: 11px; background: linear-gradient(135deg, var(--navy), var(--navy-2)); color: #fff; font-size: 13px; font-weight: 800; }
.service-btn:disabled { opacity: .55; }
.service-form .notice { margin-top: 0; }

/* Client-facing service team contacts */
.team-card { margin-bottom: 14px; }
.team-list .team-row:first-child { padding-top: 0; }
.team-list .team-row:last-child { border-bottom: 0; padding-bottom: 0; }
.team-row > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.team-row strong { display: block; color: var(--navy); }
.team-phone { flex: 0 0 auto; color: var(--navy); font-size: 12px; font-weight: 800; text-decoration: none; white-space: nowrap; }
.team-phone::before { content: "☎ "; }
.team-note { flex: 0 0 auto; color: var(--muted); font-size: 11px; }
