:root {
    /* Brand & Accent Colors */
    --primary-color: #ff3b30;       /* Autoline Red */
    --primary-hover: #ff4f45;
    --accent-blue: #0a84ff;         /* Financed Amount */
    --accent-green: #30d158;        /* Installment Value */
    --accent-purple: #bf5af2;       /* Total Paid */
    --accent-orange: #ff9f0a;       /* Total Interest */

    /* Backgrounds Dark Theme */
    --bg-main: #0c0d11;             /* Ultra dark background */
    --bg-card: #16181f;             /* Card background */
    --bg-card-header: #1c1e26;      /* Slightly lighter for headers */
    --bg-input: #0f1015;            /* Deep dark input bg */
    --bg-input-focus: #161a29;      /* Focus state input */
    
    /* Text Colors */
    --text-primary: #ffffff;
    --text-secondary: #8b92a5;
    --text-tertiary: #5f6577;

    /* Borders */
    --border-color: #262933;
    --border-light: rgba(255, 255, 255, 0.05);

    /* Shadows */
    --shadow-sm: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 15px rgba(0, 0, 0, 0.4);
    --shadow-neon: 0 0 15px rgba(255, 59, 48, 0.2);

    /* Radii */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-main);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

.app-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* --- Header --- */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background-color: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary-color) 0%, #aa0000 100%);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-neon);
    position: relative;
}
.logo-icon::after {
    content: 'A';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: 800;
    font-size: 1.5rem;
    font-style: italic;
}

.logo-text h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.logo-text p {
    font-size: 0.75rem;
    color: var(--text-secondary);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    outline: none;
}

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

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}
.btn-outline:hover {
    color: var(--text-primary);
    border-color: var(--text-primary);
}

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

/* --- Dashboard Layout --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 1.5rem;
}

.left-panel, .right-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

/* --- Cards --- */
.card {
    background-color: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-card-header);
}

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
}

.card-header.space-between {
    justify-content: space-between;
}

.card-header.highlight h3 {
    color: var(--accent-blue);
}

/* --- Inputs Section --- */
.inputs-card {
    padding: 1.5rem;
}

.row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.row:last-child {
    margin-bottom: 0;
}

.align-items-center {
    align-items: flex-end;
}

.flex-1 { flex: 1; min-width: 120px; }
.flex-2 { flex: 2; min-width: 200px; }
.flex-3 { flex: 3; }

.section-divider {
    margin: 1.5rem 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}
.section-divider h3 {
    font-size: 1rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.helper-text {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

/* Forms */
input[type="text"], 
input[type="number"], 
select {
    width: 100%;
    padding: 0.8rem 1rem;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.2s;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: var(--bg-input-focus);
    box-shadow: 0 0 0 2px rgba(255, 59, 48, 0.15);
}

input:disabled, select:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.input-with-symbol {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-symbol input {
    padding-right: 2.5rem;
}

.start-symbol input {
    padding-left: 2.5rem;
    padding-right: 1rem;
}

.symbol {
    position: absolute;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
}
.input-with-symbol:not(.start-symbol) .symbol { right: 1rem; }
.start-symbol .symbol { left: 1rem; }

/* Custom Scrollbar for Select */
select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b92a5' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
}

.best-condition-badge {
    position: absolute;
    top: -8px;
    right: 0px;
    background: linear-gradient(135deg, var(--accent-green) 0%, #1c9e3c 100%);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    text-transform: uppercase;
    box-shadow: 0 2px 4px rgba(48, 209, 88, 0.3);
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}
.best-condition-badge.show {
    opacity: 1;
}

/* --- Metrics Grid --- */
.results-highlight-card {
    border: 1px solid rgba(10, 132, 255, 0.2);
    box-shadow: 0 4px 20px rgba(10, 132, 255, 0.05);
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    padding: 1.5rem;
}

.metric-box {
    padding: 1.25rem 1rem;
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s;
}
.metric-box:hover {
    transform: translateY(-2px);
}

.metric-icon {
    margin-bottom: 0.75rem;
    opacity: 0.9;
}

.metric-label {
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: 0.4rem;
    opacity: 0.9;
}

.metric-value {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

/* Colors for Metrics */
.bg-blue { background: rgba(10, 132, 255, 0.1); color: var(--accent-blue); }
.bg-green { background: rgba(48, 209, 88, 0.1); color: var(--accent-green); }
.bg-purple { background: rgba(191, 90, 242, 0.1); color: var(--accent-purple); }
.bg-orange { background: rgba(255, 159, 10, 0.1); color: var(--accent-orange); }

.info-footer {
    padding: 1rem 1.5rem;
    background-color: var(--bg-card-header);
    border-top: 1px solid var(--border-color);
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: center;
}

/* --- Charts Area --- */
.chart-card {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chart-wrapper {
    padding: 1.5rem;
    flex: 1;
    position: relative;
    min-height: 220px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.chart-legend-custom {
    padding: 0 1.5rem 1.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.legend-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.legend-label-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.legend-color {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}
.legend-val {
    font-weight: 600;
    color: var(--text-primary);
}

/* --- Table Area --- */
.table-card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.table-scroll-container {
    padding: 0;
    overflow-y: auto;
    max-height: calc(100vh - 200px);
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}
.table-scroll-container::-webkit-scrollbar {
    width: 6px;
}
.table-scroll-container::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 4px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: right;
}

.data-table th, .data-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    background-color: var(--bg-card-header);
    position: sticky;
    top: 0;
    z-index: 10;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table th:first-child, .data-table td:first-child {
    text-align: center;
}

.data-table td {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

.data-table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

/* Responsive */
@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .table-scroll-container {
        max-height: 400px;
    }
}

@media (max-width: 850px) {
    .charts-row {
        grid-template-columns: 1fr;
    }
    
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 550px) {
    .top-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .metrics-grid {
        grid-template-columns: 1fr;
    }
}
