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

body {
    font-family: Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    padding-bottom: 60px;
}

#header-bar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

#header-bar h1 {
    font-size: 18px;
    font-weight: normal;
    margin: 0;
}

#panel-container {
    margin-top: 60px;
    padding: 15px;
}

.panel-content {
    display: none;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.panel-content.active {
    display: block;
}

.panel-header {
    background: #f8f9fa;
    padding: 15px;
    border-bottom: 1px solid #e9ecef;
}

.panel-header h2 {
    font-size: 16px;
    color: #495057;
    margin: 0;
}

.panel-body {
    padding: 15px;
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 14px;
    color: #495057;
    font-weight: 500;
}

.form-group input[type="number"],
.form-group input[type="text"],
.form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ced4da;
    border-radius: 5px;
    font-size: 14px;
    transition: border-color 0.15s ease;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group .hint {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    color: #6c757d;
}

.panel-footer {
    padding: 15px;
    border-top: 1px solid #e9ecef;
    text-align: center;
}

.btn-save,
.btn-calculate,
.btn-reset {
    padding: 12px 30px;
    border: none;
    border-radius: 5px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-save {
    background: #28a745;
    color: white;
}

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

.btn-calculate {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    width: 100%;
    font-size: 16px;
    padding: 15px;
}

.btn-calculate:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-reset {
    background: #6c757d;
    color: white;
}

.btn-reset:hover {
    background: #5a6268;
}

.result-section {
    margin-bottom: 20px;
}

.result-group {
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.result-group h3 {
    font-size: 14px;
    color: #495057;
    margin-bottom: 10px;
    border-bottom: 2px solid #667eea;
    padding-bottom: 5px;
}

.result-item {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    font-size: 14px;
}

.result-label {
    color: #6c757d;
    flex: 1;
}

.result-value {
    color: #495057;
    font-weight: 600;
    margin-right: 5px;
}

.result-unit {
    color: #6c757d;
    font-size: 12px;
}

#mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 999;
    padding: 5px 0;
    height: 60px;
}

.nav-item-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.nav-item {
    background: none;
    border: none;
    color: #6c757d;
    font-size: 11px;
    text-align: center;
    cursor: pointer;
    padding: 5px;
    transition: all 0.15s ease;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.nav-item:hover {
    color: #667eea;
}

.nav-item.active {
    color: #667eea;
    font-weight: 600;
}

@media screen and (max-width: 480px) {
    #header-bar h1 {
        font-size: 16px;
    }
    
    .panel-header h2 {
        font-size: 14px;
    }
    
    .form-group label {
        font-size: 13px;
    }
    
    .form-group input,
    .form-group select {
        font-size: 13px;
    }
    
    .nav-item {
        font-size: 10px;
    }
}

@supports (padding: max(0px)) {
    body {
        padding-bottom: max(60px, env(safe-area-inset-bottom));
    }
    
    #mobile-nav {
        padding-bottom: max(5px, env(safe-area-inset-bottom));
        height: max(60px, calc(60px + env(safe-area-inset-bottom)));
    }
}
/* ===== Viewport-fill adaptive layout ===== */
html, body { height: 100%; }
body {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding-bottom: 0;
    overflow: hidden;
}
#header-bar { position: relative; flex: 0 0 auto; width: 100%; }
#panel-container {
    margin-top: 0;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}
#mobile-nav { position: relative; flex: 0 0 auto; width: 100%; }
@media (min-width: 768px) {
    #panel-container { max-width: 720px; margin-left: auto; margin-right: auto; }
}
/* === bottom-nav fix === */
#mobile-nav { position: fixed !important; bottom: 0; left: 0; right: 0; width: 100%; height: 60px; z-index: 999; box-shadow: 0 -2px 10px rgba(0,0,0,.1); }
html, body { height: 100%; }
body { display: flex; flex-direction: column; min-height: 100vh; overflow: hidden; padding-bottom: 0 !important; }
#header-bar { position: relative; flex: 0 0 auto; width: 100%; }
#panel-container { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 72px; width: 100%; margin-top: 0 !important; }
