/* Shared tokens and controls. CRC Evans design system.
   Taken from the approved prototype. Keep the two in step. */

:root {
  --hero-red: #EB1C37;
  --hero-red-10: #FBD2D7;
  --hero-red-20: #F8B3BC;
  --hero-red-60: #C4172E;
  --readable-red: #C4001F;
  --blueprint-blue: #00273F;
  --heritage-grey: #969696;
  --text-grey: #464646;
  --galvanizing-green: #1F9A3A;
  --thin-yellow: #FFCA57;
  --page-bg: #F5F6F8;
  --border: #E2E5EA;
  --divider: #EEF0F3;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Montserrat', sans-serif;
  background: var(--page-bg);
  color: var(--text-grey);
  font-size: 13px;
  line-height: 1.6;
}

.hidden { display: none !important; }
.heading { font-family: 'Funnel Sans', sans-serif; color: var(--blueprint-blue); }

/* ---------- Cards ---------- */
.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  padding: 4px 24px 8px;
  margin-bottom: 16px;
}
.card.accent { border-top: 3px solid var(--hero-red); }
.card.accent.good { border-top-color: var(--galvanizing-green); }
.card.accent.blue { border-top-color: var(--blueprint-blue); }

.sec-label { display: flex; align-items: center; gap: 10px; padding: 18px 0 4px; }
.sec-label .lbl, .caps {
  font-size: 10px; font-weight: 700; color: var(--heritage-grey);
  text-transform: uppercase; letter-spacing: 0.06em; white-space: nowrap;
}
.sec-label .line { flex: 1; height: 1px; background: var(--border); }

.notice {
  margin: 16px 0 0;
  border: 1px solid var(--border); border-left: 3px solid var(--readable-red);
  border-radius: 8px; background: var(--page-bg);
  padding: 10px 14px; font-size: 11.5px;
}
.notice.blue { border-left-color: var(--blueprint-blue); }
.notice.yellow { border-left-color: var(--thin-yellow); }

/* ---------- Questions and fields ---------- */
.q { padding: 16px 0; border-bottom: 1px solid var(--divider); }
.q:last-child { border-bottom: none; }
.q-label { font-size: 13px; font-weight: 600; color: var(--blueprint-blue); margin-bottom: 9px; display: block; }
.q-label .star { color: var(--readable-red); margin-left: 3px; }
.q-label .opt { color: var(--heritage-grey); font-weight: 500; font-size: 11.5px; margin-left: 6px; }
.q-help { font-size: 11.5px; color: var(--heritage-grey); margin: -5px 0 9px; }
.err { display: none; font-size: 11.5px; font-weight: 600; color: var(--readable-red); margin-top: 7px; }
.q.invalid .err { display: block; }
.q.invalid .fld, .q.invalid .select-trigger { border-color: var(--readable-red); }

.fld {
  width: 100%;
  font-family: 'Montserrat', sans-serif; font-size: 13px; color: var(--text-grey);
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; transition: border-color 0.15s ease;
}
.fld::placeholder { color: var(--heritage-grey); }
.fld:focus { outline: none; border-color: var(--blueprint-blue); }
.fld:disabled { background: var(--page-bg); color: var(--heritage-grey); }
textarea.fld { min-height: 84px; resize: vertical; line-height: 1.6; }
.fld.sm { padding: 7px 10px; font-size: 12px; }
/* Phones zoom into any text box under 16px when it is tapped, and stay zoomed. */
@media (pointer: coarse) {
  .fld, .fld.sm, .select-search input { font-size: 16px; }
}
/* Stops a quick second tap on a button or tile zooming the page. Pinch zoom still works. */
button, .tile, .choice, .kind { touch-action: manipulation; }
.two-up { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- Radio and checkbox rows ---------- */
.choice {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 9px 11px; border: 1px solid transparent; border-radius: 8px;
  cursor: pointer; transition: background 0.12s ease, border-color 0.12s ease;
}
.choice:hover { background: var(--page-bg); }
.choice input { position: absolute; opacity: 0; width: 0; height: 0; }
.choice .box {
  flex: 0 0 auto; width: 17px; height: 17px; margin-top: 1px;
  border: 1.5px solid #C0C5CE; background: #fff; transition: all 0.12s ease;
  display: flex; align-items: center; justify-content: center;
}
.choice .box.radio { border-radius: 50%; }
.choice .box.check { border-radius: 4px; }
.choice .box svg { width: 10px; height: 10px; opacity: 0; }
.choice .txt { font-size: 13px; color: var(--text-grey); }
.choice .txt .hint { display: block; font-size: 11.5px; color: var(--heritage-grey); line-height: 1.5; font-weight: 400; }
.choice input:focus-visible ~ .box { box-shadow: 0 0 0 3px rgba(235, 28, 55, 0.18); }
.choice input:checked ~ .box { border-color: var(--hero-red); background: var(--hero-red); }
.choice input:checked ~ .box.radio { box-shadow: inset 0 0 0 3.5px #fff; }
.choice input:checked ~ .box.check svg { opacity: 1; }
.choice input:checked ~ .txt { color: var(--blueprint-blue); font-weight: 600; }
.choice.on { background: var(--hero-red-10); border-color: var(--hero-red-20); }
.choice.disabled { opacity: 0.5; cursor: not-allowed; }
.choice-group { margin: 0 -11px; }
.choice-group.inline { display: flex; flex-wrap: wrap; gap: 4px; }
.group-head { font-size: 10px; font-weight: 700; color: var(--heritage-grey); text-transform: uppercase; letter-spacing: 0.06em; padding: 12px 11px 4px; }

/* ---------- Single select: button plus listbox, never a native select ---------- */
.select { position: relative; }
.select-trigger {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-family: 'Montserrat', sans-serif; font-size: 13px; text-align: left;
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; cursor: pointer; transition: border-color 0.15s ease;
}
.select.sm .select-trigger { padding: 7px 10px; font-size: 12px; }
.select-trigger:focus { outline: none; border-color: var(--blueprint-blue); }
.select-trigger .val { color: var(--text-grey); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.select-trigger .val.ph { color: var(--heritage-grey); }
.select-trigger .chev { color: var(--heritage-grey); transition: transform 0.15s ease; flex: 0 0 auto; }
.select.open .select-trigger .chev { transform: rotate(180deg); }
.select-menu {
  display: none; position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 100;
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 39, 63, 0.12); max-height: 260px; overflow-y: auto;
}
.select.open .select-menu { display: block; }
.select-search { padding: 8px; border-bottom: 1px solid var(--divider); position: sticky; top: 0; background: #fff; }
.select-search input { width: 100%; font-family: 'Montserrat', sans-serif; font-size: 12px; border: 1px solid var(--border); border-radius: 6px; padding: 7px 10px; }
.select-search input:focus { outline: none; border-color: var(--blueprint-blue); }
.select-opt { padding: 9px 12px; font-size: 13px; color: var(--text-grey); cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.select-opt:hover, .select-opt.active { background: var(--page-bg); }
.select-opt[aria-selected="true"] { background: var(--hero-red-10); color: var(--readable-red); font-weight: 500; }
.select-opt svg { opacity: 0; flex: 0 0 auto; }
.select-opt[aria-selected="true"] svg { opacity: 1; }
.select-empty { padding: 12px; font-size: 12px; color: var(--heritage-grey); text-align: center; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-family: 'Montserrat', sans-serif; font-size: 13px; font-weight: 500;
  border-radius: 8px; padding: 9px 18px; border: 1px solid transparent;
  cursor: pointer; transition: all 0.15s ease; text-decoration: none; white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; flex: 0 0 auto; }
.btn.sm { font-size: 12px; padding: 7px 13px; }
.btn.lg { font-size: 15px; padding: 14px 30px; }
.btn-primary { background: var(--hero-red); color: #fff; }
.btn-primary:hover { background: var(--hero-red-60); }
.btn-secondary { background: var(--blueprint-blue); color: #fff; }
.btn-secondary:hover { opacity: 0.9; }
.btn-outline { background: #fff; color: var(--text-grey); border-color: var(--border); }
.btn-outline:hover { border-color: var(--heritage-grey); background: var(--page-bg); }
.btn-danger { background: var(--readable-red); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-grey); }
.btn-ghost:hover { background: var(--page-bg); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.link { color: var(--hero-red); font-weight: 500; text-decoration: none; cursor: pointer; background: none; border: none; font: inherit; padding: 0; }
.link:hover { text-decoration: underline; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border);
  background: #fff; color: var(--blueprint-blue); cursor: pointer; transition: all 0.15s ease;
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { background: var(--page-bg); }
.icon-btn.danger { color: var(--readable-red); }
.icon-btn.danger:hover { border-color: var(--readable-red); }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- Status badges: always a dot plus a pill ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 7px; padding: 3px 12px;
  border-radius: 20px; font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.good { color: var(--galvanizing-green); background: rgba(31, 154, 58, 0.08); }
.badge.warn { color: #B38600; background: rgba(230, 161, 0, 0.08); }
.badge.warn .dot { background: #E6A100; }
.badge.no { color: var(--readable-red); background: rgba(196, 0, 31, 0.06); }
.badge.info { color: var(--blueprint-blue); background: rgba(0, 39, 63, 0.06); }
.badge.mute { color: var(--heritage-grey); background: var(--page-bg); }
.tag { font-size: 10px; font-weight: 500; color: var(--blueprint-blue); background: rgba(0, 39, 63, 0.06); padding: 2px 7px; border-radius: 4px; white-space: nowrap; }

/* ---------- Filter pills and segmented control ---------- */
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  font-family: 'Montserrat', sans-serif; font-size: 12px; font-weight: 500;
  padding: 4px 13px; border-radius: 20px; cursor: pointer; transition: all 0.15s ease;
  background: #fff; border: 1px solid var(--border); color: var(--blueprint-blue);
}
.pill:hover { border-color: #C0C5CE; background: #FAFBFC; }
.pill.on { background: var(--hero-red-10); border-color: var(--hero-red-20); color: var(--readable-red); }
.seg { display: inline-flex; background: var(--page-bg); border: 1px solid var(--border); border-radius: 8px; padding: 3px; }
.seg button {
  font-family: 'Montserrat', sans-serif; font-size: 12.5px; font-weight: 500;
  padding: 5px 14px; border-radius: 6px; border: none; background: transparent;
  color: var(--heritage-grey); cursor: pointer; transition: all 0.15s ease;
}
.seg button:hover { color: var(--blueprint-blue); }
.seg button.on { background: #fff; color: var(--blueprint-blue); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06); }

/* ---------- Toggle switch ---------- */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; background: #C0C5CE; border-radius: 22px; cursor: pointer; transition: background 0.15s ease; }
.switch .track::before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform 0.15s ease; }
.switch input:checked + .track { background: var(--galvanizing-green); }
.switch input:checked + .track::before { transform: translateX(18px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px rgba(0, 39, 63, 0.18); }

/* ---------- Prototype flag ---------- */
.proto-flag {
  border: 1px solid var(--border); border-left: 3px solid var(--thin-yellow);
  border-radius: 8px; background: #fff; padding: 9px 14px; font-size: 11.5px;
}
.proto-flag strong { color: var(--blueprint-blue); }
