* { box-sizing: border-box; }
body { font-family: "Segoe UI", "Microsoft JhengHei", sans-serif; margin: 0; background: #f0f2f5; }
body.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box { background: #fff; padding: 2rem; border-radius: 8px; box-shadow: 0 2px 12px rgba(0,0,0,0.1); width: 100%; max-width: 360px; }
.login-box h1 { margin: 0 0 0.5rem 0; font-size: 1.35rem; }
.login-desc { color: #666; font-size: 0.9rem; margin-bottom: 1.5rem; }
.login-box label { display: block; margin: 0.75rem 0; font-size: 0.9rem; }
.login-box input { display: block; width: 100%; padding: 0.5rem 0.75rem; margin-top: 0.25rem; border: 1px solid #ddd; border-radius: 6px; }
.login-box button { width: 100%; padding: 0.6rem; margin-top: 1rem; cursor: pointer; background: #2563eb; color: #fff; border: none; border-radius: 6px; font-size: 1rem; }
.login-box button:hover { background: #1d4ed8; }
.login-copyright { margin-top: 1.5rem; padding-top: 1rem; font-size: 0.8rem; color: #94a3b8; text-align: center; }
.dc-app { display: flex; min-height: 100vh; }

/* ----- 侧栏 ----- */
.sidebar {
  width: 220px;
  background: #1e293b;
  color: #e2e8f0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-header { padding: 1rem; border-bottom: 1px solid #334155; }
.sidebar-header h2 { margin: 0 0 0.25rem 0; font-size: 1.1rem; font-weight: 600; }
.sidebar-header .subtitle { margin: 0; font-size: 0.8rem; color: #94a3b8; }
.sidebar-header .user { margin: 0.5rem 0 0 0; font-size: 0.8rem; color: #94a3b8; }
.sidebar-header .user a { color: #60a5fa; margin-left: 0.5rem; text-decoration: none; }
.sidebar-header .user a:hover { text-decoration: underline; }
.sidebar nav { padding: 0.5rem 0; overflow: auto; }
.nav-item { display: block; padding: 0.6rem 1rem; color: #cbd5e1; text-decoration: none; font-size: 0.95rem; }
.nav-item:hover { background: #334155; color: #fff; }
.nav-item.active { background: #2563eb; color: #fff; }
.sidebar-copyright {
  margin-top: auto;
  padding: 0.75rem 1rem;
  border-top: 1px solid #334155;
  font-size: 0.78rem;
  color: #94a3b8;
}

/* ----- 主内容 ----- */
.content { flex: 1; padding: 1.5rem; overflow: auto; }
.page { display: none; }
.page.active { display: block; }
.content .page h1 { margin: 0 0 0.35rem 0; font-size: 1.4rem; }
.page-desc { margin: 0 0 1.25rem 0; color: #475569; font-size: 0.9rem; }

/* ----- 卡片与统计 ----- */
.card { background: #fff; border-radius: 8px; padding: 1.25rem; margin-bottom: 1rem; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.card h2, .card h3 { margin: 0 0 0.75rem 0; font-size: 1.1rem; }
.card p { margin: 0 0 1rem 0; color: #475569; font-size: 0.9rem; }
.card p:last-child { margin-bottom: 0; }

.stats-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: #fff; border-radius: 8px; padding: 1.25rem; box-shadow: 0 1px 3px rgba(0,0,0,0.08); text-align: center; }
.stat-card .stat-value { display: block; font-size: 1.75rem; font-weight: 700; color: #1e293b; }
.stat-card .stat-label { display: block; font-size: 0.85rem; color: #64748b; margin-top: 0.25rem; }
.stat-card-alerts .stat-value { color: #dc2626; }

/* ----- 设备与层级 ----- */
.breadcrumb { margin-bottom: 1rem; font-size: 0.9rem; color: #64748b; }
.breadcrumb a { color: #2563eb; text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .sep { margin: 0 0.35rem; color: #cbd5e1; }
.breadcrumb .crumb-current { color: #1e293b; font-weight: 500; }

.hierarchy-layout { display: grid; grid-template-columns: 1fr 1fr 1.5fr; gap: 1rem; margin-bottom: 1.5rem; }
@media (max-width: 900px) { .hierarchy-layout { grid-template-columns: 1fr; } }

.hierarchy-panel { background: #fff; border-radius: 8px; padding: 1rem; box-shadow: 0 1px 3px rgba(0,0,0,0.08); min-height: 200px; }
.hierarchy-panel h3 { margin: 0 0 0.75rem 0; font-size: 1rem; color: #475569; border-bottom: 1px solid #e2e8f0; padding-bottom: 0.5rem; }

.hierarchy-item { padding: 0.6rem 0.75rem; border-radius: 6px; cursor: pointer; margin-bottom: 0.25rem; }
.hierarchy-item:hover { background: #f1f5f9; }
.hierarchy-item.active { background: #dbeafe; color: #1e40af; }
.status-badge.status-online { color: #059669; background: #d1fae5; padding: 0.2rem 0.5rem; border-radius: 4px; font-size: 0.85em; }
.status-badge.status-offline { color: #64748b; background: #f1f5f9; padding: 0.2rem 0.5rem; border-radius: 4px; font-size: 0.85em; }

.devices-table-wrap { position: relative; }
.devices-table-wrap .muted { margin: 1rem 0; }
.devices-table { width: 100%; }
.link-view { color: #2563eb; text-decoration: none; font-size: 0.9rem; }
.link-view:hover { text-decoration: underline; }

/* 设备详情页 */
.page-detail-header { margin-bottom: 1.25rem; }
.back-link { color: #2563eb; text-decoration: none; font-size: 0.9rem; display: inline-block; margin-bottom: 0.5rem; }
.back-link:hover { text-decoration: underline; }
.page-detail-header h1 { margin: 0 0 0.35rem 0; font-size: 1.35rem; font-weight: 600; }
.detail-error { color: #dc2626; padding: 1rem; background: #fef2f2; border-radius: 6px; margin-bottom: 1rem; }
.detail-section { margin-bottom: 1.25rem; }
.detail-section h3 { margin: 0 0 0.75rem 0; font-size: 1rem; color: #334155; border-bottom: 1px solid #e2e8f0; padding-bottom: 0.5rem; }
.detail-info-table { max-width: 560px; }
.detail-info-table .detail-label { font-weight: 500; color: #475569; width: 100px; }
.detail-hint { font-size: 0.85rem; color: #64748b; margin: 0 0 0.5rem 0; }

.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table th, .data-table td { padding: 0.5rem 0.6rem; text-align: left; border-bottom: 1px solid #e2e8f0; }
.data-table code { font-size: 0.85em; }
.data-table .row-alert { background: #fef2f2; }
.badge.alert { background: #dc2626; color: #fff; padding: 0.15rem 0.4rem; border-radius: 4px; font-size: 0.8rem; }

.device-actions { background: #fff; border-radius: 8px; padding: 1rem; margin-top: 1rem; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.device-actions h3 { margin: 0 0 0.75rem 0; font-size: 1rem; }
.device-action-block { margin-bottom: 1rem; }
.device-action-block:last-child { margin-bottom: 0; }
.device-action-block h4 { margin: 0 0 0.5rem 0; font-size: 0.95rem; color: #475569; }
.device-actions form { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end; }
.device-actions form label { margin: 0; }
.device-actions form label.checkbox-label { display: inline-flex; align-items: center; gap: 0.35rem; }
.device-actions form input[type="datetime-local"] { padding: 0.4rem 0.6rem; border: 1px solid #e2e8f0; border-radius: 6px; }
.device-actions form input { padding: 0.4rem 0.6rem; border: 1px solid #e2e8f0; border-radius: 6px; width: 200px; }
.form-msg.error { color: #dc2626; }
.btn-link { background: none; border: none; color: #2563eb; cursor: pointer; font-size: inherit; padding: 0 0.25rem; text-decoration: underline; }
.btn-link:hover { color: #1d4ed8; }

/* ----- IOC 库 ----- */
.ioc-password-row { margin-bottom: 0.75rem; }
.ioc-password-row input { width: 260px; padding: 0.4rem 0.6rem; border: 1px solid #e2e8f0; border-radius: 6px; }
.ioc-actions { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-start; margin-bottom: 0.5rem; }
.ioc-actions .inline-form { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.ioc-actions .inline-form input[type="text"] { padding: 0.4rem 0.6rem; border: 1px solid #e2e8f0; border-radius: 6px; width: 200px; }
.ioc-actions .inline-form input[type="file"] { font-size: 0.9rem; }
.ioc-actions button, .device-actions button { padding: 0.5rem 1rem; cursor: pointer; background: #2563eb; color: #fff; border: none; border-radius: 6px; }
.ioc-actions button:hover, .device-actions button:hover { background: #1d4ed8; }

.hash-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; margin-top: 0.75rem; }
.hash-table th, .hash-table td { padding: 0.4rem 0.6rem; text-align: left; border-bottom: 1px solid #e2e8f0; }
.hash-table code { font-size: 0.8em; word-break: break-all; }

/* ----- 通用 ----- */
.error { color: #dc2626; font-size: 0.9rem; }
.success { color: #16a34a; }
.muted { color: #64748b; font-size: 0.9rem; }
.form-msg { margin-top: 0.5rem; font-size: 0.9rem; min-height: 1.2em; }
code { background: #f1f5f9; padding: 0.1rem 0.3rem; border-radius: 4px; font-size: 0.85em; }
