:root {
  color-scheme: light;
  --ink: #17211b;
  --muted: #68736b;
  --line: #dde5df;
  --paper: #f5f3ec;
  --panel: #fffefa;
  --green: #176b43;
  --green-2: #238657;
  --green-soft: #e7f2eb;
  --amber: #b66a13;
  --red: #b93b32;
  --shadow: 0 16px 45px rgba(36, 54, 43, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell {
  display: grid;
  grid-template-columns: 238px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 18px;
  color: #f5fbf7;
  background:
    radial-gradient(circle at 25% 8%, rgba(87, 189, 127, 0.27), transparent 28%),
    linear-gradient(155deg, #183c2b, #10271d 68%);
}

.brand { padding: 0 12px 30px; }
.brand-kicker { color: #9fcbb0; font-size: 12px; letter-spacing: 0.18em; }
.brand-title { margin-top: 7px; font-size: 23px; font-weight: 800; }

.nav-list { display: grid; gap: 8px; }
.nav-item {
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-radius: 12px;
  color: #c9dbd0;
  background: transparent;
  text-align: left;
}
.nav-item:hover { background: rgba(255,255,255,.07); }
.nav-item.is-active { color: white; background: rgba(255,255,255,.13); box-shadow: inset 3px 0 #71d39b; }

.sidebar-note {
  position: absolute;
  right: 22px;
  bottom: 24px;
  left: 22px;
  padding: 14px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 14px;
  color: #afc7b8;
  font-size: 12px;
  line-height: 1.65;
  background: rgba(255,255,255,.05);
}

.main { min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 30px;
  border-bottom: 1px solid var(--line);
  background: rgba(245,243,236,.88);
  backdrop-filter: blur(12px);
}
.page-title { margin: 0; font-size: 24px; }
.page-subtitle { margin-top: 5px; color: var(--muted); font-size: 13px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.date-pill { padding: 9px 12px; border-radius: 999px; color: var(--muted); background: #ebe9e1; font-size: 13px; }

.content { padding: 28px 30px 46px; }
.view[hidden] { display: none; }

.btn {
  min-height: 38px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: var(--panel);
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 7px 20px rgba(34,55,43,.08); }
.btn-primary { border-color: var(--green); color: white; background: var(--green); }
.btn-primary:hover { background: var(--green-2); }
.btn-quiet { background: transparent; }
.btn-danger { color: var(--red); }

.hero {
  display: grid;
  grid-template-columns: 1.45fr .8fr;
  gap: 24px;
  padding: 28px;
  border-radius: 22px;
  color: white;
  background:
    radial-gradient(circle at 88% 18%, rgba(255,210,122,.34), transparent 22%),
    linear-gradient(135deg, #176b43, #12452f);
  box-shadow: var(--shadow);
}
.hero-eyebrow { color: #bfe5ce; font-size: 13px; letter-spacing: .12em; }
.hero h2 { max-width: 720px; margin: 10px 0 12px; font-size: clamp(26px, 3.4vw, 42px); line-height: 1.2; }
.hero p { max-width: 690px; margin: 0; color: #d6e9dc; line-height: 1.8; }
.formula-card { align-self: stretch; padding: 21px; border: 1px solid rgba(255,255,255,.17); border-radius: 18px; background: rgba(255,255,255,.1); }
.formula-label { color: #bad8c6; font-size: 12px; }
.formula-main { margin: 9px 0 13px; font-size: 19px; font-weight: 800; line-height: 1.5; }
.formula-note { color: #d4e4d9; font-size: 12px; line-height: 1.7; }

.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px; margin-top: 18px; }
.metric-card, .panel {
  border: 1px solid rgba(29,71,47,.09);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.metric-card { padding: 19px; }
.metric-label { color: var(--muted); font-size: 13px; }
.metric-value { margin-top: 9px; font-size: 28px; font-weight: 800; }
.metric-foot { margin-top: 5px; color: var(--muted); font-size: 12px; }
.metric-card.good .metric-value { color: var(--green); }
.metric-card.warn .metric-value { color: var(--amber); }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(300px, .75fr); gap: 18px; margin-top: 18px; }
.panel { padding: 20px; }
.panel + .panel { margin-top: 18px; }
.dashboard-grid .panel + .panel { margin-top: 0; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; margin-bottom: 17px; }
.panel-title { margin: 0; font-size: 17px; }
.panel-desc { margin-top: 5px; color: var(--muted); font-size: 12px; }
.panel-link { border: 0; color: var(--green); background: transparent; }

.chart { display: flex; align-items: end; gap: 12px; height: 210px; padding: 12px 4px 0; border-bottom: 1px solid var(--line); }
.chart-item { display: grid; flex: 1; grid-template-rows: 1fr auto; align-items: end; height: 100%; text-align: center; }
.chart-bar { min-height: 8px; border-radius: 9px 9px 3px 3px; background: linear-gradient(#52ae79, #1b7248); }
.chart-label { padding-top: 8px; color: var(--muted); font-size: 11px; }
.chart-value { display: block; margin-bottom: 5px; color: var(--green); font-size: 10px; font-weight: 700; }

.queue-list, .leader-list, .comment-list { display: grid; gap: 11px; }
.queue-item, .leader-item, .comment-item { padding: 13px; border: 1px solid var(--line); border-radius: 13px; background: #fbfaf6; }
.queue-top, .leader-top, .comment-top { display: flex; justify-content: space-between; gap: 12px; }
.queue-meta, .comment-meta { margin-top: 5px; color: var(--muted); font-size: 12px; }
.leader-item { display: grid; grid-template-columns: 30px 1fr auto; align-items: center; }
.rank { display: grid; width: 26px; height: 26px; place-items: center; border-radius: 50%; color: var(--green); background: var(--green-soft); font-weight: 800; }
.leader-score { text-align: right; }
.leader-score strong { display: block; color: var(--green); }
.leader-score span { color: var(--muted); font-size: 11px; }

.section-head, .toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.section-head { margin-bottom: 18px; }
.section-head h2 { margin: 0; font-size: 24px; }
.section-head p { margin: 6px 0 0; color: var(--muted); }
.toolbar { margin-bottom: 15px; }
.toolbar-fields { display: flex; gap: 10px; flex-wrap: wrap; }
.input, .select, textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid #ccd7cf;
  border-radius: 9px;
  outline: none;
  background: white;
}
.input:focus, .select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23,107,67,.1); }
.toolbar .input { width: 260px; }
.toolbar .select { width: 140px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 15px; }
table { width: 100%; min-width: 980px; border-collapse: collapse; background: var(--panel); }
th, td { padding: 13px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); background: #f6f6f1; font-size: 12px; font-weight: 600; }
td { font-size: 13px; }
tr:last-child td { border-bottom: 0; }
.cell-main { font-weight: 700; }
.cell-sub { margin-top: 4px; color: var(--muted); font-size: 11px; }
.badge { display: inline-flex; align-items: center; min-height: 25px; padding: 0 9px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge-ok { color: #17643f; background: #e0f1e7; }
.badge-wait { color: #926018; background: #fff0d5; }
.badge-frozen { color: #9d3830; background: #fde4e1; }
.badge-neutral { color: #566159; background: #edf0ed; }
.score { color: var(--green); font-size: 17px; font-weight: 800; }
.row-action { padding: 6px 9px; border: 1px solid var(--line); border-radius: 8px; color: var(--green); background: white; }

.feedback-grid { display: grid; grid-template-columns: .8fr 1.2fr; gap: 18px; }
.big-rating { margin: 5px 0 3px; color: var(--green); font-size: 48px; font-weight: 900; }
.rating-count { color: var(--muted); font-size: 12px; }
.dimension-list { display: grid; gap: 15px; margin-top: 22px; }
.dimension-row { display: grid; grid-template-columns: 72px 1fr 38px; align-items: center; gap: 10px; font-size: 13px; }
.progress { height: 9px; overflow: hidden; border-radius: 999px; background: #e8ece8; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #2a8858, #6fc58f); }
.comment-text { margin-top: 9px; line-height: 1.65; }

.rule-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.field label { display: block; margin-bottom: 7px; color: #4b574f; font-size: 12px; font-weight: 700; }
.field-full { grid-column: 1 / -1; }
.help { margin-top: 5px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.location-row { display: grid; grid-template-columns: 1fr auto; gap: 9px; }
.btn-location { white-space: nowrap; color: var(--green); border-color: #9ec8ae; background: var(--green-soft); }
.btn-location:disabled { cursor: wait; opacity: .65; }
.location-status { margin-top: 7px; color: var(--muted); font-size: 11px; }
.location-status.is-loading { color: var(--amber); }
.location-status.is-ok { color: var(--green); font-weight: 700; }
.location-status.is-error { color: var(--red); }
.watermark-preview { padding: 14px; border: 1px dashed #a9c8b5; border-radius: 13px; background: #f2f8f4; }
.watermark-preview-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.watermark-preview-head span { color: var(--green); font-size: 12px; font-weight: 700; }
.watermark-preview img { display: block; width: 100%; max-height: 430px; object-fit: contain; border-radius: 10px; background: #dfe8e2; }
.photo-link { margin-top: 6px; padding: 0; border: 0; color: var(--green); background: transparent; font-size: 11px; text-decoration: underline; }
.photo-dialog { width: min(920px, calc(100vw - 28px)); }
.photo-dialog-body { padding: 20px; background: #eef2ee; }
.photo-dialog-body > img { display: block; width: 100%; max-height: 68vh; object-fit: contain; border-radius: 13px; background: #17211b; }
.photo-location { display: grid; grid-template-columns: 100px 1fr; gap: 7px 12px; margin-top: 14px; padding: 14px; border-radius: 12px; background: white; font-size: 12px; }
.photo-location strong { color: var(--green); }
.photo-location small { grid-column: 2; color: var(--muted); }
.rule-total { margin-top: 15px; padding: 12px; border-radius: 11px; color: var(--green); background: var(--green-soft); font-weight: 800; }
.coef-list, .guard-list { display: grid; gap: 10px; }
.coef-row { display: flex; justify-content: space-between; padding: 10px 12px; border-radius: 10px; background: #f3f5f1; }
.guard-list { margin: 18px 0 0; padding-left: 20px; color: #4f5a53; line-height: 1.75; }

.connection-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}
.connection-pill.is-pending { color: #7a5a23; background: #fff0d5; }
.connection-pill.is-off { color: #7a4742; background: #f6e5e3; }
.connection-pill.is-preview { color: #17643f; background: #e0f1e7; }
.connection-pill.is-write { color: white; background: var(--green); }
.sync-pill { display: inline-flex; align-items: center; min-height: 30px; padding: 0 10px; border-radius: 999px; color: #5e6d64; background: #edf0ee; font-size: 11px; font-weight: 800; white-space: nowrap; }
.sync-pill.is-loading { color: #806025; background: #fff2d8; }
.sync-pill.is-ok { color: #17643f; background: #e0f1e7; }
.sync-pill.is-error { color: #8e3e37; background: #f6e4e2; }

.amap-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(240px, .5fr);
  gap: 22px;
  align-items: center;
  padding: 25px 28px;
  border-radius: 20px;
  color: white;
  background:
    radial-gradient(circle at 83% 26%, rgba(100, 194, 144, .24), transparent 26%),
    linear-gradient(135deg, #163c2a, #10251b);
  box-shadow: var(--shadow);
}
.amap-hero h3 { margin: 8px 0 10px; font-size: clamp(22px, 2.5vw, 31px); }
.amap-hero p { margin: 0; color: #cce0d3; line-height: 1.7; }
.safe-mode { display: grid; gap: 7px; padding: 17px; border: 1px solid rgba(255,255,255,.16); border-radius: 15px; background: rgba(255,255,255,.08); }
.safe-mode strong { color: #8fe0b1; }
.safe-mode span { color: #cce0d3; font-size: 12px; line-height: 1.6; }

.flow-strip {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr auto 1fr;
  gap: 12px;
  align-items: center;
  margin: 17px 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: rgba(255,255,255,.54);
}
.flow-strip > div { display: grid; grid-template-columns: 29px 1fr; column-gap: 9px; align-items: center; }
.flow-strip > div span { display: grid; grid-row: 1 / 3; width: 29px; height: 29px; place-items: center; border-radius: 50%; color: var(--green); background: var(--green-soft); font-weight: 800; }
.flow-strip strong { font-size: 13px; }
.flow-strip small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.flow-strip i { color: #8ba094; font-style: normal; }

.amap-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.amap-grid .panel + .panel { margin-top: 0; }
.panel-head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.btn-small { min-height: 34px; padding: 7px 12px; font-size: 12px; }
.config-list, .capability-list { display: grid; gap: 10px; }
.config-row { display: grid; grid-template-columns: 24px 1fr auto; align-items: center; gap: 9px; padding: 10px 11px; border: 1px solid var(--line); border-radius: 11px; background: #fbfaf6; }
.config-row b { display: grid; width: 22px; height: 22px; place-items: center; border-radius: 50%; color: #7b8780; background: #e9edea; font-size: 11px; }
.config-row.is-ok b { color: white; background: var(--green); }
.config-row span { font-size: 13px; }
.config-row small { color: var(--muted); }
.config-note { display: grid; gap: 6px; margin-top: 13px; padding: 13px; border-radius: 11px; color: #5a4a2c; background: #fff4df; font-size: 12px; line-height: 1.6; }
.capability-list > div { display: grid; grid-template-columns: 12px 112px 1fr; gap: 9px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.capability-list > div:last-child { border-bottom: 0; }
.capability-list small { color: var(--muted); line-height: 1.55; }
.cap-dot { width: 9px; height: 9px; border-radius: 50%; }
.cap-dot.is-ready { background: #49a66f; box-shadow: 0 0 0 4px #e3f2e8; }
.cap-dot.is-planned { background: #d39742; box-shadow: 0 0 0 4px #f8ecd9; }

.route-builder { margin-top: 18px; }
.route-builder textarea { font-family: "Microsoft YaHei", monospace; line-height: 1.75; resize: vertical; }
.route-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 15px; }
.route-actions > span { color: var(--muted); font-size: 12px; }
.route-preview { margin-top: 16px; overflow: hidden; border: 1px solid #bdd6c7; border-radius: 13px; background: #f3f8f4; }
.route-preview-head { display: flex; justify-content: space-between; gap: 12px; padding: 12px 14px; border-bottom: 1px solid #d4e5da; }
.route-preview-head span { color: var(--green); font-size: 12px; font-weight: 800; }
.route-preview pre { max-height: 360px; margin: 0; padding: 15px; overflow: auto; color: #d7f4e2; background: #12281d; font: 12px/1.65 Consolas, monospace; white-space: pre-wrap; word-break: break-word; }
.issue-list { display: grid; gap: 5px; margin: 0; padding: 12px 14px 12px 32px; color: #8a571d; background: #fff4df; font-size: 12px; }
.issue-ok { padding: 11px 14px; color: var(--green); font-size: 12px; font-weight: 700; }
.mapping-panel { margin-top: 18px; }
.mapping-grid { display: grid; grid-template-columns: 150px 1fr; gap: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; }
.mapping-grid > * { padding: 11px 13px; border-bottom: 1px solid var(--line); }
.mapping-grid > :nth-last-child(-n+2) { border-bottom: 0; }
.mapping-grid strong { color: var(--green); background: #f2f6f3; }
.mapping-grid span { color: #4f5a53; }

.amap-config-dialog { width: min(760px, calc(100vw - 28px)); }
.security-banner { display: grid; gap: 5px; margin-bottom: 17px; padding: 14px 15px; border: 1px solid #bcd9c7; border-radius: 12px; color: #28543b; background: #eff8f1; }
.security-banner span { color: #577064; font-size: 12px; line-height: 1.6; }
.amap-secret-grid { margin-bottom: 15px; }
.amap-config-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.amap-config-actions span { color: var(--muted); font-size: 12px; }
.connection-step { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 20px; padding: 16px; border: 1px solid #e2c68f; border-radius: 13px; background: #fff8ea; }
.connection-step.is-locked { opacity: .58; }
.connection-step p { max-width: 520px; margin: 5px 0 0; color: #6d604b; font-size: 12px; line-height: 1.65; }
.connection-step code { padding: 1px 4px; border-radius: 4px; background: rgba(255,255,255,.72); }
.connection-step .btn { flex: 0 0 auto; }
.discover-action { display: grid; flex: 0 0 auto; gap: 6px; justify-items: stretch; min-width: 190px; }
.discover-action span { max-width: 260px; color: var(--muted); font-size: 11px; line-height: 1.45; text-align: center; }
.discover-action span.is-loading { color: #806025; }
.discover-action span.is-ok { color: var(--green); font-weight: 700; }
.discover-action span.is-error { color: #9a4038; font-weight: 700; }
.amap-map-results { margin-top: 18px; overflow: hidden; border: 1px solid #bdd6c7; border-radius: 13px; background: #f7faf7; }
.amap-map-list { display: grid; gap: 9px; padding: 13px; }
.amap-map-option { display: flex; align-items: center; gap: 11px; padding: 12px; border: 1px solid var(--line); border-radius: 11px; background: white; cursor: pointer; }
.amap-map-option:has(input:checked) { border-color: #56a778; box-shadow: 0 0 0 2px #def0e5; }
.amap-map-option span { display: grid; gap: 4px; }
.amap-map-option small { color: var(--muted); }
.amap-map-foot { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px; border-top: 1px solid var(--line); background: white; }
.amap-map-foot span { color: var(--muted); font-size: 12px; }

dialog { width: min(780px, calc(100vw - 28px)); max-height: 90vh; padding: 0; overflow: auto; border: 0; border-radius: 19px; box-shadow: 0 26px 90px rgba(17,36,25,.25); }
dialog::backdrop { background: rgba(14,28,20,.52); backdrop-filter: blur(4px); }
.dialog-head, .dialog-foot { position: sticky; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 17px 21px; background: white; }
.dialog-head { top: 0; border-bottom: 1px solid var(--line); }
.dialog-head h3 { margin: 0; }
.dialog-close { width: 34px; height: 34px; border: 0; border-radius: 50%; background: #eef1ee; }
.dialog-body { padding: 21px; }
.dialog-foot { bottom: 0; border-top: 1px solid var(--line); }
.score-preview { display: flex; align-items: center; justify-content: space-between; margin-top: 18px; padding: 15px; border-radius: 13px; background: #edf5ef; }
.score-preview strong { color: var(--green); font-size: 25px; }
.check-row { display: flex; align-items: center; gap: 8px; min-height: 40px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 10; padding: 13px 17px; border-radius: 11px; color: white; background: #172f22; box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .22s; }
.toast.show { opacity: 1; transform: translateY(0); }
.empty { padding: 34px 15px; color: var(--muted); text-align: center; }

@media (max-width: 1040px) {
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .hero, .dashboard-grid, .feedback-grid, .rule-grid, .amap-hero, .amap-grid { grid-template-columns: 1fr; }
  .flow-strip { grid-template-columns: 1fr 1fr; }
  .flow-strip i { display: none; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: auto; height: auto; padding: 16px; }
  .brand { padding: 0 4px 15px; }
  .sidebar-note { display: none; }
  .nav-list { display: flex; overflow-x: auto; }
  .nav-item { flex: 0 0 auto; width: auto; }
  .nav-item.is-active { box-shadow: inset 0 -3px #71d39b; }
  .topbar { align-items: flex-start; padding: 18px; }
  .date-pill, #resetDemoBtn, #sharedStateBadge { display: none; }
  .content { padding: 18px; }
  .summary-grid, .form-grid { grid-template-columns: 1fr; }
  .field-full { grid-column: auto; }
  .toolbar, .section-head { align-items: stretch; flex-direction: column; }
  .toolbar .input, .toolbar .select { width: 100%; }
  .top-actions { flex-wrap: wrap; justify-content: flex-end; }
  .hero { padding: 22px; }
  .location-row { grid-template-columns: 1fr; }
  .photo-location { grid-template-columns: 1fr; }
  .photo-location small { grid-column: auto; }
  .flow-strip { grid-template-columns: 1fr; }
  .connection-step, .amap-map-foot { align-items: stretch; flex-direction: column; }
  .mapping-grid { grid-template-columns: 1fr; }
  .mapping-grid > * { border-bottom: 1px solid var(--line); }
  .mapping-grid > :last-child { border-bottom: 0; }
  .capability-list > div { grid-template-columns: 12px 1fr; }
  .capability-list small { grid-column: 2; }
}
