:root {
  --navy: #102a43;
  --navy-deep: #081c2c;
  --blue: #2476ed;
  --blue-soft: #eaf2ff;
  --text: #172b4d;
  --muted: #718096;
  --line: #e5eaf2;
  --surface: #ffffff;
  --background: #f5f7fb;
  --green: #16a36a;
  --orange: #e68a20;
  --red: #e05263;
  --shadow: 0 10px 30px rgba(24, 51, 84, 0.08);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 1100px; color: var(--text); background: var(--background); }
button, input, select { font: inherit; }
button { cursor: pointer; }

.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 232px; flex: 0 0 232px; display: flex; flex-direction: column; color: #d7e3f2; background: linear-gradient(180deg, #102d49 0%, #09243c 100%); }
.brand { height: 78px; display: flex; align-items: center; gap: 12px; padding: 0 21px; border-bottom: 1px solid rgba(255,255,255,.11); }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: #fff; font-weight: 800; font-size: 19px; background: linear-gradient(145deg, #4b9bff, #2463cc); box-shadow: 0 5px 12px rgba(0,0,0,.2); }
.brand strong { display: block; font-size: 16px; letter-spacing: .3px; color: #fff; }
.brand span { display: block; margin-top: 3px; font-size: 11px; color: #9db7d2; }
.sidebar-nav { padding: 18px 12px; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; height: 45px; padding: 0 13px; margin: 4px 0; border: 0; border-radius: 8px; color: #b7cae0; background: transparent; text-align: left; font-size: 14px; transition: background .18s ease, color .18s ease; }
.nav-item span { display: inline-grid; width: 16px; place-items: center; color: #9db5d0; font-size: 18px; }
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { color: #fff; background: #2374df; box-shadow: 0 7px 16px rgba(0,0,0,.12); }
.nav-item.active span { color: #fff; }
.sidebar-foot { margin: auto 20px 20px; padding: 15px 0 0; border-top: 1px solid rgba(255,255,255,.12); }
.environment-badge { display: inline-flex; align-items: center; gap: 6px; color: #cbddf1; font-size: 12px; }
.environment-badge span { width: 7px; height: 7px; border-radius: 50%; background: #3fd58a; }
.sidebar-foot p { margin: 9px 0 0; color: #8ba8c6; font-size: 11px; line-height: 1.65; }
.policy-links { display: flex; gap: 12px; margin-top: 10px; }
.policy-links a { color: #a7bfdb; font-size: 11px; text-decoration: none; }
.policy-links a:hover { color: #fff; text-decoration: underline; }

.main { min-width: 0; flex: 1; }
.topbar { height: 78px; display: flex; align-items: center; justify-content: space-between; padding: 0 34px; border-bottom: 1px solid var(--line); background: var(--surface); }
.breadcrumb { font-weight: 650; font-size: 18px; letter-spacing: .1px; }
.topbar-actions { display: flex; align-items: center; gap: 15px; }
.read-only-badge { padding: 5px 10px; border: 1px solid #cfe0fb; border-radius: 99px; color: #3972be; background: #f5f9ff; font-size: 12px; }
.icon-button { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 1px solid var(--line); border-radius: 8px; color: #5d6d82; background: #fff; font-size: 20px; line-height: 1; }
.icon-button:hover { color: var(--blue); border-color: #afcffa; background: var(--blue-soft); }
.user-chip { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #516175; }
.user-avatar { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; color: #2669cf; background: #e5efff; font-size: 13px; }
.topbar-button { min-height: 32px; padding: 0 10px; font-size: 12px; }
.content { padding: 30px 34px 42px; }

.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 23px; }
.page-heading h1 { margin: 0; color: #102a43; font-size: 22px; font-weight: 700; }
.page-heading p { margin: 8px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.primary-button, .secondary-button { min-height: 37px; padding: 0 14px; border-radius: 7px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.primary-button { border: 1px solid var(--blue); color: #fff; background: var(--blue); box-shadow: 0 4px 9px rgba(36,118,237,.17); }
.primary-button:hover { border-color: #1765d5; background: #1765d5; }
.secondary-button { border: 1px solid #cfd9e8; color: #40546d; background: #fff; }
.secondary-button:hover { border-color: #9ebfe9; color: var(--blue); background: #f8fbff; }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; }

.notice { display: flex; align-items: flex-start; gap: 11px; padding: 13px 15px; margin-bottom: 20px; border: 1px solid #cde0ff; border-radius: 9px; color: #31639c; background: #f1f7ff; font-size: 13px; line-height: 1.6; }
.notice-icon { display: grid; flex: 0 0 auto; place-items: center; width: 18px; height: 18px; margin-top: 1px; border-radius: 50%; color: #fff; background: #5b93e8; font-size: 12px; font-weight: 700; }

.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
.metric-card { min-height: 124px; padding: 18px; border: 1px solid #e7edf5; border-radius: 11px; background: var(--surface); box-shadow: 0 3px 10px rgba(34, 61, 96, .025); }
.metric-label { color: #748399; font-size: 13px; }
.metric-value { margin-top: 14px; color: #152c49; font-size: 25px; font-weight: 720; letter-spacing: .2px; }
.metric-note { margin-top: 8px; color: #91a0b2; font-size: 11px; }
.metric-card.blue-top { border-top: 3px solid #4d93f4; }
.metric-card.green-top { border-top: 3px solid #4fbd8a; }
.metric-card.orange-top { border-top: 3px solid #efa84f; }
.metric-card.purple-top { border-top: 3px solid #9875d9; }
.metric-card.red-top { border-top: 3px solid #ea7986; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(325px, .8fr); gap: 18px; }
.panel { border: 1px solid #e6ecf4; border-radius: 11px; background: #fff; box-shadow: 0 3px 12px rgba(34, 61, 96, .03); }
.panel-head { display: flex; align-items: center; justify-content: space-between; min-height: 57px; padding: 0 20px; border-bottom: 1px solid #edf1f5; }
.panel-head h2 { margin: 0; font-size: 15px; color: #243a57; }
.panel-head span { color: #8e9daf; font-size: 12px; }
.panel-body { padding: 18px 20px; }

.platform-row { display: grid; grid-template-columns: 29px 1fr auto; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid #eff2f6; }
.platform-row:last-child { border-bottom: 0; }
.platform-symbol { display: grid; place-items: center; width: 27px; height: 27px; border-radius: 8px; color: #3566b7; background: #eef4ff; font-size: 12px; font-weight: 700; }
.platform-row strong { display: block; color: #3d5069; font-size: 13px; }
.platform-row small { display: block; margin-top: 3px; color: #98a4b3; font-size: 11px; }
.platform-amount { color: #233e60; font-size: 13px; font-weight: 650; }
.small-link { padding: 0; border: 0; color: var(--blue); background: transparent; font-size: 12px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 15px 18px; border-bottom: 1px solid #edf1f5; }
.toolbar .search-input { min-width: 220px; }
.input, .select, .search-input { height: 36px; padding: 0 10px; border: 1px solid #d9e1eb; border-radius: 7px; outline: none; color: #33485f; background: #fff; font-size: 13px; }
.input:focus, .select:focus, .search-input:focus { border-color: #6fa7f5; box-shadow: 0 0 0 3px rgba(68,137,235,.11); }
.toolbar-spacer { flex: 1; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { height: 42px; padding: 0 16px; color: #8492a4; background: #fafbfd; text-align: left; font-weight: 550; white-space: nowrap; }
td { padding: 13px 16px; border-top: 1px solid #edf1f5; color: #465a73; vertical-align: middle; }
tbody tr:hover { background: #fbfdff; }
.cell-main { display: block; color: #2b405c; font-weight: 600; }
.cell-sub { display: block; margin-top: 4px; color: #96a3b4; font-size: 11px; }
.amount { color: #243d5a; font-weight: 650; }
.muted { color: #91a0b1; }
.empty-state { padding: 48px 20px; color: #90a0b2; text-align: center; }

.badge { display: inline-flex; align-items: center; min-height: 23px; padding: 0 8px; border-radius: 99px; font-size: 11px; font-weight: 650; white-space: nowrap; }
.badge.pending { color: #ad6b16; background: #fff4df; }
.badge.info { color: #3772c2; background: #edf5ff; }
.badge.success { color: #168154; background: #e6f7ef; }
.badge.danger { color: #c14658; background: #ffeaed; }
.badge.neutral { color: #65768b; background: #edf1f5; }

.shop-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.shop-card { position: relative; padding: 20px; overflow: hidden; border: 1px solid #e5ebf3; border-radius: 10px; background: #fff; }
.shop-card::after { position: absolute; top: -26px; right: -18px; width: 95px; height: 95px; border-radius: 50%; background: rgba(60, 135, 237, .04); content: ""; }
.shop-card-top { position: relative; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.shop-platform { display: flex; align-items: center; gap: 10px; }
.shop-platform-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; color: #3e76c3; background: #eef5ff; font-size: 12px; font-weight: 750; }
.shop-platform strong { display: block; color: #2a405c; font-size: 14px; }
.shop-platform span { display: block; margin-top: 3px; color: #97a4b5; font-size: 11px; }
.shop-meta { position: relative; display: grid; grid-template-columns: 91px 1fr; gap: 9px 12px; margin: 18px 0; color: #7d8ca0; font-size: 12px; }
.shop-meta b { color: #455a74; font-weight: 550; }
.shop-actions { position: relative; display: flex; gap: 9px; }

.inventory-summary { display: grid; grid-template-columns: 1.2fr .8fr; gap: 17px; margin-bottom: 18px; }
.compact-stat { display: flex; align-items: center; gap: 13px; padding: 18px; border: 1px solid #e5ecf4; border-radius: 10px; background: #fff; }
.compact-stat-icon { display: grid; place-items: center; width: 39px; height: 39px; border-radius: 10px; color: #2872d5; background: #eaf3ff; font-size: 20px; }
.compact-stat b { display: block; margin-top: 4px; color: #243c59; font-size: 19px; }
.compact-stat span { color: #8593a5; font-size: 12px; }

.integration-flow { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: stretch; gap: 8px; padding: 20px; border: 1px dashed #b7cdec; border-radius: 10px; background: linear-gradient(90deg, #f8fbff, #fff); }
.integration-step { min-height: 119px; padding: 13px; border: 1px solid #e0eaf7; border-radius: 9px; background: #fff; }
.integration-step strong { display: block; color: #334d6c; font-size: 13px; }
.integration-step span { display: block; margin-top: 8px; color: #8494a8; font-size: 11px; line-height: 1.55; }
.integration-step .step-number { display: grid; place-items: center; width: 23px; height: 23px; margin-bottom: 10px; border-radius: 50%; color: #fff; background: #4a89e5; font-size: 11px; }
.scope-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; margin-top: 18px; }
.scope-item { padding: 15px; border: 1px solid #e8edf4; border-radius: 9px; background: #fff; }
.scope-item b { display: block; color: #324a68; font-size: 13px; }
.scope-item p { margin: 7px 0 0; color: #8190a2; font-size: 12px; line-height: 1.58; }
.user-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 17px; margin-bottom: 18px; }
.role-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.role-card { padding: 15px; border: 1px solid #e7edf4; border-radius: 9px; background: #fff; }
.role-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.role-card h3 { margin: 0; color: #314a68; font-size: 14px; }
.role-card p { margin: 9px 0 0; color: #7c8c9f; font-size: 12px; line-height: 1.6; }
.role-code { color: #8897a9; font-size: 10px; letter-spacing: .35px; }
.scope-text { display: block; max-width: 190px; color: #576d87; font-size: 12px; line-height: 1.5; }

.modal { width: min(590px, calc(100vw - 36px)); max-height: calc(100vh - 44px); padding: 0; border: 0; border-radius: 12px; box-shadow: 0 22px 55px rgba(16,42,67,.24); }
.modal::backdrop { background: rgba(11, 33, 55, .46); }
.modal-head { display: flex; align-items: center; justify-content: space-between; min-height: 62px; padding: 0 20px; border-bottom: 1px solid #ebf0f5; }
.modal-head h2 { margin: 0; color: #233c5b; font-size: 16px; }
.modal form, .modal-content { padding: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-field { display: grid; gap: 7px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { color: #53667d; font-size: 12px; font-weight: 600; }
.form-field small { color: #94a1b1; font-size: 11px; line-height: 1.5; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.upload-zone { padding: 25px; border: 1px dashed #aac8ed; border-radius: 9px; color: #7990a9; background: #f8fbff; text-align: center; }
.upload-zone strong { display: block; margin-bottom: 7px; color: #456583; font-size: 13px; }
.import-result { margin-top: 14px; padding: 12px; border-radius: 8px; color: #416a98; background: #eff7ff; font-size: 12px; line-height: 1.65; }

.toast { position: fixed; right: 28px; bottom: 25px; z-index: 20; max-width: 390px; padding: 12px 16px; border-radius: 8px; color: #fff; background: #243f5f; box-shadow: 0 10px 25px rgba(16,42,67,.23); font-size: 13px; opacity: 0; pointer-events: none; transform: translateY(12px); transition: opacity .2s, transform .2s; }
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.error { background: #bb4053; }

body.unauthenticated { min-width: 0; background: linear-gradient(135deg, #eef5ff 0%, #f7f9fc 53%, #ecf4ff 100%); }
.unauthenticated .sidebar, .unauthenticated .topbar { display: none; }
.unauthenticated .main { display: grid; min-height: 100vh; place-items: center; }
.unauthenticated .content { width: min(100%, 470px); padding: 28px; }
.login-card { overflow: hidden; border: 1px solid #dfe9f6; border-radius: 14px; background: #fff; box-shadow: 0 22px 52px rgba(24, 62, 108, .13); }
.login-brand { padding: 27px 29px 23px; color: #fff; background: linear-gradient(135deg, #153b65, #266ec5); }
.login-brand-row { display: flex; align-items: center; gap: 12px; }
.login-brand .brand-mark { width: 38px; height: 38px; background: rgba(255,255,255,.17); box-shadow: none; }
.login-brand h1 { margin: 0; font-size: 20px; }
.login-brand p { margin: 8px 0 0; color: #dcecff; font-size: 12px; line-height: 1.6; }
.login-form { padding: 25px 29px 28px; }
.login-form .form-field { margin-bottom: 15px; }
.login-form .input { width: 100%; height: 40px; }
.login-form .primary-button { width: 100%; height: 40px; margin-top: 6px; }
.login-tip { margin: 17px 0 0; color: #8292a7; font-size: 11px; line-height: 1.65; }
.login-error { display: none; margin: 0 0 14px; padding: 9px 11px; border-radius: 7px; color: #b33c50; background: #fff0f2; font-size: 12px; }
.login-error.visible { display: block; }

@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
}
