:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e9ecef;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --accent-primary: #4285f4;
    --accent-hover: #5a95f5;
    --success: #34a853;
    --warning: #fbbc04;
    --error: #ea4335;
    --border: #dee2e6;
}

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

body {
    font-family: 'Lato', 'Helvetica Neue', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    animation: fadeIn 0.4s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

nav {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    animation: slideDown 0.5s ease-out;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    letter-spacing: -0.5px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent-primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-brand:hover {
    transform: scale(1.05);
    filter: brightness(1.1);
}

.nav-links {
    display: flex;
    gap: 0.2rem;
    list-style: none;
    align-items: center;
}

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.85rem;
    position: relative;
}

.nav-links a::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--accent-primary);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateX(-50%);
}

.nav-links a:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
    transform: translateY(-2px);
}

.nav-links a:hover::before {
    width: 80%;
}

.nav-links a.active {
    color: var(--accent-primary);
    background: rgba(66, 133, 244, 0.1);
}

.nav-links a.active::before {
    width: 80%;
}

.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    animation: fadeInUp 0.5s ease-out;
}

.card:hover {
    transform: translateY(-4px) scale(1.01);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.1);
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    display: inline-block;
    font-family: inherit;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:active::before {
    width: 300px;
    height: 300px;
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 20px rgba(66, 133, 244, 0.4);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #2d9348;
    transform: translateY(-1px);
}

.btn-danger {
    background: var(--error);
    color: white;
}

.btn-danger:hover {
    background: #d33828;
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 1rem;
}

thead {
    background: var(--bg-tertiary);
}

th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

tr {
    transition: background 0.2s ease;
}

tbody tr {
    animation: fadeInRow 0.4s ease-out;
    animation-fill-mode: both;
}

tbody tr:nth-child(1) {
    animation-delay: 0.05s;
}

tbody tr:nth-child(2) {
    animation-delay: 0.1s;
}

tbody tr:nth-child(3) {
    animation-delay: 0.15s;
}

tbody tr:nth-child(4) {
    animation-delay: 0.2s;
}

tbody tr:nth-child(5) {
    animation-delay: 0.25s;
}

tbody tr:nth-child(n+6) {
    animation-delay: 0.3s;
}

@keyframes fadeInRow {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

tbody tr:hover {
    background: var(--bg-tertiary);
    transform: translateX(4px);
    transition: all 0.2s ease;
}

.status-badge {
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-block;
}

.status-forwarded {
    background: #d4edda;
    color: #155724;
}

.status-skipped {
    background: #fff3cd;
    color: #856404;
}

.status-failed {
    background: #f8d7da;
    color: #721c24;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    background: white;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    transition: all 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.1);
    transform: translateY(-1px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-control option {
    background: white;
}

.alert {
    padding: 1rem 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.alert-success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.alert-error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.alert-warning {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    color: #856404;
}

.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 3rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    animation: scaleIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.login-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 2rem;
    text-align: center;
    color: var(--text-primary);
    animation: fadeInUp 0.6s ease-out 0.2s both;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent-primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.grid {
    display: grid;
    gap: 1.5rem;
}

.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.stat-card {
    background: var(--bg-tertiary);
    padding: 1.5rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-6px) scale(1.02);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15);
    border-color: var(--accent-primary);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.dark-window-indicator {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: pulse 2s ease-in-out infinite;
    color: #721c24;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.8;
    }
}

.dark-window-indicator::before {
    content: "🌙";
    font-size: 1.5rem;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

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

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    border: 1px solid var(--border);
    transition: 0.3s;
    border-radius: 26px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

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

input:checked+.toggle-slider:before {
    transform: translateX(24px);
    background-color: white;
}

.config-table {
    overflow-x: auto;
}

.config-table table {
    min-width: 800px;
}

.pagination {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 2rem;
    list-style: none;
}

.pagination a {
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    text-decoration: none;
    transition: all 0.2s ease;
}

.pagination a:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-primary);
}

.pagination .active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state-text {
    font-size: 1.1rem;
}

.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top-color: var(--accent-primary);
    animation: spin 1s ease-in-out infinite;
}

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

.time-info {
    background: var(--bg-tertiary);
    padding: 0.75rem 1rem;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.time-info strong {
    color: var(--text-primary);
}

.text-success {
    color: var(--success);
}

.text-error {
    color: var(--error);
}

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

@media (max-width: 768px) {
    .nav-links {
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .nav-links a {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
    }

    .card {
        padding: 1rem;
    }

    table {
        font-size: 0.85rem;
    }

    th,
    td {
        padding: 0.75rem 0.5rem;
    }
}

/* Connection Status Indicator */
.connection-status {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.connection-status .status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    animation: pulse-dot 2s ease-in-out infinite;
}

.connection-status.connected {
    background: rgba(52, 168, 83, 0.15);
    color: var(--success);
}

.connection-status.connected .status-dot {
    background: var(--success);
}

.connection-status.disconnected {
    background: rgba(234, 67, 53, 0.15);
    color: var(--error);
}

.connection-status.disconnected .status-dot {
    background: var(--error);
}

.connection-status.error {
    background: rgba(234, 67, 53, 0.15);
    color: var(--error);
}

.connection-status.error .status-dot {
    background: var(--error);
}

.connection-status.connecting {
    background: rgba(251, 188, 4, 0.15);
    color: var(--warning);
}

.connection-status.connecting .status-dot {
    background: var(--warning);
}

@keyframes pulse-dot {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* Price Flash Animations */
.price-flash-up {
    animation: flash-green 0.5s ease-out;
}

.price-flash-down {
    animation: flash-red 0.5s ease-out;
}

@keyframes flash-green {
    0% {
        background-color: rgba(52, 168, 83, 0.4);
    }

    100% {
        background-color: transparent;
    }
}

@keyframes flash-red {
    0% {
        background-color: rgba(234, 67, 53, 0.4);
    }

    100% {
        background-color: transparent;
    }
}

/* P&L Colors */
.pnl-positive {
    color: var(--success);
    font-weight: 600;
}

.pnl-negative {
    color: var(--error);
    font-weight: 600;
}