*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: var(--fs-md);
  line-height: var(--lh);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--font-mono); font-size: 12.5px; }
/* Mono text shows machine data as typed: no ligatures (^~\&, ->, != stay separate glyphs). */
code, .mono, .code, kbd, pre { font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
::selection { background: rgba(2,116,254,0.35); }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.12) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 10px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.22); background-clip: content-box; border: 2px solid transparent; }
*::-webkit-scrollbar-track { background: transparent; }

/* Text utilities */
.muted { color: var(--text-muted); }
.secondary { color: var(--text-secondary); }
.disabled { color: var(--text-disabled); }
.xs { font-size: var(--fs-xs); }
.sm { font-size: var(--fs-sm); }
.lg { font-size: var(--fs-lg); }
.xl { font-size: var(--fs-xl); }
.bold { font-weight: 700; }
.semibold { font-weight: 600; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.caps { text-transform: uppercase; letter-spacing: 0.08em; font-size: 11px; font-weight: 700; color: var(--text-muted); }
.right { text-align: right; }
.center { text-align: center; }
.success { color: var(--success); }
.warning { color: var(--warning); }
.danger { color: var(--danger); }
.info { color: var(--info); }
.accent { color: var(--accent); }
.primary { color: var(--primary); }

/* Layout utilities */
.row { display: flex; align-items: center; gap: var(--sp-3); }
.row.between { justify-content: space-between; }
.row.start { align-items: flex-start; }
.row.end { justify-content: flex-end; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: var(--sp-3); }
.grow { flex: 1 1 auto; min-width: 0; }
.gap-1 { gap: var(--sp-1); } .gap-2 { gap: var(--sp-2); } .gap-4 { gap: var(--sp-4); } .gap-6 { gap: var(--sp-6); }
.mt-2 { margin-top: var(--sp-2); } .mt-4 { margin-top: var(--sp-4); } .mt-6 { margin-top: var(--sp-6); }
.mb-2 { margin-bottom: var(--sp-2); } .mb-4 { margin-bottom: var(--sp-4); }
.grid { display: grid; gap: var(--sp-4); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.hidden { display: none !important; }
.relative { position: relative; }
.w-full { width: 100%; }
.nowrap { white-space: nowrap; }

@media (max-width: 1599px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-3 { grid-column: span 2; }
  .hide-md { display: none !important; }
}
@media (max-width: 1365px) {
  .hide-sm { display: none !important; }
}

/* Keyframes */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeDown { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideInRight { from { transform: translateX(24px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideInLeft { from { transform: translateX(-16px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes scaleIn { from { transform: scale(0.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
@keyframes pulseRing { 0% { box-shadow: 0 0 0 0 rgba(43,211,224,0.5); } 100% { box-shadow: 0 0 0 10px rgba(43,211,224,0); } }
@keyframes shimmer { 0% { background-position: -400px 0; } 100% { background-position: 400px 0; } }
@keyframes flowDash { to { stroke-dashoffset: -24; } }
@keyframes rowFlash { 0% { background: rgba(43,211,224,0.22); } 100% { background: transparent; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes countUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.anim-fade { animation: fadeIn var(--dur-base) var(--ease-out) both; }
.anim-up { animation: fadeUp var(--dur-base) var(--ease-out) both; }
.anim-scale { animation: scaleIn var(--dur-base) var(--ease-out) both; }
.stagger > * { animation: fadeUp var(--dur-slow) var(--ease-out) both; }
.stagger > *:nth-child(1) { animation-delay: 0ms; }
.stagger > *:nth-child(2) { animation-delay: 40ms; }
.stagger > *:nth-child(3) { animation-delay: 80ms; }
.stagger > *:nth-child(4) { animation-delay: 120ms; }
.stagger > *:nth-child(5) { animation-delay: 160ms; }
.stagger > *:nth-child(6) { animation-delay: 200ms; }
.stagger > *:nth-child(7) { animation-delay: 240ms; }
.stagger > *:nth-child(8) { animation-delay: 280ms; }
.stagger > *:nth-child(n+9) { animation-delay: 320ms; }
.flash { animation: rowFlash 1.4s var(--ease-out) both; }
.pulse { animation: pulse 1.6s ease-in-out infinite; }

/* Skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--bg-elevated) 0px, #22304d 40px, var(--bg-elevated) 80px);
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: var(--r-sm);
  min-height: 14px;
}

svg.ic { width: 16px; height: 16px; flex: none; }

/* Focus */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* Grid items may shrink below their content width (long HL7 lines, file paths, JSON) instead of
   pushing the column and the page wider. Overflowing content scrolls or wraps inside its own box. */
.grid > *, .dash > *, .tx-detail > *, .settings > *, .label-editor > *, .form-grid > *, .health-grid > *, .queue-mini > *, .kv > *, .dlq-item > *, .map-row > * { min-width: 0; }
.boot { height: calc(100vh - var(--notice-h)); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: var(--text-muted); font-size: var(--fs-sm); }
