/* ===========================================================
   山东杰瑞达追溯平台 — 统一设计系统 (政务蓝)
   基于本地 Bootstrap 5，覆盖 --bs-primary 实现品牌主色。
   不依赖任何外部 CDN。
   =========================================================== */

:root {
    --brand: #1f6feb;
    --brand-dark: #1857c4;
    --brand-darker: #0f3d6e;
    --sidebar-bg: #0f2c54;
    --sidebar-bg-2: #143a6b;
    --app-bg: #f4f6fb;
    --app-text: #1f2937;
    --app-muted: #6b7280;
    --border-soft: #e6eaf2;

    /* 覆盖 Bootstrap 主色 → 政务蓝 */
    --bs-primary: #1f6feb;
    --bs-primary-rgb: 31, 111, 235;
    --bs-link-color: #1f6feb;
    --bs-link-hover-color: #1857c4;
    --bs-btn-primary-bg: #1f6feb;
    --bs-btn-primary-border-color: #1f6feb;
    --bs-btn-primary-hover-bg: #1857c4;
    --bs-btn-primary-hover-border-color: #1857c4;
}

html, body { height: 100%; }
body {
    background: var(--app-bg);
    color: var(--app-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", Arial, sans-serif;
    font-size: 14px;
}

/* ---------- 后台外壳布局 ---------- */
.app-body { display: flex; min-height: 100vh; }

.app-sidebar {
    width: 244px;
    flex: 0 0 244px;
    background: linear-gradient(180deg, var(--sidebar-bg-2) 0%, var(--sidebar-bg) 100%);
    color: #fff;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform .25s ease;
}

.app-sidebar__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 18px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.app-sidebar__logo {
    width: 38px; height: 38px;
    border-radius: 9px;
    background: rgba(255, 255, 255, .12);
    display: flex; align-items: center; justify-content: center;
    flex: 0 0 38px;
}
.app-sidebar__title { font-size: 15px; font-weight: 700; line-height: 1.25; }
.app-sidebar__subtitle { font-size: 11px; color: rgba(255, 255, 255, .6); }

.app-sidebar__nav { padding: 12px 10px; overflow-y: auto; flex: 1 1 auto; }
.app-sidebar .nav-group-label {
    color: rgba(255, 255, 255, .45);
    font-size: 11px;
    letter-spacing: .08em;
    padding: 14px 12px 6px;
}
.app-sidebar .nav-item { margin-bottom: 2px; }
.app-sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    color: rgba(255, 255, 255, .82);
    padding: 10px 12px;
    border-radius: 9px;
    font-size: 14px;
    text-decoration: none;
    transition: background .15s ease, color .15s ease;
}
.app-sidebar .nav-link svg { width: 18px; height: 18px; flex: 0 0 18px; }
.app-sidebar .nav-link:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.app-sidebar .nav-link.active {
    background: var(--brand);
    color: #fff;
    box-shadow: 0 6px 16px -6px rgba(31, 111, 235, .8);
}

.app-sidebar__footer {
    padding: 12px 16px;
    font-size: 11px;
    color: rgba(255, 255, 255, .5);
    border-top: 1px solid rgba(255, 255, 255, .08);
}

/* ---------- 主区域 ---------- */
.app-main {
    flex: 1 1 auto;
    margin-left: 244px;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.app-topbar {
    height: 60px;
    background: #fff;
    border-bottom: 1px solid var(--border-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 1030;
}
.app-topbar__title { font-size: 16px; font-weight: 600; margin: 0; }
.app-topbar__actions { display: flex; align-items: center; gap: 12px; }
.app-topbar .user-name { font-size: 13px; color: var(--app-muted); }
.app-topbar .btn-logout {
    border: 1px solid var(--border-soft);
    background: #fff;
    color: var(--app-text);
    font-size: 13px;
    padding: 6px 14px;
    border-radius: 8px;
    text-decoration: none;
}
.app-topbar .btn-logout:hover { background: #f4f6fb; color: var(--brand); }

.sidebar-toggle {
    display: none;
    border: none;
    background: transparent;
    font-size: 20px;
    line-height: 1;
    color: var(--app-text);
    cursor: pointer;
}

.app-content { padding: 22px 24px 40px; flex: 1 1 auto; }

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 44, 84, .45);
    z-index: 1035;
}

/* ---------- 页面组件 ---------- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}
.page-header h1, .page-header h2 { font-size: 19px; font-weight: 700; margin: 0; }
.page-header .page-header__desc { color: var(--app-muted); font-size: 13px; margin-top: 2px; }

.panel {
    background: #fff;
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}
.panel__head {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.panel__title { font-size: 15px; font-weight: 600; margin: 0; }
.panel__body { padding: 18px; }

/* 统计卡片 */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.stat-card {
    background: #fff;
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}
.stat-card__icon {
    width: 46px; height: 46px;
    border-radius: 12px;
    background: rgba(31, 111, 235, .1);
    color: var(--brand);
    display: flex; align-items: center; justify-content: center;
    flex: 0 0 46px;
}
.stat-card__icon svg { width: 22px; height: 22px; }
.stat-card__num { font-size: 22px; font-weight: 700; line-height: 1.1; }
.stat-card__label { font-size: 13px; color: var(--app-muted); }

/* 表格美化（在 panel 内） */
.panel .table { margin-bottom: 0; }
.panel .table thead th {
    background: #f7f9fc;
    font-weight: 600;
    font-size: 13px;
    color: #374151;
    border-bottom-width: 1px;
    white-space: nowrap;
}
.panel .table td { vertical-align: middle; font-size: 13px; }

/* 表单字段间距统一 */
.app-content .form-label { font-weight: 500; }

/* 错误/空态 */
.empty-state {
    text-align: center;
    color: var(--app-muted);
    padding: 36px 16px;
}
.empty-state svg { width: 40px; height: 40px; color: #cbd2de; margin-bottom: 8px; }

/* 拒绝访问页 */
.denied-box { max-width: 480px; margin: 40px auto; text-align: center; }

/* ---------- 登录页（独立布局，Layout=null） ---------- */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #0f3d6e 0%, #1f6feb 100%);
}
.auth-card {
    width: 100%;
    max-width: 400px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 18px 50px -12px rgba(15, 44, 84, .55);
    overflow: hidden;
}
.auth-card__head {
    background: linear-gradient(135deg, #0f3d6e 0%, #1f6feb 100%);
    color: #fff;
    padding: 26px 24px;
    text-align: center;
}
.auth-card__logo {
    width: 52px; height: 52px;
    border-radius: 13px;
    background: rgba(255, 255, 255, .15);
    display: inline-flex; align-items: center; justify-content: center;
    margin-bottom: 12px;
}
.auth-card__logo svg { width: 28px; height: 28px; }
.auth-card__title { font-size: 18px; font-weight: 700; margin: 0; }
.auth-card__sub { font-size: 12px; opacity: .85; margin-top: 4px; }
.auth-card__body { padding: 24px; }
.auth-card .btn-primary { width: 100%; padding: 11px; font-weight: 600; }

/* ---------- 公开扫码查询页（独立布局，Layout=null） ---------- */
.trace-page {
    min-height: 100vh;
    background: #eef2f8;
    color: #1f2937;
    padding: 16px;
}
.trace-wrap { max-width: 720px; margin: 0 auto; }
.trace-hero {
    background: linear-gradient(135deg, #0f3d6e 0%, #1f6feb 100%);
    color: #fff;
    border-radius: 14px;
    padding: 20px;
    text-align: center;
    margin-bottom: 14px;
}
.trace-hero__logo { width: 44px; height: 44px; border-radius: 11px; background: rgba(255,255,255,.16); display: inline-flex; align-items: center; justify-content: center; margin-bottom: 10px; }
.trace-hero h1 { font-size: 18px; margin: 0; font-weight: 700; }
.trace-hero p { font-size: 12px; opacity: .85; margin: 4px 0 0; }

.trace-card {
    background: #fff;
    border-radius: 14px;
    padding: 16px 18px;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(16, 24, 40, .06);
}
.trace-card__title {
    font-size: 14px;
    font-weight: 600;
    color: var(--brand);
    margin: 0 0 10px;
    display: flex;
    align-items: center;
    gap: 7px;
    border-left: 3px solid var(--brand);
    padding-left: 9px;
}
.trace-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 0;
    border-bottom: 1px dashed #eef0f4;
    font-size: 14px;
}
.trace-row:last-child { border-bottom: 0; }
.trace-row__label { color: #6b7280; flex: 0 0 38%; }
.trace-row__value { text-align: right; font-weight: 500; word-break: break-all; }
.trace-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

/* 商标图片位：产品信息卡片顶部居中展示 */
.trace-trademark {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 6px 0 14px;
    margin-bottom: 4px;
}
.trace-trademark__img {
    max-width: 160px;
    max-height: 120px;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 1px 4px rgba(15, 23, 42, .08);
}

.trace-search { display: flex; gap: 8px; margin-top: 10px; }
.trace-search input { flex: 1 1 auto; }

.trace-back {
    display: block;
    width: 100%;
    text-align: center;
    padding: 12px;
    border-radius: 10px;
    background: var(--brand);
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    margin-top: 6px;
}
.trace-back:hover { background: var(--brand-dark); color: #fff; }

.trace-footer {
    margin-top: 16px;
    font-size: 12px;
    color: #9aa3b2;
    text-align: center;
    line-height: 1.7;
}
.trace-footer a { color: #6b7280; }

/* ---------- 响应式 ---------- */
@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); }
    .app-main { margin-left: 0; }
    .sidebar-toggle { display: inline-flex; }
    body.sidebar-open .app-sidebar { transform: translateX(0); }
    body.sidebar-open .sidebar-backdrop { display: block; }
}
