/* Trading agents tab — section title + hero (aligned with Trade Picks / Alerts) */
.autotrade-section-modern {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Three fixed agents: 3 columns desktop/tablet, 1 column mobile */
.automation-fixed-agents-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-top: 12px;
    margin-bottom: 8px;
}

@media (max-width: 639px) {
    .automation-fixed-agents-grid {
        grid-template-columns: 1fr;
    }
}

.automation-ares-status-card-wide {
    margin-bottom: 4px;
}

.automation-agent-fixed-card.is-active-slot {
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.55);
    background: linear-gradient(
        180deg,
        rgba(16, 185, 129, 0.22),
        rgba(16, 185, 129, 0.09)
    );
    border-color: rgba(16, 185, 129, 0.52);
    align-items: flex-start;
    text-align: left;
    padding: 16px 18px;
    gap: 8px;
}

.automation-agent-fixed-card {
    min-height: 180px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    gap: 12px;
    cursor: pointer;
}

.automation-agent-fixed-card.automation-ares-card {
    border-radius: 6px;
}

.automation-agent-fixed-card.automation-ares-card h4 {
    font-size: calc(20px + 2pt);
}

.automation-agent-fixed-card.automation-ares-card .btn-modern {
    font-size: calc(13px + 2pt);
}

.automation-agent-fixed-card .sub {
    display: none !important;
}

.automation-agent-fixed-card:not(.is-active-slot) .automation-agent-label-wrap,
.automation-agent-fixed-card:not(.is-active-slot) .automation-budget-row,
.automation-agent-fixed-card:not(.is-active-slot) [data-agent-action="save"] {
    display: none !important;
}

.automation-agent-fixed-card.is-active-slot .automation-agent-label-wrap {
    display: flex !important;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    text-align: left;
}

.automation-agent-fixed-card.is-active-slot .automation-budget-row {
    display: flex !important;
    flex-direction: column;
    width: 100%;
    align-items: stretch;
    text-align: left;
}

.automation-agent-fixed-card.is-active-slot [data-agent-action="save"] {
    display: inline-flex !important;
}

.automation-agent-active-summary {
    margin: 0;
    font-size: 14px;
    color: var(--text-secondary);
    display: none;
    line-height: 1.45;
    letter-spacing: 0.01em;
}

.automation-agent-fixed-card.is-active-slot .automation-agent-active-summary {
    display: block;
    color: #083344;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.65);
    border: 1px solid rgba(6, 95, 70, 0.16);
    border-radius: 6px;
    padding: 8px 10px;
    width: 100%;
    box-sizing: border-box;
    font-size: calc(14px + 2pt);
}

.automation-agent-fixed-card .automation-agent-card-actions {
    margin: 0;
    justify-content: center;
}

.automation-agent-fixed-card.is-active-slot .automation-agent-card-actions {
    width: 100%;
    justify-content: flex-start;
}

.automation-agent-fixed-card.is-active-slot [data-agent-action="activate"] {
    display: none;
}

.automation-agent-fixed-card.is-hash-focus {
    outline: 2px solid rgba(59, 130, 246, 0.7);
    outline-offset: 2px;
}

.automation-agent-fixed-card.is-inactive-slot {
    opacity: 0.76;
    filter: saturate(0.75);
    background: linear-gradient(
        180deg,
        rgba(148, 163, 184, 0.08),
        rgba(148, 163, 184, 0.03)
    );
    border-color: rgba(148, 163, 184, 0.35);
    min-height: 220px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    gap: 14px;
}

.automation-agent-fixed-card.is-inactive-slot h4 {
    margin: 0;
    font-size: calc(26px + 2pt);
    line-height: 1.2;
}

.automation-agent-fixed-card.is-inactive-slot .sub,
.automation-agent-fixed-card.is-inactive-slot [data-agent-action="save"] {
    display: none !important;
}

.automation-agent-fixed-card.is-inactive-slot .automation-agent-card-actions {
    margin: 0;
    justify-content: center;
}

.automation-agent-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1200;
    background: rgba(2, 6, 23, 0.72);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.automation-agent-modal {
    width: min(680px, 96vw);
    max-height: min(92vh, 100dvh);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
}

.automation-agent-modal-header {
    flex-shrink: 0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 16px 10px;
    border-bottom: 1px solid var(--border-color);
}

.automation-agent-modal-header h4 {
    margin: 0;
    font-size: 22px;
}

.automation-agent-modal-sub {
    margin: 4px 0 0;
    color: var(--text-secondary);
    font-size: 13px;
}

.automation-agent-modal-close {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 16px;
    padding: 6px;
    border-radius: 8px;
    cursor: pointer;
}

.automation-agent-modal-close:hover {
    background: rgba(148, 163, 184, 0.15);
    color: var(--text-primary);
}

.automation-agent-modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.automation-agent-modal-status {
    margin: 2px 0 0;
    min-height: 1.2em;
}

.automation-agent-modal-footer {
    flex-shrink: 0;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
    padding: 12px 16px 16px;
    border-top: 1px solid var(--border-color);
}

@media (max-width: 1023px) {
    .automation-agent-fixed-card.is-active-slot {
        padding: 14px;
        gap: 8px;
    }

    .automation-agent-fixed-card.is-inactive-slot {
        min-height: 180px;
        padding: 18px 14px;
    }

    .automation-agent-fixed-card.is-inactive-slot h4 {
        font-size: calc(22px + 2pt);
    }

    .automation-agent-fixed-card h4 {
        font-size: calc(22px + 2pt);
    }

    .automation-agent-fixed-card.automation-ares-card h4 {
        font-size: calc(22px + 2pt);
    }

    .automation-agent-active-summary {
        font-size: calc(13px + 2pt);
    }
}

.automation-agent-label-wrap {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.automation-agent-label-wrap input {
    width: 100%;
    box-sizing: border-box;
}

.automation-agent-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.autotrade-position-header {
    margin-top: 4px;
    border-bottom: none !important;
    padding-bottom: 0 !important;
    margin-bottom: 0 !important;
    min-height: 68px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    width: 100%;
    box-sizing: border-box;
}

.autotrade-position-header .hero-secondary-icon {
    order: -1;
}

.autotrade-header-leading {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.autotrade-position-header .section-title-modern {
    display: flex;
    align-items: center;
}

.autotrade-hero-modern {
    padding: 32px;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.12), rgba(59, 130, 246, 0.08));
}

/* Tighter header → hero (shared rule adds margin-top on all dismissible heroes) */
#tab-trading-agents-modern .autotrade-hero-modern.hero-panel-dismissible {
    margin-top: -10px !important;
}

.autotrade-hero-content {
    display: flex;
    align-items: center;
    gap: 24px;
}

.autotrade-icon-large {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, #10b981, #3b82f6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 36px;
    flex-shrink: 0;
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.28);
}

.autotrade-hero-text {
    flex: 1;
}

.autotrade-hero-title {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0 0 8px 0;
    letter-spacing: -0.5px;
}

.autotrade-hero-description {
    font-size: 18px;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.6;
}

@media (max-width: 639px) {
    .autotrade-hero-content {
        flex-direction: column;
        align-items: flex-start;
        text-align: left;
    }

    .autotrade-icon-large {
        width: 64px;
        height: 64px;
        font-size: 28px;
    }

    .autotrade-hero-title {
        font-size: 22px;
    }
}

.automation-ares-tab {
    display: grid;
    gap: 14px;
}

.automation-ares-panel {
    border: 1px solid var(--border-color);
    border-radius: 14px;
    overflow: hidden;
    background: var(--bg-glass);
}

.automation-ares-panel-hero {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 16px;
    border-radius: 6px 6px 0 0;
}

.automation-ares-panel-hero h3 {
    margin: 0;
    font-size: calc(22px + 2pt);
}

.automation-ares-panel-hero p {
    margin: 8px 0 0;
    color: var(--text-secondary);
    font-size: calc(17px + 2pt);
}

.automation-ares-kpi-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.automation-ares-kpi {
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    border-radius: 10px;
    padding: 10px 11px;
}

.automation-ares-kpi .k {
    display: block;
    font-size: calc(13px + 2pt);
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.automation-ares-kpi .v {
    font-size: calc(18px + 2pt);
    font-weight: 800;
}

.automation-ares-content {
    padding: 16px;
    display: grid;
    row-gap: 16px;
    column-gap: 12px;
}

.automation-ares-detached {
    padding: 0;
    display: grid;
    row-gap: 16px;
    column-gap: 12px;
}

.automation-ares-grid {
    display: grid;
    row-gap: 16px;
    column-gap: 12px;
}

.automation-ares-grid-3 {
    grid-template-columns: 1fr 1fr 1fr;
}

.automation-ares-grid-2 {
    grid-template-columns: 1fr 1fr;
}

.automation-ares-detached .automation-ares-grid-2 > .automation-ares-card {
    margin-top: 10px;
    margin-bottom: 10px;
}

.automation-ares-card {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-secondary);
    padding: 14px;
}

.automation-ares-card h4 {
    margin: 0;
    font-size: 20px;
    letter-spacing: 0.15px;
}

.automation-ares-card .sub {
    margin: 5px 0 0;
    color: var(--text-secondary);
    font-size: 16px;
}

.automation-ares-switch-row {
    margin-top: 10px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-primary);
    padding: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    font-size: 13px;
}

.automation-ares-toggle {
    position: relative;
    width: 46px;
    height: 24px;
    flex-shrink: 0;
}

.automation-ares-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.automation-ares-toggle .slider {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: #64748b;
    transition: 0.2s;
    cursor: pointer;
}

.automation-ares-toggle .slider::before {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    top: 3px;
    left: 3px;
    border-radius: 50%;
    background: #fff;
    transition: 0.2s;
}

.automation-ares-toggle input:checked + .slider {
    background: #10b981;
}

.automation-ares-toggle input:checked + .slider::before {
    transform: translateX(22px);
}

.automation-ares-actions {
    margin-top: 12px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.automation-ares-line {
    margin-top: 10px;
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 13px;
}

.automation-budget-card .automation-budget-row {
    margin-top: 12px;
    padding: 10px 11px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-primary);
}

.automation-budget-row-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 8px;
}

.automation-budget-label {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.automation-budget-hint {
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.automation-budget-segmented {
    display: flex;
    gap: 6px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    padding: 4px;
}

.automation-budget-opt {
    flex: 1;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    padding: 8px 10px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.automation-budget-opt:hover {
    color: var(--text-primary);
    background: rgba(59, 130, 246, 0.08);
}

.automation-budget-opt.active {
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid rgba(59, 130, 246, 0.45);
    color: var(--text-primary);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.automation-budget-segmented-many {
    flex-wrap: wrap;
    justify-content: center;
    border-radius: 12px;
}

.automation-budget-segmented-many .automation-budget-opt {
    flex: 0 1 auto;
    min-width: 2.35rem;
    padding: 7px 8px;
    font-size: 12px;
}

.automation-agent-modal-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-color);
}

.automation-agent-modal-section:last-of-type {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.automation-agent-modal-section-title {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.automation-agent-modal-section-title .fas {
    opacity: 0.75;
    font-size: 13px;
}

.automation-agent-modal-section-sub {
    margin: 0;
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.45;
}

.automation-agent-toggle-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 14px;
}

@media (max-width: 560px) {
    .automation-agent-toggle-grid {
        grid-template-columns: 1fr;
    }
}

.automation-agent-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 12px;
    color: var(--text-primary);
    padding: 8px 10px;
    border-radius: 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
}

.automation-agent-toggle-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    accent-color: var(--primary, #3b82f6);
}

.automation-agent-toggle-row-single {
    max-width: 100%;
}

.automation-agent-range-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 6px;
}

.automation-agent-range-row > label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}

.automation-agent-range-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}

.automation-agent-range-wrap input[type="range"] {
    flex: 1;
    min-width: 0;
    accent-color: var(--primary, #3b82f6);
}

.automation-agent-range-readout {
    font-size: 13px;
    font-weight: 700;
    min-width: 3rem;
    text-align: right;
    color: var(--text-primary);
}

.automation-budget-usage {
    margin-top: 14px;
}

.automation-budget-cap-hint {
    margin: 6px 0 0;
}

.automation-budget-save-status {
    margin: 8px 0 0;
    min-height: 1.2em;
}

.automation-ares-chip-row {
    margin-top: 10px;
    display: flex;
    gap: 7px;
    flex-wrap: wrap;
}

.automation-ares-chip {
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 700;
    padding: 4px 9px;
}

.automation-ares-chip.ok {
    border-color: rgba(16, 185, 129, 0.45);
    background: rgba(16, 185, 129, 0.12);
    color: #067161;
}

.automation-ares-chip.off {
    opacity: 0.55;
    filter: grayscale(20%);
}

.automation-days-card .automation-days-glance {
    margin-top: 12px;
}

.automation-days-chip-strip {
    margin-top: 0;
}

.automation-days-editor {
    margin-top: 12px;
}

.automation-days-editor .automation-days-actions {
    margin-top: 12px;
}

.automation-days-summary-line {
    margin: 10px 0 0;
    font-weight: 600;
    font-size: 15px;
    text-align: center;
}

.automation-days-save-status {
    margin: 6px 0 0;
    min-height: 1.2em;
}

.automation-day-grid-modern {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
    padding: 4px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 999px;
}

.automation-day-pill {
    flex: 1;
    min-width: 52px;
    position: relative;
    margin: 0;
    cursor: pointer;
    text-align: center;
}

.automation-day-pill input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    margin: 0;
}

.automation-day-pill span {
    display: block;
    border-radius: 999px;
    padding: 8px 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid transparent;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.automation-day-pill:hover span {
    color: var(--text-primary);
    background: rgba(59, 130, 246, 0.08);
}

.automation-day-pill input:checked + span {
    color: var(--text-primary);
    background: rgba(16, 185, 129, 0.18);
    border-color: rgba(16, 185, 129, 0.5);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.automation-day-pill input:focus-visible + span {
    outline: 2px solid rgba(59, 130, 246, 0.6);
    outline-offset: 2px;
}

.automation-fine {
    color: var(--text-secondary);
    font-size: 13px;
}

.automation-ares-queue {
    margin-top: 10px;
    display: grid;
    gap: 8px;
}

.automation-ares-queue .q-row {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-secondary);
    padding: 10px 11px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-size: 12px;
    margin-bottom: 10px;
}

.automation-ares-queue .q-row:last-child {
    margin-bottom: 0;
}

.automation-ares-queue .q-main {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.automation-ares-queue .sym {
    font-weight: 700;
}

.automation-ares-queue .q-mini-swap {
    display: flex;
    align-items: stretch;
    gap: 10px;
}

.automation-ares-queue .q-mini-swap.q-mini-swap--buy-only {
    gap: 0;
}

.automation-ares-queue .q-mini-leg-link {
    display: block;
    flex: 1 1 0;
    min-width: 0;
    color: inherit;
    text-decoration: none;
}

.automation-ares-queue .q-mini-leg.q-mini-leg--clickable {
    cursor: pointer;
}

.automation-ares-queue .q-mini-leg.q-mini-leg--clickable:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
    border-color: var(--primary);
}

.automation-ares-queue .q-mini-leg {
    flex: 1 1 0;
    min-width: 0;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    padding: 9px 10px;
    background: var(--bg-primary);
    transition: var(--transition);
}

.automation-ares-queue .q-mini-leg.q-mini-leg--sell {
    border-left: 3px solid rgba(239, 68, 68, 0.85);
}

.automation-ares-queue .q-mini-leg.q-mini-leg--buy {
    border-left: 3px solid rgba(16, 185, 129, 0.9);
}

.automation-ares-queue .q-mini-leg-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 5px;
}

.automation-ares-queue .q-mini-leg-title {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.automation-ares-queue .q-mini-pill {
    font-size: calc(14px + 2pt);
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    border-radius: 6px;
    padding: 4px 7px;
    line-height: 1;
}

.automation-ares-queue .q-mini-pill.q-mini-pill--sell {
    background: rgba(239, 68, 68, 0.14);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.28);
}

.automation-ares-queue .q-mini-pill.q-mini-pill--buy {
    background: rgba(16, 185, 129, 0.14);
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.28);
}

.automation-ares-queue .q-mini-ticker {
    font-size: 17px;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.2;
    color: var(--text-primary);
}

.automation-ares-queue .q-mini-price {
    font-size: 17px;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.2;
    color: var(--text-primary);
    text-align: right;
    white-space: nowrap;
    margin-left: auto;
}

.automation-ares-queue .q-mini-quote {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    margin-left: auto;
    min-width: fit-content;
}

.automation-ares-queue .q-mini-quote-detail {
    margin-top: 2px;
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.1;
    white-space: nowrap;
}

.automation-ares-queue .q-mini-yf-company-name {
    margin: 8px 0 0;
    font-size: calc(15px + 2pt);
    font-weight: 700;
    line-height: 1.3;
    color: var(--text-primary);
    width: 100%;
}

.automation-ares-queue .q-mini-leg-meta {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-wrap: wrap;
    gap: 5px 7px;
    align-items: center;
}

.automation-ares-queue .artemis-yf-meta-wrap--queue {
    margin-top: 8px;
    width: 100%;
    min-width: 0;
}

.automation-ares-queue .artemis-yf-meta-line--queue {
    display: none !important;
}

.automation-ares-queue .artemis-yf-description-text {
    font-size: 10px;
    line-height: 1.4;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
}

.automation-ares-queue
    .artemis-yf-meta-wrap--queue.artemis-yf-meta-wrap--desc-expanded
    .artemis-yf-description-text {
    display: block;
    -webkit-line-clamp: unset;
    overflow: visible;
}

.automation-ares-queue .artemis-yf-description-more {
    font-size: 10px;
}

.automation-ares-queue .q-mini-company {
    width: 100%;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
}

.automation-ares-queue .q-mini-submeta {
    font-size: calc(10px + 2pt);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    border-radius: 6px;
    padding: 2px 6px;
    line-height: 1.25;
}

.automation-ares-queue .stage-badge-modern {
    border-radius: 6px;
    font-size: calc(12px + 2pt);
}

.automation-ares-queue .q-mini-submeta.q-mini-submeta--pl {
    font-weight: 600;
}

.automation-ares-queue .q-mini-realized-pl-wrap {
    margin-top: 6px;
}

.automation-ares-queue .q-mini-submeta.q-mini-submeta--pl {
    font-weight: 800;
}

.automation-ares-queue .q-mini-submeta.q-mini-submeta--pl.positive {
    color: var(--success, #16a34a);
    border-color: color-mix(in srgb, var(--success, #16a34a) 45%, var(--border-color));
    background: color-mix(in srgb, var(--success, #16a34a) 12%, var(--bg-secondary));
}

.automation-ares-queue .q-mini-submeta.q-mini-submeta--pl.negative {
    color: var(--danger, #dc2626);
    border-color: color-mix(in srgb, var(--danger, #dc2626) 45%, var(--border-color));
    background: color-mix(in srgb, var(--danger, #dc2626) 12%, var(--bg-secondary));
}

.automation-ares-queue .q-mini-bridge {
    width: 28px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.automation-ares-queue .q-mini-bridge-line {
    width: 2px;
    min-height: 12px;
    flex: 1;
    background: linear-gradient(
        180deg,
        transparent,
        var(--border-color) 20%,
        var(--border-color) 80%,
        transparent
    );
}

.automation-ares-queue .q-mini-bridge-icon {
    width: 22px;
    height: 22px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    margin: 4px 0;
}

.automation-ares-queue .q-mini-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.automation-ares-queue .q-mini-chip {
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 3px 7px;
    line-height: 1;
}

.automation-ares-queue .q-mini-chip.q-mini-chip--swap {
    border-color: rgba(59, 130, 246, 0.42);
    color: #2563eb;
}

.automation-ares-queue .q-mini-chip.q-mini-chip--cash {
    border-color: rgba(16, 185, 129, 0.42);
    color: #059669;
}

.automation-queue-pager {
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.automation-queue-page-text {
    font-size: 14px;
    color: var(--text-secondary);
    text-align: center;
}

.automation-queue-pager .btn-modern {
    font-size: 14px;
}

.automation-ares-feed {
    margin: 10px 0 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 8px;
}

.automation-ares-feed li.automation-feed-item {
    border-left: 3px solid rgba(59, 130, 246, 0.55);
    border-radius: 8px;
    background: var(--bg-primary);
    padding: 10px 12px;
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr) minmax(76px, auto);
    gap: 10px 12px;
    align-items: start;
    font-size: calc(12px + 2pt);
}

.automation-ares-feed li.automation-feed-item--close {
    border-left-color: rgba(245, 158, 11, 0.65);
}

.automation-ares-feed li.automation-feed-item--cash {
    border-left-color: rgba(16, 185, 129, 0.6);
}

.automation-ares-feed li.automation-feed-item--empty {
    border-left-color: rgba(148, 163, 184, 0.5);
}

.automation-feed-time {
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
    line-height: 1.35;
    padding-top: 2px;
}

.automation-feed-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.automation-feed-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
}

.automation-feed-pill {
    flex-shrink: 0;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 999px;
    line-height: 1.2;
    background: rgba(59, 130, 246, 0.18);
    color: var(--text-primary);
    border: 1px solid rgba(59, 130, 246, 0.35);
}

.automation-feed-pill--swap {
    background: rgba(59, 130, 246, 0.18);
    border-color: rgba(59, 130, 246, 0.4);
}

.automation-feed-pill--close {
    background: rgba(245, 158, 11, 0.16);
    border-color: rgba(245, 158, 11, 0.4);
}

.automation-feed-pill--cash {
    background: rgba(16, 185, 129, 0.14);
    border-color: rgba(16, 185, 129, 0.38);
}

.automation-feed-pill--other {
    background: rgba(148, 163, 184, 0.15);
    border-color: rgba(148, 163, 184, 0.35);
}

.automation-feed-pill--idle {
    align-self: center;
    background: rgba(148, 163, 184, 0.12);
    border-color: rgba(148, 163, 184, 0.3);
}

.automation-feed-symbols {
    font-weight: 600;
    font-size: calc(12px + 1pt);
    line-height: 1.35;
    min-width: 0;
}

.automation-feed-sym {
    color: var(--accent-primary, #3b82f6);
    text-decoration: none;
}

.automation-feed-sym:hover {
    text-decoration: underline;
}

.automation-feed-arrow {
    opacity: 0.55;
    margin: 0 5px;
    font-weight: 500;
}

.automation-feed-verb {
    font-weight: 600;
    color: var(--text-secondary);
    margin-right: 4px;
}

.automation-feed-detail {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
    word-break: break-word;
}

.automation-feed-agent-row {
    font-size: 11px;
    color: var(--text-secondary);
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px;
}

.automation-feed-agent {
    font-weight: 600;
    color: var(--text-primary);
}

.automation-feed-agent-label {
    opacity: 0.85;
}

.automation-feed-source {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    opacity: 0.75;
}

.automation-feed-side {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: flex-start;
    gap: 4px;
    text-align: right;
}

.automation-feed-metrics {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.automation-feed-metric {
    font-size: 11px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.automation-feed-metric--muted {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 11px;
}

.automation-feed-metric--pl-pos {
    color: #059669;
}

.automation-feed-metric--pl-neg {
    color: #dc2626;
}

.automation-feed-empty-title {
    color: var(--text-secondary);
    font-size: 13px;
    padding-top: 2px;
}

.automation-range-btns {
    margin-top: 10px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.automation-range-btns .btn-modern.active {
    background: rgba(59, 130, 246, 0.18);
    border-color: rgba(59, 130, 246, 0.5);
    color: var(--text-primary);
}

.automation-order-table {
    margin-top: 10px;
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.automation-order-table-wrap {
    margin-top: 10px;
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

.automation-order-table-wrap .automation-order-table {
    margin-top: 0;
    min-width: 920px;
}

.automation-order-table th,
.automation-order-table td {
    border-bottom: 1px solid var(--border-color);
    padding: 7px 8px;
    text-align: left;
    vertical-align: top;
}

.automation-order-table th {
    font-weight: 700;
    background: var(--bg-primary);
}

.automation-pl-pos {
    color: #059669;
    font-weight: 700;
}

.automation-pl-neg {
    color: #dc2626;
    font-weight: 700;
}

.automation-pl-flat {
    color: var(--text-primary);
    font-weight: 700;
}

.automation-agents-hint {
    margin: 6px 0 0;
    font-size: 12px;
    color: var(--text-secondary);
    min-height: 1.2em;
}

.automation-agents-slots {
    margin-top: 12px;
    display: grid;
    gap: 8px;
}

.automation-agent-slot {
    border: 1px solid var(--border-color);
    border-radius: 9px;
    background: var(--bg-primary);
    padding: 10px;
    display: grid;
    gap: 8px;
    font-size: 12px;
}

.automation-agent-slot-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.automation-agent-slot-title {
    font-weight: 700;
    font-size: 13px;
}

.automation-agent-slot-meta {
    color: var(--text-secondary);
    font-size: 11px;
    line-height: 1.35;
}

.automation-agent-slot-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.automation-agent-slot .automation-agent-label-input {
    flex: 1;
    min-width: 120px;
    padding: 6px 8px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-glass);
    color: inherit;
    font-size: 12px;
}

.automation-agent-slot.is-active-slot {
    border-color: rgba(16, 185, 129, 0.45);
    box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.12);
}

.automation-check-row {
    margin-top: 9px;
    display: grid;
    gap: 6px;
}

.automation-check-row label {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
}

.automation-check-row input {
    width: 14px;
    height: 14px;
    accent-color: var(--primary);
}

.automation-flow-log {
    margin: 10px 0 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 7px;
    max-height: 220px;
    overflow: auto;
}

.automation-flow-log li {
    border-left: 3px solid rgba(59, 130, 246, 0.5);
    border-radius: 8px;
    background: var(--bg-primary);
    padding: 7px 9px;
    font-size: 12px;
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.automation-flow-log .tag {
    color: var(--text-secondary);
    font-size: 11px;
    white-space: nowrap;
}

@media (max-width: 1023px) {
    .automation-ares-panel-hero {
        grid-template-columns: 1fr;
    }

    .automation-ares-grid-3 {
        grid-template-columns: 1fr 1fr;
    }

    .automation-ares-queue .q-meta {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 639px) {
    .automation-ares-line {
        flex-wrap: wrap;
    }

    .automation-agent-slot .automation-agent-label-input {
        min-width: 0;
        width: 100%;
    }

    .automation-ares-grid-3,
    .automation-ares-grid-2 {
        grid-template-columns: 1fr;
    }

    .automation-ares-feed li {
        grid-template-columns: 1fr;
    }

    .automation-ares-queue .q-mini-swap:not(.q-mini-swap--buy-only) {
        flex-direction: column;
        gap: 8px;
    }

    .automation-ares-queue .q-mini-bridge {
        width: 100%;
        flex-direction: row;
    }

    .automation-ares-queue .q-mini-bridge-line {
        width: auto;
        height: 2px;
        min-height: 0;
        flex: 1;
        background: linear-gradient(
            90deg,
            transparent,
            var(--border-color) 20%,
            var(--border-color) 80%,
            transparent
        );
    }

    .automation-ares-queue .q-mini-bridge-icon {
        margin: 0 5px;
    }

    .automation-ares-queue .q-mini-bridge-icon .fa-arrow-right {
        transform: rotate(90deg);
    }

    .automation-queue-pager {
        justify-content: space-between;
    }

    .automation-day-grid-modern {
        flex-direction: column;
        border-radius: 12px;
    }

    .automation-day-pill {
        min-width: 100%;
    }

    .automation-order-history-card {
        overflow: hidden;
    }

    .automation-order-table-wrap .automation-order-table {
        min-width: 760px;
    }
}

/* Trading agents visual refresh (design-aligned, behavior-preserving) */
#tab-trading-agents-modern .automation-ares-content {
    row-gap: 18px;
}

#tab-trading-agents-modern .automation-ares-grid-2 {
    gap: 14px;
}

#tab-trading-agents-modern .automation-ares-status-card-wide {
    border-radius: 18px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    box-shadow: inset 0 1px 0 color-mix(in srgb, var(--text-primary) 5%, transparent);
    padding: 18px;
}

@media (min-width: 1024px) {
    #tab-trading-agents-modern .automation-ares-decision-log-card {
        width: 50%;
        max-width: 50%;
        box-sizing: border-box;
    }
}

/* Status (col 1) + active agent card (col 2); inactive agents in grid below */
#tab-trading-agents-modern .automation-ares-agent-ui-root {
    display: flex;
    flex-direction: column;
    gap: 0;
    width: 100%;
}

#tab-trading-agents-modern .automation-ares-status-agent-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    align-items: start;
    width: 100%;
}

@media (min-width: 1024px) {
    #tab-trading-agents-modern .automation-ares-status-agent-row {
        grid-template-columns: 1fr 1fr;
    }

    /* ARES off: only automation status in top row; all 3 agent cards live in #automation-fixed-agents-root */
    #tab-trading-agents-modern
        #automation-ares-agent-ui-root.ares-automation-off
        .automation-ares-status-agent-row {
        grid-template-columns: 1fr;
    }
}

#tab-trading-agents-modern .automation-active-agent-slot {
    min-height: 0;
    width: 100%;
    box-sizing: border-box;
}

/* Execution feed + ARES decision log: larger labels / cell text on this tab */
#tab-trading-agents-modern .automation-ares-feed li.automation-feed-item {
    font-size: calc(14px + 2pt);
    grid-template-columns: 100px minmax(0, 1fr) minmax(88px, auto);
    gap: 10px 14px;
    padding: 11px 14px;
}

#tab-trading-agents-modern .automation-feed-time {
    font-size: 14px;
}

#tab-trading-agents-modern .automation-feed-pill {
    font-size: 12px;
    padding: 4px 10px;
}

#tab-trading-agents-modern .automation-feed-symbols {
    font-size: calc(14px + 1pt);
}

#tab-trading-agents-modern .automation-feed-detail {
    font-size: 14px;
}

#tab-trading-agents-modern .automation-feed-agent-row {
    font-size: 13px;
}

#tab-trading-agents-modern .automation-feed-source {
    font-size: 12px;
}

#tab-trading-agents-modern .automation-feed-metric,
#tab-trading-agents-modern .automation-feed-metric--muted {
    font-size: 13px;
}

#tab-trading-agents-modern .automation-feed-empty-title {
    font-size: 15px;
}

#tab-trading-agents-modern .automation-fixed-agents-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-top: 14px;
}

@media (min-width: 1024px) {
    #tab-trading-agents-modern .automation-fixed-agents-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

#tab-trading-agents-modern .automation-agent-fixed-card {
    position: relative;
    border-radius: 18px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    min-height: 248px;
    padding: 18px 16px;
    justify-content: flex-start;
    align-items: center;
    text-align: center;
    gap: 10px;
    box-shadow: inset 0 1px 0 color-mix(in srgb, var(--text-primary) 5%, transparent);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

#tab-trading-agents-modern .automation-agent-fixed-card .automation-agent-card-icon {
    width: 64px;
    height: 64px;
    border-radius: 18px;
    border: 1px solid var(--border-color);
    background: linear-gradient(180deg, var(--bg-primary), var(--bg-tertiary));
    display: grid;
    place-items: center;
    font-size: 28px;
    color: var(--text-secondary);
    margin-top: 2px;
}

#tab-trading-agents-modern .automation-agent-fixed-card h4 {
    margin: 4px 0 0;
    font-size: 38px;
    line-height: 1.05;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

#tab-trading-agents-modern .automation-agent-fixed-card .sub {
    display: block !important;
    margin: 0;
    font-size: 14px;
    line-height: 1.4;
    color: var(--text-secondary);
    max-width: 240px;
}

#tab-trading-agents-modern .automation-agent-fixed-card .sub code {
    background: transparent;
    color: inherit;
    padding: 0;
}

/* Active slot: show only content through the slot blurb; hide label, save, buys/sells, weekdays */
#tab-trading-agents-modern #automation-fixed-agents-root .automation-agent-fixed-card.is-active-slot > p.sub ~ *,
#tab-trading-agents-modern #automation-active-agent-slot .automation-agent-fixed-card.is-active-slot > p.sub ~ * {
    display: none !important;
}

#tab-trading-agents-modern .automation-agent-fixed-card .automation-agent-card-actions {
    margin-top: 4px;
    width: 100%;
    justify-content: center;
}

#tab-trading-agents-modern .automation-agent-fixed-card [data-agent-action="activate"] {
    border-radius: 999px;
    min-width: 116px;
}

#tab-trading-agents-modern .automation-agent-fixed-card.is-active-slot {
    border-color: color-mix(in srgb, var(--primary, #60a5fa) 55%, var(--border-color));
    background: linear-gradient(
        180deg,
        color-mix(in srgb, var(--primary, #60a5fa) 12%, var(--bg-primary)),
        color-mix(in srgb, var(--primary, #60a5fa) 6%, var(--bg-secondary))
    );
    box-shadow:
        0 0 0 3px color-mix(in srgb, var(--primary, #60a5fa) 28%, transparent),
        0 12px 24px color-mix(in srgb, var(--primary, #60a5fa) 20%, transparent);
    transform: translateY(-3px) scale(1.012);
}

#tab-trading-agents-modern .automation-agent-fixed-card.is-active-slot h4 {
    color: var(--text-primary);
}

#tab-trading-agents-modern .automation-agent-fixed-card.is-active-slot .automation-agent-card-icon {
    border-color: color-mix(in srgb, var(--primary, #60a5fa) 42%, var(--border-color));
    color: var(--primary, #3b82f6);
    background: linear-gradient(
        180deg,
        var(--bg-primary),
        color-mix(in srgb, var(--primary, #60a5fa) 14%, var(--bg-secondary))
    );
    box-shadow: 0 8px 18px color-mix(in srgb, var(--primary, #60a5fa) 18%, transparent);
}

#tab-trading-agents-modern .automation-agent-fixed-card.is-active-slot::before {
    content: "ACTIVE AGENT";
    position: absolute;
    top: -11px;
    left: 14px;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid color-mix(in srgb, var(--primary, #60a5fa) 70%, #475569);
    background: linear-gradient(
        90deg,
        var(--primary, #60a5fa),
        var(--primary-dark, #3b82f6)
    );
    color: #ffffff;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.06em;
    line-height: 1;
    text-transform: uppercase;
    box-shadow: 0 6px 14px color-mix(in srgb, var(--primary, #60a5fa) 34%, transparent);
}

#tab-trading-agents-modern .automation-agent-fixed-card.is-active-slot .automation-agent-active-summary {
    display: block;
    width: 100%;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-secondary);
    padding: 8px 10px;
    font-weight: 600;
    font-size: 13px;
}

#tab-trading-agents-modern .automation-agent-fixed-card.is-active-slot [data-agent-action="activate"] {
    display: none;
}

#tab-trading-agents-modern .automation-agent-fixed-card:not(.is-active-slot) .automation-budget-row,
#tab-trading-agents-modern .automation-agent-fixed-card:not(.is-active-slot) .automation-agent-label-wrap,
#tab-trading-agents-modern .automation-agent-fixed-card:not(.is-active-slot) [data-agent-action="save"] {
    display: none !important;
}

#tab-trading-agents-modern .automation-agent-fixed-card.is-active-slot .automation-agent-label-wrap,
#tab-trading-agents-modern .automation-agent-fixed-card.is-active-slot .automation-budget-row {
    display: flex !important;
    flex-direction: column;
    width: 100%;
    align-items: stretch;
    text-align: left;
}

#tab-trading-agents-modern .automation-agent-fixed-card.is-active-slot [data-agent-action="save"] {
    display: inline-flex !important;
}

#tab-trading-agents-modern .automation-agent-fixed-card.is-inactive-slot {
    opacity: 0.78;
    filter: saturate(0.8);
    transform: none;
    box-shadow: inset 0 1px 0 color-mix(in srgb, var(--text-primary) 5%, transparent);
}

#tab-trading-agents-modern .automation-agent-fixed-card.is-inactive-slot .automation-agent-card-icon {
    opacity: 0.82;
}

#tab-trading-agents-modern .automation-agent-fixed-card.is-inactive-slot [data-agent-action="activate"] {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

#tab-trading-agents-modern .automation-agent-fixed-card.is-inactive-slot [data-agent-action="activate"]:hover {
    border-color: color-mix(in srgb, var(--text-secondary) 50%, var(--border-color));
    color: var(--text-primary);
}

@media (max-width: 1023px) {
    #tab-trading-agents-modern .automation-fixed-agents-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 20px;
    }

    #tab-trading-agents-modern .automation-agent-fixed-card {
        min-height: 198px;
        padding: 16px 14px;
    }

    #tab-trading-agents-modern .automation-agent-fixed-card h4 {
        font-size: 30px;
    }
}

/* Trading agents modal glow-up */
#tab-trading-agents-modern .automation-agent-modal-overlay {
    background: rgba(10, 14, 25, 0.62);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    padding: 18px;
}

#tab-trading-agents-modern .automation-agent-modal {
    width: min(820px, 96vw);
    max-height: min(90vh, 100dvh);
    display: flex;
    flex-direction: column;
    border-radius: 22px;
    border: 1px solid color-mix(in srgb, var(--primary, #60a5fa) 18%, var(--border-color));
    background: linear-gradient(
        180deg,
        color-mix(in srgb, var(--primary, #60a5fa) 5%, var(--bg-primary)) 0%,
        var(--bg-primary) 16%,
        var(--bg-primary) 100%
    );
    box-shadow:
        0 24px 48px rgba(21, 28, 44, 0.24),
        inset 0 2px 0 color-mix(in srgb, var(--text-primary) 6%, transparent);
    overflow: hidden;
}

#tab-trading-agents-modern .automation-agent-modal-header {
    flex-shrink: 0;
    padding: 20px 20px 16px;
    border-bottom: 1px solid color-mix(in srgb, var(--primary, #60a5fa) 18%, var(--border-color));
    background: linear-gradient(
        90deg,
        color-mix(in srgb, var(--primary, #60a5fa) 12%, var(--bg-primary)),
        color-mix(in srgb, var(--primary-dark, #3b82f6) 8%, var(--bg-primary))
    );
    align-items: center;
}

#tab-trading-agents-modern .automation-agent-modal-header h4 {
    margin: 0;
    font-size: 28px;
    line-height: 1.1;
    letter-spacing: -0.015em;
    color: var(--text-primary);
}

#tab-trading-agents-modern .automation-agent-modal-sub {
    margin: 6px 0 0;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

#tab-trading-agents-modern .automation-agent-modal-close {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    display: grid;
    place-items: center;
    color: var(--text-secondary);
}

#tab-trading-agents-modern .automation-agent-modal-close:hover {
    background: color-mix(in srgb, var(--primary, #60a5fa) 10%, var(--bg-primary));
    border-color: color-mix(in srgb, var(--primary, #60a5fa) 42%, var(--border-color));
    color: var(--primary-dark, #2563eb);
}

#tab-trading-agents-modern .automation-agent-modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 18px 20px;
    gap: 14px;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
}

#tab-trading-agents-modern .automation-agent-modal-section {
    border-bottom-color: var(--border-color);
    margin-bottom: 14px;
    padding-bottom: 12px;
}

#tab-trading-agents-modern .automation-agent-toggle-row {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

#tab-trading-agents-modern .automation-agent-modal .automation-agent-label-wrap {
    margin: 0;
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

#tab-trading-agents-modern .automation-agent-modal .automation-agent-label-wrap input {
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    padding: 11px 12px;
    font-size: 14px;
    color: var(--text-primary);
}

#tab-trading-agents-modern .automation-agent-modal .automation-budget-row {
    margin-top: 0;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    background: var(--bg-secondary);
    padding: 12px;
}

#tab-trading-agents-modern .automation-agent-modal .automation-budget-row-head {
    margin-bottom: 10px;
}

#tab-trading-agents-modern .automation-agent-modal .automation-budget-label {
    font-size: 13px;
    color: var(--text-primary);
    text-transform: none;
    letter-spacing: 0;
}

#tab-trading-agents-modern .automation-agent-modal .automation-budget-hint {
    font-size: 10px;
    color: var(--text-secondary);
}

#tab-trading-agents-modern .automation-agent-modal .automation-budget-segmented {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    padding: 5px;
}

#tab-trading-agents-modern .automation-agent-modal .automation-budget-opt {
    font-size: 13px;
    font-weight: 700;
}

#tab-trading-agents-modern .automation-agent-modal .automation-budget-opt.active {
    background: linear-gradient(
        90deg,
        var(--primary, #60a5fa),
        var(--primary-dark, #3b82f6)
    );
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 4px 12px color-mix(in srgb, var(--primary, #60a5fa) 30%, transparent);
}

#tab-trading-agents-modern .automation-agent-modal .automation-day-grid-modern {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
}

#tab-trading-agents-modern .automation-agent-modal .automation-day-pill input:checked + span {
    background: linear-gradient(
        90deg,
        color-mix(in srgb, var(--primary, #60a5fa) 22%, var(--bg-primary)),
        color-mix(in srgb, var(--primary-dark, #3b82f6) 18%, var(--bg-primary))
    );
    border-color: color-mix(in srgb, var(--primary, #60a5fa) 44%, var(--border-color));
    color: var(--text-primary);
}

#tab-trading-agents-modern .automation-agent-modal-status {
    margin-top: 2px;
    font-size: 12px;
    color: var(--text-secondary);
}

#tab-trading-agents-modern .automation-agent-modal-footer {
    flex-shrink: 0;
    padding: 14px 20px 18px;
    border-top: 1px solid color-mix(in srgb, var(--primary, #60a5fa) 18%, var(--border-color));
    background: linear-gradient(
        180deg,
        color-mix(in srgb, var(--primary, #60a5fa) 4%, var(--bg-primary)),
        var(--bg-primary)
    );
    justify-content: space-between;
}

#tab-trading-agents-modern #automation-agent-modal-activate-btn,
#tab-trading-agents-modern #automation-agent-modal-save-btn {
    border-radius: 999px;
    min-height: 40px;
    padding-inline: 16px;
}

#tab-trading-agents-modern #automation-agent-modal-save-btn {
    background: linear-gradient(
        90deg,
        var(--primary, #60a5fa),
        var(--primary-dark, #3b82f6)
    );
    border-color: transparent;
    color: #ffffff;
    box-shadow: 0 8px 16px color-mix(in srgb, var(--primary, #60a5fa) 34%, transparent);
}

@media (max-width: 639px) {
    #tab-trading-agents-modern .automation-fixed-agents-grid {
        grid-template-columns: 1fr;
        gap: 22px;
    }

    #tab-trading-agents-modern .automation-agent-modal {
        width: 100%;
        max-height: min(92vh, 100dvh);
        border-radius: 16px;
    }

    #tab-trading-agents-modern .automation-agent-modal-header {
        padding: 16px 16px 12px;
    }

    #tab-trading-agents-modern .automation-agent-modal-header h4 {
        font-size: 24px;
    }

    #tab-trading-agents-modern .automation-agent-modal-body {
        padding: 14px 16px;
        gap: 12px;
    }

    #tab-trading-agents-modern .automation-agent-modal-footer {
        padding: 12px 16px 14px;
        flex-direction: column;
        align-items: stretch;
    }
}
