:root {
    --ink: #16231f;
    --muted: #66756f;
    --line: #dfe7e3;
    --paper: #f4f7f5;
    --card: #ffffff;
    --green: #176b4d;
    --green-dark: #0d4d37;
    --orange: #d56a33;
    --shadow: 0 18px 45px rgba(22, 48, 39, .10);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
    color: var(--ink);
    background:
        radial-gradient(circle at 8% 0%, rgba(23, 107, 77, .12), transparent 28rem),
        var(--paper);
    font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

button, input, select { font: inherit; }
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 28px clamp(20px, 4vw, 64px) 22px;
}
.topbar h1 { margin: 4px 0 0; font-size: clamp(24px, 3vw, 38px); letter-spacing: -.03em; }
.eyebrow { margin: 0; color: var(--green); font-size: 12px; font-weight: 800; letter-spacing: .2em; }
.topbar-status { display: flex; gap: 9px; align-items: center; color: var(--muted); font-size: 13px; }
.topbar-actions { display: flex; align-items: center; gap: 16px; }
.admin-entry { border: 1px solid var(--line); border-radius: 9px; padding: 8px 13px; color: var(--green); background: rgba(255,255,255,.75); cursor: pointer; }
.pulse { width: 9px; height: 9px; border-radius: 50%; background: #39a875; box-shadow: 0 0 0 5px rgba(57,168,117,.13); }
.page-shell { padding: 0 clamp(20px, 4vw, 64px) 50px; }

.stats-grid { display: grid; grid-template-columns: repeat(3, minmax(130px, 1fr)) 1.6fr; gap: 14px; }
.stat-card { padding: 18px 20px; border: 1px solid rgba(223,231,227,.85); border-radius: 18px; background: rgba(255,255,255,.86); box-shadow: 0 8px 28px rgba(28,58,48,.05); }
.stat-card span { display: block; color: var(--muted); font-size: 13px; }
.stat-card strong { display: block; margin-top: 8px; font-size: 27px; font-weight: 750; }
.stat-card-wide strong { font-size: 18px; margin-top: 13px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin: 18px 0; padding: 14px; background: rgba(255,255,255,.72); border: 1px solid var(--line); border-radius: 16px; }
.toolbar label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; }
.toolbar input, .toolbar select { min-width: 150px; height: 40px; border: 1px solid var(--line); border-radius: 10px; padding: 0 11px; color: var(--ink); background: white; }
.toolbar button { height: 40px; border: 0; border-radius: 10px; padding: 0 18px; color: white; background: var(--green); cursor: pointer; font-weight: 700; }
.toolbar button:hover { background: var(--green-dark); }
.toolbar .button-secondary { color: var(--green); background: #e6f1ec; }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 340px; min-height: 590px; overflow: hidden; border: 1px solid var(--line); border-radius: 22px; background: var(--card); box-shadow: var(--shadow); }
.map-panel { position: relative; min-height: 590px; }
#map { position: absolute; inset: 0; }
.map-empty { position: absolute; inset: 0; z-index: 5; display: grid; place-content: center; gap: 8px; text-align: center; background: linear-gradient(145deg,#eef4f1,#f8faf9); color: var(--muted); }
.map-empty[hidden] { display: none; }
.map-empty strong { color: var(--ink); font-size: 20px; }
.event-panel { display: flex; min-width: 0; flex-direction: column; border-left: 1px solid var(--line); background: #fbfcfb; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; padding: 20px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin: 4px 0 0; font-size: 20px; }
.panel-heading > span { color: var(--muted); font-size: 12px; }
.event-list { overflow: auto; max-height: 535px; }
.event-item { width: 100%; display: flex; align-items: center; border-bottom: 1px solid #e9efec; color: var(--ink); background: transparent; }
.event-item:hover { background: #eef5f1; }
.event-open { min-width: 0; flex: 1; display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 12px; padding: 16px 18px; border: 0; text-align: left; color: inherit; background: transparent; cursor: pointer; }
.event-delete { margin-right: 12px; border: 1px solid #e8b5ae; border-radius: 8px; padding: 7px 10px; color: #a3362b; background: #fff4f2; cursor: pointer; }
.event-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--orange); }
.event-main { display: grid; gap: 5px; }
.event-main small, .event-coordinate { color: var(--muted); font-size: 11px; }
.event-coordinate { text-align: right; line-height: 1.5; }
.map-marker { width: 16px; height: 16px; border: 3px solid white; border-radius: 50%; background: var(--orange); box-shadow: 0 2px 10px rgba(80,43,20,.38); }
.map-marker.latest { width: 20px; height: 20px; background: #d33d32; }
.admin-dialog { width: min(420px, calc(100% - 32px)); border: 0; border-radius: 18px; padding: 0; color: var(--ink); box-shadow: var(--shadow); }
.admin-dialog::backdrop { background: rgba(12,28,22,.48); backdrop-filter: blur(3px); }
.admin-dialog form { padding: 24px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; }
.dialog-heading h2 { margin: 5px 0 0; }
.dialog-heading > button { border: 0; color: var(--muted); background: transparent; font-size: 28px; cursor: pointer; }
#adminLoggedOut { display: grid; gap: 14px; }
#adminLoggedOut[hidden], #adminLoggedIn[hidden] { display: none; }
#adminLoggedOut label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; }
#adminLoggedOut input { height: 44px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; }
#adminLoggedOut button, #adminLoggedIn button { height: 42px; border: 0; border-radius: 10px; padding: 0 16px; color: white; background: var(--green); cursor: pointer; }
.admin-message { min-height: 20px; margin: 12px 0 0; color: var(--green); font-size: 13px; }

@media (max-width: 900px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .workspace { grid-template-columns: 1fr; }
    .map-panel { min-height: 430px; }
    .event-panel { border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 560px) {
    .topbar { align-items: flex-start; gap: 18px; flex-direction: column; }
    .topbar-actions { width: 100%; justify-content: space-between; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .stat-card { padding: 15px; }
    .stat-card strong { font-size: 22px; }
    .stat-card-wide { grid-column: 1 / -1; }
    .toolbar label, .toolbar input, .toolbar select { width: 100%; }
    .toolbar button { flex: 1; }
}
