/* ===== Integrations (historical name — legal/auth chrome, not Telegram/webhooks) ===== */
.integration-card {
    background: rgba(255, 255, 255, 0.03); /* integration card bg */
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1rem 1.2rem;
    transition: border-color 0.2s;
}

.integration-card:hover {
    border-color: var(--accent-blue-border);
}

.integration-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.integration-icon {
    font-size: var(--text-heading);
}

.integration-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: var(--text-heading);
}

.integration-status {
    font-size: var(--text-caption);
    color: var(--text-secondary);
    margin-left: auto;
}

.integration-status.connected {
    color: var(--accent-green);
    font-weight: 600;
}

.integration-desc {
    font-size: var(--text-caption);
    color: var(--text-secondary);
    margin: 0.25rem 0 0.75rem 0;
    line-height: 1.5;
}

.integration-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Utility: checkbox-inline (used by chart-display.html) */
.checkbox-inline {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

/* Utility: apply optimal settings button */
.btn-apply-optimal {
    margin-top: var(--space-md);
}

/* Trade Plan Block */
.trade-plan-block {
    margin-top: 0.6rem;
    padding: 0.6rem 0.8rem;
    background: linear-gradient(135deg, var(--accent-blue-bg-strong), var(--accent-blue-bg));
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: var(--text-caption);
}

.trade-plan-header {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.4rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.trade-dir {
    font-size: var(--text-caption);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
}

.trade-plan-levels {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.tp-row {
    display: flex;
    gap: 0.4rem;
    align-items: baseline;
}

.tp-label {
    font-weight: 700;
    font-size: var(--text-caption);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.tp-entry .tp-label {
    color: var(--accent-green);
}

.tp-stop .tp-label {
    color: var(--accent-red);
}

.tp-value {
    color: var(--text-primary);
    font-weight: 600;
}

.tp-value small {
    color: var(--text-secondary);
    font-weight: 400;
}

.trade-plan-steps {
    border-top: 1px solid var(--border-color);
    padding-top: 0.4rem;
}

.tp-step {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 0.2rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.tp-step-num {
    color: var(--accent-blue);
    flex-shrink: 0;
}

/* Modal Navigation */
.modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-scrim);
    border: 1px solid rgba(255, 255, 255, 0.2); /* modal nav border */
    color: white;
    font-size: var(--text-display);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 1001;
}

.modal-nav:hover {
    background: var(--bg-active);
}

.modal-prev {
    left: 20px;
}

.modal-next {
    right: 20px;
}

.modal-counter {
    text-align: center;
    color: var(--text-secondary);
    font-size: var(--text-caption);
    margin-top: 0.5rem;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: calc(var(--nav-height) + 0.75rem);
    right: 1.5rem;
    bottom: auto;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 0.8rem 1.2rem;
    border-radius: 8px;
    color: white;
    font-size: var(--text-body);
    box-shadow: var(--shadow-toast);
    animation: toast-in 0.3s ease, toast-out 0.3s ease 3.7s;
    min-width: 250px;
    max-width: 400px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toast-success {
    background: linear-gradient(135deg, #238636, #2ea043);
    border-left: 4px solid #3fb950;
}

.toast-error {
    background: linear-gradient(135deg, #b62324, #da3633);
    border-left: 4px solid #f85149;
}

.toast-info {
    background: linear-gradient(135deg, #1a5276, #1f6feb);
    border-left: 4px solid #58a6ff;
}

@keyframes toast-in {
    0% {
        transform: translateX(100%) translateY(20px);
        opacity: 0;
    }
    70% {
        transform: translateX(-5%) translateY(0);
        opacity: 1;
    }
    100% {
        transform: translateX(0) translateY(0);
        opacity: 1;
    }
}

@keyframes toast-out {
    from {
        transform: translateX(0) translateY(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%) translateY(20px);
        opacity: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    @keyframes toast-in {
        from { opacity: 0; }
        to { opacity: 1; }
    }

    @keyframes toast-out {
        from { opacity: 1; }
        to { opacity: 0; }
    }

    .toast {
        animation: toast-in 0.15s ease forwards,
                   toast-out 0.15s ease 3.85s forwards;
    }
}

/* Loading State */
.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-top: -8px;
    margin-left: -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* Macro Pulse Bar */
.macro-pulse-bar {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.macro-pill {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.75rem;
    border-radius: 16px;
    font-size: var(--text-caption);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    transition: transform 0.15s ease;
}

.macro-pill:hover {
    transform: translateY(-1px);
}

.macro-pill.macro-up {
    border-color: var(--accent-green);
}

.macro-pill.macro-down {
    border-color: var(--accent-red);
}

.macro-emoji {
    font-size: var(--text-body);
}

.macro-name {
    color: var(--text-secondary);
    font-size: var(--text-caption);
    font-weight: 500;
}

.macro-value {
    font-weight: 700;
    color: var(--text-primary);
}

.macro-change {
    font-size: var(--text-caption);
    font-weight: 600;
}

.macro-change.macro-up {
    color: var(--accent-green);
}

.macro-change.macro-down {
    color: var(--accent-red);
}

.macro-change.macro-flat {
    color: var(--text-secondary);
}

/* Traffic Light Bar */
.traffic-light-bar {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.tl-pill {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: var(--text-caption);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border-color);
}

.tl-pill.tl-green {
    background: var(--accent-green-bg-strong);
    border-color: var(--accent-green);
}

.tl-pill.tl-yellow {
    background: var(--accent-warning-bg-strong);
    border-color: var(--accent-warning);
}

.tl-pill.tl-red {
    background: var(--accent-red-bg);
    border-color: var(--accent-red);
}

.tl-emoji {
    font-size: var(--text-heading);
}

.tl-name {
    font-weight: 600;
    color: var(--text-primary);
}

.tl-label {
    font-weight: 500;
}

.tl-green .tl-label {
    color: var(--accent-green);
}

.tl-yellow .tl-label {
    color: var(--accent-warning);
}

.tl-red .tl-label {
    color: var(--accent-red);
}

.tl-slopes {
    color: var(--text-secondary);
    font-size: var(--text-caption);
}

/* Help Page — sheet craft on the existing dark tokens (not a light iOS theme) */
.help-content {
    max-width: 700px;
    margin: 0 auto;
    padding-top: 0.25rem;
}

.help-content h1 {
    font-size: 1.65rem;
    margin: 0 2.5rem var(--space-lg) 0;
    color: var(--accent-blue);
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1.25;
}

/* Help ToC — grouped list navigation */
.help-toc {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    padding: var(--space-md) var(--space-lg);
    margin-bottom: var(--space-lg);
    overflow: hidden;
}

.help-toc > summary {
    padding: 0 0 var(--space-sm);
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
}

.help-toc > summary::-webkit-details-marker {
    display: none;
}

.help-toc > summary::marker {
    display: none;
    content: "";
}

.help-toc > summary h3 {
    font-size: var(--text-heading);
    color: var(--text-primary);
    margin: 0;
    font-weight: 600;
    line-height: 1.4;
}

.help-toc > summary::after {
    content: "";
    display: inline-block;
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--text-dim);
    border-bottom: 2px solid var(--text-dim);
    transform: rotate(45deg);
    transition: transform 0.25s ease;
    flex-shrink: 0;
    margin-left: var(--space-sm);
    opacity: 0.6;
}

.help-toc[open] > summary::after {
    transform: rotate(-135deg);
}

.help-toc-section-title {
    font-size: var(--text-caption);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-dim);
    margin: 0 0 var(--space-xs) 0;
    padding: 0;
}

.help-toc-section {
    list-style: none;
    margin: 0;
    padding: 0;
}

.help-toc-section li {
    margin: 0;
    padding: 0;
}

.help-toc-section a {
    display: block;
    font-size: var(--text-body);
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.45rem 0.6rem;
    margin: 0 -0.6rem;
    transition: color 0.15s ease, background 0.15s ease;
    border-radius: var(--radius-sm);
}

.help-toc-section a:hover {
    color: var(--text-primary);
    background: var(--bg-hover-light);
}

.help-toc-divider {
    border: none;
    border-top: 1px solid var(--border-subtle);
    margin: var(--space-sm) 0;
}

/* Help section cards (details elements) */
.help-section {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    margin-bottom: var(--space-md);
    overflow: hidden;
    transition: border-color 0.2s ease;
}

.help-section[open] {
    border-color: var(--border-color);
}

.help-section > summary {
    padding: var(--space-md) var(--space-lg);
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    transition: background 0.2s ease;
}

.help-section > summary::-webkit-details-marker {
    display: none;
}

.help-section > summary::marker {
    display: none;
    content: "";
}

.help-section > summary:hover {
    background: rgba(255, 255, 255, 0.03);
}

.help-section > summary h2 {
    font-size: var(--text-heading);
    color: var(--text-primary);
    margin: 0;
    font-weight: 600;
    line-height: 1.4;
}

/* Chevron indicator */
.help-section > summary::after {
    content: "";
    display: inline-block;
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--text-dim);
    border-bottom: 2px solid var(--text-dim);
    transform: rotate(45deg);
    transition: transform 0.25s ease;
    flex-shrink: 0;
    margin-left: var(--space-sm);
    opacity: 0.6;
}

.help-section[open] > summary::after {
    transform: rotate(-135deg);
}

.help-section .section-body {
    padding: 0 var(--space-lg) var(--space-lg);
}

.help-text {
    line-height: 1.75;
    color: var(--text-secondary);
}

.help-text p {
    margin-bottom: 0.8rem;
}

.help-text h3 {
    color: var(--text-primary);
    margin: 1.2rem 0 0.5rem;
    font-size: var(--text-heading);
    font-weight: 600;
}

.help-text ul {
    margin: 0.5rem 0 1rem 1.5rem;
}

.help-text li {
    margin-bottom: 0.4rem;
}

.help-text code {
    background: var(--bg-input);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: var(--text-caption);
    color: var(--accent-blue);
}

.help-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.8rem 0;
}

.help-table td {
    padding: 0.5rem 0.8rem;
    border-bottom: 1px solid var(--border-color);
}

.help-table tr:last-child td {
    border-bottom: none;
}

/* Help overlay must not scroll — only .help-modal-body does.
   overflow:auto + flex-center + 100vh child pushes the dialog off-canvas. */
#help-modal.modal {
    overflow: hidden;
    padding: 0;
    align-items: center;
    justify-content: center;
}

/* Help Modal body */
.help-modal-body {
    position: relative;
    max-width: 780px;
    width: min(780px, 92vw);
    max-height: min(90vh, 100%);
    height: auto;
    overflow-y: auto;
    background: var(--bg-modal);
    border: 1px solid var(--border-subtle);
    border-radius: 20px;
    padding: var(--space-xl);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55), var(--shadow-modal);
    scroll-padding-top: var(--space-md);
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
    #help-modal.modal {
        align-items: stretch;
        justify-content: stretch;
    }

    #help-modal .help-modal-body {
        width: 100%;
        max-width: none;
        height: 100%;
        max-height: none;
        min-height: 0;
        border-radius: 0;
        margin: 0;
    }
}

#help-modal .modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    background: var(--bg-hover-medium);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    font-size: 1.35rem;
    font-weight: 500;
}

.help-search-wrap {
    position: sticky;
    top: calc(-1 * var(--space-xl));
    z-index: 2;
    margin: 0 calc(-0.25rem) var(--space-lg);
    padding: 0.15rem 0.25rem 0.75rem;
    background: var(--bg-modal);
}

.help-search {
    width: 100%;
    padding: 0.7rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: var(--text-body);
    font-family: inherit;
}

.help-search:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px var(--accent-blue-glow);
}

.help-search-empty {
    margin: 0.6rem 0 0;
    color: var(--text-secondary);
    font-size: var(--text-caption);
}

mark.help-search-hit {
    background: rgba(59, 130, 246, 0.35);
    color: inherit;
    border-radius: 2px;
    padding: 0 0.1em;
}


.portfolio-dashboard {
    /* 800px clipped the last columns (closed-trade date, % change) once
       secondary columns appear at ≥1200px (#1157). Match performance tables. */
    max-width: 1100px;
}

.portfolio-dashboard .section-body {
    overflow-x: auto;
}

.portfolio-summary-bar {
    display: flex;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.pnl-card {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.pnl-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-soft);
}

.pnl-label {
    font-size: var(--text-caption);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pnl-value {
    font-size: var(--text-title);
    font-weight: 700;
}

.pnl-positive {
    color: var(--accent-green);
}

.pnl-negative {
    color: var(--accent-red);
}

.pnl-missing {
    color: var(--text-muted, #64748b);
}

.portfolio-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-body);
}

.portfolio-table th {
    text-align: left;
    padding: 0.6rem 0.8rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    font-weight: 500;
    font-size: var(--text-caption);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

/* Closed-trade date must stay readable (de-DE "31.12.2025") (#1157). */
.portfolio-table .col-date {
    white-space: nowrap;
    min-width: 8rem;
}

.portfolio-table td {
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid rgba(48, 54, 61, 0.5); /* table row border */
}

.portfolio-table tbody tr:hover {
    background: var(--bg-input);
}

.portfolio-table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.015); /* zebra stripe */
}

.portfolio-table tbody tr:nth-child(even):hover {
    background: var(--bg-input);
}

.portfolio-table tbody tr:last-child td {
    border-bottom: none;
}

/* Sortable table headers */
.sortable-th {
    cursor: pointer;
    user-select: none;
    transition: color 0.15s ease;
}

.sortable-th:hover {
    color: var(--accent-blue);
}

.sortable-th.sort-active {
    color: var(--text-primary);
    font-weight: 600;
}

.sort-arrow {
    font-size: var(--text-caption);
    opacity: 0.7;
}
/* Expandable rows */
.expand-toggle {
    width: 32px;
    padding-left: 0.4rem;
    padding-right: 0.4rem;
    text-align: center;
}

.expand-icon {
    display: inline-block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    transition: transform 200ms ease;
}

.summary-row {
    cursor: pointer;
}

.summary-row[aria-expanded="true"] .expand-icon {
    transform: rotate(90deg);
}

/* Secondary columns - hidden by default on mobile */
.portfolio-table th[data-column="secondary"],
.portfolio-table td[data-column="secondary"] {
    display: none;
}

/* Detail row */
.detail-row {
    display: none;
}

.detail-row.expanded {
    display: table-row;
    animation: detailFadeIn 200ms ease;
}

@keyframes detailFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.detail-row td {
    background: var(--bg-input);
    padding: 0;
    border-bottom: 1px solid var(--border-color);
}

.detail-card {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.75rem;
    padding: 1rem 0.8rem;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.detail-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-value {
    font-size: 0.9rem;
    font-weight: 500;
}

/* Desktop: show all columns, hide expand */
@media (min-width: 1200px) {
    .portfolio-table th[data-column="secondary"],
    .portfolio-table td[data-column="secondary"] {
        display: table-cell;
    }

    .expand-toggle {
        display: none;
    }

    .detail-row {
        display: none !important;
    }
}

/* Ensure touch targets on mobile */
@media (max-width: 1199px) {
    .summary-row td {
        padding-top: 0.75rem;
        padding-bottom: 0.75rem;
    }
}

/* Canceled trades banner (gallery) */
.canceled-trades-banner {
    background: var(--accent-warning-bg);
    border: 1px solid var(--accent-warning);
    border-radius: var(--radius);
    padding: 0.6rem 1rem;
    margin-bottom: 1rem;
    transition: all 0.3s ease;
}

.canceled-details summary {
    list-style: none;
    /* Hide default arrow in some browsers */
}

.canceled-details summary::-webkit-details-marker {
    display: none;
    /* Hide default arrow in Chrome/Safari */
}

.canceled-header {
    color: var(--accent-warning);
    font-weight: 600;
    font-size: var(--text-caption);
    margin-bottom: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    user-select: none;
}

.canceled-details[open] .canceled-header {
    margin-bottom: 0.8rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--accent-warning-border);
}

.canceled-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    max-height: 150px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

/* Custom scrollbar for the small list */
.canceled-list::-webkit-scrollbar {
    width: 6px;
}

.canceled-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1); /* scrollbar track */
    border-radius: 3px;
}

.canceled-list::-webkit-scrollbar-thumb {
    background: var(--accent-warning);
    border-radius: 3px;
}

.canceled-list::-webkit-scrollbar-thumb:hover {
    background: rgba(210, 153, 34, 0.5);
}

.canceled-item {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.2rem 0.6rem;
    font-size: var(--text-caption);
    color: var(--text-secondary);
}

.canceled-item small {
    color: var(--accent-warning);
}

/* Input group for selects in settings */
.input-group select,
.settings-field select {
    padding: 0.6rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: var(--text-body);
    width: 100%;
    margin-top: 0.3rem;
    appearance: auto;
    cursor: pointer;
}

