.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.metric-widgets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.metric-widget {
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 12px;
  border: 1px solid rgba(88, 103, 121, 0.42);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 28%),
    linear-gradient(145deg, rgba(6, 9, 14, 0.98), rgba(2, 4, 8, 0.96));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 6px 14px rgba(0, 0, 0, 0.28);
}

.metric-widget__id,
.metric-widget__name,
.metric-widget__reading,
.metric-widget__value {
  min-width: 0;
}

.metric-widget__id,
.metric-widget__name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.metric-widget__id {
  flex: 0 0 auto;
  color: #64748b;
  font-size: 0.62rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  line-height: 1.2;
  white-space: nowrap;
}

.metric-widget__name {
  flex: 0 0 auto;
  color: #e5e7eb;
  font-size: 0.82rem;
  font-weight: 760;
  line-height: 1.35;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.metric-widget__reading {
  margin-top: auto;
  align-self: flex-end;
  display: inline-flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 5px;
  max-width: 100%;
  text-align: right;
}

.metric-widget__value {
  color: #f8fafc;
  font-size: 1.22rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-widget__unit {
  flex: 0 1 auto;
  min-width: 0;
  color: #94a3b8;
  font-size: 0.72rem;
  font-weight: 650;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-mosaic {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(82px, 1fr));
  gap: 7px;
}

.metric-tile {
  position: relative;
  isolation: isolate;
  aspect-ratio: 1 / 0.86;
  min-height: 76px;
  min-width: 0;
  display: grid;
  align-content: space-between;
  gap: 7px;
  padding: 10px 9px 9px;
  border: 1px solid rgba(88, 103, 121, 0.5);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), transparent 32%),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 9px),
    linear-gradient(145deg, rgba(20, 27, 36, 0.96), rgba(5, 8, 13, 0.92));
  cursor: pointer;
  text-align: left;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -1px 0 rgba(0, 0, 0, 0.55),
    0 8px 18px rgba(0, 0, 0, 0.18);
  transition:
    border-color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.metric-tile::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  z-index: -1;
  width: 4px;
  border-radius: 6px 0 0 6px;
  background: currentColor;
  box-shadow: 0 0 16px currentColor;
  opacity: 0.94;
}

.metric-tile::after {
  content: "";
  position: absolute;
  inset: 5px;
  z-index: -1;
  border: 1px solid rgba(255, 255, 255, 0.045);
  border-radius: 4px;
  pointer-events: none;
}

.metric-tile:hover,
.metric-tile--selected {
  border-color: rgba(232, 201, 160, 0.58);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    inset 0 -1px 0 rgba(0, 0, 0, 0.6),
    0 10px 22px rgba(0, 0, 0, 0.26);
  transform: translateY(-1px);
}

.metric-tile--normal,
.metric-card--normal {
  color: #22c55e;
}

.metric-tile--warning,
.metric-card--warning {
  color: #f59e0b;
}

.metric-tile--critical,
.metric-card--critical {
  color: #ef4444;
}

.metric-tile__status {
  width: 10px;
  height: 10px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  background: currentColor;
  box-shadow:
    0 0 0 3px color-mix(in srgb, currentColor 13%, transparent),
    0 0 16px currentColor;
}

.metric-tile__tag,
.metric-tile strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-tile__tag {
  color: #cbd5e1;
  font-family: "Segoe UI", Inter, system-ui, sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.metric-tile strong {
  color: #f8fafc;
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.metric-card {
  position: relative;
  overflow: hidden;
  min-height: 184px;
  text-align: left;
  padding: 16px 15px 15px 17px;
  border: 1px solid rgba(88, 103, 121, 0.52);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 30%),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 11px),
    linear-gradient(145deg, rgba(18, 25, 34, 0.95), rgba(5, 8, 13, 0.92));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -1px 0 rgba(0, 0, 0, 0.52),
    0 14px 28px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.metric-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: currentColor;
  box-shadow: 0 0 18px currentColor;
}

.metric-card::after {
  content: "";
  position: absolute;
  inset: 7px;
  border: 1px solid rgba(255, 255, 255, 0.045);
  border-radius: 5px;
  pointer-events: none;
}

.metric-card:hover,
.metric-card--selected {
  border-color: rgba(232, 201, 160, 0.58);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), transparent 30%),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.032) 0 1px, transparent 1px 11px),
    linear-gradient(145deg, rgba(27, 35, 46, 0.98), rgba(11, 14, 20, 0.94));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    inset 0 -1px 0 rgba(0, 0, 0, 0.58),
    0 18px 32px rgba(0, 0, 0, 0.28);
  transform: translateY(-1px);
}

.metric-card--normal .metric-card__signal {
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.24);
  background: rgba(34, 197, 94, 0.08);
}

.metric-card--warning .metric-card__signal {
  color: #facc15;
  border-color: rgba(245, 158, 11, 0.28);
  background: rgba(245, 158, 11, 0.08);
}

.metric-card--critical .metric-card__signal {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.1);
}

.metric-card__header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: 9px;
}

.metric-card__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.metric-card__signal {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(212, 165, 116, 0.24);
  border-radius: 6px;
  color: var(--accent-soft);
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.04) 0 1px, transparent 1px 7px),
    rgba(2, 6, 23, 0.42);
}

.metric-card__tag {
  min-width: 0;
  color: #e5e7eb;
  font-size: 0.86rem;
  font-weight: 750;
  letter-spacing: 0.025em;
}

.metric-card__tag span,
.metric-card__tag small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-card__tag small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0;
}

.metric-card__state {
  flex: 0 0 auto;
  padding: 0 8px;
}

.metric-card__corner {
  display: inline-flex;
  align-items: flex-end;
  flex-direction: column;
  gap: 6px;
}

.metric-card__age {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #9aa8ba;
  font-size: 0.73rem;
  font-variant-numeric: tabular-nums;
}

.metric-card__state.is-normal {
  border-color: rgba(34, 197, 94, 0.24);
  background: rgba(34, 197, 94, 0.1);
  color: #86efac;
}

.metric-card__state.is-warning {
  border-color: rgba(245, 158, 11, 0.28);
  background: rgba(245, 158, 11, 0.1);
  color: #facc15;
}

.metric-card__state.is-critical {
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
}

.metric-card__value {
  margin: 22px 0 16px;
  overflow: hidden;
  font-size: clamp(1.85rem, 4vw, 2.7rem);
  font-variant-numeric: tabular-nums;
  font-weight: 760;
  line-height: 1;
  color: #f8fafc;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-shadow: 0 0 18px color-mix(in srgb, currentColor 18%, transparent);
}

.metric-card__footer {
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
  color: var(--muted);
  font-size: 0.78rem;
}

.metric-card__footer span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-card__action {
  flex: 0 0 auto;
  color: var(--accent-soft);
  font-weight: 700;
}
