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

:root {
    --primary-1: #667eea;
    --primary-2: #764ba2;
    --bg-gradient-1: #667eea;
    --bg-gradient-2: #764ba2;
    --container-bg: white;
    --text-color: #333;
    --text-secondary: #666;
    --border-color: #ddd;
    --input-bg: white;
    --input-border: #ddd;
    --tab-bg: #f5f5f5;
    --result-box-bg: #f0f9ff;
}

body.theme-purple {
    --primary-1: #667eea;
    --primary-2: #764ba2;
    --bg-gradient-1: #667eea;
    --bg-gradient-2: #764ba2;
}

body.theme-blue {
    --primary-1: #3b82f6;
    --primary-2: #1e40af;
    --bg-gradient-1: #3b82f6;
    --bg-gradient-2: #1e40af;
}

body.theme-green {
    --primary-1: #10b981;
    --primary-2: #047857;
    --bg-gradient-1: #10b981;
    --bg-gradient-2: #047857;
}

body.theme-red {
    --primary-1: #ef4444;
    --primary-2: #b91c1c;
    --bg-gradient-1: #ef4444;
    --bg-gradient-2: #b91c1c;
}

body.theme-orange {
    --primary-1: #f59e0b;
    --primary-2: #d97706;
    --bg-gradient-1: #f59e0b;
    --bg-gradient-2: #d97706;
}

body.dark-mode {
    --bg-gradient-1: #1e293b;
    --bg-gradient-2: #0f172a;
    --container-bg: #1e293b;
    --text-color: #e2e8f0;
    --text-secondary: #94a3b8;
    --border-color: #475569;
    --input-bg: #334155;
    --input-border: #475569;
    --tab-bg: #334155;
    --result-box-bg: #334155;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #667eea;
    min-height: 100vh;
    padding: 0;
    padding-bottom: 80px;
}

body.loaded {
    background: linear-gradient(135deg, var(--bg-gradient-1) 0%, var(--bg-gradient-2) 100%);
    transition: background 0.5s ease;
}

.container {
    background: var(--container-bg);
    border-radius: 0;
    max-width: 100%;
    width: 100%;
    min-height: 100vh;
    transition: all 0.3s ease;
    position: relative;
    padding-bottom: 100px;
    overflow-x: hidden;
}

.defer-load {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.defer-load.show {
    opacity: 1;
}

.ad-container {
    width: 100%;
    background: var(--tab-bg);
    padding: 15px 10px;
    margin: 15px 0;
    border-radius: 10px;
    position: relative;
    z-index: 1;
    min-height: 100px;
}

.ad-label {
    font-size: 9px;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.7;
}

.ad-frame {
    width: 100%;
    min-height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ad-frame iframe {
    display: block;
    margin: 0 auto;
    border: 0;
    max-width: 100%;
}

.tabs {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    background: var(--container-bg);
    padding: 8px 0;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
    box-shadow: 0 -2px 15px rgba(0,0,0,0.1);
    z-index: 999999;
    border-top: 1px solid var(--border-color);
    transition: all 0.3s ease;
    isolation: isolate;
}

.tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    position: relative;
    min-height: 64px;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    outline: none;
    touch-action: manipulation;
}

.tab-icon {
    font-size: 26px;
    transition: transform 0.2s ease;
    margin-bottom: 2px;
    display: block;
    pointer-events: none;
    user-select: none;
}

.tab.active {
    color: var(--primary-1);
}

.tab.active .tab-icon {
    transform: scale(1.15);
}

.tab.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 3px;
    background: var(--primary-1);
    border-radius: 0 0 3px 3px;
    animation: slideDown 0.3s ease-out;
    pointer-events: none;
}

@keyframes slideDown {
    from {
        height: 0;
        opacity: 0;
    }
    to {
        height: 3px;
        opacity: 1;
    }
}

.tab:active {
    transform: scale(0.92);
    background: rgba(0,0,0,0.05);
}

body.dark-mode .tab:active {
    background: rgba(255,255,255,0.05);
}

body.dark-mode .tabs {
    background: var(--container-bg);
    box-shadow: 0 -2px 15px rgba(0,0,0,0.5);
}

.theme-toggle {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 100;
}

.theme-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 30px;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 30px;
}

.slider:before {
    position: absolute;
    content: "☀️";
    height: 22px;
    width: 22px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

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

input:checked + .slider:before {
    transform: translateX(30px);
    content: "🌙";
}

.tab-content {
    padding: 70px 20px 20px 20px;
    position: relative;
    z-index: 1;
}

.tab-pane {
    display: none;
    animation: fadeIn 0.3s ease-in;
}

.tab-pane.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.header {
    text-align: center;
    margin-bottom: 25px;
}

.header h1 {
    font-size: 24px;
    color: var(--text-color);
    margin-bottom: 5px;
    transition: color 0.3s ease;
}

.header h2 {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 400;
    transition: color 0.3s ease;
}

.icon {
    font-size: 36px;
    margin-bottom: 8px;
    display: inline-block;
}

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

label {
    display: block;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 8px;
    font-size: 14px;
    transition: color 0.3s ease;
}

input[type="number"], select {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    border: 2px solid var(--input-border);
    border-radius: 10px;
    transition: all 0.3s ease;
    background: var(--input-bg);
    color: var(--text-color);
}

input[type="number"]:focus, select:focus {
    outline: none;
    border-color: var(--primary-1);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.mode-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    background: var(--tab-bg);
    padding: 5px;
    border-radius: 10px;
}

.mode-btn {
    flex: 1;
    padding: 12px;
    background: transparent;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.mode-btn.active {
    background: linear-gradient(135deg, var(--primary-1) 0%, var(--primary-2) 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.mode-btn:hover:not(.active) {
    background: rgba(102, 126, 234, 0.1);
}

.input-mode {
    display: none;
}

.input-mode.active {
    display: block;
}

.battery-display {
    margin-bottom: 20px;
}

.battery-bar {
    position: relative;
    height: 70px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    border: 3px solid #999;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

.battery-fill {
    height: 100%;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.5s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: bold;
    color: white;
    position: relative;
    overflow: hidden;
}

.battery-fill::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shine 2s infinite;
}

@keyframes shine {
    0% { left: -100%; }
    100% { left: 100%; }
}

.battery-percentage-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: bold;
    pointer-events: none;
}

.battery-icon {
    text-align: center;
    font-size: 50px;
    margin: 12px 0;
}

.status-text {
    text-align: center;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 5px;
}

.voltage-text {
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
    transition: color 0.3s ease;
}

.autonomy-box, .charging-box {
    border-radius: 15px;
    padding: 18px;
    text-align: center;
    color: white;
    margin-top: 15px;
    transition: all 0.3s ease;
}

.autonomy-box {
    background: linear-gradient(135deg, var(--primary-1) 0%, var(--primary-2) 100%);
}

.autonomy-box h3, .charging-box h3 {
    font-size: 13px;
    margin-bottom: 8px;
    opacity: 0.9;
}

.autonomy-value, .charging-value {
    font-size: 32px;
    font-weight: bold;
    margin-bottom: 5px;
}

.autonomy-subtitle, .charging-subtitle {
    font-size: 11px;
    opacity: 0.8;
}

.charging-box {
    background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
}

.btn {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, var(--primary-1) 0%, var(--primary-2) 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 15px;
    transition: all 0.3s ease;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.btn:active {
    transform: scale(0.98);
}

.btn-secondary {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.result-box {
    background: var(--result-box-bg);
    border: 2px solid var(--primary-1);
    border-radius: 15px;
    padding: 20px;
    margin-top: 20px;
    transition: all 0.3s ease;
}

.result-box h3 {
    color: var(--primary-1);
    font-size: 16px;
    margin-bottom: 15px;
    text-align: center;
}

.result-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.result-item:last-child {
    border-bottom: none;
}

.result-label {
    color: var(--text-secondary);
    font-size: 14px;
    transition: color 0.3s ease;
}

.result-value {
    color: var(--text-color);
    font-weight: 600;
    font-size: 14px;
    transition: color 0.3s ease;
}

.big-result {
    text-align: center;
    padding: 15px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border-radius: 10px;
    margin-top: 15px;
}

.big-result-label {
    font-size: 13px;
    opacity: 0.9;
    margin-bottom: 5px;
}

.big-result-value {
    font-size: 36px;
    font-weight: bold;
}

.reference-toggle {
    text-align: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    transition: border-color 0.3s ease;
}

.toggle-btn {
    background: none;
    border: none;
    color: var(--primary-1);
    font-weight: 600;
    cursor: pointer;
    font-size: 13px;
    padding: 10px;
    transition: all 0.3s ease;
}

.reference-table {
    margin-top: 15px;
    font-size: 12px;
}

.reference-table table {
    width: 100%;
    border-collapse: collapse;
}

.reference-table th {
    background: var(--tab-bg);
    padding: 8px;
    text-align: left;
    color: var(--text-color);
    transition: all 0.3s ease;
}

.reference-table td {
    padding: 8px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-color);
    transition: all 0.3s ease;
}

.reference-table td:last-child {
    text-align: right;
    font-family: monospace;
}

.hidden {
    display: none !important;
}

.info-box {
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
    padding: 12px;
    margin-bottom: 20px;
    border-radius: 5px;
    font-size: 13px;
    color: #92400e;
    transition: all 0.3s ease;
}

body.dark-mode .info-box {
    background: #78350f;
    border-left-color: #f59e0b;
    color: #fef3c7;
}

.history-item {
    background: var(--tab-bg);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 10px;
    border-left: 4px solid var(--primary-1);
    transition: all 0.3s ease;
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.history-date {
    font-size: 12px;
    color: var(--text-secondary);
    transition: color 0.3s ease;
}

.history-value {
    font-weight: 600;
    color: var(--primary-1);
}

.history-details {
    font-size: 12px;
    color: var(--text-secondary);
    transition: color 0.3s ease;
}

.clear-btn {
    background: #ef4444;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 5px;
    font-size: 12px;
    cursor: pointer;
    margin-top: 10px;
    transition: all 0.3s ease;
}

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

.theme-selector {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.theme-option {
    padding: 15px 10px;
    border-radius: 10px;
    border: 2px solid var(--border-color);
    cursor: pointer;
    text-align: center;
    transition: all 0.3s ease;
    position: relative;
}

.theme-option:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.theme-option.active {
    border-color: var(--primary-1);
    transform: scale(1.05);
}

.theme-purple { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.theme-blue { background: linear-gradient(135deg, #3b82f6 0%, #1e40af 100%); }
.theme-green { background: linear-gradient(135deg, #10b981 0%, #047857 100%); }
.theme-red { background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%); }
.theme-orange { background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); }

.theme-preview {
    width: 100%;
    height: 40px;
    border-radius: 5px;
    margin-bottom: 5px;
}

.theme-name {
    color: var(--text-color);
    font-size: 11px;
    font-weight: 600;
}

.emoji-selector {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
    gap: 8px;
    margin-bottom: 20px;
}

.emoji-option {
    padding: 12px 8px;
    font-size: 28px;
    text-align: center;
    border-radius: 10px;
    border: 2px solid var(--border-color);
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--tab-bg);
}

.emoji-option:hover {
    transform: scale(1.1);
}

.emoji-option.active {
    border-color: var(--primary-1);
    background: var(--primary-1);
    transform: scale(1.15);
}

.green { background-color: #10b981; color: #059669; }
.yellow { background-color: #fbbf24; color: #d97706; }
.orange { background-color: #f97316; color: #ea580c; }
.red { background-color: #ef4444; color: #dc2626; }
.gray { background-color: #9ca3af; color: #6b7280; }

.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #333;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 99998;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

body.dark-mode .toast {
    background: #e2e8f0;
    color: #1e293b;
}

.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    background: #f0f;
    animation: confetti-fall 3s linear forwards;
    z-index: 1000;
}

@keyframes confetti-fall {
    to {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0;
    }
}

.settings-card {
    background: var(--tab-bg);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 15px;
    transition: all 0.3s ease;
}

.settings-card h3 {
    color: var(--text-color);
    font-size: 14px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ios-install-prompt {
    position: fixed;
    bottom: -100%;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, var(--primary-1), var(--primary-2));
    color: white;
    padding: 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
    box-shadow: 0 -5px 20px rgba(0,0,0,0.3);
    z-index: 99999;
    transition: bottom 0.4s ease;
    border-radius: 20px 20px 0 0;
}

.ios-install-prompt.show {
    bottom: 0;
}

.ios-install-prompt h3 {
    margin: 0 0 15px 0;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.ios-install-prompt p {
    margin: 10px 0;
    font-size: 14px;
    line-height: 1.6;
}

.ios-install-prompt .step {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 10px 0;
    background: rgba(255,255,255,0.1);
    padding: 10px;
    border-radius: 8px;
}

.ios-install-prompt .step-icon {
    font-size: 24px;
    min-width: 30px;
    text-align: center;
}

.ios-install-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.android-install-btn {
    position: fixed;
    bottom: 90px;
    right: 20px;
    background: linear-gradient(135deg, var(--primary-1), var(--primary-2));
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    z-index: 99998;
    display: none;
    align-items: center;
    gap: 8px;
    animation: pulse 2s infinite;
}

.android-install-btn.show {
    display: flex;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@media (max-width: 360px) {
    .theme-selector {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .emoji-selector {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .emoji-option {
        font-size: 24px;
        padding: 10px 5px;
    }

    .tab-icon {
        font-size: 22px;
    }
}