:root {
    --ink: #04111f;
    --ink-2: #071a2b;
    --ink-3: #0a2034;
    --sky: #8fd8ff;
    --sky-2: #4fb7f2;
    --mist: #d9f3ff;
    --muted: #91afc3;
    --cherry: #ff4f86;
    --cherry-2: #b51f53;
    --gold: #ffd98a;
    --green: #73f0bd;
    --red: #ff7c8e;
    --line: rgba(143, 216, 255, 0.18);
    --panel: rgba(8, 27, 45, 0.82);
    --panel-2: rgba(10, 36, 60, 0.72);
    --shadow: 0 20px 70px rgba(0, 0, 0, 0.38);
    --radius: 22px;
    --radius-sm: 14px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    min-height: 100vh;
    color: var(--mist);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at 18% -10%, rgba(79, 183, 242, 0.34), transparent 32rem),
        radial-gradient(circle at 95% 8%, rgba(255, 79, 134, 0.18), transparent 30rem),
        linear-gradient(135deg, #020712 0%, #061423 46%, #091c2e 100%);
    overflow-x: hidden;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(143, 216, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(143, 216, 255, 0.03) 1px, transparent 1px);
    background-size: 36px 36px;
    mask-image: linear-gradient(to bottom, black, transparent 80%);
}

button, input, select, textarea { font: inherit; }

a { color: inherit; text-decoration: none; }

code {
    color: var(--gold);
    background: rgba(255, 217, 138, 0.09);
    padding: 0.1rem 0.35rem;
    border-radius: 0.5rem;
}

.app-shell {
    display: grid;
    grid-template-columns: 290px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 1.25rem;
    background: linear-gradient(180deg, rgba(4, 17, 31, 0.98), rgba(7, 26, 43, 0.94));
    border-right: 1px solid var(--line);
    box-shadow: 15px 0 55px rgba(0, 0, 0, 0.24);
    z-index: 20;
    display: flex;
    flex-direction: column;
}

.brand {
    display: flex;
    gap: 0.85rem;
    align-items: center;
    padding: 0.85rem;
    border: 1px solid rgba(143, 216, 255, 0.18);
    border-radius: var(--radius-sm);
    background: rgba(143, 216, 255, 0.055);
    margin-bottom: 1.15rem;
}

.brand-orb {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: var(--ink);
    background: radial-gradient(circle at 35% 25%, #f1fbff, var(--sky) 45%, var(--cherry));
    box-shadow: 0 0 28px rgba(143, 216, 255, 0.42), inset 0 0 16px rgba(255, 255, 255, 0.42);
}

.brand strong {
    display: block;
    font-family: Georgia, "Times New Roman", serif;
    letter-spacing: 0.04em;
    font-size: 1.15rem;
}

.brand small { color: var(--muted); display: block; margin-top: 0.1rem; }

.nav-scroll {
    display: grid;
    gap: 0.4rem;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.nav-link, .nav-group summary {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    border-radius: 14px;
    padding: 0.78rem 0.85rem;
    color: #c9eaf8;
    border: 1px solid transparent;
    background: transparent;
    cursor: pointer;
    transition: transform 160ms ease, background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.nav-link:hover, .nav-group summary:hover {
    transform: translateX(3px);
    color: white;
    background: rgba(143, 216, 255, 0.08);
    border-color: rgba(143, 216, 255, 0.16);
}

.nav-link.active {
    background: linear-gradient(135deg, rgba(79, 183, 242, 0.22), rgba(255, 79, 134, 0.12));
    border-color: rgba(143, 216, 255, 0.33);
    box-shadow: inset 0 0 20px rgba(143, 216, 255, 0.08);
}

.nav-link.slim { padding-left: 2.2rem; font-size: 0.94rem; }
.nav-link.disabled { opacity: 0.55; cursor: not-allowed; }
.nav-link.disabled em { margin-left: auto; color: var(--cherry); font-size: 0.74rem; font-style: normal; }

.nav-group {
    border-radius: 14px;
}

.nav-group summary {
    list-style: none;
    user-select: none;
}

.nav-group summary::-webkit-details-marker { display: none; }
.nav-group summary::after {
    content: "⌄";
    margin-left: auto;
    color: var(--sky);
    transition: transform 180ms ease;
}
.nav-group[open] summary::after { transform: rotate(180deg); }

.nav-submenu {
    display: grid;
    gap: 0.25rem;
    overflow: hidden;
    animation: dropdown 220ms ease both;
}

@keyframes dropdown {
    from { opacity: 0; transform: translateY(-5px); max-height: 0; }
    to { opacity: 1; transform: translateY(0); max-height: 500px; }
}

.sidebar-footer {
    margin-top: auto;
    color: var(--muted);
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.85rem;
    border: 1px solid rgba(143, 216, 255, 0.14);
    border-radius: 14px;
    background: rgba(143, 216, 255, 0.05);
}

.pulse-dot {
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 0 0 rgba(115, 240, 189, 0.55);
    animation: pulse 1.8s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(115, 240, 189, 0.5); }
    70% { box-shadow: 0 0 0 10px rgba(115, 240, 189, 0); }
    100% { box-shadow: 0 0 0 0 rgba(115, 240, 189, 0); }
}

.main-panel {
    min-width: 0;
    padding: 1.25rem;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.1rem;
    margin-bottom: 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(8, 27, 45, 0.74);
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow);
}

.eyebrow {
    margin: 0 0 0.25rem;
    color: var(--sky);
    font-size: 0.76rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    font-weight: 800;
}

h1, h2, h3 {
    margin: 0;
    line-height: 1.08;
    font-family: Georgia, "Times New Roman", serif;
    letter-spacing: 0.012em;
}

h1 { font-size: clamp(1.65rem, 2vw, 2.45rem); }
h2 { font-size: clamp(1.45rem, 1.8vw, 2.15rem); }
h3 { font-size: 1.2rem; }

.topbar-actions, .hero-actions, .form-actions, .badge-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.pill-button, .icon-button, .tab-pill {
    border: 1px solid rgba(143, 216, 255, 0.32);
    color: #02111f;
    background: linear-gradient(135deg, #d9f3ff 0%, #8fd8ff 52%, #ff8cb1 145%);
    padding: 0.76rem 1rem;
    border-radius: 999px;
    font-weight: 850;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
    box-shadow: 0 10px 30px rgba(79, 183, 242, 0.16);
}

.pill-button:hover, .icon-button:hover, .tab-pill:hover {
    transform: translateY(-1px);
    box-shadow: 0 16px 34px rgba(255, 79, 134, 0.17), 0 0 0 3px rgba(143, 216, 255, 0.08);
}

.pill-button.ghost, .tab-pill {
    color: var(--mist);
    background: rgba(143, 216, 255, 0.08);
}

.content-panel {
    display: grid;
    gap: 1rem;
}

.hero-card, .panel-card, .metric-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
}

.hero-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 270px;
    align-items: stretch;
    gap: 1rem;
    padding: clamp(1rem, 2vw, 1.5rem);
    position: relative;
    overflow: hidden;
}

.hero-card::after, .spell-card::after {
    content: "";
    position: absolute;
    width: 18rem;
    height: 18rem;
    border-radius: 999px;
    background: radial-gradient(circle, rgba(143, 216, 255, 0.18), transparent 70%);
    right: -8rem;
    top: -9rem;
    pointer-events: none;
}

.hero-card > *, .spell-card > * { position: relative; z-index: 1; }

.muted { color: var(--muted); }
.wide { max-width: 70ch; }

.sigil-card {
    padding: 1.1rem;
    border: 1px solid rgba(255, 79, 134, 0.22);
    border-radius: 18px;
    background: linear-gradient(160deg, rgba(255, 79, 134, 0.16), rgba(79, 183, 242, 0.07));
    display: grid;
    align-content: center;
    text-align: center;
    gap: 0.5rem;
}

.sigil-card span { font-size: 3rem; color: var(--sky); text-shadow: 0 0 20px rgba(143, 216, 255, 0.45); }
.sigil-card strong { font-family: Georgia, serif; font-size: 1.3rem; }
.sigil-card small { color: var(--muted); line-height: 1.45; }

.grid { display: grid; gap: 1rem; }
.cards-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cards-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.two-col { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }

.metric-card {
    padding: 1rem;
    background: linear-gradient(160deg, rgba(10, 36, 60, 0.88), rgba(8, 27, 45, 0.78));
}
.metric-card.cherry { border-color: rgba(255, 79, 134, 0.28); }
.metric-card strong { display: block; font-size: clamp(1.45rem, 2.3vw, 2.2rem); margin: 0.2rem 0; }
.metric-label { color: var(--sky); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.14em; font-weight: 800; }
.metric-card small { color: var(--muted); }

.panel-card {
    padding: 1rem;
    position: relative;
    overflow: hidden;
}
.section-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}
.section-heading p { margin-bottom: 0; }

.rune-list, .timeline-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 0.8rem; }
.rune-list li {
    padding: 0.8rem;
    border: 1px solid rgba(143, 216, 255, 0.13);
    border-radius: 14px;
    background: rgba(143, 216, 255, 0.04);
    color: #ccecf8;
}
.timeline-list div {
    display: grid;
    grid-template-columns: 2.2rem minmax(0, 1fr);
    gap: 0.8rem;
    align-items: start;
}
.timeline-list span {
    display: grid;
    place-items: center;
    width: 2.1rem;
    height: 2.1rem;
    border-radius: 999px;
    color: var(--ink);
    font-weight: 900;
    background: linear-gradient(135deg, var(--sky), var(--cherry));
}
.timeline-list p { margin: 0; color: #ccecf8; line-height: 1.5; }
.timeline-list.large { gap: 1.1rem; }

.spell-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.9rem;
}
.spell-grid.compact { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.full-width { grid-column: 1 / -1; }

label {
    display: grid;
    gap: 0.4rem;
    color: #bfe6f8;
    font-size: 0.88rem;
    font-weight: 750;
}

input, select, textarea {
    width: 100%;
    color: var(--mist);
    background: rgba(3, 14, 26, 0.72);
    border: 1px solid rgba(143, 216, 255, 0.24);
    border-radius: 13px;
    padding: 0.72rem 0.78rem;
    outline: none;
    transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

input:focus, select:focus, textarea:focus {
    border-color: rgba(255, 79, 134, 0.7);
    box-shadow: 0 0 0 4px rgba(255, 79, 134, 0.08);
    background: rgba(3, 14, 26, 0.92);
}

select option { background: #071a2b; color: var(--mist); }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: #ccecf8;
    border: 1px solid rgba(143, 216, 255, 0.18);
    background: rgba(143, 216, 255, 0.06);
    border-radius: 999px;
    padding: 0.45rem 0.65rem;
    font-size: 0.82rem;
}

.table-wrap {
    overflow: auto;
    border: 1px solid rgba(143, 216, 255, 0.12);
    border-radius: 16px;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 860px;
}
.data-table th, .data-table td {
    text-align: left;
    padding: 0.78rem 0.85rem;
    border-bottom: 1px solid rgba(143, 216, 255, 0.09);
    white-space: nowrap;
}
.data-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    color: var(--sky);
    background: rgba(6, 21, 36, 0.98);
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}
.data-table tbody tr:hover { background: rgba(143, 216, 255, 0.04); }
.empty-cell { text-align: center !important; color: var(--muted); padding: 2rem !important; }

.chart-shell {
    min-height: 280px;
    border: 1px solid rgba(143, 216, 255, 0.14);
    border-radius: 18px;
    background: rgba(2, 10, 18, 0.55);
    padding: 1rem;
    margin-top: 1rem;
}

.tabs { display: flex; flex-wrap: wrap; gap: 0.65rem; }
.material-editor {
    border: 1px solid rgba(143, 216, 255, 0.14);
    border-radius: 18px;
    padding: 1rem;
    background: rgba(2, 10, 18, 0.32);
}
.material-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}
.material-line {
    display: grid;
    grid-template-columns: minmax(160px, 1fr) 130px 150px 42px;
    gap: 0.6rem;
    align-items: end;
    margin-bottom: 0.6rem;
}
.remove-line {
    width: 42px;
    height: 42px;
    padding: 0;
    display: grid;
    place-items: center;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}
.result-card {
    border: 1px solid rgba(143, 216, 255, 0.13);
    border-radius: 16px;
    padding: 0.85rem;
    background: rgba(143, 216, 255, 0.045);
}
.result-card strong { display: block; font-size: 1.15rem; margin-top: 0.2rem; }
.result-card.good strong { color: var(--green); }
.result-card.bad strong { color: var(--red); }
.result-notes { grid-column: 1 / -1; color: var(--muted); }

.stat-list { margin: 0; display: grid; gap: 0.65rem; }
.stat-list div {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem;
    border: 1px solid rgba(143, 216, 255, 0.11);
    border-radius: 13px;
    background: rgba(143, 216, 255, 0.035);
}
.stat-list dt { color: var(--muted); }
.stat-list dd { margin: 0; color: var(--mist); font-weight: 850; text-align: right; }

.toast-root {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    display: grid;
    gap: 0.6rem;
    z-index: 99;
}
.toast {
    border: 1px solid rgba(143, 216, 255, 0.28);
    border-radius: 14px;
    padding: 0.8rem 0.9rem;
    background: rgba(7, 26, 43, 0.94);
    color: var(--mist);
    box-shadow: var(--shadow);
    max-width: 360px;
}
.toast.error { border-color: rgba(255, 79, 134, 0.46); }

.mobile-only { display: none; }

@media (max-width: 1180px) {
    .cards-4, .cards-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .spell-grid, .spell-grid.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .hero-card { grid-template-columns: 1fr; }
    .result-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed;
        transform: translateX(-105%);
        transition: transform 180ms ease;
        width: min(88vw, 320px);
    }
    .sidebar.open { transform: translateX(0); }
    .mobile-only { display: inline-grid; }
    .topbar { align-items: flex-start; }
    .topbar-actions { display: none; }
    .two-col, .cards-4, .cards-5, .spell-grid, .spell-grid.compact, .result-grid { grid-template-columns: 1fr; }
    .material-line { grid-template-columns: 1fr; }
    .remove-line { width: 100%; }
    .main-panel { padding: 0.75rem; }
}

/* Polished dropdowns and autocomplete */
.nav-group .nav-submenu {
    max-height: 0;
    opacity: 0;
    transform: translateY(-4px);
    transition: max-height 220ms ease, opacity 180ms ease, transform 180ms ease;
}
.nav-group[open] .nav-submenu {
    max-height: 520px;
    opacity: 1;
    transform: translateY(0);
}
.nav-link.disabled:hover {
    transform: none;
    background: transparent;
    border-color: transparent;
}
.field-hint {
    color: var(--muted);
    font-weight: 600;
    font-size: 0.74rem;
    line-height: 1.35;
}
label { position: relative; }
.suggestion-menu {
    position: absolute;
    z-index: 60;
    left: 0;
    right: 0;
    top: calc(100% - 0.05rem);
    display: grid;
    gap: 0.35rem;
    max-height: 0;
    overflow: auto;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-4px);
    padding: 0;
    border: 1px solid rgba(143, 216, 255, 0.22);
    border-radius: 14px;
    background: rgba(4, 17, 31, 0.98);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.42);
    transition: max-height 180ms ease, opacity 160ms ease, transform 160ms ease, padding 160ms ease;
}
.suggestion-menu.open {
    max-height: 340px;
    opacity: 1;
    pointer-events: auto;
    transform: translateY(4px);
    padding: 0.4rem;
}
.suggestion-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 0.58rem 0.65rem;
    color: var(--mist);
    background: rgba(143, 216, 255, 0.045);
    cursor: pointer;
    text-align: left;
    transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}
.suggestion-item:hover {
    transform: translateX(2px);
    background: rgba(143, 216, 255, 0.09);
    border-color: rgba(255, 79, 134, 0.28);
}
.suggestion-item span { display: grid; gap: 0.14rem; min-width: 0; }
.suggestion-item strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggestion-item small { color: var(--muted); font-size: 0.75rem; }
.suggestion-empty { color: var(--muted); padding: 0.75rem; }
.item-cell { display: grid; gap: 0.25rem; }
.item-cell strong { color: var(--mist); }
.data-table td.good { color: var(--green); font-weight: 850; }
.data-table td.bad { color: var(--red); font-weight: 850; }
.feature-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 0.8rem; }
.feature-list li {
    padding: 0.8rem;
    border: 1px solid rgba(143, 216, 255, 0.13);
    border-radius: 14px;
    background: rgba(143, 216, 255, 0.04);
    color: #ccecf8;
}

/* Phase 1 visual polish: clearer brand mark, smoother data cards, and better wide-screen readability. */
.brand-logo {
    width: 2.95rem;
    height: 2.95rem;
    flex: 0 0 auto;
    display: block;
    filter: drop-shadow(0 0 18px rgba(143, 216, 255, 0.42));
}
.brand:hover .brand-logo {
    filter: drop-shadow(0 0 22px rgba(143, 216, 255, 0.52)) drop-shadow(0 0 14px rgba(255, 79, 134, 0.18));
}
.sigil-logo {
    width: 5.2rem;
    height: 5.2rem;
    margin: 0 auto 0.2rem;
    display: block;
    filter: drop-shadow(0 0 24px rgba(143, 216, 255, 0.45));
}
.hero-card, .panel-card, .metric-card, .topbar, .brand {
    background-image:
        linear-gradient(135deg, rgba(255, 255, 255, 0.032), transparent 32%),
        linear-gradient(180deg, rgba(143, 216, 255, 0.045), transparent 62%);
}
.panel-card::before, .metric-card::before, .topbar::before, .brand::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: inherit;
    background: linear-gradient(135deg, rgba(143, 216, 255, 0.07), transparent 24%, rgba(255, 79, 134, 0.045) 100%);
    opacity: 0.72;
}
.metric-card, .topbar, .brand { position: relative; overflow: hidden; }
.metric-card > *, .topbar > *, .brand > *, .panel-card > * { position: relative; z-index: 1; }
.metric-card {
    min-height: 7.3rem;
    transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}
.metric-card:hover {
    transform: translateY(-2px);
    border-color: rgba(143, 216, 255, 0.32);
}
.compact-cards .metric-card {
    min-height: 5.9rem;
    padding: 0.85rem;
}
.compact-cards .metric-card strong {
    font-size: clamp(1.15rem, 1.6vw, 1.65rem);
}
.pill-button, .icon-button, .tab-pill {
    position: relative;
    overflow: hidden;
    letter-spacing: 0.012em;
}
.pill-button::after, .icon-button::after, .tab-pill::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-120%);
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.28), transparent);
    transition: transform 420ms ease;
    pointer-events: none;
}
.pill-button:hover::after, .icon-button:hover::after, .tab-pill:hover::after { transform: translateX(120%); }
.pill-button:active, .icon-button:active, .tab-pill:active { transform: translateY(0) scale(0.985); }
.pill-button[aria-busy="true"] { opacity: 0.78; pointer-events: none; }
.spell-card {
    background:
        radial-gradient(circle at 100% 0%, rgba(79, 183, 242, 0.14), transparent 28rem),
        linear-gradient(160deg, rgba(10, 36, 60, 0.89), rgba(8, 27, 45, 0.8));
}
input, select, textarea {
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
}
input:hover, select:hover, textarea:hover {
    border-color: rgba(143, 216, 255, 0.36);
}
.data-table th { letter-spacing: 0.105em; }
.data-table td { color: #cfeafa; }
.table-wrap::-webkit-scrollbar, .nav-scroll::-webkit-scrollbar, .suggestion-menu::-webkit-scrollbar { height: 9px; width: 9px; }
.table-wrap::-webkit-scrollbar-thumb, .nav-scroll::-webkit-scrollbar-thumb, .suggestion-menu::-webkit-scrollbar-thumb {
    background: rgba(143, 216, 255, 0.22);
    border-radius: 999px;
}
.table-wrap::-webkit-scrollbar-track, .nav-scroll::-webkit-scrollbar-track, .suggestion-menu::-webkit-scrollbar-track { background: rgba(2, 10, 18, 0.28); }
.nav-submenu .nav-link.active {
    background: linear-gradient(135deg, rgba(79, 183, 242, 0.26), rgba(255, 79, 134, 0.12));
    border-color: rgba(143, 216, 255, 0.34);
}
.nav-group[open] summary {
    color: #eefaff;
}
.result-grid .result-card {
    transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}
.result-grid .result-card:hover {
    transform: translateY(-1px);
    border-color: rgba(143, 216, 255, 0.3);
    background: rgba(143, 216, 255, 0.07);
}
.history-summary { margin-top: 1rem; }
@media (min-width: 1800px) {
    .main-panel { max-width: 2200px; margin-inline: auto; width: 100%; }
    .spell-grid { grid-template-columns: repeat(3, minmax(220px, 1fr)); }
    .spell-grid.compact { grid-template-columns: repeat(6, minmax(160px, 1fr)); }
}
@media (max-width: 540px) {
    .brand strong { font-size: 1rem; }
    .hero-actions .pill-button, .form-actions .pill-button { width: 100%; justify-content: center; text-align: center; }
    .section-heading { flex-direction: column; }
}

/* Phase 1.4: recipe presets + market autofill */
.section-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.6rem;
}

.market-settings-card {
    border-color: rgba(255, 79, 134, 0.18);
    background:
        radial-gradient(circle at 88% 16%, rgba(255, 79, 134, 0.12), transparent 26rem),
        linear-gradient(150deg, rgba(9, 32, 54, 0.94), rgba(7, 24, 40, 0.86));
}

.market-settings-grid {
    align-items: end;
}

.market-helper {
    margin: 0.85rem 0 0;
    max-width: 98ch;
}

.market-fill-summary {
    margin-top: 1rem;
}

.market-fill-summary:empty {
    display: none;
}

.fill-summary-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.55rem;
}

.fill-summary-table {
    display: grid;
    gap: 0.45rem;
}

.fill-summary-row {
    display: grid;
    grid-template-columns: 100px minmax(200px, 1fr) 150px 165px 120px;
    gap: 0.7rem;
    align-items: center;
    border: 1px solid rgba(143, 216, 255, 0.12);
    border-radius: 14px;
    padding: 0.62rem 0.75rem;
    background: rgba(143, 216, 255, 0.045);
}

.fill-summary-row strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fill-summary-row span {
    color: var(--muted);
}

.fill-summary-row code {
    color: var(--mist);
    justify-self: end;
}

.fill-summary-row.missing {
    border-color: rgba(255, 111, 134, 0.22);
    background: rgba(255, 111, 134, 0.06);
}

.fill-summary-row.missing code {
    color: var(--red);
}

[data-recipe-select] {
    min-height: 3rem;
}

@media (max-width: 1050px) {
    .fill-summary-row {
        grid-template-columns: 90px minmax(180px, 1fr) 130px 110px;
    }
    .fill-summary-row span:nth-child(4) { display: none; }
}

@media (max-width: 720px) {
    .section-actions { justify-content: stretch; }
    .section-actions .pill-button { flex: 1 1 100%; justify-content: center; }
    .fill-summary-row {
        grid-template-columns: 1fr;
        gap: 0.25rem;
    }
    .fill-summary-row code { justify-self: start; }
}

/* Phase 1.5: volume metrics */
.volume-cell {
    font-variant-numeric: tabular-nums;
    color: #e6f7ff;
    font-weight: 800;
}
.muted-cell {
    color: var(--muted);
    font-weight: 650;
}
.activity-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 6.4rem;
    border-radius: 999px;
    padding: 0.28rem 0.52rem;
    border: 1px solid rgba(143, 216, 255, 0.18);
    background: rgba(143, 216, 255, 0.055);
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 850;
}
.activity-pill.high { color: var(--green); border-color: rgba(115, 240, 189, 0.28); background: rgba(115, 240, 189, 0.07); }
.activity-pill.medium { color: var(--gold); border-color: rgba(255, 217, 138, 0.26); background: rgba(255, 217, 138, 0.065); }
.activity-pill.low { color: var(--sky); }
.activity-pill.no-recent-volume { color: var(--muted); opacity: 0.78; }
@media (min-width: 1600px) {
    .cards-5.compact-cards .metric-card strong { font-size: clamp(1.05rem, 1.3vw, 1.45rem); }
}

/* Phase 1.6: city comparison + opportunity scoring */
.opportunity-panel {
    background:
        radial-gradient(circle at 88% 0%, rgba(255, 79, 134, 0.12), transparent 24rem),
        radial-gradient(circle at 12% 12%, rgba(143, 216, 255, 0.10), transparent 28rem),
        linear-gradient(160deg, rgba(9, 31, 52, 0.92), rgba(7, 24, 40, 0.86));
}

.city-cards {
    margin: 0.85rem 0 1rem;
}

.opportunity-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
    gap: 0.85rem;
}

.opportunity-card {
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(143, 216, 255, 0.16);
    border-radius: 20px;
    padding: 0.95rem;
    background:
        linear-gradient(135deg, rgba(143, 216, 255, 0.075), rgba(255, 79, 134, 0.035)),
        rgba(7, 24, 40, 0.78);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
    transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.opportunity-card::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(90deg, rgba(143, 216, 255, 0.08), transparent 30%, rgba(255, 79, 134, 0.045));
    opacity: 0.8;
}

.opportunity-card > * {
    position: relative;
    z-index: 1;
}

.opportunity-card:hover {
    transform: translateY(-2px);
    border-color: rgba(143, 216, 255, 0.36);
}

.opportunity-card.score-high {
    border-color: rgba(115, 240, 189, 0.26);
}

.opportunity-card.score-medium {
    border-color: rgba(255, 217, 138, 0.24);
}

.opportunity-card.score-low {
    border-color: rgba(143, 216, 255, 0.16);
}

.opportunity-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.8rem;
}

.opportunity-head strong {
    display: block;
    color: var(--mist);
    font-size: 1rem;
    line-height: 1.25;
}

.opportunity-head small {
    display: block;
    margin-top: 0.2rem;
    color: var(--muted);
    font-weight: 750;
}

.score-pill {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    min-width: 5.5rem;
    padding: 0.34rem 0.55rem;
    font-size: 0.78rem;
    font-weight: 950;
    border: 1px solid rgba(143, 216, 255, 0.22);
    background: rgba(143, 216, 255, 0.08);
    color: var(--mist);
}

.score-pill.score-high {
    border-color: rgba(115, 240, 189, 0.34);
    color: var(--green);
    background: rgba(115, 240, 189, 0.08);
}

.score-pill.score-medium {
    border-color: rgba(255, 217, 138, 0.32);
    color: var(--gold);
    background: rgba(255, 217, 138, 0.075);
}

.score-pill.score-low {
    border-color: rgba(143, 216, 255, 0.22);
    color: var(--sky);
}

.opportunity-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.48rem;
}

.opportunity-metrics span {
    display: block;
    min-width: 0;
    border: 1px solid rgba(143, 216, 255, 0.105);
    border-radius: 13px;
    padding: 0.48rem 0.58rem;
    background: rgba(3, 12, 21, 0.25);
}

.opportunity-metrics small {
    display: block;
    margin-bottom: 0.16rem;
    color: var(--muted);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 900;
}

.opportunity-metrics strong {
    display: block;
    color: var(--mist);
    font-variant-numeric: tabular-nums;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tag-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.75rem;
}

.mini-tag {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    border: 1px solid rgba(143, 216, 255, 0.14);
    background: rgba(143, 216, 255, 0.055);
    color: #a9c9dc;
    padding: 0.22rem 0.48rem;
    font-size: 0.68rem;
    font-weight: 850;
    text-transform: uppercase;
    letter-spacing: 0.045em;
}

@media (max-width: 720px) {
    .opportunity-list { grid-template-columns: 1fr; }
    .opportunity-head { flex-direction: column; }
    .opportunity-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Phase 1.7: Gold market arbitrage */
.gold-hero {
    background:
        radial-gradient(circle at 88% 10%, rgba(255, 217, 138, 0.16), transparent 23rem),
        radial-gradient(circle at 18% 5%, rgba(143, 216, 255, 0.16), transparent 28rem),
        linear-gradient(160deg, rgba(8, 27, 45, 0.92), rgba(7, 24, 40, 0.86));
}
.gold-sigil span {
    color: var(--gold);
    text-shadow: 0 0 20px rgba(255, 217, 138, 0.36), 0 0 36px rgba(255, 79, 134, 0.18);
}
.gold-chart-shell {
    min-height: 330px;
}
.gold-tables .data-table {
    min-width: 780px;
}
#gold-summary-cards .metric-card strong,
#gold-profit-cards .metric-card strong {
    font-variant-numeric: tabular-nums;
}
#gold-velocity-note {
    margin: 0.85rem 0 0;
    padding: 0.82rem 0.95rem;
    border: 1px solid rgba(143, 216, 255, 0.12);
    border-radius: 15px;
    background: rgba(2, 10, 18, 0.28);
}
@media (max-width: 900px) {
    .gold-tables { grid-template-columns: 1fr; }
}

/* Phase 1.10: scanner, opportunity dashboard, and chain optimizer */
.chain-materials {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-top: 0.75rem;
}
.chain-materials span {
    border: 1px solid rgba(143, 216, 255, 0.12);
    border-radius: 999px;
    background: rgba(2, 10, 18, 0.28);
    color: var(--muted);
    padding: 0.26rem 0.55rem;
    font-size: 0.72rem;
    font-weight: 800;
}
.chain-card .opportunity-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}
#scanner-table .item-cell code {
    display: block;
    margin-top: 0.15rem;
}
@media (max-width: 720px) {
    .chain-card .opportunity-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Phase 1.11: cleaner navigation state and custom multi-choice dropdowns */
html.aotc-loading .nav-link,
html.aotc-loading .nav-group summary,
html.aotc-loading .nav-submenu {
    transition: none !important;
    animation: none !important;
}

.multi-choice-source {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
    pointer-events: none !important;
    overflow: hidden !important;
}

.multi-choice {
    position: relative;
    width: 100%;
}

.multi-choice-button {
    width: 100%;
    min-height: 2.8rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    color: var(--mist);
    background: rgba(3, 14, 26, 0.72);
    border: 1px solid rgba(143, 216, 255, 0.24);
    border-radius: 13px;
    padding: 0.72rem 0.78rem;
    cursor: pointer;
    text-align: left;
    transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease, transform 140ms ease;
}

.multi-choice-button:hover,
.multi-choice.open .multi-choice-button {
    border-color: rgba(255, 79, 134, 0.56);
    background: rgba(3, 14, 26, 0.92);
    box-shadow: 0 0 0 4px rgba(255, 79, 134, 0.07);
}

.multi-choice-button span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.multi-choice-button strong {
    color: var(--sky);
    transition: transform 160ms ease;
}

.multi-choice.open .multi-choice-button strong {
    transform: rotate(180deg);
}

.multi-choice-menu {
    position: absolute;
    z-index: 70;
    top: calc(100% + 0.35rem);
    left: 0;
    right: 0;
    display: grid;
    gap: 0.35rem;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-4px);
    padding: 0;
    border: 1px solid rgba(143, 216, 255, 0.24);
    border-radius: 16px;
    background: rgba(4, 17, 31, 0.98);
    box-shadow: 0 22px 65px rgba(0, 0, 0, 0.45);
    transition: max-height 180ms ease, opacity 160ms ease, transform 160ms ease, padding 160ms ease;
}

.multi-choice.open .multi-choice-menu {
    max-height: 390px;
    overflow: auto;
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
    padding: 0.45rem;
}

.multi-choice-actions {
    display: flex;
    gap: 0.45rem;
    padding: 0.2rem;
}

.multi-choice-actions button {
    flex: 1;
    border: 1px solid rgba(143, 216, 255, 0.18);
    border-radius: 11px;
    color: var(--mist);
    background: rgba(143, 216, 255, 0.06);
    padding: 0.45rem 0.55rem;
    cursor: pointer;
    font-weight: 850;
}

.multi-choice-actions button:hover {
    border-color: rgba(255, 79, 134, 0.28);
    background: rgba(143, 216, 255, 0.10);
}

.multi-choice-list {
    display: grid;
    gap: 0.28rem;
    max-height: 300px;
    overflow: auto;
    padding-right: 0.1rem;
}

.multi-choice-row {
    display: flex;
    grid-template-columns: none;
    align-items: center;
    gap: 0.55rem;
    padding: 0.5rem 0.55rem;
    border: 1px solid transparent;
    border-radius: 12px;
    color: #cfeafa;
    background: rgba(143, 216, 255, 0.04);
    cursor: pointer;
    transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.multi-choice-row:hover {
    transform: translateX(2px);
    background: rgba(143, 216, 255, 0.08);
    border-color: rgba(143, 216, 255, 0.16);
}

.multi-choice-row input {
    width: auto;
    accent-color: var(--cherry);
    box-shadow: none;
}

.multi-choice-row span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.multi-choice-menu::-webkit-scrollbar,
.multi-choice-list::-webkit-scrollbar {
    height: 9px;
    width: 9px;
}

.multi-choice-menu::-webkit-scrollbar-thumb,
.multi-choice-list::-webkit-scrollbar-thumb {
    background: rgba(143, 216, 255, 0.22);
    border-radius: 999px;
}

/* Phase 1.11 polish: keep navigation stable during page changes. */
.nav-submenu { animation: none !important; }
.nav-group:not([open]) .nav-submenu { display: grid; max-height: 0; opacity: 0; transform: translateY(-4px); }
.nav-group[open] .nav-submenu { display: grid; max-height: 520px; opacity: 1; transform: translateY(0); }
.nav-link.active { transform: none; }
.multi-choice.open { z-index: 80; }

/* Phase 1.12: public launch polish, admin gate, SEO/legal pages */
.site-footer {
    margin-top: 1rem;
    padding: 1rem 1.1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(8, 27, 45, 0.66);
    color: var(--muted);
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.site-footer strong { color: var(--mist); margin-right: 0.55rem; font-family: Georgia, serif; }
.site-footer nav { display: flex; gap: 0.85rem; flex-wrap: wrap; }
.site-footer a { color: var(--sky); font-weight: 750; }
.site-footer a:hover { color: var(--cherry); }
.public-hero, .admin-hero {
    background:
        radial-gradient(circle at 12% 0%, rgba(143, 216, 255, 0.16), transparent 28rem),
        radial-gradient(circle at 92% 18%, rgba(255, 79, 134, 0.14), transparent 26rem),
        linear-gradient(160deg, rgba(8, 27, 45, 0.92), rgba(7, 24, 40, 0.86));
}
.feature-cards .metric-card strong { font-size: clamp(1.1rem, 1.8vw, 1.6rem); }
.legal-page {
    max-width: 1050px;
    line-height: 1.62;
}
.legal-page h3 { margin-top: 1.35rem; margin-bottom: 0.55rem; }
.legal-page p { color: #cfeafa; }
.admin-login-card {
    display: grid;
    gap: 0.85rem;
    align-content: center;
    min-width: min(100%, 360px);
}
.form-error {
    margin: 0;
    border: 1px solid rgba(255, 124, 142, 0.36);
    border-radius: 13px;
    background: rgba(255, 124, 142, 0.08);
    color: var(--red);
    padding: 0.75rem;
    font-weight: 800;
}
.section-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 720px) {
    .site-footer { display: grid; }
    .site-footer nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Phase 1.13: Patreon/Discord supporter account polish */
.action-row {
    display: flex;
    gap: 0.7rem;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 1rem;
}
.feature-list {
    display: grid;
    gap: 0.8rem;
    margin: 0.8rem 0 0;
    padding-left: 1.2rem;
    color: var(--mist);
}
.feature-list li::marker { color: var(--cherry); }
.alert {
    padding: 0.9rem 1rem;
    border-radius: 15px;
    border: 1px solid var(--line);
    margin-bottom: 1rem;
    background: rgba(143, 216, 255, 0.08);
}
.alert.success { border-color: rgba(88, 220, 159, 0.38); color: #baffdc; background: rgba(88, 220, 159, 0.08); }
.alert.danger { border-color: rgba(255, 124, 142, 0.38); color: #ffd0d7; background: rgba(255, 124, 142, 0.08); }
.status-pills {
    display: flex;
    gap: 0.55rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}
.status-pill {
    border: 1px solid var(--line);
    background: rgba(143, 216, 255, 0.08);
    color: var(--mist);
    padding: 0.45rem 0.65rem;
    border-radius: 999px;
    font-weight: 800;
    font-size: 0.82rem;
}
.status-pill.good { border-color: rgba(88, 220, 159, 0.38); color: #baffdc; }
.status-pill.warn { border-color: rgba(255, 203, 107, 0.38); color: #ffe2a6; }
.kv-list {
    display: grid;
    gap: 0.65rem;
    margin: 1rem 0;
}
.kv-list div {
    display: grid;
    grid-template-columns: minmax(110px, 0.35fr) 1fr;
    gap: 0.75rem;
    padding: 0.65rem;
    border: 1px solid rgba(143, 216, 255, 0.11);
    border-radius: 13px;
    background: rgba(0, 0, 0, 0.12);
}
.kv-list dt { color: var(--muted); font-weight: 800; }
.kv-list dd { margin: 0; color: var(--mist); overflow-wrap: anywhere; }
.inline-form { margin-top: 1rem; }
@media (max-width: 720px) {
    .stacked-mobile { display: grid; }
    .kv-list div { grid-template-columns: 1fr; }
}

/* Phase 1.13 integration polish */
.status-pill{display:inline-flex;align-items:center;gap:.35rem;border-radius:999px;border:1px solid rgba(139,194,255,.3);padding:.28rem .65rem;font-size:.78rem;letter-spacing:.03em;text-transform:uppercase;background:rgba(11,26,46,.7);color:var(--text-soft)}
.status-pill.good{border-color:rgba(89,218,156,.45);color:#a8ffd4;background:rgba(42,143,91,.14)}
.status-pill.warn{border-color:rgba(255,184,89,.4);color:#ffd6a0;background:rgba(255,184,89,.10)}
.account-status-card{gap:.55rem}
.integration-card .hero-actions form{display:inline-flex}
.notice-card{border-color:rgba(221,74,110,.32);box-shadow:0 0 0 1px rgba(221,74,110,.08) inset}
.feature-list.compact li{margin:.35rem 0}
.topbar-actions form{display:inline-flex;margin:0}
