:root {
    /* MD3 Dark Theme Tokens */
    --md-sys-color-background: #121212;
    --md-sys-color-surface: #1e1e1e;
    --md-sys-color-surface-variant: #2d2d2d;
    --md-sys-color-on-background: #e3e3e3;
    --md-sys-color-on-surface: #e3e3e3;
    --md-sys-color-on-surface-variant: #c4c7c5;
    
    --md-sys-color-primary: #a8c7fa;
    --md-sys-color-on-primary: #062e6f;
    --md-sys-color-primary-container: #004a77;
    --md-sys-color-on-primary-container: #c2e7ff;
    
    --md-sys-color-error: #ffb4ab;
    --md-sys-color-on-error: #690005;
    --md-sys-color-error-container: #93000a;
    --md-sys-color-on-error-container: #ffb4ab;
    
    --md-sys-color-success: #6dd58c;
    --md-sys-color-on-success: #003915;
    
    /* Typography */
    --font-family: 'Inter', sans-serif;
    
    /* Elevation / Shadows */
    --md-elevation-1: 0px 1px 3px 1px rgba(0, 0, 0, 0.15), 0px 1px 2px 0px rgba(0, 0, 0, 0.30);
    --md-elevation-2: 0px 2px 6px 2px rgba(0, 0, 0, 0.15), 0px 1px 2px 0px rgba(0, 0, 0, 0.30);
}

[data-theme="light"] {
    /* MD3 Light Theme Tokens */
    --md-sys-color-background: #fdfdfd;
    --md-sys-color-surface: #f3f4f9;
    --md-sys-color-surface-variant: #e1e3e8;
    --md-sys-color-on-background: #1a1b1f;
    --md-sys-color-on-surface: #1a1b1f;
    --md-sys-color-on-surface-variant: #44474e;
    
    --md-sys-color-primary: #0061a4;
    --md-sys-color-on-primary: #ffffff;
    --md-sys-color-primary-container: #d1e4ff;
    --md-sys-color-on-primary-container: #001d36;
    
    --md-sys-color-error: #ba1a1a;
    --md-sys-color-on-error: #ffffff;
    --md-sys-color-error-container: #ffdad6;
    --md-sys-color-on-error-container: #410002;
    
    --md-sys-color-success: #196c34;
    --md-sys-color-on-success: #ffffff;
    
    --md-elevation-1: 0px 1px 2px 0px rgba(0, 0, 0, 0.30), 0px 1px 3px 1px rgba(0, 0, 0, 0.15);
    --md-elevation-2: 0px 1px 2px 0px rgba(0, 0, 0, 0.30), 0px 2px 6px 2px rgba(0, 0, 0, 0.15);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--md-sys-color-background);
    color: var(--md-sys-color-on-background);
    min-height: 100vh;
    display: flex;
    justify-content: center;
}

.app-container {
    width: 100%;
    max-width: 1200px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* App Bar */
.app-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background-color: var(--md-sys-color-surface);
    border-radius: 100px;
    box-shadow: var(--md-elevation-1);
}

.app-bar-title {
    font-size: 1.25rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    font-weight: 500;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--md-sys-color-on-surface-variant);
}

.status-dot.connected {
    background-color: var(--md-sys-color-success);
    box-shadow: 0 0 8px var(--md-sys-color-success);
}

.status-dot.disconnected {
    background-color: var(--md-sys-color-error);
}

.theme-toggle {
    background: none;
    border: none;
    color: var(--md-sys-color-on-surface-variant);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.2s;
}
.theme-toggle:hover {
    background-color: var(--md-sys-color-surface-variant);
}

/* Cards */
.dashboard-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 24px;
}

.card {
    background-color: var(--md-sys-color-surface);
    border-radius: 24px;
    padding: 24px;
    box-shadow: var(--md-elevation-1);
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: var(--md-elevation-2);
}

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--md-sys-color-primary);
}

/* MTM Hero */
.mtm-hero {
    align-items: center;
    text-align: center;
    padding: 40px 24px;
    background: linear-gradient(145deg, var(--md-sys-color-surface), var(--md-sys-color-surface-variant));
}

.mtm-value-container {
    font-size: 4rem;
    font-weight: 700;
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 8px;
    margin: 16px 0;
    transition: color 0.3s ease;
}

.mtm-value-container.positive {
    color: var(--md-sys-color-success);
}

.mtm-value-container.negative {
    color: var(--md-sys-color-error);
}

.mtm-currency {
    font-size: 2rem;
    opacity: 0.8;
}

.mtm-subtitle {
    color: var(--md-sys-color-on-surface-variant);
    font-size: 0.875rem;
}

.bot-mtm-container {
    margin-top: 16px;
    padding: 8px 16px;
    background-color: var(--md-sys-color-surface-variant);
    border-radius: 100px;
    font-weight: 500;
}

/* Settings Row & Switch */
.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.setting-info h3 {
    font-size: 1rem;
    font-weight: 500;
}

.setting-info p {
    font-size: 0.875rem;
    color: var(--md-sys-color-on-surface-variant);
    margin-top: 4px;
}

/* MD3 Switch */
.md-switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 32px;
}

.md-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.md-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--md-sys-color-surface-variant);
    transition: .4s;
    border-radius: 34px;
    border: 2px solid var(--md-sys-color-on-surface-variant);
}

.md-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: var(--md-sys-color-on-surface-variant);
    transition: .3s cubic-bezier(0.2, 0.85, 0.32, 1.2);
    border-radius: 50%;
}

input:checked + .md-slider {
    background-color: var(--md-sys-color-primary);
    border-color: var(--md-sys-color-primary);
}

input:checked + .md-slider:before {
    background-color: var(--md-sys-color-on-primary);
    transform: translateX(20px);
    width: 24px;
    height: 24px;
    bottom: 2px;
}

/* Buttons */
.md-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 24px;
    border-radius: 100px;
    border: none;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, box-shadow 0.2s, transform 0.1s;
}

.md-button:active {
    transform: scale(0.98);
}

.md-button.primary {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
}

.md-button.primary:hover {
    background-color: #b9d3fa; /* slightly lighter */
    box-shadow: var(--md-elevation-1);
}

.md-button.danger {
    background-color: var(--md-sys-color-error-container);
    color: var(--md-sys-color-on-error-container);
    width: 100%;
    margin-top: 12px;
}

.md-button.danger:hover {
    background-color: #b0000c;
}

/* Inputs */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-group label {
    font-size: 0.875rem;
    color: var(--md-sys-color-on-surface-variant);
}

.input-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    background-color: var(--md-sys-color-surface-variant);
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid transparent;
    transition: border-color 0.2s;
}

.input-wrapper:focus-within {
    border-color: var(--md-sys-color-primary);
}

.input-wrapper span {
    color: var(--md-sys-color-on-surface-variant);
}

.input-wrapper input {
    background: transparent;
    border: none;
    color: var(--md-sys-color-on-surface);
    font-family: inherit;
    font-size: 1rem;
    width: 100%;
    outline: none;
}

/* Strategies List */
.strategies-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.strategy-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background-color: var(--md-sys-color-surface-variant);
    border-radius: 16px;
}

.strategy-name {
    font-weight: 500;
}

.divider {
    height: 1px;
    background-color: var(--md-sys-color-surface-variant);
    margin: 8px 0;
}

.danger-zone h3 {
    color: var(--md-sys-color-error);
    font-size: 1rem;
    font-weight: 500;
}

.danger-zone p {
    font-size: 0.875rem;
    color: var(--md-sys-color-on-surface-variant);
    margin-top: 4px;
}

/* Snackbar */
.snackbar {
    visibility: hidden;
    min-width: 250px;
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    text-align: center;
    border-radius: 8px;
    padding: 16px;
    position: fixed;
    z-index: 1;
    left: 50%;
    bottom: 30px;
    transform: translateX(-50%);
    box-shadow: var(--md-elevation-2);
}

.snackbar.show {
    visibility: visible;
    animation: fadein 0.5s, fadeout 0.5s 2.5s;
}

@keyframes fadein {
    from {bottom: 0; opacity: 0;}
    to {bottom: 30px; opacity: 1;}
}

@keyframes fadeout {
    from {bottom: 30px; opacity: 1;}
    to {bottom: 0; opacity: 0;}
}
