:root {
    --background: 240 10% 3.9%;
    --foreground: 0 0% 98%;
    --card: 240 10% 5.8%;
    --card-foreground: 0 0% 98%;
    --popover: 240 10% 5.8%;
    --popover-foreground: 0 0% 98%;
    --primary: 47.9 95.8% 53.1%;
    --primary-foreground: 26 83.3% 14.1%;
    --secondary: 240 3.7% 15.9%;
    --secondary-foreground: 0 0% 98%;
    --muted: 240 3.7% 15.9%;
    --muted-foreground: 240 5% 64.9%;
    --accent: 240 3.7% 15.9%;
    --accent-foreground: 0 0% 98%;
    --destructive: 0 62.8% 45%;
    --destructive-foreground: 0 0% 98%;
    --border: 240 3.7% 15.9%;
    --input: 240 3.7% 15.9%;
    --ring: 47.9 95.8% 53.1%;
    --radius: 0.85rem;
    --header-height: 4rem;
    --nav-height: 5rem;
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

html {
    background: hsl(var(--background));
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at 50% -12%, rgba(250, 204, 21, 0.08), transparent 26rem),
        hsl(var(--background));
    color: hsl(var(--foreground));
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 0.95rem;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior-y: none;
}

button,
input {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

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

svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

h1,
h2,
p {
    margin: 0;
}

h1 {
    font-size: clamp(1.55rem, 6vw, 2rem);
    line-height: 1.15;
    letter-spacing: -0.035em;
}

h2 {
    font-size: 1rem;
    letter-spacing: -0.015em;
}

.app-shell {
    padding-top: calc(var(--header-height) + env(safe-area-inset-top));
    padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 1.2rem);
}

.app-header {
    position: fixed;
    z-index: 50;
    inset: 0 0 auto;
    height: calc(var(--header-height) + env(safe-area-inset-top));
    padding-top: env(safe-area-inset-top);
    border-bottom: 1px solid hsl(var(--border) / 0.86);
    background: hsl(var(--background) / 0.88);
    backdrop-filter: blur(18px) saturate(150%);
}

.app-header__inner {
    width: min(100%, 64rem);
    height: var(--header-height);
    margin-inline: auto;
    padding-inline: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    font-weight: 750;
    letter-spacing: -0.025em;
}

.brand__icon {
    width: 2rem;
    height: 2rem;
    border-radius: 0.65rem;
    box-shadow: 0 0 0 1px rgba(250, 204, 21, 0.15), 0 8px 26px rgba(0, 0, 0, 0.35);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.header-actions form {
    margin: 0;
}

.icon-button {
    width: 2.55rem;
    height: 2.55rem;
    display: inline-grid;
    place-items: center;
    border: 0;
    border-radius: 0.75rem;
    background: transparent;
    color: hsl(var(--muted-foreground));
    cursor: pointer;
    transition: background 140ms ease, color 140ms ease, transform 140ms ease;
}

.icon-button:hover,
.icon-button:focus-visible {
    background: hsl(var(--accent));
    color: hsl(var(--foreground));
}

.icon-button:active {
    transform: scale(0.94);
}

.icon-button svg {
    width: 1.25rem;
    height: 1.25rem;
}

.app-main {
    width: min(100%, 64rem);
    margin-inline: auto;
    padding: 1.25rem 1rem 0;
}

.auth-shell {
    display: grid;
    min-height: 100vh;
    min-height: 100dvh;
    place-items: center;
    padding: max(1.2rem, env(safe-area-inset-top)) 1rem max(1.2rem, env(safe-area-inset-bottom));
}

.auth-main {
    width: min(100%, 25rem);
}

.card {
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    background: linear-gradient(180deg, hsl(var(--card) / 0.98), hsl(var(--card) / 0.9));
    color: hsl(var(--card-foreground));
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.02) inset, 0 18px 50px rgba(0, 0, 0, 0.16);
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.stack--xs {
    gap: 0.35rem;
}

.text-center {
    text-align: center;
}

.muted {
    color: hsl(var(--muted-foreground));
}

.page-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.eyebrow {
    margin-bottom: 0.28rem;
    color: hsl(var(--primary));
    font-size: 0.69rem;
    font-weight: 760;
    letter-spacing: 0.16em;
}

.status-dot {
    width: 0.65rem;
    height: 0.65rem;
    border-radius: 999px;
    background: #22c55e;
    box-shadow: 0 0 0 0.35rem rgba(34, 197, 94, 0.1), 0 0 1.2rem rgba(34, 197, 94, 0.45);
}

.auth-card {
    padding: 1.3rem;
    display: flex;
    flex-direction: column;
    gap: 1.35rem;
}

.auth-logo-wrap {
    width: 4.7rem;
    height: 4.7rem;
    margin-inline: auto;
    padding: 0.35rem;
    border: 1px solid rgba(250, 204, 21, 0.2);
    border-radius: 1.45rem;
    background: rgba(250, 204, 21, 0.04);
    box-shadow: 0 0 3rem rgba(250, 204, 21, 0.1);
}

.auth-logo {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 1.1rem;
}

.auth-footnote {
    color: hsl(var(--muted-foreground));
    font-size: 0.73rem;
    text-align: center;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.field label {
    color: hsl(var(--foreground));
    font-size: 0.82rem;
    font-weight: 650;
}

.field input {
    width: 100%;
    min-height: 2.85rem;
    padding: 0.7rem 0.85rem;
    border: 1px solid hsl(var(--input));
    border-radius: 0.7rem;
    outline: none;
    background: hsl(var(--background) / 0.8);
    color: hsl(var(--foreground));
    transition: border 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.field input::placeholder {
    color: hsl(var(--muted-foreground) / 0.7);
}

.field input:focus {
    border-color: hsl(var(--ring));
    box-shadow: 0 0 0 3px hsl(var(--ring) / 0.15);
    background: hsl(var(--background));
}

.input-with-icon {
    position: relative;
}

.input-with-icon > svg {
    position: absolute;
    z-index: 1;
    top: 50%;
    left: 0.8rem;
    width: 1.05rem;
    height: 1.05rem;
    transform: translateY(-50%);
    color: hsl(var(--muted-foreground));
    pointer-events: none;
}

.input-with-icon input {
    padding-left: 2.45rem;
}

.input-suffix {
    position: relative;
}

.input-suffix input {
    padding-right: 2.5rem;
}

.input-suffix > span {
    position: absolute;
    top: 50%;
    right: 0.9rem;
    transform: translateY(-50%);
    color: hsl(var(--muted-foreground));
    font-weight: 650;
}

.field-help,
.field-error {
    font-size: 0.72rem;
}

.field-help {
    color: hsl(var(--muted-foreground));
}

.field-error,
.validation-summary {
    color: #f87171;
}

.validation-summary:empty,
.field-error:empty {
    display: none;
}

.validation-summary ul {
    margin: 0;
    padding-left: 1.2rem;
}

.button {
    min-height: 2.9rem;
    padding: 0.7rem 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    border: 1px solid transparent;
    border-radius: 0.72rem;
    font-weight: 710;
    cursor: pointer;
    transition: transform 130ms ease, filter 130ms ease, border-color 130ms ease, background 130ms ease;
}

.button:active {
    transform: scale(0.985);
}

.button:focus-visible {
    outline: 3px solid hsl(var(--ring) / 0.3);
    outline-offset: 2px;
}

.button svg {
    width: 1.15rem;
    height: 1.15rem;
}

.button--primary {
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    box-shadow: 0 10px 28px hsl(var(--primary) / 0.14);
}

.button--primary:hover {
    filter: brightness(1.05);
}

.button--secondary {
    border-color: hsl(var(--border));
    background: hsl(var(--secondary));
    color: hsl(var(--secondary-foreground));
}

.button--secondary:hover {
    border-color: hsl(var(--muted-foreground) / 0.45);
    background: hsl(var(--accent));
}

.button--full {
    width: 100%;
}

.state-card {
    min-height: 5rem;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.state-card strong {
    display: block;
    margin-bottom: 0.15rem;
}

.state-card p {
    color: hsl(var(--muted-foreground));
    font-size: 0.8rem;
}

.state-card > svg {
    width: 1.5rem;
    height: 1.5rem;
    flex: 0 0 auto;
}

.state-card--error {
    border-color: rgba(248, 113, 113, 0.3);
    background: rgba(127, 29, 29, 0.16);
}

.state-card--error > svg {
    color: #f87171;
}

.spinner {
    width: 1.45rem;
    height: 1.45rem;
    flex: 0 0 auto;
    border: 2px solid hsl(var(--muted));
    border-top-color: hsl(var(--primary));
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.hero-card {
    padding: 1.15rem 1rem;
    overflow: hidden;
    position: relative;
}

.hero-card::before {
    content: "";
    position: absolute;
    inset: -7rem 20% auto;
    height: 9rem;
    border-radius: 50%;
    background: hsl(var(--primary) / 0.1);
    filter: blur(30px);
    pointer-events: none;
}

.latest-price {
    position: relative;
    margin: 0.25rem 0 0.05rem;
    font-size: clamp(2rem, 10vw, 3.3rem);
    line-height: 1;
    font-weight: 810;
    letter-spacing: -0.06em;
    text-align: center;
}

.recommendation-badge {
    width: fit-content;
    margin: 1rem auto 0.35rem;
    padding: 0.35rem 0.7rem;
    border: 1px solid hsl(var(--border));
    border-radius: 999px;
    background: hsl(var(--muted));
    color: hsl(var(--foreground));
    font-size: 0.72rem;
    font-weight: 760;
    letter-spacing: 0.045em;
    text-transform: uppercase;
}

.recommendation-badge[data-state="enter"],
.recommendation-badge[data-state="stay-long"] {
    border-color: rgba(34, 197, 94, 0.35);
    background: rgba(34, 197, 94, 0.12);
    color: #86efac;
}

.recommendation-badge[data-state="exit"] {
    border-color: rgba(248, 113, 113, 0.35);
    background: rgba(248, 113, 113, 0.12);
    color: #fca5a5;
}

.recommendation-badge[data-state="cash"] {
    border-color: rgba(161, 161, 170, 0.25);
    background: rgba(161, 161, 170, 0.08);
    color: #d4d4d8;
}

.recommendation-text {
    color: hsl(var(--muted-foreground));
    font-size: 0.8rem;
    text-align: center;
}

.chart-card,
.table-card,
.settings-card {
    overflow: hidden;
}

.card-header {
    min-height: 4rem;
    padding: 0.9rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    border-bottom: 1px solid hsl(var(--border));
}

.card-header p {
    margin-top: 0.15rem;
    color: hsl(var(--muted-foreground));
    font-size: 0.75rem;
}

.legend-pill,
.period-badges span {
    padding: 0.3rem 0.52rem;
    border: 1px solid hsl(var(--border));
    border-radius: 999px;
    background: hsl(var(--muted) / 0.65);
    color: hsl(var(--muted-foreground));
    font-size: 0.67rem;
    font-weight: 700;
    white-space: nowrap;
}

.period-badges {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.35rem;
}

.chart-stage {
    position: relative;
}

.chart-overlay {
    position: absolute;
    z-index: 5;
    top: 0.65rem;
    left: 0.65rem;
    max-width: calc(100% - 1.3rem);
    padding: 0.35rem;
    border: 1px solid rgba(63, 63, 70, 0.8);
    border-radius: 0.75rem;
    background: rgba(9, 9, 11, 0.78);
    backdrop-filter: blur(8px);
    pointer-events: none;
}

.chart-container {
    width: 100%;
    height: min(62vh, 31rem);
    min-height: 24rem;
    background: #09090b;
    touch-action: pan-y pinch-zoom;
}

.chart-container--indicator {
    height: min(58vh, 29rem);
}

.chart-legend {
    min-height: 2.8rem;
    padding: 0.7rem 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.2rem;
    border-top: 1px solid hsl(var(--border));
    color: hsl(var(--muted-foreground));
    font-size: 0.7rem;
}

.chart-legend span {
    display: inline-flex;
    align-items: center;
    gap: 0.42rem;
}

.legend-marker {
    width: 0;
    height: 0;
    display: inline-block;
    border-left: 0.33rem solid transparent;
    border-right: 0.33rem solid transparent;
}

.legend-marker--entry {
    border-bottom: 0.55rem solid #facc15;
}

.legend-marker--exit {
    border-top: 0.55rem solid #facc15;
}

.line-swatch {
    width: 1.1rem;
    height: 0.16rem;
    display: inline-block;
    border-radius: 999px;
}

.line-swatch--fisher { background: #52525b; }
.line-swatch--fast { background: #3b82f6; }
.line-swatch--slow { background: #f97316; }

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

.metrics-grid--three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric-card {
    min-height: 5.3rem;
    padding: 0.95rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 0.6rem;
}

.metric-card span {
    color: hsl(var(--muted-foreground));
    font-size: 0.72rem;
}

.metric-card strong {
    font-size: 1rem;
    letter-spacing: -0.02em;
}

.info-card {
    padding: 0.9rem 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    color: hsl(var(--muted-foreground));
    font-size: 0.78rem;
}

.info-card svg {
    width: 1.15rem;
    height: 1.15rem;
    flex: 0 0 auto;
    color: hsl(var(--primary));
}

.table-scroll {
    overflow-x: auto;
    overscroll-behavior-x: contain;
}

.trades-table {
    width: 100%;
    min-width: 52rem;
    border-collapse: collapse;
    font-size: 0.76rem;
}

.trades-table th,
.trades-table td {
    padding: 0.72rem 0.8rem;
    border-bottom: 1px solid hsl(var(--border));
    text-align: left;
    white-space: nowrap;
}

.trades-table th {
    position: sticky;
    top: 0;
    background: hsl(var(--card));
    color: hsl(var(--muted-foreground));
    font-weight: 650;
}

.trades-table tr:last-child td {
    border-bottom: 0;
}

.return-positive {
    color: #4ade80;
    font-weight: 700;
}

.return-negative {
    color: #f87171;
    font-weight: 700;
}

.trade-status {
    padding: 0.2rem 0.45rem;
    border-radius: 999px;
    font-size: 0.66rem;
    font-weight: 720;
}

.trade-status--open {
    background: rgba(250, 204, 21, 0.12);
    color: #fde047;
}

.trade-status--closed {
    background: rgba(161, 161, 170, 0.12);
    color: #d4d4d8;
}

.empty-state {
    min-height: 13rem;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    color: hsl(var(--muted-foreground));
    text-align: center;
}

.empty-state svg {
    width: 2rem;
    height: 2rem;
    margin-bottom: 0.4rem;
    color: hsl(var(--primary));
}

.empty-state strong {
    color: hsl(var(--foreground));
}

.empty-state p {
    max-width: 22rem;
    font-size: 0.78rem;
}

.settings-card > form {
    padding: 1rem;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.toast {
    margin-bottom: 1rem;
    padding: 0.8rem 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    border: 1px solid hsl(var(--border));
    border-radius: 0.75rem;
    font-size: 0.8rem;
}

.toast svg {
    width: 1.1rem;
    height: 1.1rem;
}

.toast--success {
    border-color: rgba(34, 197, 94, 0.3);
    background: rgba(34, 197, 94, 0.1);
    color: #86efac;
}

.error-page {
    width: min(100%, 25rem);
    margin: 12vh auto 0;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.auth-main .error-page {
    margin-top: 0;
}

.error-icon {
    width: 4rem;
    height: 4rem;
    margin-inline: auto;
    display: grid;
    place-items: center;
    border-radius: 1.2rem;
    background: rgba(248, 113, 113, 0.1);
    color: #f87171;
}

.error-icon svg {
    width: 2rem;
    height: 2rem;
}

.bottom-nav {
    position: fixed;
    z-index: 50;
    inset: auto 0 0;
    min-height: calc(var(--nav-height) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    border-top: 1px solid hsl(var(--border) / 0.88);
    background: hsl(var(--background) / 0.9);
    backdrop-filter: blur(20px) saturate(150%);
}

.bottom-nav__inner {
    width: min(100%, 40rem);
    height: var(--nav-height);
    margin-inline: auto;
    padding: 0.4rem 0.55rem 0.45rem;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.25rem;
}

.bottom-nav__item {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.22rem;
    border-radius: 0.75rem;
    color: hsl(var(--muted-foreground));
    font-size: 0.64rem;
    font-weight: 650;
    transition: color 130ms ease, background 130ms ease, transform 130ms ease;
}

.bottom-nav__item svg {
    width: 1.28rem;
    height: 1.28rem;
}

.bottom-nav__item:active {
    transform: scale(0.94);
}

.bottom-nav__item--active {
    background: hsl(var(--accent));
    color: hsl(var(--primary));
}

.busy-overlay {
    position: fixed;
    z-index: 100;
    inset: 0;
    padding: 1rem;
    display: grid;
    place-items: center;
    background: rgba(0, 0, 0, 0.66);
    backdrop-filter: blur(8px);
}

.busy-overlay[hidden] {
    display: none;
}

.busy-card {
    width: min(100%, 20rem);
    padding: 1.25rem;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.25rem 0.85rem;
    border: 1px solid hsl(var(--border));
    border-radius: 1rem;
    background: hsl(var(--card));
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

.busy-card .spinner {
    grid-row: span 2;
    align-self: center;
}

.busy-card span:last-child {
    color: hsl(var(--muted-foreground));
    font-size: 0.75rem;
}

[hidden] {
    display: none !important;
}

@media (max-width: 640px) {
    .app-main {
        padding-inline: 0.75rem;
    }

    .metrics-grid--three {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .metric-card--wide-mobile {
        grid-column: 1 / -1;
    }

    .settings-grid {
        grid-template-columns: 1fr;
    }

    .card-header--stack-mobile {
        align-items: flex-start;
        flex-direction: column;
    }

    .period-badges {
        justify-content: flex-start;
    }

    .chart-legend--three {
        gap: 0.7rem;
        justify-content: space-between;
    }

    .chart-container {
        min-height: 22rem;
        height: 57vh;
        height: 57dvh;
    }
}

@media (min-width: 768px) {
    .app-main {
        padding-top: 1.65rem;
    }

    .auth-card {
        padding: 1.6rem;
    }

    .chart-card,
    .hero-card,
    .settings-card,
    .table-card {
        border-radius: 1rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
