/* DBAIOps 樣式 — 依截圖還原設計語彙 */
:root {
  --sidebar: #0b3b2c; --sidebar-2: #0e4634; --accent: #16a34a; --accent-d: #128a3f;
  --bg: #f2f4f6; --card: #fff; --line: #e7ebee; --text: #1f2937; --muted: #6b7280;
  --red: #dc2626; --orange: #ea580c; --yellow: #d97706; --green: #16a34a; --blue: #2563eb;
  --radius: 12px; --shadow: 0 1px 3px rgba(16, 40, 32, .06);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font: 14px/1.55 -apple-system, "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif; color: var(--text); background: var(--bg); }
button { font: inherit; cursor: pointer; }
input, select { font: inherit; }
a { color: var(--blue); text-decoration: none; cursor: pointer; }

.layout { display: flex; min-height: 100vh; }

/* ===== 側邊欄 ===== */
.sidebar { width: 208px; background: var(--sidebar); color: #d9e5df; display: flex; flex-direction: column; flex-shrink: 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px 14px; }
.brand .logo { width: 34px; height: 34px; border-radius: 8px; background: linear-gradient(135deg, #22c55e, #0ea56c); display: flex; align-items: center; justify-content: center; font-size: 18px; }
.brand h1 { font-size: 17px; color: #fff; letter-spacing: .5px; }
.brand p { font-size: 10.5px; color: #9fbcb0; }
.nav-sec { font-size: 11px; color: #7da695; padding: 14px 18px 4px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9.5px 16px; color: #cfe0d8; cursor: pointer; font-size: 13.5px; border-left: 3px solid transparent; }
.nav-item:hover { background: var(--sidebar-2); color: #fff; }
.nav-item.active { background: var(--accent); color: #fff; border-radius: 8px; margin: 0 8px; padding-left: 13px; border-left: none; }
.nav-item .ico { width: 18px; text-align: center; opacity: .9; }
.sidebar .me { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-top: 1px solid #1c5340; }
.sidebar .me .av { width: 32px; height: 32px; border-radius: 50%; background: #157a4b; display: flex; align-items: center; justify-content: center; color: #fff; }
.sidebar .me small { color: #9fbcb0; display: block; font-size: 11px; }

/* ===== 頂欄 ===== */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; background: #fff; border-bottom: 1px solid var(--line); padding: 10px 20px; position: sticky; top: 0; z-index: 20; }
.topbar select, .topbar .datebox { border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: #fff; color: var(--text); }
.searchbox { flex: 1; max-width: 480px; display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; color: var(--muted); background: #fafbfc; }
.searchbox input { border: none; outline: none; flex: 1; background: transparent; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.alarm { position: relative; cursor: pointer; }
.alarm .n { color: var(--red); font-weight: 600; }
.userbox { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.userbox .av { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; }

/* ===== 內容 ===== */
.content { padding: 18px 20px 40px; }
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h2 { font-size: 22px; }
.page-head .sub { color: var(--muted); font-size: 13px; }
.page-head .upd { color: var(--muted); font-size: 12.5px; margin-left: auto; }
.btn { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 8px 14px; }
.btn:hover { border-color: #c9d2d9; }
.btn.primary { background: #123f2e; color: #fff; border-color: #123f2e; font-weight: 600; }
.btn.primary:hover { background: #0d3123; }
.btn.green { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.sm { padding: 4px 10px; font-size: 12.5px; border-radius: 6px; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); padding: 16px 18px; }
.card h3 { font-size: 15px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.card h3 .hint { font-weight: 400; font-size: 12px; color: var(--muted); }
.grid { display: grid; gap: 14px; }

/* 風險總覽 */
.risk-strip { display: flex; align-items: stretch; }
.risk-items { display: flex; flex: 1; }
.risk-item { flex: 1; display: flex; gap: 12px; align-items: center; padding: 6px 10px; }
.risk-item .ic { width: 42px; height: 42px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 20px; }
.risk-item .v { font-size: 30px; font-weight: 700; line-height: 1.1; }
.risk-item .lb { font-size: 13px; color: var(--muted); }
.risk-item .d { font-size: 11.5px; color: var(--muted); }
.risk-item .d b { font-weight: 600; }
.asset-brief { border-left: 1px solid var(--line); padding-left: 18px; min-width: 240px; }
.asset-brief h4 { font-size: 13.5px; margin-bottom: 8px; }
.asset-brief .row { display: flex; justify-content: space-between; font-size: 13px; padding: 3px 0; }
.asset-brief .row b { font-size: 15px; }

/* 中段三卡 */
.mid-grid { grid-template-columns: 1fr 1.35fr 1fr; }
.legend { font-size: 12.5px; }
.legend .lg-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.lg-dot { width: 9px; height: 9px; border-radius: 50%; }
.trend-stats { display: flex; gap: 22px; margin-bottom: 6px; }
.trend-stats .ts .v { font-size: 22px; font-weight: 700; }
.trend-stats .ts .lb { font-size: 12px; color: var(--muted); }
.insp-row { display: flex; align-items: center; justify-content: space-between; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin-bottom: 10px; }
.insp-row .st { display: flex; gap: 10px; align-items: center; font-weight: 600; }
.insp-foot { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; padding-top: 8px; border-top: 1px dashed var(--line); }
.insp-foot b.warn { color: var(--red); }

/* 表格 */
.tbl-tools { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; align-items: center; }
.tbl-tools select, .tbl-tools input { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; background: #fff; }
.tbl-tools input { min-width: 180px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; color: var(--muted); font-weight: 500; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fafbfc; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid #f0f3f5; vertical-align: middle; }
.tbl tr:hover td { background: #f8faf9; }
.sev { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.sev .dot { width: 8px; height: 8px; border-radius: 50%; }
.tag { display: inline-block; border-radius: 6px; padding: 2px 8px; font-size: 12px; }
.tag.red { background: #fee2e2; color: var(--red); }
.tag.orange { background: #ffedd5; color: var(--orange); }
.tag.yellow { background: #fef9c3; color: #a16207; }
.tag.green { background: #dcfce7; color: #15803d; }
.tag.gray { background: #f1f5f9; color: #475569; }
.tag.blue { background: #dbeafe; color: #1d4ed8; }
.pager { display: flex; align-items: center; gap: 8px; justify-content: flex-end; padding-top: 12px; font-size: 13px; color: var(--muted); }
.pager button { border: 1px solid var(--line); background: #fff; border-radius: 6px; min-width: 28px; padding: 3px 8px; }
.pager button.cur { background: var(--accent); color: #fff; border-color: var(--accent); }
.pager button:disabled { opacity: .4; cursor: default; }

/* AI 結論卡 */
.ai-badge { margin-left: auto; }
.ai-item { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; display: flex; justify-content: space-between; gap: 10px; align-items: center; cursor: pointer; }
.ai-item:hover { border-color: #c9d2d9; }
.ai-item .t { font-weight: 600; font-size: 13px; }
.ai-item .d { color: var(--muted); font-size: 12px; }
.ai-sec { font-size: 13px; font-weight: 700; margin: 10px 0 6px; }
.ai-sec.hi { color: var(--red); } .ai-sec.mi { color: var(--yellow); }
.ai-advice { background: #f8faf9; border-radius: 10px; padding: 10px 14px; font-size: 12.8px; }
.ai-advice li { margin-left: 18px; padding: 2px 0; }
.ai-foot { display: flex; gap: 10px; margin-top: 12px; }
.ai-foot .btn { flex: 1; text-align: center; }

/* 健康條 / 進度條 */
.bar { height: 6px; border-radius: 4px; background: #eef1f4; overflow: hidden; min-width: 70px; }
.bar i { display: block; height: 100%; border-radius: 4px; }

/* 實例卡 / 鑽取 */
.inst-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.inst-card { cursor: pointer; transition: box-shadow .15s; }
.inst-card:hover { box-shadow: 0 4px 14px rgba(16, 40, 32, .12); }
.inst-card .hd { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.inst-card .hd b { font-size: 14.5px; }
.inst-card .meta { color: var(--muted); font-size: 12.3px; }
.inst-kpis { display: flex; gap: 14px; margin-top: 10px; }
.inst-kpis .k .v { font-weight: 700; }
.inst-kpis .k .l { font-size: 11px; color: var(--muted); }
.drill-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.drill-head h2 { font-size: 20px; }
.metric-grid { grid-template-columns: repeat(2, 1fr); }
.metric-card canvas { width: 100%; height: 170px; }
.kpi-strip { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 16px; min-width: 130px; }
.kpi .v { font-size: 20px; font-weight: 700; }
.kpi .l { font-size: 12px; color: var(--muted); }

/* modal */
.modal-mask { position: fixed; inset: 0; background: rgba(15, 30, 25, .45); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: #fff; border-radius: 14px; width: min(720px, 92vw); max-height: 86vh; overflow: auto; padding: 20px 22px; }
.modal h3 { margin-bottom: 12px; }
.modal .x { float: right; border: none; background: none; font-size: 18px; color: var(--muted); }
.form-row { display: flex; gap: 10px; margin-bottom: 10px; align-items: center; }
.form-row label { width: 110px; color: var(--muted); font-size: 13px; }
.form-row input, .form-row select { flex: 1; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }

/* 巡檢執行 log */
.runlog { background: #0f2419; color: #a7e3c0; font: 12px/1.7 ui-monospace, monospace; border-radius: 10px; padding: 12px 14px; max-height: 300px; overflow: auto; }
.runlog .ok { color: #4ade80; } .runlog .warn { color: #fbbf24; } .runlog .err { color: #f87171; }
.progress { height: 8px; border-radius: 5px; background: #eef1f4; overflow: hidden; margin: 10px 0; }
.progress i { display: block; height: 100%; background: var(--accent); transition: width .3s; }

/* toggle */
.toggle { width: 38px; height: 21px; border-radius: 12px; background: #d1d9de; position: relative; cursor: pointer; border: none; }
.toggle.on { background: var(--accent); }
.toggle i { position: absolute; top: 2.5px; left: 3px; width: 16px; height: 16px; background: #fff; border-radius: 50%; transition: left .15s; }
.toggle.on i { left: 19px; }

.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); background: #123f2e; color: #fff; border-radius: 10px; padding: 10px 20px; z-index: 200; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, monospace; font-size: 12px; }
.empty { text-align: center; color: var(--muted); padding: 30px 0; }

@media (max-width: 1100px) {
  .mid-grid, .metric-grid { grid-template-columns: 1fr; }
  .risk-strip { flex-direction: column; }
  .asset-brief { border-left: none; border-top: 1px solid var(--line); padding: 12px 0 0; margin-top: 10px; }
  .sidebar { width: 64px; }
  .sidebar .brand h1, .sidebar .brand p, .sidebar .nav-sec, .sidebar .nav-item span.txt, .sidebar .me div { display: none; }
}
