:root {
  --bg: #f3f6f7;
  --side: #0f2f36;
  --side-2: #0b2429;
  --accent: #1a7a7a;
  --accent-2: #b8792a;
  --card: #ffffff;
  --text: #1a2a30;
  --muted: #6a7c82;
  --line: #dce6e8;
  --danger: #c4473a;
  --ok: #2a8f5b;
  --warn: #b8792a;
  --shadow: 0 8px 24px rgba(15, 47, 54, 0.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; background: var(--bg); color: var(--text); }
a { color: inherit; text-decoration: none; }
.login-wrap { min-height: 100%; display: grid; place-items: center; background: radial-gradient(900px 420px at 15% 0%, #1a7a7a33, transparent), linear-gradient(160deg, #0f2f36, #143a42); }
.login-card { width: 420px; background: #fff; border-radius: 16px; padding: 36px 32px; box-shadow: 0 20px 50px #0004; }
.login-card h1 { margin: 0 0 6px; font-size: 22px; }
.login-card p { margin: 0 0 22px; color: var(--muted); font-size: 13px; }
.login-card label { display: block; font-size: 13px; margin: 12px 0 6px; }
.login-card input { width: 100%; height: 40px; border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; }
.login-card button { width: 100%; margin-top: 18px; height: 42px; border: 0; border-radius: 8px; background: var(--accent); color: #fff; font-size: 15px; cursor: pointer; }
.demo { margin-top: 16px; font-size: 12px; color: var(--muted); line-height: 1.7; background: #f6fafb; padding: 10px 12px; border-radius: 8px; }
.error { color: var(--danger); font-size: 13px; margin-top: 8px; }

.app { display: grid; grid-template-columns: 228px 1fr; min-height: 100%; }
.side { background: linear-gradient(180deg, var(--side), var(--side-2)); color: #d7ecec; padding: 18px 12px 28px; }
.brand { padding: 8px 12px 16px; font-weight: 700; letter-spacing: .3px; font-size: 16px; }
.brand small { display: block; font-weight: 400; opacity: .65; margin-top: 6px; font-size: 12px; line-height: 1.4; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-group { margin: 14px 12px 6px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; opacity: .45; }
.side a { display: block; padding: 10px 12px; border-radius: 8px; color: #d7ecec; font-size: 14px; }
.side a.active, .side a:hover { background: #ffffff18; color: #fff; }

.main { display: flex; flex-direction: column; min-width: 0; }
.top { min-height: 58px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 10px 24px; gap: 12px; }
.page-title { font-size: 17px; font-weight: 650; color: #12343c; }
.userbox { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.userbox b { color: var(--text); }
.top-link:hover { color: var(--accent); }
.license-pill {
  font-size: 12px;
  color: #0f766e;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.role-pill { display: inline-block; padding: 2px 8px; border-radius: 999px; background: #e8f3f3; color: #1a5f5f; font-size: 12px; }
.badge { display: inline-block; min-width: 16px; padding: 0 5px; margin-left: 4px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 11px; line-height: 16px; text-align: center; }
.sep { opacity: .35; }
.content { padding: 20px 24px 48px; max-width: none; min-width: 0; }

.flash { position: relative; padding: 12px 36px 12px 14px; border-radius: 10px; margin-bottom: 14px; border: 1px solid transparent; white-space: pre-wrap; line-height: 1.55; font-size: 13px; }
.flash.ok { background: #e7f6ee; color: #1a2a30; border-color: #c6e6d3; }
.flash.error { background: #fdecea; color: #8f2d24; border-color: #f3c6c1; }
.flash.info { background: #eef5f8; color: #2a4d57; border-color: #d3e3ea; }
.flash-close {
  position: absolute; top: 6px; right: 8px;
  width: 28px; height: 28px; border: 0; border-radius: 6px;
  background: transparent; color: inherit; opacity: .55;
  font-size: 20px; line-height: 1; cursor: pointer;
}
.flash-close:hover { opacity: 1; background: rgba(0,0,0,.06); }
.flash-body { white-space: pre-wrap; }

.cards { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.card { background: var(--card); border-radius: 12px; padding: 16px 18px; border: 1px solid var(--line); box-shadow: var(--shadow); }
.card .k { font-size: 12px; color: var(--muted); }
.card .v { font-size: 24px; font-weight: 700; margin-top: 8px; }
.card h3 { margin: 0 0 10px; font-size: 15px; color: #12343c; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 14px; align-items: center; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.page-desc { margin: -6px 0 14px; color: var(--muted); font-size: 13px; line-height: 1.5; }

input, select, textarea { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: inherit; background: #fff; color: var(--text); }
.btn { display: inline-flex; align-items: center; justify-content: center; height: 36px; padding: 0 14px; border-radius: 8px; border: 0; background: var(--accent); color: #fff; cursor: pointer; font-size: 13px; white-space: nowrap; }
.btn:hover { filter: brightness(1.05); }
.btn.gray { background: #5d7178; }
.btn.gold { background: var(--accent-2); }
.btn.red { background: var(--danger); }
.btn.line { background: #fff; color: var(--text); border: 1px solid var(--line); }

.table-wrap, .table-scroll { width: 100%; max-width: 100%; overflow-x: auto; }
.table-wrap { background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.table-wrap::-webkit-scrollbar, .table-scroll::-webkit-scrollbar { height: 12px; }
.table-wrap::-webkit-scrollbar-thumb, .table-scroll::-webkit-scrollbar-thumb { background: #b7c9cc; border-radius: 6px; }
table { width: 100%; min-width: max-content; border-collapse: collapse; background: #fff; }
th, td { white-space: nowrap; vertical-align: middle; padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; font-size: 13px; }
th { background: #f5f9fa; color: #4a6066; font-weight: 600; }
.goods-table .clip { max-width: none; overflow: visible; text-overflow: clip; }
.msg-table .msg-body { white-space: nowrap; max-width: none; word-break: normal; }
.staff-ops { flex-wrap: nowrap; }
.tag, .hint-ok, .hint-low, .hint-none { white-space: nowrap; display: inline-block; }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: #fafcfc; }

.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; }
.tag.s0 { background: #e8f3ff; color: #1d5d9b; }
.tag.s1 { background: #fff4d6; color: #8a5a00; }
.tag.s2 { background: #efe7ff; color: #5b3ea8; }
.tag.s3, .tag.s4 { background: #e7f6ee; color: #1e6b40; }
.tag.s5, .tag.warn { background: #fde8e6; color: #9b2c22; }
.tag.ok { background: #e7f6ee; color: #1e6b40; }

html.in-frame .side { display: none !important; }
html.in-frame .app { display: block; }
html.in-frame .app-frame { display: block; }
html.in-frame .top { display: none !important; }
html.in-frame .content { padding-top: 16px; }

html.is-shell, html.is-shell body { height: 100%; overflow: hidden; }
html.is-shell .app { height: 100%; }
.shell-main { height: 100vh; min-height: 0; }
.tabbar {
  display: flex; align-items: flex-end; gap: 4px;
  background: #fff; border-bottom: 1px solid var(--line);
  padding: 8px 12px 0; overflow-x: auto; flex: 0 0 auto;
}
.tabbar::-webkit-scrollbar { height: 8px; }
.tabbar .ptab {
  display: inline-flex; align-items: center; gap: 6px; max-width: 200px;
  height: 34px; padding: 0 8px 0 12px; border: 1px solid transparent; border-bottom: 0;
  border-radius: 8px 8px 0 0; background: transparent; color: var(--muted);
  cursor: pointer; font: inherit; font-size: 13px; flex: 0 0 auto;
}
.tabbar .ptab.on { background: #e7f3f3; color: #0f5f6b; font-weight: 650; }
.tabbar .ptab span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabbar .ptab .x {
  border: 0; background: transparent; color: inherit; cursor: pointer;
  font-size: 15px; line-height: 1; padding: 0 2px; border-radius: 4px;
}
.tabbar .ptab .x:hover { background: #00000014; }
.tab-frames { flex: 1; position: relative; min-height: 0; background: var(--bg); }
.tab-frames iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: none; background: var(--bg); }
.tab-frames iframe.on { display: block; }

.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.tabs a { display: inline-block; padding: 8px 12px; border-radius: 8px; background: #fff; border: 1px solid var(--line); font-size: 13px; }
.tabs a.on { background: var(--side); color: #fff; border-color: var(--side); }

.grid2 { display: grid; grid-template-columns: 1.15fr .85fr; gap: 14px; }
.modal { position: fixed; inset: 0; background: rgba(8, 16, 20, 0.62); display: none; place-items: center; z-index: 4000; padding: 24px 16px; }
.modal.show { display: grid; }
body.modal-open { overflow: hidden; }
.modal .box {
  width: min(820px, 96vw);
  background: #ffffff;
  color: #1c2b30;
  border-radius: 14px;
  padding: 22px 24px;
  max-height: min(86vh, 760px);
  overflow: auto;
  box-shadow: 0 24px 60px rgba(0,0,0,.35);
  border: 1px solid #d7e2e4;
}
.modal .box h3 { margin: 0 0 14px; color: #12343c; }
.modal .box label.small, .modal .box .small { color: #4a6066; display: block; margin-bottom: 4px; text-align: left; }
.modal .box input, .modal .box select, .modal .box textarea {
  width: 100%;
  background: #fff;
  color: #1c2b30;
  border: 1px solid #c5d4d8;
}
.modal .box .form-grid { text-align: left; }
.modal .box.wide { width: min(1100px, 98vw); }
.modal .box.import-box { width: min(480px, 96vw); padding: 22px 22px 18px; }
.modal .box.notify-box { width: min(460px, 96vw); }
.notify-options { display: flex; flex-direction: column; gap: 8px; margin: 14px 0 16px; text-align: left; }
.notify-options label {
  display: flex; align-items: flex-start; gap: 10px;
  margin: 0; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: #f7fbfb;
  font-size: 14px; line-height: 1.4; color: #1c2b30; cursor: pointer;
}
.modal .box.notify-box .notify-options input { width: 16px; height: 16px; margin-top: 3px; flex: 0 0 auto; }
.notify-options small { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; font-weight: 400; }
.staff-table { width: max-content; min-width: 100%; }
.staff-table th, .staff-table td { white-space: nowrap; vertical-align: middle; }
.staff-ops { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.staff-ops .inline-form { margin: 0; }
.msg-table { width: max-content; min-width: 100%; }
.msg-table th, .msg-table td { white-space: nowrap; vertical-align: middle; }
.msg-table .msg-body { white-space: normal; min-width: 320px; max-width: 560px; word-break: break-word; line-height: 1.5; }
.import-note { margin: 0 0 14px; color: var(--muted); font-size: 13px; line-height: 1.6; text-align: left; }
.import-field { text-align: left; margin-bottom: 12px; }
.import-field label { display: block; font-size: 13px; font-weight: 650; color: #12343c; margin-bottom: 6px; }
.modal .box.import-box .check-row {
  display: flex; align-items: flex-start; gap: 8px;
  margin: 0 0 14px; font-size: 13px; line-height: 1.45; text-align: left; color: #1c2b30;
}
.modal .box.import-box .check-row input { width: 16px; height: 16px; margin-top: 2px; flex: 0 0 auto; }
.modal .box.import-box .file-pick {
  display: flex; align-items: center; gap: 12px;
  border: 1px dashed #b7c9cc; border-radius: 10px; padding: 12px 14px;
  background: #f6fbfb; cursor: pointer; margin: 0 0 16px; text-align: left;
}
.modal .box.import-box .file-pick input { width: auto; max-width: 100%; }
.modal .box.import-box .file-name { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; word-break: break-all; }

.info-list { margin: 0; display: grid; gap: 10px; }
.info-list > div { display: grid; grid-template-columns: 140px 1fr; gap: 8px; align-items: start; padding-bottom: 8px; border-bottom: 1px solid #eef3f4; }
.info-list dt { margin: 0; color: var(--muted); font-size: 12px; }
.info-list dd { margin: 0; font-size: 14px; word-break: break-word; }
.info-list .break { word-break: break-all; }

.batch-bar { position: sticky; top: 0; z-index: 5; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; display: none; align-items: center; gap: 10px; }
.batch-bar.show { display: flex; }
.batch-table-wrap { overflow: auto; max-height: 60vh; border: 1px solid var(--line); border-radius: 8px; }
.batch-table-wrap table { margin: 0; }
.batch-table-wrap th, .batch-table-wrap td { white-space: nowrap; }
.batch-table-wrap input { min-width: 110px; }

.hint-ok { color: var(--ok); }
.hint-low { color: var(--warn); }
.hint-none { color: var(--danger); font-weight: 600; }
.muted { color: var(--muted); font-size: 12px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
.form-grid .full { grid-column: 1 / -1; }
.form-grid input:not([type="checkbox"]):not([type="radio"]),
.form-grid select,
.form-grid textarea { width: 100%; }
.form-grid input[type="checkbox"],
.form-grid input[type="radio"] { width: 16px; height: 16px; margin: 0; flex: 0 0 auto; }
input[name="check_purchase_url"] {
  width: 64ch;
  min-width: 64ch;
  max-width: none;
}
.check-list { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 8px 0 4px; }
.check-list label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; }
.inline-form { display: inline-flex; gap: 6px; align-items: center; margin: 0 6px 6px 0; }
.chart { display: flex; align-items: flex-end; gap: 10px; height: 140px; padding-top: 10px; }
.bar { flex: 1; background: #b7d8d8; border-radius: 6px 6px 0 0; min-height: 6px; position: relative; }
.bar span { position: absolute; bottom: -22px; left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--muted); }

.chart-card .chart-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px;
}
.chart-card .chart-head .k { margin: 0; font-size: 13px; color: var(--muted); }
.chart-total { font-size: 14px; color: var(--text); white-space: nowrap; }
.chart-total b { font-size: 22px; font-weight: 700; color: #0f5f6b; margin: 0 4px; }
.combo-chart {
  position: relative;
  height: 200px;
  margin-top: 4px;
}
.chart-line-svg {
  position: absolute; left: 0; right: 0; top: 0; bottom: 28px;
  width: 100%; height: calc(100% - 28px);
  z-index: 2; pointer-events: none; overflow: visible;
}
.chart-bars {
  position: absolute; inset: 0 0 0 0;
  display: flex; align-items: stretch; gap: 4px;
  z-index: 1;
}
.bar-col {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
}
.bar-val {
  font-size: 11px; font-weight: 700; color: #12343c; line-height: 1.2;
  margin-bottom: 4px; white-space: nowrap;
}
.bar-track {
  width: 100%; height: 160px;
  display: flex; align-items: flex-end; justify-content: center;
}
.bar-col .bar {
  width: 70%; max-width: 28px; flex: none;
  background: linear-gradient(180deg, #3aa0a0, #1a7a7a);
  border-radius: 5px 5px 0 0; min-height: 4px;
}
.bar-date {
  margin-top: 6px; height: 22px;
  font-size: 10px; color: var(--muted);
  transform: rotate(-35deg); transform-origin: center top;
  white-space: nowrap;
}
@media (max-width: 900px) {
  .bar-val { font-size: 10px; }
  .bar-date { font-size: 9px; }
  .chart-total b { font-size: 18px; }
}

.loading-mask {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(10, 24, 28, 0.55);
  display: grid; place-items: center;
  pointer-events: all;
}
.loading-mask[hidden] { display: none !important; }
.loading-box {
  width: min(400px, 92vw);
  background: #fff;
  border-radius: 14px;
  padding: 28px 24px 24px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.loading-locked { user-select: none; }
.spinner {
  width: 42px; height: 42px; margin: 0 auto 14px;
  border: 3px solid #d7e6e8;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 15px; font-weight: 600; color: #12343c; }
.loading-sub { margin-top: 10px; font-size: 12px; color: var(--muted); line-height: 1.5; }
.progress-track {
  margin-top: 18px; height: 8px; border-radius: 999px;
  background: #e6eef0; overflow: hidden;
}
.progress-bar {
  height: 100%; width: 30%; border-radius: 999px;
  background: linear-gradient(90deg, #1a7a7a, #2aa8a0, #1a7a7a);
  background-size: 200% 100%;
  animation: progressSlide 1.4s ease-in-out infinite;
}
@keyframes progressSlide {
  0% { transform: translateX(-120%); width: 35%; }
  50% { width: 55%; }
  100% { transform: translateX(280%); width: 35%; }
}

.rate-today {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: #f7fbfb;
}
.rate-today-main { min-width: 0; }
.rate-today .v { font-size: 28px; font-weight: 700; margin: 6px 0 4px; color: #12343c; }

@media (max-width: 1100px) {
  .cards { grid-template-columns: 1fr 1fr; }
  .app { grid-template-columns: 1fr; }
  .side { display: none; }
  .grid2 { grid-template-columns: 1fr; }
}
