/*
 * ADDITIVE ONLY — this stylesheet never overrides a rule in app.css.
 *
 * The approved design system is complete for the screens the prototype built.
 * These rules supply the §28.6 components the prototype never needed, and the
 * §29.2 / §29.3 / §29.4 standards it was missing:
 *
 *   · the two animations referenced by loading and skeleton states
 *   · a visible focus ring on every interactive element (§29.3)
 *   · prefers-reduced-motion (§29.2)
 *   · pill, tabs, segmented control, toolbar, search, tooltip (§28.6)
 *   · the 620px and 1280px breakpoints (§29.4 — app.css has only 900px)
 *
 * Every value is drawn from the tokens already defined in app.css. No new
 * colour, type size or spacing value is introduced.
 */

/* --- animations referenced by loading and skeleton states ------------------ */
@keyframes hvr-spin { to { transform: rotate(360deg); } }
@keyframes hvr-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* --- §29.3 Focus: visible on every interactive element, never removed ------- */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(46, 141, 163, 0.28);
  border-radius: var(--r-sm);
}
.skip-card:focus-visible,
.jump-btn:focus-visible,
.acc-card:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(46, 141, 163, 0.28);
}

/* --- §28.6 Pill: status indicator ------------------------------------------ */
.pill {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: var(--card-2);
  color: var(--ink-2);
}
.pill.ok { background: var(--ok-bg); border-color: var(--ok-border); color: var(--ok); }
.pill.minor { background: var(--minor-bg); border-color: var(--minor-border); color: var(--minor); }
.pill.major { background: var(--major-bg); border-color: var(--major-border); color: var(--major); }
.pill.crit { background: var(--critical-bg); border-color: var(--critical-border); color: var(--critical); }

/* --- §28.6 Tabs: underline style, 2px active border ------------------------ */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  appearance: none;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 9px 14px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-3);
  cursor: pointer;
  white-space: nowrap;
  transition: color 160ms cubic-bezier(.2,.7,.3,1), border-color 160ms cubic-bezier(.2,.7,.3,1);
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--brand-600); border-bottom-color: var(--brand-600); }
.tab .count {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--card-3);
  font-size: 10.5px;
  color: var(--ink-2);
}
.tab.active .count { background: var(--brand-050); color: var(--brand-600); }

/* --- §28.6 Segmented control: range switching ------------------------------ */
.segmented {
  display: inline-flex;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.segmented button {
  appearance: none;
  background: var(--card);
  border: none;
  border-right: 1px solid var(--line-2);
  padding: 6px 13px;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
  transition: background 160ms cubic-bezier(.2,.7,.3,1);
}
.segmented button:last-child { border-right: none; }
.segmented button:hover { background: var(--card-3); }
.segmented button.active { background: var(--brand-600); color: #fff; }

/* --- §28.6 Toolbar: filters, spacer, then search --------------------------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  margin-bottom: 16px;
  box-shadow: var(--sh-1);
}
.toolbar .spacer { flex: 1 1 auto; }
.toolbar select,
.toolbar input[type="date"] {
  font-family: var(--font-body);
  font-size: 12.5px;
  padding: 7px 9px;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  background: var(--card);
  color: var(--ink);
}

/* --- §28.6 Search: inset glyph at 12px, 34px left padding ------------------ */
.search-wrap { position: relative; display: inline-flex; align-items: center; }
.search-wrap .ico {
  position: absolute;
  left: 12px;
  width: 14px;
  height: 14px;
  color: var(--ink-4);
  pointer-events: none;
}
.search-wrap input {
  padding: 8px 12px 8px 34px;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  font-family: var(--font-body);
  font-size: 13px;
  min-width: 220px;
  background: var(--card);
  color: var(--ink);
}

/* --- §28.6 Tooltip --------------------------------------------------------- */
.tip { position: relative; }
.tip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--brand-900);
  color: #fff;
  font-family: var(--font-body);
  font-size: 11.5px;
  line-height: 1.4;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  max-width: 260px;
  width: max-content;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms cubic-bezier(.2,.7,.3,1);
  z-index: 300;
}
.tip:hover::after, .tip:focus-visible::after { opacity: 1; }

/* --- Evidence thumbnails --------------------------------------------------- */
.evidence-thumb {
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--card-3);
  display: block;
}
.evidence-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }

/* --- Heatmap cell (§24) ---------------------------------------------------- */
.heat-cell {
  width: 13px;
  height: 16px;
  border-radius: 2px;
  margin: 0 auto;
  background: var(--card-3);
  border: 1px solid var(--line-3);
}
.heat-cell.excellent { background: var(--ok); border-color: var(--ok); }
.heat-cell.needs_improvement { background: var(--minor); border-color: var(--minor); }
.heat-cell.poor { background: var(--major); border-color: var(--major); }
.heat-cell.critical_fail { background: var(--critical); border-color: var(--critical); }
.heat-cell.missed,
.heat-cell.not_performed { background: repeating-linear-gradient(45deg, var(--card-3), var(--card-3) 2px, var(--line-2) 2px, var(--line-2) 4px); }

/* --- §29.4 Responsive: the breakpoints app.css does not carry -------------- */

/* > 1280px — content capped so line lengths stay readable on wide monitors */
@media (min-width: 1281px) {
  #main-content > div { max-width: 1480px; }
}

/* < 620px — phone: single column, tables scroll inside their card */
@media (max-width: 620px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar .search-wrap, .toolbar input, .toolbar select { width: 100%; }
  .search-wrap input { min-width: 0; }
  .card { padding: 16px; }
}

@media (max-width: 420px) {
  .kpi-grid { grid-template-columns: 1fr; }
}

/* --- §29.2 Reduced motion -------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* --- Print (§25): the report stylesheet ------------------------------------ */
@media print {
  .no-print, .toolbar, .mobile-bottom-nav, #sidebar, #top-nav-bar, .btn { display: none !important; }
  .card { box-shadow: none !important; border: 1px solid #ccc !important; break-inside: avoid; }
  body { background: #fff; }
}
