* { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #f5f6f8;
    color: #1f2530;
    margin: 0;
    line-height: 1.5;
}

.container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 24px 20px 60px;
}

header h1 {
    font-size: 26px;
    margin: 0 0 6px;
    color: #1a3b6e;
    text-align: center;
}

header .subtitle {
    margin: 0 0 8px;
    color: #555c6b;
    font-size: 14px;
}

.disclaimer {
    margin: 10px 0 20px;
    padding: 8px 12px;
    background: #fff8e6;
    border-left: 3px solid #d4a017;
    color: #6b4f00;
    font-size: 12.5px;
    border-radius: 4px;
}

.disclaimer summary {
    cursor: pointer;
    list-style: none;
    line-height: 1.45;
}

.disclaimer summary::-webkit-details-marker { display: none; }
.disclaimer summary::marker { content: ""; }

.disclaimer-toggle {
    color: #1a3b6e;
    text-decoration: underline;
    font-size: 12px;
    margin-left: 4px;
}

.disclaimer[open] .disclaimer-toggle::after { content: " ↑"; }
.disclaimer:not([open]) .disclaimer-toggle::after { content: " ↓"; }

.disclaimer-full {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed #d4a017;
    font-size: 12px;
    line-height: 1.55;
}

.disclaimer-full p { margin: 4px 0; }

.panel {
    background: #fff;
    border: 1px solid #e3e6ec;
    border-radius: 8px;
    padding: 18px 20px;
    margin-bottom: 16px;
}

.panel h2 {
    margin: 0 0 14px;
    font-size: 17px;
    color: #1a3b6e;
    font-weight: 600;
}

.check-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 10px;
}

.check-grid label,
.radio-group label,
.check-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 4px;
}

.check-grid label:hover,
.radio-group label:hover,
.check-group label:hover {
    background: #f0f3f8;
}

.anx-sub {
    margin-top: 10px;
    padding: 10px 14px;
    background: #f7f9fc;
    border-left: 3px solid #1a3b6e;
    border-radius: 4px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    align-items: center;
    font-size: 13px;
}

.anx-sub[hidden] { display: none; }

.anx-sub-label {
    font-size: 12px;
    color: #5b6271;
    font-weight: 500;
    margin-right: 4px;
}

.anx-sub label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 6px;
    border-radius: 3px;
    cursor: pointer;
}

.anx-sub label:hover { background: #eef3fb; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

@media (max-width: 720px) {
    .form-row { grid-template-columns: 1fr; }
}

.form-group label {
    display: block;
    font-weight: 600;
    font-size: 13px;
    color: #4a5161;
    margin-bottom: 8px;
}

.radio-group,
.check-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.constraint-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 8px;
}

.constraint-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: #fff;
    border: 1px solid #d9dde4;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: #2c3242;
    text-align: left;
    font-family: inherit;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.constraint-btn:hover {
    background: #f3f5f9;
}

.constraint-btn.active {
    background: #fde9e7;
    border-color: #d94a3d;
    color: #8a1f15;
}

.weights {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.weight-row {
    display: grid;
    grid-template-columns: 220px 1fr 40px;
    align-items: center;
    gap: 12px;
}

@media (max-width: 720px) {
    .weight-row { grid-template-columns: 1fr 36px; }
    .weight-row label { grid-column: 1 / -1; }
}

.weight-row label {
    font-size: 14px;
    color: #2c3242;
    font-weight: 500;
}

.weight-out {
    text-align: right;
    font-weight: 600;
    color: #1a3b6e;
    font-size: 14px;
}

input[type="range"] {
    width: 100%;
}

.results-panel { border: 1px solid #cfe0f4; }

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    gap: 12px;
    flex-wrap: wrap;
}

.results-header h2 { margin: 0; }

.sort-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.sort-label {
    font-size: 12px;
    color: #5b6271;
    margin-right: 2px;
}

.btn-sort {
    background: #fff;
    border: 1px solid #d9dde4;
    color: #4a5161;
    padding: 5px 10px;
    border-radius: 14px;
    cursor: pointer;
    font-size: 12px;
    font-family: inherit;
}

.btn-sort:hover { background: #f3f5f9; }

.btn-sort.active {
    background: #1a3b6e;
    color: #fff;
    border-color: #1a3b6e;
}

.btn-secondary {
    background: #fff;
    border: 1px solid #1a3b6e;
    color: #1a3b6e;
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
}

.btn-secondary:hover { background: #eef3fb; }

.drug-card {
    display: grid;
    grid-template-columns: 28px 1fr auto;
    align-items: start;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid #e3e6ec;
    border-radius: 6px;
    margin-bottom: 8px;
    background: #fff;
}

.drug-card.top { border-color: #1d9e75; background: #f1faf6; }
.drug-card.passes { border-left: 4px solid #1d9e75; }
.drug-card.excluded { opacity: 0.5; }

.group-header {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    padding: 10px 0 6px;
    margin-top: 4px;
    border-top: 1px solid #e3e6ec;
}

.group-header:first-child {
    margin-top: 0;
    border-top: none;
    padding-top: 0;
}

.group-passing { color: #0f6e56; }
.group-partial { color: #8a4a00; }
.group-excluded { color: #6f7585; }

.drug-rank {
    font-weight: 700;
    color: #6f7585;
    font-size: 14px;
    padding-top: 2px;
}

.drug-name {
    font-weight: 600;
    font-size: 15px;
    color: #14213d;
}

.drug-class {
    display: inline-block;
    background: #eef2f8;
    color: #4a5161;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 8px;
    font-weight: 500;
}

.qt-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 20px;
    padding: 0 7px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
    color: #fff;
    margin-left: 8px;
    cursor: help;
    line-height: 1;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.qt-known       { background: #d94a3d; }
.qt-possible    { background: #d4a017; }
.qt-conditional { background: #1a73c0; }

.qt-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: center;
    margin-top: 8px;
    padding: 8px 12px;
    background: #f7f9fc;
    border-radius: 4px;
    font-size: 12px;
    color: #5b6271;
}

.qt-legend-title { font-weight: 600; color: #2c3242; }
.qt-legend-item  { display: inline-flex; align-items: center; gap: 4px; }
.qt-legend-item .qt-icon { margin-left: 0; }

.qt-explain {
    margin: 0 0 18px;
}

.qt-explain-intro {
    margin: 0 0 14px;
    padding: 10px 14px;
    background: #f7f9fc;
    border-left: 3px solid #1a3b6e;
    border-radius: 4px;
    font-size: 13px;
    color: #2c3242;
    line-height: 1.55;
}

.qt-explain-card {
    background: #fff;
    border: 1px solid #e3e6ec;
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 10px;
    font-size: 13px;
    color: #2c3242;
}

.qt-explain-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 14px;
}

.qt-explain-head .qt-icon { margin-left: 0; }

.qt-explain-card p { margin: 6px 0; line-height: 1.55; }
.qt-explain-card ul { margin: 4px 0 8px; padding-left: 20px; }
.qt-explain-card li { margin-bottom: 3px; line-height: 1.5; }

.drug-meta {
    color: #5b6271;
    font-size: 12px;
    margin: 4px 0 6px;
}

.drug-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 4px;
}

.tag {
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 10px;
    background: #f0f3f8;
    color: #4a5161;
}

.tag.warn { background: #fde9e7; color: #8a1f15; }
.tag.good { background: #e6f5ee; color: #0f6e56; }
.tag.info { background: #e6f1fb; color: #0c447c; }

.tag.se-low  { background: #fff4d6; color: #6b4f00; }
.tag.se-med  { background: #ffe2c2; color: #8a4a00; }
.tag.se-high { background: #fde0dc; color: #8a1f15; }

.drug-score {
    text-align: right;
    min-width: 210px;
}

.validated-badge {
    display: inline-block;
    font-size: 11px;
    padding: 3px 9px;
    border-radius: 10px;
    font-weight: 500;
    margin: 0 0 4px;
}

.validated-badge.is-amm {
    background: #e6f5ee;
    color: #0f6e56;
}

.validated-badge.is-reco {
    background: #eef3fb;
    color: #1a3b6e;
    border: 1px dashed #1a3b6e;
}

.prob-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.prob-col {
    background: #f7f9fc;
    border-radius: 4px;
    padding: 6px 8px;
    text-align: left;
    border: 1px solid transparent;
}

.prob-col.is-sort {
    background: #eef3fb;
    border-color: #1a3b6e;
}

.prob-col-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6f7585;
    font-weight: 500;
}

.prob-col-value {
    font-size: 18px;
    font-weight: 600;
    color: #1f2530;
    margin-top: 2px;
}

.prob-col-bar {
    height: 4px;
    background: #e3e6ec;
    border-radius: 2px;
    overflow: hidden;
    margin-top: 5px;
}

.prob-col-fill {
    height: 100%;
    width: var(--w, 0%);
}

.prob-col-fill.prob-eff { background: #1a3b6e; }
.prob-col-fill.prob-tol { background: #1d9e75; }

.score-bar {
    width: 100px;
    height: 6px;
    background: #eef2f8;
    border-radius: 3px;
    overflow: hidden;
    margin: 4px 0 6px auto;
}

.score-fill { height: 100%; background: #1a3b6e; }
.drug-card.top .score-fill { background: #1d9e75; }

.score-label {
    font-size: 11px;
    color: #6f7585;
}

.legend {
    margin-top: 12px;
    color: #6f7585;
    font-size: 12px;
    line-height: 1.6;
}

.sources h3 { font-size: 14px; color: #1a3b6e; margin: 14px 0 6px; font-weight: 600; }
.sources h3:first-of-type { margin-top: 0; }
.sources ul { margin: 0 0 8px; padding-left: 22px; font-size: 13px; color: #4a5161; }
.sources li { margin-bottom: 6px; line-height: 1.5; }
.sources a { color: #1a3b6e; text-decoration: none; border-bottom: 1px dotted #1a3b6e; }
.sources a:hover { color: #0c447c; border-bottom-style: solid; }
.biblio-note {
    margin-top: 14px;
    padding: 10px 14px;
    background: #fff8e6;
    border-left: 3px solid #d4a017;
    color: #6b4f00;
    font-size: 12px;
    border-radius: 4px;
    line-height: 1.5;
}

.data-table-title {
    font-size: 13px;
    color: #4a5161;
    font-weight: 600;
    margin: 10px 0 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    margin: 0 0 18px;
    background: #fff;
    border: 1px solid #e3e6ec;
    border-radius: 4px;
    overflow: hidden;
}

.data-table thead { background: #f7f9fc; }
.data-table th {
    padding: 8px 10px;
    text-align: left;
    font-weight: 600;
    color: #1a3b6e;
    border-bottom: 1px solid #e3e6ec;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.data-table td {
    padding: 7px 10px;
    border-bottom: 1px solid #f0f3f8;
    color: #2c3242;
    vertical-align: top;
    line-height: 1.45;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #f7f9fc; }
.data-table td .qt-icon { margin-left: 0; }

.data-table-legend {
    font-size: 12px;
    color: #5b6271;
    margin: 0 0 8px;
    line-height: 1.5;
}

.data-table-wrap {
    overflow-x: auto;
    margin-bottom: 18px;
    border-radius: 4px;
}

.data-table-wide {
    margin-bottom: 0;
    min-width: 880px;
}

.data-table-wide th,
.data-table-wide td {
    text-align: center;
    padding: 6px 8px;
    font-size: 11px;
}

.data-table-wide td:first-child,
.data-table-wide th:first-child,
.data-table-wide td:last-child,
.data-table-wide th:last-child {
    text-align: left;
}

.download-block {
    margin-top: 22px;
    padding: 16px 18px;
    background: #eef3fb;
    border: 1px solid #cfe0f4;
    border-radius: 8px;
}

.download-block h3 {
    margin: 0 0 8px;
    color: #1a3b6e;
    font-size: 15px;
}

.download-block p {
    margin: 0 0 12px;
    font-size: 13px;
    color: #4a5161;
    line-height: 1.5;
}

.btn-download {
    background: #1a3b6e;
    color: #fff;
    border: none;
    padding: 10px 18px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
}

.btn-download:hover { background: #14305a; }

.legend-top { margin-top: 0; }

.empty-msg {
    color: #6b4f00;
    background: #fff8e6;
    border-left: 3px solid #d4a017;
    padding: 12px 14px;
    border-radius: 4px;
    font-size: 13px;
}

.chart-host {
    width: 100%;
    overflow-x: auto;
}

.chart-svg {
    max-width: 100%;
    height: auto;
    display: block;
    font-family: inherit;
}

.chart-axis {
    stroke: #4a5161;
    stroke-width: 1;
}

.chart-grid {
    stroke: #e6e9ef;
    stroke-width: 0.5;
}

.chart-tick {
    fill: #6f7585;
    font-size: 11px;
}

.chart-axis-label {
    fill: #2c3242;
    font-size: 12px;
    font-weight: 500;
}

.chart-favorable {
    fill: #e6f5ee;
    opacity: 0.55;
}

.chart-pt {
    fill: #6f7585;
    stroke: #fff;
    stroke-width: 1.5;
}

.chart-pt-validated {
    fill: #1a3b6e;
    stroke: #fff;
    stroke-width: 1.5;
}

.chart-label {
    fill: #2c3242;
    font-size: 11px;
}

.chart-leader {
    stroke: #b4b9c4;
    stroke-width: 0.5;
}

.chart-legend {
    margin-top: 14px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 4px 12px;
    font-size: 12px;
    color: #4a5161;
}

.chart-legend-item {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.chart-legend-code {
    font-weight: 600;
    color: #1f2530;
    min-width: 36px;
    display: inline-block;
}

.chart-legend-code.validated { color: #1a3b6e; }

.chart-legend-name { color: #4a5161; }
