:root {
  /* Deep green with a golden-oil accent. */
  --brand: #1c5a4b;
  --brand-dark: #123f35;
  --brand-tint: #e9f2ef;
  --gold: #d9a12a;
  --ink: #16201d;
  --muted: #5f6b67;
  --line: #e4e9e7;
  --bg: #f3f5f4;
  --card: #ffffff;
  --shadow: 0 1px 2px rgb(16 32 26 / .05), 0 6px 20px rgb(16 32 26 / .06);
  --accent-line: rgb(217 161 42 / .55);
  --ring: rgb(28 90 75 / .14);
  --mark: linear-gradient(140deg, #f3c552, var(--gold) 55%, #a96d0c);
  --mark-shadow: rgb(169 109 12 / .35);
  --login-picture: linear-gradient(165deg, rgb(10 26 20 / .58), rgb(20 12 2 / .10) 50%, rgb(10 26 20 / .46)), url(/img/oil-bg.svg);
  --login-base: #2a1703;
  --danger: #b3382c;
  --warn-bg: #fff6e0;
  --warn-ink: #6d5200;
  color-scheme: light;
}

/* The ISCC Audit App: same layout, navy and steel blue instead of green and gold, and its own sign-in picture.
   The app's Wrangler config picks the theme (APP_THEME); app.js puts it on <html data-theme>. */
html[data-theme="iscc"] {
  --brand: #21467f;
  --brand-dark: #14284f;
  --brand-tint: #e8eef8;
  --gold: #5aa9e6;
  --ink: #151b26;
  --muted: #5d6675;
  --line: #e3e7ee;
  --bg: #f2f4f8;
  --shadow: 0 1px 2px rgb(16 24 40 / .05), 0 6px 20px rgb(16 24 40 / .06);
  --accent-line: rgb(90 169 230 / .6);
  --ring: rgb(33 70 127 / .16);
  --mark: linear-gradient(140deg, #6fb7ee, #2f6fc0 55%, #173a78);
  --mark-shadow: rgb(23 58 120 / .4);
  --login-picture: linear-gradient(165deg, rgb(8 16 36 / .45), rgb(8 16 36 / .05) 50%, rgb(8 16 36 / .40)), url(/img/audit-bg.svg);
  --login-base: #0e1c3a;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--brand-dark); }
h1 { font-size: 22px; letter-spacing: -.01em; line-height: 1.25; margin: 0; }
h2 { font-size: 18px; letter-spacing: -.01em; margin: 24px 0 10px; }
h3 {
  color: var(--brand-dark);
  font-size: 12px;
  letter-spacing: .07em;
  margin: 0 0 8px;
  text-transform: uppercase;
}
p { margin: 0; }

.topbar {
  align-items: center;
  background: linear-gradient(120deg, var(--brand-dark), var(--brand));
  box-shadow: 0 1px 0 var(--accent-line), 0 6px 18px rgb(16 32 26 / .14);
  color: #fff;
  display: flex;
  gap: 8px;
  min-height: 56px;
  padding: 8px 12px;
  padding-top: max(8px, env(safe-area-inset-top));
  position: sticky;
  top: 0;
  z-index: 1000;
}
.topbar .title small { display: block; font-size: 10.5px; font-weight: 600; letter-spacing: .09em; line-height: 1.3; opacity: .72; overflow: hidden; text-overflow: ellipsis; text-transform: uppercase; }
.topbar .title { flex: 1; font-size: 17px; font-weight: 600; letter-spacing: -.01em; line-height: 1.2; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iconbtn {
  align-items: center;
  background: none;
  border: 0;
  border-radius: 10px;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font-size: 15px;
  height: 38px;
  justify-content: center;
  min-width: 38px;
  padding: 0 8px;
  text-decoration: none;
}
.iconbtn:hover { background: rgb(255 255 255 / .16); }
.iconbtn.me {
  background: rgb(255 255 255 / .14);
  border: 1px solid rgb(255 255 255 / .28);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .03em;
  padding: 0;
  width: 38px;
}
.iconbtn.me:hover { background: rgb(255 255 255 / .26); }
.demo-banner {
  background: var(--warn-bg);
  color: var(--warn-ink);
  font-size: 13px;
  padding: 6px 16px;
  text-align: center;
}

main {
  margin: 0 auto;
  max-width: 720px;
  padding: 16px 16px calc(84px + env(safe-area-inset-bottom));
}

.tabs {
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  backdrop-filter: blur(16px) saturate(1.4);
  background: rgb(255 255 255 / .88);
  border-top: 1px solid var(--line);
  bottom: 0;
  display: flex;
  left: 0;
  padding-bottom: env(safe-area-inset-bottom);
  position: fixed;
  right: 0;
  z-index: 1000;
}
.tabs a {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex: 1;
  flex-direction: column;
  font-size: 12px;
  gap: 2px;
  padding: 7px 4px 8px;
  text-decoration: none;
}
.tabs svg {
  border-radius: 999px;
  box-sizing: content-box;
  fill: none;
  height: 22px;
  padding: 3px 16px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
  transition: background-color .15s;
  width: 22px;
}
.tabs a.active { color: var(--brand-dark); font-weight: 600; }
.tabs a.active svg { background: var(--brand-tint); }

.row-between { align-items: center; display: flex; gap: 12px; justify-content: space-between; }
.stack > * + * { margin-top: 10px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.num { font-variant-numeric: tabular-nums; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px;
}
.card + .card { margin-top: 12px; }
.list { background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.list a.item, .list label.item, .list div.item {
  align-items: center;
  color: inherit;
  display: flex;
  gap: 12px;
  padding: 13px 16px;
  text-decoration: none;
  transition: background-color .12s;
}
.list .item + .item { border-top: 1px solid var(--line); }
.list a.item:hover { background: var(--brand-tint); }
.item .grow { flex: 1; min-width: 0; }
.item .name { font-weight: 600; overflow-wrap: anywhere; }
.chev { color: var(--muted); }
.avatar {
  align-items: center;
  background: var(--brand-tint);
  border-radius: 12px;
  color: var(--brand-dark);
  display: flex;
  flex: none;
  font-weight: 700;
  height: 48px;
  justify-content: center;
  object-fit: cover;
  width: 48px;
}

.pill {
  background: var(--brand-tint);
  border-radius: 999px;
  color: var(--brand-dark);
  display: inline-block;
  font-size: 12.5px;
  font-weight: 500;
  padding: 2px 10px;
}
.pill.pending { background: var(--warn-bg); color: var(--warn-ink); }
.pill.off { background: #edf0ef; color: var(--muted); }
.pill.high { background: #fdeeec; color: var(--danger); }
details.card summary { cursor: pointer; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  padding: 6px 12px;
  text-decoration: none;
}
.chip.active { background: var(--brand-tint); border-color: var(--brand); color: var(--brand-dark); font-weight: 600; }

label.field { display: block; font-size: 14px; font-weight: 600; }
label.field + label.field, .field-gap { margin-top: 14px; }
label.field .hint { color: var(--muted); font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=search], input[type=number], input[type=date], select, textarea {
  background: #fff;
  border: 1px solid #cdd5d2;
  border-radius: 10px;
  color: var(--ink);
  display: block;
  font: inherit;
  font-weight: 400;
  margin-top: 5px;
  min-height: 46px;
  padding: 10px 12px;
  transition: border-color .12s, box-shadow .12s;
  width: 100%;
}
input:focus, select:focus, textarea:focus, canvas:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--ring); outline: none; }
.check { align-items: center; display: flex; font-weight: 400; gap: 10px; min-height: 36px; }
.check input { height: 20px; width: 20px; }
.grid2 { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.grid2 > label.field + label.field { margin-top: 0; }

.btn {
  align-items: center;
  background: var(--brand);
  border: 1px solid var(--brand);
  border-radius: 10px;
  box-shadow: 0 1px 2px rgb(16 32 26 / .18);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-weight: 600;
  gap: 6px;
  justify-content: center;
  min-height: 46px;
  padding: 10px 16px;
  text-decoration: none;
  transition: background-color .12s, border-color .12s, transform .06s;
}
.btn:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .chip:focus-visible, .iconbtn:focus-visible, .tabs a:focus-visible, a.item:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.btn:disabled { cursor: progress; opacity: .6; }
.btn.secondary { background: #fff; border-color: #cdd5d2; box-shadow: none; color: var(--brand-dark); }
.btn.secondary:hover { background: var(--brand-tint); }
.btn.danger { background: #fff; border-color: var(--danger); box-shadow: none; color: var(--danger); }
.btn.danger:hover { background: #fdeeec; border-color: var(--danger); }
.btn.block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.btn-row .btn { flex: 1 1 140px; }

.error { background: #fdeeec; border-radius: 10px; color: var(--danger); font-size: 14px; margin-top: 12px; padding: 10px 12px; }
.empty { color: var(--muted); padding: 24px 14px; text-align: center; }

.map { background: #e8ecea; border-radius: 14px; box-shadow: var(--shadow); height: 240px; margin-bottom: 14px; z-index: 0; }
.hero { border-radius: 14px; display: block; margin-bottom: 12px; max-height: 240px; object-fit: cover; width: 100%; }
.doc-img { border: 1px solid var(--line); border-radius: 8px; display: block; margin-top: 6px; max-height: 320px; max-width: 100%; }

.sign-wrap { border: 1px dashed #aab5b1; border-radius: 10px; margin-top: 6px; overflow: hidden; }
canvas.sign { background: #fff; cursor: crosshair; display: block; height: 170px; touch-action: none; width: 100%; }
.linkbtn { background: none; border: 0; color: var(--brand-dark); cursor: pointer; font: inherit; font-size: 14px; padding: 6px 0; text-decoration: underline; }

dl.facts { display: grid; gap: 4px 12px; grid-template-columns: max-content 1fr; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }

/* Sign-in: the oil picture (public/img/oil-bg.svg, drawn by scripts/make-background.py) under a dark wash,
   so the white card and the caption stay readable. */
.login {
  align-items: center;
  background-color: var(--login-base);
  background-image: var(--login-picture);
  background-position: center;
  background-size: cover;
  display: flex;
  flex-direction: column;
  gap: 18px;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px 16px;
}
.login .card {
  -webkit-backdrop-filter: blur(22px) saturate(1.3);
  backdrop-filter: blur(22px) saturate(1.3);
  background: rgb(255 255 255 / .93);
  border: 1px solid rgb(255 255 255 / .7);
  border-radius: 22px;
  box-shadow: 0 30px 70px rgb(8 14 10 / .45), 0 2px 6px rgb(8 14 10 / .2);
  max-width: 400px;
  padding: 30px 26px 26px;
  width: 100%;
}
.login h1 { font-size: 23px; margin-bottom: 6px; }
.login .btn { min-height: 48px; }
.login-foot { color: rgb(255 255 255 / .78); font-size: 13px; letter-spacing: .02em; text-shadow: 0 1px 2px rgb(0 0 0 / .4); }
.brandmark {
  align-items: center;
  background: var(--mark);
  border-radius: 14px;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .45), 0 6px 14px var(--mark-shadow);
  display: flex;
  height: 48px;
  justify-content: center;
  margin-bottom: 18px;
  width: 48px;
}
.brandmark svg { fill: #fff; height: 26px; width: 26px; }

table.simple { border-collapse: collapse; font-size: 14px; width: 100%; }
table.simple th, table.simple td { border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: left; vertical-align: top; }
table.simple th { color: var(--muted); font-weight: 600; }
table.simple .right { text-align: right; }

@media (min-width: 720px) {
  .tabs { justify-content: center; }
  .tabs a { flex: 0 1 150px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
