:root {
    --bg: #eef2f7;
    --bg-card: #ffffff;
    --bg-elevated: #f6f8fb;
    --text: #152033;
    --text-secondary: #3d4f66;
    --muted: #64748b;
    --green: #0a8f4a;
    --green-dim: #e8f7ef;
    --green-border: #86d4a8;
    --yellow: #b45309;
    --yellow-dim: #fef6e8;
    --yellow-border: #f5c76a;
    --red: #c53030;
    --red-dim: #fef0f0;
    --red-border: #f5a8a8;
    --gray: #94a3b8;
    --gray-dim: #f1f5f9;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(21, 32, 51, 0.06), 0 4px 16px rgba(21, 32, 51, 0.04);
    --shadow-lg: 0 4px 24px rgba(21, 32, 51, 0.1);
    --radius: 14px;
    --font: "DM Sans", system-ui, -apple-system, sans-serif;
    --touch: 48px;
    --app-bar-h: 52px;
    --bottom-nav-h: 64px;
    --install-banner-h: 0px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    min-height: 100dvh;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    overscroll-behavior-y: none;
}

body.has-shell {
    padding-top: calc(var(--app-bar-h) + env(safe-area-inset-top, 0px));
    padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
}

body.has-install-banner {
    --install-banner-h: 52px;
    padding-top: calc(var(--app-bar-h) + var(--install-banner-h) + env(safe-area-inset-top, 0px));
}

body.is-standalone .install-banner,
body.is-standalone .page-intro {
    display: none !important;
}

body.is-standalone.has-install-banner {
    --install-banner-h: 0px;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 90% 60% at 50% -10%, rgba(10, 143, 74, 0.07), transparent),
        radial-gradient(ellipse 50% 40% at 100% 0%, rgba(59, 130, 246, 0.05), transparent);
    pointer-events: none;
    z-index: 0;
}

/* —— PWA shell —— */
.install-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 200;
    background: linear-gradient(135deg, #0a8f4a, #087a3f);
    color: #fff;
    padding: calc(0.5rem + env(safe-area-inset-top, 0px)) 0.75rem 0.5rem;
    box-shadow: var(--shadow-lg);
}

.install-banner-body {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    max-width: 720px;
    margin: 0 auto;
}

.install-banner-text {
    flex: 1;
    font-size: 0.8rem;
    line-height: 1.35;
}

.install-banner-text strong {
    display: block;
    font-size: 0.88rem;
}

.install-banner-close {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
}

.app-bar {
    position: fixed;
    top: env(safe-area-inset-top, 0);
    left: 0;
    right: 0;
    z-index: 150;
    height: var(--app-bar-h);
    padding: 0 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
}

body.has-install-banner .app-bar {
    top: calc(52px + env(safe-area-inset-top, 0px));
}

.app-bar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.app-bar-icon {
    font-size: 1.35rem;
}

.app-bar-title {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text);
}

.app-bar-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 12px;
    background: var(--green-dim);
    color: var(--green);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.app-bar-btn:active {
    transform: scale(0.95);
}

.app-bar-btn.syncing svg {
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.app-main {
    position: relative;
    z-index: 1;
}

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 150;
    height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    display: flex;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 20px rgba(21, 32, 51, 0.06);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    border: none;
    background: none;
    color: var(--muted);
    font-family: inherit;
    font-size: 0.65rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0.35rem 0.15rem;
    min-height: var(--bottom-nav-h);
}

.nav-item .nav-icon {
    font-size: 1.25rem;
    line-height: 1;
}

.nav-item.active {
    color: var(--green);
}

.nav-item.active .nav-label {
    font-weight: 700;
}

.scroll-section {
    scroll-margin-top: calc(var(--app-bar-h) + var(--install-banner-h) + 12px);
    scroll-margin-bottom: calc(var(--bottom-nav-h) + 12px);
}

.section-hint {
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
}

.sectors-title {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    padding: 0 0.125rem;
}

.sectors-wrap {
    margin-bottom: 0.5rem;
}

.app {
    position: relative;
    z-index: 1;
    max-width: 720px;
    margin: 0 auto;
    padding: 0.75rem 1rem 1rem;
}

body.has-shell .app {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

.page-intro {
    margin-bottom: 0.75rem;
}

.sim-link-wrap {
    margin-bottom: 1rem;
}

.sim-link-btn {
    display: block;
    text-align: center;
    text-decoration: none;
    width: 100%;
}

body.is-standalone .app {
    padding-top: 0.25rem;
}

/* —— Header —— */
.header {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
    margin-bottom: 1.25rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-icon {
    font-size: 2rem;
    line-height: 1;
    flex-shrink: 0;
}

.brand h1 {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
    line-height: 1.2;
}

.brand p {
    color: var(--muted);
    font-size: 0.9rem;
    margin-top: 0.15rem;
}

.header-actions {
    width: 100%;
}

.btn {
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    min-height: var(--touch);
    padding: 0.75rem 1.25rem;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    transition: transform 0.12s, box-shadow 0.12s, background 0.12s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--green);
    color: #fff;
    box-shadow: 0 2px 8px rgba(10, 143, 74, 0.25);
}

.btn-primary:hover {
    background: #087a3f;
}

.btn-ghost {
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1.5px solid var(--border);
    box-shadow: var(--shadow);
}

.btn-ghost:hover {
    background: var(--bg-elevated);
}

/* —— Hero —— */
.hero {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}

.hero-inner {
    display: flex;
    gap: 0.875rem;
    align-items: flex-start;
}

.hero-icon {
    font-size: 2.25rem;
    line-height: 1;
    flex-shrink: 0;
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--green-dim);
    border-radius: 14px;
}

.hero h2 {
    font-size: 1.2rem;
    margin-bottom: 0.2rem;
    line-height: 1.3;
}

.hero-sub {
    color: var(--green);
    font-weight: 700;
    font-size: 0.95rem;
}

.hero-desc {
    color: var(--text-secondary);
    margin-top: 0.5rem;
    font-size: 0.95rem;
    line-height: 1.5;
}

.hero-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.625rem;
    margin-top: 1.125rem;
    padding-top: 1.125rem;
    border-top: 1px solid var(--border);
}

.stat-box {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.75rem 0.875rem;
}

.stat-box .label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    font-weight: 600;
}

.stat-box .value {
    font-size: 1.2rem;
    font-weight: 700;
    margin-top: 0.2rem;
    color: var(--text);
    line-height: 1.2;
}

.stat-box .value.up {
    color: var(--green);
}

.stat-box .value.down {
    color: var(--red);
}

/* —— Cards —— */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}

.card h3 {
    font-size: 1.05rem;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.muted {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
}

.muted strong {
    color: var(--text);
}

/* —— Scenario form —— */
.scenario-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
}

.scenario-form label {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
}

.scenario-form input {
    font-family: inherit;
    font-size: 16px; /* iOS zoom önleme */
    min-height: var(--touch);
    padding: 0.65rem 0.875rem;
    border-radius: 10px;
    border: 1.5px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text);
}

.scenario-form input:focus {
    outline: none;
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(10, 143, 74, 0.15);
}

.scenario-form small {
    color: var(--muted);
    font-weight: 400;
    font-size: 0.8rem;
}

/* —— Timeline —— */
.timeline-section {
    margin-bottom: 1.25rem;
}

.timeline-section h3 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    padding: 0 0.125rem;
    color: var(--text);
}

.timeline {
    display: flex;
    gap: 0.625rem;
    overflow-x: auto;
    padding: 0.25rem 0.125rem 0.75rem;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.timeline::-webkit-scrollbar {
    display: none;
}

.timeline-item {
    flex: 0 0 auto;
    width: 118px;
    scroll-snap-align: start;
    text-align: center;
    padding: 0.875rem 0.5rem;
    border-radius: 12px;
    background: var(--bg-card);
    border: 2px solid var(--border);
    font-size: 0.72rem;
    line-height: 1.35;
    box-shadow: var(--shadow);
    color: var(--text-secondary);
}

.timeline-item strong {
    display: block;
    font-size: 0.8rem;
    color: var(--text);
    margin: 0.2rem 0;
}

.timeline-item .ti-status {
    display: block;
    margin-top: 0.25rem;
    font-weight: 600;
    font-size: 0.72rem;
}

.timeline-item .ti-icon {
    font-size: 1.75rem;
    display: block;
    margin-bottom: 0.2rem;
}

.timeline-item.status-waiting {
    border-color: var(--gray);
    background: var(--gray-dim);
}

.timeline-item.status-approaching {
    border-color: var(--yellow-border);
    background: var(--yellow-dim);
}

.timeline-item.status-now {
    border-color: var(--green-border);
    background: var(--green-dim);
    box-shadow: 0 0 0 1px var(--green-border);
}

.timeline-item.status-late {
    border-color: var(--red-border);
    background: var(--red-dim);
}

/* —— Sectors —— */
.sectors {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.sector-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.sector-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1.125rem;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, var(--bg-elevated) 0%, var(--bg-card) 100%);
}

.sector-icon {
    font-size: 1.75rem;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    flex-shrink: 0;
}

.sector-meta {
    flex: 1;
    min-width: 0;
}

.sector-meta h4 {
    font-size: 1.05rem;
    margin-bottom: 0.15rem;
    line-height: 1.25;
}

.sector-meta .phase {
    font-size: 0.78rem;
    color: var(--muted);
    font-weight: 500;
}

.sector-header > .badge {
    flex: 1 1 100%;
    justify-content: center;
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
    border: 1px solid transparent;
}

.badge-green {
    background: var(--green-dim);
    color: var(--green);
    border-color: var(--green-border);
}

.badge-yellow {
    background: var(--yellow-dim);
    color: var(--yellow);
    border-color: var(--yellow-border);
}

.badge-gray {
    background: var(--gray-dim);
    color: var(--muted);
    border-color: var(--border);
}

.badge-red {
    background: var(--red-dim);
    color: var(--red);
    border-color: var(--red-border);
}

.progress-wrap {
    margin-top: 0;
    padding: 0.875rem 1.125rem 0;
}

.progress-label {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.78rem;
    color: var(--muted);
    margin-bottom: 0.4rem;
    line-height: 1.35;
}

@media (min-width: 480px) {
    .progress-label {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
}

.progress-bar {
    height: 10px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 5px;
    transition: width 0.4s ease;
}

.progress-fill.green {
    background: linear-gradient(90deg, #0a8f4a, #22c55e);
}

.progress-fill.yellow {
    background: linear-gradient(90deg, #d97706, #f59e0b);
}

.progress-fill.red {
    background: linear-gradient(90deg, #dc2626, #ef4444);
}

.progress-fill.gray {
    background: var(--gray);
}

.sector-message {
    padding: 0.75rem 1.125rem 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.stocks-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem 1.125rem 1.125rem;
}

.stock-card {
    background: var(--bg-elevated);
    border-radius: 12px;
    padding: 1rem;
    border: 1.5px solid var(--border);
}

.stock-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.stock-top strong {
    font-size: 1rem;
    color: var(--text);
}

.stock-top span.code {
    font-size: 0.8rem;
    color: var(--muted);
    display: block;
    font-weight: 500;
    margin-top: 0.1rem;
}

.stock-price {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text);
    letter-spacing: -0.02em;
}

.stock-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.625rem;
}

.chip {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.3rem 0.55rem;
    border-radius: 8px;
    background: var(--bg-card);
    color: var(--muted);
    border: 1px solid var(--border);
}

.chip.up {
    color: var(--green);
    background: var(--green-dim);
    border-color: var(--green-border);
}

.chip.down {
    color: var(--red);
    background: var(--red-dim);
    border-color: var(--red-border);
}

.stock-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.45;
    padding-top: 0.5rem;
    border-top: 1px dashed var(--border);
}

.signal-strong {
    border-color: var(--green-border);
    background: var(--green-dim);
}

.signal-wait {
    border-color: var(--yellow-border);
    background: #fffdf8;
}

.signal-avoid {
    border-color: var(--red-border);
    background: var(--red-dim);
}

.footer {
    margin-top: 1.5rem;
    text-align: center;
    font-size: 0.8rem;
    color: var(--muted);
    line-height: 1.5;
    padding: 0 0.5rem;
}

.footer p + p {
    margin-top: 0.5rem;
}

.toast {
    position: fixed;
    bottom: calc(var(--bottom-nav-h) + 0.75rem + env(safe-area-inset-bottom, 0px));
    left: 1rem;
    right: 1rem;
    transform: none;
    background: var(--text);
    border: none;
    color: #fff;
    padding: 0.875rem 1.125rem;
    border-radius: 12px;
    font-size: 0.9rem;
    z-index: 100;
    box-shadow: var(--shadow-lg);
    text-align: center;
    line-height: 1.4;
}

.toast[hidden] {
    display: none;
}

.loading .sectors {
    opacity: 0.55;
    pointer-events: none;
}

@media (min-width: 600px) {
    .bottom-nav {
        max-width: 480px;
        left: 50%;
        transform: translateX(-50%);
        border-radius: 16px 16px 0 0;
        margin-bottom: 0;
    }
}

/* —— Tablet / desktop —— */
@media (min-width: 600px) {
    body.has-shell {
        padding-bottom: 1.5rem;
    }

    .bottom-nav {
        display: none;
    }

    .app-bar {
        position: sticky;
        top: 0;
    }

    body.has-install-banner .app-bar {
        top: calc(52px + env(safe-area-inset-top, 0px));
    }

    .app {
        max-width: 900px;
        padding: 1.5rem 1.5rem 3rem;
    }

    .header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .header-actions {
        width: auto;
    }

    .header-actions .btn {
        width: auto;
        min-width: 180px;
    }

    .brand h1 {
        font-size: 1.5rem;
    }

    .hero {
        padding: 1.5rem;
    }

    .hero h2 {
        font-size: 1.35rem;
    }

    .hero-stats {
        grid-template-columns: repeat(4, 1fr);
    }

    .scenario-form {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
    }

    .scenario-form .btn-primary {
        grid-column: 1 / -1;
        max-width: 280px;
    }

    .sector-header > .badge {
        flex: 0 0 auto;
        margin-left: auto;
    }

    .stocks-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
    }

    .timeline-item {
        width: 130px;
    }
}

@media (min-width: 900px) {
    .stocks-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
