:root {
    color-scheme: dark;
    --bg: #071017;
    --bg2: #0b1822;
    --panel: rgba(15, 31, 42, .92);
    --panel2: rgba(11, 24, 33, .82);
    --line: rgba(125, 211, 252, .18);
    --text: #e8f4f8;
    --muted: #8ca8b4;
    --cyan: #52d9e8;
    --cyan2: #0ea5b7;
    --green: #5ee29b;
    --amber: #f6c75b;
    --red: #ff7380;
    --shadow: 0 18px 55px rgba(0, 0, 0, .34);
}
* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at 15% -10%, rgba(14,165,183,.20), transparent 35%),
        radial-gradient(circle at 100% 0, rgba(82,217,232,.10), transparent 28%),
        linear-gradient(160deg, #061017 0%, #07131c 48%, #050c12 100%);
}
a { color: var(--cyan); text-decoration: none; }
a:hover { color: #a8f6ff; }
code { color: #b7f5fb; background: rgba(82,217,232,.08); border: 1px solid rgba(82,217,232,.12); border-radius: 6px; padding: .08rem .33rem; }
.topbar {
    min-height: 68px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 12px clamp(16px, 4vw, 56px);
    border-bottom: 1px solid var(--line);
    background: rgba(5, 14, 20, .82);
    backdrop-filter: blur(14px);
    position: sticky;
    top: 0;
    z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand strong, .brand small { display: block; }
.brand strong { letter-spacing: .02em; }
.brand small { color: var(--muted); font-size: .78rem; margin-top: 2px; }
.brand-mark {
    display: inline-grid;
    place-items: center;
    min-width: 62px;
    height: 38px;
    padding: 0 10px;
    border: 1px solid rgba(82,217,232,.45);
    border-radius: 9px;
    color: #baf8ff;
    font-weight: 900;
    font-size: .78rem;
    letter-spacing: .13em;
    background: linear-gradient(135deg, rgba(82,217,232,.18), rgba(14,165,183,.04));
    box-shadow: inset 0 0 22px rgba(82,217,232,.08);
}
.topbar nav { display: flex; gap: 18px; font-size: .9rem; }
.shell { width: min(1460px, calc(100% - 28px)); margin: 26px auto 70px; }
.shell.narrow { max-width: 760px; }
.card {
    background: linear-gradient(155deg, rgba(17,35,47,.96), rgba(9,22,31,.92));
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: clamp(18px, 2vw, 28px);
}
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(310px, .75fr); gap: 18px; margin-bottom: 18px; }
.hero h1 { font-size: clamp(2rem, 4vw, 3.7rem); line-height: 1.03; margin: .35rem 0 .8rem; letter-spacing: -.045em; }
.hero p, .explanation li { color: #aac0ca; line-height: 1.62; }
.eyebrow { color: var(--cyan); text-transform: uppercase; letter-spacing: .14em; font-weight: 800; font-size: .72rem; }
.explanation h2 { margin-top: 0; }
.explanation ol { margin: 0; padding-left: 1.2rem; }
.explanation li + li { margin-top: .65rem; }
.metric-row { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; margin-top: 22px; }
.metric-row div, .summary-card {
    background: rgba(0,0,0,.18);
    border: 1px solid rgba(125,211,252,.12);
    border-radius: 12px;
    padding: 13px 14px;
}
.metric-row span, .summary-card span { display: block; color: var(--muted); font-size: .76rem; }
.metric-row strong, .summary-card strong { display: block; margin-top: 4px; font-size: 1.12rem; }
.notice { border-radius: 13px; padding: 15px 17px; border: 1px solid; margin: 16px 0; }
.notice.good { color: #bff8d7; border-color: rgba(94,226,155,.35); background: rgba(94,226,155,.08); }
.notice.bad { color: #ffd0d4; border-color: rgba(255,115,128,.35); background: rgba(255,115,128,.08); }
.notice.warn { color: #ffe7ad; border-color: rgba(246,199,91,.35); background: rgba(246,199,91,.08); }
.calculator-card { margin-top: 18px; }
.form-grid { display: grid; gap: 13px; }
.settings-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 18px; }
label { display: grid; gap: 7px; color: #c7dbe3; font-size: .86rem; font-weight: 700; }
input, select, textarea {
    width: 100%;
    color: var(--text);
    background: rgba(3,12,17,.72);
    border: 1px solid rgba(125,211,252,.21);
    border-radius: 10px;
    padding: 11px 12px;
    font: inherit;
    outline: none;
}
input:focus, select:focus, textarea:focus { border-color: rgba(82,217,232,.72); box-shadow: 0 0 0 3px rgba(82,217,232,.10); }
textarea { resize: vertical; min-height: 240px; line-height: 1.55; }
.paste-label { margin-top: 3px; }
.hint, .muted { color: var(--muted); font-size: .84rem; line-height: 1.5; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 17px; }
.btn, button.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 16px;
    border-radius: 10px;
    border: 1px solid rgba(125,211,252,.22);
    background: rgba(125,211,252,.07);
    color: #dff9fc;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}
.btn:hover { border-color: rgba(82,217,232,.58); background: rgba(82,217,232,.12); }
.btn.primary { background: linear-gradient(135deg, #0e9fb0, #087281); border-color: #36c9d8; color: white; box-shadow: 0 8px 22px rgba(14,165,183,.2); }
.btn.ghost { color: var(--muted); background: transparent; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.hidden { display: none !important; }
.loading { margin-top: 18px; display: flex; align-items: center; gap: 12px; color: #b8d1da; }
.spinner { width: 20px; height: 20px; border: 2px solid rgba(82,217,232,.2); border-top-color: var(--cyan); border-radius: 50%; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.result-stack { display: grid; gap: 18px; margin-top: 18px; }
.summary-grid { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 12px; }
.summary-card.good { border-color: rgba(94,226,155,.35); background: rgba(94,226,155,.07); }
.summary-card.warn { border-color: rgba(246,199,91,.35); background: rgba(246,199,91,.07); }
.summary-card .big { font-size: clamp(1.25rem, 2vw, 1.75rem); }
.delta.positive { color: var(--green); }
.delta.negative { color: var(--red); }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; margin-bottom: 14px; }
.section-head h2 { margin: 0; }
.section-head p { margin: 5px 0 0; color: var(--muted); }
.table-wrap { overflow-x: auto; border: 1px solid rgba(125,211,252,.11); border-radius: 12px; }
table { border-collapse: collapse; width: 100%; min-width: 980px; }
th, td { padding: 12px 13px; border-bottom: 1px solid rgba(125,211,252,.09); text-align: left; vertical-align: top; }
th { color: #8fb0bd; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; background: rgba(0,0,0,.18); position: sticky; top: 0; }
td { font-size: .86rem; color: #d6e6eb; }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.item-name { font-weight: 800; color: #effcff; }
.subtext { color: var(--muted); font-size: .75rem; margin-top: 3px; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 9px; font-size: .7rem; font-weight: 900; letter-spacing: .05em; border: 1px solid; white-space: nowrap; }
.badge.sell { color: #bcdfff; border-color: rgba(125,211,252,.36); background: rgba(125,211,252,.09); }
.badge.reprocess { color: #bff8d7; border-color: rgba(94,226,155,.36); background: rgba(94,226,155,.09); }
.badge.warn { color: #ffe5a3; border-color: rgba(246,199,91,.36); background: rgba(246,199,91,.09); }
.badge.bad { color: #ffd0d4; border-color: rgba(255,115,128,.36); background: rgba(255,115,128,.09); }
details.material-detail { margin-top: 8px; }
details.material-detail summary { cursor: pointer; color: var(--cyan); font-size: .78rem; }
.mini-table { margin-top: 8px; border: 1px solid rgba(125,211,252,.10); border-radius: 9px; overflow: hidden; }
.mini-row { display: grid; grid-template-columns: minmax(150px, 1fr) 90px 115px; gap: 8px; padding: 8px 10px; font-size: .74rem; background: rgba(0,0,0,.13); }
.mini-row + .mini-row { border-top: 1px solid rgba(125,211,252,.08); }
.mini-row span:nth-child(n+2) { text-align: right; font-variant-numeric: tabular-nums; }
.warning-list { margin: 10px 0 0; padding-left: 1.2rem; color: #ffdca0; }
.admin-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px; }
.progress { height: 12px; background: rgba(0,0,0,.25); border-radius: 999px; overflow: hidden; border: 1px solid rgba(125,211,252,.13); }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, #087281, #52d9e8); width: 0; transition: width .25s ease; }
.status-list { display: grid; gap: 10px; }
.status-line { display: grid; grid-template-columns: 125px 1fr auto; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid rgba(125,211,252,.08); }
.status-line:last-child { border-bottom: 0; }
footer { text-align: center; color: #66828e; font-size: .75rem; padding: 0 20px 28px; }
@media (max-width: 1050px) {
    .hero-grid { grid-template-columns: 1fr; }
    .settings-grid, .summary-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 700px) {
    .shell { width: min(100% - 18px, 1460px); margin-top: 14px; }
    .topbar { position: static; padding: 10px 12px; }
    .brand small { display: none; }
    .settings-grid, .summary-grid, .metric-row, .admin-grid { grid-template-columns: 1fr; }
    .card { border-radius: 13px; padding: 16px; }
    .hero h1 { font-size: 2.15rem; }
    .section-head { display: block; }
}
.download-status { display: grid; gap: 8px; margin-top: 18px; }
.ftp-card { margin-top: 18px; }

.top-actions { align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.eve-login-link { border: 1px solid rgba(82,217,232,.4); border-radius: 8px; padding: 8px 12px; background: rgba(82,217,232,.09); font-weight: 800; }
.character-pill { display: inline-flex; align-items: center; gap: 8px; border: 1px solid rgba(94,226,155,.28); background: rgba(94,226,155,.08); border-radius: 999px; padding: 7px 10px; color: #dff9e9; }
.character-pill span { font-weight: 800; }
.character-pill strong { color: var(--green); font-size: .72rem; }
.skill-login-notice { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.skill-login-notice > span { color: var(--muted); font-size: .78rem; white-space: nowrap; }
.skill-readonly { min-height: 44px; display: flex; flex-direction: column; justify-content: center; border: 1px solid rgba(94,226,155,.3); background: rgba(94,226,155,.07); border-radius: 10px; padding: 8px 12px; }
.skill-readonly strong { color: var(--green); font-size: 1rem; }
.skill-readonly span { color: var(--muted); font-size: .72rem; font-weight: 500; }
@media (max-width: 700px) {
    .top-actions { gap: 10px; font-size: .78rem; }
    .character-pill { width: 100%; justify-content: center; order: 5; }
    .skill-login-notice { align-items: flex-start; flex-direction: column; }
}

/* v1.5 per-item decision filters and copy controls */
.item-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin: 0 0 14px;
}
.item-filter-group,
.item-copy-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.item-filter {
    min-height: 38px;
    padding: 0 12px;
    border: 1px solid rgba(125,211,252,.18);
    border-radius: 999px;
    background: rgba(125,211,252,.05);
    color: #cfe6ed;
    font: inherit;
    font-size: .8rem;
    font-weight: 800;
    cursor: pointer;
}
.item-filter:hover {
    border-color: rgba(82,217,232,.5);
    background: rgba(82,217,232,.10);
}
.item-filter.active {
    color: white;
    border-color: rgba(82,217,232,.72);
    background: linear-gradient(135deg, rgba(14,159,176,.88), rgba(8,114,129,.88));
    box-shadow: 0 7px 18px rgba(14,165,183,.18);
}
.item-filter span {
    display: inline-grid;
    place-items: center;
    min-width: 24px;
    height: 20px;
    margin-left: 5px;
    padding: 0 6px;
    border-radius: 999px;
    background: rgba(0,0,0,.22);
    font-size: .7rem;
    font-variant-numeric: tabular-nums;
}
.item-filter-status {
    color: var(--muted);
    font-size: .78rem;
    white-space: nowrap;
}
.item-row-filtered {
    display: none;
}
.empty-filter-row {
    padding: 24px 16px;
    text-align: center;
    color: var(--muted);
}
@media (max-width: 700px) {
    .item-toolbar,
    .item-copy-group {
        align-items: stretch;
    }
    .item-copy-group {
        width: 100%;
    }
    .item-copy-group .btn {
        flex: 1 1 auto;
    }
    .item-filter-status {
        width: 100%;
    }
}

/* v1.7.1: keep all calculator setting controls top-aligned.
   Labels with helper text previously stretched their internal grid rows,
   causing the four boxes to begin at different vertical positions. */
.settings-grid {
    align-items: start;
}
.settings-grid > label {
    align-self: start;
    align-content: start;
}

/* v1.8 facility and standings selector */
.settings-grid-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.fixed-yield strong { color: var(--cyan); }
.facility-builder {
    margin: 4px 0 20px;
    padding: 18px;
    border: 1px solid rgba(125,211,252,.16);
    border-radius: 14px;
    background: rgba(3,12,17,.28);
}
.facility-heading {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    margin-bottom: 16px;
}
.facility-heading h2 { margin: 4px 0 0; font-size: 1.3rem; }
.facility-type-tabs { display: inline-flex; gap: 6px; padding: 4px; border: 1px solid rgba(125,211,252,.18); border-radius: 11px; background: rgba(0,0,0,.2); }
.facility-tab {
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    padding: 9px 13px;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}
.facility-tab.active { background: rgba(82,217,232,.14); color: #e8fdff; box-shadow: inset 0 0 0 1px rgba(82,217,232,.32); }
.facility-panel { position: relative; }
.facility-form-grid { display: grid; grid-template-columns: minmax(0,1.55fr) minmax(280px,.8fr); gap: 14px; align-items: start; }
.player-fields { margin-top: 14px; }
.station-search-field { position: relative; }
.station-search-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; align-items: stretch; }
.station-search-row input { min-width: 0; }
.station-find-button { white-space: nowrap; min-width: 112px; }
.station-results {
    position: absolute;
    z-index: 30;
    top: calc(100% - 20px);
    left: 0;
    right: 0;
    max-height: 330px;
    overflow: auto;
    padding: 6px;
    border: 1px solid rgba(82,217,232,.35);
    border-radius: 11px;
    background: #071820;
    box-shadow: 0 18px 40px rgba(0,0,0,.48);
}
.station-result {
    display: grid;
    width: 100%;
    gap: 3px;
    padding: 10px 11px;
    border: 0;
    border-radius: 8px;
    text-align: left;
    color: var(--text);
    background: transparent;
    cursor: pointer;
}
.station-result:hover, .station-result:focus { background: rgba(82,217,232,.11); outline: none; }
.station-result span, .station-empty { color: var(--muted); font-size: .78rem; }
.station-empty { padding: 12px; }
.facility-status-card { min-height: 68px; }
.facility-detail-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0,1fr));
    gap: 10px;
    margin-top: 13px;
}
.facility-detail-grid > div {
    padding: 11px 12px;
    border: 1px solid rgba(125,211,252,.12);
    border-radius: 10px;
    background: rgba(0,0,0,.17);
}
.facility-detail-grid span { display: block; color: var(--muted); font-size: .72rem; }
.facility-detail-grid strong { display: block; margin-top: 4px; font-size: .92rem; overflow-wrap: anywhere; }
.manual-override-row { display: flex; gap: 18px; align-items: end; margin-top: 13px; flex-wrap: wrap; }
.check-label { display: flex; grid-template-columns: auto 1fr; align-items: center; gap: 8px; min-height: 42px; }
.check-label input { width: auto; }
.compact-field { width: min(250px, 100%); }
.compact-actions { margin-top: 12px; }
.facility-warning { margin: 11px 0 0; color: #ffe7ad; font-size: .82rem; line-height: 1.5; }

@media (max-width: 900px) {
    .settings-grid-three { grid-template-columns: 1fr; }
    .facility-heading { align-items: stretch; flex-direction: column; }
    .facility-type-tabs { align-self: flex-start; }
    .facility-form-grid { grid-template-columns: 1fr; }
    .facility-detail-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 520px) {
    .facility-type-tabs { display: grid; width: 100%; grid-template-columns: 1fr 1fr; }
    .facility-detail-grid { grid-template-columns: 1fr; }
}
.summary-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
@media (max-width: 1050px) { .summary-grid { grid-template-columns: repeat(2,minmax(0,1fr)); } }
@media (max-width: 700px) { .summary-grid { grid-template-columns: 1fr; } }

@media (max-width: 620px) { .station-search-row { grid-template-columns: 1fr; } .station-find-button { width: 100%; } }
