/*
 * /settings/billing/usage · Phase 2 W2-front 计费控制台样式
 * 2026-05-06 落地（W2-front by hu-mei-ren）
 *
 * 设计原则：
 *   - 优先复用 settings.css 的 .s-btn / .s-section / .settings-page-header
 *   - 仅本页定制元素以 .bu- 前缀避免污染全局
 *   - 弹层 z-index 1000+；toast 1001 高于弹层
 *   - 颜色与 firewall 页对齐（暗系深蓝 + 状态色）
 */

.bu-global-msg {
    margin: 8px 0 0;
    padding: 6px 12px;
    font-size: 12px;
    color: #94a3b8;
    min-height: 1.6em;
}
.bu-global-msg.bu-msg-ok    { color: #22c55e; }
.bu-global-msg.bu-msg-warn  { color: #f59e0b; }
.bu-global-msg.bu-msg-error { color: #ef4444; }

/* ── Hero 健康卡片 ───────────────────────────────────── */
.bu-hero {
    margin-top: 12px;
    border: 1px solid rgba(56, 189, 248, 0.22);
    border-radius: 10px;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.75), rgba(15, 23, 42, 0.5));
    padding: 18px;
}
.bu-hero-title {
    font-size: 16px;
    font-weight: 600;
    color: #e2e8f0;
}
.bu-hero-desc {
    margin: 6px 0 14px;
    font-size: 12px;
    color: #94a3b8;
}
.bu-flag-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
}
.bu-flag-card {
    background: rgba(2, 6, 23, 0.55);
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 8px;
    padding: 12px;
}
.bu-flag-label {
    font-size: 11px;
    color: #94a3b8;
    margin-bottom: 4px;
}
.bu-flag-value {
    font-size: 18px;
    font-weight: 600;
    color: #e2e8f0;
    margin-bottom: 4px;
    letter-spacing: 0.02em;
}
.bu-flag-value-time {
    font-size: 11px;
    font-family: ui-monospace, "Cascadia Mono", "Consolas", monospace;
    color: #cbd5e1;
}
.bu-flag-value.bu-flag-on  { color: #22c55e; }
.bu-flag-value.bu-flag-off { color: #f59e0b; }
.bu-flag-desc {
    font-size: 11px;
    color: #64748b;
    font-family: ui-monospace, "Cascadia Mono", "Consolas", monospace;
}

/* ── Tab 导航 ────────────────────────────────────────── */
.bu-tabs {
    display: flex;
    gap: 4px;
    margin-top: 16px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
    overflow-x: auto;
}
.bu-tab {
    background: transparent;
    border: 0;
    color: #94a3b8;
    padding: 10px 16px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
}
.bu-tab:hover { color: #cbd5e1; }
.bu-tab.active {
    color: #38bdf8;
    border-bottom-color: #38bdf8;
}

/* ── Tenant 切换栏 ───────────────────────────────────── */
.bu-tenant-bar {
    margin: 12px 0 4px;
    padding: 10px 12px;
    border: 1px dashed rgba(148, 163, 184, 0.3);
    border-radius: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.bu-tenant-label {
    font-size: 12px;
    color: #cbd5e1;
}
.bu-tenant-input {
    flex: 1 1 220px;
    min-width: 180px;
    padding: 6px 10px;
    border-radius: 6px;
    background: rgba(2, 6, 23, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.3);
    color: #e2e8f0;
    font-family: ui-monospace, "Cascadia Mono", "Consolas", monospace;
    font-size: 12px;
}
.bu-tenant-hint {
    flex-basis: 100%;
    font-size: 11px;
    color: #64748b;
}

/* ── Panel ────────────────────────────────────────────── */
.bu-panel { display: none; padding-top: 12px; }
.bu-panel.active { display: block; }

.bu-empty {
    padding: 18px;
    color: #64748b;
    font-size: 12px;
    text-align: center;
    font-style: italic;
}
.bu-error {
    padding: 12px;
    color: #ef4444;
    font-size: 12px;
    background: rgba(239, 68, 68, 0.08);
    border-radius: 6px;
}

/* ── 通用列表/表格 ───────────────────────────────────── */
.bu-list { list-style: none; padding: 0; margin: 0; }
.bu-list-item {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
    font-size: 12px;
    color: #cbd5e1;
}
.bu-list-item:last-child { border-bottom: 0; }
.bu-list-item-key {
    color: #94a3b8;
    font-family: ui-monospace, "Cascadia Mono", "Consolas", monospace;
    margin-right: 8px;
}

.bu-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.bu-table th, .bu-table td {
    padding: 6px 10px;
    text-align: left;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
    color: #cbd5e1;
}
.bu-table th {
    color: #94a3b8;
    font-weight: 500;
    background: rgba(2, 6, 23, 0.4);
    position: sticky;
    top: 0;
    z-index: 1;
}
.bu-table tr:hover td { background: rgba(56, 189, 248, 0.04); }

/* ── 状态徽章 ────────────────────────────────────────── */
.bu-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
    border: 1px solid currentColor;
}
.bu-status-draft     { color: #94a3b8; }
.bu-status-proposed  { color: #38bdf8; }
.bu-status-approved  { color: #22c55e; }
.bu-status-applied   { color: #a78bfa; }
.bu-status-rejected  { color: #f59e0b; }
.bu-status-cancelled { color: #64748b; }

/* ── 用量工具栏 ─────────────────────────────────────── */
.bu-usage-toolbar,
.bu-approval-toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px 0;
    align-items: end;
}
.bu-usage-toolbar label {
    display: flex;
    flex-direction: column;
    font-size: 11px;
    color: #94a3b8;
    gap: 4px;
}
.bu-usage-toolbar input,
.bu-approval-toolbar input {
    padding: 4px 8px;
    border-radius: 6px;
    background: rgba(2, 6, 23, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.3);
    color: #e2e8f0;
    font-family: ui-monospace, "Cascadia Mono", "Consolas", monospace;
    font-size: 12px;
}

/* ── Section toolbar ────────────────────────────────── */
.s-section-toolbar {
    margin-top: 10px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.s-section-toolbar [data-wip] { opacity: 0.65; }

.bu-badge-wip {
    display: inline-block;
    margin-left: 6px;
    padding: 0 6px;
    border-radius: 999px;
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.4);
    color: #f59e0b;
    font-size: 10px;
    font-weight: 500;
}

/* ── 流程图代码块 ───────────────────────────────────── */
.bu-flow-pre {
    margin: 0;
    padding: 12px;
    background: rgba(2, 6, 23, 0.55);
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 6px;
    color: #cbd5e1;
    font-family: ui-monospace, "Cascadia Mono", "Consolas", monospace;
    font-size: 11px;
    line-height: 1.6;
    overflow-x: auto;
}

/* ── HMAC confirm 浮层 ─────────────────────────────── */
.bu-modal-mask {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.75);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
}
.bu-modal-mask:not([hidden]) {
    display: flex;
}
.bu-modal {
    background: #0f172a;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 10px;
    width: min(440px, 92vw);
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}
.bu-modal-head {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.bu-modal-head h2 {
    margin: 0;
    font-size: 14px;
    color: #e2e8f0;
}
.bu-modal-close {
    background: transparent;
    border: 0;
    color: #94a3b8;
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
}
.bu-modal-body {
    padding: 14px 16px;
    overflow-y: auto;
}
.bu-modal-body p {
    margin: 0 0 12px;
    font-size: 12px;
    color: #cbd5e1;
}
.bu-confirm-meta {
    margin: 0 0 12px;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 12px;
    font-size: 12px;
}
.bu-confirm-meta dt { color: #94a3b8; }
.bu-confirm-meta dd { margin: 0; color: #e2e8f0; font-family: ui-monospace, "Cascadia Mono", "Consolas", monospace; }
.bu-confirm-reason {
    width: 100%;
    box-sizing: border-box;
    padding: 6px 8px;
    border-radius: 6px;
    background: rgba(2, 6, 23, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.3);
    color: #e2e8f0;
    font-size: 12px;
    resize: vertical;
}
.bu-modal-foot {
    padding: 10px 16px;
    border-top: 1px solid rgba(148, 163, 184, 0.18);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ── HTTP 402 余额引导 toast ─────────────────────── */
.bu-topup-toast {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1001;
    max-width: min(480px, 92vw);
    padding: 12px 16px;
    background: rgba(127, 29, 29, 0.92);
    border: 1px solid rgba(239, 68, 68, 0.6);
    border-radius: 10px;
    color: #fee2e2;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    display: flex;
    gap: 12px;
    align-items: flex-start;
}
.bu-topup-toast-body { flex: 1; }
/* ── 充值表单 ──────────────────────────────────────── */
.bu-topup-bar { align-items: end; }
.bu-topup-label {
    display: flex;
    flex-direction: column;
    font-size: 11px;
    color: #94a3b8;
    gap: 4px;
}
.bu-topup-label input {
    padding: 5px 8px;
    border-radius: 6px;
    background: rgba(2, 6, 23, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.3);
    color: #e2e8f0;
    font-family: ui-monospace, "Cascadia Mono", "Consolas", monospace;
    font-size: 12px;
}

.bu-topup-toast-title { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.bu-topup-toast-desc { font-size: 12px; color: #fecaca; line-height: 1.5; }

/* ── Soft block status bar ───────────────────────────── */
.bu-softblock-bar {
    margin-top: 12px;
    padding: 10px 14px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 8px;
    background: rgba(2, 6, 23, 0.45);
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}
.bu-sb-indicator {
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.bu-sb-indicator.bu-sb-critical { background: rgba(239, 68, 68, 0.2); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.5); }
.bu-sb-indicator.bu-sb-high     { background: rgba(245, 158, 11, 0.2); color: #fcd34d; border: 1px solid rgba(245, 158, 11, 0.5); }
.bu-sb-indicator.bu-sb-medium   { background: rgba(56, 189, 248, 0.15); color: #7dd3fc; border: 1px solid rgba(56, 189, 248, 0.4); }
.bu-sb-indicator.bu-sb-low      { background: rgba(100, 116, 139, 0.15); color: #94a3b8; border: 1px solid rgba(100, 116, 139, 0.3); }
.bu-sb-detail {
    font-size: 11px;
    color: #94a3b8;
    font-family: ui-monospace, "Cascadia Mono", "Consolas", monospace;
}

/* ── Usage trend chart ───────────────────────────────── */
.bu-usage-chart {
    padding: 12px 0;
    overflow-x: auto;
}

/* ── Budget row action buttons ──────────────────────── */
.bu-action-btn {
    padding: 2px 8px;
    font-size: 11px;
    border-radius: 4px;
    cursor: pointer;
    border: 1px solid rgba(148, 163, 184, 0.3);
    background: rgba(2, 6, 23, 0.4);
    color: #cbd5e1;
    transition: background 0.15s, color 0.15s;
}
.bu-action-btn:hover { background: rgba(56, 189, 248, 0.15); color: #38bdf8; }
.bu-action-danger { border-color: rgba(239, 68, 68, 0.4); color: #fca5a5; }
.bu-action-danger:hover { background: rgba(239, 68, 68, 0.15); color: #ef4444; }

/* ── 首页 Dashboard 卡片 ───────────────────────────────────── */
.bu-dashboard-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 4px 0;
}
.bu-dash-card {
    flex: 1 1 130px;
    min-width: 120px;
    padding: 14px 16px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.5);
}
.bu-dash-label {
    font-size: 11px;
    color: #94a3b8;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.bu-dash-value {
    font-size: 18px;
    font-weight: 600;
    color: #e2e8f0;
}
.bu-dash-warn .bu-dash-value { color: #fbbf24; }
.bu-dash-danger .bu-dash-value { color: #f87171; }

.bu-dashboard-tenants {
    overflow-x: auto;
}
.bu-dashboard-tenants .bu-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.bu-dashboard-tenants .bu-table th {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
    color: #94a3b8;
    font-weight: 500;
}
.bu-dashboard-tenants .bu-table td {
    padding: 8px 10px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
    color: #cbd5e1;
}
.bu-dashboard-tenants .bu-table tr:hover td {
    background: rgba(56, 189, 248, 0.05);
}

/* ── W5 管理升级 ─────────────────────────────────────── */
.bu-tenant-select {
    padding: 5px 8px;
    border-radius: 6px;
    background: rgba(2, 6, 23, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.3);
    color: #e2e8f0;
    font-size: 12px;
    min-width: 200px;
    cursor: pointer;
}
.bu-tenant-select:focus {
    outline: none;
    border-color: rgba(56, 189, 248, 0.5);
}
.bu-w5-btn {
    margin-right: 4px;
    font-size: 11px;
}
.bu-w5-actions .s-btn {
    font-size: 12px;
    padding: 4px 12px;
}
