/* Azure 成本对账平台 — 清爽浅色主题 */
:root {
  --bg: #f4f6f9; --panel: #fff; --border: #e3e8ef; --text: #1a2332; --muted: #64748b;
  --primary: #0f6cbd; --primary-dark: #0a5299; --ok: #16a34a; --warn: #d97706; --err: #dc2626;
  --radius: 10px; --shadow: 0 1px 3px rgba(16,24,40,.07), 0 1px 2px rgba(16,24,40,.05);
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.6 "Segoe UI", "Microsoft YaHei", system-ui, sans-serif; background: var(--bg); color: var(--text); }
#app { display: flex; min-height: 100vh; }

/* ===== 侧栏 ===== */
#sidebar { width: 216px; flex: none; background: #10243e; color: #cbd5e1; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
#sidebar.hidden { display: none; }
.brand { padding: 18px 16px; font-size: 16px; font-weight: 600; color: #fff; border-bottom: 1px solid rgba(255,255,255,.08); }
#nav { flex: 1; padding: 10px 8px; overflow-y: auto; }
#nav a { display: block; padding: 9px 12px; margin: 2px 0; color: #cbd5e1; text-decoration: none; border-radius: 8px; }
#nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
#nav a.active { background: var(--primary); color: #fff; }
.sidebar-foot { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; }
.sidebar-foot a { color: #94a3b8; text-decoration: none; }
.sidebar-foot a:hover { color: #fff; }
#whoami { margin-bottom: 6px; color: #e2e8f0; }
#whoami .role-tag { font-size: 11px; background: rgba(255,255,255,.15); padding: 1px 7px; border-radius: 99px; margin-left: 6px; }

/* ===== 主区 ===== */
#main { flex: 1; padding: 22px 26px; max-width: 1720px; }
h1 { font-size: 20px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 0 0 10px; }
.page-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.page-head h1 { margin: 0; }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 16px; }
.grid { display: grid; gap: 14px; }
.grid.cols-3 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }

/* ===== 控件 ===== */
button, .btn { font: inherit; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--border); background: #fff; color: var(--text); cursor: pointer; text-decoration: none; display: inline-block; }
button:hover, .btn:hover { border-color: var(--primary); color: var(--primary); }
button.primary, .btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.primary:hover { background: var(--primary-dark); }
button.danger { color: var(--err); border-color: #fecaca; }
button.danger:hover { background: #fef2f2; border-color: var(--err); }
button:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea { font: inherit; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(15,108,189,.25); border-color: var(--primary); }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
label.field input, label.field select { width: 100%; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar label { font-size: 13px; color: var(--muted); }

/* ===== 表格 ===== */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 500; white-space: nowrap; background: #fafbfc; }
tr:hover td { background: #f8fafc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty-tip { color: var(--muted); text-align: center; padding: 28px 0; }

/* ===== 徽标/状态 ===== */
.tag { display: inline-block; font-size: 12px; padding: 1px 9px; border-radius: 99px; border: 1px solid transparent; }
.tag.ok { background: #f0fdf4; color: var(--ok); border-color: #bbf7d0; }
.tag.warn { background: #fffbeb; color: var(--warn); border-color: #fde68a; }
.tag.err { background: #fef2f2; color: var(--err); border-color: #fecaca; }
.tag.info { background: #eff6ff; color: var(--primary); border-color: #bfdbfe; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.err { background: var(--err); } .dot.off { background: #94a3b8; }

/* ===== 横幅 ===== */
.banner { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; font-size: 13.5px; }
.banner.warn { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.banner.err { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.banner.info { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }

/* ===== 汇总卡 ===== */
.stat { padding: 14px 16px; }
.stat .label { font-size: 12.5px; color: var(--muted); }
.stat .value { font-size: 22px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ===== 图表 ===== */
.chart-box { overflow-x: auto; }
.bar-row { display: flex; align-items: center; gap: 10px; margin: 7px 0; }
.bar-label { width: 220px; flex: none; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { flex: 1; background: #eef2f7; height: 20px; border-radius: 5px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, #3b82f6, #0f6cbd); border-radius: 5px; }
.bar-val { width: 170px; flex: none; font-size: 12.5px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

/* ===== 登录页 ===== */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; width: 100%; }
.login-card { width: 360px; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: 30px; }
.login-card h1 { text-align: center; font-size: 20px; }
.login-card button { width: 100%; margin-top: 6px; }

/* ===== toast/modal ===== */
#toast-wrap { position: fixed; top: 18px; right: 18px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #1e293b; color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow); font-size: 13.5px; max-width: 380px; white-space: pre-wrap; }
.toast.err { background: #b91c1c; } .toast.ok { background: #15803d; }
#modal-wrap { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; }
#modal-wrap.hidden { display: none; }
.modal { background: #fff; border-radius: 12px; padding: 22px 24px; width: 560px; max-width: 96vw; max-height: 88vh; overflow-y: auto; }
.modal h2 { margin-top: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.modal pre { background: #0f172a; color: #e2e8f0; padding: 12px; border-radius: 8px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; }

/* ===== 向导 ===== */
.wizard-steps { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.wizard-step { flex: 1; min-width: 110px; text-align: center; padding: 8px 4px; background: #eef2f7; border-radius: 8px; font-size: 12.5px; color: var(--muted); }
.wizard-step.active { background: var(--primary); color: #fff; }
.wizard-step.done { background: #dcfce7; color: var(--ok); }
.devicecode-box { text-align: center; padding: 16px; }
.devicecode-box .code { font-size: 30px; font-weight: 700; letter-spacing: 5px; color: var(--primary); margin: 8px 0; user-select: all; }
.sub-check { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; cursor: pointer; }
.sub-check:hover { border-color: var(--primary); }
.sub-check input { width: auto; }

.mono { font-family: Consolas, monospace; font-size: 12.5px; }
.muted { color: var(--muted); }
.mt0 { margin-top: 0; } .mb0 { margin-bottom: 0; }
a.plain { color: var(--primary); }
@media (max-width: 760px) { #sidebar { display: none; } #main { padding: 14px; } }

/* ===== 对账单（Power BI 风格三栏） ===== */
.bill-layout { display: flex; gap: 14px; align-items: flex-start; }
.bill-nav { width: 200px; flex-shrink: 0; padding: 14px; position: sticky; top: 10px; max-height: calc(100vh - 40px); overflow-y: auto; }
.bill-nav h2, .bill-filters h2 { font-size: 14px; margin: 0 0 10px; }
.bill-nav-list { display: flex; flex-direction: column; gap: 2px; }
.bill-nav-item { display: block; padding: 7px 10px; border-radius: 7px; color: #334155; text-decoration: none; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bill-nav-item:hover { background: #f1f5f9; }
.bill-nav-item.active { background: var(--primary); color: #fff; font-weight: 600; }
.bill-filters { width: 220px; flex-shrink: 0; padding: 14px; position: sticky; top: 10px; max-height: calc(100vh - 40px); overflow-y: auto; }
.bill-filter-svcs { display: flex; flex-direction: column; gap: 4px; max-height: 320px; overflow-y: auto; margin-top: 6px; }
.bill-filter-svc { display: flex; align-items: center; gap: 6px; font-size: 12.5px; cursor: pointer; }
.bill-filter-svc input { width: auto; margin: 0; }
.bill-filter-svc span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bill-main { flex: 1; min-width: 0; padding: 26px 32px; }
.bill-title { display: flex; align-items: center; gap: 12px; border-bottom: 2px solid #0f172a; padding-bottom: 12px; margin-bottom: 18px; }
.bill-title h1 { margin: 0; font-size: 21px; }
.bill-badge { background: #10243e; color: #fff; font-size: 13px; padding: 4px 12px; border-radius: 4px; font-weight: 600; }
.bill-h2 { color: #2563eb; font-size: 16px; margin: 0 0 10px; }
.bill-section { margin-bottom: 26px; }
.bill-summary { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }
.bill-kvs { flex: 1; min-width: 260px; }
.bill-kv { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed #e2e8f0; font-size: 14px; }
.bill-kv-label { color: var(--muted); }
.bill-kv-val { font-weight: 600; }
.bill-kv-val.bill-settle { color: #dc2626; font-size: 16px; }
.bill-donut { flex-shrink: 0; }
.donut-wrap { display: flex; gap: 14px; align-items: center; }
.donut-legend { display: flex; flex-direction: column; gap: 4px; max-width: 200px; }
.donut-legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.donut-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.donut-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 130px; }
.bill-chart-title { text-align: center; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.bill-table { width: 100%; }
.bill-table th { background: #10243e; color: #fff; font-weight: 600; }
.bill-table tfoot td { background: #f1f5f9; }
@media (max-width: 1100px) { .bill-filters { display: none; } }

/* 打印 = 导出 PDF：只保留账单主体 */
@media print {
  #sidebar, .no-print, #toast-wrap, #modal-wrap { display: none !important; }
  #main { max-width: none; padding: 0; }
  .bill-layout { display: block; }
  .bill-main { box-shadow: none; border: none; padding: 0; }
  body { background: #fff; }
  .bill-section { break-inside: avoid; }
}
