:root {
  color-scheme: dark;
  --ink: #f4fbff;
  --muted: #93a6b7;
  --line: rgba(137, 169, 190, 0.24);
  --panel: rgba(10, 20, 30, 0.78);
  --panel-solid: #101b27;
  --bg: #081018;
  --accent: #36d7c7;
  --accent-dark: #19a99c;
  --alert: #ffb45c;
  --soft: rgba(54, 215, 199, 0.14);
  --hot: #ff5d73;
  --glow: rgba(54, 215, 199, 0.22);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 0%, rgba(54, 215, 199, 0.16), transparent 34rem),
    radial-gradient(circle at 92% 8%, rgba(255, 93, 115, 0.13), transparent 28rem),
    linear-gradient(145deg, #050a10 0%, #081018 42%, #0d1722 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1280px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 20px;
}

.site-logo {
  flex: none;
  width: clamp(5rem, 10vw, 6.5rem);
  height: clamp(5rem, 10vw, 6.5rem);
  border-radius: 14px;
  box-shadow: 0 0 24px rgba(54, 215, 199, 0.12);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 4.3rem);
  line-height: 0.96;
  max-width: 760px;
  text-shadow: 0 0 32px rgba(54, 215, 199, 0.16);
}

h2 {
  font-size: 1.8rem;
}

.status,
.badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(9, 18, 27, 0.84);
  padding: 8px 12px;
  color: #d2edf0;
  white-space: nowrap;
  box-shadow: inset 0 0 20px rgba(54, 215, 199, 0.05);
}

.badge-stack {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.dose-type-badge {
  color: #ffe0a6;
}

.dose-type-badge.weight {
  color: #a7fff4;
  border-color: rgba(54, 215, 199, 0.52);
}

.protocol-level-badge.bls-als {
  color: #ffe566;
  border-color: rgba(255, 210, 0, 0.45);
  background: rgba(255, 210, 0, 0.1);
}

.protocol-level-badge.als {
  color: #ffc8d0;
  border-color: rgba(200, 16, 46, 0.45);
  background: rgba(200, 16, 46, 0.1);
}

.protocol-level-badge.als-osp {
  color: #d8c8ff;
  border-color: rgba(160, 120, 255, 0.45);
  background: rgba(160, 120, 255, 0.1);
}


.protocol-pill {
  border-radius: 999px;
  font-size: 0.62rem;
  font-style: normal;
  font-weight: 900;
  line-height: 1;
  padding: 5px 7px;
  text-transform: uppercase;
  white-space: nowrap;
  border: 1px solid transparent;
}

.protocol-pill.bls-als {
  background: rgba(255, 210, 0, 0.14);
  border-color: rgba(255, 210, 0, 0.44);
  color: #ffe566;
}

.protocol-pill.als {
  background: rgba(200, 16, 46, 0.14);
  border-color: rgba(200, 16, 46, 0.44);
  color: #ffc8d0;
}

.protocol-pill.als-osp {
  background: rgba(160, 120, 255, 0.14);
  border-color: rgba(160, 120, 255, 0.44);
  color: #d8c8ff;
}

.notice {
  border-left: 5px solid var(--alert);
  background: rgba(255, 180, 92, 0.1);
  padding: 12px 14px;
  margin-bottom: 14px;
  color: #ffdcb0;
  font-weight: 650;
  border-radius: 0 8px 8px 0;
}

.filter-toolbar {
  padding: 14px 16px;
  margin-bottom: 14px;
  display: grid;
  gap: 12px;
}

.filter-toolbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.filter-toolbar-row.search-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) minmax(180px, 1fr);
  gap: 12px;
  align-items: end;
}

.filter-toolbar-segments {
  gap: 16px;
}

.search-field label,
.filter-toolbar .filter-label {
  margin-bottom: 6px;
}

.search-field input,
.search-field select {
  margin-bottom: 0;
}

.segment-block {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.workspace {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 18px;
  align-items: start;
}

.med-sidebar {
  padding: 12px 16px 16px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  align-self: start;
}

.med-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.med-sidebar-header .filter-label {
  margin: 0;
}

.med-expand-btn {
  border: 1px solid var(--line);
  background: rgba(8, 16, 24, 0.78);
  color: var(--accent);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 850;
  padding: 7px 10px;
  white-space: nowrap;
  flex-shrink: 0;
}

.med-expand-btn:hover {
  border-color: var(--accent);
  background: var(--soft);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.34), 0 0 0 1px rgba(255, 255, 255, 0.02);
  backdrop-filter: blur(18px);
}

.filter-toolbar.panel {
  margin-bottom: 14px;
}

.search-panel {
  padding: 16px;
  position: sticky;
  top: 16px;
}

label {
  display: block;
  margin: 0 0 7px;
  color: #b6c7d4;
  font-size: 0.88rem;
  font-weight: 750;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(5, 11, 18, 0.86);
  color: var(--ink);
  padding: 9px 11px;
  margin-bottom: 14px;
}

input::placeholder {
  color: #607484;
}

input:focus,
select:focus,
button:focus {
  outline: 3px solid var(--glow);
  border-color: var(--accent);
}

.filter-block {
  margin-bottom: 14px;
}

.filter-label {
  display: block;
  margin: 0 0 7px;
  color: #b6c7d4;
  font-size: 0.88rem;
  font-weight: 750;
}

.chip-grid,
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1;
}

.chip-grid {
  display: flex;
}

.chip,
.segment {
  border: 1px solid var(--line);
  background: rgba(8, 16, 24, 0.78);
  color: var(--ink);
  cursor: pointer;
}

.chip {
  min-height: 36px;
  border-radius: 999px;
  padding: 8px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 0 0 auto;
}

.chip span {
  font-weight: 800;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip strong {
  color: var(--accent);
  font-size: 0.82rem;
}

.chip:hover,
.chip.active,
.segment:hover,
.segment.active {
  border-color: var(--accent);
  background: var(--soft);
}

.chip.active {
  box-shadow: inset 0 0 0 1px rgba(54, 215, 199, 0.35);
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  flex: 0 0 auto;
  width: fit-content;
  max-width: 100%;
}

.segment {
  min-height: 36px;
  border-width: 0 1px 0 0;
  border-radius: 0;
  font-size: 0.82rem;
  font-weight: 850;
  padding: 0 14px;
  white-space: nowrap;
}

.segment:last-child {
  border-right: 0;
}

.med-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.med-grid-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  padding: 16px;
  background: rgba(4, 8, 12, 0.94);
  backdrop-filter: blur(10px);
}

.med-grid-overlay.open {
  display: flex;
}

.med-grid-panel {
  display: flex;
  flex-direction: column;
  width: min(1280px, 100%);
  max-height: 100%;
  margin: 0 auto;
  min-height: 0;
  flex: 1;
}

.med-grid-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 16px 12px;
  flex-shrink: 0;
}

.med-grid-header h2 {
  margin: 4px 0 0;
  font-size: 1.35rem;
}

.med-list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
  align-content: start;
  padding: 0 16px 16px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.med-list-grid .med-item {
  height: 100%;
}

.med-list-grid .med-title-row {
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.med-list-grid .med-title-row strong {
  width: 100%;
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
}

.med-list-grid .med-pills {
  justify-content: flex-start;
}

body.med-grid-open {
  overflow: hidden;
}

.med-item {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(8, 16, 24, 0.78);
  color: var(--ink);
  padding: 10px;
  text-align: left;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
  flex-shrink: 0;
}

.med-item:hover,
.med-item.active {
  border-color: var(--accent);
  background: var(--soft);
  transform: translateY(-1px);
}

.med-item strong {
  display: block;
  margin-bottom: 3px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.med-item span {
  color: var(--muted);
  font-size: 0.85rem;
}

.med-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.med-title-row strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.med-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.med-title-row em {
  border-radius: 999px;
  font-size: 0.68rem;
  font-style: normal;
  font-weight: 900;
  line-height: 1;
  padding: 5px 7px;
  text-transform: uppercase;
  white-space: nowrap;
}

.weight-pill {
  background: rgba(54, 215, 199, 0.14);
  border: 1px solid rgba(54, 215, 199, 0.44);
  color: #a7fff4;
}

.fixed-pill {
  background: rgba(255, 180, 92, 0.12);
  border: 1px solid rgba(255, 180, 92, 0.36);
  color: #ffdcab;
}

.med-item small {
  display: inline-block;
  margin-top: 7px;
  color: #7fb8c1;
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.calculator {
  padding: 20px;
}


.calc-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
  margin-bottom: 18px;
}

.muted {
  color: var(--muted);
}

.dose-card {
  background:
    linear-gradient(135deg, rgba(54, 215, 199, 0.2), rgba(255, 93, 115, 0.1)),
    #071319;
  color: #fff;
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 18px;
  border: 1px solid rgba(54, 215, 199, 0.28);
  box-shadow: 0 0 44px rgba(54, 215, 199, 0.1);
}

.dose-card span {
  color: #a7fff4;
}

.dose-card strong {
  display: block;
  margin: 4px 0;
  font-size: clamp(2.2rem, 6vw, 4.5rem);
  line-height: 1;
  overflow-wrap: anywhere;
}

.dose-card p {
  margin: 0;
  color: #d2e7e9;
}

.draw-card {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(260px, 0.9fr);
  gap: 14px;
  align-items: stretch;
  border: 1px solid rgba(255, 180, 92, 0.28);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 180, 92, 0.12), rgba(54, 215, 199, 0.06)),
    rgba(7, 14, 22, 0.76);
  padding: 14px;
  margin-bottom: 18px;
}

.draw-result {
  border-right: 1px solid var(--line);
  padding-right: 14px;
}

.draw-result span {
  color: #ffdcab;
}

.draw-result strong {
  display: block;
  margin: 4px 0;
  color: #fff4df;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1;
}

.draw-result p {
  margin: 0;
  color: #d9c8ad;
  line-height: 1.35;
}

.locked-concentration {
  align-self: center;
}

.locked-concentration span {
  display: block;
  color: #ffdcab;
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
  margin-bottom: 7px;
}

.locked-concentration strong {
  display: block;
  color: #fff;
  font-size: 1.15rem;
  line-height: 1.25;
  margin-bottom: 8px;
}

.locked-select {
  margin-bottom: 10px;
}

.locked-select[hidden] {
  display: none;
}

.locked-concentration p {
  margin: 0;
  color: #d9c8ad;
  line-height: 1.35;
}

.concentration-controls {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(120px, 0.85fr);
  gap: 12px;
  align-items: end;
}

.concentration-controls input,
.concentration-controls select {
  margin-bottom: 0;
}

.controls {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 12px;
  align-items: start;
  padding: 14px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(12, 12, 12, 0.72);
}

.regimen-group {
  grid-column: span 2;
}

.controls.optional-weight input#weight {
  border-style: dashed;
}

.controls input,
.controls select {
  margin-bottom: 6px;
}

button[type="submit"] {
  align-self: start;
  margin-top: 25px;
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), #69a7ff);
  color: #031016;
  font-weight: 800;
  padding: 0 18px;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(54, 215, 199, 0.16);
}

button[type="submit"]:hover {
  background: linear-gradient(135deg, #54f4e5, #7cb4ff);
}

.controls.disabled {
  opacity: 0.68;
}

.controls.disabled input,
.controls.disabled select {
  cursor: not-allowed;
}

button[type="submit"]:disabled {
  background: rgba(96, 116, 132, 0.35);
  color: #8fa1ad;
  cursor: not-allowed;
  box-shadow: none;
}

.conversion {
  min-height: 18px;
  color: #9eece4;
  font-size: 0.82rem;
  font-weight: 700;
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding-top: 18px;
}

.details-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  min-height: 118px;
  background: rgba(7, 14, 22, 0.58);
}

.details-grid span {
  display: block;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
  margin-bottom: 7px;
}

.details-grid p {
  margin: 0;
  line-height: 1.45;
}

.wide-detail {
  grid-column: 1 / -1;
}

@media (max-width: 860px) {
  .topbar,
  .calc-header {
    align-items: start;
    flex-direction: column;
  }

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

  .med-sidebar {
    max-height: none;
  }

  .med-list:not(.med-list-grid) {
    max-height: 320px;
  }

  .filter-toolbar-row.search-row {
    grid-template-columns: 1fr;
  }

  .filter-toolbar-segments {
    flex-direction: column;
    align-items: stretch;
  }

  .segment-block {
    flex-direction: column;
    align-items: stretch;
  }

  .segment-block .segmented {
    width: 100%;
    min-width: 0;
  }

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

  .regimen-group {
    grid-column: span 2;
  }

  .draw-card,
  .details-grid {
    grid-template-columns: 1fr;
  }

  button[type="submit"] {
    margin-top: 0;
  }

  .draw-result {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding-right: 0;
    padding-bottom: 14px;
  }
}

@media (max-width: 560px) {
  .segmented {
    display: grid;
    grid-template-columns: 1fr;
    border-radius: 7px;
  }

  .segmented-four {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border-radius: 7px;
  }

  .segment {
    border-width: 0 0 1px;
  }

  .segment:last-child {
    border-bottom: 0;
  }

  .concentration-controls {
    grid-template-columns: 1fr;
  }
}
