:root {
  --primary: #2563eb;
  --secondary: #10b981;
  --accent: #22d3ee;
  --bg-light: #f9fafb;
  --bg-card: #fff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --danger: #dc2626;
  --border: #e2e8f0;
}

/* Global Reset & Base */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-light);
  color: var(--text-main);
  font-family: 'Segoe UI', Arial, sans-serif;
  line-height: 1.5;
}

.container {
  width: 100%;
  max-width: 1050px;
  margin: 0 auto;
  padding: 20px 8px 60px;
}

/* Typography */
h1 {
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 8px;
  text-align: center;
}

h2 {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 20px;
}

h3 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 15px;
}

.subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 1.1rem;
  margin-bottom: 28px;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 22px;
  justify-content: center;
}

.tab-btn {
  padding: 12px 28px;
  font-weight: 600;
  border: none;
  background: var(--bg-card);
  border-bottom: 3px solid var(--bg-light);
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 1rem 1rem 0 0;
  transition: all 0.2s ease;
  font-size: 1rem;
}

.tab-btn.active {
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  color: #fff;
  border-bottom-color: var(--secondary);
}

.tab-btn:hover:not(.active) {
  background: #f1f5f9;
}

/* Tab Content */
.tab-content {
  display: block;
}

.tab-content.hidden {
  display: none;
}

/* Cards */
.card {
  background: var(--bg-card);
  border-radius: 1rem;
  box-shadow: 0 2px 12px rgba(30, 41, 59, 0.09);
  padding: 28px;
  margin-bottom: 22px;
}

/* Form Elements */
.field-row {
  display: flex;
  gap: 18px;
  margin-bottom: 16px;
}

.field {
  flex: 1;
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-weight: 500;
  margin-bottom: 4px;
  color: var(--text-main);
}

input[type='text'],
input[type='number'],
select {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  font-size: 1rem;
  transition: outline 0.2s ease, border-color 0.2s ease;
  background: var(--bg-card);
}

input:focus,
select:focus {
  outline: 2px solid var(--secondary);
  border-color: var(--secondary);
}

.unit-select {
  margin-top: 4px;
  width: 100%;
}

/* Radio Groups */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.radio-option {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.radio-option input[type="radio"] {
  margin-top: 2px;
  width: auto;
}

.radio-option label {
  flex: 1;
  cursor: pointer;
}

.radio-option .subtext {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Checkbox Options */
.checkbox-option {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.checkbox-option input[type="checkbox"] {
  width: auto;
}

.checkbox-option label {
  cursor: pointer;
  margin-bottom: 0;
}

/* Buttons */
.btn {
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  color: #fff;
  padding: 11px 28px;
  border: none;
  border-radius: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
  transition: opacity 0.2s ease;
  font-size: 1rem;
}

.btn:hover {
  opacity: 0.9;
}

.btn:disabled {
  background: #d1d5db;
  cursor: not-allowed;
  opacity: 0.7;
}

.btn-secondary {
  background: var(--accent);
}

.btn-tertiary {
  background: var(--text-muted);
}

.button-group {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
}

/* Results */
.results {
  background: #e0f2fe;
  border-radius: 0.7rem;
  padding: 24px;
  margin-top: 14px;
}

.results h3 {
  color: var(--primary);
  font-size: 1.5rem;
  margin-bottom: 10px;
}

.results ul {
  list-style: disc;
  padding-left: 20px;
  margin-bottom: 0;
}

.results li {
  margin-bottom: 6px;
}

/* Peptide Cards */
.peptide {
  background: #f1f5f9;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 15px;
}

.peptide .field-row {
  margin-bottom: 12px;
}

.peptide .field:last-child {
  margin-bottom: 0;
}

/* Vials Display */
.vial {
  margin-bottom: 10px;
  padding: 8px;
  background: #f8fafc;
  border-radius: 8px;
}

.vial-label {
  display: flex;
  align-items: center;
  gap: 12px;
}

.vial-name {
  font-weight: 600;
  flex: 1;
}

.vial-mass {
  width: 80px;
  text-align: right;
  color: var(--text-muted);
}

.vial-dosage {
  width: 120px;
  text-align: right;
  color: var(--text-muted);
}

/* Share URL Box */
.share-url-box {
  background: #f9f9f9;
  border-radius: 8px;
  padding: 16px;
  margin-top: 16px;
  text-align: center;
}

.share-url-box.hidden {
  display: none;
}

.share-url-box input {
  border: none;
  background: transparent;
  color: var(--primary);
  text-align: center;
  font-size: 0.9rem;
}

.copy-confirmation {
  color: var(--secondary);
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.3s ease;
  margin-top: 8px;
}

.copy-confirmation.show {
  opacity: 1;
}

/* Preset Description */
.preset-desc {
  font-style: italic;
  color: var(--text-muted);
  margin-top: 4px;
  font-size: 0.9rem;
}

/* Reference Table */
.reference {
  background: #f3f4f6;
  border-radius: 0.7rem;
  padding: 18px;
  margin-top: 16px;
}

.table-responsive {
  overflow-x: auto;
}

.reference table {
  width: 100%;
  border-collapse: collapse;
  min-width: 500px;
}

.reference th,
.reference td {
  padding: 10px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.reference th {
  background: #dbeafe;
  color: var(--primary);
  font-weight: 600;
}

.reference tr:nth-child(even) {
  background: #f8fafc;
}

/* Converter */
.converter {
  background: #f3f4f6;
  border-radius: 0.7rem;
  padding: 18px;
  margin-top: 16px;
}

.converter-section {
  margin-bottom: 20px;
}

.converter-section:last-child {
  margin-bottom: 0;
}

.converter-row {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 400px;
}

.converter-row input {
  flex: 1;
  min-width: 120px;
}

.converter-row span {
  font-weight: 600;
  color: var(--text-main);
}

/* Utility Classes */
.hidden {
  display: none !important;
}

.danger {
  color: var(--danger);
  font-weight: 600;
}

/* Footer */
footer {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  margin-top: 40px;
}

/* Responsive Design */
@media (max-width: 768px) {
  .container {
    padding: 16px 12px 40px;
  }

  h1 {
    font-size: 2rem;
  }

  .field-row {
    flex-direction: column;
  }

  .tabs {
    flex-direction: column;
    gap: 4px;
  }

  .tab-btn {
    width: 100%;
    text-align: center;
    border-radius: 0.7rem;
  }

  .button-group {
    flex-direction: column;
  }

  .btn {
    width: 100%;
    text-align: center;
  }

  .converter-row {
    flex-direction: column;
    align-items: stretch;
    max-width: none;
  }

  .vial-label {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .vial-mass,
  .vial-dosage {
    width: auto;
    text-align: left;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 12px 8px 30px;
  }

  .card {
    padding: 20px;
  }

  h1 {
    font-size: 1.8rem;
  }

  .subtitle {
    font-size: 1rem;
  }

  .tab-btn {
    padding: 10px 16px;
    font-size: 0.9rem;
  }
}

/* Print Styles */
@media print {
  .tabs,
  .btn,
  .converter,
  .button-group,
  footer {
    display: none;
  }

  .results {
    background: #fff;
    box-shadow: none;
    border: 1px solid var(--border);
  }

  .card {
    box-shadow: none;
    border: 1px solid var(--border);
  }
}