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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #0a0e1a;
    min-height: 100vh;
    padding: 20px;
    color: #e4e6eb;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: #1a1f2e;
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.main-layout {
    display: flex;
    gap: 30px;
}

.calculator-section {
    flex: 1;
    min-width: 0;
}

.sidebar-section {
    width: 320px;
    flex-shrink: 0;
}

h1 {
    color: #e4e6eb;
    margin-bottom: 10px;
    font-size: 2em;
    font-weight: 600;
}

.subtitle {
    color: #9ba3af;
    margin-bottom: 30px;
    font-size: 1em;
}

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

label {
    display: block;
    margin-bottom: 5px;
    color: #9ba3af;
    font-weight: 500;
    font-size: 14px;
}

input[type="text"],
input[type="number"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #2d3748;
    border-radius: 6px;
    font-size: 15px;
    transition: border-color 0.2s;
    background: #0f1419;
    color: #e4e6eb;
}

input[type="text"]:focus,
input[type="number"]:focus {
    outline: none;
    border-color: #4a5568;
}

input[readonly] {
    background-color: #1a1f2e;
    cursor: not-allowed;
    color: #6b7280;
}

small {
    display: block;
    margin-top: 5px;
    color: #6b7280;
    font-size: 0.85em;
}

.horse-entry {
    background: #0f1419;
    padding: 10px 15px;
    border-radius: 6px;
    margin-bottom: 6px;
    position: relative;
    border: 1px solid #2d3748;
    display: flex;
    align-items: center;
    gap: 8px;
}

.horse-entry:hover {
    background: #1a1f2e;
    border-color: #374151;
}

.horse-entry label {
    display: inline;
    margin-bottom: 0;
    font-size: 13px;
    white-space: nowrap;
    color: #9ba3af;
}

.horse-entry .compact-input {
    width: 60px;
    padding: 6px 8px;
    font-size: 14px;
}

.horse-entry .form-group {
    margin-bottom: 15px;
}

.horse-entry .form-group:last-of-type {
    margin-bottom: 0;
}

.button-group {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

button {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.add-btn {
    background: #059669;
    color: white;
    flex: 1;
}

.add-btn:hover {
    background: #047857;
}

.clear-btn {
    background: #d97706;
    color: white;
    flex: 1;
}

.clear-btn:hover {
    background: #b45309;
}

.submit-btn {
    background: #3b82f6;
    color: white;
    flex: 2;
}

.submit-btn:hover {
    background: #2563eb;
}

.scratch-btn {
    background: #dc2626;
    color: white;
    padding: 6px 12px;
    font-size: 13px;
    margin-left: auto;
}

.scratch-btn:hover {
    background: #b91c1c;
}

.running-total {
    background: #0f1419;
    padding: 15px;
    border-radius: 6px;
    margin: 20px 0;
    text-align: center;
    font-size: 1em;
    border: 1px solid #2d3748;
}

.running-total strong {
    color: #9ba3af;
}

#totalValue {
    color: #3b82f6;
    font-size: 1.3em;
    font-weight: 600;
}

.diff-perfect {
    color: #10b981;
    font-weight: 600;
    margin-left: 10px;
}

.diff-over {
    color: #ef4444;
    margin-left: 10px;
}

.diff-under {
    color: #f59e0b;
    margin-left: 10px;
}

.error {
    background: #7f1d1d;
    color: #fca5a5;
    padding: 15px;
    border-radius: 6px;
    margin-top: 20px;
    border: 1px solid #991b1b;
}

.results {
    margin-top: 30px;
    padding-top: 30px;
    border-top: 1px solid #2d3748;
}

.results h2 {
    color: #e4e6eb;
    margin-bottom: 20px;
    font-size: 1.4em;
    font-weight: 600;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-bottom: 15px;
    font-size: 14px;
}

thead {
    background: #0f1419;
    color: #9ba3af;
}

th, td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #2d3748;
}

th {
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

tbody tr {
    background: #1a1f2e;
}

tbody tr:nth-child(even) {
    background: #0f1419;
}

tbody tr:hover {
    background: #252d3d;
}

.horse-name {
    font-weight: 500;
    color: #e4e6eb;
}

.probability-cell {
    color: #9ba3af;
}

.odds {
    font-weight: 600;
    color: #3b82f6;
    font-size: 1.05em;
}

.total {
    text-align: right;
    font-weight: 600;
    color: #e4e6eb;
    padding: 12px;
    background: #0f1419;
    border-radius: 6px;
    border: 1px solid #2d3748;
}

.saved-races {
    padding: 20px;
    background: #0f1419;
    border-radius: 8px;
    border: 1px solid #2d3748;
    height: fit-content;
    position: sticky;
    top: 20px;
}

.saved-races h2 {
    color: #e4e6eb;
    margin-bottom: 15px;
    font-size: 1.2em;
    font-weight: 600;
}

.saved-races-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.saved-race-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: #1a1f2e;
    border-radius: 6px;
    border: 1px solid #2d3748;
    transition: all 0.2s;
}

.saved-race-item:hover {
    background: #252d3d;
    border-color: #374151;
}

.race-name {
    font-weight: 500;
    color: #e4e6eb;
    flex: 1;
    font-size: 14px;
}

.race-actions {
    display: flex;
    gap: 8px;
}

.load-btn {
    background: #3b82f6;
    color: white;
    padding: 6px 14px;
    font-size: 13px;
}

.load-btn:hover {
    background: #2563eb;
}

.delete-btn {
    background: #dc2626;
    color: white;
    padding: 6px 14px;
    font-size: 13px;
}

.delete-btn:hover {
    background: #b91c1c;
}

.save-race-form {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    align-items: center;
}

.save-race-form input {
    flex: 1;
    padding: 10px;
    border: 1px solid #2d3748;
    border-radius: 6px;
    font-size: 14px;
    background: #0f1419;
    color: #e4e6eb;
}

.save-btn {
    background: #059669;
    color: white;
    padding: 10px 20px;
    white-space: nowrap;
    font-size: 14px;
}

.save-btn:hover {
    background: #047857;
}

.adjust-cell {
    display: flex;
    gap: 5px;
}

.adjust-btn {
    background: #374151;
    color: #e4e6eb;
    padding: 6px 12px;
    font-size: 13px;
    border: 1px solid #4b5563;
}

.adjust-btn:hover {
    background: #4b5563;
    border-color: #6b7280;
}

.fade-cell {
    min-width: 180px;
}

.fade-select {
    width: 100%;
    padding: 6px 8px;
    background: #0f1419;
    color: #e4e6eb;
    border: 1px solid #2d3748;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.fade-select:hover {
    background: #1a1f2e;
    border-color: #4b5563;
}

.fade-select:focus {
    outline: none;
    border-color: #667eea;
}

.fade-select option {
    background: #1a1f2e;
    color: #e4e6eb;
}

.lock-cell {
    text-align: center;
}

.lock-btn {
    background: transparent;
    border: 1px solid #4b5563;
    color: #9ba3af;
    padding: 6px 12px;
    font-size: 16px;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
}

.lock-btn:hover {
    background: #374151;
    border-color: #6b7280;
}

.lock-btn[data-locked="true"] {
    background: #7c2d12;
    color: #fb923c;
    border-color: #ea580c;
}

tbody tr.locked {
    background: #1e1410 !important;
    border-left: 3px solid #ea580c;
}

tbody tr.locked:hover {
    background: #292116 !important;
}

tbody tr.unlocked {
    background: #1a1f2e;
}

tbody tr.unlocked:nth-child(even) {
    background: #0f1419;
}

tbody tr.unlocked:hover {
    background: #252d3d;
}

@media (max-width: 900px) {
    .main-layout {
        flex-direction: column;
    }
    
    .sidebar-section {
        width: 100%;
        order: -1;
    }
    
    .saved-races {
        position: static;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 20px;
    }
    
    h1 {
        font-size: 1.5em;
    }
    
    .button-group {
        flex-direction: column;
    }
    
    table {
        font-size: 0.85em;
    }
    
    th, td {
        padding: 10px 12px;
    }
    
    .save-race-form {
        flex-direction: column;
    }
    
    .save-race-form input,
    .save-btn {
        width: 100%;
    }
    
    .adjust-cell {
        flex-direction: column;
    }
}
