:root {
  --brand: #4f8f7f;
  --brand-dark: #3b7062;
  --brand-tint: #eef5f3;
  --ink: #1d2523;
  --muted: #66716e;
  --line: #e2e7e5;
  --bg: #f5f7f6;
  --card: #ffffff;
  --danger: #b3382c;
  --warn-bg: #fff6e0;
  --warn-ink: #6d5200;
  color-scheme: light;
}

* { 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; margin: 0; line-height: 1.25; }
h2 { font-size: 18px; margin: 24px 0 10px; }
h3 {
  color: var(--brand-dark);
  font-size: 12px;
  letter-spacing: .05em;
  margin: 0 0 8px;
  text-transform: uppercase;
}
p { margin: 0; }

.topbar {
  align-items: center;
  background: var(--brand);
  color: #fff;
  display: flex;
  gap: 8px;
  min-height: 54px;
  padding: 8px 12px;
  padding-top: max(8px, env(safe-area-inset-top));
  position: sticky;
  top: 0;
  z-index: 1000;
}
.topbar .title { flex: 1; font-size: 17px; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iconbtn {
  align-items: center;
  background: none;
  border: 0;
  border-radius: 8px;
  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); }
.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 {
  background: var(--card);
  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 {
  color: var(--muted);
  flex: 1;
  font-size: 13px;
  padding: 15px 4px;
  text-align: center;
  text-decoration: none;
}
.tabs a.active { box-shadow: inset 0 3px 0 var(--brand); color: var(--brand-dark); font-weight: 600; }

.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: 12px;
  padding: 14px;
}
.card + .card { margin-top: 12px; }
.list { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.list a.item, .list label.item, .list div.item {
  align-items: center;
  color: inherit;
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  text-decoration: none;
}
.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: 10px;
  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: 13px;
  padding: 2px 10px;
}
.pill.pending { background: var(--warn-bg); color: var(--warn-ink); }
.pill.off { background: #edf0ef; color: var(--muted); }
.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 #c9d1ce;
  border-radius: 10px;
  color: var(--ink);
  display: block;
  font: inherit;
  font-weight: 400;
  margin-top: 5px;
  min-height: 44px;
  padding: 9px 12px;
  width: 100%;
}
input:focus, select:focus, textarea:focus, canvas:focus { border-color: var(--brand); outline: 2px solid rgb(79 143 127 / .25); }
.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;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-weight: 600;
  gap: 6px;
  justify-content: center;
  min-height: 44px;
  padding: 9px 16px;
  text-decoration: none;
}
.btn:hover { background: var(--brand-dark); }
.btn:disabled { cursor: progress; opacity: .6; }
.btn.secondary { background: #fff; color: var(--brand-dark); }
.btn.secondary:hover { background: var(--brand-tint); }
.btn.danger { background: #fff; border-color: var(--danger); color: var(--danger); }
.btn.danger:hover { background: #fdeeec; }
.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: 12px; height: 240px; margin-bottom: 14px; z-index: 0; }
.hero { border-radius: 12px; 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; }

.login { align-items: center; display: flex; justify-content: center; min-height: 100vh; padding: 16px; }
.login .card { max-width: 380px; width: 100%; }
.login h1 { margin-bottom: 4px; }

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; }
}
