* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --app-max-width: 1180px;
    --primary-color: #338059;
    --primary-dark: #2a6b4a;
    --secondary-color: #CCA634;
    --border-color: #E1E5E3;
    --text-dark: #2B332F;
    --text-medium: #5E6662;
    --text-light: #919995;
    --bg-color: #f3f5f4;
    --card-bg: #ffffff;
    --error-color: #e74c3c;
    --header-h: 56px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-dark);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: none;
    margin: 0;
    background-color: transparent;
    box-shadow: none;
}

header {
    background: var(--primary-color);
    color: white;
    padding: 0 24px;
    height: var(--header-h);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    position: sticky;
    top: 0;
    z-index: 100;
}

header h1,
.header-title {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.2;
}

.lang-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.lang-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.menu-btn {
    background: none;
    border: none;
    color: white;
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
}

/* Login Page Styles */
#page-login.active {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 50px;
    position: relative;
}

.login-lang-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    background: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    font-size: 13px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.5px;
}

.login-lang-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.login-container {
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-container h1 {
    font-size: 24px;
    margin-bottom: 40px;
    color: var(--primary-color);
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form button {
    width: 100%;
    margin-top: 15px;
}

/* Overlay and Mask Styles */
.mask {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

.overlay {
    display: none;
    position: fixed;
    background: white;
    z-index: 1001;
    transition: transform 0.3s ease;
}

/* Side Menu Dropdown */
#menu-overlay {
    top: 54px;
    right: max(20px, calc((100vw - var(--app-max-width)) / 2 + 20px));
    width: 160px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 10px 0;
    transform: translateY(-10px);
}

#menu-overlay.show {
    display: block;
    transform: translateY(0);
}

.menu-item {
    padding: 12px 20px;
    font-size: 15px;
    color: var(--text-dark);
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
}

.menu-item:last-child {
    border-bottom: none;
}

.menu-item:hover {
    background: #f5f5f5;
    color: var(--primary-color);
}

/* History Half-screen Drawer */
#history-overlay {
    bottom: 0;
    left: 50%;
    right: auto;
    width: min(100vw, var(--app-max-width));
    max-width: var(--app-max-width);
    height: 85vh;
    border-radius: 20px 20px 0 0;
    transform: translateX(-50%) translateY(100%);
    padding: 20px;
    display: flex;
    flex-direction: column;
}

#history-overlay.show {
    display: flex;
    transform: translateX(-50%) translateY(0);
}

.history-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-shrink: 0;
}

/* Gradient Analysis Overlay */
#gradient-overlay {
    bottom: 0;
    left: 50%;
    right: auto;
    width: min(100vw, var(--app-max-width));
    max-width: var(--app-max-width);
    height: 90vh;
    border-radius: 20px 20px 0 0;
    transform: translateX(-50%) translateY(100%);
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#gradient-overlay.show {
    display: flex;
    transform: translateX(-50%) translateY(0);
}

#gradient-overlay .overlay-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
}

#gradient-overlay .overlay-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-dark);
}

#gradient-overlay .overlay-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    -webkit-overflow-scrolling: touch;
}

.gradient-inputs {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.grad-input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    width: 100%;
}

.grad-field {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
}

.grad-field .range-error {
    position: absolute;
    right: 0;
    top: 0;
    font-size: 11px;
    font-weight: normal;
    white-space: nowrap;
    background: white;
}

.grad-field label {
    font-size: 13px;
    color: var(--text-medium);
    font-weight: 500;
}

.grad-field input {
    width: 100%;
    height: 38px;
    padding: 0 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 13px;
}

#grad-param-select {
    width: 100%;
}

.chart-container {
    width: 100%;
    margin: 20px 0;
    background: white;
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    height: 320px;
}

/* Gradient Overlay Flex Layout */
.grad-overlay-flex {
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

.grad-fixed-top {
    flex-shrink: 0;
    padding: 10px 20px 0;
    background: #fafafa;
    z-index: 10;
}

.grad-scrollable-content {
    flex: 1;
    overflow-y: auto;
    padding: 0 20px 20px;
}

#gradient-overlay .overlay-header {
    margin-bottom: 10px;
}


.close-overlay {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.history-tabs {
    display: flex;
    border-radius: 8px;
    background: #f0f0f0;
    padding: 4px;
    margin-bottom: 15px;
    flex-shrink: 0;
}

.tab-btn {
    flex: 1;
    text-align: center;
    padding: 8px;
    font-size: 14px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-medium);
}

.tab-btn.active {
    background: white;
    color: var(--primary-color);
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.tab-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
    background: #e0e0e0;
}

.history-filters {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-shrink: 0;
}

.filter-btn {
    background: white;
    border: 1px solid var(--border-color);
    color: var(--text-medium);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.history-list-items {
    flex: 1;
    overflow-y: auto;
    padding-right: 5px;
}

.history-item {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.history-item-content {
    flex: 1;
}

.history-title {
    font-size: 16px;
    font-weight: bold;
    color: var(--text-dark);
    margin-bottom: 8px;
}

.history-details {
    font-size: 13px;
    color: var(--text-medium);
    line-height: 1.5;
}

.history-details div {
    margin-bottom: 2px;
}

.history-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-left: 10px;
}

.load-btn, .delete-btn {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    width: 60px;
}

.load-btn {
    background: white;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
}

.load-btn:hover {
    background: var(--primary-color);
    color: white;
}

.delete-btn {
    background: white;
    border: 1px solid var(--error-color);
    color: var(--error-color);
}

.delete-btn:hover {
    background: var(--error-color);
    color: white;
}

main {
    flex: 1;
    padding: 20px;
}

.page {
    display: none;
}

.page.active {
    display: block;
}

#page-parameter-input {
    padding-bottom: 80px;
    /* 留出底部固定按钮组的空间 */
}

.group-selector {
    margin-bottom: 20px;
}

.group-selector label {
    display: block;
    font-size: 14px;
    color: var(--text-medium);
    margin-bottom: 8px;
}

.group-selector select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
    color: var(--text-dark);
    background-color: white;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235E6662' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.animal-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    justify-content: center;
}

.animal-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.animal-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: var(--primary-color);
}

.animal-card img {
    width: 100%;
    max-width: 100%;
    height: 160px;
    object-fit: cover;
    background-color: #ffffff;
    display: block;
}

.animal-card p {
    padding: 16px 12px;
    text-align: center;
    font-size: 15px;
    font-weight: bold;
    color: var(--text-dark);
}

/* 结果页样式优化 */
#page-result {
    padding-bottom: 110px;
    /* 为固定底栏留空间 */
}

.page-header {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    position: sticky;
    top: 63px;
    background: var(--bg-color);
    z-index: 90;
    padding: 10px 0;
    margin-top: -10px;
}

.back-btn {
    background: none;
    border: none;
    color: var(--text-dark);
    cursor: pointer;
    padding: 8px;
    margin-right: 8px;
    display: flex;
    align-items: center;
}

.back-btn:hover {
    color: var(--primary-color);
}

.page-header-title {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.header-reset-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-medium);
    font-size: 13px;
    padding: 4px 10px;
    cursor: pointer;
    text-decoration: none;
    font-weight: normal;
    transition: all 0.2s;
    border-radius: 4px;
}

.header-reset-btn:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.header-reset-btn:active {
    transform: scale(0.95);
}

.page-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-dark);
}

.parameter-form {
    margin-bottom: 20px;
}

.module {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 15px;
}

.module h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-color);
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-medium);
    margin-bottom: 8px;
}

.range-error {
    color: var(--error-color);
    font-size: 12px;
    font-weight: bold;
    opacity: 0;
    transition: opacity 0.8s ease;
    pointer-events: none;
}

.range-error.show {
    opacity: 1;
    pointer-events: auto;
}

.form-group label .required {
    color: #e74c3c !important;
    /* var(--error-color) 强化 */
    font-size: 16px;
    font-weight: bold;
}

.input-with-unit {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.input-with-unit input {
    flex: 1;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
    color: var(--text-dark);
    background-color: white;
    transition: border-color 0.8s ease, box-shadow 0.8s ease;
    min-width: 0;
    appearance: none;
    background-image: none !important;
}

.input-with-unit select {
    flex: 1;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
    color: var(--text-dark);
    background-color: white;
    transition: border-color 0.8s ease, box-shadow 0.8s ease;
    min-width: 0;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235E6662' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.input-with-unit select option {
    padding: 8px 12px;
    font-size: 14px;
    color: var(--text-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    box-sizing: border-box;
}

/* 确保带单位的选择框也有正确的宽度限制 */
.input-with-unit {
    max-width: 95vw;
    box-sizing: border-box;
}

/* 自定义下拉组件样式 */
.custom-select {
    position: relative;
    max-width: 95vw;
    box-sizing: border-box;
    width: 100%;
}

.custom-select__selected {
    position: relative;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: #FFFFFF;
    cursor: pointer;
    transition: border-color 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.custom-select__selected:hover {
    border-color: var(--primary-color);
}

.custom-select__selected:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(51, 128, 89, 0.12);
}

::placeholder {
    color: #BFBFB2 !important;
}

.custom-select__placeholder {
    color: #BFBFB2 !important;
    font-size: 15px;
}

.custom-select__value {
    color: var(--text-dark);
    font-size: 15px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.custom-select__arrow {
    margin-left: 10px;
    transition: transform 0.3s ease;
}

.custom-select__arrow.open {
    transform: rotate(180deg);
}

.custom-select__dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    max-height: 300px;
    overflow: hidden;
    display: none;
    width: 100%;
    max-width: 95vw;
    box-sizing: border-box;
}

.custom-select__dropdown.open {
    display: block;
}

.custom-select__search {
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
}

.custom-select__search-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    color: var(--text-dark);
    box-sizing: border-box;
    background-image: none !important;
}

.custom-select__search-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.custom-select__options {
    max-height: 240px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.custom-select__option {
    padding: 10px 12px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    font-size: 14px;
    color: var(--text-dark);
    white-space: normal;
    word-break: break-all;
    line-height: 1.4;
    border-bottom: 1px solid var(--border-color);
}

.custom-select__option:last-child {
    border-bottom: none;
}

.custom-select__option:hover {
    background-color: rgba(51, 128, 89, 0.08);
}

.custom-select__option.selected {
    background-color: rgba(51, 128, 89, 0.14);
    font-weight: 500;
}

/* 自定义下拉组件的错误状态 */
.custom-select.error .custom-select__selected {
    border-color: var(--error-color);
}

/* 确保自定义下拉组件在不同浏览器中的一致性 */
@-moz-document url-prefix() {
    .custom-select__dropdown {
        width: 100%;
        max-width: 95vw;
        box-sizing: border-box;
    }
}

/* 加强IE和Edge浏览器的支持 */
@media screen and (-ms-high-contrast: active),
(-ms-high-contrast: none) {
    .custom-select__dropdown {
        width: 100%;
        max-width: 95vw;
        box-sizing: border-box;
    }
}

.input-with-unit input {
    background-image: none;
}

.input-with-unit .unit {
    color: var(--text-medium);
    font-size: 14px;
    white-space: nowrap;
    min-width: 50px;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
    color: var(--text-dark);
    background-color: white;
    transition: border-color 0.3s ease;
    appearance: none;
    background-image: none !important;
}

.form-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
    color: var(--text-dark);
    background-color: white;
    transition: border-color 0.3s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235E6662' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.form-group select option {
    padding: 8px 12px;
    font-size: 14px;
    color: var(--text-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    box-sizing: border-box;
}

/* 确保下拉菜单宽度与选择框一致 */
.form-group {
    position: relative;
    max-width: 95vw;
    box-sizing: border-box;
}

/* 对于某些浏览器，需要特殊处理下拉菜单宽度 */
@-moz-document url-prefix() {
    .form-group select {
        width: 100%;
        max-width: 95vw;
    }
}

.form-group input:focus,
.form-group select:focus,
.input-with-unit input:focus,
.input-with-unit select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-group input.error,
.form-group select.error {
    border-color: var(--error-color);
    animation: shake 0.3s ease;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

.clear-btn {
    display: none;
    position: absolute;
    right: 65px;
    /* Adjust based on unit width */
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    background: #f0f0f0;
    color: #999;
    border-radius: 50%;
    text-align: center;
    line-height: 18px;
    cursor: pointer;
    font-size: 16px;
    user-select: none;
    z-index: 5;
    transition: all 0.2s ease;
}

.clear-btn:hover {
    background: #e0e0e0;
    color: #666;
}

.clear-btn.show {
    display: block;
}

/* For fields without units, the X should be closer to the right */
#processing-type+.clear-btn {
    right: 35px;
}

/* Adjust select padding to avoid text overlapping with X */
.input-with-unit select {
    padding-right: 45px;
}

.error-message {
    color: var(--error-color);
    font-size: 12px;
    margin-top: 5px;
    display: none;
}

/* 隐藏 Firefox 的数字微调按钮 */
input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

/* 隐藏 Chrome/Safari/Edge 的数字微调按钮 */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
}

.error-message.show {
    display: block;
}

.bottom-actions {
    position: fixed;
    bottom: 0;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: min(100vw, var(--app-max-width));
    max-width: var(--app-max-width);
    background: white;
    padding: 15px 20px;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    gap: 10px;
    z-index: 100;
}

.primary-btn {
    flex: 1;
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 14px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: none;
}

.primary-btn:active {
    transform: translateY(0);
}

.secondary-btn {
    flex: 1;
    background: white;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    padding: 14px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

/* 按钮基础样式，使用 :active 提供触摸反馈，而不是依赖 :hover */
.secondary-btn:active {
    background: #f0f0f0;
    transform: scale(0.98);
}

@media (hover: hover) {
    .secondary-btn:hover {
        background: var(--primary-color);
        color: white;
    }
}

#page-parameter-input .bottom-actions .primary-btn {
    flex: 7;
}

#page-parameter-input .bottom-actions .secondary-btn {
    flex: 3;
}

.result-table {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 20px;
}

.result-table table {
    width: 100%;
    border-collapse: collapse;
}

.result-table th {
    background: var(--primary-color);
    color: white;
    padding: 12px;
    font-size: 14px;
    font-weight: 600;
    text-align: left;
    border: 1px solid var(--border-color);
}

.result-table td {
    padding: 16px 12px;
    font-size: 15px;
    color: var(--text-dark);
    border: 1px solid var(--border-color);
}

.predicted-value {
    color: var(--primary-color);
    font-size: 150%;
    font-weight: bold;
}

.result-table tr:last-child td {
    border-bottom: none;
}

.result-table tbody tr:hover {
    background-color: #f8f9fa;
}

.input-summary {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.input-summary h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-color);
}

.input-summary-content {
    font-size: 0.8125rem;
    color: var(--text-medium);
    line-height: 1.6;
}

.summary-group {
    margin-bottom: 20px;
}

.summary-group:last-child {
    margin-bottom: 0;
}

.summary-group p {
    margin-bottom: 5px;
}

.summary-item {
    padding-left: 2em;
    color: var(--text-medium);
}

.input-summary-content strong {
    color: var(--text-dark);
    font-weight: 600;
}

@media (max-width: 480px) {
    .animal-list {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 375px) {
    header h1 {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 70vw;
        /* Limit width to give space to lang button */
    }

    /* 中文版恢复 16px */
    html[lang="zh"] header h1 {
        font-size: 16px;
    }

    /* 英文版采用 13px (从 14px 下调) */
    html[lang="en"] header h1 {
        font-size: 13px;
    }

    .animal-list {
        gap: 12px;
    }

    .animal-card img {
        height: auto;
        min-height: 100px;
    }

    .animal-card p {
        font-size: 14px;
        padding: 10px;
    }

    .module {
        padding: 15px;
    }

    .bottom-actions {
        padding: 12px 15px;
    }

    .primary-btn,
    .secondary-btn {
        padding: 12px 20px;
        font-size: 15px;
    }
}

.footer-copyright {
    text-align: center;
    color: var(--text-light);
    font-size: 11px;
    line-height: 1.4;
    padding: 5px 0;
}

#result-footer td {
    border-bottom: none;
}

#result-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px 20px;
    gap: 8px;
    border-top: 1px solid var(--border-color);
    background: #fff;
    position: fixed;
    bottom: 0;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: min(100vw, var(--app-max-width));
    max-width: var(--app-max-width);
    z-index: 100;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

#result-footer .secondary-btn {
    width: auto;
    padding: 12px 48px;
}

/* Custom Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 5000;
}

.modal-overlay.show {
    display: flex;
}

.modal-content {
    background: #fff;
    width: 85%;
    max-width: 320px;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    animation: modal-pop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modal-pop {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-message {
    font-size: 16px;
    color: var(--text-dark);
    margin-bottom: 24px;
    text-align: center;
    line-height: 1.5;
    font-weight: 500;
}

.modal-actions {
    display: flex;
    gap: 12px;
}

.modal-actions button {
    flex: 1;
    padding: 12px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.modal-cancel {
    background: #f0f2f1;
    color: var(--text-medium);
}

.modal-confirm {
    background: var(--primary-color);
    color: white;
}

/* 移动端点击反馈 */
.modal-cancel:active {
    background: #e1e5e3;
}

.modal-confirm:active {
    background: var(--primary-dark);
}

/* Visitor Usage Bar */
#page-parameter-input .bottom-actions {
    flex-direction: column;
    padding: 0;
    padding-bottom: 10px;
}

#page-parameter-input .bottom-actions > div:last-child {
    padding: 10px 20px 0 20px;
}

.visitor-usage-bar {
    background-color: #FFFBE6;
    border: none;
    border-top: 1px solid #FFE58F;
    border-bottom: 1px solid #FFE58F;
    border-radius: 0;
    padding: 8px 12px;
    text-align: center;
    font-size: 14px;
    color: #FF4D4F;
    font-weight: 500;
    margin-bottom: 8px;
    width: 100%;
}

.modal-overlay.visitor-limit-modal .modal-content {
    max-width: 320px;
}

/* 对齐膨化饲料品质预测系统的桌面布局 */
.header-brand {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.header-subtitle {
    font-size: 11px;
    line-height: 1.2;
    color: rgba(255, 255, 255, 0.72);
    margin-top: 2px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.btn-header {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 28px;
    padding: 0 10px;
    border: none;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.95);
    font-size: 13px;
    cursor: pointer;
}

.btn-header:hover {
    background: rgba(255, 255, 255, 0.2);
}

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #fff;
    font-size: 13px;
    margin: 0 4px;
}

.user-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.lang-switch {
    display: inline-flex;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 2px;
    overflow: hidden;
}

.lang-switch .lang-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.82);
    border-radius: 0;
    padding: 3px 8px;
    font-size: 12px;
}

.lang-switch .lang-btn.active {
    background: #fff;
    color: var(--primary-color);
}

.header-powered {
    margin-left: 6px;
    padding: 3px 8px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 4px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.8);
    white-space: nowrap;
}

main {
    width: min(var(--app-max-width), calc(100% - 48px));
    margin: 20px auto 28px;
    padding: 0;
}

.app-footer {
    margin-top: auto;
    display: flex;
    justify-content: center;
    gap: 16px;
    padding: 14px 16px 18px;
    color: #a0a6ad;
    font-size: 12px;
}

#page-login.active {
    position: fixed;
    inset: 0;
    z-index: 300;
    height: 100%;
    padding: 0;
    display: flex;
    align-items: stretch;
    justify-content: stretch;
    background: linear-gradient(180deg, #e7f0ea 0%, #f5f7f6 42%, #eef2f0 100%);
}

.login-stage {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 16px 48px;
    position: relative;
}

.login-card {
    width: min(420px, 100%);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 32px rgba(16, 40, 72, 0.08);
    padding: 36px 36px 28px;
    text-align: left;
}

.login-mark {
    width: 44px;
    height: 44px;
    margin: 0 auto 14px;
    border-radius: 10px;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card h1 {
    text-align: center;
    font-size: 20px;
    font-weight: 650;
    color: var(--text-dark);
    margin-bottom: 6px;
}

.login-hint,
.login-sub {
    text-align: center;
    color: var(--text-light);
    font-size: 12px;
    line-height: 1.5;
}

.login-sub {
    margin-bottom: 22px;
}

.login-form .form-group {
    margin-bottom: 14px;
    text-align: left;
}

.login-form label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    color: var(--text-dark);
}

.login-form input {
    width: 100%;
    height: 40px;
    padding: 0 14px;
    border: none;
    border-radius: 20px;
    background: #f2f3f5;
    font-size: 14px;
}

.login-form input:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(51, 128, 89, 0.16);
}

.login-form .primary-btn {
    width: 100%;
    height: 42px;
    margin-top: 8px;
    border-radius: 21px;
    letter-spacing: 2px;
    font-size: 15px;
}

.btn-ghost {
    width: 100%;
    height: 40px;
    margin-top: 10px;
    border-radius: 20px;
    border: none;
    background: #f2f3f5;
    color: var(--primary-color);
    font-size: 14px;
    cursor: pointer;
}

.btn-ghost:hover {
    background: #e8eaed;
}

.login-langs {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    color: var(--text-light);
    font-size: 12px;
}

.text-lang {
    border: none;
    background: none;
    color: var(--text-medium);
    cursor: pointer;
    font-size: 12px;
    padding: 0;
}

.text-lang.active {
    color: var(--primary-color);
    font-weight: 600;
}

.login-foot {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 16px;
    text-align: center;
    color: #b0b6bd;
    font-size: 12px;
}

.workspace-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 14px;
}

.page-header {
    position: static;
    background: transparent;
    margin-top: 0;
    padding: 0 0 12px;
}

.parameter-form {
    counter-reset: section;
}

.parameter-form .module,
.group-selector,
.input-summary,
.result-table {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: none;
}

.parameter-form .module {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    column-gap: 16px;
    row-gap: 2px;
    padding: 16px 18px 8px;
}

.parameter-form .module h3,
.parameter-form .field-span-3 {
    grid-column: 1 / -1;
}

.module h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-dark);
    border-bottom: none;
    margin-bottom: 12px;
    padding-bottom: 0;
    font-size: 15px;
}

.parameter-form .module h3::before {
    counter-increment: section;
    content: counter(section);
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--primary-color);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.form-group input,
.input-with-unit input,
.custom-select__selected,
.grad-field input {
    border-radius: 4px;
    border-color: var(--border-color);
    min-height: 36px;
    padding-top: 7px;
    padding-bottom: 7px;
    font-size: 14px;
}

.primary-btn,
.secondary-btn {
    border-radius: 4px;
    min-height: 36px;
    padding: 8px 18px;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0;
}

.primary-btn:hover,
.secondary-btn:hover {
    transform: none;
}

.bottom-actions,
#result-footer {
    position: static;
    transform: none;
    left: auto;
    width: auto;
    max-width: none;
    box-shadow: none;
}

#page-parameter-input,
#page-result {
    padding-bottom: 8px;
}

#page-parameter-input .bottom-actions {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 14px 16px;
    gap: 10px;
}

#page-parameter-input .bottom-actions > div:last-child {
    display: flex;
    gap: 10px;
    width: 100%;
    padding: 0;
}

#page-parameter-input .bottom-actions .primary-btn,
#page-parameter-input .bottom-actions .secondary-btn {
    flex: 0 0 auto;
}

.visitor-usage-bar {
    border-radius: 4px;
    margin-bottom: 0;
}

#result-footer {
    align-items: flex-start;
    background: transparent;
    border: none;
    padding: 8px 0 0;
}

.animal-list {
    grid-template-columns: repeat(auto-fill, minmax(220px, 260px));
}

.animal-card,
.history-item,
.modal-content {
    border-radius: 8px;
}

#history-overlay {
    top: var(--header-h);
    right: 0;
    bottom: 0;
    left: auto;
    width: min(420px, 100vw);
    max-width: none;
    height: auto;
    border-radius: 0;
    transform: translateX(100%);
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.08);
}

#history-overlay.show {
    transform: translateX(0);
}

#gradient-overlay {
    top: var(--header-h);
    right: 0;
    bottom: 0;
    left: auto;
    width: min(720px, 100vw);
    max-width: none;
    height: auto;
    border-radius: 0;
    transform: translateX(100%);
}

#gradient-overlay.show {
    transform: translateX(0);
}

.result-table th {
    background: #f7f8fa;
    color: var(--text-medium);
    font-weight: 600;
}

.predicted-value {
    color: var(--primary-color);
    font-size: 28px;
}

@media (max-width: 860px) {
    header {
        height: auto;
        min-height: var(--header-h);
        padding: 8px 12px;
        align-items: flex-start;
        gap: 8px;
    }

    .header-powered {
        display: none;
    }

    main {
        width: calc(100% - 24px);
        margin-top: 12px;
    }

    .parameter-form .module {
        grid-template-columns: 1fr;
    }

    .login-card {
        padding: 28px 20px 22px;
    }
}
