.osm {
  --osm-ink: #172033;
  --osm-muted: #667085;
  --osm-line: #d7deea;
  --osm-panel: #fff;
  --osm-soft: #f3f7fb;
  --osm-blue: #2563eb;
  --osm-cyan: #21a6b8;
  --osm-green: #079455;
  --osm-red: #d92d20;
  --osm-amber: #f79009;

  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(7, 148, 85, 0.08)),
    var(--osm-panel);
  border: 1px solid var(--osm-line);
  border-radius: 8px;
  color: var(--osm-ink);
  display: grid;
  gap: 12px;
  padding: 12px;
  width: 100%;
}

.theme-dark .osm {
  --osm-ink: #eef4ff;
  --osm-muted: #a8b3c7;
  --osm-line: #344155;
  --osm-panel: #101827;
  --osm-soft: #1b2638;
  --osm-blue: #6da8ff;
  --osm-cyan: #42d3e4;
  --osm-green: #48d597;
  --osm-red: #ff6b5f;
  --osm-amber: #ffb84d;

  background:
    radial-gradient(circle at 10% 0%, rgba(109, 168, 255, 0.16), transparent 34%),
    linear-gradient(135deg, rgba(16, 24, 39, 0.96), rgba(17, 32, 48, 0.96));
}

.osm__warning {
  align-items: center;
  background: linear-gradient(90deg, rgba(217, 45, 32, 0.18), rgba(247, 144, 9, 0.14));
  border: 1px solid rgba(217, 45, 32, 0.62);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: 38px minmax(0, 1fr);
  padding: 10px 12px;
}

.osm__warning-mark {
  align-items: center;
  background: var(--osm-red);
  border-radius: 8px;
  color: #fff;
  display: flex;
  font-size: 28px;
  font-weight: 900;
  height: 38px;
  justify-content: center;
  line-height: 1;
}

.osm__warning strong,
.osm__warning span {
  display: block;
}

.osm__warning strong {
  font-size: 0.9rem;
  letter-spacing: 0;
  line-height: 1.2;
  text-transform: uppercase;
}

.osm__warning span {
  color: var(--osm-ink);
  font-size: 0.88rem;
  line-height: 1.35;
  margin-top: 2px;
}

.osm__grid {
  display: grid;
  gap: 12px;
}

.osm__panel {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--osm-line);
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(16, 24, 40, 0.06);
  padding: 12px;
}

.theme-dark .osm__panel {
  background: rgba(17, 24, 39, 0.78);
  box-shadow: none;
}

.osm__panel--results {
  display: grid;
  gap: 12px;
}

.osm__panel--inputs {
  display: grid;
  gap: 12px;
}

.osm__field {
  display: grid;
  gap: 6px;
  grid-template-rows: 18px 46px 32px;
  min-width: 0;
}

.osm__field > span {
  align-items: end;
  display: flex;
  font-size: 0.82rem;
  font-weight: 900;
  line-height: 1.1;
}

.osm__input-shell {
  align-items: center;
  background: var(--osm-soft);
  border: 1px solid var(--osm-line);
  border-radius: 8px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  height: 46px;
  overflow: hidden;
}

.osm__input-shell--toggle {
  grid-template-columns: minmax(0, 1fr) 142px;
}

.osm__input-shell input {
  background: transparent;
  border: 0;
  color: var(--osm-ink);
  font: inherit;
  font-size: 1rem;
  font-weight: 800;
  min-width: 0;
  outline: 0;
  padding: 10px 12px;
}

.osm__input-shell input::placeholder {
  color: var(--osm-muted);
  font-weight: 600;
}

.osm__input-shell small {
  color: var(--osm-muted);
  font-size: 0.76rem;
  font-weight: 900;
  padding: 0 12px 0 6px;
  text-align: right;
  white-space: nowrap;
}

.osm__input-shell input::-webkit-outer-spin-button,
.osm__input-shell input::-webkit-inner-spin-button {
  margin: 0;
}

.osm__toggle {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 4px;
  padding: 4px;
}

.osm__toggle-btn {
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--osm-muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.68rem;
  font-weight: 900;
  min-height: 30px;
  min-width: 0;
  overflow: hidden;
  padding: 0 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.osm__toggle-btn--active {
  background: var(--osm-ink);
  color: var(--osm-panel);
}

.osm__converted,
.osm__hint {
  color: var(--osm-muted);
  font-size: 0.76rem;
  line-height: 1.25;
  min-height: 32px;
  overflow-wrap: anywhere;
}

.osm__hero {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr);
}

.osm__metric {
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.12), rgba(33, 166, 184, 0.08)),
    var(--osm-soft);
  border: 1px solid rgba(37, 99, 235, 0.18);
  border-radius: 8px;
  min-height: 104px;
  padding: 14px;
}

.osm__metric span,
.osm__metric small {
  color: var(--osm-muted);
  display: block;
  font-weight: 900;
}

.osm__metric span {
  font-size: 0.82rem;
  text-transform: uppercase;
}

.osm__metric small {
  font-size: 0.76rem;
  line-height: 1.25;
}

.osm__metric strong {
  display: block;
  font-size: 2.35rem;
  line-height: 1;
  margin: 7px 0 4px;
}

.osm__metric--primary strong {
  color: var(--osm-blue);
}

.osm__gap-chip {
  background:
    linear-gradient(135deg, rgba(7, 148, 85, 0.12), rgba(247, 144, 9, 0.08)),
    var(--osm-soft);
  border-color: rgba(7, 148, 85, 0.28);
}

.osm__gap-chip strong {
  color: var(--osm-green);
}

.osm__gap-chip--elevated {
  background:
    linear-gradient(135deg, rgba(217, 45, 32, 0.16), rgba(247, 144, 9, 0.12)),
    var(--osm-soft);
  border-color: rgba(217, 45, 32, 0.58);
}

.osm__gap-chip--elevated strong {
  color: var(--osm-red);
}

.osm__bars {
  display: grid;
  gap: 10px;
}

.osm__bar-row {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: 76px minmax(0, 1fr) 42px;
}

.osm__bar-row span,
.osm__bar-row b {
  color: var(--osm-muted);
  font-size: 0.76rem;
  font-weight: 900;
}

.osm__bar-row b {
  text-align: right;
}

.osm__bar-track {
  background: color-mix(in srgb, var(--osm-soft) 88%, var(--osm-ink));
  border: 1px solid var(--osm-line);
  border-radius: 999px;
  height: 18px;
  overflow: hidden;
  position: relative;
}

.osm__bar {
  border-radius: inherit;
  height: 100%;
  min-width: 0;
  transition: width 0.28s ease;
}

.osm__bar--calculated {
  background: linear-gradient(90deg, var(--osm-blue), var(--osm-cyan));
}

.osm__bar--measured {
  background: linear-gradient(90deg, var(--osm-green), var(--osm-amber));
}

.osm__bar-gap {
  background: linear-gradient(90deg, rgba(247, 144, 9, 0.92), rgba(217, 45, 32, 0.95));
  border-left: 2px solid rgba(255, 255, 255, 0.72);
  height: 100%;
  position: absolute;
  right: 0;
  top: 0;
  transition: width 0.28s ease;
}

.osm__bar-row--muted {
  opacity: 0.58;
}

.osm__alert {
  background: rgba(217, 45, 32, 0.11);
  border: 1px solid rgba(217, 45, 32, 0.45);
  border-radius: 8px;
  padding: 12px;
}

.osm__alert strong {
  color: var(--osm-red);
  display: block;
  font-size: 0.95rem;
}

.osm__alert p {
  font-size: 0.86rem;
  line-height: 1.35;
  margin: 6px 0;
}

.osm__alert span {
  color: var(--osm-muted);
  display: block;
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1.3;
}

.osm__formula {
  align-items: center;
  background: rgba(16, 24, 40, 0.03);
  border: 1px solid var(--osm-line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: 120px minmax(0, 1fr);
  padding: 10px;
}

.theme-dark .osm__formula {
  background: rgba(255, 255, 255, 0.03);
}

.osm__formula span {
  color: var(--osm-muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.osm__formula code {
  background: var(--osm-soft);
  border: 1px solid var(--osm-line);
  border-radius: 6px;
  color: var(--osm-ink);
  display: block;
  font-size: 0.82rem;
  padding: 8px 10px;
  white-space: normal;
}

@media (min-width: 720px) {
  .osm__grid {
    grid-template-columns: 1fr;
  }

  .osm__panel--results {
    grid-column: 1 / -1;
  }

  .osm__panel--inputs {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .osm__hero {
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.9fr);
  }

  .osm__formula {
    grid-column: 1 / -1;
  }
}

@media (min-width: 720px) and (max-width: 1020px) {
  .osm__panel--inputs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .osm {
    padding: 10px;
  }

  .osm__warning {
    align-items: start;
  }

  .osm__input-shell--toggle {
    grid-template-columns: minmax(0, 1fr) 142px;
  }

  .osm__toggle {
    border-top: 0;
  }

  .osm__toggle-btn {
    padding: 0 6px;
  }

  .osm__bar-row {
    grid-template-columns: 66px minmax(0, 1fr) 38px;
  }

  .osm__formula {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 430px) {
  .osm__field {
    grid-template-rows: 18px auto 32px;
  }

  .osm__input-shell--toggle {
    grid-template-columns: 1fr;
    grid-template-rows: 44px 34px;
    height: auto;
    min-height: 78px;
  }

  .osm__toggle {
    border-top: 1px solid var(--osm-line);
  }

  .osm__toggle-btn {
    padding: 0 8px;
  }
}
