:root {
  /* green mode (default) */
  --bg: #0e1512;
  --panel: #16201c;
  --panel-2: #1b2822;
  --line: #25332b;
  --green: #43c46b;
  --green-dim: #2e8f4e;
  --copper: #e0a241;
  --red: #e06767;
  --text: #e6efe8;
  --text-soft: #cdd9d0;
  --muted: #8aa396;
  --info: #5aa6d8;
  font-size: 15px;
}
:root[data-theme="dark"] {
  /* night mode — near-black neutral, low glare */
  --bg: #0a0c0b;
  --panel: #121514;
  --panel-2: #191d1b;
  --line: #252a27;
  --green: #3fb864;
  --green-dim: #2a7d45;
  --copper: #cf9538;
  --red: #d96262;
  --text: #dfe5e1;
  --text-soft: #c3ccc6;
  --muted: #7f8c84;
}
:root[data-theme="light"] {
  /* daylight mode — bright surfaces for full-sun readability */
  --bg: #eef1ee;
  --panel: #ffffff;
  --panel-2: #f1f5f1;
  --line: #d3dcd4;
  --green: #1e7a3c;
  --green-dim: #2e8f4e;
  --copper: #9a6210;
  --red: #b03030;
  --text: #17201a;
  --text-soft: #2e3b32;
  --muted: #58685d;
  --info: #22618c;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
}
button {
  font: inherit;
  background: var(--green-dim);
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 8px 14px;
  cursor: pointer;
}
button:hover { background: var(--green); }
button.ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); }
button.ghost:hover { color: var(--text); border-color: var(--muted); }
button.danger { background: transparent; border: 1px solid #6b3535; color: var(--red); }
input, select {
  font: inherit;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  width: 100%;
}
input:focus, select:focus { outline: none; border-color: var(--green-dim); }
label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 4px; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; }
.login-card { width: 340px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; }
.login-card h1 { margin: 0 0 2px; font-size: 22px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.login-card button { width: 100%; margin-top: 18px; }
.error { color: var(--red); font-size: 13px; margin-top: 10px; min-height: 17px; }
.ssodivider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; margin: 16px 0 12px; }
.ssodivider::before, .ssodivider::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.shell { display: grid; grid-template-columns: 210px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { font-weight: 700; font-size: 17px; padding: 4px 10px 16px; }
.brand span { color: var(--green); }
.nav a { display: block; padding: 9px 10px; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: 14px; }
.nav a:hover { color: var(--text); background: var(--panel-2); }
.nav a.active { color: var(--text); background: var(--panel-2); border-left: 2px solid var(--green); }
.side .foot { margin-top: auto; padding: 10px; font-size: 12px; color: var(--muted); }
.side .foot b { display: block; color: var(--text); font-weight: 600; }
.side .foot button { margin-top: 8px; width: 100%; }

.main { padding: 26px 32px; max-width: 1100px; }
.main h2 { margin: 0 0 4px; }
.main .desc { color: var(--muted); font-size: 13px; margin: 0 0 20px; }
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 10px; }

table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 10px 12px; background: var(--panel-2); }
td { padding: 10px 12px; border-top: 1px solid var(--line); font-size: 14px; }
td .sub { color: var(--muted); font-size: 12px; }
.pill { display: inline-block; font-size: 11px; padding: 2px 9px; border-radius: 10px; border: 1px solid var(--line); color: var(--muted); }
.pill.on { color: var(--green); border-color: var(--green-dim); }
.pill.warn { color: var(--copper); border-color: var(--copper); }
.pill.off { color: var(--red); border-color: #6b3535; }
.pill.info { color: var(--info, #5aa6d8); border-color: #2f5d75; }

.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; z-index: 10; }
.modal { width: 400px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 24px; }
.modal h3 { margin: 0 0 6px; }
.modal .row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.switch { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.switch:last-child { border-bottom: none; }
.switch .grow { flex: 1; }
.switch .name { font-weight: 600; font-size: 14px; }
.switch .d { color: var(--muted); font-size: 12px; }
.switch input[type=number] { width: 70px; }
.muted { color: var(--muted); }
.mt { margin-top: 16px; }
.refl { margin: 6px 0 0; padding-left: 20px; }
.refl li { font-size: 13.5px; margin: 4px 0; color: var(--text-soft); }

.lockedfield { opacity: 0.65; cursor: not-allowed; background: var(--panel); }
.lockedfield:focus { border-color: var(--line); }

.backbtn { display: inline-flex; align-items: center; gap: 6px; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); text-decoration: none; padding: 10px 18px; border-radius: 10px; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.backbtn:hover { border-color: var(--green-dim); color: var(--green); }
.backbtn:active { transform: scale(0.97); }

tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--panel-2); }
tr.clickable a { color: var(--text); text-decoration: none; font-weight: 600; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 18px 0 18px; }
.tabs a { padding: 8px 14px; color: var(--muted); text-decoration: none; font-size: 14px; border-radius: 8px 8px 0 0; }
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-bottom-color: var(--panel-2); margin-bottom: -1px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px 18px; }

/* --- audit field UI --- */
.syncbar { border-radius: 8px; padding: 8px 14px; font-size: 13px; margin-bottom: 14px; border: 1px solid var(--line); }
.syncbar.on { color: var(--green); border-color: var(--green-dim); background: rgba(67,196,107,0.06); }
.syncbar.warn { color: var(--copper); border-color: var(--copper-dim); background: rgba(224,162,65,0.06); }
.syncbar.off { color: var(--red); border-color: #6b3535; background: rgba(224,103,103,0.06); }
.cards { display: flex; flex-direction: column; gap: 10px; }
.fieldcard { display: flex; align-items: center; gap: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 11px; padding: 14px 16px; }
.fieldcard.done { opacity: 0.65; }
.fieldcard .name { font-weight: 600; font-size: 15px; }
.fieldcard .d { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.fieldcard .grow, .checkitem .grow, .switch .grow { flex: 1; min-width: 0; }
.ordernum { font-family: ui-monospace, monospace; font-size: 15px; color: var(--green); min-width: 28px; text-align: center; }
.navlink { color: var(--green); font-size: 12.5px; }
.checkitem { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.checkitem:last-child { border-bottom: none; }
.checkitem .name { font-weight: 600; font-size: 14px; }
.checkitem .d { color: var(--muted); font-size: 12px; }
.checkitem input { flex-basis: 100%; }
.qcol { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.verdict { font-size: 11px; font-weight: 700; letter-spacing: .08em; padding: 2px 12px; border-radius: 10px; border: 1px solid var(--line); color: var(--muted); min-width: 46px; text-align: center; }
.verdict.pass { color: #fff; background: var(--green-dim); border-color: var(--green-dim); }
.verdict.fail { color: #fff; background: #8f2e2e; border-color: #8f2e2e; }
.verdict.na { color: var(--text); background: var(--panel-2); }
.sechead { display: flex; align-items: center; gap: 12px; margin: 22px 0 10px; }
.sechead .secnum { width: 30px; height: 30px; border-radius: 50%; background: var(--green-dim); color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; flex: none; }
.sechead b { font-size: 16px; }
.sechead .d { color: var(--muted); font-size: 12px; }
.factgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px 18px; padding: 14px 18px; }
.fact .fl { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.fact .fv { font-size: 14px; margin-top: 1px; word-wrap: break-word; }
.resultbanner { border-radius: 12px; padding: 14px 18px; text-align: center; font-size: 15px; margin-bottom: 10px; border: 1px solid var(--line); }
.resultbanner b { font-size: 20px; letter-spacing: .06em; margin-right: 8px; }
.resultbanner.pass { border-color: var(--green-dim); background: rgba(67,196,107,0.08); }
.resultbanner.pass b { color: var(--green); }
.resultbanner.fail { border-color: #8f2e2e; background: rgba(224,103,103,0.08); }
.resultbanner.fail b { color: var(--red); }
.resultbanner.no_access { border-color: var(--copper-dim); background: rgba(224,162,65,0.08); }
.resultbanner.no_access b { color: var(--copper); }

/* --- Field Audit design --- */
.fieldaudit { max-width: 820px; }
.fahead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.jobtimer { font-family: ui-monospace, monospace; font-weight: 600; }
.noaccess { display: flex; align-items: center; gap: 10px; border: 1px solid var(--copper-dim); background: rgba(224,162,65,0.05); border-radius: 12px; padding: 13px 16px; margin: 0 0 10px; cursor: pointer; color: var(--copper); }
.noaccess .d { color: var(--muted); font-size: 12px; }
.fsechead { display: flex; justify-content: space-between; align-items: center; background: var(--panel-2); border: 1px solid var(--line); border-bottom: none; border-radius: 12px 12px 0 0; padding: 11px 18px; margin-top: 18px; font-size: 13.5px; letter-spacing: .03em; }
.fsechead .fstag { color: var(--muted); font-size: 11.5px; }
.fsechead .fstag.crit { color: var(--red); font-weight: 700; }
.fapanel { border-radius: 0 0 12px 12px; padding: 16px 18px; }
.rxbig { font-family: ui-monospace, monospace; font-size: 26px; font-weight: 700; color: var(--green); letter-spacing: .02em; }
.locnotes { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin-top: 8px; font-size: 14px; }
.locnotes .fl { margin-bottom: 3px; }
.tilerow { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-top: 6px; }
.cleartile { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; text-align: center; }
.cleartile .ctl { color: var(--muted); font-size: 12px; }
.cleartile .ctv { font-size: 30px; font-weight: 700; color: var(--info, #5aa6d8); line-height: 1.2; }
.cleartile .ctu { color: var(--muted); font-size: 11.5px; }
.cleartile.inputtile .tileinput { font-size: 26px; font-weight: 700; text-align: center; background: transparent; border: none; width: 100%; color: var(--text); padding: 2px 0; }
.cleartile.inputtile .tileinput:focus { outline: none; }
.cleartile.inputtile { border-color: var(--green-dim); }
.critbadge { font-size: 9.5px; font-weight: 700; letter-spacing: .06em; color: #ff9d9d; background: rgba(176,48,48,0.25); border: 1px solid #8f2e2e; border-radius: 5px; padding: 1px 7px; vertical-align: middle; }
.photodrop { width: 100%; background: transparent; border: 2px dashed var(--line); border-radius: 12px; padding: 26px; text-align: center; color: var(--muted); font-size: 14px; }
.photodrop:hover { border-color: var(--muted); background: transparent; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { background: transparent; color: var(--muted); border-radius: 0; padding: 8px 14px; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: none; }
.seg .seg-pass.active { background: var(--green-dim); color: #fff; }
.seg .seg-fail.active { background: #8f2e2e; color: #fff; }
.seg .seg-na.active { background: var(--panel-2); color: var(--text); }
.formgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-top: 4px; }
textarea { font: inherit; background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; width: 100%; resize: vertical; }
textarea:focus { outline: none; border-color: var(--green-dim); }
.photostrip { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0; }
.thumb { display: flex; flex-direction: column; gap: 4px; }
.thumb img { width: 110px; height: 110px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.thumb .small { padding: 4px 8px; font-size: 12px; }
.passbtn { background: var(--green-dim); font-weight: 600; }
.passbtn:hover { background: var(--green); }
.failbtn { background: #8f2e2e; font-weight: 600; }
.failbtn:hover { background: #a83a3a; }
.modal.wide { width: min(92vw, 900px); max-height: 94vh; overflow-y: auto; }
canvas.markup { display: block; max-width: 100%; width: auto; max-height: 62vh; margin: 0 auto; border-radius: 8px; border: 1px solid var(--line); touch-action: none; cursor: crosshair; }

/* leaflet topology map */
.leafmap { height: 46vh; min-height: 320px; border-radius: 14px; border: 1px solid var(--line); z-index: 0; }
.pinnum { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 13px; font-family: system-ui, sans-serif; border: 2px solid rgba(255,255,255,0.65); box-shadow: 0 1px 5px rgba(0,0,0,0.5); }
.pinnum.cur { transform: scale(1.3); border-color: #ffd98a; }
@media (max-width: 700px) { .leafmap { height: 38vh; } }

/* --- route map + guided mode --- */
.routemap { width: 100%; max-height: 46vh; border-radius: 14px; border: 1px solid var(--line); display: block; }
.progressbar { height: 8px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--line); overflow: hidden; margin: 10px 0 16px; }
.progressbar .fill { height: 100%; background: linear-gradient(90deg, var(--green-dim), var(--green)); transition: width .3s; }
.guided-card { background: var(--panel); border: 1px solid var(--green-dim); border-radius: 14px; padding: 20px; margin-bottom: 14px; position: relative; }
.guided-order { position: absolute; top: 16px; right: 18px; font-family: ui-monospace, monospace; font-size: 26px; color: var(--copper); }
.guided-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.bigbtn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 13px 20px; border-radius: 10px; font-size: 15px; font-weight: 600; text-decoration: none; border: none; cursor: pointer; }
.bigbtn.nav { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
.bigbtn.nav:hover { border-color: var(--muted); }
.bigbtn.go { background: var(--green-dim); color: #fff; }
.bigbtn.go:hover { background: var(--green); }
.guided-done { text-align: center; padding: 60px 20px; }
.notifrow { display: flex; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.notifrow:last-of-type { border-bottom: none; }
.notifrow.unread { background: rgba(224,162,65,0.06); border-left: 3px solid var(--copper); padding-left: 10px; border-radius: 6px; }
.notifrow .grow { flex: 1; }

.exphead { display: flex; align-items: center; gap: 14px; cursor: pointer; width: 100%; }
.chev { color: var(--muted); font-size: 16px; transition: transform .15s; flex: none; }
.chev.open { transform: rotate(180deg); color: var(--green); }
.expdetail { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; }
.nonhftd { color: var(--red); font-weight: 600; }

.altstop { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.altstop:last-child { border-bottom: none; }
.altstop .d { color: var(--muted); font-size: 12.5px; }

/* --- dashboard --- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.stattile { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; cursor: pointer; transition: border-color .15s; }
.stattile:hover { border-color: var(--muted); }
.stattile.flat { cursor: default; }
.stattile.flat:hover { border-color: var(--line); }
.stattile.selected { border-color: var(--green); background: rgba(67,196,107,0.06); }
.stattile .num { font-size: 30px; font-weight: 700; line-height: 1.1; }
.stattile .lbl { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.stattile.good .num { color: var(--green); }
.stattile.bad .num { color: var(--red); }
.stattile.warn .num { color: var(--copper, #d97706); }
.tiles.timing .stattile .num { font-size: 22px; }
.minibar { display: flex; height: 7px; border-radius: 5px; background: var(--panel-2); border: 1px solid var(--line); overflow: hidden; margin-top: 8px; }
.minibar .seg-pass { background: var(--green-dim); }
.minibar .seg-fail { background: #a83a3a; }
.drill { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; margin-bottom: 16px; }
.drill h3 { margin: 0 0 12px; }
.failcard { border: 1px solid #6b3535; border-left: 3px solid var(--red); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; background: rgba(224,103,103,0.04); }
.failitems { margin: 8px 0; padding-left: 20px; }
.failitems li { margin: 3px 0; font-size: 13.5px; }
.dashcols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 16px; }
@media (max-width: 900px) { .dashcols { grid-template-columns: 1fr; } }
.dashpane { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; }
.dashpane h3 { margin: 0 0 10px; }
.chatlist { flex: 1; overflow-y: auto; max-height: 380px; display: flex; flex-direction: column; gap: 8px; padding-right: 4px; }
.chatmsg { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; max-width: 92%; align-self: flex-start; }
.chatmsg.mine { align-self: flex-end; border-color: var(--green-dim); background: rgba(67,196,107,0.07); }
.chathead { font-size: 12px; margin-bottom: 2px; }
.chatbody { font-size: 14px; word-wrap: break-word; }
.chatsend { display: flex; gap: 8px; margin-top: 10px; }
.chatsend input { flex: 1; }
.acbox { position: absolute; bottom: calc(100% + 6px); left: 0; right: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.35); max-height: 220px; overflow-y: auto; z-index: 20; }
.acitem { padding: 9px 13px; cursor: pointer; font-size: 14px; border-bottom: 1px solid var(--line); }
.acitem:last-child { border-bottom: none; }
.acitem:hover, .acitem.active { background: var(--panel-2); }
.acitem b { color: var(--green); font-weight: 600; }
.acitem .sub { color: var(--muted); font-size: 12px; }
.mention { color: var(--info, #5aa6d8); font-weight: 600; }
.rxlink { color: var(--copper); font-weight: 600; text-decoration: none; border-bottom: 1px dashed var(--copper-dim); }
.recentlist { flex: 1; overflow-y: auto; max-height: 430px; display: flex; flex-direction: column; }
.recentrow { display: flex; align-items: center; gap: 10px; padding: 10px 6px; border-bottom: 1px solid var(--line); cursor: pointer; border-radius: 8px; }
.recentrow:hover { background: var(--panel-2); }
.recentrow:last-child { border-bottom: none; }
.recentrow .name { font-weight: 600; font-size: 14px; }
.recentrow .d { color: var(--muted); font-size: 12px; }

/* --- education portal --- */
.coursegrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.coursecard { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; cursor: pointer; transition: border-color .15s; }
.coursecard:hover { border-color: var(--green-dim); }
.coursecard.complete { border-color: var(--green-dim); }
.coursecard .cicon { font-size: 30px; margin-bottom: 8px; }
.coursecard .name { font-weight: 600; font-size: 16px; margin-bottom: 4px; }
.coursecard .d { color: var(--muted); font-size: 13px; }
.lesson { max-width: 780px; }
.lesson-sec { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px 22px; margin-bottom: 14px; }
.lesson-sec h3 { margin: 0 0 10px; color: var(--green); }
.lesson-sec p { color: var(--text-soft); line-height: 1.65; font-size: 14.5px; }
.tbl-scroll { overflow-x: auto; margin: 10px 0; }
.eduTable { min-width: 420px; }
.eduTable caption { caption-side: top; text-align: left; font-size: 12px; color: var(--copper); padding-bottom: 6px; }
.keypoints { background: rgba(67,196,107,0.06); border: 1px solid var(--green-dim); border-radius: 10px; padding: 12px 16px; margin-top: 10px; }
.keypoints .kphead { font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.keypoints ul { margin: 0; padding-left: 20px; }
.keypoints li { font-size: 13.5px; margin: 4px 0; }
.quizq { padding: 14px 0; border-bottom: 1px solid var(--line); }
.quizq:last-of-type { border-bottom: none; }
.quizchoices { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.quizchoice { text-align: left; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); }
.quizchoice:hover { background: var(--panel-2); border-color: var(--muted); }
.quizchoice.picked { border-color: var(--info, #5aa6d8); box-shadow: 0 0 0 1px var(--info, #5aa6d8) inset; }
.quizchoice.right { border-color: var(--green); background: rgba(67,196,107,0.1); }
.quizchoice.wrong { border-color: var(--red); background: rgba(224,103,103,0.1); }
.quizfb .fb-ok { color: var(--green); font-size: 13px; margin-top: 8px; }
.quizfb .fb-no { color: var(--copper); font-size: 13px; margin-top: 8px; }
.quizresult { text-align: center; border-radius: 12px; padding: 22px; margin-top: 16px; border: 1px solid var(--line); }
.quizresult.pass { border-color: var(--green-dim); background: rgba(67,196,107,0.07); }
.quizresult.fail { border-color: var(--copper-dim); background: rgba(224,162,65,0.06); }
.cert { max-width: 640px; margin: 20px auto 0; background: var(--panel); border: 2px solid var(--copper); border-radius: 16px; padding: 40px 34px; text-align: center; }
.certline { font-size: 13px; letter-spacing: .28em; text-transform: uppercase; color: var(--copper); margin-bottom: 14px; }
.certname { font-size: 30px; font-weight: 700; margin-bottom: 8px; }
.certbody { color: var(--muted); font-size: 14px; margin: 6px 0; }
.certcourse { font-size: 20px; font-weight: 600; color: var(--green); margin: 10px 0; }
.certfoot { color: var(--muted-2, #5f7268); font-size: 11px; margin-top: 20px; line-height: 1.5; }
@media print {
  .side, .syncbar, button, .toolbar { display: none !important; }
  body, .doc { background: #fff !important; color: #000; }
  .cert { border-color: #b8860b; color: #000; }
  .certname, .certcourse { color: #000; }
  .shell { grid-template-columns: 1fr; }
}

/* --- responsive: tablet --- */
@media (min-width: 701px) and (max-width: 1100px) {
  .main { padding: 20px; max-width: none; }
  .cards { display: grid; grid-template-columns: 1fr 1fr; }
}
.spark { width: 100%; height: 44px; display: block; opacity: .9; }
.fieldcard.credcrit { border-color: #b03030; background: rgba(176,48,48,0.12); box-shadow: 0 0 0 1px #b03030 inset; }
.repgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 12px; }
.circuitrow { display: flex; flex-wrap: wrap; gap: 8px; }
.circuitbox { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 9px; padding: 8px 12px; font-size: 13px; cursor: pointer; max-width: 320px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.circuitbox:hover { border-color: var(--muted); }
.replinks { margin-top: 4px; }

.seatchip { font-size: 11.5px; padding: 3px 10px; border-radius: 12px; margin: 2px 4px 2px 0; background: transparent; border: 1px dashed var(--line); color: var(--muted); }
.seatchip:hover { border-color: var(--muted); background: transparent; color: var(--text); }
.seatchip.on { border: 1px solid var(--green-dim); color: var(--green); background: rgba(67,196,107,0.07); }
.seatchip.full { border-style: dashed; color: var(--copper); border-color: var(--copper-dim); }

.impbanner { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 18px; background: #7a4d10; color: #ffe9c4; font-size: 13.5px; border-bottom: 2px solid var(--copper); }
.impbanner button { background: var(--copper); color: #241703; font-weight: 700; padding: 7px 14px; }
.impbanner button:hover { background: #f0b45a; }

.themerow { display: flex; gap: 10px; margin: 6px 0 4px; }
.themebtn { flex: 1; border-radius: 10px; border: 2px solid var(--line); background: transparent; padding: 10px 6px; cursor: pointer; text-align: center; color: var(--text); font-size: 13px; }
.themebtn .sw { width: 100%; height: 26px; border-radius: 6px; margin-bottom: 6px; border: 1px solid rgba(128,128,128,0.35); }
.themebtn.active { border-color: var(--green); }
.themebtn .sw.green { background: linear-gradient(135deg, #0e1512 60%, #43c46b); }
.themebtn .sw.dark { background: linear-gradient(135deg, #0a0c0b 60%, #3a423d); }
.themebtn .sw.light { background: linear-gradient(135deg, #ffffff 60%, #cfe4d4); }

@media (max-width: 700px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; overflow: visible; }
  button, .seg button { padding: 11px 16px; }
  .guided-actions .bigbtn { flex: 1 1 44%; }
  .routemap { max-height: 38vh; }
  .formgrid { grid-template-columns: 1fr; }
  .modal { width: 94vw; }
  table { min-width: 0; }
  th, td { padding: 8px 8px; font-size: 13px; }
  .side { flex-direction: row; align-items: center; gap: 6px; padding: 10px; border-right: none; border-bottom: 1px solid var(--line); overflow-x: auto; }
  .brand img { width: 90px !important; }
  .nav { display: flex; gap: 2px; }
  .side .foot { margin: 0 0 0 auto; padding: 0; display: flex; align-items: center; gap: 8px; }
  .side .foot b, .side .foot span { display: none; }
  .side .foot button { margin: 0; width: auto; }
  .main { padding: 16px; }
}

/* ================================================================
   2026 responsive + polish overhaul
   Layered last so it cleanly overrides the base rules above.
   Device classes on <html>: .is-ios/.is-android/.is-desktop-os,
   .is-touch, .is-phone/.is-tablet/.is-desktop, .is-installed
   ================================================================ */
:root {
  --radius: 12px;
  --shadow-soft: 0 1px 2px rgba(0,0,0,.18), 0 3px 12px rgba(0,0,0,.10);
  --shadow-pop: 0 4px 10px rgba(0,0,0,.22), 0 14px 40px rgba(0,0,0,.18);
  --ring: 0 0 0 3px color-mix(in srgb, var(--green) 30%, transparent);
}
:root[data-theme="light"] {
  --shadow-soft: 0 1px 2px rgba(23,32,26,.08), 0 3px 10px rgba(23,32,26,.06);
  --shadow-pop: 0 6px 16px rgba(23,32,26,.14), 0 18px 44px rgba(23,32,26,.10);
}
html { -webkit-text-size-adjust: 100%; }
body {
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
}

/* --- interactive feel: buttons, inputs, focus --- */
button {
  min-height: 38px;
  font-weight: 500;
  transition: background .15s, border-color .15s, color .15s, transform .06s, box-shadow .15s;
}
button:active { transform: scale(.97); }
button:disabled { opacity: .55; cursor: not-allowed; transform: none; }
:is(button, a, input, select, textarea, .seatchip):focus-visible { outline: none; box-shadow: var(--ring); }
input, select { min-height: 42px; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--green-dim); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 14%, transparent); }
/* iOS zooms any focused field under 16px — never let that happen on touch devices */
.is-touch input, .is-touch select, .is-touch textarea { font-size: 16px; }
.is-touch button, .is-touch .seg button { min-height: 44px; }
.is-touch .seatchip { padding: 7px 13px; font-size: 12.5px; }
.is-touch .quizchoice { padding: 13px 15px; }
.is-touch .recentrow, .is-touch .acitem { padding-top: 12px; padding-bottom: 12px; }

/* --- desktop: center the stage, give surfaces depth --- */
.shell { grid-template-columns: 236px 1fr; }
.main { max-width: 1200px; margin: 0 auto; width: 100%; padding: 30px 40px 70px; }
.main h2 { font-size: 24px; letter-spacing: -.01em; }
.side { width: auto; padding: 20px 14px; }
.brand { padding: 4px 10px 20px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; margin: 1px 0; border-radius: 10px;
  font-size: 14px; transition: background .15s, color .15s;
}
.nav .navic { width: 20px; text-align: center; flex: none; font-size: 15px; }
.nav a.active { border-left: none; background: color-mix(in srgb, var(--green) 12%, transparent); color: var(--text); font-weight: 600; box-shadow: inset 2.5px 0 0 var(--green); }
.side .foot { padding: 12px 10px 4px; border-top: 1px solid var(--line); }
.side .foot button { min-height: 36px; }

.panel, .dashpane, .drill, .stattile, .fieldcard, .coursecard, .guided-card, .login-card, table { box-shadow: var(--shadow-soft); }
.modal { box-shadow: var(--shadow-pop); border-radius: 16px; }
.modal-bg { backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.stattile { transition: border-color .15s, transform .12s, box-shadow .15s; }
.stattile:hover { transform: translateY(-1px); box-shadow: var(--shadow-pop); }
.stattile .num { font-size: 32px; }
.fieldcard, .coursecard, .recentrow { transition: border-color .15s, background .12s; }
.fieldcard:hover { border-color: var(--muted); }
tr.clickable td { transition: background .12s; }
.progressbar .fill { transition: width .45s cubic-bezier(.22,.9,.36,1); }

/* subtle scrollbars on desktop */
.is-desktop ::-webkit-scrollbar { width: 10px; height: 10px; }
.is-desktop ::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; border: 2px solid var(--bg); }
.is-desktop ::-webkit-scrollbar-thumb:hover { background: var(--muted); }
.is-desktop ::-webkit-scrollbar-track { background: transparent; }

/* --- login: modern viewport units, roomy card --- */
.login-wrap { min-height: 100dvh; padding: 20px; }
.login-card { width: min(94vw, 370px); box-shadow: var(--shadow-pop); }

/* --- tablet (portrait ≤ 1100): sidebar stays, denser grids --- */
@media (min-width: 701px) and (max-width: 1100px) {
  .shell { grid-template-columns: 200px 1fr; }
  .main { padding: 22px 24px 60px; }
  .cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .dashcols { grid-template-columns: 1fr 1fr; }
}

/* --- phone (≤ 700): sticky top bar, thumb-sized everything --- */
@media (max-width: 700px) {
  .side {
    position: sticky; top: 0; z-index: 40;
    box-shadow: var(--shadow-soft);
    padding: 8px 10px;
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
    padding-top: max(8px, env(safe-area-inset-top));
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .side::-webkit-scrollbar { display: none; }
  .nav a { flex: none; padding: 9px 11px; gap: 7px; }
  .nav a.active { box-shadow: none; }
  .main {
    padding: 14px 14px 40px;
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
    padding-bottom: calc(40px + env(safe-area-inset-bottom));
  }
  .main h2 { font-size: 21px; }
  /* wide admin tables scroll sideways instead of crushing */
  .main table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  /* PASS/FAIL verdict stays on screen while filling the audit */
  .resultbanner { position: sticky; top: calc(56px + env(safe-area-inset-top)); z-index: 5; box-shadow: var(--shadow-soft); }
  /* modals become bottom sheets */
  .modal-bg { align-items: end; place-items: end center; }
  .modal {
    width: 100vw; max-height: 92dvh; overflow-y: auto;
    border-radius: 18px 18px 0 0; border-bottom: none;
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
    animation: sheetup .24s cubic-bezier(.22,.9,.36,1);
  }
  .modal.wide { width: 100vw; max-height: 92dvh; }
  .tiles { grid-template-columns: repeat(auto-fit, minmax(105px, 1fr)); gap: 8px; }
  .stattile { padding: 12px 12px; }
  .stattile .num { font-size: 25px; }
  .stattile .lbl { font-size: 11px; }
  .toolbar { flex-wrap: wrap; }
  .photodrop { padding: 34px 20px; font-size: 15px; }
  .thumb img { width: 96px; height: 96px; }
  .fapanel, .panel { padding-left: 14px; padding-right: 14px; }
  .factgrid { grid-template-columns: 1fr 1fr; padding: 12px 14px; gap: 10px 12px; }
  .chatlist { max-height: 300px; }
  .recentlist { max-height: 340px; }
}
@keyframes sheetup { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }

/* installed to the home screen: honor the bottom safe area globally (gesture bar) */
.is-installed .main { padding-bottom: calc(48px + env(safe-area-inset-bottom)); }

/* --- accessibility & motion --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* --- brand: centered, roomier logo --- */
.brand { display: flex; justify-content: center; padding: 6px 6px 22px; }
@media (max-width: 700px) { .brand { padding: 0 6px; } .brand img { width: 118px !important; } }

/* --- sidebar nav: full-bodied bubbly buttons --- */
.nav { display: flex; flex-direction: column; gap: 5px; }
.nav a {
  padding: 13px 15px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-soft);
  border: 1px solid transparent;
  gap: 12px;
  transition: background .18s, color .18s, transform .16s cubic-bezier(.34,1.56,.64,1), border-color .18s, box-shadow .18s;
}
.nav .navic { font-size: 18px; width: 24px; transition: transform .18s cubic-bezier(.34,1.56,.64,1); }
.nav a:hover { background: var(--panel-2); color: var(--text); transform: translateX(4px); }
.nav a:hover .navic { transform: scale(1.18); }
.nav a:active { transform: translateX(4px) scale(.97); }
.nav a.active {
  background: linear-gradient(135deg, color-mix(in srgb, var(--green) 20%, var(--panel-2)), color-mix(in srgb, var(--green) 8%, var(--panel-2)));
  border-color: color-mix(in srgb, var(--green) 45%, transparent);
  color: var(--text);
  box-shadow: 0 2px 10px color-mix(in srgb, var(--green) 22%, transparent), inset 0 1px 0 color-mix(in srgb, #fff 8%, transparent);
  transform: none;
}
.nav a.active .navic { transform: scale(1.12); }
.nav a.active .navlbl { text-shadow: 0 0 14px color-mix(in srgb, var(--green) 40%, transparent); }

/* phone top bar: pill bubbles that pop when active */
@media (max-width: 700px) {
  .nav { flex-direction: row; gap: 6px; }
  .nav a { flex: none; padding: 10px 15px; border-radius: 999px; font-size: 14px; }
  .nav a:hover { transform: none; }
  .nav a.active { box-shadow: 0 2px 10px color-mix(in srgb, var(--green) 25%, transparent); }
}

/* ================================================================
   Phone shell v2: slim header + native-style bottom tab bar.
   The desktop sidebar disappears entirely on phones.
   ================================================================ */
.mhead, .tabbar { display: none; }

@media (max-width: 700px) {
  .side { display: none !important; }
  .mhead {
    display: flex; align-items: center; gap: 12px;
    position: sticky; top: 0; z-index: 45;
    padding: 10px 14px;
    padding-top: max(10px, env(safe-area-inset-top));
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
    background: color-mix(in srgb, var(--panel) 88%, transparent);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line);
  }
  .mhead img { height: 30px; width: auto; max-width: 110px; object-fit: contain; }
  .mhead .mtitle { flex: 1; text-align: center; font-weight: 700; font-size: 16px; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .iconbtn { background: transparent; border: none; font-size: 20px; min-height: 40px; min-width: 40px; padding: 4px; position: relative; }
  .iconbtn:hover { background: var(--panel-2); }
  .bellbadge {
    position: absolute; top: 1px; right: 0;
    background: var(--red); color: #fff; font-size: 10px; font-weight: 700;
    min-width: 16px; height: 16px; line-height: 16px; border-radius: 8px; padding: 0 3px;
  }
  .tabbar {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    background: color-mix(in srgb, var(--panel) 92%, transparent);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--line);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 20px rgba(0,0,0,.18);
  }
  .tab {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 6px 2px 4px; border-radius: 12px; text-decoration: none;
    color: var(--muted); position: relative;
    transition: color .15s, background .15s, transform .12s;
  }
  .tab:active { transform: scale(.92); }
  .tab .tabic { font-size: 22px; line-height: 1.15; transition: transform .18s cubic-bezier(.34,1.56,.64,1); }
  .tab .tablbl { font-size: 10.5px; font-weight: 600; letter-spacing: .01em; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tab.active { color: var(--green); }
  .tab.active .tabic { transform: translateY(-2px) scale(1.12); }
  .tab.active::before {
    content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
    width: 26px; height: 3px; border-radius: 3px; background: var(--green);
  }
  /* content clears the fixed tab bar */
  .main { padding-bottom: calc(86px + env(safe-area-inset-bottom)); }
  .is-installed .main { padding-bottom: calc(92px + env(safe-area-inset-bottom)); }
  /* audit verdict banner sticks under the new slim header */
  .resultbanner { top: calc(54px + env(safe-area-inset-top)); }
}

/* the More bottom sheet */
.moresheet { padding: 10px 18px 22px; }
.sheetgrab { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 2px auto 14px; }
.morelist { display: flex; flex-direction: column; margin-bottom: 10px; }
.moreitem {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 10px; border-radius: 12px;
  color: var(--text); text-decoration: none; font-size: 15.5px; font-weight: 600;
  border-bottom: 1px solid var(--line);
}
.moreitem:last-child { border-bottom: none; }
.moreitem:active { background: var(--panel-2); }
.moreitem.active { color: var(--green); }
.moreitem .navic { font-size: 19px; width: 26px; text-align: center; }
.moreuser { display: flex; align-items: center; gap: 12px; padding: 12px 10px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.moreuser .sub { color: var(--muted); font-size: 12.5px; }

/* --- drawn icon set --- */
.ic { display: inline-flex; align-items: center; justify-content: center; }
.ic svg { display: block; }
.navic { display: inline-flex; align-items: center; justify-content: center; width: 24px; flex: none; }
.navic svg { display: block; }
.tabic { display: inline-flex; }
.tabic svg { display: block; }
.nav a:hover .navic { transform: scale(1.12); }
.nav a.active .navic { transform: none; color: var(--green); }

@media (max-width: 700px) {
  /* active tab gets a soft pill under the icon, not just color */
  .tab.active { background: color-mix(in srgb, var(--green) 10%, transparent); }
  .tab.active::before { display: none; }
  .tab .tabic { padding-top: 1px; }
  /* content polish: cards and toolbars breathe, headers don't wrap awkwardly */
  .toolbar { gap: 8px; }
  .toolbar > div:first-child { min-width: 0; }
  .fieldcard { padding: 13px 14px; border-radius: 12px; }
  .drill, .dashpane { padding: 12px 13px; }
  h3 { font-size: 16px; }
  .iconbtn { color: var(--text); }
}

/* ================================================================
   Professional finish pass — typography discipline, flat confident
   surfaces, quiet chrome. Overrides the earlier playful styling.
   ================================================================ */
:root { font-size: 14.5px; }
body { font-family: -apple-system, "SF Pro Text", "Segoe UI Variable", "Segoe UI", Roboto, Inter, system-ui, sans-serif; }

/* headings: tight, weighted, quiet descriptors */
.main h2 { font-size: 22px; font-weight: 650; letter-spacing: -.015em; }
.main h3 { font-size: 15px; font-weight: 650; letter-spacing: -.005em; }
.main .desc { font-size: 13px; }
label, .fact .fl, .fl { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; }
th { font-size: 10.5px; font-weight: 600; letter-spacing: .07em; }

/* buttons: clear hierarchy, no shouting */
button { font-weight: 550; letter-spacing: .005em; border-radius: 9px; }
button.ghost { color: var(--text-soft); }
.passbtn, .bigbtn.go { font-weight: 600; }

/* nav: flat and assured — no glow, no gradient */
.nav a { font-weight: 550; font-size: 14px; border-radius: 10px; padding: 10px 12px; }
.nav a:hover { transform: none; }
.nav a:hover .navic { transform: none; }
.nav a.active {
  background: color-mix(in srgb, var(--green) 13%, transparent);
  border-color: transparent;
  box-shadow: none;
}
.nav a.active .navlbl { text-shadow: none; }
.nav a.active .navic { color: var(--green); }
.nav { gap: 2px; }

/* pills: micro-labels, not stickers */
.pill { font-size: 10px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; padding: 2px 8px; border-radius: 6px; }
.seatchip { border-radius: 7px; font-weight: 550; }

/* stat tiles: quiet labels, numbers carry the weight */
.stattile { border-radius: 12px; }
.stattile .num { font-size: 28px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stattile .lbl { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.stattile:hover { transform: none; box-shadow: var(--shadow-soft); border-color: var(--muted); }

/* tables: dense, aligned, calm */
td { font-size: 13.5px; padding: 9px 12px; }
td .sub { font-size: 12px; }
table { border-radius: 10px; }

/* cards/panels: consistent radius, subtle depth only */
.panel, .dashpane, .drill, .fieldcard, .coursecard, .guided-card { border-radius: 12px; }
.fapanel, .fsechead { border-radius: 0; }
.fsechead { border-radius: 12px 12px 0 0; font-weight: 600; font-size: 12px; letter-spacing: .05em; }
.fapanel { border-radius: 0 0 12px 12px; }

/* dashboard pane heads align with the system */
.dashpane h3, .drill h3 { font-size: 13px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--text-soft); }

/* segmented controls: crisp */
.seg { border-radius: 9px; }
.seg button { font-weight: 550; font-size: 13px; }

/* result banner: authoritative, not decorative */
.resultbanner b { letter-spacing: .1em; font-size: 18px; }

/* phone tab labels slightly quieter */
@media (max-width: 700px) {
  .tab .tablbl { font-weight: 550; letter-spacing: .02em; }
  .mhead .mtitle { font-weight: 650; font-size: 15.5px; }
}

/* --- auto-fit fixes: banner, map, tables --- */
.leafmap, .routemap { width: 100%; }
.impbanner { padding: 8px 14px; font-size: 13px; }
.impbanner .impmsg { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.impbanner button { flex: none; min-height: 34px; padding: 6px 14px; }
@media (max-width: 700px) {
  .impbanner { padding: 6px 10px; padding-top: max(6px, env(safe-area-inset-top)); gap: 8px; font-size: 12.5px; }
  .impbanner select { min-height: 32px; font-size: 12px; padding: 2px 6px; }
  /* the banner replaces the header's safe-area job when present */
  .impbanner + .mhead { padding-top: 10px; }
  /* tables: one line per cell, finger-scroll sideways — never crushed columns */
  .main table td, .main table th { white-space: nowrap; }
  .main table td .sub { white-space: nowrap; }
  .leafmap { height: 34vh; min-height: 240px; }
}

/* ================================================================
   Hard viewport guards: NOTHING may stretch the page wider than
   the device. A single overflowing element is what makes mobile
   browsers render the whole page zoomed out.
   ================================================================ */
html, body { overflow-x: clip; }
.main, .shell { overflow-x: clip; min-width: 0; }
img, svg, video, canvas { max-width: 100%; }
/* leaflet tiles are sized by the map engine — never constrain them */
.leaflet-pane img, .leaflet-pane svg, .leaflet-pane canvas, .leaflet-tile { max-width: none !important; }
.fact .fv, .chatbody, .fieldcard .d, .recentrow .d, .locnotes { overflow-wrap: anywhere; }
@media (max-width: 700px) {
  .factgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .formgrid { grid-template-columns: minmax(0, 1fr); }
  .tilerow { grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); }
  .toolbar > * { min-width: 0; }
  .dashcols { grid-template-columns: minmax(0, 1fr); }
}

/* desktop-site-mode helper banner */
.dswarn { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--panel-2); border-bottom: 1px solid var(--copper); color: var(--text); font-size: 13px; }
.dswarn b { color: var(--copper); }

/* ================================================================
   iPhone shrink-killer: fix the actual wide offenders, not just
   clip them. Any control row that can't fit 390px wraps or scrolls.
   ================================================================ */
@media (max-width: 700px) {
  /* dashboard period selector: 6 segments become a clean full-width grid row */
  .toolbar .seg { width: 100%; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; }
  .toolbar .seg button { padding: 10px 2px; font-size: 12px; border-right: 1px solid var(--line); }
  .toolbar .seg button:last-child { border-right: none; }
  /* header + controls stack instead of fighting for one row */
  .toolbar { flex-direction: row; flex-wrap: wrap; }
  .toolbar > .seg, .toolbar > div .seg { order: 10; }
  /* guided-mode action buttons wrap to two clean columns */
  .guided-actions .bigbtn { flex: 1 1 45%; min-width: 0; font-size: 14px; padding: 12px 8px; }
  /* photostrip and chip rows scroll rather than push */
  .photostrip { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
  .circuitrow { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  /* any stray fixed-width input calms down */
  input, select, textarea { max-width: 100%; }
}

/* ================================================================
   Condense & mold: correct layering, wrapping cards, and graceful
   compaction all the way down to ~250px-wide viewports.
   ================================================================ */
/* sheets and dialogs always layer ABOVE the bottom tab bar */
.modal-bg { z-index: 70; }

@media (max-width: 700px) {
  /* cards wrap: badges/pills/buttons drop BELOW the text instead of
     strangling it into one-character-per-line columns */
  .fieldcard { flex-wrap: wrap; }
  .fieldcard .grow { min-width: min(100%, 170px); flex-basis: 60%; }
  .fieldcard > .pill, .fieldcard > button { margin-top: 4px; }
  .switch { flex-wrap: wrap; }
  .switch .grow { min-width: min(100%, 170px); }
  /* the More sheet always leaves room for its last row */
  .moresheet { max-height: 86dvh; overflow-y: auto; }
}

/* ultra-narrow (display zoom / accessibility zoom): condense everything */
@media (max-width: 360px) {
  .main { padding-left: 10px; padding-right: 10px; }
  .main h2 { font-size: 19px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .stattile { padding: 10px; }
  .stattile .num { font-size: 21px; }
  .stattile .lbl { font-size: 9.5px; letter-spacing: .03em; }
  button, .seg button { padding: 9px 10px; font-size: 13px; }
  .fieldcard { padding: 11px 12px; }
  .pill { font-size: 9px; padding: 2px 6px; }
  .tab .tablbl { font-size: 9.5px; }
  .tab .tabic svg { width: 21px; height: 21px; }
  .factgrid { grid-template-columns: minmax(0, 1fr); }
  .fahead h2 { font-size: 17px; }
  .cleartile .ctv { font-size: 24px; }
}

/* ================================================================
   THE fix: on phones the desktop sidebar grid must die completely.
   A later desktop rule (.shell { grid-template-columns: 236px 1fr })
   was overriding the phone layout, trapping ALL content in a
   236px column while the header/tab bar spanned full width.
   ================================================================ */
@media (max-width: 700px) {
  .shell { display: block !important; }
  .main { max-width: none !important; width: 100% !important; }
}

/* --- photo editor --- */
.mk-active { border-color: var(--green) !important; color: var(--green) !important; }
.mk-swatch { width: 30px; height: 30px; min-height: 30px; border-radius: 50%; border: 2px solid transparent; padding: 0; }
.mk-swatch.mk-active { border-color: #fff; box-shadow: 0 0 0 2px var(--green); }

/* --- removal verdict control (audit form section 3) --- */
.removalctl { border: 2px solid var(--copper-dim, #b07d2e); background: rgba(224,162,65,0.07); border-radius: 12px; padding: 12px 14px; margin-bottom: 6px; }
.removalctl .seg .seg-pass.active { background: var(--green-dim); color: #fff; }
.removalctl .seg .seg-fail.active { background: #8f2e2e; color: #fff; }

/* --- switch + link-button controls --- */
.switchbtn {
  display: inline-flex; align-items: center; gap: 9px;
  background: transparent; border: 1px solid var(--line); border-radius: 999px;
  color: var(--text-soft); font-size: 13px; font-weight: 550; padding: 7px 14px 7px 8px;
  min-height: 36px;
}
.switchbtn:hover { background: var(--panel-2); border-color: var(--muted); }
.switchbtn .track {
  width: 36px; height: 20px; border-radius: 10px; background: var(--panel-2);
  border: 1px solid var(--line); position: relative; flex: none; transition: background .18s, border-color .18s;
}
.switchbtn .knob {
  position: absolute; top: 1.5px; left: 2px; width: 15px; height: 15px; border-radius: 50%;
  background: var(--muted); transition: transform .18s cubic-bezier(.22,.9,.36,1), background .18s;
}
.switchbtn.on { color: var(--text); border-color: color-mix(in srgb, var(--green) 40%, transparent); }
.switchbtn.on .track { background: color-mix(in srgb, var(--green) 45%, var(--panel-2)); border-color: var(--green-dim); }
.switchbtn.on .knob { transform: translateX(16px); background: #fff; }
.linkbtn {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--line); border-radius: 999px; padding: 7px 15px; min-height: 36px;
  color: var(--green); text-decoration: none; font-size: 13px; font-weight: 550;
}
.linkbtn:hover { border-color: var(--green-dim); background: color-mix(in srgb, var(--green) 8%, transparent); }

/* --- prominent navigate buttons --- */
.navbtn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--green-dim); color: #fff; border: none; border-radius: 10px;
  padding: 12px 20px; font-size: 14px; font-weight: 650; min-height: 46px;
  box-shadow: var(--shadow-soft);
}
.navbtn::before { content: '➤'; font-size: 12px; transform: rotate(-45deg) translateY(1px); }
.navbtn:hover { background: var(--green); }
.navbtn:active { transform: scale(.97); }
@media (max-width: 700px) { .navbtn { width: 100%; } }

/* --- photo lightbox --- */
.lightbox {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(0,0,0,.88);
  display: grid; place-items: center;
  padding: 24px;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  animation: lbfade .16s ease;
}
.lightbox img {
  max-width: min(94vw, 1400px); max-height: 88dvh;
  border-radius: 12px; box-shadow: 0 20px 80px rgba(0,0,0,.6);
  cursor: zoom-out;
}
.lb-close {
  position: absolute; top: max(14px, env(safe-area-inset-top)); right: max(14px, env(safe-area-inset-right));
  width: 48px; height: 48px; min-height: 48px; border-radius: 50%;
  background: rgba(255,255,255,.14); color: #fff; border: 1px solid rgba(255,255,255,.3);
  font-size: 20px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.lb-close:hover { background: rgba(255,255,255,.28); }
@keyframes lbfade { from { opacity: 0; } to { opacity: 1; } }
