:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --bg-gradient-start: #e0f2fe;
    --bg-gradient-mid: #ddd6fe;
    --bg-gradient-end: #fce7f3;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --success: #10b981;
    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 20px 40px -10px rgba(0, 0, 0, 0.15);
    --radius: 16px;
    --gradient-button: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
}

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

body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(180deg, var(--bg-gradient-start) 0%, var(--bg-gradient-mid) 50%, var(--bg-gradient-end) 100%);
    min-height: 100vh;
    color: var(--text-main);
    line-height: 1.5;
    padding: 20px;
}

.container {
    max-width: 600px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.update-date {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    font-style: italic;
}

.estimation-note {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    opacity: 0.8;
}

/* Form Styles */
form {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.8);
}

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

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-main);
    font-size: 0.95rem;
}

input[type="number"] {
    width: 100%;
    padding: 0.875rem;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.2s;
    background: white;
}

input[type="number"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.power-section h2,
.consumption-section h2 {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.checkbox-group input {
    width: 1.2rem;
    height: 1.2rem;
    accent-color: var(--primary);
}

.checkbox-group label {
    margin-bottom: 0;
    cursor: pointer;
}

.btn-calculate {
    background: var(--gradient-button);
    color: white;
    width: 100%;
    padding: 1.125rem;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-calculate:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.btn-calculate:active {
    transform: translateY(0);
}

/* Results Styles */
.results-container {
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.5s ease;
}

.results-container.visible {
    opacity: 1;
    transform: translateY(0);
}

.results-container h2 {
    text-align: center;
    margin-bottom: 1.5rem;
}

.tariff-card {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
    border: 2px solid rgba(226, 232, 240, 0.6);
    position: relative;
    overflow: visible;
    transition: transform 0.2s, box-shadow 0.2s;
}

.tariff-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.top-rank {
    border: 2px solid rgba(139, 92, 246, 0.3);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(249, 250, 251, 0.95) 100%);
}

.rank-badge {
    position: absolute;
    top: -12px;
    left: 16px;
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    color: white;
    padding: 0.35rem 0.85rem;
    border-radius: 20px;
    font-weight: 800;
    font-size: 0.95rem;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    margin-top: 0.25rem;
}

.company-name {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
}

.plan-name {
    font-size: 1.25rem;
    font-weight: 700;
    margin-top: 0.25rem;
    color: var(--text-main);
}

.badges-row {
    display: flex;
    gap: 6px;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.total-price {
    text-align: right;
}

.price-big {
    font-size: 2rem;
    font-weight: 900;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.price-period {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 2rem 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border-color);
}

.divider span {
    padding: 0 10px;
}

.hidden {
    display: none;
}

/* Details Expansion */
.btn-details {
    background: none;
    border: none;
    color: var(--primary);
    font-weight: 600;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.5rem 0;
    margin-top: 0.5rem;
    width: 100%;
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-details .arrow {
    transition: transform 0.3s ease;
}

.btn-details.expanded .arrow {
    transform: rotate(180deg);
}

.btn-details:hover {
    text-decoration: underline;
}

.details-section {
    background-color: #f9fafb;
    margin: 0 -1.5rem -1.5rem -1.5rem;
    /* Negative margin to span full width */
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.details-section.hidden {
    display: none;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.4rem;
}

.detail-divider {
    height: 1px;
    background-color: var(--border-color);
    margin: 0.5rem 0;
}

.badge-zero {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: #065f46;
    font-size: 0.65rem;
    padding: 3px 6px;
    border-radius: 6px;
    font-weight: 700;
    margin-left: 4px;
    display: inline-block;
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.2);
}

.badge-permanencia {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #991b1b;
    font-size: 0.7rem;
    padding: 3px 8px;
    border-radius: 6px;
    font-weight: 600;
    margin-left: 8px;
    display: inline-block;
    cursor: help;
}

.badge-sin-permanencia {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    color: #1e40af;
    font-size: 0.7rem;
    padding: 3px 8px;
    border-radius: 6px;
    font-weight: 600;
    margin-left: 8px;
    display: inline-block;
    cursor: help;
}

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

.summary-grid {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    background: rgba(248, 250, 252, 0.6);
    border-radius: 10px;
}

.summary-grid>div {
    flex: 1;
    min-width: fit-content;
}

.btn-link {
    display: block;
    text-align: center;
    background-color: var(--text-main);
    color: white;
    text-decoration: none;
    padding: 0.75rem;
    border-radius: 8px;
    margin-top: 1rem;
    font-weight: 600;
    transition: background-color 0.2s;
}

.btn-link:hover {
    background-color: black;
}

.battery-note {
    background-color: #fef3c7;
    color: #92400e;
    padding: 0.5rem;
    border-radius: 6px;
    font-size: 0.85rem;
    margin-top: 0.5rem;
    text-align: center;
    font-weight: 600;
}

.compensation-note {
    background: linear-gradient(135deg, #dbeafe 0%, #e0e7ff 100%);
    color: #1e40af;
    padding: 0.5rem;
    border-radius: 6px;
    font-size: 0.85rem;
    margin-top: 0.5rem;
    text-align: center;
    font-weight: 600;
}

/* Mobile Tweaks */
@media (max-width: 480px) {
    .grid-3 {
        gap: 0.5rem;
    }

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

    .price-big {
        font-size: 1.5rem;
    }
}