/* ====== 续费总管理 v4 ====== */
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }

:root {
    --bg: #f1f5f9;
    --surface: #fff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --green: #059669;
    --green-bg: #d1fae5;
    --red: #dc2626;
    --red-bg: #fee2e2;
    --orange: #d97706;
    --orange-bg: #fef3c7;
    --blue: #2563eb;
    --purple: #7c3aed;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { opacity: 0.85; }

/* ====== 容器 ====== */
.container { max-width: 1200px; margin: 0 auto; padding: 24px; }

/* ====== 头部 ====== */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 12px;
    margin-bottom: 24px; padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.page-header h1 { font-size: 24px; font-weight: 700; color: var(--text); }
.page-header .title-sub { font-size: 15px; color: var(--text-muted); font-weight: 400; }
.header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.back-link { font-size: 16px; color: var(--text-secondary); display: inline-flex; align-items: center; gap: 4px; margin-bottom: 4px; }
.back-link:hover { color: var(--primary); }

/* ====== 按钮 ====== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 16px; border: none; border-radius: var(--radius-sm);
    font-size: 16px; font-weight: 500; cursor: pointer;
    transition: all 0.15s; white-space: nowrap; text-decoration: none;
}
.btn-sm { padding: 4px 10px; font-size: 15px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-warning { background: #f59e0b; color: #fff; }
.btn-warning:hover { background: #d97706; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-outline { background: var(--surface); color: var(--text); border: 1px solid #cbd5e1; }
.btn-outline:hover { background: #f8fafc; }

/* ====== 消息条 ====== */
.msg { padding: 10px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 16px; font-weight: 500; }
.msg-success { background: var(--green-bg); color: #065f46; }
.msg-error { background: var(--red-bg); color: #991b1b; }

/* ====== 统计卡片行 ====== */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}
.stat-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    text-align: center;
}
.stat-box .num { font-size: 34px; font-weight: 700; color: var(--text); line-height: 1.1; }
.stat-box .lbl { font-size: 14px; color: var(--text-muted); margin-top: 4px; letter-spacing: 0.5px; }
.stat-box.green .num { color: var(--green); }
.stat-box.red .num { color: var(--red); }

/* ====== 表格 ====== */
.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
table { width: 100%; border-collapse: collapse; font-size: 16px; }
thead { background: #f8fafc; border-bottom: 2px solid var(--border); }
th {
    padding: 10px 14px; text-align: left;
    font-weight: 600; color: var(--text-secondary);
    font-size: 14px; text-transform: uppercase; letter-spacing: 0.5px;
    white-space: nowrap;
}
td { padding: 12px 14px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
tbody tr:hover { background: #fafbff; }
tbody tr:last-child td { border-bottom: none; }

/* ====== 徽章 ====== */
.badge {
    display: inline-block; padding: 2px 10px; border-radius: 20px;
    font-size: 14px; font-weight: 600; white-space: nowrap;
}
.badge-green { background: var(--green-bg); color: #065f46; }
.badge-red { background: var(--red-bg); color: #991b1b; }
.badge-gray { background: #f1f5f9; color: var(--text-secondary); }
.badge-yellow { background: var(--orange-bg); color: #92400e; }
.text-muted { color: var(--text-muted); font-size: 15px; }

/* ====== 域名单元格 ====== */
.domain-cell { display: flex; flex-direction: column; gap: 2px; }
.domain-cell strong { font-size: 16px; color: var(--text); }
.domain-cell a { font-size: 13px; color: var(--text-muted); font-family: "SF Mono", monospace; }

/* ====== 空状态 ====== */
.empty-state { text-align: center; padding: 48px 20px; }
.empty-state p { color: var(--text-muted); margin-bottom: 16px; }

/* ====== 弹窗 ====== */
.modal {
    display: none; position: fixed; inset: 0; z-index: 1000;
    background: rgba(15,23,42,0.4); backdrop-filter: blur(4px);
    justify-content: center; align-items: center; padding: 20px;
}
.modal-content {
    background: var(--surface); border-radius: 16px;
    width: 100%; max-width: 460px; overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    animation: mi 0.2s ease;
}
@keyframes mi { from{opacity:0;transform:translateY(-12px)} to{opacity:1;transform:translateY(0)} }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 18px; font-weight: 600; }
.modal-close { font-size: 22px; color: var(--text-muted); cursor: pointer; line-height: 1; }
.modal-close:hover { color: var(--red); }
.modal-body { padding: 22px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--border); background: #f8fafc; }

/* ====== 表单 ====== */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 15px; font-weight: 500; color: var(--text-secondary); margin-bottom: 5px; }
.form-group small { display: block; font-size: 14px; color: var(--text-muted); margin-top: 3px; }
.form-input {
    width: 100%; padding: 8px 12px; border: 1px solid #cbd5e1;
    border-radius: var(--radius-sm); font-size: 16px; color: var(--text);
    background: var(--surface); outline: none; transition: border-color 0.15s;
}
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,0.1); }

/* ====== 详情页 ====== */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.detail-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}
.detail-card.full { grid-column: 1 / -1; }
.detail-card h2 {
    font-size: 17px; font-weight: 600; color: var(--text);
    margin-bottom: 14px; padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}
.info-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 7px 0; font-size: 16px;
}
.info-row + .info-row { border-top: 1px solid #fafafa; }
.info-label { color: var(--text-secondary); flex-shrink: 0; margin-right: 12px; }
.info-value { color: var(--text); text-align: right; word-break: break-all; }

/* ====== 过期高亮 ====== */
.expire-box {
    text-align: center; padding: 20px; border-radius: var(--radius);
    margin-bottom: 16px;
}
.expire-box.ok { background: linear-gradient(135deg, #d1fae5, #ecfdf5); }
.expire-box.warn { background: linear-gradient(135deg, #fef3c7, #fffbeb); }
.expire-box.bad { background: linear-gradient(135deg, #fee2e2, #fef2f2); }
.expire-box .date { font-size: 24px; font-weight: 700; font-family: "SF Mono", monospace; margin-bottom: 6px; }
.expire-box.bad .date { color: var(--red); }
.expire-box .days { font-size: 16px; font-weight: 500; }

/* ====== 续费表单 ====== */
.action-form { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.action-form select, .action-form input[type="datetime-local"] {
    padding: 6px 10px; border: 1px solid #cbd5e1; border-radius: var(--radius-sm);
    font-size: 15px; outline: none; background: #fff;
}

/* ====== 迷你统计 ====== */
.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; text-align: center; }
.mini-stats .num { font-size: 30px; font-weight: 700; }
.mini-stats .lbl { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.green-txt { color: var(--green); }
.blue-txt { color: #2563eb; }

/* ====== API 原始响应 ====== */
.raw-json {
    background: #1e293b; color: #94a3b8; padding: 14px;
    border-radius: var(--radius-sm); font-size: 12px;
    font-family: "SF Mono", monospace; overflow-x: auto;
    max-height: 250px; overflow-y: auto;
}

/* ====== 操作按钮组 ====== */
.act-btns { display: flex; gap: 6px; }
.act-group { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }

/* ====== 复选框 ====== */
input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary); }

/* ====== 开关 ====== */
.toggle-switch {
    position: relative; display: inline-block; width: 40px; height: 22px;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #cbd5e1; border-radius: 22px;
    transition: 0.2s;
}
.toggle-slider:before {
    content: ""; position: absolute;
    height: 16px; width: 16px;
    left: 3px; bottom: 3px;
    background: #fff; border-radius: 50%;
    transition: 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--green); }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(18px); }

/* ====== 响应式 ====== */
@media (max-width: 768px) {
    .container { padding: 12px 14px; }
    .page-header h1 { font-size: 20px; }
    .detail-grid { grid-template-columns: 1fr; }
    .stats-bar { gap: 10px; }
    .modal-content { max-width: 90vw; }
    .table-wrap { overflow-x: visible; }
    th, td { padding: 8px 10px; font-size: 14px; }
}

@media (max-width: 640px) {
    .container { padding: 8px 10px; }
    .page-header { gap: 8px; margin-bottom: 14px; padding-bottom: 12px; }
    .page-header h1 { font-size: 19px; }
    .header-actions { gap: 6px; }
    .header-actions .btn { padding: 6px 10px; font-size: 13px; }
    .header-actions .toggle-switch { transform: scale(0.85); transform-origin: left center; }
    #refreshTime { display: none !important; }
    .stats-bar { gap: 8px; }
    .stat-box { padding: 14px 8px; }
    .stat-box .num { font-size: 26px; }
    .stat-box .lbl { font-size: 13px; }
    .detail-card { padding: 14px; }
    .expire-box { padding: 14px; }
    .expire-box .date { font-size: 20px; }
    .btn { padding: 9px 14px; font-size: 14px; min-height: 40px; }
    .btn-sm { padding: 5px 10px; min-height: 34px; }
    .modal { padding: 0; align-items: flex-end; }
    .modal-content { max-width: 100%; border-radius: 16px 16px 0 0; max-height: 88vh; overflow-y: auto; }
    .modal-body { padding: 18px; }
    .modal-footer { flex-direction: column; }
    .modal-footer .btn { width: 100%; }

    /* 表格转卡片布局 */
    .table-wrap { background: transparent; border: none; border-radius: 0; }
    table, thead, tbody, tr, td { display: block; width: 100%; }
    thead { display: none; }
    tbody tr {
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        padding: 12px 14px;
        margin-bottom: 12px;
        box-shadow: var(--shadow);
    }
    tbody tr:hover { background: var(--surface); }
    td {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        padding: 6px 0 !important;
        border: none !important;
        font-size: 14px;
        gap: 12px;
    }
    td + td { border-top: 1px solid #f1f5f9 !important; padding-top: 8px !important; margin-top: 4px; }
    td[data-label]:not([data-label="选择"]):not([data-label="操作"]):before {
        content: attr(data-label);
        color: var(--text-muted);
        font-size: 13px;
        flex-shrink: 0;
        min-width: 70px;
    }
    td[data-label="选择"] {
        justify-content: flex-end;
        padding-bottom: 4px !important;
    }
    td[data-label="域名"] { flex-direction: column; align-items: flex-start; gap: 2px; }
    td[data-label="域名"]:before { display: none; }
    td[data-label="操作"] { justify-content: flex-end; }
    .act-btns { width: 100%; justify-content: flex-end; }
    .act-btns .btn { flex: 1; max-width: 120px; }
    .domain-cell strong { font-size: 17px; }
    .domain-cell a { font-size: 13px; word-break: break-all; }
}

/* ====== 夜间模式 ====== */
:root[data-theme="dark"] {
    --bg: #0f172a;
    --surface: #1e293b;
    --border: #334155;
    --text: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --primary: #818cf8;
    --primary-hover: #6366f1;
    --green: #34d399;
    --green-bg: #064e3b;
    --red: #f87171;
    --red-bg: #450a0a;
    --orange: #fbbf24;
    --orange-bg: #451a03;
    --blue: #60a5fa;
    --purple: #a78bfa;
    --shadow: 0 1px 3px rgba(0,0,0,0.4);
}

:root[data-theme="dark"] body { background: var(--bg); color: var(--text); }
:root[data-theme="dark"] thead { background: #0f172a; }
:root[data-theme="dark"] td { border-bottom-color: #1e293b; }
:root[data-theme="dark"] tbody tr:hover { background: #263449; }
:root[data-theme="dark"] td + td { border-top-color: #1e293b !important; }
:root[data-theme="dark"] .badge-gray { background: #334155; color: #cbd5e1; }
:root[data-theme="dark"] .btn-outline { border-color: #475569; }
:root[data-theme="dark"] .btn-outline:hover { background: #334155; }
:root[data-theme="dark"] .modal-footer { background: #0f172a; }
:root[data-theme="dark"] .modal { background: rgba(0,0,0,0.6); }
:root[data-theme="dark"] .form-input { border-color: #475569; }
:root[data-theme="dark"] .action-form select,
:root[data-theme="dark"] .action-form input[type="datetime-local"] { background: #1e293b; border-color: #475569; color: var(--text); }
:root[data-theme="dark"] .info-row + .info-row { border-top-color: #1e293b; }
:root[data-theme="dark"] .toggle-slider { background: #475569; }
:root[data-theme="dark"] .toggle-slider:before { background: #e2e8f0; }
:root[data-theme="dark"] .expire-box.ok { background: linear-gradient(135deg, #064e3b, #0f3d2e); }
:root[data-theme="dark"] .expire-box.warn { background: linear-gradient(135deg, #451a03, #3b2f05); }
:root[data-theme="dark"] .expire-box.bad { background: linear-gradient(135deg, #450a0a, #3f1414); }
:root[data-theme="dark"] .msg-success { background: var(--green-bg); color: #6ee7b7; }
:root[data-theme="dark"] .msg-error { background: var(--red-bg); color: #fca5a5; }
:root[data-theme="dark"] .badge-green { background: var(--green-bg); color: #6ee7b7; }
:root[data-theme="dark"] .badge-red { background: var(--red-bg); color: #fca5a5; }
:root[data-theme="dark"] .badge-yellow { background: var(--orange-bg); color: #fcd34d; }
:root[data-theme="dark"] .raw-json { background: #0b1220; }

/* 批量弹窗输入框高亮（浅色 / 夜间两套） */
.input-highlight { background: #fffbe6 !important; }
.input-highlight-warn { background: #fff3cd !important; }
:root[data-theme="dark"] .input-highlight { background: #3f3a10 !important; }
:root[data-theme="dark"] .input-highlight-warn { background: #4a3410 !important; }

/* ====== 今日跳转走势图 Tooltip ====== */
.today-ip-num { cursor: pointer; }
.trend-tooltip {
    position: fixed; z-index: 9999;
    display: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 10px 32px rgba(0,0,0,0.16);
    padding: 16px 18px;
    min-width: 620px;
    width: min(1400px, calc(100vw - 32px));
    pointer-events: auto;
}
.trend-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.trend-head strong { font-size: 18px; color: var(--text); }
.trend-now { font-size: 15px; color: var(--text-muted); }
.trend-stats { display: flex; gap: 8px; margin: 8px 0 6px; }
.trend-stats .ts {
    flex: 1; background: #f1f5f9; border: 1px solid var(--border); border-radius: 8px;
    padding: 8px 10px; display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.trend-stats .ts i { font-style: normal; font-size: 14px; color: var(--text-muted); }
.trend-stats .ts b { font-size: 22px; color: var(--text); }
.trend-stats .ts.hl b { color: var(--blue); }
.trend-stats .ts.hl-peak b { color: var(--orange); }
.trend-stats .ts.hl-total b { color: var(--green); }
.trend-loading { padding: 40px 0; text-align: center; font-size: 16px; color: var(--text-muted); min-width: 420px; }
.trend-tooltip svg { display: block; width: 100%; height: auto; }
.trend-tooltip svg text { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; }
.trend-foot { font-size: 14px; color: var(--text-muted); margin-top: 6px; text-align: right; }
:root[data-theme="dark"] .trend-tooltip { box-shadow: 0 10px 32px rgba(0,0,0,0.55); }
:root[data-theme="dark"] .trend-stats .ts { background: #0f172a; }

/* ====== 移动端：走势图 Tooltip 适配 ====== */
@media (max-width: 640px) {
    .trend-tooltip {
        min-width: 0;
        width: calc(100vw - 20px) !important;
        left: 10px !important;
        right: 10px !important;
        padding: 12px;
        max-height: 78vh;
        overflow-y: auto;
    }
    .trend-head { flex-direction: column; gap: 2px; align-items: flex-start; }
    .trend-head strong { font-size: 16px; }
    .trend-now { font-size: 13px; }
    .trend-stats { flex-direction: column; gap: 6px; margin: 8px 0 8px; }
    .trend-stats .ts {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 7px 12px;
    }
    .trend-stats .ts i { font-size: 13px; }
    .trend-stats .ts b { font-size: 18px; }
    .trend-loading { min-width: 0; padding: 28px 0; font-size: 15px; }
    .trend-foot { font-size: 13px; line-height: 1.4; }
}
