/* ============================================================
   AllRich Dashboard 设计系统（现代金融浅色风）
   全站共享样式：tokens / 导航 / 卡片 / 按钮 / 表单 / 表格 / 弹窗
   ============================================================ */

:root {
    /* 主色与语义色 */
    --primary: #3b6ef6;
    --primary-hover: #2b5ce4;
    --primary-active: #234fbe;
    --primary-soft: rgba(59, 110, 246, 0.09);
    --primary-border: rgba(59, 110, 246, 0.30);
    --brand-grad: linear-gradient(135deg, #667eea 0%, #764ba2 100%);

    --up: #e5484d;            /* 盈 / 涨（A股红） */
    --up-soft: rgba(229, 72, 77, 0.09);
    --down: #16a34a;          /* 亏 / 跌 */
    --down-soft: rgba(22, 163, 74, 0.09);
    --warn: #d97706;
    --warn-soft: rgba(217, 119, 6, 0.12);

    /* 中性色 */
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-2: #f8fafd;
    --surface-3: #eef2f8;
    --border: #e6eaf2;
    --border-strong: #d5dcea;
    --text: #1d2330;
    --text-2: #5b6472;
    --text-3: #98a2b3;

    /* 圆角 / 阴影 */
    --r-sm: 8px;
    --r: 12px;
    --r-lg: 16px;
    --r-xl: 20px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow: 0 1px 3px rgba(16, 24, 40, 0.04), 0 8px 24px -8px rgba(16, 24, 40, 0.08);
    --shadow-lg: 0 12px 40px -12px rgba(16, 24, 40, 0.18);

    --nav-h: 52px;
    --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Segoe UI', sans-serif;
    --mono: 'SF Mono', ui-monospace, Menlo, Consolas, monospace;
    --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
}

/* ---------- 基础 ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

::selection { background: rgba(59, 110, 246, 0.18); }

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

/* 细滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #cdd5e1; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #b3bfd1; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 导航栏 ---------- */
.apple-nav {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--nav-h);
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    z-index: 9999;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.2px;
    color: var(--text);
    min-width: 100px;
    flex: 1;
    user-select: none;
}

.nav-brand-icon {
    width: 26px;
    height: 26px;
    background: var(--brand-grad);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.35);
}

.nav-links {
    display: flex;
    gap: 2px;
    justify-content: center;
    background: var(--surface-3);
    padding: 3px;
    border-radius: 999px;
}

.nav-link {
    padding: 5px 16px;
    border-radius: 999px;
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-2);
    transition: all 0.2s var(--ease);
    white-space: nowrap;
}

.nav-link:hover { color: var(--text); background: rgba(255, 255, 255, 0.7); }

.nav-link.active {
    color: var(--primary);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    font-weight: 600;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 100px;
    flex: 1;
    justify-content: flex-end;
}

/* 用户菜单 */
.user-menu { position: relative; cursor: pointer; }

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--brand-grad);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    transition: transform 0.2s var(--ease);
}

.user-menu:hover .user-avatar { transform: scale(1.05); }

.user-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    box-shadow: var(--shadow-lg);
    min-width: 136px;
    z-index: 10000;
    margin-top: 10px;
    padding: 6px;
}

.user-dropdown a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    color: var(--text-2);
    text-decoration: none;
    font-size: 13.5px;
    border-radius: var(--r-sm);
    transition: all 0.15s var(--ease);
}

.user-dropdown a:hover { background: var(--surface-2); color: var(--text); }

.user-dropdown.show { display: block; animation: dropdown-in 0.18s var(--ease); }

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

/* ---------- 布局 ---------- */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: calc(var(--nav-h) + 28px) 32px 48px;
}

.container-wide {
    max-width: 1560px;
    margin: 0 auto;
    padding: calc(var(--nav-h) + 28px) 32px 48px;
}

.page-header { margin-bottom: 22px; }

.page-title {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: var(--text);
}

.page-subtitle { font-size: 13.5px; color: var(--text-3); margin-top: 4px; }

/* ---------- 卡片 ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.card-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 16px;
    letter-spacing: -0.2px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-subtitle { font-size: 13px; color: var(--text-3); font-weight: 400; }

/* 统计卡片 */
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 16px 18px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.25s var(--ease), transform 0.25s var(--ease);
}

.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }

.stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.3px;
}

.stat-label { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }

/* ---------- 按钮 ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 15px;
    border-radius: var(--r-sm);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    line-height: 1.4;
    cursor: pointer;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text-2);
    text-decoration: none;
    transition: all 0.18s var(--ease);
    user-select: none;
    white-space: nowrap;
}

.btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.btn:active { transform: translateY(0.5px); }

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(59, 110, 246, 0.25);
}

.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; box-shadow: 0 4px 12px rgba(59, 110, 246, 0.32); }
.btn-primary:active { background: var(--primary-active); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }

.btn-outline-primary { background: var(--surface); border-color: var(--primary-border); color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-hover); }

.btn-danger { background: var(--surface); border-color: rgba(229, 72, 77, 0.35); color: var(--up); }
.btn-danger:hover { background: var(--up-soft); border-color: var(--up); color: var(--up); }

.btn-sm { padding: 4px 10px; font-size: 12.5px; border-radius: 7px; }
.btn-lg { padding: 10px 22px; font-size: 14px; border-radius: 10px; }

.chart-view-controls {
    display: grid;
    grid-template-columns: repeat(3, max-content);
    gap: 8px;
    justify-content: end;
}

.btn:disabled, .btn.disabled { opacity: 0.55; cursor: not-allowed; pointer-events: none; }

/* ---------- 表单控件 ---------- */
.input, .select, textarea.input {
    font-family: inherit;
    font-size: 13.5px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    padding: 7px 12px;
    outline: none;
    transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.input::placeholder { color: var(--text-3); }

.input:focus, .select:focus, textarea.input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2398a2b3' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 30px;
    cursor: pointer;
}

/* ---------- 表格 ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

.table th {
    text-align: left;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-3);
    padding: 10px 12px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}

.table tbody tr { transition: background 0.12s var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: none; }

.table .num, .table td.num, .table th.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ---------- 徽章 / 标签 ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    background: var(--surface-3);
    color: var(--text-2);
    white-space: nowrap;
}

.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-up { background: var(--up-soft); color: var(--up); }
.badge-down { background: var(--down-soft); color: var(--down); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }

/* ---------- 盈亏配色（A股：红涨绿跌） ---------- */
.text-up { color: var(--up); }
.text-down { color: var(--down); }
.text-warn { color: var(--warn); }
.muted { color: var(--text-3); }
.num, .mono { font-variant-numeric: tabular-nums; }

/* ---------- 分页 ---------- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.pagination .page-btn,
.pagination a,
.pagination button {
    min-width: 32px;
    height: 32px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-2);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s var(--ease);
}

.pagination .page-btn:hover,
.pagination a:hover,
.pagination button:hover { border-color: var(--primary-border); color: var(--primary); background: var(--primary-soft); }

.pagination .page-btn.active,
.pagination .active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    font-weight: 600;
    pointer-events: none;
}

.pagination .page-btn:disabled,
.pagination .disabled { opacity: 0.45; pointer-events: none; }

/* ---------- 弹窗 ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    animation: fade-in 0.18s var(--ease);
}

.modal {
    background: var(--surface);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    padding: 24px;
    max-width: 90vw;
    max-height: 86vh;
    overflow: auto;
    animation: modal-in 0.22s var(--ease);
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in {
    from { opacity: 0; transform: translateY(10px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- 页签 ---------- */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

.tabs .tab {
    padding: 9px 16px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-2);
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.15s var(--ease);
    text-decoration: none;
}

.tabs .tab:hover { color: var(--text); }

.tabs .tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ---------- 上传区 ---------- */
.upload-zone {
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--r-lg);
    padding: 44px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s var(--ease);
    background: var(--surface-2);
}

.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-soft);
}

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
    .apple-nav { padding: 0 14px; }
    .nav-link { padding: 5px 10px; font-size: 13px; }
    .nav-brand span { display: none; }
    .container, .container-wide { padding-left: 16px; padding-right: 16px; }

    .chart-view-controls {
        gap: 6px;
    }
}

/* ---------- 任务悬浮球 ---------- */
.task-float-root {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 10050;
    font-family: var(--font);
}

.task-float-ball {
    position: relative;
    width: 58px;
    height: 58px;
    border: 0;
    border-radius: 50%;
    background: var(--brand-grad);
    color: #fff;
    box-shadow: 0 10px 28px rgba(77, 88, 180, 0.34);
    cursor: pointer;
    font: inherit;
    font-size: 24px;
    transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease);
}

.task-float-ball:hover { transform: translateY(-2px) scale(1.03); box-shadow: 0 14px 34px rgba(77, 88, 180, 0.42); }
.task-float-ball:focus-visible { outline: 3px solid rgba(59, 110, 246, 0.35); outline-offset: 3px; }
.task-float-ball.is-active { animation: task-float-pulse 2.2s ease-in-out infinite; }

@keyframes task-float-pulse {
    0%, 100% { box-shadow: 0 10px 28px rgba(77, 88, 180, 0.34); }
    50% { box-shadow: 0 10px 30px rgba(59, 110, 246, 0.58), 0 0 0 7px rgba(59, 110, 246, 0.09); }
}

.task-float-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 21px;
    height: 21px;
    padding: 0 5px;
    border: 2px solid var(--surface);
    border-radius: 999px;
    background: var(--up);
    color: #fff;
    font-size: 11px;
    line-height: 17px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.task-float-panel {
    display: none;
    position: absolute;
    right: 0;
    bottom: 72px;
    width: 390px;
    max-width: calc(100vw - 24px);
    max-height: min(76vh, 680px);
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
}

.task-float-root.is-open .task-float-panel {
    display: flex;
    flex-direction: column;
    animation: task-panel-in 0.18s var(--ease);
}

@keyframes task-panel-in {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.task-float-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 15px 16px 12px;
    border-bottom: 1px solid var(--border);
}

.task-float-title { font-size: 16px; font-weight: 700; color: var(--text); }
.task-float-subtitle { margin-top: 2px; color: var(--text-3); font-size: 11px; }
.task-float-actions { display: flex; gap: 4px; }
.task-float-icon-btn { border: 0; background: transparent; color: var(--text-2); cursor: pointer; padding: 5px 7px; border-radius: 7px; font: inherit; }
.task-float-icon-btn:hover { background: var(--surface-3); color: var(--text); }

.task-float-body { overflow-y: auto; padding: 10px; }
.task-float-section-title { margin: 2px 4px 8px; color: var(--text-3); font-size: 11px; font-weight: 700; letter-spacing: 0.04em; }
.task-float-empty { padding: 24px 14px; text-align: center; color: var(--text-3); font-size: 13px; }

.task-float-item {
    padding: 11px 12px;
    margin-bottom: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r);
}

.task-float-item:last-child { margin-bottom: 0; }
.task-float-item-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.task-float-item-name { min-width: 0; color: var(--text); font-size: 13px; font-weight: 650; word-break: break-word; }
.task-float-status { flex: 0 0 auto; color: var(--primary); font-size: 11px; white-space: nowrap; }
.task-float-status.is-paused { color: var(--warn); }
.task-float-status.is-failed { color: var(--up); }
.task-float-status.is-success { color: var(--down); }
.task-float-detail { margin-top: 3px; color: var(--text-2); font-size: 11px; line-height: 1.45; word-break: break-word; }
.task-float-message { margin-top: 4px; color: var(--text-3); font-size: 11px; word-break: break-word; }
.task-float-progress { height: 7px; margin-top: 8px; overflow: hidden; background: var(--surface-3); border-radius: 999px; }
.task-float-progress > span { display: block; width: 0; height: 100%; background: var(--primary); border-radius: inherit; transition: width 0.25s ease; }
.task-float-progress > span.is-indeterminate { width: 42%; animation: task-progress-slide 1.2s ease-in-out infinite; }
@keyframes task-progress-slide { 0% { transform: translateX(-110%); } 100% { transform: translateX(250%); } }
.task-float-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; color: var(--text-3); font-size: 10px; }
.task-float-item-actions { display: flex; gap: 6px; margin-top: 8px; }
.task-float-action { padding: 3px 8px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface); color: var(--text-2); cursor: pointer; font: inherit; font-size: 11px; }
.task-float-action:hover { border-color: var(--primary-border); color: var(--primary); background: var(--primary-soft); }
.task-float-action.danger:hover { border-color: rgba(229, 72, 77, 0.35); color: var(--up); background: var(--up-soft); }
.task-float-action:disabled { opacity: 0.5; cursor: wait; }
.task-float-schedule { padding: 8px 10px; border-bottom: 1px solid var(--border); }
.task-float-schedule:last-child { border-bottom: 0; }
.task-float-schedule-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.task-float-schedule-name { min-width: 0; color: var(--text-2); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-float-schedule-time { margin-top: 2px; color: var(--text-3); font-size: 10px; }
.task-float-schedule-btn { flex: 0 0 auto; padding: 3px 7px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface); color: var(--text-2); cursor: pointer; font: inherit; font-size: 10px; }
.task-float-schedule-btn:hover { color: var(--primary); border-color: var(--primary-border); }
.task-float-footer { padding: 9px 12px; border-top: 1px solid var(--border); text-align: right; }
.task-float-footer a { font-size: 11px; }

@media (max-width: 600px) {
    .task-float-root { right: 12px; bottom: 14px; }
    .task-float-panel { right: -2px; bottom: 70px; width: calc(100vw - 24px); }
}
