/* ============================================
   锅炉检验报告管理平台 · 商用级设计系统
   ============================================ */

:root {
    --brand-primary: #4f46e5;        /* indigo-600 */
    --brand-secondary: #06b6d4;      /* cyan-500 */
    --brand-accent: #f59e0b;         /* amber-500 */
    --brand-gradient: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #06b6d4 100%);
    --brand-gradient-warm: linear-gradient(135deg, #f97316 0%, #f59e0b 100%);
    --brand-gradient-cool: linear-gradient(135deg, #0ea5e9 0%, #06b6d4 100%);
    --brand-gradient-success: linear-gradient(135deg, #10b981 0%, #34d399 100%);

    --sidebar-bg: #0f172a;           /* slate-900 */
    --sidebar-bg-2: #1e293b;
    --sidebar-text: #cbd5e1;
    --sidebar-text-active: #ffffff;
    --sidebar-active: rgba(99, 102, 241, 0.15);

    --bg-page: #f1f5f9;              /* slate-100 */
    --bg-card: #ffffff;
    --bg-soft: #f8fafc;
    --border: #e2e8f0;
    --border-light: #eef2f7;

    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.08), 0 4px 12px rgba(15, 23, 42, 0.04);
    --shadow-glow: 0 8px 32px rgba(79, 70, 229, 0.18);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
}

* { box-sizing: border-box; }

body {
    background: var(--bg-page) !important;
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

/* ============================================
   侧边栏
   ============================================ */
.navbar-vertical {
    background: var(--sidebar-bg) !important;
    border-right: 1px solid rgba(255, 255, 255, 0.04);
}

.navbar-vertical .navbar-brand {
    padding: 22px 16px 18px;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.navbar-vertical .navbar-brand a {
    color: #fff !important;
    text-decoration: none;
    font-size: 16px;
}

.navbar-vertical .navbar-brand .brand-logo {
    width: 38px;
    height: 38px;
    background: var(--brand-gradient-warm);
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 22px;
    box-shadow: 0 4px 14px rgba(249, 115, 22, 0.4);
}

.navbar-vertical .brand-logo .ti {
    color: #fff !important;
    background: none !important;
    -webkit-text-fill-color: #fff !important;
}

.navbar-vertical .navbar-nav .nav-link {
    color: var(--sidebar-text) !important;
    padding: 11px 14px;
    margin: 2px 10px;
    border-radius: 10px;
    transition: all 0.2s ease;
    font-size: 14px;
    font-weight: 500;
}

.navbar-vertical .navbar-nav .nav-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff !important;
}

.navbar-vertical .navbar-nav .nav-item.active .nav-link,
.navbar-vertical .navbar-nav .nav-link.active {
    background: var(--sidebar-active);
    color: var(--sidebar-text-active) !important;
    box-shadow: inset 3px 0 0 var(--brand-primary);
}

.navbar-vertical .nav-link-icon {
    color: inherit;
    width: 22px;
    text-align: center;
    font-size: 18px;
}

.navbar-vertical .nav-link-icon .ti {
    font-size: 18px;
}

/* ============================================
   ⭐ 全新侧栏（独立命名空间 sb-*）
   ============================================ */

.sb-nav {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 6px 10px 0;
    width: 100%;
}

/* 顶级链接 & 父组标题，统一样式 */
.sb-link {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.15s ease;
    cursor: pointer;
    user-select: none;
}

.sb-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.sb-link.active {
    background: var(--sidebar-active);
    color: #fff;
    box-shadow: inset 3px 0 0 var(--brand-primary);
}

.sb-icon {
    width: 22px;
    font-size: 18px;
    margin-right: 12px;
    text-align: center;
    flex-shrink: 0;
}

.sb-text {
    flex: 1;
    white-space: nowrap;
}

/* 折叠箭头 */
.sb-caret {
    font-size: 16px;
    opacity: 0.5;
    transition: transform 0.25s ease;
    margin-left: 4px;
}

.sb-toggle.collapsed .sb-caret {
    transform: rotate(-90deg);
}

.sb-toggle:not(.collapsed) .sb-caret {
    opacity: 0.85;
}

/* 子菜单组 */
.sb-group {
    display: flex;
    flex-direction: column;
}

.sb-sub {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 2px 0 4px 0;
}

.sb-sublink {
    display: flex;
    align-items: center;
    padding: 8px 12px 8px 36px;
    color: #94a3b8;
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.15s ease;
    position: relative;
}

.sb-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.22);
    position: absolute;
    left: 19px;
    top: 50%;
    transform: translateY(-50%);
    transition: all 0.2s ease;
}

.sb-sublink:hover {
    background: rgba(255, 255, 255, 0.04);
    color: #fff;
}

.sb-sublink:hover .sb-dot {
    background: rgba(255, 255, 255, 0.6);
}

.sb-sublink.active {
    background: var(--sidebar-active);
    color: #fff;
    box-shadow: inset 3px 0 0 var(--brand-primary);
}

.sb-sublink.active .sb-dot {
    background: var(--brand-primary);
    width: 6px;
    height: 6px;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}

/* 让外层容器 flex 撑起来，user-card 推到底 */
.navbar-vertical .navbar-collapse {
    display: flex !important;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

/* 侧栏底部用户卡 */
.sidebar-user {
    margin: 12px 12px 16px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    color: var(--sidebar-text);
}

.sidebar-user .avatar {
    width: 36px;
    height: 36px;
    background: var(--brand-gradient);
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
}

.sidebar-user .name { color: #fff; font-weight: 500; font-size: 13px; }
.sidebar-user .role { color: #64748b; font-size: 11px; }

/* ============================================
   顶部
   ============================================ */
.navbar:not(.navbar-vertical) {
    background: var(--bg-card) !important;
    border-bottom: 1px solid var(--border-light);
    backdrop-filter: blur(8px);
}

.page-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    padding: 5px 12px;
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
}

.status-pill::before {
    content: "";
    width: 6px;
    height: 6px;
    background: #10b981;
    border-radius: 50%;
    margin-right: 6px;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%   { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5); }
    70%  { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* ============================================
   通用卡片
   ============================================ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-light) !important;
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-light);
    padding: 18px 22px;
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.card-body { padding: 22px; }
.card-table { margin: 0; }

/* ============================================
   Hero banner（仪表盘）
   ============================================ */
.hero-banner {
    background: var(--brand-gradient);
    color: #fff;
    border-radius: var(--radius-xl);
    padding: 36px 36px 36px;
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-glow);
}

.hero-banner::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
      radial-gradient(circle at 100% 0%, rgba(255, 255, 255, 0.15) 0%, transparent 60%),
      radial-gradient(circle at 0% 100%, rgba(245, 158, 11, 0.12) 0%, transparent 50%);
    pointer-events: none;
}

.hero-banner h1 {
    color: #fff;
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
    position: relative;
}

.hero-banner .hero-subtitle {
    color: rgba(255, 255, 255, 0.85);
    font-size: 14px;
    margin-bottom: 0;
    position: relative;
}

.hero-banner .hero-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 16px;
    position: relative;
}

.hero-banner .hero-tag {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 12px;
    padding: 4px 12px;
    border-radius: 999px;
    backdrop-filter: blur(8px);
}

.hero-banner .btn-light {
    background: rgba(255, 255, 255, 0.95);
    color: var(--brand-primary);
    font-weight: 600;
    border: 0;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
    position: relative;
}

.hero-banner .btn-light:hover {
    background: #fff;
    transform: translateY(-1px);
}

/* ============================================
   KPI 卡片
   ============================================ */
.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 22px;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--accent, var(--brand-primary));
    opacity: 0;
    transition: opacity 0.2s ease;
}

.kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: transparent;
}

.kpi-card:hover::before { opacity: 1; }

.kpi-card .kpi-label {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.kpi-card .kpi-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    letter-spacing: -1px;
    margin-bottom: 8px;
    font-variant-numeric: tabular-nums;
}

.kpi-card .kpi-delta {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
}

.kpi-card .kpi-delta.up   { color: #059669; }
.kpi-card .kpi-delta.down { color: #dc2626; }

.kpi-card .kpi-icon {
    position: absolute;
    right: 18px; top: 18px;
    width: 44px; height: 44px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    color: #fff;
    opacity: 0.9;
}

.kpi-icon.bg-indigo  { background: var(--brand-gradient); }
.kpi-icon.bg-success { background: var(--brand-gradient-success); }
.kpi-icon.bg-warm    { background: var(--brand-gradient-warm); }
.kpi-icon.bg-cool    { background: var(--brand-gradient-cool); }

/* ============================================
   图表容器
   ============================================ */
.chart-box {
    width: 100%;
    height: 320px;
}

.chart-box-sm {
    width: 100%;
    height: 220px;
}

/* ============================================
   报告类型卡片
   ============================================ */
.report-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 18px;
    transition: all 0.25s ease;
    text-decoration: none;
    display: block;
    color: inherit;
    position: relative;
    overflow: hidden;
}

.report-card::after {
    content: "";
    position: absolute;
    right: -20px; bottom: -20px;
    width: 80px; height: 80px;
    background: var(--brand-gradient);
    border-radius: 50%;
    opacity: 0.04;
    transition: all 0.3s ease;
}

.report-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: rgba(79, 70, 229, 0.2);
    color: inherit;
}

.report-card:hover::after {
    transform: scale(2);
    opacity: 0.08;
}

.report-card .report-icon {
    width: 44px;
    height: 44px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.12), rgba(6, 182, 212, 0.1));
    color: var(--brand-primary);
}

/* ============================================
   上传 dropzone
   ============================================ */
.dropzone {
    border: 2px dashed #cbd5e1;
    border-radius: var(--radius-lg);
    padding: 56px 32px;
    text-align: center;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    transition: all 0.25s ease;
    cursor: pointer;
}

.dropzone:hover,
.dropzone.dragover {
    border-color: var(--brand-primary);
    background: linear-gradient(180deg, #f5f3ff 0%, #eef2ff 100%);
    transform: scale(1.005);
}

.dropzone .ti {
    font-size: 56px;
    color: var(--brand-primary);
    opacity: 0.6;
}

.dropzone:hover .ti { opacity: 1; }

/* ============================================
   数据表
   ============================================ */
.data-table-wrapper {
    overflow-x: auto;
}

.table {
    margin: 0;
    color: var(--text-primary);
}

.table thead th {
    background: var(--bg-soft);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
}

.table tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
    font-size: 14px;
    vertical-align: middle;
}

.data-table td {
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.table tbody tr:hover {
    background: var(--bg-soft);
}

/* ============================================
   字段网格（详情页）
   ============================================ */
.field-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 12px;
}

.field-item {
    background: var(--bg-soft);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    transition: all 0.15s ease;
}

.field-item:hover {
    border-color: rgba(79, 70, 229, 0.3);
    background: #fff;
    box-shadow: var(--shadow-sm);
}

.field-key {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 600;
    letter-spacing: 0.3px;
    margin-bottom: 4px;
    text-transform: uppercase;
}

.field-value {
    font-size: 14px;
    color: var(--text-primary);
    word-break: break-all;
    min-height: 18px;
    font-weight: 500;
}

.field-value.empty {
    color: var(--text-muted);
    font-weight: 400;
    font-style: italic;
}

/* ============================================
   规则代码块
   ============================================ */
.rule-content {
    background: #0f172a;
    color: #e2e8f0;
    border-radius: var(--radius-md);
    padding: 22px;
    font-family: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
    font-size: 13px;
    line-height: 1.75;
    overflow-x: auto;
    white-space: pre;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* ============================================
   任务进度
   ============================================ */
.progress {
    height: 6px;
    border-radius: 999px;
    background: #e2e8f0;
}

.progress-bar {
    border-radius: 999px;
    background: var(--brand-gradient);
}

.progress-bar.bg-success { background: var(--brand-gradient-success); }
.progress-bar.bg-danger  { background: linear-gradient(90deg, #ef4444, #dc2626); }
.progress-bar.bg-info    { background: var(--brand-gradient-cool); }

.task-row-pending td:first-child { border-left: 3px solid #cbd5e1; }
.task-row-parsing td:first-child { border-left: 3px solid #06b6d4; }
.task-row-done    td:first-child { border-left: 3px solid #10b981; }
.task-row-failed  td:first-child { border-left: 3px solid #ef4444; }

/* ============================================
   按钮
   ============================================ */
.btn {
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
}

.btn-primary {
    background: var(--brand-gradient);
    border: 0;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
}

.btn-primary:hover {
    background: var(--brand-gradient);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.4);
    filter: brightness(1.05);
}

.btn-lg { padding: 11px 22px; font-size: 15px; }
.btn-sm { font-size: 12px; }

.btn-ghost-primary {
    color: var(--brand-primary);
    background: transparent;
}

.btn-ghost-primary:hover {
    background: rgba(79, 70, 229, 0.08);
    color: var(--brand-primary);
}

.btn-ghost-secondary {
    color: var(--text-secondary);
    background: transparent;
}

.btn-ghost-secondary:hover {
    background: var(--bg-soft);
    color: var(--text-primary);
}

/* ============================================
   Badge
   ============================================ */
.badge {
    font-weight: 500;
    padding: 4px 9px;
    border-radius: 6px;
    font-size: 11.5px;
    letter-spacing: 0.2px;
}

.bg-success    { background: linear-gradient(135deg, #10b981, #34d399) !important; }
.bg-danger     { background: linear-gradient(135deg, #ef4444, #f87171) !important; }
.bg-info       { background: linear-gradient(135deg, #0ea5e9, #06b6d4) !important; }
.bg-warning    { background: linear-gradient(135deg, #f59e0b, #fbbf24) !important; }
.bg-secondary  { background: linear-gradient(135deg, #64748b, #94a3b8) !important; }

.bg-success-lt   { background: rgba(16, 185, 129, 0.12) !important; color: #059669 !important; }
.bg-danger-lt    { background: rgba(239, 68, 68, 0.12) !important; color: #dc2626 !important; }
.bg-warning-lt   { background: rgba(245, 158, 11, 0.12) !important; color: #d97706 !important; }
.bg-info-lt      { background: rgba(6, 182, 212, 0.12) !important; color: #0891b2 !important; }
.bg-primary-lt   { background: rgba(79, 70, 229, 0.1) !important; color: var(--brand-primary) !important; }
.bg-secondary-lt { background: rgba(100, 116, 139, 0.12) !important; color: #475569 !important; }
.bg-green-lt     { background: rgba(16, 185, 129, 0.12) !important; color: #059669 !important; }
.bg-yellow-lt    { background: rgba(245, 158, 11, 0.12) !important; color: #d97706 !important; }
.bg-azure-lt     { background: rgba(14, 165, 233, 0.12) !important; color: #0284c7 !important; }
.bg-orange-soft  { background: rgba(249, 115, 22, 0.12) !important; color: #ea580c !important; }

/* ============================================
   表单
   ============================================ */
.form-control {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 14px;
    transition: all 0.15s ease;
}

.form-control:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.input-icon .input-icon-addon { color: var(--text-muted); }

/* ============================================
   分页
   ============================================ */
.pagination .page-item .page-link {
    border-radius: var(--radius-sm);
    margin: 0 2px;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 13px;
    padding: 6px 12px;
}

.pagination .page-item.active .page-link {
    background: var(--brand-gradient);
    border-color: transparent;
    color: #fff;
}

.pagination .page-item.disabled .page-link {
    background: var(--bg-soft);
    color: var(--text-muted);
}

/* ============================================
   空状态
   ============================================ */
.empty-state {
    text-align: center;
    padding: 56px 20px;
    color: var(--text-muted);
}

.empty-state .ti {
    font-size: 64px;
    margin-bottom: 14px;
    opacity: 0.4;
}

/* ============================================
   List group（最近任务/表）
   ============================================ */
.list-group-item {
    border-color: var(--border-light) !important;
    padding: 14px 18px;
    transition: all 0.15s ease;
}

.list-group-item-action:hover {
    background: var(--bg-soft);
}

/* ============================================
   HTMX 加载指示
   ============================================ */
.htmx-indicator { opacity: 0; transition: opacity 0.2s ease; }
.htmx-request .htmx-indicator { opacity: 1; }
.htmx-request.htmx-indicator { opacity: 1; }

/* ============================================
   滚动条美化
   ============================================ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.4); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(148, 163, 184, 0.7); }

/* 页面 footer 全局隐藏 */
.footer.footer-transparent { display: none; }

/* 仪表盘小标签 */
.section-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-label::before {
    content: "";
    width: 3px;
    height: 14px;
    background: var(--brand-gradient);
    border-radius: 2px;
}

/* 数据条形进度 */
.bar-track {
    height: 6px;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
    margin-top: 6px;
}

.bar-fill {
    height: 100%;
    background: var(--brand-gradient);
    border-radius: 999px;
    transition: width 0.6s ease;
}

/* trend mini badge */
.trend-up,
.trend-down {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
}

.trend-up   { color: #059669; background: rgba(16, 185, 129, 0.1); }
.trend-down { color: #dc2626; background: rgba(239, 68, 68, 0.1); }
