:root {
  --bg: #f4f1ea; --card: #fffdf8; --ink: #1c211d; --muted: #5d665f; --line: #ddd6c8;
  --green: #1f3b2c; --green2: #2f5a43; --orange: #ff7a1a; --orange-ink: #a94600; --red: #b3261e; --ok: #1e7a3c; --warn: #f4c542;
  --radius: 14px; --tabs: 62px; --top: 52px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Arial, sans-serif;
  color: var(--ink); background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { overscroll-behavior-y: none; }
a { color: var(--green2); }
button, input, select, textarea { font: inherit; color: inherit; }
#app { min-height: 100%; display: flex; flex-direction: column; }

#top { position: sticky; top: 0; z-index: 20; height: calc(var(--top) + var(--safe-t)); padding: var(--safe-t) 8px 0;
  display: flex; align-items: center; gap: 6px; background: var(--green); color: #fff; }
#top h1 { flex: 1; margin: 0; font-size: 18px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: 6px; }
.icon-btn { background: none; border: 0; color: inherit; font-size: 26px; min-width: 44px; height: 44px; border-radius: 10px; cursor: pointer; }
.icon-btn:active { background: rgba(255,255,255,.15); }
.net { width: 10px; height: 10px; border-radius: 50%; background: #7bd88f; }
.net.off { background: var(--orange); }

#view { flex: 1; padding: 14px 14px calc(var(--tabs) + var(--safe-b) + 18px); max-width: 860px; width: 100%; margin: 0 auto; }
#view.full { padding: 0; max-width: none; }
.loading { padding: 40px; text-align: center; color: var(--muted); }

#tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: flex; height: calc(var(--tabs) + var(--safe-b));
  padding-bottom: var(--safe-b); background: #fff; border-top: 1px solid var(--line); }
#tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 11px; color: var(--muted); text-decoration: none; gap: 2px; }
#tabs a span { font-size: 22px; line-height: 1; }
#tabs a.on { color: var(--green); font-weight: 700; }

h2 { font-size: 22px; margin: 6px 0 12px; }
h3 { font-size: 17px; margin: 18px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.card.hero { background: var(--green); color: #fff; border: 0; }
.card.hero .muted { color: #c9d8cd; }
.card.warn { border-color: var(--orange); background: #fff4ea; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile { display: flex; flex-direction: column; gap: 4px; padding: 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  text-decoration: none; color: var(--ink); min-height: 84px; }
.tile b { font-size: 15px; }
.tile .ico { font-size: 24px; }
.tile.alert { border-color: var(--orange); background: #fff4ea; }
.list { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 12px; }
.list li { border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list a, .list .row { display: flex; align-items: center; gap: 10px; padding: 13px 14px; text-decoration: none; color: var(--ink); }
.list .grow { flex: 1; min-width: 0; }
.list .sub { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.chev { color: var(--muted); }
.pill { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 99px; background: #e8e2d4; color: var(--ink); white-space: nowrap; }
.pill.verify, .verify { background: #fff0c2; color: #6b4e00; border-radius: 6px; padding: 1px 6px; font-weight: 700; font-size: .85em; }
.pill.ok { background: #d8f0de; color: var(--ok); }
.pill.bad { background: #fbe0de; color: var(--red); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 12px 16px; border-radius: 12px; border: 1px solid var(--green2);
  background: var(--green2); color: #fff; font-weight: 650; cursor: pointer; text-decoration: none; min-height: 46px; }
.btn.secondary { background: transparent; color: var(--green2); }
.btn.orange { background: var(--orange); border-color: var(--orange); color: #1c1100; }
.btn.danger { background: var(--red); border-color: var(--red); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
input[type=text], input[type=password], input[type=search], input[type=datetime-local], input[type=number], select, textarea {
  width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font-size: 16px; }
textarea { min-height: 110px; }
label.f { display: block; margin: 10px 0 4px; font-weight: 600; font-size: 14px; }

/* Articles */
.article { line-height: 1.6; font-size: 17px; }
.article h1 { font-size: 24px; } .article h2 { font-size: 21px; margin-top: 24px; } .article h3 { font-size: 18px; }
.article img { max-width: 100%; height: auto; background: #fff; border-radius: 10px; border: 1px solid var(--line); display: block; margin: 10px auto; }
.article table { border-collapse: collapse; width: 100%; font-size: 15px; display: block; overflow-x: auto; }
.article th, .article td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
.article blockquote { margin: 12px 0; padding: 8px 14px; border-left: 4px solid var(--orange); background: #fff4ea; border-radius: 6px; }
.article code { background: #eee8db; padding: 1px 5px; border-radius: 5px; }
.article .cite { font-size: .75em; vertical-align: super; text-decoration: none; padding: 0 1px; }
.sources { font-size: 14px; }
.sources li { margin-bottom: 8px; word-break: break-word; }
.sources li:target { background: #fff0c2; }

/* Checklists */
.check { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; cursor: pointer; }
.check input { width: 26px; height: 26px; flex: none; accent-color: var(--green2); margin: 0; }
.check.done .t { text-decoration: line-through; color: var(--muted); }
.progress { height: 8px; background: #e8e2d4; border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--green2); }

/* Map */
#map { position: absolute; inset: calc(var(--top) + var(--safe-t)) 0 calc(var(--tabs) + var(--safe-b)) 0; }
.map-ui { position: absolute; z-index: 5; display: flex; flex-direction: column; gap: 8px; }
.map-ui.tr { top: calc(var(--top) + var(--safe-t) + 10px); right: 10px; }
.map-ui.bl { bottom: calc(var(--tabs) + var(--safe-b) + 10px); left: 10px; right: 64px; }
.mbtn { width: 46px; height: 46px; border-radius: 12px; border: 1px solid var(--line); background: #fff; font-size: 21px; box-shadow: 0 2px 8px rgba(0,0,0,.15); cursor: pointer; }
.mbtn.on { background: var(--green2); color: #fff; }
.mbtn.rec { background: var(--red); color: #fff; }
.where { background: rgba(255,255,255,.96); border-radius: 12px; padding: 8px 12px; font-size: 14px; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.where b { font-size: 15px; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; max-height: 75vh; overflow: auto; background: var(--card); border-radius: 18px 18px 0 0;
  box-shadow: 0 -6px 30px rgba(0,0,0,.25); padding: 10px 16px calc(20px + var(--safe-b)); }
.sheet .grab { width: 44px; height: 5px; border-radius: 9px; background: var(--line); margin: 0 auto 10px; }
.layer-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.layer-row .sw { width: 18px; height: 18px; border-radius: 4px; flex: none; border: 2px solid; }
.maplibregl-popup-content { border-radius: 12px; padding: 12px 14px; font-size: 14px; max-width: 280px; }
.maplibregl-ctrl-attrib { font-size: 10px; }

/* Field mode */
body.field { background: #000; }
body.field #top { background: #000; }
.field-view { color: #fff; font-size: 20px; }
.field-view .big { font-size: 64px; font-weight: 800; line-height: 1; letter-spacing: -1px; }
.field-view .huge { font-size: 46px; font-weight: 800; }
.field-view .fcard { background: #151515; border: 2px solid #333; border-radius: 16px; padding: 16px; margin-bottom: 12px; }
.field-view .fcard.go { border-color: #2ecc71; }
.field-view .fcard.stop { border-color: var(--orange); }
.field-view .label { color: #aaa; font-size: 15px; text-transform: uppercase; letter-spacing: 1px; }
.field-view .fbtns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-view .fbtn { display: flex; align-items: center; justify-content: center; text-align: center; min-height: 86px; padding: 10px; border-radius: 16px; border: 0;
  background: #262626; color: #fff; font-size: 20px; font-weight: 750; text-decoration: none; }
.field-view .fbtn.orange { background: var(--orange); color: #1c1100; }
.field-view .fbtn.red { background: #8f1d16; }
.field-view a { color: #ffb37a; }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; }
.steps li { counter-increment: s; position: relative; padding: 12px 12px 12px 56px; margin-bottom: 10px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); font-size: 18px; }
.steps li::before { content: counter(s); position: absolute; left: 12px; top: 10px; width: 34px; height: 34px; border-radius: 50%; background: var(--orange); color: #1c1100;
  font-weight: 800; display: flex; align-items: center; justify-content: center; }
.steps li .d { display: block; font-size: 15px; color: var(--muted); margin-top: 4px; }
body.field .steps li { background: #151515; border-color: #333; color: #fff; font-size: 22px; }
body.field .steps li .d { color: #bbb; font-size: 17px; }

table.daylight { width: 100%; border-collapse: collapse; font-size: 15px; background: var(--card); border-radius: 12px; overflow: hidden; }
table.daylight th, table.daylight td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: center; }
table.daylight tr.today { background: #fff0c2; font-weight: 700; }
table.daylight tr.trip td:first-child { border-left: 4px solid var(--orange); }

#toast { position: fixed; left: 50%; bottom: calc(var(--tabs) + var(--safe-b) + 16px); transform: translateX(-50%); z-index: 60; background: #222; color: #fff;
  padding: 10px 16px; border-radius: 12px; font-size: 15px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; }
#toast.on { opacity: 1; }
.login { max-width: 380px; margin: 8vh auto; text-align: center; }
.login img { width: 96px; height: 96px; }
.wx { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.wx .d { flex: none; width: 92px; text-align: center; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 4px; font-size: 13px; }
.wx .d b { display: block; font-size: 15px; }
.arrow { display: inline-block; }
.photos { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.photos img { width: 86px; height: 86px; object-fit: cover; border-radius: 8px; }
@media (min-width: 900px) { .article { font-size: 18px; } }
