:root {
  --done: #2e7d32; --part: #e08600; --todo: #c62828;
  --bg: #f6f7f5; --card: #fff; --ink: #1d2320; --muted: #66706a; --line: #e2e6e3;
  --accent: #2e7d32;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink); background: var(--bg);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
button, select, input { font: inherit; }
button { cursor: pointer; }

/* login */
body.login { display: grid; place-items: center; min-height: 100%; padding: 16px; }
.login-card { background: var(--card); padding: 28px; border-radius: 14px; width: min(340px, 100%);
  box-shadow: 0 4px 24px rgba(0,0,0,.08); display: flex; flex-direction: column; gap: 10px; }
.login-card img { border-radius: 14px; align-self: center; }
.login-card h1 { text-align: center; margin: 4px 0 8px; font-size: 22px; }
.login-card input { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; }
.login-card button, #refresh, .btn { background: var(--accent); color: #fff; border: 0;
  border-radius: 8px; padding: 9px 14px; font-weight: 600; text-decoration: none; display: inline-block; }
.msg { color: var(--todo); margin: 0; min-height: 1em; text-align: center; font-size: 14px; }

/* app */
body.app { display: flex; flex-direction: column; height: 100%; }
header { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--card);
  border-bottom: 1px solid var(--line); flex-wrap: wrap; }
header img { border-radius: 7px; }
header h1 { font-size: 18px; margin: 0 6px 0 0; }
header select { padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
#updated { color: var(--muted); font-size: 13px; margin-left: auto; }
#refresh { padding: 6px 12px; font-size: 14px; }
#refresh:disabled { opacity: .5; cursor: default; }
.logout { color: var(--muted); font-size: 13px; }
main { flex: 1; display: flex; min-height: 0; }
#side { width: 400px; max-width: 45vw; overflow-y: auto; padding: 12px; border-right: 1px solid var(--line); }
#map { flex: 1; min-height: 300px; }

#notice, #setup, #progress { background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; margin-bottom: 10px; font-size: 14px; line-height: 1.45; }
#notice { border-color: var(--done); }
#setup h2 { font-size: 15px; margin: 0 0 6px; }
#setup .row { display: flex; gap: 8px; align-items: baseline; margin: 6px 0; }
#setup .ok { color: var(--done); font-weight: 600; }
#setup .no { color: var(--todo); font-weight: 600; }
#setup .err { color: var(--todo); font-size: 13px; }
#progress { color: var(--muted); }

#summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 10px; }
#summary button { background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 4px; text-align: center; color: var(--ink); }
#summary button b { display: block; font-size: 20px; }
#summary button span { font-size: 12px; color: var(--muted); }
#summary button.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
#summary .done b { color: var(--done); } #summary .part b { color: var(--part); } #summary .todo b { color: var(--todo); }

.tools { display: flex; gap: 6px; margin-bottom: 10px; }
.tools input { flex: 1; min-width: 0; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; }
.tools select { padding: 7px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }

#list { list-style: none; margin: 0; padding: 0; }
#list li { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px;
  margin-bottom: 6px; cursor: pointer; }
#list li:hover { border-color: #b9c2bc; }
#list li.sel { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.row1 { display: flex; align-items: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.name { flex: 1; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pct { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 14px; }
.bar { height: 5px; background: #eceeed; border-radius: 3px; margin: 6px 0 4px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 3px; }
.meta { color: var(--muted); font-size: 12px; }
.empty { color: var(--muted); font-size: 14px; padding: 8px 2px; }

#detail { background: var(--card); border: 1px solid var(--ink); border-radius: 12px; padding: 12px;
  margin-bottom: 10px; position: relative; }
#detail h2 { font-size: 16px; margin: 0 28px 4px 0; }
#detail .close { position: absolute; top: 6px; right: 8px; border: 0; background: none; font-size: 22px;
  color: var(--muted); line-height: 1; }
#detail .sub { font-size: 13px; color: var(--muted); }
#detail h3 { font-size: 13px; margin: 12px 0 4px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
#detail ul { list-style: none; padding: 0; margin: 0; font-size: 13px; }
#detail li { display: flex; gap: 8px; padding: 4px 0; border-top: 1px solid var(--line); }
#detail li .d { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
#detail li a { flex: 1; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#detail li .p { font-weight: 600; font-variant-numeric: tabular-nums; }
#detail .links { margin-top: 8px; font-size: 13px; }
#detail .links a { color: #fc4c02; }
#detail .legend { display: flex; gap: 12px; font-size: 12px; color: var(--muted); margin-top: 8px; }
#detail .legend i { display: inline-block; width: 16px; height: 4px; border-radius: 2px; vertical-align: middle; margin-right: 4px; }
.foot { color: var(--muted); font-size: 11px; text-align: center; margin: 14px 0 4px; }

@media (max-width: 800px) {
  main { flex-direction: column-reverse; }
  #map { flex: none; height: 45vh; }
  #side { width: auto; max-width: none; border-right: 0; flex: 1; }
  #updated { display: none; }
}
