*,
*::before,
*::after {
    box-sizing: border-box;
}

:root {
    --bg: #050b1f;
    --surface: #101830;
    --surface-alt: #121c38;
    --border: rgba(255, 255, 255, 0.08);
    --text: #e4e9ff;
    --text-muted: #a0a7c2;
    --accent: #4262ff;
    --accent-strong: #5d7bff;
    --danger: #ff5f6d;
    --success: #2dd4bf;
}

body {
    margin: 0;
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background: radial-gradient(circle at top left, #1a2250 0%, #050b1f 55%);
    color: var(--text);
    min-height: 100vh;
    padding: 32px;
}

body.drawer-active {
    overflow: hidden;
}

/* 即将扫描队列 */
.queue-board {
    margin-bottom: 24px;
}
.queue-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 12px 0;
    color: var(--text-muted);
}
.queue-count {
    color: var(--accent);
}
.queue-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.queue-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface-alt);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
}
.queue-name {
    font-weight: 500;
}
.queue-time {
    color: var(--text-muted);
}
.queue-sec {
    font-variant-numeric: tabular-nums;
    color: var(--accent-strong);
}
.queue-empty,
.loading-inline {
    color: var(--text-muted);
    font-size: 14px;
}

.tabs {
    display: inline-flex;
    gap: 8px;
    margin-top: 6px;
}
.tab-btn {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
}
.tab-btn.active {
    color: var(--text);
    border-color: var(--accent);
}

/* 日志列表 */
/* 日志列表样式 - 适配更大的弹窗 */
.logs-list {
    padding: 16px;
    max-height: calc(90vh - 120px);
    overflow-y: auto;
    font-size: 14px;
    line-height: 1.5;
}
.logs-filter {
    display: flex;
    gap: 8px;
    padding: 0 16px 8px 16px;
}
.chip {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 6px 10px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 12px;
}
.chip.active {
    color: #6ea8ff;
    border-color: #6ea8ff;
}
.drawer-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.logs-count {
    color: var(--text-muted);
    font-size: 12px;
}
/* 日志条目样式 - 适配更宽显示 */
.log-item {
    display: grid;
    grid-template-columns: 160px 80px 1fr;
    gap: 16px;
    align-items: start;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    line-height: 1.6;
}

.log-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.log-details {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 12px;
    margin-top: 4px;
}

.log-details span {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--text-muted);
}

.log-details .detail-price {
    background: rgba(82, 124, 255, 0.2);
    color: #6ea8ff;
}

.log-details .detail-min {
    background: rgba(34, 197, 94, 0.2);
    color: #4ade80;
}

.log-details .detail-max {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

.log-details .detail-alert-type {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
}

.log-details .detail-status {
    background: rgba(34, 197, 94, 0.2);
    color: #4ade80;
}

.log-details .detail-error {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
}
.log-time {
    color: var(--text-muted);
}
.log-level {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 12px;
    padding: 2px 6px;
    border-radius: 4px;
    text-align: center;
}
.log-info  { background: rgba(66, 98, 255, 0.15); color: #6ea8ff; }
.log-warn  { background: rgba(255, 193, 7, 0.15); color: #ffc107; }
.log-error { background: rgba(255, 95, 109, 0.15); color: var(--danger); }
.log-msg   { color: var(--text); word-break: break-word; }

.app-body {
    min-height: 100vh;
}

.app-shell {
    max-width: 1400px;
    margin: 0 auto;
}

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

.brand {
    display: flex;
    align-items: center;
    gap: 16px;
}

.brand-icon {
    width: 48px;
    height: 48px;
    background: rgba(66, 98, 255, 0.18);
    border-radius: 12px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    padding: 8px;
}

.brand-icon span {
    display: block;
    background: var(--accent);
    border-radius: 6px;
}

.brand-label {
    font-size: 1.5rem;
    margin: 0;
    font-weight: 600;
}

.brand-subtitle {
    margin: 2px 0 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.header-actions {
    display: flex;
    gap: 12px;
}

.btn {
    border: none;
    border-radius: 12px;
    padding: 12px 20px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff;
    box-shadow: 0 8px 20px rgba(79, 70, 229, 0.35);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-primary:hover,
.btn-outline:hover {
    transform: translateY(-1px);
}

.btn-icon {
    margin-right: 8px;
    font-size: 1.2rem;
}

.app-main {
    background: rgba(255, 255, 255, 0.01);
    border-radius: 24px;
    padding: 32px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.monitor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 24px;
}

.loading-card,
.empty-state-card {
    grid-column: 1 / -1;
    background: var(--surface);
    border-radius: 18px;
    padding: 60px;
    text-align: center;
    color: var(--text-muted);
    border: 1px dashed var(--border);
}

.monitor-card {
    background: var(--surface);
    border-radius: 24px;
    padding: 24px;
    border: 1px solid var(--border);
    box-shadow: 0 10px 40px rgba(2, 8, 34, 0.45);
    display: flex;
    flex-direction: column;
    gap: 18px;
    transition: border-color 0.2s, transform 0.2s;
}

.monitor-card--alert {
    border-color: rgba(255, 95, 109, 0.8);
    box-shadow: 0 15px 45px rgba(255, 95, 109, 0.25);
}

.monitor-card--silenced .card-title-row::after {
    content: '';
}

.card-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.card-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-title {
    margin: 0;
    font-size: 1.2rem;
}

.chip {
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    letter-spacing: 0.04em;
}

.chip-muted {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.card-url {
    display: inline-block;
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-decoration: none;
}

.card-url:hover {
    color: var(--accent-strong);
}

.card-toolbar {
    display: flex;
    gap: 8px;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
}

.icon-btn.success {
    color: var(--success);
}

.icon-btn.danger {
    color: var(--danger);
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: translateY(-1px);
}

.card-value-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-end;
}

.card-value {
    margin: 0;
    font-size: 2.6rem;
    font-weight: 600;
}

.card-value-label {
    margin: 4px 0 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.card-meta-lines {
    text-align: right;
    color: var(--text-muted);
    font-size: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.card-meta-lines strong {
    color: var(--text);
}

.card-history {
    background: var(--surface-alt);
    border-radius: 18px;
    padding: 16px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.sparkline {
    width: 100%;
    height: 80px;
}

.sparkline svg {
    width: 100%;
    height: 80px;
}

.history-placeholder {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.drawer {
    position: fixed;
    inset: 0;
    background: rgba(5, 8, 20, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: flex-end;
    align-items: stretch;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 20;
}

.drawer-left {
    justify-content: flex-start;
}

.drawer-open {
    opacity: 1;
    pointer-events: auto;
}

.drawer-panel {
    width: min(420px, 90vw);
    background: #0d1329;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    padding: 32px;
    overflow-y: auto;
}

.drawer-left .drawer-panel {
    border-left: none;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 24px;
}

.drawer-title {
    margin: 0 0 6px;
    font-size: 1.3rem;
}

.drawer-subtitle {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.drawer-subtitle code {
    background: rgba(255, 255, 255, 0.08);
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 0.8rem;
    color: var(--text);
}

.monitor-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
    font-size: 1rem;
}

.form-group input:focus {
    outline: 2px solid rgba(82, 124, 255, 0.5);
    border-color: transparent;
}

.form-group.dual {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.drawer-actions {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 8px;
}

.submit-btn {
    flex: 1;
}

.icon-btn,
.btn,
.monitor-form input {
    font-family: inherit;
}

.alert {
    position: fixed;
    top: 24px;
    right: 24px;
    padding: 16px 24px;
    border-radius: 16px;
    background: rgba(20, 26, 56, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 16px;
    z-index: 30;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
}

.alert-success {
    border-color: rgba(45, 212, 191, 0.5);
}

.alert-error {
    border-color: rgba(255, 95, 109, 0.5);
}

.alert-info {
    border-color: rgba(93, 123, 255, 0.5);
}

.alert-close {
    border: none;
    background: transparent;
    color: inherit;
    font-size: 1.2rem;
    cursor: pointer;
}

@media (max-width: 960px) {
    body {
        padding: 16px;
    }

    .app-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .card-value-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .card-meta-lines {
        text-align: left;
    }
}

@media (max-width: 600px) {
    .form-group.dual {
        grid-template-columns: 1fr;
    }

    .drawer-panel {
        width: 100%;
    }
}
/* 确保日志抽屉居中显示 - 高优先级选择器 */
.drawer.drawer-center,
#logsDrawer.drawer-center,
.drawer#logsDrawer,
#logsDrawer {
    justify-content: center !important;
    align-items: center !important;
}
/* 日志抽屉面板样式 - 更宽的显示 */
.drawer-center .drawer-panel,
#logsDrawer .drawer-panel,
.drawer#logsDrawer .drawer-panel {
    width: min(1400px, 95vw);
    height: 90vh;
    max-width: 1400px;
    min-width: 800px;
    border-left: none;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 20px 60px rgba(0,0,0,0.45);
}
