/* ─── The Settings page (js/settings_page.js) ───
   Full screen, over the page and the drawers and under the rates window, the dialogs and Help.
   Drawn like the landing page: the same cards, headings and buttons. */
.sp {
    position: fixed;
    inset: 0;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
}
body.sp-open { overflow: hidden; }

.sp-head {
    flex: none;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}
.sp-head h2 { font-family: 'Outfit', sans-serif; font-size: 1.5rem; font-weight: 800; }
.sp-head p { flex: 1; min-width: 0; color: var(--text-secondary); font-size: 0.9rem; }
.sp-close {
    flex: none;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 40px;
    padding: 0 0.9rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-primary);
    box-shadow: var(--neo-btn);
    color: var(--text-primary);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.sp-close:hover, .sp-close:focus-visible { border-color: var(--border-hover); outline: none; }

.sp-body {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
    gap: 1.5rem;
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 1.5rem;
    overflow: hidden;
}
.sp-sets, .sp-main { min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.sp-main { display: grid; align-content: start; gap: 1.4rem; padding: 0.4rem 0.4rem 2rem; }   /* room for the cards' shadows */
.sp-sets { display: flex; flex-direction: column; gap: 0.9rem; padding: 0.4rem; }

.sp-sets-head { display: flex; align-items: baseline; justify-content: space-between; }
.sp h3 { font-family: 'Outfit', sans-serif; font-size: 1.15rem; font-weight: 800; }
.sp-count, .sp-note, .sp-help { color: var(--text-muted); font-size: 0.82rem; line-height: 1.45; }
.sp-help { color: var(--text-secondary); font-size: 0.9rem; }

/* The sets */
.sp-set-list { list-style: none; display: grid; gap: 0.6rem; }
.sp-set { position: relative; }
.sp-set-pick {
    display: grid;
    gap: 0.2rem;
    width: 100%;
    padding: 0.8rem 2.6rem 0.8rem 0.95rem;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    background: var(--bg-primary);
    box-shadow: var(--neo-btn);
    color: var(--text-primary);
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.sp-set-pick:hover, .sp-set-pick:focus-visible { border-color: var(--border-hover); outline: none; }
.sp-set.in-use .sp-set-pick { border-color: var(--brand-orange); box-shadow: var(--neo-inset); cursor: default; }
.sp-set-name { font-weight: 700; overflow-wrap: anywhere; }
.sp-set-what { color: var(--text-secondary); font-size: 0.8rem; }
.sp-set-badge { justify-self: start; margin-top: 0.15rem; padding: 0.1rem 0.5rem; border-radius: 999px; background: rgba(var(--brand-orange-rgb), 0.16); color: var(--brand-orange); font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.sp-set-del, .sp-icon-btn {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
}
.sp-set-del { position: absolute; top: 0.45rem; right: 0.45rem; }
.sp-set-del:hover, .sp-set-del:focus-visible, .sp-icon-btn:hover, .sp-icon-btn:focus-visible { border-color: var(--border-hover); color: var(--text-primary); outline: none; }
.sp-set-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }

/* Buttons, as the landing cards' */
.sp-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 40px;
    padding: 0 0.9rem;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-primary);
    box-shadow: var(--neo-btn);
    color: var(--text-primary);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}
.sp-btn:hover, .sp-btn:focus-visible { border-color: var(--border-hover); outline: none; }
.sp-btn:active { box-shadow: var(--neo-pressed); }
.sp-btn:disabled { opacity: 0.45; cursor: default; box-shadow: none; }
.sp-btn.sp-primary { background: var(--brand-orange); border-color: transparent; color: #1a1a1a; }

/* The set in use */
.sp-card {
    display: grid;
    gap: 1rem;
    padding: 1.35rem 1.5rem;
    border: 1px solid var(--border-color);
    border-radius: 18px;
    background: var(--bg-primary);
    box-shadow: var(--neo-raised);
}
.sp-card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.sp-name-row { display: flex; align-items: end; gap: 0.8rem; flex-wrap: wrap; }
.sp-field { flex: 1; min-width: 200px; display: grid; gap: 0.35rem; }
.sp-field span { color: var(--text-secondary); font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.sp-input {
    width: 100%;
    min-height: 40px;
    padding: 0 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-deep);
    box-shadow: var(--neo-inset);
    color: var(--text-primary);
    font: inherit;
}
.sp-input:focus-visible { border-color: var(--border-hover); outline: none; }
.sp-input.invalid { border-color: #ef4444; }

.sp-charge-rows { display: grid; gap: 0.5rem; }
.sp-charge { display: grid; grid-template-columns: minmax(0, 1fr) 7.5rem 32px; gap: 0.6rem; align-items: center; }
.sp-pct { display: flex; align-items: center; gap: 0.35rem; color: var(--text-secondary); }
.sp-charge-pct { text-align: right; font-variant-numeric: tabular-nums; }

/* Cumulative or flat */
.sp-seg { display: inline-grid; grid-template-columns: 1fr 1fr; padding: 3px; border: 1px solid var(--border-color); border-radius: 12px; background: var(--bg-deep); box-shadow: var(--neo-inset); }
.sp-seg label { position: relative; }
.sp-seg input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.sp-seg span { display: block; padding: 0.45rem 1rem; border-radius: 9px; color: var(--text-secondary); font-size: 0.88rem; font-weight: 600; text-align: center; }
.sp-seg input:checked + span { background: var(--bg-primary); box-shadow: var(--neo-btn); color: var(--text-primary); }
.sp-seg input:focus-visible + span { outline: 2px solid var(--brand-cyan); outline-offset: 1px; }

/* Rates */
.sp-rates { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.8rem; }
.sp-rate { display: grid; gap: 0.15rem; padding: 0.85rem 1rem; border: 1px solid var(--border-color); border-radius: 14px; background: var(--bg-primary); box-shadow: var(--neo-btn); color: var(--text-primary); font: inherit; text-align: left; cursor: pointer; }
.sp-rate:hover, .sp-rate:focus-visible { border-color: var(--border-hover); outline: none; }
.sp-rate strong { font-weight: 700; }
.sp-rate span { color: var(--text-secondary); font-size: 0.82rem; }

/* Options: a switch and what it does */
.sp-options { display: grid; gap: 0.2rem; }
.sp-option { display: grid; grid-template-columns: auto 1fr; gap: 0.1rem 0.85rem; align-items: center; padding: 0.55rem 0; cursor: pointer; }
.sp-option + .sp-option { border-top: 1px solid var(--border-color); }
.sp-option input { grid-row: 1 / span 2; appearance: none; width: 38px; height: 22px; border-radius: 999px; background: var(--bg-deep); box-shadow: var(--neo-inset); border: 1px solid var(--border-color); position: relative; cursor: pointer; transition: background 0.15s; }
.sp-option input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--text-secondary); transition: transform 0.15s, background 0.15s; }
.sp-option input:checked { background: rgba(var(--brand-orange-rgb), 0.25); border-color: var(--brand-orange); }
.sp-option input:checked::after { transform: translateX(16px); background: var(--brand-orange); }
.sp-option input:focus-visible { outline: 2px solid var(--brand-cyan); outline-offset: 2px; }
.sp-option strong { font-weight: 600; font-size: 0.95rem; }
.sp-option small { grid-column: 2; color: var(--text-secondary); font-size: 0.82rem; line-height: 1.4; }

/* The drawer's line naming the set in use, and the way here */
.set-row { display: grid; gap: 0.5rem; margin-bottom: 0.4rem; }
.set-row-name { display: flex; align-items: baseline; gap: 0.5rem; color: var(--text-secondary); font-size: 0.82rem; }
.set-row-name strong { color: var(--text-primary); font-size: 0.95rem; overflow-wrap: anywhere; }

@media (prefers-reduced-motion: reduce) { .sp-option input, .sp-option input::after { transition: none; } }

@media (max-width: 860px) {
    /* One column: the sets first, then the set in use, the whole page scrolling as one */
    .sp-body { display: block; overflow-y: auto; padding: 1rem; }
    .sp-sets, .sp-main { overflow: visible; }
    .sp-sets { margin-bottom: 1.4rem; }
}
@media (max-width: 480px) {
    .sp-head { padding: 0.8rem 0.9rem; }
    .sp-head p { display: none; }
    .sp-head h2 { flex: 1; }
    .sp-body { padding: 0.8rem 0.6rem; }
    .sp-card { padding: 1.05rem 1rem; }
    .sp-rates { grid-template-columns: 1fr; }
    .sp-charge { grid-template-columns: minmax(0, 1fr) 5.6rem 32px; gap: 0.4rem; }
}
