:root {
  --cp-tap-min: 48px;
  --cp-blue: #1456c0;
  --cp-dark: #0b3f91;
  --cp-cyan: #13a8e6;
  --cp-red: #e12636;
  --cp-green: #138a56;
  --cp-line: #dfe6ef;
  --cp-bg: #f5f7fa;
  --cp-card: #fff;
  --cp-muted: #667085;

  --bs-primary: var(--cp-blue);
  --bs-primary-rgb: 20, 86, 192;
  --bs-link-color: var(--cp-blue);
  --bs-link-color-rgb: 20, 86, 192;
  --bs-link-hover-color: var(--cp-dark);
  --bs-body-bg: var(--cp-bg);
  --bs-border-radius: 0.7rem;
  --bs-border-radius-lg: 0.85rem;
}
:root[data-bs-theme="dark"] {
  --cp-bg: #0e1420;
  --cp-card: #161d2b;
  --cp-line: #29344a;
  --cp-muted: #93a0b8;
  --bs-body-bg: var(--cp-bg);
}

body {
  padding-bottom: 4rem;
  background: var(--cp-bg);
}

.btn, .form-check-input, .form-control, .form-select {
  min-height: var(--cp-tap-min);
}
.btn { font-weight: 700; }
.btn-primary {
  background: linear-gradient(135deg, #2d68d8, #1751bf);
  border-color: #1751bf;
}
.btn-success {
  background: linear-gradient(135deg, #12479f, #06337e);
  border-color: #06337e;
}

.form-check-input {
  width: 1.6em;
  height: 1.6em;
  margin-top: 0;
}

.card {
  background: var(--cp-card);
  border: 1px solid var(--cp-line);
  border-radius: 0.9rem;
  box-shadow: 0 8px 28px rgba(16, 24, 40, .08);
}

.item-card {
  border-radius: 0.75rem;
}

.item-card .form-check {
  padding-left: 2.4em;
}

.note-indicator {
  font-size: 0.75rem;
}

.signature-pad {
  touch-action: none;
  width: 100%;
  border: 2px dashed var(--cp-line);
  border-radius: 0.5rem;
  background: #fff;
}

.template-tile {
  cursor: pointer;
  transition: transform 0.1s ease;
}
.template-tile:active {
  transform: scale(0.98);
}

.photo-thumb {
  width: 84px;
  height: 84px;
  object-fit: cover;
  border-radius: 0.5rem;
}

.offline-banner {
  display: none;
  position: sticky;
  top: 0;
  z-index: 1050;
}
body.is-offline .offline-banner {
  display: block;
}

/* Top brand bar + header, shared across pages */
.cp-topline {
  height: 6px;
  background: linear-gradient(90deg, var(--cp-dark), var(--cp-blue), var(--cp-cyan));
}
.cp-navbar {
  background: var(--cp-card);
  border-bottom: 1px solid var(--cp-line);
}
.cp-navbar .navbar-brand {
  color: var(--cp-dark);
  font-weight: 800;
}

/* Checklist run screen: field grid + grouped section table */
.cp-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}
.cp-field label {
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 0.4rem;
  display: block;
}
.cp-field .req { color: var(--cp-red); }

.cp-group {
  border: 1px solid var(--cp-line);
  border-radius: 0.6rem;
  overflow: hidden;
}
.cp-group-head {
  display: grid;
  grid-template-columns: minmax(160px, 1.6fr) .8fr .8fr .9fr;
  background: linear-gradient(90deg, rgba(20,86,192,.08), rgba(19,168,230,.08));
  color: var(--cp-blue);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .02em;
}
.cp-group-head > div, .cp-row > div {
  padding: 0.6rem 0.7rem;
  border-right: 1px solid var(--cp-line);
  display: flex;
  align-items: center;
}
.cp-group-head > div:last-child, .cp-row > div:last-child { border-right: 0; }
.cp-row {
  display: grid;
  grid-template-columns: minmax(160px, 1.6fr) .8fr .8fr .9fr;
  border-top: 1px solid var(--cp-line);
  align-items: stretch;
}
.cp-row.cp-row-bad { background: rgba(225, 38, 54, .06); }
.cp-row-name { font-weight: 600; font-size: 0.9rem; }
.cp-choice {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  margin: 0 auto;
}
.cp-choice.ok { color: var(--cp-blue); }
.cp-choice.no { color: var(--cp-red); }
.cp-obs-btn {
  padding: 0.35rem 0.6rem;
  min-height: auto;
  border: 1px solid var(--cp-blue);
  background: #fff;
  color: var(--cp-blue);
  border-radius: 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
}
.cp-obs-btn.has { background: rgba(20, 86, 192, .1); }

@media (max-width: 700px) {
  .cp-group-head, .cp-row { grid-template-columns: minmax(120px, 1.2fr) .7fr .7fr .8fr; }
  .cp-group-head > div, .cp-row > div { padding: 0.5rem 0.35rem; font-size: 0.78rem; }
  .cp-choice span { display: none; }
}

.cp-sidebar { display: flex; flex-direction: column; gap: 1rem; }
.cp-side-title {
  font-weight: 800;
  color: var(--cp-blue);
  font-size: 1rem;
  margin-bottom: 0.9rem;
}
.cp-progress-track {
  flex: 1; height: 10px; background: var(--cp-line);
  border-radius: 999px; overflow: hidden;
}
.cp-progress-fill {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--cp-blue), var(--cp-cyan));
  transition: width .2s;
}
.cp-stats {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; margin-top: 1rem;
}
.cp-stat {
  padding: 0.7rem; text-align: center; border-radius: 0.6rem;
  border: 1px solid rgba(20,86,192,.25); background: rgba(20,86,192,.06);
}
.cp-stat.cp-stat-no { border-color: rgba(225,38,54,.3); background: rgba(225,38,54,.06); }
.cp-stat b { display: block; font-size: 1.6rem; color: var(--cp-blue); }
.cp-stat.cp-stat-no b { color: var(--cp-red); }
.cp-stat span { font-size: 0.68rem; font-weight: 800; color: var(--cp-blue); }
.cp-stat.cp-stat-no span { color: var(--cp-red); }

.cp-sign-empty {
  min-height: 160px; border: 1px dashed var(--cp-line); border-radius: 0.6rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--cp-blue); text-align: center; padding: 1rem; gap: .4rem;
}
.cp-sign-result img { max-width: 100%; max-height: 140px; }

@media (max-width: 480px) {
  .btn-lg-mobile {
    width: 100%;
  }
}
