@font-face {
    font-family: Estedad;
    src: url("/fonts/Estedad-FD-variable.woff2") format("woff2-variations");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

:root {
    --oil: #061525;
    --oil-2: #0a2138;
    --oil-3: #123a5c;
    --sky: #9ec4e8;
    --foam: #e8f2fb;
    --mute: #8eabc4;
    --line: rgba(158, 196, 232, .18);
    --glass: rgba(12, 36, 62, .42);
    --glass-hi: rgba(232, 242, 251, .08);
    --gain: #3dcfb0;
    --loss: #ff6b7a;
    --accent: #4ea1d9;
    --pad: 20px;
    --dock: 84px;
    --r: 18px;
    --ease: cubic-bezier(.22, 1, .36, 1);
    --font: "Estedad", Tahoma, sans-serif;
}
* { box-sizing: border-box; }
html { color-scheme: dark; }
html, body { min-height: 100%; }
body {
    margin: 0;
    color: var(--foam);
    font-family: var(--font);
    background: var(--oil);
    overflow-x: hidden;
}
a { color: var(--sky); text-decoration: none; }
button, input, select { font: inherit; color: inherit; }

/* —— Atmosphere —— */
.atmosphere {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
    background:
        radial-gradient(120% 80% at 50% -20%, #1a4a78 0%, transparent 55%),
        linear-gradient(165deg, #04101c 0%, #0a2138 48%, #061525 100%);
}
.atmosphere::before,
.atmosphere::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    filter: blur(40px);
    opacity: .55;
    will-change: transform;
}
.atmosphere::before {
    width: 55vw; height: 55vw;
    top: -10%; right: -15%;
    background: radial-gradient(circle, #1e5f96 0%, transparent 70%);
    animation: orb-a 18s var(--ease) infinite alternate;
}
.atmosphere::after {
    width: 48vw; height: 48vw;
    bottom: -12%; left: -18%;
    background: radial-gradient(circle, #0d3d66 0%, transparent 70%);
    animation: orb-b 22s var(--ease) infinite alternate;
}
.atmosphere .sheen {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(115deg, transparent 40%, rgba(255,255,255,.04) 50%, transparent 60%),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='100' viewBox='0 0 160 100'%3E%3Cg fill='none' stroke='%239ec4e8' stroke-opacity='.07' stroke-width='1.2'%3E%3Cpath d='M20 70V35M20 35h8v22H20M55 78V28M55 28h9v32H55M95 66V22M95 22h8v26H95M130 74V40M130 40h9v20h-9'/%3E%3C/g%3E%3C/svg%3E");
    background-size: 220% 220%, 280px 175px;
    animation: sheen 14s linear infinite, grid-drift 30s var(--ease) infinite alternate;
}
@keyframes orb-a {
    from { transform: translate3d(0, 0, 0) scale(1); }
    to { transform: translate3d(-12%, 18%, 0) scale(1.15); }
}
@keyframes orb-b {
    from { transform: translate3d(0, 0, 0) scale(1); }
    to { transform: translate3d(16%, -10%, 0) scale(1.2); }
}
@keyframes sheen {
    from { background-position: 0% 0%, 0 0; }
    to { background-position: 100% 100%, 0 0; }
}
@keyframes grid-drift {
    from { transform: translate3d(0, 0, 0); }
    to { transform: translate3d(-2%, 1.5%, 0); }
}

/* —— Shell —— */
.app {
    position: relative;
    z-index: 1;
    min-height: 100dvh;
    padding: calc(14px + env(safe-area-inset-top)) var(--pad) calc(var(--dock) + env(safe-area-inset-bottom));
}
.topbar {
    display: grid;
    grid-template-columns: 40px 1fr 40px;
    align-items: center;
    justify-content: unset;
    margin-bottom: 22px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--glass);
    backdrop-filter: blur(22px) saturate(1.35);
    -webkit-backdrop-filter: blur(22px) saturate(1.35);
    box-shadow: inset 0 1px 0 var(--glass-hi);
    animation: rise .55s var(--ease) both;
}
.wordmark {
    grid-column: 2;
    justify-self: center;
    color: var(--foam);
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -.03em;
}
.wordmark span {
    color: var(--accent);
    font-weight: 500;
    margin-right: .35em;
    font-size: .72rem;
    letter-spacing: .12em;
    text-transform: uppercase;
}
.text-btn {
    background: none;
    border: 0;
    color: var(--mute);
    padding: 4px 2px;
    cursor: pointer;
    font-size: .9rem;
    font-weight: 500;
}
.text-btn:hover { color: var(--foam); }
.icon-btn {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 12px;
    background: transparent;
    color: var(--loss);
    cursor: pointer;
    transition: color .2s, background .2s, border-color .2s;
}
.icon-btn svg { width: 18px; height: 18px; display: block; }
.icon-btn:hover {
    color: #ff8a95;
    background: rgba(255, 107, 122, .12);
    border-color: rgba(255, 107, 122, .35);
}
.topbar-sync {
    grid-column: 3;
    justify-self: end;
    margin: 0;
}
.topbar-sync .icon-btn {
    width: 36px;
    min-height: 0;
    color: var(--sky);
}
.topbar-sync .icon-btn:hover {
    color: var(--foam);
    background: rgba(78, 161, 217, .14);
    border-color: rgba(78, 161, 217, .35);
}

/* —— Modal —— */
.modal {
    border: 0;
    padding: 0;
    max-width: min(92vw, 400px);
    background: transparent;
    color: var(--foam);
}
.modal::backdrop {
    background: rgba(4, 16, 28, .72);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.modal[open] { animation: rise .35s var(--ease) both; }
.modal-card {
    margin: 0;
    padding: 22px;
    border-radius: var(--r);
    border: 1px solid var(--line);
    background: rgba(10, 33, 56, .92);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    box-shadow: inset 0 1px 0 var(--glass-hi);
    display: grid;
    gap: 10px;
}
.modal-card h2 {
    margin: 0;
    font-size: 1.2rem;
}
.modal-card p {
    margin: 0 0 8px;
    color: var(--mute);
    font-size: .92rem;
    line-height: 1.5;
}
.modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.modal-actions button { width: 100%; min-height: 44px; }
.modal-actions .ghost { width: 100%; }
.modal-facts {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 14px;
    margin: 2px 0 10px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: rgba(4, 16, 28, .4);
}
.modal-facts dt {
    margin: 0;
    color: var(--mute);
    font-size: .78rem;
}
.modal-facts dd {
    margin: 0;
    text-align: left;
    font-variant-numeric: tabular-nums;
    font-size: .9rem;
}
.modal-actions .danger {
    background: linear-gradient(180deg, #ff7a88, #e24b5a);
    color: #fff;
    border: 0;
}
.modal-actions .danger:hover { filter: brightness(1.06); }
.stage > * { animation: rise .65s var(--ease) both; }
.stage > *:nth-child(2) { animation-delay: .06s; }
.stage > *:nth-child(3) { animation-delay: .12s; }
.stage > *:nth-child(4) { animation-delay: .18s; }
.stage > *:nth-child(5) { animation-delay: .24s; }
@keyframes rise {
    from { opacity: 0; transform: translateY(22px) scale(.985); filter: blur(4px); }
    to { opacity: 1; transform: none; filter: none; }
}

/* —— Auth —— */
.splash {
    position: relative;
    z-index: 1;
    min-height: 100dvh;
    display: grid;
    align-content: end;
    gap: 18px;
    padding: 36px var(--pad) calc(40px + env(safe-area-inset-bottom));
}
.splash-brand {
    animation: rise .8s var(--ease) both;
}
.splash h1 {
    margin: 0;
    font-size: clamp(3.2rem, 15vw, 5.4rem);
    line-height: .86;
    letter-spacing: -.07em;
    font-weight: 800;
    background: linear-gradient(180deg, #fff 20%, #7eb6e8 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.splash-brand p {
    margin: 16px 0 0;
    max-width: 17rem;
    color: var(--mute);
    font-size: 1.05rem;
    line-height: 1.55;
}
.gate {
    display: grid;
    gap: 14px;
    padding: 22px;
    border-radius: var(--r);
    border: 1px solid var(--line);
    background: var(--glass);
    backdrop-filter: blur(28px) saturate(1.4);
    -webkit-backdrop-filter: blur(28px) saturate(1.4);
    box-shadow: inset 0 1px 0 var(--glass-hi);
    animation: rise .75s var(--ease) .08s both;
    position: relative;
    overflow: hidden;
}
.gate::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 -40%;
    width: 40%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.07), transparent);
    animation: glass-sweep 4.5s var(--ease) 1.2s infinite;
}
@keyframes glass-sweep {
    from { transform: translateX(0); }
    to { transform: translateX(380%); }
}
.quiet {
    color: var(--mute);
    font-size: .95rem;
    animation: rise .7s var(--ease) .16s both;
}

/* —— Forms —— */
label {
    display: grid;
    gap: 7px;
    color: var(--mute);
    font-size: .82rem;
    position: relative;
    z-index: 1;
}
input, select {
    width: 100%;
    border: 1px solid var(--line);
    background: rgba(4, 16, 28, .45);
    border-radius: 12px;
    padding: 12px 14px;
    margin: 0;
    transition: border-color .2s, background .2s;
}
input:focus, select:focus {
    outline: none;
    border-color: rgba(78, 161, 217, .55);
    background: rgba(4, 16, 28, .65);
}
option { background: var(--oil-2); color: var(--foam); }

button, .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 50px;
    border: 0;
    border-radius: 14px;
    background: linear-gradient(180deg, #4ea1d9, #2a6fa3);
    color: #04101c;
    cursor: pointer;
    font-weight: 750;
    letter-spacing: .01em;
    position: relative;
    z-index: 1;
    transition: transform .15s var(--ease), filter .15s;
}
button:hover, .btn:hover { filter: brightness(1.06); }
button:active, .btn:active { transform: scale(.98); }
button.ghost, .ghost {
    width: auto;
    min-height: 42px;
    padding: 0 16px;
    background: transparent;
    color: var(--foam);
    border: 1px solid var(--line);
}
button.ok, .btn.ok {
    background: linear-gradient(180deg, #5ee0c2, #2a9d82);
    color: #041c16;
}
button.danger, .btn.danger {
    background: linear-gradient(180deg, #ff8a96, #d64555);
    color: #1a0508;
}
button.sync {
    width: auto;
    min-height: 40px;
    padding: 0 18px;
    border-radius: 999px;
    background: rgba(78, 161, 217, .18);
    color: var(--sky);
    border: 1px solid rgba(78, 161, 217, .35);
}
button.icon-btn {
    width: 36px;
    min-height: 36px;
    height: 36px;
    padding: 0;
    border-radius: 12px;
    background: transparent;
    font-weight: 500;
    filter: none;
}
button.icon-btn:hover { filter: none; }

/* —— Content —— */
.dash-head {
    text-align: center;
    margin-bottom: 20px;
}
.dash-head .hello {
    margin: 0;
    font-size: 1.45rem;
    font-weight: 750;
    letter-spacing: -.03em;
}
.hero-line {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}
h1, h2 { margin: 0; font-weight: 750; letter-spacing: -.03em; }
.hero-line h1 { font-size: 1.75rem; }
.hint { margin: 8px 0 0; color: var(--mute); font-size: .9rem; }

.pulse {
    display: grid;
    grid-template-columns: 1.35fr 1fr 1fr;
    gap: 10px;
    margin: 8px 0 14px;
    padding: 18px 16px;
    border-radius: var(--r);
    border: 1px solid var(--line);
    background: var(--glass);
    backdrop-filter: blur(24px) saturate(1.3);
    -webkit-backdrop-filter: blur(24px) saturate(1.3);
    box-shadow: inset 0 1px 0 var(--glass-hi);
}
.pulse > div { min-width: 0; }
.pulse span {
    display: block;
    color: var(--mute);
    font-size: .72rem;
    letter-spacing: .08em;
    margin-bottom: 8px;
}
.pulse strong {
    display: block;
    font-size: clamp(1.9rem, 7.5vw, 2.5rem);
    line-height: 1;
    letter-spacing: -.05em;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.panel {
    padding: 4px 0 8px;
}
.block-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin: 26px 0 12px;
}
.block-head h2 { font-size: 1rem; color: var(--mute); font-weight: 600; }
.block-head a { color: var(--accent); font-size: .88rem; }

.ticket-link, .ticket {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 16px;
    margin-bottom: 10px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: var(--glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: inset 0 1px 0 var(--glass-hi);
    color: inherit;
    transition: border-color .2s, transform .2s var(--ease);
}
.ticket-link:hover, .ticket:hover {
    border-color: rgba(78, 161, 217, .35);
    transform: translateY(-1px);
}
.ticket-link small, .meta {
    display: block;
    color: var(--mute);
    font-size: .8rem;
    font-weight: 400;
    margin-top: 5px;
}
.ticket { display: block; }
.ticket header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
}
.quote-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin: 12px 0 0;
}
.quote-row dt {
    margin: 0;
    color: var(--mute);
    font-size: .72rem;
}
.quote-row dd {
    margin: 4px 0 0;
    font-variant-numeric: tabular-nums;
    font-size: .95rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chip {
    display: inline-block;
    padding: .12em .55em;
    border-radius: 8px;
    font-size: .75rem;
    vertical-align: middle;
    border: 1px solid var(--line);
}
.chip-active { color: var(--gain); border-color: rgba(61, 207, 176, .35); }
.chip-sold_bot { color: var(--sky); }
.chip-sold_manual { color: var(--mute); }
.chip-sold_auto { color: var(--gain); border-color: rgba(61, 207, 176, .35); }
.pnl-stack {
    display: grid;
    justify-items: end;
    gap: 2px;
    text-align: left;
}
.pnl-stack small {
    font-size: .72rem;
    font-variant-numeric: tabular-nums;
}
.order-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 4px;
}
.order-actions form { display: grid; margin: 0; }
button.act {
    width: 100%;
    min-height: 46px;
    padding: 0 10px;
    border-radius: 12px;
    font-size: .84rem;
    font-weight: 750;
}
button.act-smart {
    grid-column: 1 / -1;
    background: linear-gradient(180deg, #5ee0c2, #2a9d82);
    color: #041c16;
}
button.act-now {
    background: linear-gradient(180deg, #ff8a96, #d64555);
    color: #1a0508;
}
button.act-done {
    background: transparent;
    color: var(--foam);
    border: 1px solid var(--line);
}
.ticket .targets {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    align-items: end;
    margin: 14px 0 10px;
}
.pos { color: var(--gain); font-variant-numeric: tabular-nums; }
.neg { color: var(--loss); font-variant-numeric: tabular-nums; }

.filters {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    align-items: end;
    margin-bottom: 14px;
    padding: 14px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: var(--glass);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}
.filters input[type="search"],
.filters input[name="q"] {
    grid-column: 1 / -1;
}
.filters button[type="submit"] {
    grid-column: 1 / -1;
}
.filters input, .filters select { margin: 0; }

.stack { display: grid; gap: 16px; margin-bottom: 18px; }
fieldset {
    border: 1px solid var(--line);
    margin: 0;
    padding: 18px 16px 16px;
    border-radius: var(--r);
    display: grid;
    gap: 12px;
    background: var(--glass);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
    box-shadow: inset 0 1px 0 var(--glass-hi);
}
legend {
    padding: 0 8px;
    font-weight: 750;
    font-size: 1rem;
    color: var(--foam);
}
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--foam);
    font-size: .95rem;
}
.check input { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); }

.toast, .banner {
    margin: 0 0 14px;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid rgba(61, 207, 176, .28);
    background: rgba(61, 207, 176, .1);
    backdrop-filter: blur(12px);
    animation: rise .45s var(--ease) both;
}
.banner.warn {
    border-color: rgba(78, 161, 217, .35);
    background: rgba(78, 161, 217, .1);
}
.banner.err, .err {
    color: #ffc0c6;
    border-color: rgba(255, 107, 122, .35);
    background: rgba(255, 107, 122, .1);
}
.ok { color: var(--gain); margin: 0; }
.empty { color: var(--mute); padding: 28px 8px; text-align: center; }
.pager {
    display: flex;
    gap: 16px;
    align-items: center;
    justify-content: center;
    margin-top: 18px;
    color: var(--mute);
}

/* —— Dock —— */
.dock {
    position: fixed;
    z-index: 5;
    left: 14px;
    right: 14px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    padding: 8px;
    border-radius: 22px;
    border: 1px solid var(--line);
    background: rgba(6, 21, 37, .72);
    backdrop-filter: blur(28px) saturate(1.4);
    -webkit-backdrop-filter: blur(28px) saturate(1.4);
    box-shadow: inset 0 1px 0 var(--glass-hi);
    animation: dock-in .6s var(--ease) both;
}
@keyframes dock-in {
    from { opacity: 0; transform: translateY(120%) scale(.96); }
    to { opacity: 1; transform: none; }
}
.dock a,
.dock-logout {
    display: grid;
    justify-items: center;
    gap: 4px;
    color: var(--mute);
    font-size: .62rem;
    padding: 10px 2px;
    border-radius: 16px;
    position: relative;
    transition: color .2s, background .2s;
    background: none;
    border: 0;
    width: 100%;
    cursor: pointer;
    font-family: inherit;
}
.dock svg,
.dock-logout svg { width: 22px; height: 22px; fill: currentColor; }
.dock a.on {
    color: var(--foam);
    background: rgba(78, 161, 217, .16);
}
.dock a.on::after {
    content: "";
    position: absolute;
    bottom: 5px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--accent);
    animation: pop .35s var(--ease) both;
}
.dock-logout {
    color: var(--loss);
}
.dock-logout:hover {
    background: rgba(255, 107, 122, .12);
    color: #ff8a95;
}
@keyframes pop {
    from { transform: scale(0); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@media (min-width: 820px) {
    .app { max-width: 760px; margin: 0 auto; }
    .dock {
        left: max(14px, calc(50vw - 380px + 14px));
        right: auto;
        width: min(732px, calc(100% - 28px));
    }
    .splash {
        max-width: 480px;
        margin: 0 auto;
        align-content: center;
        min-height: 100dvh;
    }
    .pulse { grid-template-columns: repeat(3, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
