:root {
  --bg: #f4f6f5;
  --card: #ffffff;
  --text: #1b2420;
  --muted: #5f6b66;
  --border: #dde3e0;
  --primary: #1f7a4d;
  --primary-dark: #17603c;
  --primary-soft: #e6f2ec;
  --danger: #b3261e;
  --danger-soft: #fbe9e7;
  --warn: #8a5a00;
  --warn-soft: #fff4dc;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--primary); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hidden { display: none !important; }

.wrap { max-width: 640px; margin: 0 auto; padding: 16px; }
.wrap-wide { max-width: 1180px; margin: 0 auto; padding: 16px; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }
.hero { background: linear-gradient(135deg, #17603c 0%, #1f7a4d 60%, #2d9463 100%); color: #fff; border: 0; }
.hero .muted { color: rgba(255,255,255,.85); }
.hero .brand { font-size: .8rem; letter-spacing: .12em; text-transform: uppercase; opacity: .85; margin-bottom: 6px; }
.facts { display: grid; gap: 8px; margin: 14px 0 4px; }
.fact { display: flex; gap: 10px; align-items: flex-start; }
.fact .ico { width: 22px; flex: none; text-align: center; }

label.lbl { display: block; font-weight: 600; margin: 0 0 6px; }
.field { margin-bottom: 18px; }
input[type=text], input[type=date], input[type=time], input[type=search], select, textarea {
  width: 100%; font: inherit; color: inherit; background: #fff;
  border: 1px solid var(--border); border-radius: 10px; padding: 11px 12px; font-size: 16px;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: var(--primary); }

.options { display: grid; gap: 8px; }
.options.cols-2 { grid-template-columns: 1fr 1fr; }
.options.cols-3 { grid-template-columns: repeat(3, 1fr); }
.opt { position: relative; }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt span {
  display: block; border: 1.5px solid var(--border); border-radius: 10px; padding: 12px 14px;
  cursor: pointer; background: #fff; transition: border-color .15s, background .15s; height: 100%;
}
.opt input:checked + span { border-color: var(--primary); background: var(--primary-soft); font-weight: 600; }
.opt input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.opt span:hover { border-color: #b9c5bf; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; border: 1px solid transparent; border-radius: 10px;
  padding: 11px 18px; cursor: pointer; background: var(--primary); color: #fff; text-decoration: none;
}
.btn:hover { background: var(--primary-dark); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.block { width: 100%; padding: 14px; font-size: 1.05rem; }
.btn.ghost { background: #fff; color: var(--text); border-color: var(--border); }
.btn.ghost:hover { background: #f1f4f2; }
.btn.danger { background: #fff; color: var(--danger); border-color: #efc4c0; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.sm { padding: 6px 10px; font-size: .875rem; border-radius: 8px; }

.alert { border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; }
.alert.error { background: var(--danger-soft); color: var(--danger); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.ok { background: var(--primary-soft); color: var(--primary-dark); }

.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: #eef1ef; color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--primary-soft); color: var(--primary-dark); }
.badge.no { background: var(--danger-soft); color: var(--danger); }
.badge.pend { background: var(--warn-soft); color: var(--warn); }

.summary { list-style: none; padding: 0; margin: 0; }
.summary li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.summary li:last-child { border-bottom: 0; }
.summary li b { text-align: right; }

.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 12px 0 24px; }

/* ---------- admin */
.topbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.topbar h1 { margin: 0; font-size: 1.35rem; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tab { background: none; border: 0; font: inherit; padding: 10px 14px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.tile .v { font-size: 1.8rem; font-weight: 700; line-height: 1.1; }
.tile .k { color: var(--muted); font-size: .85rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.bar { height: 8px; background: #eef1ef; border-radius: 99px; overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--primary); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #fafbfa; position: sticky; top: 0; }
td.actions { white-space: nowrap; text-align: right; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar input[type=search] { max-width: 260px; }
.toolbar select { width: auto; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > .field { flex: 1 1 200px; }
.check { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.check input { width: 18px; height: 18px; }

.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 50; overflow-y: auto; }
.modal { background: #fff; border-radius: var(--radius); width: 100%; max-width: 560px; padding: 20px; box-shadow: 0 10px 40px rgba(0,0,0,.2); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1b2420; color: #fff; padding: 10px 18px; border-radius: 10px; z-index: 60; font-size: .92rem; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
#qr img, #qr canvas { margin-top: 8px; }

@media (max-width: 640px) {
  h1 { font-size: 1.35rem; }
  .card { padding: 16px; }
  .options.cols-3 { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
}
@media print {
  .tabs, .toolbar, .topbar .btn, td.actions { display: none !important; }
  body { background: #fff; }
}
