/* ═══════════════════════════════════════════════════════════
   HSA RECEIPT TRACKER — Scoped Styles
   Uses FT CSS variables for consistency.
═══════════════════════════════════════════════════════════ */

/* ── Sub-Navigation ── */
.hsa-subnav {
  display: flex;
  justify-content: flex-start;
  gap: 2px;
  padding: 10px 14px;
  background: var(--bg-primary, #0d0d0d);
  border-bottom: 1px solid rgba(255,255,255,0.05);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  position: sticky;
  top: 0;
  z-index: 20;
}
.hsa-subnav::-webkit-scrollbar { display: none; }
@media (min-width: 901px) {
  .hsa-subnav { justify-content: center; }
}

.hsa-subnav-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted, #888);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 120ms ease, background 120ms ease;
}
.hsa-subnav-btn:hover {
  color: var(--text-primary, #e0e0e0);
}
.hsa-subnav-btn.active {
  color: var(--accent-primary, #ff5f10);
  font-weight: 600;
}
.hsa-subnav-btn.active::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 2px;
  height: 2px;
  background: var(--accent-primary, #ff5f10);
  border-radius: 2px;
}
.hsa-subnav-btn:focus-visible {
  outline: 2px solid rgba(255,95,16,0.5);
  outline-offset: 2px;
}
.hsa-subnav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  stroke: currentColor;
}
.hsa-subnav-label {
  font-size: 12px;
  line-height: 1;
}

/* ── Content Area ── */
#hsa-content {
  padding: 20px 16px;
  min-height: 300px;
}

/* ── Section Headers ── */
.hsa-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}
.hsa-section-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-heading, #fff);
  margin: 0;
}
.hsa-count {
  font-weight: 400;
  font-size: 0.85rem;
  color: var(--text-muted, #888);
}

/* ── Stat Grid (Dashboard) ── */
.hsa-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--card-gap, 12px);
  margin-bottom: var(--section-mb, 20px);
}
.hsa-stat-card {
  background: var(--bg-card, #111111);
  border: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
  border-radius: 10px;
  padding: var(--card-pad, 16px);
  text-align: center;
}
.hsa-stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent-primary, #ff5f10);
  margin-bottom: 4px;
}
.hsa-stat-value.hsa-stat-warn { color: #f59e0b; }
.hsa-stat-value.hsa-stat-good { color: #10b981; }
.hsa-stat-clickable { cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.hsa-stat-clickable:hover { border-color: var(--accent-primary, #ff5f10); background: rgba(255,255,255,0.03); }
.hsa-stat-label {
  font-size: 0.75rem;
  color: var(--text-muted, #888);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Cards ── */
.hsa-card-list {
  display: flex;
  flex-direction: column;
  gap: var(--bill-gap, 8px);
}
.hsa-card {
  background: var(--bg-card, #111111);
  border: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
  border-radius: var(--radius-md, 10px);
  padding: var(--card-body-pad-y, 14px) var(--card-body-pad-x, 16px);
  box-shadow: var(--shadow-card);
  transition:
    border-color var(--dur-fast, 150ms) var(--ease-out, cubic-bezier(0.22, 1, 0.36, 1)),
    box-shadow var(--dur-med, 220ms) var(--ease-out, cubic-bezier(0.22, 1, 0.36, 1)),
    transform var(--dur-med, 220ms) var(--ease-out, cubic-bezier(0.22, 1, 0.36, 1));
  will-change: transform;
}
.hsa-card:hover {
  border-color: var(--border-accent, rgba(255,106,0,0.28));
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}
.hsa-card-archived { opacity: 0.6; }

.hsa-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.hsa-card-main { flex: 1; min-width: 0; }
.hsa-card-header-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  min-width: 0;
}
.hsa-card-vendor {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-heading, #fff);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}
.hsa-card-header-row .hsa-badge { flex-shrink: 0; }
.hsa-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 6px;
  font-size: 0.72rem;
  color: var(--text-muted, #aaa);
}
.hsa-meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 999px;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}
.hsa-meta-chip svg { width: 11px; height: 11px; opacity: 0.7; flex-shrink: 0; }
.hsa-meta-chip-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 140px;
}
.hsa-dot { opacity: 0.4; }
.hsa-card-notes {
  font-size: 0.76rem;
  color: var(--text-muted, #888);
  margin-top: 6px;
  font-style: italic;
}
.hsa-card-right {
  text-align: right;
  flex-shrink: 0;
}
.hsa-card-amount {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-heading, #fff);
  margin-bottom: 0;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.hsa-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle, rgba(255,255,255,0.04));
}
.hsa-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
  z-index: 2;
}

/* ── Status Badges ── */
.hsa-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.hsa-status-unreimbursed { background: rgba(245,158,11,0.15); color: #f59e0b; }
.hsa-status-reimbursed   { background: rgba(16,185,129,0.15); color: #10b981; }
.hsa-status-pending      { background: rgba(99,102,241,0.15); color: #818cf8; }
.hsa-status-ineligible   { background: rgba(239,68,68,0.15);  color: #ef4444; }

/* ── Readiness Mini Bar ── */
.hsa-readiness-mini {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  max-width: 200px;
}
.hsa-readiness-bar {
  flex: 1;
  height: 5px;
  background: rgba(255,255,255,0.06);
  border-radius: 3px;
  overflow: hidden;
}
.hsa-readiness-fill {
  height: 100%;
  background: var(--accent-primary, #ff5f10);
  border-radius: 3px;
  transition: width 0.3s;
}
.hsa-readiness-pct {
  font-size: 0.7rem;
  color: var(--text-muted, #888);
  font-weight: 600;
  white-space: nowrap;
}

/* ── Icon Buttons ── */
.hsa-btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  padding: 6px 8px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
  line-height: 1;
  min-width: 32px;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 2;
  color: var(--text-secondary, #a0a0a0);
}
.hsa-btn-icon:hover { background: rgba(255,255,255,0.08); color: var(--text-primary, #e0e0e0); }
.hsa-btn-icon svg { display: block; color: var(--text-secondary, #a0a0a0); transition: color 0.15s; }
.hsa-btn-icon:hover svg { color: var(--text-primary, #e0e0e0); }
.hsa-btn-icon-danger:hover { background: rgba(239, 68, 68, 0.12); }
.hsa-btn-icon-danger:hover svg { color: #ef4444; }

.hsa-btn-with-icon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.hsa-btn-with-icon svg {
  flex-shrink: 0;
}

.hsa-inline-icon {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.hsa-inline-icon svg {
  opacity: 0.75;
  width: 13px;
  height: 13px;
}

.hsa-attach-badge-count {
  margin-left: 3px;
  font-weight: 600;
}
.hsa-attach-file-icon-warn svg {
  color: var(--accent-primary, #ff5f10);
}

/* ── Buttons ── */
.hsa-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 7px 14px;
  border: none;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.hsa-btn:active { transform: scale(0.97); }
.hsa-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.hsa-btn-primary {
  background: var(--accent-primary, #ff5f10);
  color: #fff;
}
.hsa-btn-primary:hover:not(:disabled) {
  background: var(--accent-secondary, #e65500);
}

.hsa-btn-secondary {
  background: rgba(255,255,255,0.06);
  color: var(--text-primary, #e0e0e0);
  border: 1px solid var(--border-subtle, rgba(255,255,255,0.1));
}
.hsa-btn-secondary:hover:not(:disabled) {
  background: rgba(255,255,255,0.1);
}

/* Inline SVG icons inside hsa-btn: bigger + bolder stroke so they read clearly against the button */
.hsa-btn .emoji-ico { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; color: inherit; }
.hsa-btn .emoji-ico svg { width: 16px; height: 16px; stroke-width: 2.25; stroke: currentColor; color: inherit; }
.hsa-btn-primary,
.hsa-btn-primary .emoji-ico,
.hsa-btn-primary .emoji-ico svg { color: #fff; stroke: #fff; }
.hsa-btn-primary .emoji-ico svg { stroke-width: 2.5; }

/* ── Filters & Sort ── */
.hsa-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.hsa-search {
  flex: 1;
  min-width: 160px;
  padding: 7px 12px;
  border: 1px solid var(--border-subtle, rgba(255,255,255,0.1));
  border-radius: 6px;
  background: rgba(255,255,255,0.04);
  color: var(--text-primary, #e0e0e0);
  font-size: 16px; /* 16px prevents iOS Safari auto-zoom on focus */
  outline: none;
}
.hsa-search:focus { border-color: var(--accent-primary, #ff5f10); }
.hsa-search::placeholder { color: var(--text-muted, #888); }

.hsa-select {
  padding: 7px 10px;
  border: 1px solid var(--border-subtle, rgba(255,255,255,0.1));
  border-radius: 6px;
  background: rgba(255,255,255,0.04);
  color: var(--text-primary, #e0e0e0);
  font-size: 0.78rem;
  outline: none;
  cursor: pointer;
}
.hsa-select:focus { border-color: var(--accent-primary, #ff5f10); }

.hsa-sort-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
}
.hsa-sort-btn {
  padding: 4px 10px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted, #888);
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.hsa-sort-btn:hover { background: rgba(255,255,255,0.05); color: var(--text-primary, #e0e0e0); }
.hsa-sort-btn.active { color: var(--accent-primary, #ff5f10); font-weight: 600; }

/* ── Forms ── */
.hsa-form-card {
  background: var(--bg-card, #111111);
  border: 1px solid rgba(255,95,16,0.25);
  border-radius: 10px;
  padding: var(--card-pad, 16px);
  margin-bottom: var(--section-mb, 12px);
}
.hsa-form-title-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.hsa-form-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent-primary, #ff5f10);
  margin-bottom: 14px;
}
.hsa-form-close {
  display: none;
}
.hsa-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.hsa-form-group { display: flex; flex-direction: column; gap: 4px; }
.hsa-form-full { grid-column: 1 / -1; }
.hsa-form-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted, #888);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.hsa-input {
  padding: 7px 10px;
  border: 1px solid var(--border-subtle, rgba(255,255,255,0.1));
  border-radius: 6px;
  background: rgba(255,255,255,0.04);
  color: var(--text-primary, #e0e0e0);
  font-size: 0.84rem;
  outline: none;
  font-family: inherit;
}
.hsa-input:focus { border-color: var(--accent-primary, #ff5f10); }
.hsa-input::placeholder { color: var(--text-muted, #666); }
.hsa-textarea { resize: vertical; min-height: 40px; }
/* Field-level validation */
.hsa-input.hsa-input-error {
  border-color: #ef4444;
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.35);
}
.hsa-input.hsa-input-error:focus {
  border-color: #ef4444;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.25);
}
.hsa-field-error {
  color: #ef4444;
  font-size: 0.72rem;
  line-height: 1.3;
  margin-top: 4px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}
.hsa-field-error::before {
  content: "!";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #ef4444;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  flex-shrink: 0;
}

.hsa-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
}
.hsa-form-help {
  font-size: 0.75rem;
  color: var(--text-muted, #888);
  margin-top: 12px;
  line-height: 1.4;
}

/* ── Info Bar ── */
.hsa-info-bar {
  background: rgba(255,95,16,0.06);
  border: 1px solid rgba(255,95,16,0.15);
  border-radius: 8px;
  padding: var(--row-pad-y, 10px) 14px;
  font-size: 0.82rem;
  color: var(--text-secondary, #bbb);
  margin-bottom: var(--section-mb, 16px);
}

/* ── Contributions ── */
.hsa-year-group {
  margin-bottom: 20px;
}
.hsa-year-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.hsa-year-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-heading, #fff);
}
.hsa-year-summary {
  font-size: 0.82rem;
  color: var(--text-secondary, #bbb);
}
.hsa-over-limit {
  color: #ef4444;
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
}
.hsa-contrib-bar {
  height: 6px;
  background: rgba(255,255,255,0.06);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 12px;
}
.hsa-contrib-fill {
  height: 100%;
  background: var(--accent-primary, #ff5f10);
  border-radius: 3px;
  transition: width 0.3s;
}
.hsa-contrib-fill.hsa-over { background: #ef4444; }

/* ── Vendor Archive Toggle ── */
.hsa-archive-toggle {
  padding: 10px 0;
  font-size: 0.82rem;
  color: var(--text-muted, #888);
  cursor: pointer;
  user-select: none;
}
.hsa-archive-toggle:hover { color: var(--text-primary, #e0e0e0); }
.hsa-archived-list { opacity: 0.7; }

/* ── Activity Log ── */
.hsa-log-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.hsa-log-entry {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  transition: background 0.1s;
}
.hsa-log-entry:hover { background: rgba(255,255,255,0.03); }
.hsa-log-icon {
  flex-shrink: 0;
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px;
  background: rgba(255,95,16,0.08);
  color: var(--accent-primary, #ff5f10);
  margin-top: 1px;
}
.hsa-log-icon svg { display: block; }
.hsa-log-body { flex: 1; min-width: 0; }
.hsa-log-msg {
  font-size: 0.82rem;
  color: var(--text-primary, #e0e0e0);
  line-height: 1.4;
}
.hsa-log-time {
  font-size: 0.7rem;
  color: var(--text-muted, #666);
  margin-top: 2px;
}

/* ── Tax-Free Reimbursement Bank (Dashboard) ── */
.hsa-bank-card {
  background: linear-gradient(145deg, rgba(255,95,16,0.07) 0%, rgba(255,140,0,0.03) 70%, transparent 100%);
  border: 1px solid rgba(255,95,16,0.18);
}
.hsa-bank-pill {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent-primary, #ff5f10);
  background: rgba(255,95,16,0.10);
  padding: 3px 8px;
  border-radius: 10px;
  letter-spacing: 0.02em;
  text-transform: none;
}
.hsa-bank-hero {
  margin: 14px 0 6px;
  text-align: center;
}
.hsa-bank-hero-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent-primary, #ff5f10);
  letter-spacing: -0.01em;
  line-height: 1.1;
}
.hsa-bank-hero-sub {
  font-size: 0.74rem;
  color: var(--text-muted, #888);
  margin-top: 4px;
  letter-spacing: 0.02em;
}
.hsa-bank-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 14px 0 10px;
}
.hsa-bank-cell {
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 8px;
  padding: 10px 8px;
  text-align: center;
}
.hsa-bank-cell-val {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary, #e0e0e0);
}
.hsa-bank-cell-lbl {
  font-size: 0.68rem;
  color: var(--text-muted, #888);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}
.hsa-bank-note {
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--text-muted, #888);
  border-top: 1px solid rgba(255,255,255,0.05);
  padding-top: 10px;
  margin-top: 6px;
}
.hsa-bank-note em {
  color: var(--text-primary, #e0e0e0);
  font-style: italic;
}
@media (max-width: 480px) {
  .hsa-bank-hero-value { font-size: 1.6rem; }
  .hsa-bank-cell-val { font-size: 0.82rem; }
  .hsa-bank-cell-lbl { font-size: 0.62rem; }
}

/* ── Toast ── */
.hsa-toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 11000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: calc(100vw - 32px);
}
.hsa-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 260px;
  max-width: 420px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #1f1f1f;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  color: #e8e8e8;
  font-size: 0.85rem;
  line-height: 1.35;
  animation: hsaToastIn 0.18s ease-out;
}
@keyframes hsaToastIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.hsa-toast-leaving {
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.18s, transform 0.18s;
}
.hsa-toast-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-top: 1px;
}
.hsa-toast-info    .hsa-toast-icon { color: #5aa9ff; }
.hsa-toast-success .hsa-toast-icon { color: #3de8a0; }
.hsa-toast-warn    .hsa-toast-icon { color: #ffb547; }
.hsa-toast-error   .hsa-toast-icon { color: #ef4444; }
.hsa-toast-error   { border-color: rgba(239,68,68,0.35); }
.hsa-toast-warn    { border-color: rgba(255,181,71,0.35); }
.hsa-toast-success { border-color: rgba(61,232,160,0.35); }
.hsa-toast-msg {
  flex: 1;
  min-width: 0;
  word-wrap: break-word;
}
.hsa-toast-close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-muted, #888);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  min-width: 24px;
  min-height: 24px;
}
.hsa-toast-close:hover { color: #e8e8e8; }
.hsa-toast-action {
  flex-shrink: 0;
  background: rgba(255, 95, 16, 0.12);
  border: 1px solid rgba(255, 95, 16, 0.45);
  color: var(--accent-primary, #ff5f10);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  min-height: 28px;
}
.hsa-toast-action:hover {
  background: rgba(255, 95, 16, 0.22);
  color: #ff7a33;
}
.hsa-toast-action:focus-visible {
  outline: 2px solid var(--accent-primary, #ff5f10);
  outline-offset: 2px;
}
.hsa-toast-with-action { padding-right: 8px; }

/* ── Confirm Modal ── */
.hsa-confirm {
  position: fixed;
  inset: 0;
  z-index: 10500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: hsaConfirmFade 0.15s ease-out;
}
@keyframes hsaConfirmFade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.hsa-confirm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(3px);
  cursor: pointer;
}
.hsa-confirm-inner {
  position: relative;
  background: #1a1a1a;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  /* Extra bottom padding on phones reserves space for the home indicator */
  padding: 22px 24px max(18px, env(safe-area-inset-bottom));
  width: min(100%, 440px);
  max-width: 440px;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 14px;
  row-gap: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  animation: hsaConfirmPop 0.18s ease-out;
}
@keyframes hsaConfirmPop {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.hsa-confirm-icon {
  grid-row: 1;
  grid-column: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
}
.hsa-confirm-icon svg { width: 20px; height: 20px; }
.hsa-confirm-icon-info   { background: rgba(90,169,255,0.15); color: #5aa9ff; }
.hsa-confirm-icon-danger { background: rgba(239,68,68,0.15);  color: #ef4444; }
.hsa-confirm-body {
  grid-row: 1;
  grid-column: 2;
  min-width: 0;
}
.hsa-confirm-title {
  font-size: 1rem;
  font-weight: 600;
  color: #f0f0f0;
  margin-bottom: 4px;
}
.hsa-confirm-msg {
  font-size: 0.88rem;
  color: #c8c8c8;
  line-height: 1.45;
}
.hsa-confirm-detail {
  margin-top: 8px;
  font-size: 0.78rem;
  color: var(--text-muted, #888);
  padding: 8px 10px;
  background: rgba(255,255,255,0.03);
  border-radius: 6px;
  border-left: 2px solid rgba(255,255,255,0.1);
}
.hsa-confirm-actions {
  grid-row: 2;
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}
.hsa-confirm-actions .hsa-btn {
  min-height: 36px;
  min-width: 88px;
}
.hsa-btn.hsa-btn-danger {
  background: #ef4444;
  color: #fff;
}
.hsa-btn.hsa-btn-danger:hover { background: #dc2626; }

@media (max-width: 480px) {
  .hsa-confirm-inner { padding: 18px 18px 14px; }
  .hsa-confirm-title { font-size: 0.95rem; }
  .hsa-confirm-actions .hsa-btn { flex: 1; }
  .hsa-toast { font-size: 0.82rem; min-width: 0; }
  .hsa-toast-container { top: 8px; right: 8px; left: 8px; max-width: none; }
  .hsa-confirm-actions .hsa-btn { min-height: 44px; }
}

/* ── Tap-Target Sizing (touch devices) ── */
@media (max-width: 768px) {
  /* Toast controls */
  .hsa-toast-close { min-width: 44px; min-height: 44px; font-size: 1.5rem; }
  .hsa-toast-action { min-height: 44px; padding: 10px 16px; font-size: 0.8rem; }
  /* Lightbox toolbar */
  .hsa-lightbox-btn { min-height: 44px; padding: 10px 14px; }
  .hsa-lightbox-close { min-height: 44px; min-width: 44px; padding: 6px 12px; font-size: 1.4rem; }
}

/* ── Receipt Photo Lightbox ── */
.hsa-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: hsaLightboxFade 0.15s ease-out;
}
@keyframes hsaLightboxFade {
  from { opacity: 0; }
  to { opacity: 1; }
}
.hsa-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(4px);
  cursor: zoom-out;
}
.hsa-lightbox-inner {
  position: relative;
  width: min(95vw, 1200px);
  height: min(92vh, 900px);
  display: flex;
  flex-direction: column;
  background: #111;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  border: 1px solid rgba(255,255,255,0.08);
}
.hsa-lightbox-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  gap: 12px;
}
.hsa-lightbox-name {
  color: #e0e0e0;
  font-size: 0.85rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.hsa-lightbox-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.hsa-lightbox-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  min-width: 44px;
  padding: 6px 12px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  color: #e0e0e0;
  font-size: 0.78rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.12s;
}
.hsa-lightbox-btn:hover {
  background: rgba(255,255,255,0.14);
}
.hsa-lightbox-close {
  font-size: 1.3rem;
  line-height: 1;
  padding: 4px 10px;
}
.hsa-lightbox-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background:
    linear-gradient(45deg, #0a0a0a 25%, transparent 25%),
    linear-gradient(-45deg, #0a0a0a 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #0a0a0a 75%),
    linear-gradient(-45deg, transparent 75%, #0a0a0a 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-color: #151515;
}
.hsa-lightbox-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}
.hsa-attach-thumb {
  cursor: zoom-in;
  transition: transform 0.12s;
}
.hsa-attach-thumb:hover {
  transform: scale(1.03);
}
@media (max-width: 600px) {
  .hsa-lightbox-inner {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    border: none;
  }
}

/* ── Monthly Flow Chart ── */
.hsa-chart-card {
  padding: 16px 18px 18px;
}
.hsa-chart-legend {
  font-size: 0.72rem;
  color: var(--text-secondary, #a0a0a0);
  font-weight: 500;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
}
.hsa-chart-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
}
.hsa-chart-wrap {
  position: relative;
  height: 220px;
  margin-top: 10px;
}
@media (max-width: 600px) {
  .hsa-chart-wrap { height: 180px; }
  .hsa-chart-legend { font-size: 0.66rem; }
}

/* ── Settings ── */
.hsa-settings-card {
  padding: 20px;
}
.hsa-toggle-row {
  display: flex;
  gap: 6px;
}
.hsa-toggle-btn {
  padding: 7px 18px;
  border: 1px solid var(--border-subtle, rgba(255,255,255,0.1));
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted, #888);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.hsa-toggle-btn:hover { background: rgba(255,255,255,0.05); }
.hsa-toggle-btn.active {
  background: rgba(255,95,16,0.15);
  border-color: var(--accent-primary, #ff5f10);
  color: var(--accent-primary, #ff5f10);
  font-weight: 600;
}

.hsa-dep-list {
  margin-bottom: 12px;
}
.hsa-dep-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border-subtle, rgba(255,255,255,0.04));
}
.hsa-dep-row:last-child { border-bottom: none; }
.hsa-dep-name {
  font-size: 0.85rem;
  color: var(--text-primary, #e0e0e0);
}
.hsa-dep-add {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.hsa-dep-add .hsa-input { flex: 1; }

/* ── Dashboard Sections ── */
.hsa-dash-section {
  background: var(--bg-card, #111111);
  border: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 12px;
}
.hsa-dash-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted, #888);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}
.hsa-dash-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-secondary, #bbb);
  margin-top: 6px;
}

/* ── Readiness Summary (Dashboard) ── */
.hsa-readiness-summary {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.hsa-ready-pill {
  padding: 5px 12px;
  border-radius: 16px;
  font-size: 0.78rem;
  font-weight: 600;
}
.hsa-ready-good    { background: rgba(16,185,129,0.15); color: #10b981; }
.hsa-ready-partial { background: rgba(245,158,11,0.15); color: #f59e0b; }
.hsa-ready-low     { background: rgba(239,68,68,0.15);  color: #ef4444; }

/* ── Quick Actions ── */
.hsa-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ── Empty States ── */
.hsa-empty-state {
  text-align: center;
  padding: 48px 20px;
  background: var(--bg-card, #111111);
  border: 1px dashed var(--border-subtle, rgba(255,255,255,0.1));
  border-radius: 12px;
}
.hsa-empty-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  color: var(--text-muted, #888);
  opacity: 0.7;
}
.hsa-empty-icon svg { width: 44px; height: 44px; stroke-width: 1.5; }
.hsa-empty-text {
  font-size: 0.88rem;
  color: var(--text-muted, #888);
  max-width: 360px;
  margin: 0 auto;
  line-height: 1.5;
}

/* ── Checkbox & Selection ── */
.hsa-card-checkbox {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding-right: 8px;
}
.hsa-card-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-primary, #ff5f10);
  cursor: pointer;
}
.hsa-card-selected {
  border-color: rgba(255,95,16,0.4) !important;
  background: rgba(255,95,16,0.04);
}
.hsa-select-all {
  padding: 10px 8px;       /* roomier tap area; was 6px 4px and felt cramped */
  margin-bottom: 4px;
  cursor: pointer;          /* now that the wrapper is a <label>, signal click */
  display: flex;            /* keep flex layout from the prior .hsa-check-label */
  align-items: center;
  gap: 8px;
  border-radius: 6px;
  transition: background .12s;
}
.hsa-select-all:hover { background: rgba(255, 255, 255, 0.03); }
.hsa-check-label {
  font-size: 0.78rem;
  color: var(--text-muted, #888);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}
.hsa-check-label input { accent-color: var(--accent-primary, #ff5f10); }

/* ── Bulk Action Toolbar ── */
.hsa-bulk-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(255,95,16,0.08);
  border: 1px solid rgba(255,95,16,0.2);
  border-radius: 8px;
  margin-bottom: 12px;
}
.hsa-bulk-count {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent-primary, #ff5f10);
  margin-right: 4px;
}

/* ── Readiness Detail Popover ── */
.hsa-readiness-detail {
  padding: 12px 0 4px;
  border-top: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
  margin-top: 8px;
}
.hsa-readiness-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.hsa-readiness-score-big {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--accent-primary, #ff5f10);
}
.hsa-readiness-factors {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.hsa-factor-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
}
.hsa-factor-check { font-size: 0.75rem; flex-shrink: 0; }
.hsa-factor-label { flex: 1; color: var(--text-primary, #e0e0e0); }
.hsa-factor-weight {
  color: var(--text-muted, #666);
  font-size: 0.7rem;
  font-weight: 500;
}

/* ── Readiness Overview (Dashboard) ── */
.hsa-readiness-overview {
  display: flex;
  gap: 20px;
  align-items: center;
  flex-wrap: wrap;
}
.hsa-readiness-avg { text-align: center; min-width: 80px; }
.hsa-readiness-avg-label {
  font-size: 0.7rem;
  color: var(--text-muted, #888);
  margin-top: 2px;
}
.hsa-readiness-needing { margin-top: 14px; }
.hsa-readiness-sub-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted, #888);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}
.hsa-readiness-item {
  padding: 6px 0;
  border-bottom: 1px solid var(--border-subtle, rgba(255,255,255,0.04));
}
.hsa-readiness-item:last-child { border-bottom: none; }
.hsa-readiness-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.hsa-readiness-item-name {
  font-size: 0.82rem;
  color: var(--text-primary, #e0e0e0);
}
.hsa-readiness-missing {
  font-size: 0.72rem;
  color: #ef4444;
  margin-top: 2px;
}
.hsa-readiness-more {
  font-size: 0.75rem;
  color: var(--text-muted, #888);
  padding-top: 6px;
  font-style: italic;
}

/* ── Batch Detail ── */
.hsa-batch-detail { }
.hsa-batch-status-controls { display: flex; gap: 4px; }

/* ── Trash ── */
.hsa-trash-card { border-left: 3px solid rgba(239,68,68,0.3); }
.hsa-trash-icon {
  margin-right: 4px;
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  color: var(--text-secondary, #a0a0a0);
}
.hsa-trash-icon svg { width: 15px; height: 15px; }

/* ── Attachments ── */
.hsa-attachments-section {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
}
.hsa-attach-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted, #888);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}
.hsa-attach-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}
.hsa-attach-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
  border-radius: 6px;
}
.hsa-attach-preview {
  width: 48px;
  height: 48px;
  border-radius: 4px;
  overflow: hidden;
  background: rgba(255,255,255,0.04);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.hsa-attach-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.hsa-attach-file-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary, #a0a0a0);
}
.hsa-attach-file-icon svg { width: 24px; height: 24px; }
.hsa-attach-loading {
  font-size: 0.68rem;
  color: var(--text-muted, #666);
}
.hsa-attach-unavailable {
  font-size: 0.72rem;
  color: #ef4444;
  text-align: center;
}
.hsa-attach-info { flex: 1; min-width: 0; }
.hsa-attach-name {
  font-size: 0.78rem;
  color: var(--text-primary, #e0e0e0);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hsa-attach-meta {
  font-size: 0.68rem;
  color: var(--text-muted, #666);
  margin-top: 2px;
}
.hsa-attach-actions { display: flex; gap: 2px; flex-shrink: 0; }
.hsa-attach-upload { margin-top: 6px; }
.hsa-attach-badge {
  font-size: 0.85rem;
  color: var(--text-muted, #888);
  display: inline-flex;
  align-items: center;
  gap: 3px;
  line-height: 1;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  padding: 5px 8px;
  min-height: 32px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.hsa-attach-badge:hover {
  background: rgba(255,95,16,0.12);
  border-color: rgba(255,95,16,0.4);
  color: var(--accent-primary, #ff5f10);
}
.hsa-attach-badge:focus-visible {
  outline: 2px solid var(--accent-primary, #ff5f10);
  outline-offset: 2px;
}
@media (max-width: 768px) {
  .hsa-attach-badge { min-height: 44px; padding: 6px 10px; }
}

/* ── Button Variants ── */
.hsa-btn-sm { font-size: 0.72rem; padding: 4px 10px; }
.hsa-btn-danger { color: #ef4444; }
.hsa-btn-danger:hover { color: #f87171; }

/* ── Export Grid ── */
.hsa-export-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.hsa-export-section { }

/* ── Print Report Modal ── */
#hsaPrintModal {
  flex-direction: column;
  align-items: center;
}
.hr-toolbar {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  background: var(--bg-card, #111111);
  border-bottom: 1px solid var(--border-subtle, rgba(255,255,255,0.1));
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  box-sizing: border-box;
  flex-wrap: wrap;
  gap: 10px;
  border-radius: 10px 10px 0 0;
}
.hr-toolbar-top {
  display: flex;
  align-items: center;
  gap: 10px;
}
.hr-toolbar-title {
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
}
.hr-toolbar-year {
  width: auto;
  min-width: 72px;
}
.hr-toolbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}
.hr-scroll {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch; /* iOS momentum scrolling */
  overscroll-behavior: contain;
  padding: 0 16px 24px;
}
.hr-content {
  background: #fff;
  color: #222;
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 32px 36px;
  border-radius: 0 0 10px 10px;
  box-sizing: border-box;
}
.hr-header { text-align: center; margin-bottom: 24px; padding-bottom: 16px; border-bottom: 2px solid #eee; }
.hr-title { font-size: 1.5rem; font-weight: 800; color: #111; margin: 0 0 4px; }
.hr-subtitle { font-size: 0.82rem; color: #666; }

.hr-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.hr-kpi {
  background: #f9f9f9;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  padding: 14px;
  text-align: center;
}
.hr-kpi-value { font-size: 1.2rem; font-weight: 800; color: #111; }
.hr-kpi-label { font-size: 0.72rem; color: #888; text-transform: uppercase; letter-spacing: 0.04em; margin-top: 2px; }
.hr-kpi-sub { font-size: 0.7rem; color: #aaa; margin-top: 4px; }

.hr-section { margin-bottom: 24px; }
.hr-section-title { font-size: 1rem; font-weight: 700; color: #333; margin: 0 0 10px; padding-bottom: 6px; border-bottom: 1px solid #eee; }

.hr-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.hr-table th { text-align: left; padding: 6px 8px; border-bottom: 2px solid #ddd; font-weight: 600; color: #555; font-size: 0.72rem; text-transform: uppercase; }
.hr-table td { padding: 5px 8px; border-bottom: 1px solid #eee; color: #333; }
.hr-table-compact td, .hr-table-compact th { padding: 4px 6px; font-size: 0.76rem; }
.hr-total-row td { border-top: 2px solid #ddd; padding-top: 8px; }

.hr-footer { margin-top: 24px; padding-top: 12px; border-top: 1px solid #eee; text-align: center; }
.hr-footer p { font-size: 0.7rem; color: #999; font-style: italic; }

/* ── Print Media ── */
/* HSA print uses a separate window (hsaDoPrint), so no @media print overrides needed here. */

/* ── Placeholder Note ── */
.hsa-placeholder-note {
  font-size: 0.82rem;
  color: var(--text-muted, #888);
  font-style: italic;
  padding: 12px 0;
}

/* ═══════════════════════════════════════════════════════════
   ANIMATIONS & MICRO-INTERACTIONS
═══════════════════════════════════════════════════════════ */

/* ── Keyframes ── */
@keyframes hsaFadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes hsaShimmer {
  0%   { background-position: -200px 0; }
  100% { background-position: 400px 0; }
}
@keyframes hsaFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── View Content Fade-In ──
   Opacity-only fade on the content container (not per-child stagger)
   so tab switches feel like a smooth cross-fade rather than a reload. */
#hsa-content.hsa-animate {
  animation: hsaFadeIn 0.14s ease both;
}

/* ── Card List Entry ── (kept subtle, no stagger-induced flicker) */
.hsa-card-list.hsa-animate {
  animation: hsaFadeIn 0.14s ease both;
}

/* ── Card Press Effect (mobile) ── */
.hsa-card {
  transition: border-color var(--transition-fast, 0.15s ease), transform 0.1s ease, box-shadow 0.15s ease;
}
.hsa-card:active {
  transform: scale(0.985);
}

/* ── Stat Card Hover Lift ── */
.hsa-stat-clickable {
  transition: border-color var(--transition-fast, 0.15s ease), background var(--transition-fast, 0.15s ease), transform 0.15s ease, box-shadow 0.15s ease;
}
.hsa-stat-clickable:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.hsa-stat-clickable:active {
  transform: translateY(0) scale(0.98);
  box-shadow: none;
}

/* ── Dashboard Section Slide-Up ── */
.hsa-dash-section {
  transition: border-color var(--transition-fast, 0.15s ease), transform 0.15s ease, box-shadow 0.15s ease;
}

/* ── Subnav Button Active Press ── */
.hsa-subnav-btn:active {
  opacity: 0.75;
}

/* ── Skeleton Loading ── */
.hsa-skeleton {
  pointer-events: none;
}
.hsa-skeleton-line {
  height: 12px;
  border-radius: 4px;
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.04) 75%);
  background-size: 400px 100%;
  animation: hsaShimmer 1.4s ease-in-out infinite;
}
.hsa-skeleton-line.hsa-skel-title { height: 18px; width: 40%; margin-bottom: 16px; }
.hsa-skeleton-line.hsa-skel-short { width: 60%; margin-bottom: 8px; }
.hsa-skeleton-line.hsa-skel-med   { width: 80%; margin-bottom: 8px; }
.hsa-skeleton-line.hsa-skel-full  { width: 100%; margin-bottom: 8px; }
.hsa-skeleton-card {
  background: var(--bg-card, #111111);
  border: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 8px;
}
.hsa-skeleton-stat {
  background: var(--bg-card, #111111);
  border: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
  border-radius: 10px;
  padding: 20px 16px;
  text-align: center;
}
.hsa-skeleton-stat .hsa-skeleton-line {
  margin: 0 auto 6px;
}
.hsa-skeleton-stat .hsa-skel-value { height: 24px; width: 50%; }
.hsa-skeleton-stat .hsa-skel-label { height: 10px; width: 70%; margin-bottom: 0; }

/* ── Form Appear ── */
.hsa-form-card {
  animation: hsaFadeIn 0.15s ease;
}

/* ── Empty State Fade ── */
.hsa-empty-state {
  animation: hsaFadeUp 0.25s ease both;
}

/* ── Readiness Bar Animate ── */
.hsa-readiness-fill,
.hsa-contrib-fill {
  transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ── Tablet Responsive ── */
@media (max-width: 900px) {
  .hsa-subnav { padding: 8px 12px; }
  .hsa-subnav-btn { padding: 9px 12px; }
  .hsa-subnav-btn.active::after { left: 12px; right: 12px; }
}

/* ── Mobile Responsive ── */
@media (max-width: 768px) {
  .hr-kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .hr-content { padding: 20px 16px; }
  .hr-table-compact { font-size: 0.7rem; }
  .hr-table-compact th, .hr-table-compact td { padding: 3px 4px; }
  .hsa-bulk-bar { flex-direction: column; align-items: flex-start; }
  .hsa-readiness-overview { flex-direction: column; }
}

@media (max-width: 600px) {

  /* ── Navigation: 4×2 grid, stacked icon + label, no scroll ── */
  .hsa-subnav {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2px 4px;
    padding: 8px 8px 10px;
    overflow-x: visible;
    /* Stick below the fixed mobile header (~55px + safe-area) */
    top: calc(55px + env(safe-area-inset-top));
  }
  .hsa-subnav-btn {
    flex-direction: column;
    gap: 5px;
    padding: 9px 4px 10px;
    min-width: 0;
  }
  .hsa-subnav-icon { width: 18px; height: 18px; }
  .hsa-subnav-label { font-size: 11px; letter-spacing: 0.01em; }
  .hsa-subnav-btn.active::after { left: 30%; right: 30%; bottom: 2px; height: 2px; }

  /* ── Content Area ── */
  #hsa-content { padding: 14px 10px; }

  /* ── Dashboard Stats ── */
  .hsa-stat-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .hsa-stat-card { padding: 12px; }
  .hsa-stat-value { font-size: 1.15rem; }
  .hsa-section-header { gap: 8px; }
  .hsa-section-title { font-size: 1rem; }

  /* ── Cards ── */
  .hsa-card { padding: 12px; }
  .hsa-card-top { gap: 10px; align-items: flex-start; }
  .hsa-card-right {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
  }
  .hsa-card-header-row { flex-wrap: wrap; gap: 6px; }
  .hsa-card-vendor { font-size: 0.9rem; }
  .hsa-card-meta { font-size: 0.7rem; gap: 4px 5px; }
  .hsa-meta-chip { padding: 2px 7px; }
  .hsa-meta-chip-text { max-width: 110px; }
  .hsa-card-amount { font-size: 1.05rem; }
  .hsa-card-footer { flex-wrap: wrap; gap: 8px; }
  /* Enlarged tap target without shifting the visual size of the checkbox */
  .hsa-card-checkbox {
    padding: 12px 10px 12px 4px;
    margin: -12px -4px -12px 0;
    min-width: 44px;
    min-height: 44px;
    box-sizing: border-box;
  }
  .hsa-card-checkbox input[type="checkbox"] { width: 22px; height: 22px; }
  .hsa-card-actions { gap: 4px; }

  /* ── Buttons ── */
  .hsa-btn { padding: 10px 14px; font-size: 0.82rem; border-radius: 8px; min-height: 44px; }
  .hsa-btn-sm { font-size: 0.78rem; padding: 8px 12px; min-height: 44px; }
  .hsa-btn-icon {
    font-size: 1.15rem;
    padding: 8px;
    min-width: 44px;
    min-height: 44px;
    border-radius: 8px;
  }

  /* ── Badges ── */
  .hsa-badge { font-size: 0.68rem; padding: 3px 8px; white-space: nowrap; }

  /* ── Readiness Mini Bar ── */
  .hsa-readiness-mini { max-width: 120px; gap: 6px; }
  .hsa-readiness-bar { height: 4px; }
  .hsa-readiness-pct { font-size: 0.68rem; }

  /* ── Filters & Sort ── */
  .hsa-filters {
    flex-direction: column;
    gap: 6px;
  }
  .hsa-search {
    min-width: auto;
    width: 100%;
    padding: 10px 12px;
    font-size: 16px;
    border-radius: 8px;
    box-sizing: border-box;
  }
  .hsa-select {
    width: 100%;
    padding: 10px 12px;
    font-size: 0.78rem;
    border-radius: 8px;
    box-sizing: border-box;
  }
  .hsa-sort-bar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
  .hsa-sort-btn {
    padding: 8px 10px;
    font-size: 0.76rem;
    text-align: center;
    border-radius: 6px;
    background: rgba(255,255,255,0.03);
    min-height: 44px;
  }

  /* ── Bulk Actions ── */
  .hsa-bulk-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .hsa-bulk-bar .hsa-select { width: 100%; }

  /* ══ Full-Screen Form Overlay ══ */
  .hsa-form-card:not(.hsa-settings-card) {
    position: fixed;
    inset: 0;
    z-index: 8000;
    background: var(--bg-primary, #0a0a0a);
    border: none;
    border-radius: 0;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  /* Form header bar */
  .hsa-form-title-bar {
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    padding-top: max(12px, env(safe-area-inset-top));
    margin: 0;
    background: var(--bg-card, #111111);
    border-bottom: 1px solid rgba(255,255,255,0.08);
  }
  .hsa-form-title {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.01em;
  }
  .hsa-form-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255,255,255,0.06);
    border: none;
    color: var(--text-muted, #999);
    font-size: 1.1rem;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .hsa-form-close:active {
    background: rgba(255,255,255,0.15);
    color: #fff;
  }

  /* Scrollable form body */
  .hsa-form-grid {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 16px;
    box-sizing: border-box;
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .hsa-form-group {
    gap: 5px;
    min-width: 0;
  }
  .hsa-form-label {
    font-size: 0.75rem;
    letter-spacing: 0.05em;
  }

  /* Form inputs — 16px prevents iOS zoom on text inputs only */
  input.hsa-input,
  textarea.hsa-input {
    font-size: 16px !important;
  }
  .hsa-input {
    padding: 11px 12px;
    font-size: 0.84rem;
    border-radius: 8px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
  }
  .hsa-input:focus {
    border-color: var(--accent-primary, #ff5f10);
    background: rgba(255,95,16,0.04);
    box-shadow: 0 0 0 3px rgba(255,95,16,0.1);
  }
  select.hsa-input {
    font-size: 0.84rem !important;
    padding-right: 12px;
  }
  .hsa-textarea { min-height: 80px; }

  /* Fixed bottom action bar */
  .hsa-form-actions {
    flex-shrink: 0;
    display: flex;
    gap: 10px;
    padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    margin: 0;
    background: var(--bg-card, #111111);
    border-top: 1px solid rgba(255,255,255,0.08);
  }
  .hsa-form-actions .hsa-btn {
    flex: 1;
    padding: 14px;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 10px;
    justify-content: center;
  }
  .hsa-form-actions .hsa-btn-primary {
    background: var(--accent-primary, #ff5f10);
    color: #fff;
  }
  .hsa-form-actions .hsa-btn-secondary {
    background: rgba(255,255,255,0.06);
    color: var(--text-muted, #999);
  }

  /* ── Contributions ── */
  .hsa-year-header { flex-direction: column; gap: 4px; align-items: flex-start; }
  .hsa-year-summary { word-break: break-word; }

  /* ── Quick Actions ── */
  .hsa-quick-actions { flex-direction: column; }
  .hsa-quick-actions .hsa-btn { width: 100%; justify-content: center; }

  /* ── Settings ── */
  .hsa-toggle-row { flex-direction: column; gap: 6px; }
  .hsa-toggle-btn { width: 100%; text-align: center; padding: 10px 18px; min-height: 44px; }
  .hsa-dep-add { flex-direction: column; }
  .hsa-dep-name { word-break: break-word; }

  /* ── Attachments ── */
  .hsa-attach-item { flex-wrap: wrap; gap: 8px; }
  .hsa-attach-info { min-width: 0; flex: 1; }
  .hsa-attach-actions { width: 100%; justify-content: flex-end; }
  .hsa-attachments-section { margin-top: 10px; padding-top: 10px; }

  /* ── Empty States ── */
  .hsa-empty-state { padding: 32px 16px; }
  .hsa-empty-text { max-width: 90%; }

  /* ── Batch Detail ── */
  .hsa-batch-status-controls { flex-wrap: wrap; gap: 6px; }

  /* ── Readiness Overview ── */
  .hsa-readiness-overview { gap: 12px; }
  .hsa-readiness-summary { gap: 6px; }
  .hsa-ready-pill { padding: 6px 12px; font-size: 0.76rem; }

  /* ── Print Report ── */
  .hr-kpi-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .hr-content { padding: 16px 12px; }
  .hr-toolbar {
    flex-direction: column;
    align-items: stretch;
    padding: 12px 14px;
    gap: 10px;
  }
  .hr-toolbar-top {
    justify-content: center;
    gap: 10px;
  }
  .hr-toolbar-title { font-size: 1.05rem; }
  .hr-toolbar-year { min-width: 80px; }
  .hr-toolbar-actions {
    justify-content: center;
    gap: 10px;
  }
  .hr-toolbar-actions .hsa-btn { flex: 1; justify-content: center; text-align: center; }
  .hr-title { font-size: 1.15rem; }
}

/* ═══════════════════════════════════════════════════════════
   FOCUS-VISIBLE — Keyboard Accessibility
═══════════════════════════════════════════════════════════ */
.hsa-btn:focus-visible,
.hsa-btn-icon:focus-visible,
.hsa-subnav-btn:focus-visible,
.hsa-sort-btn:focus-visible,
.hsa-toggle-btn:focus-visible,
.hsa-check-label input:focus-visible,
.hsa-card-checkbox input:focus-visible {
  outline: 2px solid var(--accent-primary, #ff5f10);
  outline-offset: 2px;
}
.hsa-input:focus-visible,
.hsa-search:focus-visible,
.hsa-select:focus-visible {
  outline: 2px solid var(--accent-primary, #ff5f10);
  outline-offset: -1px;
}

/* ═══════════════════════════════════════════════════════════
   LIGHT THEME OVERRIDES
   Flips hardcoded dark-mode rgba values for light backgrounds.
   CSS variables (--bg-card, --border-subtle, --text-*, --accent-*)
   auto-adapt; only standalone hardcoded values need overrides.
═══════════════════════════════════════════════════════════ */

body.light-theme .hsa-subnav {
  background: var(--bg-primary, #ffffff);
  border-bottom: 1px solid var(--border-subtle, rgba(0,0,0,0.08));
}
body.light-theme .hsa-subnav-btn:hover {
  background: rgba(0,0,0,0.04);
}
body.light-theme .hsa-subnav-btn.active {
  background: rgba(255,95,16,0.08);
}
body.light-theme .hsa-stat-clickable:hover {
  background: rgba(0,0,0,0.02);
}
body.light-theme .hsa-card:hover {
  border-color: rgba(0,0,0,0.15);
}
body.light-theme .hsa-readiness-fill,
body.light-theme .hsa-contrib-fill {
  background: var(--accent-primary, #ff5f10);
}
body.light-theme .hsa-readiness-bar,
body.light-theme .hsa-contrib-bar {
  background: rgba(0,0,0,0.06);
}
body.light-theme .hsa-btn-icon:hover {
  background: rgba(0,0,0,0.06);
}
body.light-theme .hsa-btn-secondary {
  background: rgba(0,0,0,0.04);
  border-color: var(--border-subtle, rgba(0,0,0,0.1));
}
body.light-theme .hsa-btn-secondary:hover:not(:disabled) {
  background: rgba(0,0,0,0.08);
}
body.light-theme .hsa-search,
body.light-theme .hsa-select,
body.light-theme .hsa-input {
  background: var(--bg-input, #edecea);
  border-color: var(--border-subtle, rgba(0,0,0,0.1));
  color: var(--text-primary, #1a1a1a);
}
body.light-theme .hsa-search::placeholder,
body.light-theme .hsa-input::placeholder {
  color: var(--text-muted, #666);
}
body.light-theme .hsa-sort-btn:hover {
  background: rgba(0,0,0,0.04);
}
body.light-theme .hsa-sort-btn.active {
  color: var(--accent-primary, #ff5f10);
}
body.light-theme .hsa-form-card {
  border-color: rgba(255,95,16,0.2);
}
body.light-theme .hsa-info-bar {
  background: rgba(255,95,16,0.04);
  border-color: rgba(255,95,16,0.12);
}
body.light-theme .hsa-toggle-btn {
  border-color: var(--border-subtle, rgba(0,0,0,0.1));
}
body.light-theme .hsa-toggle-btn:hover {
  background: rgba(0,0,0,0.03);
}
body.light-theme .hsa-toggle-btn.active {
  background: rgba(255,95,16,0.08);
  border-color: var(--accent-primary, #ff5f10);
  color: var(--accent-primary, #ff5f10);
}
body.light-theme .hsa-log-entry:hover {
  background: rgba(0,0,0,0.02);
}
body.light-theme .hsa-card-selected {
  border-color: rgba(255,95,16,0.3) !important;
  background: rgba(255,95,16,0.03);
}
body.light-theme .hsa-bulk-bar {
  background: rgba(255,95,16,0.05);
  border-color: rgba(255,95,16,0.15);
}
body.light-theme .hsa-attach-item {
  background: rgba(0,0,0,0.02);
  border-color: var(--border-subtle, rgba(0,0,0,0.08));
}
body.light-theme .hsa-attach-preview {
  background: rgba(0,0,0,0.04);
}
body.light-theme .hsa-empty-state {
  background: var(--bg-card, #ffffff);
  border-color: var(--border-subtle, rgba(0,0,0,0.12));
}
body.light-theme .hr-toolbar {
  background: var(--bg-card, #ffffff);
  border-bottom-color: var(--border-subtle, rgba(0,0,0,0.1));
}
body.light-theme .hsa-trash-card {
  border-left-color: rgba(239,68,68,0.25);
}
body.light-theme .hsa-skeleton-line {
  background: linear-gradient(90deg, rgba(0,0,0,0.04) 25%, rgba(0,0,0,0.08) 50%, rgba(0,0,0,0.04) 75%);
  background-size: 400px 100%;
}
body.light-theme .hsa-stat-clickable:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

/* Light theme mobile form overlay */
@media (max-width: 600px) {
  body.light-theme .hsa-form-card:not(.hsa-settings-card) {
    background: var(--bg-primary, #ffffff);
  }
  body.light-theme .hsa-form-title-bar {
    background: var(--bg-card, #ffffff);
    border-bottom-color: rgba(0,0,0,0.08);
  }
  body.light-theme .hsa-form-close {
    background: rgba(0,0,0,0.06);
    color: var(--text-muted, #666);
  }
  body.light-theme .hsa-form-close:active {
    background: rgba(0,0,0,0.12);
    color: var(--text-heading, #0d0d0d);
  }
  body.light-theme .hsa-input {
    background: var(--bg-input, #edecea);
    border-color: rgba(0,0,0,0.1);
  }
  body.light-theme .hsa-input:focus {
    background: rgba(255,95,16,0.03);
    box-shadow: 0 0 0 3px rgba(255,95,16,0.08);
  }
  body.light-theme .hsa-form-actions {
    background: var(--bg-card, #ffffff);
    border-top-color: rgba(0,0,0,0.08);
  }
  body.light-theme .hsa-form-actions .hsa-btn-secondary {
    background: rgba(0,0,0,0.04);
    color: var(--text-muted, #666);
  }
  body.light-theme .hsa-sort-btn {
    background: rgba(0,0,0,0.02);
  }
}

/* ═══════════════════════════════════════════════════════════
   REDUCED MOTION — Accessibility
═══════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  #hsa-content.hsa-animate > *,
  .hsa-card-list.hsa-animate .hsa-card,
  .hsa-form-card,
  .hsa-empty-state {
    animation: none !important;
  }
  .hsa-skeleton-line {
    animation: none !important;
    opacity: 0.5;
  }
  .hsa-card,
  .hsa-stat-clickable,
  .hsa-subnav-btn {
    transition: none !important;
  }
}
