:root {
  --bg: #f5f7fb; --surface: #fff; --surface-soft: #f8faff; --border: #e5eaf1;
  --border-strong: #d7dee9; --text: #1d2939; --muted: #667085; --subtle: #98a2b3;
  --blue: #315efb; --blue-dark: #1d6ff2; --blue-soft: #edf3ff;
  --green: #14804a; --red: #b42318; --amber: #9a6700; --sidebar: 240px;
  --radius: 14px; --shadow: 0 4px 20px rgba(29, 41, 57, .06);
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--text); font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; }
button, .button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(49, 94, 251, .22); outline-offset: 2px; }

.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; display: flex; width: var(--sidebar); flex-direction: column; overflow: hidden; background: var(--surface); border-right: 1px solid var(--border); }
.sidebar-header { padding: 24px 20px 16px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; }
.brand-mark { position: relative; display: block; width: 38px; height: 38px; flex: 0 0 38px; border-radius: 12px; background: linear-gradient(145deg, #315efb, #1d7cf2); box-shadow: 0 7px 16px rgba(49, 94, 251, .2); }
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; border: 2px solid #fff; border-radius: 50%; }
.brand-mark::before { inset: 9px 8px 13px; border-bottom: 0; border-left-color: transparent; }
.brand-mark::after { inset: 17px 12px 8px; border-top: 0; border-right-color: transparent; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 17px; font-weight: 800; letter-spacing: .02em; }
.brand small { margin-top: 1px; color: var(--muted); font-size: 12px; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 4px 12px 22px; scrollbar-width: thin; }
.nav-label { padding: 20px 12px 7px; color: var(--subtle); font-size: 11px; font-weight: 700; letter-spacing: .08em; }
.nav-item { display: flex; min-height: 42px; align-items: center; gap: 11px; margin: 3px 0; padding: 9px 12px; border-radius: 10px; color: #475467; font-weight: 600; text-decoration: none; transition: background-color .16s ease, color .16s ease, transform .16s ease; }
.nav-item:hover { background: #f4f7fc; color: var(--blue); }
.nav-item.active { color: #fff; background: linear-gradient(135deg, var(--blue), var(--blue-dark)); box-shadow: 0 7px 16px rgba(49, 94, 251, .2); }
.nav-icon { display: grid; width: 20px; height: 20px; flex: 0 0 20px; place-items: center; font-size: 16px; line-height: 1; }
.nav-item.active .nav-icon { color: #fff; }
.cockpit-return { margin-top: 18px; border: 1px solid var(--border); }
.sidebar-footer { display: flex; align-items: center; gap: 9px; padding: 15px 14px; border-top: 1px solid var(--border); background: #fbfcfe; }
.user-info { display: flex; min-width: 0; flex: 1; align-items: center; gap: 9px; }
.user-info > span:last-child { min-width: 0; }
.user-info strong, .user-info small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-info strong { font-size: 13px; }
.user-info small { color: var(--muted); font-size: 11px; }
.user-avatar { display: grid; width: 34px; height: 34px; flex: 0 0 34px; place-items: center; border-radius: 50%; color: var(--blue); background: var(--blue-soft); font-size: 12px; font-weight: 800; }
.logout-button { padding: 5px; border: 0; color: var(--muted); background: transparent; cursor: pointer; }
.logout-button:hover { color: var(--red); }

.main { min-height: 100vh; margin-left: var(--sidebar); }
.content { width: 100%; max-width: 1640px; margin: 0 auto; padding: 34px 36px 56px; }
.menu-button { display: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.page-head h1 { margin: 0 0 4px; font-size: 28px; line-height: 1.25; font-weight: 800; letter-spacing: -.02em; }
.page-head p { max-width: 760px; margin: 0; color: var(--muted); }
.eyebrow { display: none; }
.inline-actions, .row-actions { display: flex; align-items: center; gap: 12px; }
.inline-actions { min-height: 42px; }
.row-actions { min-width: 188px; }
.action-note { color: var(--subtle); font-size: 12px; }
.kicker { color: var(--blue); font-size: 12px; font-weight: 750; }
.primary, .button { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; border: 0; border-radius: 9px; padding: 9px 16px; color: #fff; background: linear-gradient(135deg, var(--blue), var(--blue-dark)); box-shadow: 0 5px 12px rgba(49, 94, 251, .16); font-weight: 700; text-decoration: none; cursor: pointer; transition: transform .15s ease, box-shadow .15s ease; }
.primary:hover, .button:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(49, 94, 251, .22); }
.link { padding: 0; border: 0; color: var(--blue); background: none; cursor: pointer; }
.danger { color: var(--red) !important; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.metric, .panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.metric { position: relative; min-height: 136px; overflow: hidden; padding: 22px; }
.metric::after { content: ""; position: absolute; top: 18px; right: 18px; width: 42px; height: 42px; border-radius: 12px; background: var(--blue-soft); }
.metric span, .metric small { position: relative; z-index: 1; display: block; color: var(--muted); }
.metric strong { position: relative; z-index: 1; display: block; margin: 9px 0 2px; font-size: 32px; line-height: 1.2; font-weight: 800; letter-spacing: -.02em; }
.panel { margin-bottom: 18px; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.panel-head h2 { margin: 0; font-size: 17px; }
.trend { display: flex; height: 230px; align-items: flex-end; justify-content: space-around; gap: 16px; padding: 30px 32px; }
.trend > div { display: flex; height: 165px; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; color: var(--muted); }
.trend span { width: 30px; min-height: 3px; border-radius: 6px 6px 2px 2px; background: linear-gradient(#6c8dff, var(--blue)); }

.form-panel, .settings-panel { padding: 22px; }
.inline-form { display: grid; grid-template-columns: repeat(5, minmax(120px, 1fr)); gap: 12px; align-items: end; }
input, select, textarea { width: 100%; border: 1px solid var(--border-strong); border-radius: 9px; color: var(--text); background: #fff; transition: border-color .15s ease, box-shadow .15s ease; }
input, select { height: 42px; padding: 0 12px; }
textarea { padding: 10px 12px; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: #b8c3d3; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(49, 94, 251, .1); outline: 0; }
.hint { margin: 12px 0 0; color: var(--muted); }
.muted-copy { color: var(--muted); }
.table-action { color: var(--blue); font-weight: 650; text-decoration: none; }
.table-action:hover { text-decoration: underline; }
.file-links { display: flex; gap: 12px; }
.file-links a { color: var(--blue); font-weight: 650; text-decoration: none; }
.file-links a:hover { text-decoration: underline; }
.table-panel { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { padding: 14px 18px; border-bottom: 1px solid var(--border); text-align: left; }
th { color: #667085; background: #f8fafc; font-size: 12px; font-weight: 700; }
tbody tr { transition: background-color .12s ease; }
tbody tr:hover { background: #fafcff; }
tbody tr:last-child td { border-bottom: 0; }
.status { display: inline-flex; border-radius: 999px; padding: 3px 9px; color: var(--muted); background: #f0f3f7; font-size: 12px; }
.status.ok { color: var(--green); background: #e9f8ef; }
.status.warn { color: var(--amber); background: #fff6df; }
.status.danger { color: var(--red); background: #fff0ef; }
.empty { padding: 40px; color: var(--muted); text-align: center; }
.ellipsis { max-width: 280px; overflow: hidden; text-overflow: ellipsis; }

.creation-panel > summary, .advanced-filters > summary { display: flex; align-items: center; justify-content: space-between; cursor: pointer; list-style: none; }
.creation-panel > summary::-webkit-details-marker, .advanced-filters > summary::-webkit-details-marker { display: none; }
.creation-panel > summary { padding: 18px 22px; }
.creation-panel > summary span:first-child { display: grid; gap: 2px; }
.creation-panel > summary strong { font-size: 16px; }
.creation-panel > summary small, .details-action { color: var(--muted); }
.creation-panel[open] .details-action::before { content: ""; }
.creation-panel:not([open]) .details-action { font-size: 0; }
.creation-panel:not([open]) .details-action::after { content: "展开"; font-size: 14px; }
.creation-body { padding: 0 22px 22px; border-top: 1px solid var(--border); }
.creation-body .inline-form { padding-top: 20px; }
.inline-form label, .filter-form label { display: grid; gap: 6px; min-width: 0; color: var(--text); font-weight: 650; }
.inline-form label > span, .filter-form label > span { font-size: 12px; }

.filter-panel { overflow: visible; }
.filter-overview { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 15px 18px; }
.filter-overview > div { display: flex; align-items: baseline; gap: 10px; }
.filter-overview > div span { color: var(--muted); font-size: 12px; }
.period-tabs { display: inline-flex; gap: 4px; padding: 3px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-soft); }
.period-tabs a { min-width: 56px; padding: 6px 12px; border-radius: 7px; color: var(--muted); text-align: center; font-weight: 650; text-decoration: none; }
.period-tabs a:hover { color: var(--blue); }
.period-tabs a.active { color: #fff; background: var(--blue); }
.advanced-filters { border-top: 1px solid var(--border); }
.advanced-filters > summary { justify-content: flex-start; gap: 10px; padding: 12px 18px; color: var(--blue); font-weight: 650; }
.advanced-filters > summary::before { content: "+"; display: grid; width: 20px; height: 20px; place-items: center; border-radius: 50%; background: var(--blue-soft); }
.advanced-filters[open] > summary::before { content: "−"; }
.advanced-filters > summary small { color: var(--muted); font-weight: 400; }
.filter-form { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 14px; padding: 4px 18px 18px; }
.filter-actions { display: flex; align-items: flex-end; gap: 10px; }
.secondary-button { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; padding: 8px 14px; border: 1px solid var(--border-strong); border-radius: 9px; color: var(--text); background: #fff; font-weight: 650; text-decoration: none; }
.secondary-button:hover { border-color: var(--blue); color: var(--blue); }
.pagination-bar { display: flex; min-width: 680px; align-items: center; justify-content: space-between; gap: 20px; padding: 14px 18px; border-top: 1px solid var(--border); color: var(--muted); }
.pagination-bar nav { display: flex; gap: 8px; }
.pagination-bar a, .pagination-bar nav span { display: inline-flex; min-height: 34px; align-items: center; padding: 6px 12px; border: 1px solid var(--border); border-radius: 8px; text-decoration: none; }
.pagination-bar a { color: var(--blue); background: #fff; }
.pagination-bar nav span { color: var(--subtle); background: var(--surface-soft); }

.dashboard-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.dashboard-metric { min-height: 132px; padding: 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.dashboard-metric span, .dashboard-metric small { display: block; color: var(--muted); }
.dashboard-metric strong { display: block; margin: 10px 0 2px; font-size: 32px; line-height: 1.1; letter-spacing: -.02em; }
.dashboard-metric.primary-metric { border-color: #061735; color: #fff; background: #061735; }
.dashboard-metric.primary-metric span, .dashboard-metric.primary-metric small { color: #c9d8eb; }
.security-alert-panel { margin-bottom: 18px; overflow: hidden; }
.security-alert-panel.has-alerts { border-color: #f2d7a5; }
.security-alert-count, .security-clear-state { padding: 5px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.security-alert-count { color: #9a5a00; background: #fff4dc; }
.security-clear-state { color: #087a55; background: #e9f8f1; }
.security-alert-list article { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px; min-height: 70px; padding: 13px 22px; border-bottom: 1px solid var(--border); }
.security-alert-list article:last-child { border-bottom: 0; }
.security-alert-list article > div { display: grid; min-width: 0; gap: 3px; }
.security-alert-list article strong { font-size: 14px; }
.security-alert-list article > div span { overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.security-alert-list article > a { color: var(--blue); font-size: 13px; font-weight: 650; text-decoration: none; }
.security-alert-badge { min-width: 76px; padding: 5px 9px; border-radius: 999px; text-align: center; font-size: 12px; font-weight: 700; }
.security-alert-badge.warning { color: #9a5a00; background: #fff4dc; }
.security-alert-badge.danger { color: #b42318; background: #ffebe9; }
.security-empty { display: grid; gap: 4px; padding: 20px 22px; background: #fbfefd; }
.security-empty strong { color: #087a55; font-size: 14px; }
.security-empty span { color: var(--muted); font-size: 12px; }
.dashboard-main-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, .72fr); gap: 18px; }
.panel-head > div { display: grid; gap: 2px; }
.panel-head p { margin: 0; color: var(--muted); font-size: 12px; }
.panel-head > a { color: var(--blue); font-weight: 650; text-decoration: none; }
.trend-chart { display: grid; height: 230px; grid-template-columns: repeat(30, minmax(5px, 1fr)); align-items: end; gap: 5px; padding: 26px 24px 20px; }
.trend-column { display: grid; height: 172px; grid-template-rows: 18px 1fr 20px; align-items: end; justify-items: center; color: var(--muted); }
.trend-column b { font-size: 10px; font-weight: 650; }
.trend-column span { width: min(100%, 16px); min-height: 4px; border-radius: 5px 5px 2px 2px; background: var(--blue); }
.trend-column small { font-size: 10px; white-space: nowrap; }
.system-summary dl { margin: 0; padding: 4px 20px 16px; }
.system-summary dl div { display: flex; align-items: center; justify-content: space-between; padding: 13px 2px; border-bottom: 1px solid var(--border); }
.system-summary dl div:last-child { border-bottom: 0; }
.system-summary dt { color: var(--muted); }
.system-summary dd { margin: 0; font-size: 18px; font-weight: 800; }
.activity-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.activity-list article { display: flex; align-items: center; justify-content: space-between; gap: 18px; min-height: 66px; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.activity-list article:last-child { border-bottom: 0; }
.activity-list article > div:first-child { display: grid; min-width: 0; gap: 2px; }
.activity-list article strong, .activity-list article span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-list article > div:first-child span, .activity-list time { color: var(--muted); font-size: 12px; }
.activity-meta { display: flex; flex: 0 0 auto; align-items: center; gap: 12px; }
.compact-empty { padding: 28px 20px; }

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.settings-grid label, .product-form label { display: grid; gap: 7px; font-weight: 650; }
.settings-grid .wide, .product-form .wide { grid-column: 1 / -1; }
.product-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.product-form label > span { color: var(--text); }
.form-actions { display: flex; align-items: center; gap: 14px; }
.form-actions span, .product-summary { color: var(--muted); font-size: 12px; }
.product-thumb { display: grid; width: 52px; height: 52px; place-items: center; border-radius: 10px; object-fit: cover; color: var(--blue); background: var(--blue-soft); font-weight: 900; }
.product-summary { display: block; max-width: 320px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; }
.empty-thumb { font-size: 18px; }

.login-body { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(135deg, #eef3ff 0, #f7f9fd 48%, #eef5ff 100%); }
.login-card { width: min(430px, 100%); padding: 36px; border: 1px solid var(--border); border-radius: 18px; background: #fff; box-shadow: 0 18px 60px rgba(30, 64, 175, .12); }
.login-mark { display: grid; width: 46px; height: 46px; margin-bottom: 22px; place-items: center; border-radius: 13px; color: #fff; background: linear-gradient(145deg, var(--blue), var(--blue-dark)); font-size: 22px; font-weight: 900; }
.login-card h1 { margin: 6px 0 8px; font-size: 28px; line-height: 1.3; }
.login-card p { margin: 0 0 24px; color: var(--muted); }
.login-card label { display: grid; gap: 7px; margin: 14px 0; font-weight: 650; }
.login-card .primary { width: 100%; height: 44px; margin-top: 10px; }
.form-error { min-height: 22px; margin-top: 10px; color: var(--red); }

#toast { position: fixed; right: 24px; bottom: 24px; z-index: 60; max-width: min(420px, calc(100vw - 48px)); padding: 12px 16px; border-radius: 10px; color: #fff; background: #1d2939; box-shadow: var(--shadow); opacity: 0; transform: translateY(10px); transition: .2s; pointer-events: none; }
#toast.show { opacity: 1; transform: none; }
@media (max-width: 1200px) { .dashboard-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); } .dashboard-main-grid { grid-template-columns: 1fr; } }
@media (max-width: 1100px) { .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); } .inline-form, .filter-form { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); box-shadow: 18px 0 50px rgba(29, 41, 57, .16); transition: transform .2s ease; }
  .nav-open .sidebar { transform: none; }
  .nav-open::after { content: ""; position: fixed; inset: 0; z-index: 20; background: rgba(29, 41, 57, .32); }
  .main { margin-left: 0; }
  .content { padding: 78px 20px 40px; }
  .menu-button { position: fixed; top: 18px; left: 18px; z-index: 45; display: grid; width: 42px; height: 42px; place-content: center; gap: 4px; border: 1px solid var(--border); border-radius: 10px; background: #fff; box-shadow: var(--shadow); cursor: pointer; }
  .menu-button span { display: block; width: 18px; height: 2px; border-radius: 2px; background: var(--text); }
}
@media (max-width: 600px) {
  .content { padding-right: 16px; padding-left: 16px; }
  .page-head { align-items: flex-start; flex-direction: column; gap: 14px; }
  .page-head h1 { font-size: 25px; }
  .metrics, .inline-form, .settings-grid, .product-form { grid-template-columns: 1fr; }
  .settings-grid .wide, .product-form .wide { grid-column: auto; }
  .metric { min-height: 116px; padding: 18px; }
  .metric strong { font-size: 28px; }
  .panel-head, .form-panel, .settings-panel { padding: 17px; }
  th, td { padding: 12px 14px; }
  .form-actions { align-items: stretch; flex-direction: column; }
  .login-card { padding: 28px 22px; }
  .filter-overview { align-items: flex-start; flex-direction: column; }
  .period-tabs { width: 100%; }
  .period-tabs a { flex: 1; }
  .filter-form, .dashboard-metrics, .activity-grid { grid-template-columns: 1fr; }
  .filter-actions { align-items: stretch; flex-direction: column; }
  .filter-actions > * { width: 100%; }
  .trend-chart { gap: 3px; padding-right: 12px; padding-left: 12px; }
  .activity-list article { align-items: flex-start; flex-direction: column; gap: 8px; }
  .activity-meta { width: 100%; justify-content: space-between; }
  .security-alert-list article { grid-template-columns: auto minmax(0, 1fr); padding: 14px 17px; }
  .security-alert-list article > a { grid-column: 2; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; } }
