/* ========== VPS 剩余价值计算器 · 优化完整版 ==========
   方案二：深蓝专业配色 + 全交互优化 + 下拉修复
*/

/* ========== 全局变量 ========== */
:root {
    /* 主色：深蓝 交易工具标准配色 */
    --brand: #2563eb;
    --brand-dark: #1d4ed8;
    --brand-soft: #eff6ff;
    --brand-light: #dbeafe;

    /* 文字四级灰度 */
    --ink: #0f172a;
    --ink-2: #334155;
    --muted: #64748b;
    --faint: #94a3b8;

    /* 线条与背景 */
    --line: #e2e8f0;
    --line-soft: #f1f5f9;
    --bg: #f8fafc;
    --card: #ffffff;

    /* 语义色 */
    --warn: #f97316;
    --good: #059669;
    --danger: #dc2626;

    /* 圆角与阴影 */
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 2px 0 rgba(15, 23, 42, .05), 0 1px 3px 0 rgba(15, 23, 42, .06);
    --shadow-lg: 0 10px 25px -5px rgba(37, 99, 235, .12);
    --shadow-dropdown: 0 8px 24px -4px rgba(15, 23, 42, .15);
}

/* ========== 基础重置 ========== */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    padding: 16px 16px 40px;
    background: var(--bg);
    color: var(--ink);
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    font-size: 17px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
a { color: var(--brand-dark); text-decoration: none; }
input, select, button, textarea { font-family: inherit; }
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; }

/* ========== 布局容器 ========== */
.wrap { max-width: 1180px; margin: 0 auto; }

/* ========== 顶部栏 ========== */
.topbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 16px;
    margin-bottom: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 6px 16px rgba(37, 99, 235, .3);
    flex: none;
}
.brand h1 {
    margin: 0;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -.01em;
    color: var(--ink);
    line-height: 1.2;
}
.brand .tagline {
    margin: 2px 0 0;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--faint);
}
.stats {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    font-size: 15px;
    font-weight: 700;
    color: var(--muted);
}
.stats .today { color: var(--brand-dark); }
.stats .total { color: var(--warn); }
.stats i { width: 16px; text-align: center; }

/* ========== 栅格布局 ========== */
.layout {
    display: grid;
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    gap: 16px;
    align-items: start;
}
.col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

/* ========== 卡片通用 ========== */
.card {
    background: var(--card);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    transition: box-shadow .2s ease, border-color .2s ease;
}
.card:hover {
    box-shadow: 0 4px 12px -2px rgba(15, 23, 42, .08);
}
.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}
.section-label {
    margin: 0 0 12px;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--faint);
}
.card-head .section-label { margin-bottom: 0; }

/* ========== 表单控件 ========== */
.field-label {
    display: block;
    font-size: 13.5px;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--faint);
    margin-bottom: 6px;
    line-height: 20px;
    min-height: 20px;
}
.field-label.row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.field-input {
    width: 100%;
    height: 44px;
    padding: 0 12px;
    line-height: 1.3;
    background: #f8fafc;
    border: 1.5px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 600;
    color: var(--ink);
    outline: none;
    transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.field-input:focus {
    border-color: var(--brand);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.core-input {
    font-size: 22px;
    font-weight: 800;
    height: 54px;
    padding: 0 14px;
    border-width: 2px;
    border-color: var(--brand-light);
    background: #fff;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-renew { display: grid; grid-template-columns: 3fr 2fr; gap: 12px; margin-bottom: 14px; }

/* ========== 周期按钮 ========== */
.grid-cycle { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.cycle-btn {
    border: 1.5px solid var(--line);
    background: #fff;
    color: var(--faint);
    font-weight: 800;
    font-size: 15px;
    border-radius: var(--radius-sm);
    padding: 8px 0;
    cursor: pointer;
    width: 100%;
    transition: all .15s ease;
}
.cycle-btn:hover { 
    border-color: var(--brand-light); 
    color: var(--brand-dark);
    background: var(--brand-soft);
}
.cycle-btn.active {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, .3);
}

/* ========== 开关 ========== */
.mini-toggle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    text-transform: none;
    letter-spacing: 0;
    font-size: 14px;
    font-weight: 700;
    line-height: 20px;
    height: 20px;
    color: var(--muted);
    transition: color .15s ease;
}
.mini-toggle:hover { color: var(--brand-dark); }
.mini-toggle input { accent-color: var(--brand); width: 14px; height: 14px; margin: 0; }

.custom-rate {
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    background: #f8fafc;
    border: 1px solid var(--line);
    padding: 6px 8px;
    border-radius: var(--radius-sm);
}
.custom-rate span { font-size: 14px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.custom-rate .field-input { height: 34px; padding: 0 10px; font-size: 15px; background: #fff; }

.link-btn {
    background: none;
    border: 0;
    padding: 0;
    font-size: 14px;
    font-weight: 700;
    color: var(--faint);
    cursor: pointer;
    transition: color .15s ease;
}
.link-btn:hover, .link-btn.on { color: var(--brand-dark); }

/* ========== 结算区 ========== */
.settle-box {
    background: var(--brand-soft);
    border: 1px solid var(--brand-light);
    border-radius: var(--radius-sm);
    padding: 14px;
    margin-bottom: 14px;
}
.settle-label { font-size: 14px; font-weight: 800; color: var(--brand-dark); margin-bottom: 6px; }
.bind-hint { font-size: 13px; font-weight: 700; color: var(--brand-dark); margin-top: 8px; }

.push-row {
    background: #f8fafc;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.push-row .push-title { font-size: 15px; font-weight: 700; color: var(--muted); }
.push-row .push-controls { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.push-row .push-fee { width: 84px; height: 40px; padding: 0 10px; background: #fff; }

/* ========== 自定义下拉（核心修复：层级+定位） ========== */
.csel-wrap { 
    position: relative; 
    display: inline-block;
    z-index: 1;
}
.csel-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    height: 44px;
    padding: 0 12px;
    background: #f8fafc;
    border: 1.5px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 600;
    color: var(--ink);
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease;
    width: 100%;
}
.csel-btn:hover { border-color: var(--brand-light); background: #fff; }
.csel-btn i { font-size: 12px; color: var(--faint); transition: transform .2s ease; }
.csel-wrap.open .csel-btn i { transform: rotate(180deg); }

.csel-dropdown {
    position: absolute;
    z-index: 100; /* 提升层级，不被遮挡 */
    top: calc(100% + 4px);
    right: 0;
    min-width: 160px;
    background: #fff;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-dropdown);
    padding: 4px;
    display: none;
    max-height: 280px;
    overflow-y: auto;
    animation: dropdown-in .18s ease-out;
}
.csel-dropdown.open { display: block; }

@keyframes dropdown-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.csel-option {
    padding: 8px 12px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: background .12s ease, color .12s ease;
}
.csel-option:hover { background: var(--brand-soft); color: var(--brand-dark); }
.csel-option.active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 700; }

/* 占满宽度的下拉块 */
.csel-wrap.csel-block { display: block; width: 100%; }
.csel-wrap.csel-block .csel-btn {
    width: 100%;
    height: 44px;
}
.csel-wrap.csel-block .csel-dropdown { left: 0; right: 0; }

/* ========== 操作菜单 ========== */
.menu-wrap { position: relative; flex: 1 1 auto; min-width: 0; z-index: 2; }
.menu-wrap > .btn { width: 100%; }
.menu-wrap .caret { font-size: 12px; opacity: .8; margin-left: 2px; }
.menu-dropdown { left: 0; right: auto; min-width: 180px; }
.menu-dropdown .csel-option {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}
.menu-dropdown .csel-option i { width: 16px; text-align: center; color: var(--faint); font-size: 15px; }
.menu-dropdown .csel-option:hover i { color: var(--brand-dark); }

/* ========== 日期输入框 ========== */
input[type="date"],
input[type="datetime-local"] {
    height: 44px !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    color: var(--ink) !important;
    padding: 0 12px !important;
    background: #f8fafc !important;
    border: 1.5px solid var(--line) !important;
    border-radius: var(--radius-sm) !important;
    width: 100%;
    box-sizing: border-box;
}
input[type="date"]:focus,
input[type="datetime-local"]:focus {
    border-color: var(--brand) !important;
    background: #fff !important;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12) !important;
    outline: none !important;
}

.date-field { position: relative; }
.date-field .fa-calendar-days {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--faint);
    pointer-events: none;
    font-size: 15px;
    z-index: 3;
}

/* flatpickr 弹窗样式匹配 */
.flatpickr-calendar {
    font-family: inherit !important;
    border-radius: var(--radius) !important;
    border: 1px solid var(--line-soft) !important;
    box-shadow: var(--shadow-dropdown) !important;
    font-size: 15px !important;
    z-index: 101 !important;
}
.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange {
    background: var(--brand) !important;
    border-color: var(--brand) !important;
    box-shadow: 0 2px 8px rgba(37, 99, 235, .3) !important;
}
.flatpickr-day.today { border-color: var(--brand) !important; color: var(--brand-dark) !important; }

/* ========== 右侧结果面板 ========== */
.result-panel {
    position: sticky;
    top: 16px;
    background: linear-gradient(180deg, #ffffff 0%, #f8faff 100%);
    border: 1px solid #dbeafe;
    border-top: 4px solid var(--brand);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 20px 18px 18px;
    color: var(--ink);
}
.result-hero { text-align: center; margin-bottom: 16px; }
.result-hero .hero-label {
    margin: 0 0 4px;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--brand-dark);
}
.result-hero .hero-value {
    font-size: 48px;
    line-height: 1.1;
    font-weight: 800;
    letter-spacing: -.02em;
    color: var(--ink);
    word-break: break-all;
}

.premium-box {
    text-align: center;
    margin-bottom: 16px;
    padding-top: 14px;
    border-top: 1px solid #e2e8f0;
}
.premium-box .premium-title { margin: 0 0 4px; font-size: 14px; font-weight: 800; }
.premium-box .premium-value { font-size: 28px; font-weight: 800; line-height: 1.15; }
.is-premium { color: var(--warn); }
.is-discount { color: var(--good); }

.result-rows { border-top: 1px solid #e2e8f0; padding-top: 6px; }
.result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid #f1f5f9;
}
.result-row:last-child { border-bottom: 0; }
.result-label {
    font-size: 14px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .03em;
}
.result-value { font-size: 16px; font-weight: 800; color: var(--ink-2); text-align: right; }
.result-row.accent .result-label, 
.result-row.accent .result-value { color: var(--brand-dark); }
.result-value.soft { color: var(--faint); }

/* 进度条 */
.progress-block { margin-top: 16px; }
.progress-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    margin-bottom: 6px;
}
.progress-head .p-title { color: var(--muted); }
.progress-head .p-days { color: var(--brand-dark); font-size: 18px; font-weight: 800; }
.progress-head .p-days.expired { color: var(--danger); }
.progress-track { background: #e2e8f0; border-radius: 99px; height: 8px; overflow: hidden; }
.progress-bar {
    background: linear-gradient(90deg, var(--brand), #60a5fa);
    border-radius: 99px;
    height: 100%;
    width: 0;
    transition: width .8s cubic-bezier(.4, 0, .2, 1);
}
.progress-hint { text-align: right; font-size: 13px; color: var(--muted); font-weight: 700; margin-top: 4px; }

/* 比例条 */
.ratio-block { margin-top: 14px; padding-top: 14px; border-top: 1px solid #e2e8f0; }
.ratio-title {
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 6px;
}
.ratio-track { height: 10px; background: #e2e8f0; border-radius: 99px; overflow: hidden; display: flex; }
.ratio-track > div { height: 100%; transition: width .5s ease; }
.bar-value { background: var(--brand); }
.bar-premium { background: var(--warn); }
.ratio-legend { display: flex; gap: 16px; margin-top: 8px; font-size: 13px; font-weight: 700; color: var(--muted); }
.ratio-legend span.dot { width: 8px; height: 8px; border-radius: 99px; display: inline-block; margin-right: 6px; }
.dot-value { background: var(--brand); }
.dot-premium { background: var(--warn); }

/* 结算区 */
.settle-block { margin-top: 16px; padding-top: 14px; border-top: 1px solid #e2e8f0; }
.settle-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.check-label { display: flex; align-items: center; gap: 7px; cursor: pointer; font-size: 15px; font-weight: 700; color: var(--muted); }
.check-label input { accent-color: var(--brand); width: 16px; height: 16px; }
.check-label:hover { color: var(--ink-2); }
.settle-head .csel-btn { height: 36px; padding: 0 10px; font-size: 14px; font-weight: 700; color: var(--ink-2); }

.final-box {
    border-radius: var(--radius-sm);
    padding: 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    transition: all .3s ease;
}
.final-box.active { 
    background: rgba(37, 99, 235, .06); 
    border-color: rgba(37, 99, 235, .3); 
}
.final-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.final-label { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.final-extra { font-size: 13px; font-weight: 700; color: var(--faint); }
.final-value { text-align: right; font-size: 28px; font-weight: 800; color: var(--ink); line-height: 1.15; }
.final-box.active .final-label,
.final-box.active .final-extra,
.final-box.active .final-value { color: var(--brand-dark); }

/* ========== 按钮组 ========== */
.actions { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.btn {
    border: 0;
    border-radius: var(--radius-sm);
    font-weight: 800;
    font-size: 16px;
    cursor: pointer;
    transition: all .15s ease;
    padding: 11px 16px;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .6; cursor: progress; transform: none; }

.btn-primary { 
    background: var(--brand); 
    color: #fff; 
    box-shadow: 0 4px 12px rgba(37, 99, 235, .3); 
}
.btn-primary:hover { background: var(--brand-dark); box-shadow: 0 6px 16px rgba(37, 99, 235, .35); }

.btn-ghost { background: #f1f5f9; color: var(--ink-2); }
.btn-ghost:hover { background: #e2e8f0; }
.btn-danger { background: #fee2e2; color: var(--danger); }
.btn-icon { padding: 11px 14px; }
.btn-sm { padding: 8px 12px; font-size: 14px; border-radius: 8px; }
.actions .btn-share { flex: 1 1 auto; }

/* ========== 汇率面板 ========== */
.rate-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.rate-title { margin: 0; font-size: 14px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.rate-title i { color: var(--brand); margin-right: 5px; }
.rate-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.badge {
    font-size: 13px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 99px;
    background: var(--brand-soft);
    color: var(--brand-dark);
}
.badge.warn { background: #fff7ed; color: #c2410c; }
.rate-source { font-size: 13px; font-weight: 700; color: var(--faint); }
.rate-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.rate-cell {
    text-align: center;
    padding: 10px 6px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line-soft);
    background: #f8fafc;
    transition: all .15s ease;
}
.rate-cell:hover { border-color: var(--brand-light); background: #fff; }
.rate-cell .code { font-size: 13px; font-weight: 800; letter-spacing: .07em; color: var(--faint); }
.rate-cell .value { font-size: 17px; font-weight: 800; color: var(--ink-2); margin-top: 2px; }
.rate-cell.is-base { border-color: var(--brand-light); background: var(--brand-soft); }
.rate-cell.is-base .code { color: var(--brand-dark); }

/* ========== 说明区 ========== */
.prose { margin-top: 18px; }
.prose h2 { font-size: 21px; font-weight: 800; margin: 0 0 12px; color: var(--ink); }
.prose h3 { font-size: 17.5px; font-weight: 800; margin: 18px 0 6px; color: var(--ink-2); }
.prose h4 { font-size: 16px; font-weight: 800; margin: 14px 0 4px; color: var(--ink-2); }
.prose p, .prose li { font-size: 16px; color: var(--ink-2); line-height: 1.6; }
.prose p { margin: 0 0 10px; }
.prose ul, .prose ol { margin: 0 0 10px; padding-left: 22px; }
.prose li { margin-bottom: 4px; }
.prose code { background: #f1f5f9; padding: 2px 6px; border-radius: 5px; font-size: 14.5px; }
.formula {
    background: #f8fafc;
    border-left: 4px solid var(--brand);
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 16px;
    font-weight: 700;
    color: var(--ink-2);
    margin: 0 0 14px;
}

/* ========== 页脚 ========== */
.site-footer {
    max-width: 1180px;
    margin: 24px auto 0;
    text-align: center;
    font-size: 14px;
    color: var(--faint);
    font-weight: 600;
}

/* ========== Toast 提示 ========== */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 999;
    display: none;
    align-items: center;
    gap: 8px;
    background: #0f172a;
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    padding: 10px 20px;
    border-radius: 99px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, .3);
    pointer-events: none;
    max-width: calc(100vw - 40px);
}
.toast i { color: #4ade80; }
.toast.error i { color: #fca5a5; }
.shturl.cc/ { display: flex; animation: toast-in .25s ease forwards; }
@keyframes toast-in {
    from { opacity: 0; transform: translateX(-50%) translateY(8px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.hidden { display: none !important; }

/* ========== 响应式适配 ========== */
@media (max-width: 1023px) {
    .layout { grid-template-columns: minmax(0, 1fr); }
    .result-panel { position: static; }
    .col-result { order: -1; }
}

@media (max-width: 640px) {
    body { padding: 12px 12px 32px; }
    .card { padding: 14px; }
    .result-panel { padding: 16px 14px; }
    .result-hero .hero-value { font-size: 40px; }
    .grid-renew { grid-template-columns: 1fr; }
    .grid-cycle { grid-template-columns: repeat(3, 1fr); }
    .rate-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .brand h1 { font-size: 20px; }
    .final-value { font-size: 24px; }
    .push-row .push-controls { margin-left: 0; width: 100%; }
    .push-row .push-fee { flex: 1; width: auto; }
    .share-row { flex-wrap: wrap; }
    .share-key { width: 100%; }
    .share-input { flex: 1 1 0; }
}
