/* ==========================================================================
   4. Surface Cards & KPI Tiles
   ========================================================================== */
.hvl-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.hvl-card:hover {
  border-color: var(--border-bright);
}

.card-header {
  padding: var(--card-header-padding);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-surface);
}

.card-body {
  padding: var(--card-padding);
}

.hvl-card-header,
.card-header-clean {
  margin-bottom: 20px;
}

.hvl-card-header h2,
.hvl-card-header h3,
.card-header-clean h2,
.card-header-clean h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 4px 0;
  line-height: 1.25;
}

.hvl-card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
}

.hvl-card-title-group {
  min-width: 0;
  flex: 1 1 240px;
}

.hvl-card-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.hvl-card-title-row h1,
.hvl-card-title-row h2,
.hvl-card-title-row h3,
.hvl-card-title-row h4,
.hvl-card-title-row strong {
  margin: 0;
}

td .hvl-card-title-row {
  margin-bottom: 0;
}

.hvl-card-subtitle {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.hvl-card-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
  min-width: 0;
  max-width: 100%;
}

.hvl-card-actions:empty {
  display: none;
}

.hvl-subcard,
.hvl-callout {
  background: var(--bg-canvas);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 16px;
  box-sizing: border-box;
}

.hvl-subcard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.hvl-subcard-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-primary);
}

.hvl-callout-blue {
  background: var(--brand-primary-bg);
  border-color: var(--brand-primary-border);
}

.hvl-callout-amber,
.hvl-callout-orange,
.hvl-callout-warn {
  background: var(--accent-amber-bg);
  border-color: var(--accent-amber-border);
}

.hvl-callout-green {
  background: var(--status-green-bg);
  border-color: var(--status-green-border);
}

.hvl-callout-red,
.hvl-callout-rose {
  background: var(--status-red-bg);
  border-color: var(--status-red-border);
}

@media (max-width: 768px) {
  .hvl-card-header,
  .card-header-clean {
    margin-bottom: 14px;
  }

  .hvl-card-header h2,
  .hvl-card-header h3,
  .card-header-clean h2,
  .card-header-clean h3 {
    margin-bottom: 2px;
  }

  .hvl-card-header-row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .hvl-card-title-group {
    flex: 1 1 auto;
  }

  .hvl-card-title-row,
  .hvl-subcard-header {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: 4px 6px;
  }

  .hvl-card-title-row > h1,
  .hvl-card-title-row > h2,
  .hvl-card-title-row > h3,
  .hvl-card-title-row > h4,
  .hvl-card-title-row > strong,
  .hvl-subcard-header > h1,
  .hvl-subcard-header > h2,
  .hvl-subcard-header > h3,
  .hvl-subcard-header > h4,
  .hvl-subcard-header > strong,
  .hvl-subcard-header > .hvl-subcard-title,
  .hvl-subcard-header > .micro-label {
    flex: 0 0 100%;
  }

  .hvl-card-actions {
    width: 100%;
    justify-content: flex-start;
    gap: 6px;
  }

  .btn-icon,
  .hvl-icon-btn,
  .hvl-card-actions .btn-icon,
  .hvl-card-actions .hvl-icon-btn {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    max-width: 32px !important;
    flex: 0 0 32px !important;
  }
}

.kpi-tile {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--card-radius);
  padding: var(--card-header-padding);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
  box-shadow: var(--card-shadow);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.kpi-tile:hover {
  border-color: var(--border-bright);
}

.kpi-val {
  font-size: clamp(1.4rem, 2.5vw, 1.85rem);
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.kpi-lbl {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ==========================================================================
   Canonical Theme Toggle Button & Appearance Choice Cards
   ========================================================================== */
.theme-btn-compact {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  width: var(--hvl-header-btn-height);
  height: var(--hvl-header-btn-height);
  min-width: var(--hvl-header-btn-height);
  min-height: var(--hvl-header-btn-height);
  padding: 0;
  cursor: pointer;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  box-sizing: border-box;
  flex-shrink: 0;
}

.theme-btn-compact:hover {
  background: var(--bg-surface-elevated);
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.theme-btn-compact .theme-icon-sun {
  display: none;
}

.theme-btn-compact .theme-icon-moon {
  display: inline-block;
}

[data-theme="dark"] .theme-btn-compact .theme-icon-sun {
  display: inline-block;
}

[data-theme="dark"] .theme-btn-compact .theme-icon-moon {
  display: none;
}

.theme-choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

.theme-choice-card {
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 14px;
  cursor: pointer;
  background: var(--bg-surface);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
}

.theme-choice-card:hover {
  border-color: var(--border-bright);
}

.theme-choice-card.is-selected {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 2px var(--accent-blue-border);
}

.theme-choice-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.theme-choice-card-label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-choice-card-title {
  font-size: 0.875rem;
}

.theme-choice-radio {
  cursor: pointer;
}

.theme-choice-card-desc {
  font-size: 0.75rem;
  margin: 0;
  line-height: 1.45;
}


