/* CSS变量定义 */
:root {
    --primary-color: #00796b;
    --primary-light: #4db6ac;
    --secondary-color: #26a69a;
    --background-light: #f7fbfc;
    --text-dark: #004d40;
    --text-medium: #555;
    --text-light: #666;
    --border-color: #ccc;
    --shadow: 0 10px 20px rgba(0,0,0,0.06);
    --radius: 12px;
}

/* 全局样式重置 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(145deg, var(--background-light), #fcfdfc);
    padding: 20px;
    display: flex;
    justify-content: center;
    min-height: 100vh;
    color: var(--text-medium);
}

/* 主容器 */
.container {
    background: #ffffff;
    padding: 25px 20px;
    border-radius: 22px;
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 900px;
    transition: all 0.3s ease;
}

/* Logo */
.logo-container {
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    position: relative;
}

.logo-link {
    display: inline-block;
    transition: all 0.3s ease;
}

.logo-img {
    max-width: 300px;
    height: auto;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.logo-link:hover .logo-img {
    transform: scale(1.05);
}

/* 标题 */
h2 {
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 20px;
    font-size: 24px;
    letter-spacing: 1px;
    position: relative;
    padding-bottom: 10px;
}

h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: linear-gradient(to right, var(--primary-light), var(--secondary-color));
    border-radius: 2px;
}

/* 输入组 */
.input-group {
    margin-bottom: 15px;
    position: relative;
}

.cache-indicator {
    position: absolute;
    right: 10px;
    top: 35px;
    font-size: 12px;
    color: var(--primary-light);
    background: rgba(77, 182, 172, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.input-group:hover .cache-indicator {
    opacity: 1;
}

label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--text-medium);
}

/* 内联输入框 */
.inline-inputs {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.inline-inputs .input-group {
    flex: 1;
    min-width: 0;
    margin-bottom: 0;
}

/* 三列布局 */
.inline-inputs.three-columns {
    gap: 6px;
}

.inline-inputs.three-columns .input-group {
    flex: 1;
    min-width: 95px;
}

.inline-inputs.three-columns input {
    padding: 10px 6px;
    font-size: 13px;
    width: 100%;
}

.inline-inputs.three-columns .input-group label {
    font-size: 13px;
    white-space: nowrap;
    text-align: center;
}

/* 输入框通用样式 */
input {
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    -moz-appearance: textfield;
    color: var(--text-light);
    font-size: 15px;
    background-color: #fafafa;
    transition: all 0.3s ease;
}

input:focus {
    border-color: var(--secondary-color);
    box-shadow: 0 0 6px rgba(38, 166, 154, 0.2);
    outline: none;
    background-color: #ffffff;
}

input.zero {
    color: #bbb;
}

input::placeholder {
    color: #bbb;
    font-style: italic;
}

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* 按钮 */
.calculate-btn-container {
    position: relative;
    margin-top: 20px;
}

.calculate-btn {
    padding: 12px;
    width: 100%;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--secondary-color), var(--primary-light));
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 3px 10px rgba(0,0,0,0.1);
    position: relative;
    overflow: hidden;
}

.calculate-btn:hover {
    background: linear-gradient(135deg, var(--primary-light), var(--secondary-color));
    transform: translateY(-2px);
    box-shadow: 0 5px 14px rgba(0,0,0,0.12);
}

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

.btn-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    margin-bottom: 8px;
    z-index: 100;
}

.btn-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.8);
}

.calculate-btn-container:hover .btn-tooltip {
    opacity: 1;
    visibility: visible;
}

/* 弹窗 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    padding: 25px;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.modal-title {
    color: var(--primary-color);
    font-size: 20px;
    font-weight: 600;
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background-color: #f5f5f5;
    color: #666;
}

/* 结果项 */
.result-item {
    margin-bottom: 15px;
    padding: 15px;
    border-radius: var(--radius);
    background: linear-gradient(to right, #e8f7f1, #f0fcf8);
    border-left: 4px solid var(--secondary-color);
}

.result-title {
    font-size: 16px;
    color: var(--primary-color);
    margin-bottom: 8px;
    font-weight: 600;
}

.result-value {
    font-size: 18px;
    color: var(--text-dark);
    font-weight: bold;
}

.result-note {
    font-size: 12px;
    color: #666;
    margin-top: 5px;
    font-style: italic;
}

.highlight {
    background: linear-gradient(to right, #e3f2fd, #e1f5fe);
    border-left-color: var(--primary-color);
}

/* 历史记录 */
.history-section {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    display: none;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.history-title {
    color: var(--primary-color);
    font-size: 18px;
    font-weight: 600;
}

.history-actions {
    display: flex;
    gap: 10px;
}

.history-actions button {
    margin-top: 0;
    padding: 8px 15px;
    width: auto;
    font-size: 14px;
    background: linear-gradient(135deg, var(--primary-light), var(--secondary-color));
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.history-actions button:hover {
    transform: translateY(-2px);
    box-shadow: 0 3px 8px rgba(0,0,0,0.15);
}

.history-table-container {
    overflow-x: auto;
    border-radius: var(--radius);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.history-table th,
.history-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
    font-size: 12px;
}

.history-table th {
    background-color: var(--primary-color);
    color: white;
    font-weight: 600;
}

.history-table tr:nth-child(even) {
    background-color: #f9f9f9;
}

.history-table tr:hover {
    background-color: #f0f9f7;
    cursor: pointer;
}

.history-table tr.selected {
    background-color: #e1f5fe;
    border: 2px solid var(--primary-color);
}

.no-history {
    text-align: center;
    padding: 20px;
    color: var(--text-light);
    font-style: italic;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container { padding: 18px 15px; }
    .logo-img { max-width: 250px; }
    .cache-indicator { display: none; }
    
    .inline-inputs {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 8px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .inline-inputs::-webkit-scrollbar { display: none; }
    
    .inline-inputs .input-group { flex-shrink: 0; min-width: 45%; }
    
    .inline-inputs.three-columns { gap: 5px; }
    .inline-inputs.three-columns .input-group { min-width: 95px; }
    .inline-inputs.three-columns input { padding: 9px 5px; font-size: 12px; }
    .inline-inputs.three-columns .input-group label { font-size: 12px; text-align: center; }
    
    .modal-content { padding: 20px; width: 95%; }
    
    .history-table { font-size: 10px; }
    .history-table th, .history-table td { padding: 8px 10px; font-size: 10px; }
    
    .history-actions { flexDirection: column; gap: 5px; }
    .history-actions button { width: 100%; font-size: 12px; padding: 6px 12px; }
    
    .history-title { font-size: 16px; }
    .btn-tooltip { white-space: normal; max-width: 200px; text-align: center; }
}

@media (max-width: 1024px) {
    .history-table { font-size: 11px; }
    .history-table th, .history-table td { padding: 9px 11px; font-size: 11px; }
}

@media (max-width: 350px) {
    .inline-inputs { flex-direction: column; gap: 12px; overflow-x: visible; }
    .inline-inputs .input-group { min-width: 100%; }
    
    .inline-inputs.three-columns .input-group { min-width: 100%; }
    .inline-inputs.three-columns input { padding: 10px 12px; font-size: 14px; }
    .inline-inputs.three-columns .input-group label { font-size: 14px; white-space: normal; text-align: left; }
    
    .history-table { font-size: 9px; }
    .history-table th, .history-table td { padding: 6px 8px; font-size: 9px; }
    
    .history-actions button { font-size: 10px; padding: 5px 10px; }
    .history-title { font-size: 14px; }
}