:root {
  --ink: #17312b; --muted: #65746f; --paper: #f3f0e8; --card: #fffdf8;
  --green: #173f36; --green-2: #245d4f; --mint: #dce9df; --line: #d7d4ca;
  --orange: #e6782f; --orange-soft: #fff0e4; --red: #ad382d; --shadow: 0 12px 35px rgba(24, 48, 41, .09);
  --radius: 18px; font-family: "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; color: var(--ink); background: var(--paper); }
body { background-image: radial-gradient(circle at 95% 5%, rgba(230,120,47,.08), transparent 24rem), linear-gradient(rgba(23,63,54,.025) 1px, transparent 1px); background-size: auto, 100% 28px; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(440px, 100%); background: var(--card); border: 1px solid rgba(23,63,54,.14); border-radius: 28px; padding: 34px; box-shadow: var(--shadow); }
.brand-mark { display: inline-grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; background: var(--green); color: white; font-weight: 900; letter-spacing: -2px; }
.eyebrow { color: var(--orange); text-transform: uppercase; letter-spacing: .16em; font-size: 11px; font-weight: 800; margin: 18px 0 7px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(26px, 5vw, 38px); line-height: 1.12; letter-spacing: -.04em; margin-bottom: 10px; }
h2 { font-size: 22px; letter-spacing: -.02em; }
.muted { color: var(--muted); }
.field { display: grid; gap: 7px; margin: 16px 0; }
.field label { font-size: 13px; font-weight: 700; }
.field-feedback { color: var(--muted); font-size: 11px; line-height: 1.5; }
.field-feedback.success { color: var(--green-2); font-weight: 700; }
.field-feedback.error { color: var(--red); font-weight: 700; }
input, select { width: 100%; min-height: 46px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 13px; color: var(--ink); background: white; outline: none; }
input:focus, select:focus { border-color: var(--green-2); box-shadow: 0 0 0 3px rgba(36,93,79,.12); }
.button { min-height: 44px; border: 0; border-radius: 12px; padding: 10px 16px; background: var(--green); color: white; font-weight: 800; }
.button:hover { background: var(--green-2); }
.button.secondary { color: var(--green); background: var(--mint); }
.button.ghost { color: var(--green); background: transparent; border: 1px solid var(--line); }
.button.orange { background: var(--orange); }
.button.danger { background: var(--red); }
.button:disabled { opacity: .45; cursor: not-allowed; }
.button.full { width: 100%; }
.app-header { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px max(18px, calc((100vw - 1180px)/2)); background: rgba(243,240,232,.92); backdrop-filter: blur(16px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand > div:last-child { min-width: 0; }
.brand strong { display: block; }
.brand small { color: var(--muted); }
.user-box { text-align: right; font-size: 13px; }
.user-box button { border: 0; color: var(--muted); background: transparent; padding: 3px; }
.layout { width: min(1180px, calc(100% - 28px)); margin: 22px auto 100px; }
.nav { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 13px; scrollbar-width: none; }
.nav button { white-space: nowrap; border: 1px solid var(--line); border-radius: 999px; padding: 9px 15px; color: var(--muted); background: rgba(255,255,255,.45); font-weight: 700; }
.nav button.active { border-color: var(--green); background: var(--green); color: white; }
.toolbar { display: flex; align-items: center; gap: 10px; margin: 8px 0 20px; }
.toolbar input { flex: 1; min-width: 0; }
.toolbar .button { flex: 0 0 auto; white-space: nowrap; }
.panel { background: var(--card); border: 1px solid rgba(23,63,54,.12); border-radius: var(--radius); box-shadow: 0 6px 22px rgba(24,48,41,.055); }
.panel-head { display: flex; align-items: start; justify-content: space-between; gap: 16px; padding: 20px; border-bottom: 1px solid var(--line); }
.panel-body { padding: 20px; }
.elder-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.elder-card { padding: 18px; position: relative; }
.elder-top { display: flex; justify-content: space-between; gap: 12px; }
.elder-name { font-size: 19px; font-weight: 900; }
.elder-meta { color: var(--muted); font-size: 13px; line-height: 1.7; margin-top: 8px; overflow-wrap: anywhere; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 13px; }
.badge { display: inline-flex; align-items: center; min-height: 25px; border-radius: 999px; padding: 3px 9px; background: #eeece5; color: var(--muted); font-size: 11px; font-weight: 800; }
.badge.green { background: var(--mint); color: var(--green); }
.badge.orange { background: var(--orange-soft); color: #9a4b17; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 15px; }
.card-actions .button { min-height: 38px; padding: 7px 11px; font-size: 13px; }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.stat { padding: 18px; }
.stat span { display: block; font-size: 12px; color: var(--muted); }
.stat strong { display: block; margin-top: 7px; font-size: 25px; letter-spacing: -.03em; }
.stat.warn strong { color: var(--orange); }
.modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: end center; background: rgba(13,31,27,.48); }
.modal.center { place-items: center; padding: 18px; }
.password-card { width: min(430px, 100%); max-height: calc(100vh - 36px); overflow: auto; padding: 22px; background: var(--card); border-radius: 22px; box-shadow: var(--shadow); }
.password-head { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.password-head .icon-btn { color: var(--green); background: var(--mint); }
.sheet { width: min(760px, 100%); height: min(92vh, 950px); display: flex; flex-direction: column; background: var(--paper); border-radius: 24px 24px 0 0; box-shadow: 0 -20px 55px rgba(0,0,0,.16); overflow: hidden; }
.sheet-head { padding: 17px 18px; background: var(--green); color: white; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet-head > div { min-width: 0; }
.sheet-head h2 { margin: 0; font-size: 18px; line-height: 1.3; overflow-wrap: anywhere; }
.sheet-head .icon-btn { flex: 0 0 auto; }
.icon-btn { border: 0; background: rgba(255,255,255,.13); color: white; width: 38px; height: 38px; border-radius: 11px; font-size: 22px; }
.sheet-scroll { overflow: auto; flex: 1; padding: 14px; }
.cap-meter { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin-bottom: 12px; }
.cap-line { display: flex; justify-content: space-between; font-size: 13px; font-weight: 700; }
.meter { display: block; appearance: none; width: 100%; height: 8px; border: 0; border-radius: 99px; overflow: hidden; margin-top: 10px; background: #e4e0d7; }
.meter::-webkit-progress-bar { background: #e4e0d7; }
.meter::-webkit-progress-value { background: var(--green-2); border-radius: 99px; }
.meter.over::-webkit-progress-value { background: var(--red); }
.meter::-moz-progress-bar { background: var(--green-2); }
.meter.over::-moz-progress-bar { background: var(--red); }
.rule-box { display: grid; gap: 7px; margin-bottom: 12px; }
.environment-box { margin-bottom: 12px; padding: 14px; border: 1px solid #b7d8cb; border-radius: 16px; background: var(--card); }
.environment-box.no-wifi { border-color: #e2a26d; background: #fffaf5; }
.environment-head { display: flex; align-items: start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.environment-head strong, .environment-head small { display: block; }
.environment-head small { margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.environment-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.environment-grid > div > span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 11px; font-weight: 800; }
.environment-options { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.environment-choice { min-height: 40px; border: 1px solid var(--line); border-radius: 10px; background: white; color: var(--green); font-weight: 800; }
.environment-choice.selected { border-color: var(--green); background: var(--green); color: white; box-shadow: 0 0 0 2px rgba(36,93,79,.12); }
.environment-warning { margin-top: 11px; padding: 9px 10px; border-left: 4px solid var(--red); border-radius: 8px; background: #fbe9e5; color: #7c2922; font-size: 11px; line-height: 1.55; }
.hidden { display: none !important; }
.recommendation-box { margin-bottom: 12px; padding: 13px; border: 1px solid #b7d8cb; border-radius: 15px; background: linear-gradient(135deg, #eef8f3, #fffdf8); }
.recommendation-box strong, .recommendation-box small { display: block; }
.recommendation-box strong { color: var(--green); font-size: 14px; }
.recommendation-box small { margin-top: 5px; color: var(--muted); line-height: 1.55; }
.recommendation-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.recommendation-actions .button { min-height: 44px; padding: 9px 10px; line-height: 1.35; white-space: normal; }
.recommendation-actions.single { grid-template-columns: 1fr; }
.recommendation-note { margin-bottom: 12px; padding: 11px 13px; border-left: 4px solid #87938e; border-radius: 9px 13px 13px 9px; background: #eef1ef; color: #52605a; font-size: 12px; line-height: 1.6; }
.product-tools { position: sticky; top: -14px; z-index: 6; display: grid; grid-template-columns: minmax(0, .8fr) minmax(180px, 1.2fr); align-items: center; gap: 10px; margin: 0 -2px 12px; padding: 10px 2px; background: var(--paper); border-bottom: 1px solid var(--line); }
.product-tools strong, .product-tools small { display: block; }
.product-tools strong { font-size: 13px; }
.product-tools small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.product-tools select { min-height: 40px; }
.rule-note { border-left: 4px solid var(--green-2); padding: 10px 12px; background: var(--mint); border-radius: 8px 12px 12px 8px; font-size: 12px; }
.rule-note.error { border-color: var(--red); background: #fbe9e5; color: #7c2922; }
.rule-note.warning { border-color: var(--orange); background: var(--orange-soft); color: #7d421b; }
.product-group { margin: 16px 0; }
.group-title { display: flex; align-items: center; justify-content: space-between; margin: 0 2px 9px; font-size: 13px; color: var(--muted); font-weight: 900; }
.product-list { display: grid; gap: 8px; }
.product { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 13px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
.product.selected { border-color: var(--green-2); box-shadow: inset 4px 0 var(--green-2); }
.product.risk-negative { border-left: 5px solid #b43b30; background: #fff8f6; }
.product.risk-low { border-left: 5px solid #d58a23; background: #fffbf2; }
.product.risk-unknown { border-left: 5px solid #87938e; background: #f8f9f7; }
.product.wifi-unavailable { outline: 2px solid rgba(173,56,45,.3); background: #fff4f1; }
.product-name-line { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.product-name { font-weight: 900; font-size: 14px; }
.requirement-badge { display: inline-flex; align-items: center; min-height: 21px; padding: 2px 7px; border: 1px solid #e2a26d; border-radius: 999px; background: var(--orange-soft); color: #8a4718; font-size: 9px; font-weight: 900; }
.wifi-warning-text { color: var(--red); }
.product-detail { color: var(--muted); font-size: 11px; margin-top: 5px; line-height: 1.45; }
.price { color: var(--orange); font-weight: 900; }
.stepper { display: grid; grid-template-columns: 36px 35px 36px; align-items: center; text-align: center; }
.stepper button { height: 36px; border: 1px solid var(--line); background: white; color: var(--green); font-size: 20px; font-weight: 800; }
.stepper button:first-child { border-radius: 10px 0 0 10px; }
.stepper button:last-child { border-radius: 0 10px 10px 0; }
.stepper span { height: 36px; display: grid; place-items: center; background: #f4f2eb; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-weight: 900; }
.sheet-foot { padding: 13px 16px calc(13px + env(safe-area-inset-bottom)); background: var(--card); border-top: 1px solid var(--line); }
.admin-calc { margin: -4px 0 10px; }
.household-risk { padding: 10px 12px; border-radius: 10px; border-left: 4px solid var(--green-2); background: var(--mint); }
.household-risk.negative { border-color: var(--red); background: #fff0ed; color: #7c2922; }
.household-risk.low { border-color: var(--orange); background: var(--orange-soft); color: #7d421b; }
.household-risk.unknown { border-color: #87938e; background: #eef1ef; color: #52605a; }
.budget-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.budget-card .panel-body p { margin-bottom: 8px; }
.settlement-card { grid-column: 1 / -1; }
.summary-line { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.summary-line strong { font-size: 21px; color: var(--orange); }
.foot-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 9px; }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 9px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-size: 11px; }
.positive { color: var(--green); font-weight: 800; }
.negative { color: var(--red); font-weight: 800; }
.low-value { color: #9a5a0c; font-weight: 800; }
.risk-badge { display: inline-flex; align-items: center; min-height: 22px; border-radius: 7px; padding: 2px 7px; font-size: 10px; font-weight: 900; white-space: nowrap; }
.risk-badge.negative { color: #92291f; background: #f9ddd8; border: 1px solid #eab1aa; }
.risk-badge.low { color: #85500b; background: #ffedc7; border: 1px solid #ebca88; }
.risk-badge.unknown { color: #52605a; background: #e7ebe8; border: 1px solid #c7cfca; }
.risk-row-negative { background: #fff8f6; }
.risk-row-low { background: #fffbf2; }
.risk-row-unknown { background: #f8f9f7; }
.import-help { padding: 12px; border-radius: 12px; background: var(--mint); color: var(--green); font-size: 12px; line-height: 1.7; }
.toast { position: fixed; z-index: 80; left: 50%; bottom: 30px; transform: translate(-50%, 20px); padding: 11px 16px; border-radius: 999px; background: #102b24; color: white; opacity: 0; pointer-events: none; transition: .2s; box-shadow: var(--shadow); max-width: calc(100% - 30px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--red); }
.loading { min-height: 60vh; display: grid; place-items: center; color: var(--muted); }
@media (max-width: 720px) {
  .app-header { min-height: 50px; padding: 7px 10px; gap: 8px; }
  .app-header .brand-mark { width: 34px; height: 34px; border-radius: 10px; font-size: 13px; }
  .brand { gap: 8px; }
  .brand strong { font-size: 14px; }
  .brand small { display: none; }
  .user-box { font-size: 11px; white-space: nowrap; }
  .user-box br { display: none; }
  .user-box strong { margin-right: 5px; }
  .layout { width: min(100% - 12px, 1180px); margin-top: 7px; }
  .nav { gap: 6px; padding-bottom: 7px; }
  .nav button { padding: 7px 11px; font-size: 12px; }
  .elder-grid, .admin-grid, .budget-grid { grid-template-columns: 1fr; }
  .settlement-card { grid-column: auto; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat { padding: 14px; }
  .stat strong { font-size: 20px; }
  .panel-head, .panel-body { padding: 15px; }
  .toolbar { position: sticky; top: 49px; z-index: 12; gap: 6px; margin: 0 0 9px; padding: 5px 0; background: var(--paper); }
  .toolbar input, .toolbar .button { min-height: 40px; }
  .toolbar .button { padding: 8px 10px; font-size: 12px; }
  .elder-card { padding: 13px; }
  .elder-name { font-size: 17px; }
  .elder-meta { margin-top: 5px; line-height: 1.55; }
  .badges { margin-top: 9px; }
  .card-actions { margin-top: 10px; }
  .login-card { padding: 25px; }
  .modal.center { place-items: stretch; padding: 0; }
  .password-card { width: 100%; height: 100dvh; max-height: none; border-radius: 0; padding: 16px; }
  .password-card .field { margin: 10px 0; }
  .sheet { width: 100%; height: 100dvh; max-height: none; border-radius: 0; }
  .sheet-head { min-height: 52px; padding: 8px 11px; }
  .sheet-head h2 { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sheet-head small { font-size: 10px; }
  .icon-btn { width: 34px; height: 34px; border-radius: 9px; }
  .sheet-scroll { padding: 8px; }
  .cap-meter { margin-bottom: 7px; padding: 9px 10px; border-radius: 12px; }
  .environment-box { margin-bottom: 7px; padding: 9px; border-radius: 12px; }
  .environment-head { margin-bottom: 8px; }
  .environment-head small { display: none; }
  .environment-grid { grid-template-columns: 1fr; gap: 6px; }
  .environment-grid > div { display: grid; grid-template-columns: 72px minmax(0, 1fr); align-items: center; gap: 6px; }
  .environment-grid > div > span { margin-bottom: 0; }
  .environment-choice { min-height: 36px; padding: 5px; font-size: 11px; }
  .environment-warning { margin-top: 7px; padding: 7px 8px; font-size: 10px; }
  .cap-line { font-size: 12px; }
  .meter { height: 6px; margin-top: 5px; }
  .product-tools { top: -8px; grid-template-columns: 1fr; gap: 5px; margin-bottom: 7px; padding: 6px 0; }
  .product-tools > div:first-child { display: none; }
  .product-tools select { min-height: 40px; padding-block: 7px; }
  .recommendation-box { margin-bottom: 7px; padding: 9px; border-radius: 12px; }
  .recommendation-box > small { display: none; }
  .recommendation-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-top: 7px; }
  .recommendation-actions .button { min-height: 40px; padding: 7px 5px; font-size: 11px; }
  .recommendation-note { margin-bottom: 7px; padding: 8px 10px; font-size: 11px; }
  .rule-box { gap: 5px; margin-bottom: 7px; }
  .rule-note { padding: 7px 9px; font-size: 11px; line-height: 1.45; }
  .product-group { margin: 10px 0; }
  .group-title { margin-bottom: 6px; font-size: 12px; }
  .product-list { gap: 6px; }
  .product { gap: 8px; padding: 9px 8px; border-radius: 12px; }
  .product-name-line { gap: 5px; }
  .product-name { font-size: 13px; }
  .product-detail { margin-top: 3px; font-size: 10px; }
  .risk-badge { min-height: 20px; padding: 1px 6px; font-size: 9px; }
  .stepper { grid-template-columns: 34px 32px 34px; }
  .stepper button, .stepper span { height: 36px; }
  .sheet-foot { padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
  .summary-line { margin-bottom: 6px; }
  .summary-line strong { font-size: 18px; }
  .foot-actions { gap: 6px; }
  .foot-actions .button { min-height: 42px; padding: 8px; font-size: 12px; }
}
