:root {
    color-scheme: dark;
    /* Force system controls (dropdowns) to dark mode */
    /* Core Colors */
    --clr-bg: #0800ff;
    /* Cobalt Blue */
    --clr-text: #ffffff;
    --clr-divider: rgba(255, 255, 255, 0.2);

    /* Accents */
    --clr-accent: rgba(255, 255, 255, 0.12);
    /* Soft White Accent */
    --clr-highlight: rgba(255, 255, 255, 0.2);
    /* Mid Accent */

    /* Spacing */
    --space-unit: 20px;
    --tiers-gap: 60px;
}

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

body {
    background-color: var(--clr-bg);
    color: var(--clr-text);
    font-family: 'Shippori Mincho B1', serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    /* Allow stacking */
    align-items: center;
    /* Center horizontally */
    padding: 60px 20px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.shine-hover {
    transition: all 0.3s ease;
}

.shine-hover:hover {
    background-color: rgba(255, 255, 255, 0.15) !important;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.8) !important;
}

.container {
    width: 100%;
    max-width: 720px;
    /* Editorial width */
}

/* HEADER */
header {
    margin-bottom: 80px;
    text-align: center;
}

h1 {
    font-size: 32px;
    font-weight: 400;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
}

.subtitle {
    font-size: 14px;
    opacity: 0.8;
    font-weight: 400;
    letter-spacing: 0.02em;
}

/* CONFIG BAR */
.config-bar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    margin-bottom: 60px;
    /* Card Style */
    background: rgba(255, 255, 255, 0.08);
    padding: 30px;
    border-radius: 6px;
    /* Standardized radius */
}

/* TIERS */
.tier-section {
    margin-bottom: var(--tiers-gap);
    border-bottom: 1px solid var(--clr-divider);
    padding-bottom: 40px;
}

.tier-header {
    margin-bottom: 30px;
    display: flex;
    align-items: baseline;
}

.tier-title {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    opacity: 0.8;
}

/* GRID */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px 30px;
    /* Row Gap, Column Gap */
}

/* CONTROLS */
.control-group {
    margin-bottom: 0;
    position: relative;
}

label {
    display: block;
    font-size: 13px;
    margin-bottom: 12px;
    opacity: 0.9;
}

/* SLIDERS - Custom Minimal */
.slider-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 4px;
    /* Reduced from 8px for tighter spacing */
}

.slider-val {
    font-size: 16px;
    font-variant-numeric: tabular-nums;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 30px;
    /* Bigger hit area */
    background: transparent;
    margin: 0;
    /* Centered by height */
    cursor: pointer;
    position: relative;
    z-index: 1;
}

input[type="range"]::-webkit-slider-runnable-track {
    width: 100%;
    height: 1px;
    background: rgba(255, 255, 255, 0.4);
    border: none;
    cursor: pointer;
    /* Clickable track */
    transition: background 0.2s;
}

/* Subtle track hover feedback */
input[type="range"]:hover::-webkit-slider-runnable-track {
    background: rgba(255, 255, 255, 0.55);
}

/* Smaller, lighter thumb */
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 12px;
    /* Even smaller thumb */
    width: 12px;
    border-radius: 50%;
    background: var(--clr-text);
    cursor: pointer;
    margin-top: -6px;
    /* Centered: half of 12px */
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
    transition: box-shadow 0.2s ease, transform 0.15s ease;
    position: relative;
    z-index: 2;
}

/* Better hover feedback */
input[type="range"]::-webkit-slider-thumb:hover {
    box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

/* Active state */
input[type="range"]:active::-webkit-slider-thumb {
    box-shadow: 0 0 0 8px rgba(255, 255, 255, 0.3);
}

/* Keyboard accessibility */
input[type="range"]:focus {
    outline: none;
}

input[type="range"]:focus-visible::-webkit-slider-thumb {
    box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.35);
}

/* DROPDOWNS & INPUTS */
select,
input[type="text"] {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    color: var(--clr-text);
    font-family: inherit;
    font-size: 15px;
    padding: 10px 0;
    border-radius: 0;
    cursor: pointer;
    transition: border-color 0.2s;
    /* Force custom look */
    -webkit-appearance: none;
    appearance: none;
    color-scheme: dark;
}

/* Custom Arrow for Dropdowns */
select {
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23FFFFFF%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E');
    background-repeat: no-repeat;
    background-position: right 0 top 50%;
    background-size: 10px auto;
    padding-right: 20px;
    /* Force transparency on Mac */
    background-color: transparent !important;
    -moz-appearance: none;
    -webkit-appearance: none;
    appearance: none;
}

select:focus,
input:focus {
    outline: none;
    border-bottom-color: var(--clr-text);
}

select option {
    background-color: #0700d6;
    color: #ffffff;
    padding: 12px 16px;
}

/* Helper text context */
.helper-text {
    font-size: 12px;
    opacity: 0.6;
    margin-top: 8px;
    font-style: italic;
}

/* TOGGLE BUTTONS */
.toggle-group {
    display: flex;
    gap: 20px;
    margin-top: 20px;
}

.toggle-opt {
    cursor: pointer;
    font-size: 14px;
    opacity: 0.5;
    padding-bottom: 4px;
    border-bottom: 1px solid transparent;
    transition: all 0.2s;
}

.toggle-opt:hover {
    opacity: 0.8;
}

.toggle-opt.active {
    opacity: 1;
    border-bottom-color: var(--clr-text);
}

.hidden {
    display: none;
}

/* ACTION AREA */
.action-bar {
    margin-top: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

button.primary-btn {
    background: rgba(255, 255, 255, 0.05);
    color: var(--clr-text);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 6px;
    /* Standardized radius */
    padding: 18px 40px;
    font-size: 16px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.3s ease;
    letter-spacing: 0.05em;
    position: relative;
    overflow: hidden;
}

button.primary-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.8);
    /* Removed text-shadow per requested polish */
}

button.secondary-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: var(--clr-text);
    padding: 8px 16px;
    font-size: 13px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-family: inherit;
    flex: 1;
    transition: all 0.2s ease;
}

button.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.7);
}

button:disabled {
    opacity: 0.5;
    cursor: default;
}

/* RESULTS */
.result-box {
    margin-top: 60px;
    padding-top: 40px;
    border-top: 1px solid var(--clr-divider);
    display: none;
    animation: fadeUp 0.8s ease forwards;
}

.result-score {
    font-size: 48px;
    font-weight: 500;
    /* Reduced weight */
    margin-bottom: 10px;
    letter-spacing: -0.02em;
}


.result-detail {
    font-size: 16px;
    opacity: 0.8;
    line-height: 1.6;
}

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

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

/* ========================================
   CUSTOM DROPDOWN STYLES
   ======================================== */

/* Hide native select elements */
select {
    display: none;
}

/* Custom Select Container */
.custom-select {
    position: relative;
    width: 100%;
}

/* Trigger (the clickable field) */
.select-trigger {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    color: var(--clr-text);
    font-family: inherit;
    font-size: 14px;
    /* Reduced from 15px */
    font-weight: 400;
    /* Explicit weight */
    padding: 10px 20px 10px 0;
    cursor: pointer;
    transition: border-color 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    line-height: 1.5;
    /* Generous line-height */
}

.select-trigger:hover {
    border-bottom-color: rgba(255, 255, 255, 0.5);
}

.custom-select.open .select-trigger {
    border-bottom-color: var(--clr-text);
}

.select-value {
    flex: 1;
}

/* Toned down arrow */
.select-arrow {
    font-size: 8px;
    /* Reduced by ~20% from 10px */
    transition: transform 0.3s ease-out;
    /* Slower, smoother */
    opacity: 0.6;
    /* Reduced from 0.8 */
}

.custom-select.open .select-arrow {
    transform: rotate(180deg);
}

/* Options Panel - Calmer blue */
.select-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    /* Slightly darker than page background for embedded feel */
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.08), rgba(0, 0, 0, 0.05)), var(--clr-bg);
    border: 1px solid rgba(255, 255, 255, 0.2);
    /* Softer border */
    border-radius: 4px;
    margin-top: 8px;
    max-height: 280px;
    overflow-y: auto;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.custom-select.open .select-options {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Individual Option - Quieter */
.select-option {
    padding: 12px 16px;
    color: var(--clr-text);
    cursor: pointer;
    transition: background-color 0.15s;
    font-size: 14px;
    /* Reduced from 15px */
    font-weight: 400;
    /* Normal weight */
    line-height: 1.4;
}

/* Calmer hover */
.select-option:hover {
    background: rgba(255, 255, 255, 0.08);
    /* Reduced from 0.12 */
}

/* Quieter selected state - soft background only */
.select-option.selected {
    background: rgba(255, 255, 255, 0.06);
    /* Very subtle */
    font-weight: 500;
    /* Max 500, not 600 */
}

/* Subtle checkmark */
.select-option.selected::after {
    content: ' ✓';
    float: right;
    opacity: 0.6;
    /* Reduced from 0.7 */
    font-size: 12px;
    /* Smaller */
}

/* Keyboard Navigation - No border, just soft highlight */
.select-option.keyboard-focus {
    background: rgba(255, 255, 255, 0.10);
    /* Removed outline border */
}

/* Custom Scrollbar for Options */
.select-options::-webkit-scrollbar {
    width: 8px;
}

.select-options::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.select-options::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

.select-options::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* Accessibility: Focus State */
.custom-select:focus-within .select-trigger {
    border-bottom-color: var(--clr-text);
    outline: none;
}

/* --- GLOBAL FORM INHERITANCE (Requested) --- */
input,
select,
button,
textarea {
    font-family: inherit;
    color: #ffffff;
}

/* Custom File Upload Styling */
.file-upload-wrapper {
    margin: 0 auto 20px auto;
    text-align: center;
}

.file-upload-input {
    width: 0.1px;
    height: 0.1px;
    opacity: 0;
    overflow: hidden;
    position: absolute;
    z-index: -1;
}

.file-upload-label {
    display: inline-block;
    padding: 12px 24px;
    background: rgba(255, 255, 255, 0.08);
    /* Matches card style */
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.05em;
    color: rgba(255, 255, 255, 0.9);
}

.file-upload-label:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.4);
    color: #ffffff;
    transform: translateY(-1px);
}

.file-upload-label i {
    margin-right: 8px;
    opacity: 0.7;
}

/* --- FLATPICKR OVERRIDES (Cobalt Theme) --- */
.flatpickr-calendar {
    background: #0500a1 !important;
    /* Deep Cobalt */
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5) !important;
    font-family: 'Shippori Mincho B1', serif !important;
}

.flatpickr-month {
    background: transparent !important;
    color: white !important;
    fill: white !important;
}

.flatpickr-current-month span.cur-month {
    font-weight: 600 !important;
}

.flatpickr-weekdays {
    background: transparent !important;
}

span.flatpickr-weekday {
    color: rgba(255, 255, 255, 0.6) !important;
}

.flatpickr-day {
    color: white !important;
}

.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange,
.flatpickr-day.selected.inRange,
.flatpickr-day.startRange.inRange,
.flatpickr-day.endRange.inRange,
.flatpickr-day:focus,
.flatpickr-day:hover {
    background: #4ecdc4 !important;
    /* Cyan accent */
    border-color: #4ecdc4 !important;
    color: #0500a1 !important;
    /* Dark text for contrast */
    font-weight: bold !important;
}

.flatpickr-day.today {
    border-color: rgba(255, 255, 255, 0.5) !important;
}

/* --- MINIMAL BADGES (User Requested) --- */
.priority-badge {
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: 500;
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    display: inline-block;
    white-space: nowrap;
}

.badge-p0 {
    border-color: rgba(255, 255, 255, 0.7);
    background: rgba(255, 255, 255, 0.2);
    font-weight: 600;
}

.badge-p1 {
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.1);
}

.badge-p2 {
    border-color: rgba(255, 255, 255, 0.2);
}

.badge-ignore {
    opacity: 0.6;
    border-style: dashed;
}

/* Driver Pills - Minimal */
.driver-pill {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8em;
    margin-right: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.02);
    color: rgba(255, 255, 255, 0.8);
}

/* --- MODE TABS --- */
.mode-tabs {
    display: flex;
    justify-content: center;
    /* Centered */
    gap: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    margin-bottom: 40px;
    /* More space */
    padding-left: 0;
    margin-left: 0;
}

.tab-item {
    padding: 12px 35px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.5);
    background: transparent;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    /* Rounded top corners */
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: -1px;
    /* Overlap container border */
}

.tab-item:hover {
    color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.05);
}

.tab-item.active {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    border-bottom-color: transparent;
    font-weight: 600;
}


/* BATCH TABLE STYLES (Moved from index.html) */
.batch-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
    /* Transparent/White Theme */
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    /* Keep radius if desired, might need overflow:hidden on container */
}

.batch-table th,
.batch-table td {
    padding: 10px 15px;
    /* Compact padding */
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    /* Fainter border */
    vertical-align: middle;
    /* Center vertically */
}

.batch-table th {
    background: rgba(255, 255, 255, 0.05);
    font-weight: 500;
    /* Lighter weight */
    color: rgba(255, 255, 255, 0.6);
    /* Less contrast */
    font-size: 0.85em;
    /* Smaller */
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.batch-table tr:last-child td {
    border-bottom: none;
}

.driver-pill {
    display: inline-block;
    padding: 3px 8px;
    /* Compact */
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.9);
    /* White text */
    font-size: 0.75em;
    /* Smaller */
    white-space: nowrap;
    border-left-width: 3px;
    border-left-style: solid;
}

.driver-up {
    border-left-color: #ff6b6b;
}

/* Only border color */
.driver-down {
    border-left-color: #4ecdc4;
}

/* Only border color */
.score-cell {
    font-family: 'SF Mono', 'Roboto Mono', monospace;
    font-weight: 600;
    font-size: 1em;
}

.agent-summary {
    background: rgba(43, 88, 219, 0.1);
    /* Subtle Blue */
    border: 1px solid rgba(43, 88, 219, 0.3);
    border-radius: 8px;
    padding: 15px 20px;
    margin-bottom: 20px;
    color: #b0c4de;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 12px;
}

.agent-summary .icon {
    font-size: 1.2rem;
}

.priority-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-block;
    min-width: 60px;
    text-align: center;
}

.badge-p0 {
    background: rgba(255, 50, 50, 0.15);
    border: 1px solid rgba(255, 50, 50, 0.4);
    color: #ff8888;
}

.badge-p1 {
    background: rgba(255, 165, 0, 0.15);
    border: 1px solid rgba(255, 165, 0, 0.4);
    color: #ffbb66;
}

.badge-p2 {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    opacity: 0.6;
}

/* CUSTOM TOOLTIP (Replaces native title) */
.custom-tooltip {
    position: fixed;
    background: #ffffff;
    color: #1a1a1a;
    /* Dark text for contrast */
    font-family: 'Shippori Mincho B1', serif;
    font-size: 13px;
    padding: 8px 12px;
    border-radius: 4px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    pointer-events: none;
    /* Mouse passes through */
    opacity: 0;
    transform: translateY(5px);
    transition: opacity 0.1s ease, transform 0.1s ease;
    white-space: nowrap;
    border: 1px solid rgba(0, 0, 0, 0.1);
    font-weight: 500;
}

.custom-tooltip.visible {
    opacity: 1;
    transform: translateY(0);
}