* { box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    background: #f4f5f7;
    color: #1f2933;
    margin: 0;
    padding: 24px 16px 48px;
    max-width: 720px;
    margin-inline: auto;
    line-height: 1.45;
}
header { text-align: center; margin-bottom: 18px; }
h1 { font-size: 1.6em; margin: 0 0 4px; }
.sub { color: #66727f; margin: 0; font-size: 0.95em; }

/* segmented toggles */
.toggles { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.seg {
    display: flex;
    background: #e4e7eb;
    border-radius: 10px;
    padding: 3px;
}
.seg-btn {
    flex: 1;
    border: 0;
    background: transparent;
    padding: 9px 10px;
    border-radius: 8px;
    font-size: 0.92em;
    cursor: pointer;
    color: #52606d;
    transition: background 0.12s, color 0.12s;
}
.seg-btn.active { background: #fff; color: #1f2933; font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,0.12); }

/* metric-conditional fields */
.m-cont { display: none; }
.m-conv { display: flex; }
body.show-cont .m-cont { display: flex; }
body.show-cont .m-conv { display: none; }

/* inputs */
.panel { animation: fade 0.15s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.variants {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}
.variant {
    border: 1px solid #d9dee3;
    border-radius: 12px;
    padding: 14px 16px 16px;
    background: #fff;
    min-width: 0;
}
.variant legend {
    font-weight: 700;
    padding: 0 6px;
    color: #334e68;
    display: flex;
    align-items: center;
    gap: 8px;
}
.variant legend .rm {
    border: 0;
    background: #f0d2d2;
    color: #b0392b;
    width: 20px;
    height: 20px;
    line-height: 1;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.05em;
    padding: 0;
}
.variant legend .rm:hover { background: #e7b6b6; }
.add {
    margin-top: 12px;
    width: 100%;
    padding: 10px;
    font-size: 0.92em;
    color: #3a64f0;
    background: #eef2fe;
    border: 1px dashed #b9c6f6;
    border-radius: 10px;
    cursor: pointer;
}
.add:hover { background: #e4ebfd; }
.add:disabled { color: #9aa5b1; background: #f0f2f4; border-color: #d9dee3; cursor: not-allowed; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 0.86em; color: #52606d; margin-top: 10px; }
.variant label:first-of-type { margin-top: 0; }
input, select {
    font-size: 1em;
    padding: 9px 10px;
    border: 1px solid #cbd2d9;
    border-radius: 8px;
    background: #fff;
    width: 100%;
}
input:focus, select:focus { outline: 2px solid #6b8afd; border-color: #6b8afd; }

.plan-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 14px;
    background: #fff;
    border: 1px solid #d9dee3;
    border-radius: 12px;
    padding: 16px;
}
.plan-grid > label:first-child,
body.show-cont .plan-grid > label.m-cont:first-of-type { grid-column: span 2; }
.mde-row { display: flex; gap: 8px; }
.mde-row input { flex: 2; }
.mde-row select { flex: 1; }
.opt, .ci { color: #9aa5b1; font-weight: 400; }
.ci { font-size: 0.82em; display: block; margin-top: 2px; }

.go {
    margin-top: 16px;
    width: 100%;
    padding: 13px;
    font-size: 1.05em;
    font-weight: 600;
    color: #fff;
    background: #3a64f0;
    border: 0;
    border-radius: 10px;
    cursor: pointer;
}
.go:hover { background: #2c52d4; }

/* output cards */
.out { margin-top: 20px; display: flex; flex-direction: column; gap: 12px; }
.card {
    background: #fff;
    border: 1px solid #e1e5ea;
    border-radius: 12px;
    padding: 16px 18px;
}
.card h3 { margin: 0 0 10px; font-size: 0.95em; color: #334e68; display: flex; align-items: center; gap: 8px; }
.tag {
    font-size: 0.72em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #5a6b7b;
    background: #eef1f4;
    padding: 2px 7px;
    border-radius: 5px;
}
.card.good { border-color: #7bce9b; background: #f1fbf4; }
.card.warn { border-color: #f0cf7b; background: #fdf9ee; }
.card.bad  { border-color: #f0a0a0; background: #fdf0f0; }
.verdict { font-size: 1.3em; font-weight: 700; }
.card.good .verdict { color: #1f8a4c; }
.card.warn .verdict { color: #a9791a; }
.gist { color: #52606d; margin-top: 3px; }

.kv {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
    padding: 7px 0;
    border-bottom: 1px solid #f0f2f4;
}
.kv:last-child { border-bottom: 0; }
.kv > span { color: #66727f; font-size: 0.9em; }
.kv > b { text-align: right; }
.pos { color: #1f8a4c; }
.neg { color: #c0392b; }
.muted { color: #9aa5b1; font-weight: 400; font-size: 0.9em; }

/* result tables (multi-variant) */
.vtable {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
    margin-top: 4px;
}
.vtable th, .vtable td {
    text-align: right;
    padding: 7px 6px;
    border-bottom: 1px solid #f0f2f4;
}
.vtable th:first-child, .vtable td:first-child { text-align: left; }
.vtable th {
    font-size: 0.82em;
    color: #9aa5b1;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.vtable tbody tr:last-child td { border-bottom: 0; }
.vtable tr.champ { background: #f1fbf4; }
.vtable tr.champ td:first-child { font-weight: 700; color: #1f8a4c; }
.vtable .ci { display: block; }
.note { font-size: 0.84em; color: #7b8794; margin-top: 10px; }
.note.neg { color: #c0392b; }
.disclaimer { font-size: 0.8em; color: #9aa5b1; text-align: center; margin-top: 28px; }

/* explainer / SEO content */
.explainer {
    margin-top: 36px;
    padding-top: 22px;
    border-top: 1px solid #e1e5ea;
    color: #3e4c59;
    font-size: 0.95em;
}
.explainer h2 {
    font-size: 1.15em;
    color: #1f2933;
    margin: 26px 0 8px;
}
.explainer h2:first-child { margin-top: 0; }
.explainer p { margin: 0 0 12px; }
.explainer em { color: #52606d; }
.explain-list { margin: 0 0 12px; padding-left: 20px; }
.explain-list li { margin-bottom: 8px; }

.faq details {
    border: 1px solid #e1e5ea;
    border-radius: 10px;
    padding: 0 14px;
    margin-bottom: 8px;
    background: #fff;
}
.faq summary {
    cursor: pointer;
    font-weight: 600;
    color: #334e68;
    padding: 12px 0;
    list-style: none;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::before { content: "+ "; color: #9aa5b1; }
.faq details[open] summary::before { content: "\2212 "; }
.faq details[open] summary { border-bottom: 1px solid #f0f2f4; }
.faq details > p { margin: 12px 0; color: #52606d; }

@media (max-width: 520px) {
    .cols { flex-direction: column; }
    .plan-grid { grid-template-columns: 1fr; }
    .plan-grid > label:first-child { grid-column: span 1; }
}
