/* Finance UI semantic palette */
:root {
    --color-profit: #16A34A;
    --color-profit-dark: #166534;
    --color-loss: #DC2626;
    --color-loss-dark: #991B1B;
    --color-info: #2563EB;
    --color-info-dark: #1D4ED8;
    --color-warning: #D97706;
    --color-disabled: #9CA3AF;
    --color-neutral: #F3F4F6;
    --color-text: #111827;
}

/* General body styling */
body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f4f4;
    font-size: 16px;
}

/* Tooltip styling for alert totals */
.alert-total-cell {
    position: relative;
}

.alert-total-cell:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #333;
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    white-space: normal;
    z-index: 1000;
    margin-bottom: 5px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    pointer-events: none;
    line-height: 1.6;
    text-align: left;
    min-width: 80px;
    max-width: 150px;
}

.alert-total-cell:hover::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #333;
    z-index: 1001;
    margin-bottom: -5px;
    pointer-events: none;
}

.alert-hour-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 2px;
    width: 100%;
}

.alert-hour-grid-single {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
}

.alert-hour-box {
    font-size: 11px;
    line-height: 1.2;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 3px;
    padding: 2px 1px;
    text-align: center;
    background: rgba(0, 0, 0, 0.18);
    color: #fff;
    font-weight: 600;
}

.alert-hour-box.active {
    background: var(--color-profit);
    border-color: #86efac;
}

/* Header container for account info and broker checkboxes */
.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background-color: #fff;
    border-bottom: 1px solid #ddd;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-left: 20px;
}

#api_mode {
    flex: 1 1 560px;
    min-width: 360px;
}

.account-info-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(110px, 1fr));
    gap: 10px;
}

.account-info-item {
    background: #f8f8f8;
    border: 1px solid #d8d8d8;
    border-radius: 8px;
    padding: 8px 10px;
    min-height: 60px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 4px;
}

.account-info-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.account-info-label {
    font-size: 12px;
    font-weight: 700;
    color: #585858;
    margin-bottom: 0;
    flex: 1;
    min-width: 0;
}

/* Pill toggle: ON (checked) = value visible = knob right — OFF = hidden = knob left */
.account-info-toggle-btn {
    flex-shrink: 0;
    width: 48px;
    height: 28px;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.account-info-toggle-btn:focus-visible {
    outline: 2px solid #0d47a1;
    outline-offset: 2px;
    border-radius: 14px;
}

.account-info-toggle-track {
    display: block;
    width: 48px;
    height: 28px;
    border-radius: 14px;
    background: #b2dfdb;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.06);
    position: relative;
    transition: background-color 0.2s ease;
}

.account-info-toggle-btn:hover .account-info-toggle-track {
    background: #9fd4cf;
}

.account-info-item--collapsed .account-info-toggle-track {
    background: #cfd8d7;
}

.account-info-item--collapsed .account-info-toggle-btn:hover .account-info-toggle-track {
    background: #bfc9c8;
}

.account-info-toggle-thumb {
    position: absolute;
    width: 22px;
    height: 22px;
    left: 3px;
    top: 3px;
    border-radius: 50%;
    background: #00897b;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.18);
    transition: transform 0.22s ease, background-color 0.2s ease;
}

/* ON: thumb slides right */
.account-info-item:not(.account-info-item--collapsed) .account-info-toggle-thumb {
    transform: translateX(20px);
    background: #00796b;
}

.account-info-body {
    overflow: hidden;
    max-height: 120px;
    opacity: 1;
    transition: max-height 0.22s ease, opacity 0.18s ease, margin 0.18s ease;
}

.account-info-item--collapsed .account-info-body {
    max-height: 0;
    opacity: 0;
    margin: 0;
    pointer-events: none;
}

.account-info-value {
    font-size: 28px;
    line-height: 1.1;
    font-weight: 700;
    color: #1f1f1f;
    white-space: nowrap;
}

.account-info-value.positive {
    color: #1b5e20;
}

.account-info-value.negative {
    color: #b71c1c;
}

.account-info-value.neutral {
    color: #1f1f1f;
}

/* Broker checkboxes container */
.broker-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-start;
    background: #f8f8f8;
    border: 1px solid #d8d8d8;
    border-radius: 8px;
    padding: 8px 10px;
    height: 60px;
    justify-content: space-between;
}

.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.header-stocks-timeframe-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.stocks-dashboard-open-btn {
    min-height: 36px;
    padding: 6px 14px;
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    cursor: pointer;
}

.stocks-dashboard-open-btn:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
}

.stocks-env-modal {
    z-index: 50;
    padding-top: 40px;
}

.stocks-env-modal-content {
    max-width: min(960px, 96vw);
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    margin: 2% auto;
}

.stocks-env-modal-title {
    margin: 0 0 8px 0;
    font-size: 1.35rem;
}

.stocks-env-modal-sub {
    font-weight: 400;
    font-size: 0.95rem;
    color: #6b7280;
}

.stocks-env-modal-help {
    margin-top: 0;
}

.stocks-modal-trade-section {
    margin: 16px 0;
    padding: 12px 14px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

.stocks-modal-section-title {
    margin: 0 0 8px 0;
    font-size: 0.95rem;
    color: #374151;
}

.stocks-modal-trade-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.stocks-trade-chip {
    display: inline-block;
    padding: 4px 10px;
    font-size: 13px;
    font-weight: 600;
    color: #14532d;
    background: #dcfce7;
    border: 1px solid #86efac;
    border-radius: 999px;
}

.stocks-modal-add-panel {
    margin-bottom: 16px;
}

.stocks-modal-form-actions {
    margin-top: 16px;
}

.stocks-row-remove-btn {
    flex: 0 0 auto;
    margin-left: 4px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    color: #991b1b;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    cursor: pointer;
}

.stocks-row-remove-btn:hover {
    background: #fee2e2;
}

/* Popover from % P/L column — STOCKS SL/TP / max investment */
.pct-pl-stocks-popover {
    min-width: 260px;
    max-width: min(320px, 96vw);
    padding: 12px 14px;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
}

.pct-pl-stocks-popover-title {
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 10px;
    color: #111827;
}

.pct-pl-stocks-popover-field {
    margin-bottom: 10px;
}

.pct-pl-stocks-popover-field .form-select,
.pct-pl-stocks-popover-field .form-input {
    width: 100%;
    margin-top: 4px;
}

.pct-pl-stocks-popover-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid #e5e7eb;
}

.positiontablebody td.pct-pl-cell:hover {
    outline: 1px solid #93c5fd;
}

.timeframe-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-start;
    background: #f8f8f8;
    border: 1px solid #d8d8d8;
    border-radius: 8px;
    padding: 8px 10px;
    height: 60px;
    justify-content: space-between;
}

.header-stocks-timeframe-wrap.timeframe-checkboxes {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    height: auto;
    min-height: 60px;
}

.autotrade-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-start;
    background: #f8f8f8;
    border: 1px solid #d8d8d8;
    border-radius: 8px;
    padding: 8px 10px;
    height: 60px;
    justify-content: space-between;
}

.autotrade-checkboxes.has-warning {
    height: auto;
    min-height: 60px;
}

.autotrade-warning-banner {
    background-color: #FEE2E2;
    color: #991B1B;
    border: 1px solid #DC2626;
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.3;
    padding: 4px 6px;
    max-width: 240px;
}

/* Investment profile checkboxes container */
.profile-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-start;
    background: #f8f8f8;
    border: 1px solid #d8d8d8;
    border-radius: 8px;
    padding: 8px 10px;
    height: 60px;
    justify-content: space-between;
}

.profile-select-label {
    font-size: 0.95em;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
}

.profile-style-select {
    min-width: 180px;
    height: 36px;
    padding: 6px 10px;
    border: 1px solid #bdbdbd;
    border-radius: 6px;
    background: #fff;
    color: #222;
    font-size: 0.95em;
}

.how-it-works-btn {
    padding: 8px 12px;
    border: 1px solid #1e6f34;
    border-radius: 6px;
    background: #2e7d32;
    color: #fff;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.how-it-works-btn:hover {
    background: #256a2a;
}

.how-it-works-btn:focus-visible {
    outline: 2px solid #0d47a1;
    outline-offset: 2px;
}

.tour-step-picker {
    width: 44px;
    height: 44px;
    border: 1px solid #9f2020;
    border-radius: 999px;
    background: #d32f2f;
    color: #fff;
    font-size: 24px;
    font-weight: 700;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    user-select: none;
    touch-action: none;
}

.tour-step-picker:focus-visible {
    outline: 2px solid #0d47a1;
    outline-offset: 2px;
}

.tour-step-picker.dragging {
    cursor: grabbing;
    opacity: 0.95;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

.guided-tour-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 2000;
}

.guided-tour-popover {
    position: fixed;
    width: min(420px, calc(100vw - 24px));
    background: #fff;
    border: 1px solid #d3d3d3;
    border-radius: 10px;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28);
    padding: 12px;
    z-index: 2002;
}

.guided-tour-title {
    font-size: 1rem;
    font-weight: 700;
    color: #222;
    margin-bottom: 8px;
}

.guided-tour-description {
    font-size: 0.9rem;
    color: #333;
    line-height: 1.45;
    margin-bottom: 10px;
}

.guided-tour-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.guided-tour-progress {
    font-size: 0.8rem;
    color: #555;
}

.guided-tour-actions {
    display: flex;
    gap: 6px;
}

.guided-tour-btn {
    border: 1px solid #bdbdbd;
    background: #f7f7f7;
    color: #222;
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 0.85rem;
}

.guided-tour-btn.primary {
    background: #2e7d32;
    color: #fff;
    border-color: #1e6f34;
}

.guided-tour-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.guided-tour-highlight {
    position: relative;
    z-index: 2001 !important;
    box-shadow: 0 0 0 3px #ffeb3b, 0 0 0 6px rgba(0, 0, 0, 0.25);
    border-radius: 6px;
}

/* Broker checkbox label styling */
.broker-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 500;
    color: #333;
    user-select: none;
}

.broker-checkbox-label:hover {
    color: #555;
}

/* Broker checkbox input styling */
.broker-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #4CAF50;
}

.broker-checkbox:checked {
    accent-color: #4CAF50;
}

/* Tab styling */
.tabs {
    display: flex;
    align-items: center;
    background-color: #e0e0e0;
    padding: 0;
    border-bottom: 2px solid #ccc;
}

.tab-button {
    padding: 12px 24px;
    background-color: #e0e0e0;
    border: none;
    cursor: pointer;
    font-size: 1em;
    font-weight: bold;
    color: #333;
    transition: all 0.2s ease;
    position: relative;
    border-bottom: 2px solid transparent;
}

/* State 1: Default/Inactive - Lighter grey background */
.tab-button:not(.active) {
    background-color: #e0e0e0;
    color: #333;
}

/* State 2: Mouse Over - Medium grey background */
.tab-button:hover:not(.active) {
    background-color: #d0d0d0;
    color: #222;
}

/* State 3: Active/Clicked/Page Loaded - Darker grey background matching loaded page */
.tab-button.active {
    background-color: #b0b0b0;
    color: #111;
    border-bottom: 2px solid #4CAF50;
    font-weight: 700;
}

/* Hover state when active (page loaded) - slightly lighter but still distinct */
.tab-button.active:hover {
    background-color: #a0a0a0;
    color: #000;
}

/* Clicked state - momentary darker shade */
.tab-button:active {
    background-color: #909090;
    transform: scale(0.98);
}

.tour-step-picker-nav {
    margin-left: 10px;
}

.top-nav-how-it-works-btn {
    margin-left: 10px;
    padding: 8px 14px;
}

.top-nav-logout-btn {
    margin-left: auto;
    margin-right: 8px;
    padding: 8px 16px;
    background-color: var(--color-loss);
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
}

.top-nav-logout-btn:hover {
    background-color: var(--color-loss-dark);
}

.tab-content {
    display: none;
    padding: 20px;
}

.tab-content.active {
    display: block;
}

/* Config tab investment buttons */
.config-investment-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 20px;
}

.config-investment-btn {
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    border: 2px solid #2563EB;
    border-radius: 8px;
    background-color: #fff;
    color: #2563EB;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 80px;
}

.config-investment-btn:hover {
    background-color: #2563EB;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.3);
}

.config-investment-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

.config-investment-btn.selected {
    background-color: #2563EB;
    color: #fff;
    border-color: #1D4ED8;
}

.config-message {
    margin-top: 20px;
    padding: 12px;
    border-radius: 6px;
    font-size: 14px;
    min-height: 20px;
    white-space: pre-line;
    line-height: 1.6;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.config-message.success {
    background-color: #D1FAE5;
    color: #065F46;
    border: 1px solid #16A34A;
}

.config-message.error {
    background-color: #FEE2E2;
    color: #991B1B;
    border: 1px solid #DC2626;
}

/* Config subtabs styling */
.config-subtabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #E5E7EB;
    padding-bottom: 10px;
}

.config-subtab-button {
    padding: 10px 20px;
    background-color: #F3F4F6;
    border: 2px solid #D1D5DB;
    border-radius: 6px 6px 0 0;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #6B7280;
    transition: all 0.2s;
    border-bottom: none;
}

.config-subtab-button:hover {
    background-color: #E5E7EB;
    color: #111827;
}

.config-subtab-button.active {
    background-color: #3B82F6;
    color: #FFFFFF;
    border-color: #3B82F6;
    border-bottom: 2px solid #FFFFFF;
    margin-bottom: -2px;
}

.config-subtab-content {
    padding-top: 20px;
}

.config-subtab-content.active {
    display: block;
}

.config-section {
    margin-bottom: 30px;
    padding: 20px;
    background-color: #F9FAFB;
    border-radius: 8px;
    border: 1px solid #E5E7EB;
}

/* Settings → Server logs: stacked audit sections */
.server-logs-card .server-logs-section-title {
    margin-top: 1.5rem;
    margin-bottom: 0.35rem;
    font-size: 1.15rem;
    font-weight: 700;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 6px;
}

/* Settings → TVOrders: Alpaca audit log tables */
.tvorders-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    margin-bottom: 12px;
}

.tvorders-toolbar .form-group {
    margin-bottom: 0;
}

.tvorders-toolbar-actions {
    margin-left: auto;
}

.tvorders-path-hint {
    font-size: 0.85rem;
    margin-bottom: 12px;
}

/* Settings → Alpaca fills: visual break between symbol groups */
#alpaca-fills-rows-body tr.alpaca-fills-symbol-group-start td {
    border-top: 2px solid #94a3b8;
    padding-top: 8px;
}

.alpaca-fills-fifo-warnings-list {
    margin-top: 0;
    margin-bottom: 1rem;
    color: #b45309;
}

.tvorders-date-input {
    max-width: 180px;
}

.tvorders-table-heading {
    margin-top: 0.75rem;
    margin-bottom: 0.35rem;
    font-size: 1rem;
    font-weight: 600;
}

.tvorders-table-wrap {
    overflow-x: auto;
    margin-bottom: 1.5rem;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fff;
}

.tvorders-log-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.tvorders-log-table th,
.tvorders-log-table td {
    border-bottom: 1px solid #eee;
    padding: 6px 8px;
    text-align: left;
    vertical-align: top;
}

.tvorders-log-table th {
    background: #f9fafb;
    font-weight: 600;
    white-space: nowrap;
}

.tvorders-log-table td.tvorders-long-text-cell {
    max-width: 14rem;
    word-break: break-word;
}

.tvorders-summary-table {
    width: 100%;
    max-width: 720px;
    border-collapse: collapse;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.tvorders-summary-table td {
    border: 1px solid #e5e7eb;
    padding: 6px 10px;
}

.tvorders-summary-table td:first-child {
    font-weight: 600;
    width: 42%;
    background: #fafafa;
}

.config-section h3 {
    margin-top: 0;
    margin-bottom: 20px;
    color: #111827;
    font-size: 18px;
    font-weight: 600;
}

.form-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #D1D5DB;
    border-radius: 6px;
    font-size: 14px;
    font-family: 'Courier New', monospace;
    resize: vertical;
    min-height: 80px;
}

.form-textarea:focus {
    outline: none;
    border-color: #3B82F6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-help {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    color: #6B7280;
    font-style: italic;
}

/* Config form styling */
.config-form {
    max-width: 600px;
    margin: 20px 0;
}

.config-form .form-group {
    margin-bottom: 20px;
}

.config-form .form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #111827;
    font-size: 14px;
}

.config-form .form-select,
.config-form .form-input {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #D1D5DB;
    border-radius: 6px;
    font-size: 16px;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
}

.config-form .form-select:focus,
.config-form .form-input:focus {
    outline: none;
    border-color: #2563EB;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.config-form .style-fields {
    margin-top: 20px;
    padding: 20px;
    background-color: #F9FAFB;
    border-radius: 8px;
    border: 1px solid #E5E7EB;
}

.config-form .form-actions {
    margin-top: 30px;
    display: flex;
    gap: 12px;
}

/* Duplicate Stocks actions row injected above Core Etfs (see scripts.js). */
.config-form #stocks-config-container > .stocks-form-actions-above-core {
    margin-bottom: 8px;
}

.config-submit-btn,
.config-reload-btn {
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.config-submit-btn {
    background-color: #2563EB;
    color: #fff;
}

.config-submit-btn:hover {
    background-color: #1D4ED8;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.3);
}

.config-submit-btn:active {
    transform: translateY(0);
}

.config-submit-btn:disabled {
    background-color: #9CA3AF;
    cursor: not-allowed;
    transform: none;
}

.config-reload-btn {
    background-color: #6B7280;
    color: #fff;
}

.config-reload-btn:hover {
    background-color: #4B5563;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(107, 114, 128, 0.3);
}

/* Table styling */
.positiontable {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed !important; /* Fixed layout to force column alignment */
}

.positiontable th, .positiontable td {
    padding: 8px 4px !important; /* Reduced padding */
    text-align: center;
    border: 1px solid black;
    white-space: nowrap;
    vertical-align: middle !important; /* Center content vertically */
    position: relative !important; /* Enable relative positioning for contained elements */
}

/* Keep headers centered, but left-align row data with a 5px inset. */
.positiontable td {
    text-align: left;
    padding-left: 5px !important;
}

/* 15-column layout — must match templates/index.html + scripts.js row (no Est./Gamma/AI cells). */
.positiontable th:nth-child(1), .positiontable td:nth-child(1) { width: 5%; }  /* Stock */
.positiontable th:nth-child(2), .positiontable td:nth-child(2) { width: 5%; }  /* Qty */
.positiontable th:nth-child(3), .positiontable td:nth-child(3) { width: 8%; } /* IN $ */
.positiontable th:nth-child(4), .positiontable td:nth-child(4) { width: 5.6%; } /* Price Now */
.positiontable th:nth-child(5), .positiontable td:nth-child(5) { width: 5.6%; } /* P/L $ */
.positiontable th:nth-child(6), .positiontable td:nth-child(6) { width: 6%; } /* % */
.positiontable th:nth-child(7), .positiontable td:nth-child(7) { width: 6%; } /* %Close */
.positiontable th:nth-child(8), .positiontable td:nth-child(8) { width: 6.4%; } /* COST $ */
.positiontable th:nth-child(9), .positiontable td:nth-child(9) { width: 5%; }  /* STATUS */
.positiontable th:nth-child(10), .positiontable td:nth-child(10) { width: 6%; } /* Alert */
.positiontable th:nth-child(11), .positiontable td:nth-child(11) { width: 3.2%; } /* ONE (−20% vs 4%) */
.positiontable th:nth-child(12), .positiontable td:nth-child(12) { width: 4%; } /* Flip (−20% vs 5%) */
.positiontable th:nth-child(13), .positiontable td:nth-child(13) { width: 12%; } /* Loss/Profit */
.positiontable th:nth-child(14), .positiontable td:nth-child(14) { width: 6.3%; } /* Buy/Sell (−30% vs prior 9%) */
.positiontable th:nth-child(15), .positiontable td:nth-child(15) { width: 4.55%; } /* EXIT (−30% vs prior 6.5%) */


.positiontable th {
    background-color: #c7ced8;
    font-weight: 700;
    color: #0f172a;
    border-bottom: 2px solid #6b7280 !important;
}

.positiontable th.sortable-header {
    cursor: pointer;
    position: relative;
    padding-right: 18px !important;
    user-select: none;
}

.positiontable th.sortable-header::after {
    content: attr(data-sort-arrow);
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    line-height: 1;
    opacity: 0.95;
}

/* Specific header background colors (Buy/Sell + EXIT columns in 15-col layout) */
.positiontable th:nth-child(14) {
    background-color: #15803d; 
    color: white; 
    width: 6.3% !important;
}
.positiontable th:nth-child(15) {
    background-color: #b91c1c; 
    color: white; 
    width: 4.55% !important;
}


/* Alternate row coloring across the full row */
.positiontable tbody tr:nth-child(odd) {
    background-color: #f2f4f7;
}

.positiontable tbody tr:nth-child(even) {
    background-color: #dfe4eb;
}

/* Decision-oriented metric coloring:
   keep context cells neutral; apply semantic tone only to P/L and % change cells. */
.positiontable td.metric-context {
    background-color: transparent;
    color: var(--color-text);
    font-weight: 600;
}

.positiontable td.est-col,
.positiontable td.gamma-col {
    white-space: normal;
    line-height: 1.3;
    font-size: 0.9em; /* ~10% smaller than row body text */
}

.positiontable td.metric-gain {
    background-color: #DCFCE7;
    color: var(--color-profit-dark);
    font-weight: 700;
}

.positiontable td.metric-loss {
    background-color: #FEE2E2;
    color: var(--color-loss-dark);
    font-weight: 700;
}

.positiontable td.metric-neutral {
    background-color: #E5E7EB;
    color: #374151;
    font-weight: 700;
}

/* Button styling */
.button {
    padding: 8px 12px;
    border: none;
    cursor: pointer;
    border-radius: 5px;
    font-size: 0.9em;
    white-space: nowrap;
    margin: 0 2px;
    transition: background-color 120ms ease, box-shadow 120ms ease, transform 60ms ease, opacity 120ms ease;
}

.button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    filter: grayscale(20%);
}

.button:focus-visible,
.liststockbuybutton:focus-visible,
.liststocksellbutton:focus-visible {
    outline: 2px solid #0d47a1;
    outline-offset: 1px;
}

.button.is-pending,
.liststockbuybutton.is-pending,
.liststocksellbutton.is-pending {
    opacity: 0.8;
    filter: saturate(80%);
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.45);
}

.button.is-success,
.liststockbuybutton.is-success,
.liststocksellbutton.is-success {
    box-shadow: inset 0 0 0 2px #1b5e20;
}

.button.is-error,
.liststockbuybutton.is-error,
.liststocksellbutton.is-error {
    box-shadow: inset 0 0 0 2px #8e0000;
}

.buybutton {
    background-color: var(--color-profit);
    color: #fff;
}

.buybutton:hover:not(:disabled) {
    background-color: #15803d;
}

.buybutton:active:not(:disabled) {
    background-color: var(--color-profit-dark);
    transform: translateY(1px);
}

.sellbutton {
    background-color: var(--color-loss);
    color: #fff;
}

.sellbutton:hover:not(:disabled) {
    background-color: #b91c1c;
}

.sellbutton:active:not(:disabled) {
    background-color: var(--color-loss-dark);
    transform: translateY(1px);
}

/* ONE column (11th) — centered */
.positiontable td:nth-child(11) {
    text-align: center !important;
    padding: 6.4px 3.2px !important;
}

.positiontable td:nth-child(11) .button {
    display: inline-block;
    margin: 0 auto;
}

.positiontable th:nth-child(11),
.positiontable td:nth-child(11) {
    width: 3.2% !important;
}

/* Flip column (12th) — centered */
.positiontable td:nth-child(12) {
    text-align: center !important;
    padding: 6.4px 3.2px !important;
}

.positiontable td:nth-child(12) .button {
    display: inline-block;
    margin: 0 auto;
}

.positiontable th:nth-child(12),
.positiontable td:nth-child(12) {
    width: 4% !important;
}

/* ONE + Flip buttons: ~20% smaller than default .button (width via padding, label via font-size) */
.positiontable td:nth-child(11) .button,
.positiontable td:nth-child(12) .button {
    padding: 6.4px 9.6px;
    font-size: calc(0.9em * 0.8);
    border-radius: 4px;
    margin: 0 1.6px;
}

/* Buy/Sell column - right-aligned buttons */
.positiontable td.buy-sell-cell {
    text-align: right !important;
    padding: 8px 4px !important;
    white-space: normal;
    vertical-align: middle;
}

.positiontable td.buy-sell-cell .button-group-inline,
.positiontable td.exit-cell .button-group-inline {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    align-content: flex-end;
    gap: 2.8px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.positiontable .buy-sell-investment-btn {
    min-width: 40.6px;
    height: 23.8px;
    padding: 4.2px 5.6px;
    font-size: calc(0.9em * 0.7);
    font-weight: 700;
}

/* EXIT column - right-aligned buttons */
.positiontable td.exit-cell {
    text-align: right !important;
    padding: 8px 4px !important;
    white-space: normal;
    vertical-align: middle;
}

.positiontable .exit-percent-btn {
    min-width: 39.2px;
    height: 23.8px;
    padding: 4.2px 5.6px;
    font-size: calc(0.9em * 0.7);
    font-weight: 700;
    background-color: #dc2626;
    color: #ffffff;
}

.positiontable .exit-percent-btn:hover:not(:disabled) {
    background-color: #b91c1c;
}

.positiontable .exit-percent-btn:active:not(:disabled) {
    background-color: #991b1b;
    transform: translateY(1px);
}

.risk-controls {
    text-align: center !important;
}

.risk-select {
    width: 80px;
    max-width: 80px;
    margin: 2px 0;
    padding: 3px 4px;
    font-size: 12px;
    border: 1px solid #666;
    border-radius: 4px;
    background: #f5f5f5;
    color: #222;
}

.flipbutton {
    background-color: #22c55e;
    color: #000;
    font-weight: 700;
}

.flipbutton:hover:not(:disabled) {
    background-color: #16a34a;
}

.flipbutton:active:not(:disabled) {
    background-color: #15803d;
    transform: translateY(1px);
}

.onebuttona {
    background-color: gray;
    color: black;
}

.onebuttona:hover:not(:disabled) {
    background-color: #767676;
}

.onebuttona:active:not(:disabled) {
    background-color: #5f5f5f;
    transform: translateY(1px);
}

.ai-col {
    text-align: center !important;
}

.positiontable td.timeframe-minute-col.alert-total-cell.alert-gradient-green {
    background: linear-gradient(to right, #86efac, #15803d) !important;
    color: #ffffff !important;
}

.positiontable td.timeframe-minute-col.alert-total-cell.alert-gradient-red {
    background: linear-gradient(to right, #fca5a5, #b91c1c) !important;
    color: #ffffff !important;
}

.positiontable td.timeframe-minute-col.alert-total-cell.alert-gradient-yellow {
    background: linear-gradient(to right, #fde68a, #ca8a04) !important;
    color: #111827 !important;
}

.positiontable td.status-cell {
    font-weight: 700;
    text-align: center;
}

.positiontable td.status-cell .status-main {
    text-transform: uppercase;
    font-size: 1.05em;
    line-height: 1.1;
}

.positiontable td.status-cell .status-age {
    margin-top: 4px;
    font-size: 0.72em;
    line-height: 1;
    opacity: 0.95;
    font-weight: 600;
}

.positiontable td.status-cell.status-mismatch {
    box-shadow: inset 0 0 0 2px #d97706;
}

.positiontable td.status-cell .status-pos-hint {
    margin-top: 3px;
    font-size: 0.68em;
    line-height: 1.1;
    font-weight: 700;
    color: #92400e;
    opacity: 0.98;
}

.positiontable td.status-cell.status-buy {
    background: linear-gradient(to right, #86efac, #15803d) !important;
    color: #ffffff !important;
}

.positiontable td.status-cell.status-sell {
    background: linear-gradient(to right, #fca5a5, #b91c1c) !important;
    color: #ffffff !important;
}

.positiontable td.status-cell.status-exit {
    background: linear-gradient(to right, #fde68a, #ca8a04) !important;
    color: #111827 !important;
}

.positiontable td.status-cell.status-empty {
    background: linear-gradient(to right, #d1d5db, #6b7280) !important;
    color: #ffffff !important;
}

.ai-signal {
    display: inline-block;
    min-width: 34px;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.ai-signal-buy {
    color: #0b7a0b;
}

.ai-signal-sell {
    color: #b00020;
}

.ai-signal-error {
    color: #666;
}

.liststocksellbutton {
    background-color: var(--color-loss);
    color: white;
}

.liststocksellbutton:hover:not(:disabled) {
    background-color: #b91c1c;
}

.liststocksellbutton:active:not(:disabled) {
    background-color: var(--color-loss-dark);
    transform: translateY(1px);
}

/* Modal background overlay */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 1; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgba(0, 0, 0, 0.4); /* Black with opacity */
    padding-top: 60px;
}

/* Modal content box */
.modal-content {
    background-color: #fefefe;
    margin: 5% auto; /* 5% from the top and centered */
    padding: 20px;
    border: 1px solid #888;
    width: 80%; /* Could be more or less, depending on screen size */
    max-width: 600px; /* Maximum width for larger screens */
    border-radius: 8px; /* Optional, rounded corners */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); /* Shadow effect */
}

/* Close button styling */
.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: black;
    text-decoration: none;
}

/* Content inside the modal */
#modalContent {
    font-size: 16px;
    color: #333;
    text-align: left;
    line-height: 1.6;
}

/* Styling for new quantity table */
#newquanity {
    width: 100%;
    border-collapse: collapse;
    text-align: center;
    margin-top: 20px;
}

#newquanity th {
    font-size: 1.2em;
    color: black;
    padding: 10px;
}

#newquanity td {
    padding: 10px;
    vertical-align: top;
    text-align: center;
}

/* Styling for stock symbols */
#newquanity td b {
    font-size: 1.2em;
    display: block;
    margin-bottom: 5px;
}

/* Button styling for Buy/Sell buttons in new quantity table */
.liststockbuybutton, .liststocksellbutton {
    display: block;
    width: 60px; /* Fixed width for uniformity */
    padding: 5px;
    margin: 5px auto;
    font-size: 1em;
    font-weight: bold;
    color: white;
    border: none;
    cursor: pointer;
    border-radius: 5px;
}

/* Specific button colors */
.liststockbuybutton {
    background-color: var(--color-profit);
    color: white;
}

.liststockbuybutton:hover {
    background-color: #15803d;
}

.liststockbuybutton:active:not(:disabled) {
    background-color: var(--color-profit-dark);
    transform: translateY(1px);
}

.liststocksellbutton {
    background-color: var(--color-loss);
    color: white;
}

.liststocksellbutton:hover {
    background-color: #b91c1c;
}

.liststocksellbutton:active:not(:disabled) {
    background-color: var(--color-loss-dark);
    transform: translateY(1px);
}

/* Quick Trade redesign */
.quick-trade-panel {
    margin-top: 12px;
    padding: 14px;
    border: 1px solid #ddd;
    border-radius: 10px;
    background: #fafafa;
}

.quick-trade-title {
    font-weight: 700;
    margin-bottom: 10px;
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.form-group {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    flex: 1 1 auto;
}

.actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.quick-trade-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.quick-trade-main-row {
    justify-content: flex-start;
    flex-wrap: nowrap;
}

.quick-trade-symbol-wrap {
    min-width: 240px;
    flex: 1 1 280px;
}

.quick-trade-symbol-input,
.quick-trade-add-input {
    width: 240px;
    max-width: 240px;
    padding: 8px 10px;
    border: 1px solid #bbb;
    border-radius: 6px;
    font-size: 1em;
    box-sizing: border-box;
}

.quick-trade-actions {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 10px;
    align-items: center;
    flex-shrink: 0;
}

.quick-trade-actions .liststockbuybutton,
.quick-trade-actions .liststocksellbutton {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    min-width: 86px;
    margin: 0;
    padding: 8px 14px;
    line-height: 1.1;
}

.quick-trade-add-row {
    margin-top: 10px;
}

.quick-trade-add-btn {
    padding: 8px 12px;
    border: 1px solid #aaa;
    border-radius: 6px;
    background: #f2f2f2;
    cursor: pointer;
}

.quick-trade-add-btn:hover {
    background: #e6e6e6;
}

.quick-trade-message {
    margin-top: 10px;
    font-size: 13px;
    min-height: 18px;
}

/* Responsive adjustments for iPhone 14 Pro Max and similar screens */
@media only screen and (max-width: 430px) {
    /* Header container responsive */
    .header-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .header-controls {
        width: 100%;
        margin-left: 0;
        gap: 12px;
        flex-wrap: wrap;
    }

    #api_mode {
        width: 100%;
        min-width: 0;
    }

    .account-info-grid {
        grid-template-columns: repeat(2, minmax(120px, 1fr));
    }

    .account-info-value {
        font-size: 20px;
    }

    .broker-checkboxes {
        width: 100%;
        justify-content: flex-start;
        gap: 8px;
    }

    .profile-checkboxes {
        width: 100%;
        justify-content: flex-start;
        gap: 12px;
    }

    .timeframe-checkboxes {
        width: 100%;
        justify-content: flex-start;
        gap: 8px;
    }

    .broker-checkbox-label {
        font-size: 0.9em;
    }

    /* Adjust table cells for smaller screens */
    .positiontable th, .positiontable td {
        padding: 8px;
        font-size: 14px;
    }

    .positiontable td.est-col,
    .positiontable td.gamma-col {
        font-size: 12.6px; /* 90% of 14px cell size */
    }

    /* Make buttons full-width in smaller screens, except in horizontal flex cells */
    .liststockbuybutton, .liststocksellbutton, .button {
        font-size: 0.9em;
    }

    .quick-trade-main-row {
        flex-wrap: nowrap;
    }

    .quick-trade-symbol-wrap {
        flex: 1 1 100%;
        min-width: 100%;
    }

    .quick-trade-symbol-input,
    .quick-trade-add-input {
        width: 100%;
        max-width: 100%;
    }

    .quick-trade-actions {
        width: auto;
        margin-left: 0;
        justify-content: flex-start;
    }
    
    /* Preserve right alignment for Buy/Sell + EXIT on small screens */
    .positiontable td:nth-child(14),
    .positiontable td:nth-child(15) {
        text-align: right !important;
    }

    /* Keep ONE + Flip centered on small screens too */
    .positiontable td:nth-child(11),
    .positiontable td:nth-child(12) {
        text-align: center !important;
    }

    /* Stack Buy and Sell buttons vertically */
    #newquanity td {
        padding: 10px;
    }

    /* Reduce font size for stock symbols */
    #newquanity td b {
        font-size: 1em;
    }

    /* Make table rows stack vertically */
    #newquanity tr {
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    /* Hide header row for a cleaner layout on small screens */
    #newquanity th {
        display: none;
    }

    .tour-step-picker {
        width: 40px;
        height: 40px;
        font-size: 22px;
    }

    .guided-tour-popover {
        width: calc(100vw - 16px);
        max-width: calc(100vw - 16px);
        left: 8px !important;
        right: 8px !important;
    }
}

/* Stocks settings (STOCKS JSON editor) */
.stocks-settings-form.config-form {
    max-width: 1180px;
}

.stocks-add-panel {
    margin-bottom: 20px;
    padding: 18px 20px;
}

.stocks-add-heading {
    margin: 0 0 8px 0;
    font-size: 18px;
    font-weight: 600;
    color: #111827;
}

.stocks-add-grid {
    display: flex;
    flex-flow: row nowrap;
    align-items: flex-end;
    gap: 12px 14px;
    margin-top: 12px;
    overflow-x: auto;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
}

.stocks-add-field {
    flex: 0 1 auto;
    min-width: 0;
}

.stocks-add-field-category {
    flex: 1 1 160px;
    min-width: 140px;
    max-width: 220px;
}

.stocks-add-field-newcat {
    flex: 1 1 150px;
    min-width: 130px;
    max-width: 200px;
}

.stocks-add-field-symbol {
    flex: 0 1 100px;
    min-width: 88px;
    max-width: 120px;
}

.stocks-add-field-timeframe {
    flex: 0 1 120px;
    min-width: 100px;
    max-width: 140px;
}

.stocks-add-field-quantity {
    flex: 0 1 88px;
    min-width: 72px;
    max-width: 100px;
}

.stocks-add-trade-field {
    flex: 0 1 auto;
    min-width: 120px;
    max-width: 200px;
}

.stocks-add-field-submit {
    flex: 0 0 auto;
}

.stocks-add-submit-label {
    visibility: hidden;
    margin-bottom: 6px;
    min-height: 1.2em;
    user-select: none;
}

.stocks-add-grid .form-help {
    display: none;
}

.stocks-add-field .form-label {
    margin-bottom: 6px;
}

.stocks-add-trade-field .form-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.stocks-add-field .form-select,
.stocks-add-field .form-input {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.stocks-add-save-btn {
    margin-top: 0;
    white-space: nowrap;
}

.stocks-bulk-trade-wrap {
    margin-bottom: 16px;
    padding: 16px 20px;
}

.stocks-bulk-trade-wrap .stocks-bulk-trade-label {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
    cursor: pointer;
}

.stocks-bulk-trade-wrap .form-help {
    margin-top: 0;
    margin-left: 28px;
}

.stocks-config-container .stocks-category {
    margin-bottom: 24px;
}

.stocks-row {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    padding: 10px 0;
    border-bottom: 1px solid #E5E7EB;
}

.stocks-row:last-child {
    border-bottom: none;
}

.stocks-row-symbol {
    flex: 0 0 88px;
    font-weight: 600;
    font-size: 15px;
    color: #111827;
}

.stocks-trade-wrap {
    flex: 0 0 auto;
    margin-bottom: 0 !important;
    font-weight: 500;
}

.stocks-qty-wrap {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    min-width: 72px;
}

.stocks-qty-label {
    margin: 0 !important;
    font-size: 12px;
    font-weight: 600;
    color: #374151;
}

/* Rounded SL/TP % from POST /stock/sltp (client_name + stock + timeframe 4h) */
.stocks-sltp-hint {
    color: #2563eb;
    font-weight: 700;
    white-space: nowrap;
}

.stocks-qty-input {
    width: 72px;
    max-width: 100%;
    padding: 6px 8px;
    font-size: 14px;
    box-sizing: border-box;
}

/* Keep quantity + hour bucket select adjacent (no space-between gap). */
.stocks-qty-tf-group {
    display: flex;
    flex-flow: row nowrap;
    align-items: flex-start;
    gap: 10px;
    flex: 0 0 auto;
}

.stocks-tf-wrap {
    flex: 0 0 160px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
}

.stocks-tf-wrap .small-select {
    width: 100%;
    font-size: 14px;
}

/* TV alert log graph modal (STATUS / Alert hover) */
#myModal.tv-alert-log-modal-open .modal-content.tv-alert-log-modal-wide {
    max-width: min(920px, 96vw);
}

#myModal.tv-alert-log-modal-open .modal-content.tv-alert-log-modal-wide.tv-alert-log-modal-maximized {
    width: 98vw;
    max-width: 98vw;
    margin: 1vh auto;
    max-height: 96vh;
    overflow: auto;
}

.tv-alert-log-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.tv-alert-log-header-main {
    min-width: 0;
}

.tv-alert-log-modal .tv-alert-log-title {
    margin: 0 0 12px 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #0f172a;
}

.tv-alert-log-latest-msg {
    margin-top: -4px;
    margin-bottom: 8px;
    display: inline-block;
    max-width: 100%;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: #1e293b;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tv-alert-log-max-btn {
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: #0f172a;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
}

.tv-alert-log-max-btn:hover,
.tv-alert-log-max-btn:focus {
    background: #e2e8f0;
}

.tv-alert-log-modal .tv-alert-log-error {
    color: #b91c1c;
}

.tv-alert-log-subtitle {
    margin: 8px 0 6px;
    font-size: 12px;
    font-weight: 700;
    color: #334155;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.tv-alert-log-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.tv-alert-chip {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    background: #f8fafc;
    color: #1e293b;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.tv-alert-price-wrap {
    position: relative;
}

.tv-alert-price-label-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.tv-alert-overlay-tag {
    position: absolute;
    transform: translate(-50%, -100%);
    white-space: nowrap;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.25);
    text-transform: none;
    letter-spacing: 0.01em;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.tv-alert-overlay-tag.buy {
    background: #16a34a;
}

.tv-alert-overlay-tag.sell {
    background: #dc2626;
}

.tv-alert-overlay-tag.exit {
    background: #d97706;
}

.tv-alert-log-legend {
    margin: 12px 0 0 0;
    padding-left: 1.1em;
    max-height: 160px;
    overflow: auto;
    font-size: 12px;
    color: #334155;
}

.tv-alert-log-legend li {
    margin-bottom: 4px;
}

.tv-alert-log-dt {
    font-family: ui-monospace, monospace;
    margin-right: 8px;
    color: #64748b;
}

.tv-alert-log-tf {
    margin-left: 4px;
    font-size: 11px;
    color: #64748b;
}

.tv-alert-log-ind {
    display: inline-block;
    margin-left: 6px;
    font-size: 11px;
    color: #475569;
    white-space: normal;
}

.tv-alert-log-modal canvas#tvAlertLogPriceChartCanvas {
    display: block;
    width: 100% !important;
    height: 260px !important;
}
