/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 14.5px;
  background: var(--gray-100);
  color: var(--gray-700);
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }

.btn svg { width: 18px; height: 18px; flex-shrink: 0; }

.btn:hover { background: var(--gray-200); }

.btn-primary {
  background: var(--brand-gradient);
  color: #fff;
  box-shadow: 0 1px 2px rgba(11, 41, 41, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.btn-primary:hover { background: var(--color-primary-dark); box-shadow: var(--shadow-brand); }

.btn-outline {
  background: var(--surface);
  border-color: var(--gray-200);
  color: var(--gray-700);
  box-shadow: var(--shadow-sm);
}
.btn-outline:hover { border-color: var(--color-primary); color: var(--color-primary); background: var(--color-primary-50); }

.btn-danger {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}
.btn-danger:hover { background: #f8d9d7; }

.btn-success {
  background: linear-gradient(135deg, #12875a 0%, #1aa36e 100%);
  color: #fff;
  box-shadow: 0 1px 2px rgba(11, 41, 41, 0.12);
}
.btn-success:hover { background: #0d6b47; box-shadow: 0 6px 16px -6px rgba(18, 135, 90, 0.55); }

.btn-ghost {
  background: transparent;
  color: var(--gray-600);
}
.btn-ghost:hover { background: var(--gray-100); }

.btn-sm {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13.5px;
  border-radius: var(--radius-sm);
}

.btn-block { width: 100%; }

.btn:disabled, .btn.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--gray-600);
  position: relative;
  flex-shrink: 0;
}
.icon-btn { transition: background var(--transition-fast), color var(--transition-fast); }
.icon-btn:hover { background: var(--gray-100); color: var(--gray-900); }

/* ==========================================================================
   Badges & pills
   ========================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.6;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-success { background: var(--color-success-bg); color: var(--color-success); }
.badge-warning { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-danger  { background: var(--color-danger-bg);  color: var(--color-danger); }
.badge-info    { background: var(--color-info-bg);    color: var(--color-info); }
.badge-neutral { background: var(--color-neutral-bg); color: var(--color-neutral); }

.priority-tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.priority-critical { background: var(--priority-critical-bg); color: var(--priority-critical); }
.priority-high     { background: var(--priority-high-bg);     color: var(--priority-high); }
.priority-medium   { background: var(--priority-medium-bg);   color: var(--priority-medium); }
.priority-low      { background: var(--priority-low-bg);      color: var(--priority-low); }

.badge-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-danger);
  border: 2px solid var(--surface);
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--gray-100);
  color: var(--gray-600);
  font-size: 12.5px;
  font-weight: 600;
}

/* ==========================================================================
   Cards
   ========================================================================== */

.card {
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card-pad { padding: 18px; }
@media (min-width: 1024px) { .card-pad { padding: 22px; } }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 0;
}

.card-header h2, .card-header h3 { margin: 0; }

.card-body { padding: 16px; }

.card-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
}

.card-link {
  display: block;
  transition: box-shadow var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}
a.card-link:hover, .card-link:hover {
  border-color: #c7dbf2;
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* ==========================================================================
   Section headings
   ========================================================================== */

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 28px 0 12px;
}
.section-heading:first-child { margin-top: 0; }

.section-heading h2 {
  font-size: 16.5px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-heading h2::before {
  content: '';
  width: 4px;
  height: 18px;
  border-radius: 2px;
  background: var(--color-secondary);
  flex-shrink: 0;
}

.section-heading .link-more {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--color-primary);
  flex-shrink: 0;
}

.page-intro {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.page-intro > * {
  min-width: 0;
}

.page-intro > div {
  flex: 1 1 240px;
}

.page-intro p {
  color: var(--gray-500);
  font-size: 14.5px;
  max-width: 64ch;
}

/* ==========================================================================
   Grid utilities
   ========================================================================== */

.grid {
  display: grid;
  gap: 14px;
}
.grid-2 { grid-template-columns: repeat(1, 1fr); }
.grid-3 { grid-template-columns: repeat(1, 1fr); }
.grid-4 { grid-template-columns: repeat(2, 1fr); }

@media (min-width: 640px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 860px) {
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
}

/* ==========================================================================
   Stat tiles
   ========================================================================== */

.stat-tile {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}
.stat-tile::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--brand-gradient);
  opacity: 0.85;
}
a.stat-tile:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.stat-tile-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}

.stat-tile-value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  color: var(--gray-900);
  line-height: 1;
  margin-bottom: 8px;
}

.stat-tile-value small {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-400);
}

.stat-tile-delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  font-weight: 700;
}
.stat-tile-delta.up { color: var(--color-success); }
.stat-tile-delta.down { color: var(--color-danger); }
.stat-tile-delta .vs { color: var(--gray-400); font-weight: 500; margin-left: 2px; }

/* ==========================================================================
   Score ring
   ========================================================================== */

.score-ring {
  --ring-size: 96px;
  --ring-value: 0;
  --ring-color: var(--color-primary);
  width: var(--ring-size);
  height: var(--ring-size);
  border-radius: 50%;
  background: conic-gradient(var(--ring-color) calc(var(--ring-value) * 1%), var(--gray-100) 0);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.score-ring-inner {
  width: calc(var(--ring-size) - 16px);
  height: calc(var(--ring-size) - 16px);
  border-radius: 50%;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.score-ring-inner strong {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  color: var(--gray-900);
  line-height: 1;
}

.score-ring-inner small {
  font-size: 10.5px;
  color: var(--gray-500);
  font-weight: 600;
  text-transform: uppercase;
  /* One line in every browser: never wrap, and stay inside the ring. */
  white-space: nowrap;
  line-height: 1.2;
  margin-top: 4px;
  max-width: 100%;
  text-align: center;
}

.score-ring.is-warning {
  --ring-color: var(--color-warning);
}
.score-ring.is-success { --ring-color: var(--color-success); }
.score-ring.is-danger  { --ring-color: var(--color-danger); }
/* Score number takes the ring's colour too, so the state reads at a glance. */
.score-ring.is-success .score-ring-inner strong { color: var(--color-success); }
.score-ring.is-warning .score-ring-inner strong { color: var(--color-warning); }
.score-ring.is-danger .score-ring-inner strong  { color: var(--color-danger); }

/* Medium ring used on vendor detail pages, between the default (96px) and
   the compact card variant used in list rows. */
.score-ring-md {
  --ring-size: 88px;
}
.score-ring-md .score-ring-inner {
  width: 72px;
  height: 72px;
}
.score-ring-md .score-ring-inner strong {
  font-size: 20px;
}

/* ==========================================================================
   Progress / meter bars
   ========================================================================== */

.meter {
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--gray-100);
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  width: 0;
  border-radius: var(--radius-full);
  background: var(--color-primary);
}
.meter-fill.success { background: var(--color-success); }
.meter-fill.warning { background: var(--color-warning); }
.meter-fill.danger { background: var(--color-danger); }

.meter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.meter-row:last-child { margin-bottom: 0; }
.meter-row-label {
  flex: 0 0 128px;
  font-size: 13px;
  color: var(--gray-600);
  font-weight: 600;
}
.meter-row .meter { flex: 1; }
.meter-row-value {
  flex: 0 0 40px;
  text-align: right;
  font-size: 13px;
  font-weight: 700;
  color: var(--gray-800);
}

/* ==========================================================================
   Avatars
   ========================================================================== */

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary-light), #d2e6fb);
  color: var(--color-primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.avatar-sm { width: 32px; height: 32px; font-size: 12.5px; }
.avatar-lg { width: 52px; height: 52px; font-size: 17px; }

/* ==========================================================================
   Forms
   ========================================================================== */

.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.form-label .required { color: var(--color-danger); }

.form-hint {
  font-size: 12.5px;
  color: var(--gray-500);
  margin-top: 5px;
}

.form-control {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid #d3dce8;
  border-radius: var(--radius-md);
  background: var(--surface);
  font-size: 15px;
  color: var(--gray-800);
  box-shadow: inset 0 1px 1px rgba(11, 41, 41, 0.03);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.form-control:hover:not(:focus):not(:disabled) { border-color: var(--gray-400); }
.form-control::placeholder { color: var(--gray-400); }

textarea.form-control {
  min-height: 92px;
  padding: 12px 14px;
  resize: vertical;
}

.form-control:focus {
  border-color: var(--color-primary);
  outline: none;
  box-shadow: 0 0 0 4px rgba(5, 127, 123, 0.14);
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24'><path fill='%23677487' d='M7 10l5 5 5-5z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 38px;
}

.form-row {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .form-row-2 { grid-template-columns: 1fr 1fr; }
  .form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
}

.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--gray-50);
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label {
  flex: 1;
  text-align: center;
  padding: 11px 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--gray-600);
  border-radius: var(--radius-sm);
  min-height: 38px;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}
.segmented label:hover { color: var(--gray-900); }
.segmented input:checked + label {
  background: var(--surface);
  color: var(--color-primary);
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--color-primary-light);
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
}

/* Vertically aligns a toggle with an adjacent field's input box when the
   field above it has a label (which a bare toggle-row doesn't need). */
.toggle-row-aligned {
  padding-top: 28px;
}

.toggle-row-text strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
}
.toggle-row-text small {
  color: var(--gray-500);
  font-size: 12.5px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 26px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track {
  position: absolute;
  inset: 0;
  background: var(--gray-300);
  border-radius: var(--radius-full);
  transition: background var(--transition-fast);
}
.switch-track::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition-fast);
  box-shadow: var(--shadow-sm);
}
.switch input:checked + .switch-track {
  background: var(--color-primary);
}
.switch input:checked + .switch-track::before {
  transform: translateX(18px);
}

/* Rating input (1-5) */
.rating-input {
  display: flex;
  gap: 8px;
}
.rating-input input { position: absolute; opacity: 0; pointer-events: none; }
.rating-input label {
  width: 44px;
  height: 44px;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid #d3dce8;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--gray-600);
}
.rating-input input:checked + label {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

/* Yes/No & Done/Not Done pill choice */
.choice-pills {
  display: flex;
  gap: 8px;
}
.choice-pills input { position: absolute; opacity: 0; pointer-events: none; }
.choice-pills label {
  flex: 1;
  min-height: 46px;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid #d3dce8;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 600;
  font-size: 14px;
  color: var(--gray-600);
}
.choice-pills input:checked + label.choice-positive {
  background: var(--color-success-bg);
  border-color: var(--color-success);
  color: var(--color-success);
}
.choice-pills input:checked + label.choice-negative {
  background: var(--color-danger-bg);
  border-color: var(--color-danger);
  color: var(--color-danger);
}

/* ==========================================================================
   Tabs / filter chips
   ========================================================================== */

.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 16px;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab-chip {
  flex-shrink: 0;
  padding: 9px 16px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--gray-600);
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tab-chip .count {
  background: var(--gray-100);
  color: var(--gray-500);
  border-radius: var(--radius-full);
  font-size: 11.5px;
  padding: 1px 7px;
}

.tab-chip:hover { border-color: #c7dbf2; color: var(--color-primary); }
.tab-chip.is-active {
  background: var(--brand-gradient);
  border-color: transparent;
  color: #fff;
  box-shadow: var(--shadow-brand);
}
.tab-chip.is-active .count {
  background: rgba(255,255,255,0.18);
  color: #fff;
}

/* ==========================================================================
   Search / filter bar
   ========================================================================== */

.filter-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-field {
  flex: 1;
  min-width: 180px;
  position: relative;
}
.search-field svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
}
.search-field input {
  padding-left: 40px;
}

.filter-select {
  min-width: 130px;
  flex: 1;
}

@media (min-width: 640px) {
  .filter-select { flex: 0 0 auto; }
}

/* ==========================================================================
   List / detail rows
   ========================================================================== */

.info-list {
  display: flex;
  flex-direction: column;
}
.info-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-100);
  font-size: 14px;
}
.info-row:last-child { border-bottom: none; }
.info-row-label { color: var(--gray-500); flex-shrink: 0; }
.info-row-value { font-weight: 600; color: var(--gray-800); text-align: right; }

/* ==========================================================================
   Timeline
   ========================================================================== */

.timeline {
  position: relative;
  padding-left: 24px;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--gray-200);
}
.timeline-item {
  position: relative;
  padding-bottom: 20px;
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
  content: '';
  position: absolute;
  left: -24px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-primary);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 2px var(--color-primary);
}
.timeline-item-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-weight: 700;
  font-size: 13.5px;
  color: var(--gray-800);
  margin-bottom: 3px;
}
.timeline-item-head time {
  font-weight: 500;
  color: var(--gray-400);
  font-size: 12px;
  white-space: nowrap;
}
.timeline-item p {
  font-size: 13.5px;
  color: var(--gray-600);
  margin: 0;
}

/* Status stepper (defect workflow) */
.stepper {
  display: flex;
  overflow-x: auto;
  gap: 0;
  scrollbar-width: none;
}
.stepper::-webkit-scrollbar { display: none; }
.stepper-step {
  flex: 1;
  min-width: 84px;
  text-align: center;
  position: relative;
  padding-top: 22px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--gray-400);
}
.stepper-step::before {
  content: '';
  position: absolute;
  top: 6px;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gray-200);
}
.stepper-step::after {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--gray-200);
  border: 3px solid var(--surface);
}
.stepper-step:first-child::before { left: 50%; }
.stepper-step:last-child::before { right: 50%; }
.stepper-step.is-complete { color: var(--gray-700); }
.stepper-step.is-complete::before { background: var(--color-primary); }
.stepper-step.is-complete::after { background: var(--color-primary); }
.stepper-step.is-current { color: var(--color-primary-dark); }
.stepper-step.is-current::after {
  background: var(--color-primary);
  box-shadow: 0 0 0 4px var(--color-primary-light);
}

/* ==========================================================================
   Flash alerts
   ========================================================================== */

.alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  border-left-width: 4px;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 18px;
}
.alert-success { background: var(--color-success-bg); color: #0b6b46; border-color: #bfe8d4; border-left-color: var(--color-success); }
.alert-danger { background: var(--color-danger-bg); color: #a92a21; border-color: #f7cdc9; border-left-color: var(--color-danger); }

/* ==========================================================================
   Empty / error states
   ========================================================================== */

.state-panel {
  text-align: center;
  padding: 48px 20px;
  color: var(--gray-500);
}
.state-panel .state-icon {
  width: 60px;
  height: 60px;
  margin: 0 auto 16px;
  border-radius: 18px;
  background: var(--color-primary-light);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}
.state-panel.is-error .state-icon {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}
.state-panel h3 {
  font-size: 15.5px;
  color: var(--gray-800);
  margin-bottom: 4px;
}
.state-panel p {
  font-size: 13.5px;
  max-width: 32ch;
  margin: 0 auto 16px;
}

/* Skeleton loading */
.skeleton {
  background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 37%, var(--gray-100) 63%);
  background-size: 400% 100%;
  animation: skeleton-loading 1.4s ease infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton-loading {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}
.skeleton-line { height: 12px; margin-bottom: 8px; }
.skeleton-card { height: 96px; border-radius: var(--radius-lg); }

/* ==========================================================================
   Dropdown
   ========================================================================== */

.dropdown {
  position: relative;
}
.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 190px;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 70;
  display: none;
}
.dropdown-menu.is-open { display: block; }
.dropdown-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--gray-400);
  padding: 6px 10px 4px;
}
.dropdown-item {
  display: block;
  padding: 10px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-700);
  min-height: 40px;
  display: flex;
  align-items: center;
}
.dropdown-item:hover { background: var(--gray-50); }
.dropdown-item.is-active {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  font-weight: 600;
}

/* ==========================================================================
   Modal / bottom sheet
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(11, 41, 41, 0.55);
  backdrop-filter: blur(3px);
  z-index: 80;
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.modal-backdrop.is-open { display: flex; }

.modal-sheet {
  background: var(--surface);
  width: 100%;
  max-width: 520px;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: sheet-up var(--transition-base);
}

@keyframes sheet-up {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-handle {
  width: 40px;
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--gray-200);
  margin: 10px auto 0;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color);
}
.modal-header h3 { margin: 0; font-size: 17px; }
.modal-body { padding: 18px; }
.modal-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 10px;
}
.modal-footer .btn { flex: 1; }

@media (min-width: 640px) {
  .modal-backdrop { align-items: center; }
  .modal-sheet { border-radius: var(--radius-xl); }
  .modal-handle { display: none; }
}

/* ==========================================================================
   Toast
   ========================================================================== */

.toast-stack {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + 16px);
  left: 16px;
  right: 16px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
@media (min-width: 1024px) {
  .toast-stack { bottom: 24px; left: auto; right: 24px; align-items: flex-end; }
}

.toast {
  background: var(--navy-800);
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 360px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--transition-base), transform var(--transition-base);
}
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast.toast-success svg { color: #4ade80; }
.toast.toast-error svg { color: #f87171; }

/* ==========================================================================
   Misc
   ========================================================================== */

.divider { height: 1px; background: var(--border-color); margin: 16px 0; }

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.flex-between > *:first-child {
  min-width: 0;
}

.text-muted { color: var(--gray-500); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.text-danger { color: var(--color-danger); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-strong { font-weight: 700; }

.mt-0 { margin-top: 0; }
.mt-8 { margin-top: 8px; }
.mt-10 { margin-top: 10px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mt-24 { margin-top: 24px; }

.mb-0 { margin-bottom: 0; }
.mb-4 { margin-bottom: 4px; }
.mb-8 { margin-bottom: 8px; }
.mb-10 { margin-bottom: 10px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-18 { margin-bottom: 18px; }
.mb-20 { margin-bottom: 20px; }
.mb-24 { margin-bottom: 24px; }

.flex-1 { flex: 1; }
.flex-2 { flex: 2; }
.flex-shrink-0 { flex-shrink: 0; }

/* Ad-hoc heading sizes used inside page-intro / detail heroes / card headers,
   so pages never need inline font-size overrides. */
.heading-page { font-size: 22px; }
.heading-detail { font-size: 20px; }
.heading-card { font-size: 15.5px; }
.text-strong-md { font-weight: 700; font-size: 16px; }

.action-buttons-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.status-badge-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.overflow-x-auto { overflow-x: auto; }

/* A card-styled variant of .state-panel for inline empty/success states
   that sit among regular cards rather than filling the whole page. */
.state-panel.is-card {
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
}
.state-panel.is-success .state-icon {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.form-footer-bar {
  display: flex;
  gap: 10px;
  box-shadow: var(--shadow-lg);
  position: sticky;
  bottom: calc(var(--bottom-nav-height) + 12px);
}
@media (min-width: 1024px) {
  .form-footer-bar { bottom: 20px; }
}

.qr-scan-box {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius-lg);
  padding: 32px 20px;
  text-align: center;
  color: var(--gray-500);
  background: var(--gray-50);
}
.qr-scan-box.is-scanning {
  border-color: var(--color-primary);
  color: var(--color-primary-dark);
  background: var(--color-primary-50);
}
.qr-scan-box.is-scanned {
  border-style: solid;
  border-color: var(--color-success);
  background: var(--color-success-bg);
  color: var(--color-success);
}
/* Geo-fenced checklist: outside the allowed area (or no location yet). */
.qr-scan-box.is-geo-failed {
  border-style: solid;
  border-color: var(--color-danger);
  background: var(--color-danger-bg);
  color: var(--color-danger);
}
.qr-scan-box.is-geo-failed .qr-scan-sub { color: var(--gray-700); max-width: 46ch; margin-left: auto; margin-right: auto; }
.qr-scan-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
}

/* Geo-location card on the checklist form. */
.geo-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* Print-only report header, hidden on screen */
.print-only { display: none; }

@media print {
  .sidebar, .sidebar-overlay, .topbar, .bottom-nav, .no-print { display: none !important; }
  .app-main { margin-left: 0 !important; }
  .page-content { padding: 0 !important; max-width: none !important; }
  .print-only { display: block; }
  body { background: #fff; }
}

/* Stat-tile rows whose tile count varies (e.g. permission-dependent tiles). */
.grid-auto { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 860px) {
  .grid-auto { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
}

/* ==========================================================================
   Graphics — welcome banner, intro decoration, illustrated empty states
   ========================================================================== */

/* Dashboard greeting with the facility illustration. */
.page-intro.welcome-hero {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 120px;
  align-items: center;
  gap: 12px 16px;
  padding: 20px;
  border-radius: var(--radius-xl);
  border: 1px solid #cfe8e6;
  background:
    radial-gradient(60% 120% at 100% 0%, rgba(16, 163, 157, 0.16) 0%, transparent 70%),
    radial-gradient(40% 80% at 0% 100%, rgba(18, 184, 134, 0.08) 0%, transparent 70%),
    linear-gradient(135deg, #ffffff 0%, #eef8f7 100%);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.welcome-hero-text { grid-column: 1; }
.welcome-hero .heading-page { font-size: 22px; margin-bottom: 4px; }
.welcome-hero-eyebrow {
  display: inline-block;
  margin-bottom: 6px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: var(--surface);
  border: 1px solid #cfe8e6;
  color: var(--color-primary);
  font-size: 11.5px;
  font-weight: 600;
}
.welcome-hero-art {
  grid-column: 2;
  grid-row: 1 / span 2;
  width: 100%;
  height: auto;
  align-self: end;
}
.welcome-hero .report-toolbar { grid-column: 1; grid-row: 2; justify-self: start; }
@media (min-width: 640px) {
  .page-intro.welcome-hero { grid-template-columns: 1fr 220px; padding: 24px 28px; }
  .welcome-hero .heading-page { font-size: 26px; }
}
@media (min-width: 1024px) {
  .page-intro.welcome-hero { grid-template-columns: 1fr 300px; padding: 28px 32px; }
  .welcome-hero .heading-page { font-size: 30px; }
}

/* Every other page intro gets a soft accent bar and a faint dot pattern. */
.page-intro:not(.welcome-hero) {
  position: relative;
  padding-left: 16px;
}
.page-intro:not(.welcome-hero)::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 4px;
  border-radius: 4px;
  background: var(--color-secondary);
}

/* Empty states: icon sits on a soft blob with little sparkles around it. */
.state-panel .state-icon {
  position: relative;
  width: 72px;
  height: 72px;
  margin-bottom: 22px;
  border-radius: 22px;
  background: var(--brand-gradient);
  color: #fff;
  box-shadow: 0 12px 24px -10px rgba(5, 127, 123, 0.55);
  isolation: isolate;
}
.state-panel .state-icon svg { width: 30px; height: 30px; }
.state-panel .state-icon::before {
  content: '';
  position: absolute;
  inset: -26px -44px;
  z-index: -1;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 124' fill='none'><path d='M22 66c-6-30 18-56 52-60 30-3 46 10 66 6 14 6 20 26 16 46-6 32-30 52-66 56-36 4-62-14-68-48z' fill='%23e3f3f1'/><path d='M20 22l2 5 5 2-5 2-2 5-2-5-5-2 5-2z' fill='%23fecb2e'/><path d='M142 94l1.6 4 4 1.6-4 1.6-1.6 4-1.6-4-4-1.6 4-1.6z' fill='%2310a39d'/><circle cx='146' cy='26' r='4' fill='%23b5dcd8'/><circle cx='14' cy='100' r='3' fill='%2312b886' opacity='.6'/></svg>") center / contain no-repeat;
}
.state-panel.is-error .state-icon {
  background: linear-gradient(135deg, #e5483d 0%, #ff7a6e 100%);
  color: #fff;
  box-shadow: 0 12px 24px -10px rgba(209, 58, 47, 0.5);
}
.state-panel.is-success .state-icon {
  background: linear-gradient(135deg, #12875a 0%, #2fc48a 100%);
  color: #fff;
  box-shadow: 0 12px 24px -10px rgba(18, 135, 90, 0.5);
}
.state-panel.is-warning .state-icon {
  background: linear-gradient(135deg, #c27400 0%, #fecb2e 100%);
  color: #fff;
  box-shadow: 0 12px 24px -10px rgba(184, 106, 0, 0.5);
}
.state-panel h3 { font-size: 17px; }

/* Insight / admin icon tiles: a touch larger, softer corners. */
.insight-icon svg { width: 20px; height: 20px; }

@media (max-height: 800px) {
  .auth-illustration { max-height: 170px; }
}

/* Insights hero: period selector + report toolbar sit together */
.welcome-hero .welcome-hero-tools { grid-column: 1; grid-row: 2; justify-self: start; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.welcome-hero .welcome-hero-tools .report-toolbar { grid-column: auto; grid-row: auto; }
