* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #f0f2f5;
  --bg-card: #ffffff;
  --border-card: #e2e5ea;
  --border-card-hover: #cbd0d8;
  --text-primary: #1a1d23;
  --text-secondary: #4b5563;
  --text-muted: #9ca3af;
  --accent: #2563eb;
  --accent-light: #3b82f6;
  --accent-bg: #eff6ff;
  --accent-border: #bfdbfe;
  --accent-glow: rgba(37, 99, 235, 0.15);
  --success: #059669;
  --success-bg: #ecfdf5;
  --success-border: #a7f3d0;
  --error: #dc2626;
  --chip-bg: #f3f4f6;
  --chip-text: #4b5563;
  --chip-active: #2563eb;
  --chip-hover: #e5e7eb;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  padding: 1rem;
  line-height: 1.5;
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 1.25rem;
}

h1 {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 0.15rem;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ==================== MAIN LAYOUT ==================== */
.layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1rem;
  max-width: 1100px;
  margin: 0 auto;
  align-items: start;
}

/* Left: selections */
.selections {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Right: result panel stretches full height */
.result-panel {
  align-self: stretch;
}

/* ==================== CARDS ==================== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 14px;
  padding: 1rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.card:hover {
  border-color: var(--border-card-hover);
  box-shadow: var(--shadow-md);
}

.card-header {
  text-align: center;
  margin-bottom: 0.5rem;
}

.card-header-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-align: left;
}

.card-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
  margin: 0 auto 0.35rem;
  box-shadow: 0 2px 6px rgba(37,99,235,0.25);
}

.card-header-row .card-number {
  margin: 0;
}

.card-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-primary);
}

.card-subtitle {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 1px;
}

.card-illustration {
  display: flex;
  justify-content: center;
  padding: 0.5rem 0 0.6rem;
}

/* Grid 2 columns for vial + diluent */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

/* ==================== CHIPS ==================== */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: center;
}

.chip {
  position: relative;
}

.chip input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.chip label {
  display: inline-block;
  padding: 0.3rem 0.65rem;
  background: var(--chip-bg);
  border: 1.5px solid transparent;
  border-radius: 7px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--chip-text);
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.chip label:hover {
  background: var(--chip-hover);
  color: var(--text-primary);
}

.chip input[type="radio"]:checked + label {
  background: var(--chip-active);
  color: #fff;
  border-color: var(--chip-active);
  box-shadow: 0 2px 8px rgba(37,99,235,0.3);
}

/* Custom input */
.custom-input {
  display: none;
  margin-top: 0.5rem;
  text-align: center;
}

.custom-input.visible {
  display: block;
}

.custom-input input {
  width: 100%;
  max-width: 130px;
  padding: 0.35rem 0.6rem;
  background: #fff;
  border: 1.5px solid var(--border-card);
  border-radius: 7px;
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 500;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  text-align: center;
}

.custom-input input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.custom-input input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

/* ==================== SYRINGE OPTIONS ==================== */
.syringe-options {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.35rem;
}

.syringe-option {
  position: relative;
  flex: 1;
}

.syringe-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.syringe-option label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 0.3rem;
  background: var(--chip-bg);
  border: 1.5px solid transparent;
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}

.syringe-option label:hover {
  background: var(--chip-hover);
}

.syringe-option input[type="radio"]:checked + label {
  background: var(--accent-bg);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.syringe-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-primary);
}

.syringe-units {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ==================== DOSE CHIPS ==================== */
.dose-chips {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.35rem;
}

.dose-chips .chip label {
  width: 100%;
  text-align: center;
  padding: 0.3rem 0.15rem;
  font-size: 0.76rem;
}

/* ==================== RESULTS PANEL ==================== */
.results-card {
  background: var(--bg-card);
  border: 2px solid var(--border-card);
  border-radius: 16px;
  padding: 1rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.4s, box-shadow 0.4s;
  position: sticky;
  top: 0.5rem;
  max-height: calc(100vh - 1rem);
  overflow-y: auto;
}

.results-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.results-card.has-result {
  border-color: var(--accent);
  box-shadow: 0 4px 20px rgba(37,99,235,0.12), 0 0 0 4px var(--accent-glow);
}

.results-card.has-error {
  border-color: var(--error);
  box-shadow: 0 4px 20px rgba(220,38,38,0.1), 0 0 0 4px rgba(220,38,38,0.08);
}

.result-placeholder {
  color: var(--text-muted);
  font-size: 0.82rem;
  padding: 1.5rem 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.result-placeholder p {
  max-width: 220px;
  line-height: 1.5;
}

.result-main {
  display: none;
}

.result-main.visible {
  display: block;
}

/* ==================== VERTICAL SYRINGE SVG ==================== */
.syringe-vertical-viz {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 0.15rem;
  margin-bottom: 0.5rem;
}

.syringe-vertical-svg {
  width: 45px;
  height: auto;
  max-height: 180px;
}

.syringe-fill-svg {
  transition: y 0.5s cubic-bezier(0.4, 0, 0.2, 1), height 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.syringe-tick-labels {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 30px 0 34px;
  height: 180px;
}

.syringe-tick-labels span {
  font-size: 0.6rem;
  color: var(--text-muted);
  font-weight: 600;
  line-height: 1;
}

/* ==================== RESULT TEXT ==================== */
.result-draw {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  line-height: 1.7;
}

.result-draw .highlight {
  display: inline-block;
  color: #fff;
  font-size: 1.15rem;
  font-weight: 800;
  padding: 0.2rem 0.7rem;
  background: var(--accent);
  border-radius: 8px;
  box-shadow: 0 3px 10px rgba(37,99,235,0.3);
  margin-top: 0.25rem;
}

/* Result info cards */
.result-info {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.result-info-item {
  flex: 1;
  text-align: center;
  background: var(--bg-primary);
  padding: 0.5rem 0.4rem;
  border-radius: 8px;
  border: 1px solid var(--border-card);
}

.result-info-label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 0.15rem;
  font-weight: 600;
}

.result-info-value {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
}

.result-info-value .badge {
  display: inline-block;
  background: var(--success-bg);
  color: var(--success);
  padding: 0.1rem 0.4rem;
  border-radius: 5px;
  font-weight: 700;
  border: 1px solid var(--success-border);
}

/* ==================== ERROR ==================== */
.result-error {
  display: none;
  padding: 1rem 0;
}

.result-error.visible {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.error-icon {
  margin-bottom: 0.15rem;
}

.error-title {
  color: var(--error);
  font-weight: 700;
  font-size: 0.95rem;
}

.error-message {
  color: var(--text-secondary);
  font-size: 0.8rem;
  line-height: 1.6;
  max-width: 280px;
}

/* ==================== BUTTONS ==================== */
.actions {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.btn {
  padding: 0.45rem 1.2rem;
  border: none;
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.04em;
}

.btn-reset {
  background: var(--chip-bg);
  color: var(--text-secondary);
  border: 1px solid var(--border-card);
}

.btn-reset:hover {
  background: var(--chip-hover);
  color: var(--text-primary);
}

.btn-print {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 6px rgba(37,99,235,0.25);
}

.btn-print:hover {
  box-shadow: 0 3px 10px rgba(37,99,235,0.35);
  transform: translateY(-1px);
}

/* ==================== DOSE TABLE ==================== */
.dose-table {
  margin: 0.75rem 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-card);
  font-size: 0.72rem;
}

.dose-table table {
  width: 100%;
  border-collapse: collapse;
}

.dose-table th {
  background: var(--bg-primary);
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 0.6rem;
  padding: 0.4rem 0.3rem;
  text-align: center;
  border-bottom: 1px solid var(--border-card);
}

.dose-table td {
  padding: 0.3rem 0.3rem;
  text-align: center;
  border-bottom: 1px solid var(--border-card);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.7rem;
}

.dose-table tr:last-child td {
  border-bottom: none;
}

.dose-table tr.selected-dose {
  background: var(--accent-bg);
}

.dose-table tr.selected-dose td {
  color: var(--accent);
  font-weight: 800;
}

.dose-table tr.selected-dose td:first-child::before {
  content: "\25B6 ";
  font-size: 0.55rem;
}

/* ==================== SHARE BUTTONS ==================== */
.btn-share {
  background: #6b7280;
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.btn-share:hover {
  background: #4b5563;
}

.btn-whatsapp {
  background: #25D366;
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  box-shadow: 0 2px 6px rgba(37,211,102,0.3);
}

.btn-whatsapp:hover {
  background: #1fb855;
}

/* Copy toast */
.copy-toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1a1d23;
  color: #fff;
  padding: 0.5rem 1.2rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  z-index: 100;
}

.copy-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Footer */
.footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.65rem;
  margin-top: 1.5rem;
  padding-bottom: 1rem;
}

.footer a {
  color: var(--text-muted);
  text-decoration: underline;
  cursor: pointer;
}

.footer a:hover {
  color: var(--text-secondary);
}

.disclaimer-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.disclaimer-modal.active {
  display: flex;
}

.disclaimer-content {
  background: #fff;
  border-radius: 12px;
  max-width: 480px;
  width: 90%;
  padding: 1.5rem;
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--text-secondary);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.disclaimer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.disclaimer-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
}

.disclaimer-close:hover {
  color: var(--text-primary);
}

.disclaimer-content p {
  margin-bottom: 0.6rem;
}

.disclaimer-content p:last-child {
  margin-bottom: 0;
}

/* ==================== AD SLOTS ==================== */
.ad-slot {
  max-width: 1100px;
  margin: 0.75rem auto;
  text-align: center;
  overflow: hidden;
  display: none;
}

.ad-slot.ad-loaded {
  display: block;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .result-panel {
    position: static;
  }

  /* On mobile: show horizontal syringe instead */
  .syringe-vertical-viz {
    flex-direction: row;
  }

  .syringe-vertical-svg {
    width: 100%;
    max-width: 300px;
    max-height: none;
  }

  .syringe-tick-labels {
    flex-direction: row;
    height: auto;
    padding: 4px 16px 0;
  }
}

@media (max-width: 600px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .dose-chips {
    grid-template-columns: repeat(3, 1fr);
  }

  .syringe-options {
    flex-direction: column;
  }

  .syringe-option label {
    flex-direction: row;
    gap: 0.5rem;
    justify-content: center;
  }

  body {
    padding: 0.5rem;
  }
}

@media (max-width: 400px) {
  .dose-chips {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ==================== PRINT ==================== */
@media print {
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  body {
    background: var(--bg-primary);
    padding: 1rem;
  }

  .result-panel {
    position: static;
  }

  .results-card {
    max-height: none;
    overflow: visible;
  }

  .card, .results-card {
    box-shadow: none;
  }

  .ad-slot {
    display: none !important;
  }

  .actions {
    display: none;
  }

  .footer {
    display: none;
  }

  .disclaimer-modal {
    display: none;
  }

  .chip input[type="radio"]:checked + label {
    background: var(--chip-active);
    color: #fff;
    border-color: var(--chip-active);
  }

  .syringe-option input[type="radio"]:checked + label {
    background: var(--accent-bg);
    border-color: var(--accent);
  }

  .syringe-fill-svg {
    fill: url(#fillGradientV);
  }
}
