:root {
  --pri: #0b7a6a;
  --pri-d: #08594d;
  --pri-l: #e6f4f1;
  --side: #0f2f2b;
  --side-2: #163f3a;
  --bg: #f3f5f7;
  --card: #ffffff;
  --line: #e5e8ec;
  --line-2: #eef0f3;
  --text: #1f2933;
  --text-2: #52606d;
  --text-3: #8a96a3;
  --red: #d64545;
  --red-l: #fdecec;
  --amber: #c27c0e;
  --amber-l: #fdf3e1;
  --blue: #2563eb;
  --blue-l: #e8effd;
  --green: #138a52;
  --green-l: #e5f5ec;
  --gray-l: #f1f3f5;
  --purple: #7c3aed;
  --purple-l: #f1eafe;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 13px/1.55 -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  color: var(--text); background: var(--bg);
}
a { color: var(--pri); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* ---------------- 登录 */
.login {
  min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr;
  background: #fff;
}
.login-hero {
  background: linear-gradient(150deg, #0b7a6a 0%, #0f2f2b 100%);
  color: #fff; padding: 64px 72px; display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.login-hero::after {
  content: ""; position: absolute; right: -120px; bottom: -120px; width: 420px; height: 420px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.14), rgba(255,255,255,0) 70%);
}
.login-hero h1 { font-size: 30px; margin: 18px 0 10px; letter-spacing: 1px; }
.login-hero p { opacity: .85; max-width: 440px; font-size: 14px; }
.login-hero ul { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 12px; }
.login-hero li { display: flex; gap: 10px; align-items: center; opacity: .92; }
.login-hero li b { width: 22px; height: 22px; border-radius: 6px; background: rgba(255,255,255,.18); display: grid; place-items: center; font-size: 12px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.logo-mark { width: 34px; height: 34px; border-radius: 9px; background: #fff; color: var(--pri); display: grid; place-items: center; font-size: 18px; font-weight: 800; }
.login-panel { display: grid; place-items: center; padding: 40px; }
.login-box { width: 360px; }
.login-box h2 { font-size: 22px; margin: 0 0 6px; }
.login-box .sub { color: var(--text-3); margin-bottom: 26px; }
.login-box .field { margin-bottom: 14px; }
.login-box .field label { display: block; margin-bottom: 6px; color: var(--text-2); }
.login-box input { width: 100%; height: 40px; }
.btn-oneid { width: 100%; height: 42px; margin-bottom: 18px; font-size: 14px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--text-3); margin: 6px 0 18px; font-size: 12px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.demo-accounts { margin-top: 20px; padding: 12px 14px; background: var(--gray-l); border-radius: 8px; color: var(--text-2); font-size: 12px; }
.demo-accounts code { background: #fff; padding: 1px 6px; border-radius: 4px; border: 1px solid var(--line); cursor: pointer; }

/* ---------------- 布局 */
.app { display: grid; grid-template-columns: 216px 1fr; min-height: 100vh; }
.side { background: var(--side); color: #c9d6d3; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .logo { color: #fff; padding: 18px 18px 14px; }
.side .logo-mark { width: 30px; height: 30px; font-size: 15px; }
.nav-group { padding: 8px 0 4px; }
.nav-title { font-size: 11px; color: #7f9a95; padding: 6px 20px; letter-spacing: 1px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 20px; color: #c9d6d3; text-decoration: none; position: relative;
  border-left: 3px solid transparent;
}
.nav a:hover { background: var(--side-2); color: #fff; }
.nav a.on { background: rgba(11, 122, 106, .35); color: #fff; border-left-color: #3fd1b5; }
.nav a .ico { width: 16px; text-align: center; opacity: .9; }
.nav a .badge { margin-left: auto; background: #e55353; color: #fff; border-radius: 10px; font-size: 11px; padding: 0 6px; line-height: 17px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.top {
  height: 54px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 16px; padding: 0 22px;
  position: sticky; top: 0; z-index: 20;
}
.top h1 { font-size: 16px; margin: 0; font-weight: 600; }
.top .crumb { color: var(--text-3); font-size: 12px; }
.top .spacer { flex: 1; }
.gsearch { position: relative; width: 300px; }
.gsearch input { width: 100%; height: 32px; padding-left: 30px; background: var(--gray-l); border-color: transparent; }
.gsearch::before { content: "⌕"; position: absolute; left: 10px; top: 5px; color: var(--text-3); font-size: 15px; }
.user-chip { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px 8px; border-radius: 8px; position: relative; }
.user-chip:hover { background: var(--gray-l); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--pri); color: #fff; display: grid; place-items: center; font-weight: 600; }
.user-menu { position: absolute; right: 0; top: 42px; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.1); min-width: 160px; padding: 6px; display: none; }
.user-chip.open .user-menu { display: block; }
.user-menu a { display: block; padding: 7px 10px; color: var(--text); border-radius: 6px; }
.user-menu a:hover { background: var(--gray-l); text-decoration: none; }
.page { padding: 18px 22px 40px; }

/* ---------------- 通用组件 */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line-2); }
.card-h h3 { margin: 0; font-size: 14px; font-weight: 600; }
.card-h .more { margin-left: auto; font-size: 12px; }
.card-b { padding: 14px 16px; }
.card + .card { margin-top: 14px; }
.grid > .card + .card, .role-cards > .card + .card { margin-top: 0; }

input[type=text], input[type=password], input[type=number], input[type=date], input:not([type]), select, textarea {
  height: 32px; padding: 0 10px; border: 1px solid #d3d8de; border-radius: 6px; background: #fff; outline: none; min-width: 0;
}
textarea { height: auto; min-height: 64px; padding: 6px 10px; resize: vertical; width: 100%; }
input:focus, select:focus, textarea:focus { border-color: var(--pri); box-shadow: 0 0 0 3px rgba(11,122,106,.12); }
input:disabled, select:disabled, textarea:disabled { background: #f7f8fa; color: var(--text-2); }

.btn {
  height: 32px; padding: 0 14px; border-radius: 6px; border: 1px solid #d3d8de; background: #fff; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; text-decoration: none !important; color: var(--text);
}
.btn:hover { border-color: var(--pri); color: var(--pri); }
.btn.pri { background: var(--pri); border-color: var(--pri); color: #fff; }
.btn.pri:hover { background: var(--pri-d); color: #fff; }
.btn.danger { color: var(--red); border-color: #f0c2c2; }
.btn.danger:hover { background: var(--red-l); }
.btn.warn { color: var(--amber); border-color: #f0d9a8; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { height: 26px; padding: 0 9px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.link { color: var(--pri); cursor: pointer; background: none; border: 0; padding: 0; }
.link.red { color: var(--red); }
.link + .link { margin-left: 10px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar .spacer { flex: 1; }
.toolbar input[type=text], .toolbar input:not([type]) { width: 220px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs a { padding: 9px 14px; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; text-decoration: none; }
.tabs a:hover { color: var(--pri); }
.tabs a.on { color: var(--pri); border-bottom-color: var(--pri); font-weight: 600; }
.tabs a .n { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px; background: var(--gray-l); color: var(--text-2); font-size: 11px; text-align: center; font-weight: 400; }
.tabs a.on .n { background: var(--pri-l); color: var(--pri); }
.tabs a .n.hot { background: var(--red-l); color: var(--red); }

.tag { display: inline-block; padding: 0 7px; border-radius: 4px; font-size: 12px; line-height: 20px; white-space: nowrap; background: var(--gray-l); color: var(--text-2); }
.tag.green { background: var(--green-l); color: var(--green); }
.tag.red { background: var(--red-l); color: var(--red); }
.tag.amber { background: var(--amber-l); color: var(--amber); }
.tag.blue { background: var(--blue-l); color: var(--blue); }
.tag.purple { background: var(--purple-l); color: var(--purple); }
.tag.teal { background: var(--pri-l); color: var(--pri); }

table.t { width: 100%; border-collapse: collapse; background: #fff; }
table.t th, table.t td { padding: 9px 10px; border-bottom: 1px solid var(--line-2); text-align: left; vertical-align: middle; }
table.t td { white-space: nowrap; }
table.t td.wrap { white-space: normal; min-width: 160px; max-width: 300px; }
table.t th { background: #f8fafb; color: var(--text-2); font-weight: 500; font-size: 12px; white-space: nowrap; position: sticky; top: 0; }
table.t tbody tr:hover { background: #fafcfc; }
table.t td.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.t td.c, table.t th.c { text-align: center; }
table.t .sub { color: var(--text-3); font-size: 12px; }
table.t tr.expand > td { background: #fbfcfd; padding: 0 10px 10px 34px; }
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.tbl-wrap table.t tr:last-child td { border-bottom: 0; }
.empty { text-align: center; padding: 42px 0; color: var(--text-3); }
.pager { display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding: 10px 2px; color: var(--text-2); }

.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g-73 { grid-template-columns: 1.7fr 1fr; }

/* KPI */
.kpi { padding: 16px 18px; display: flex; gap: 14px; align-items: flex-start; }
.kpi .ic { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-size: 18px; flex: none; }
.kpi .lbl { color: var(--text-2); }
.kpi .val { font-size: 24px; font-weight: 700; margin: 2px 0; font-variant-numeric: tabular-nums; }
.kpi .val small { font-size: 13px; font-weight: 500; color: var(--text-2); margin-left: 2px; }
.kpi .ft { color: var(--text-3); font-size: 12px; }
.alert-tiles { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.atile { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; cursor: pointer; background: #fff; transition: .15s; }
.atile:hover { border-color: var(--pri); transform: translateY(-1px); }
.atile .n { font-size: 22px; font-weight: 700; }
.atile .l { color: var(--text-2); font-size: 12px; }
.atile.red .n { color: var(--red); }
.atile.amber .n { color: var(--amber); }
.atile.blue .n { color: var(--blue); }
.atile.zero .n { color: var(--text-3); }

.chart { width: 100%; display: block; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.bar-row { display: grid; grid-template-columns: 96px 1fr 90px; gap: 10px; align-items: center; margin: 7px 0; font-size: 12px; }
.bar-row .track { height: 10px; background: var(--gray-l); border-radius: 5px; overflow: hidden; }
.bar-row .fill { height: 100%; border-radius: 5px; background: var(--pri); }
.bar-row .v { text-align: right; color: var(--text-2); font-variant-numeric: tabular-nums; }
.stack { display: flex; height: 18px; border-radius: 4px; overflow: hidden; margin: 8px 0 12px; }
.stack div { height: 100%; }

/* 表单 */
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 18px; }
.form-grid.g2c { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.g4c { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.fi { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.fi.wide { grid-column: span 2; }
.fi.full { grid-column: 1 / -1; }
.fi > label { color: var(--text-2); display: flex; gap: 6px; align-items: center; font-size: 12px; }
.fi > label .req { color: var(--red); font-weight: 700; }
.fi > label .dept { margin-left: auto; font-size: 11px; color: var(--text-3); }
.fi input, .fi select { width: 100%; }
.fi input[type=checkbox], .fi input[type=radio] { width: auto; height: auto; margin: 0; }
.radio-row label { white-space: nowrap; }
.fi .hint { color: var(--text-3); font-size: 11px; }
.fi.miss input, .fi.miss select, .fi.miss textarea, .fi.miss .picker input { border-color: #f0a3a3; background: #fffafa; }
.radio-row { display: flex; gap: 14px; height: 32px; align-items: center; }
.radio-row label { display: flex; gap: 4px; align-items: center; cursor: pointer; }

.prod-head { display: flex; gap: 16px; align-items: center; padding: 16px 18px; }
.prod-head .pic { width: 52px; height: 52px; border-radius: 12px; background: var(--pri-l); color: var(--pri); display: grid; place-items: center; font-size: 22px; font-weight: 700; }
.prod-head h2 { margin: 0; font-size: 18px; }
.prod-head .meta { color: var(--text-2); margin-top: 4px; display: flex; gap: 14px; flex-wrap: wrap; }
.prod-head .acts { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.miss-bar { background: var(--amber-l); color: #8a5a07; padding: 9px 16px; border-top: 1px solid #f3e1bc; font-size: 12px; }
.sticky-foot { position: sticky; bottom: 0; background: rgba(255,255,255,.96); border-top: 1px solid var(--line); padding: 10px 18px; display: flex; gap: 8px; justify-content: flex-end; z-index: 5; }

.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; }

/* 选择器 */
.picker { position: relative; }
.picker input { width: 100%; }
.picker .dd {
  position: absolute; left: 0; right: 0; top: 34px; background: #fff; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 10px 28px rgba(0,0,0,.12); max-height: 280px; overflow-y: auto; z-index: 60; min-width: 320px;
}
.picker .dd div { padding: 7px 10px; cursor: pointer; border-bottom: 1px solid var(--line-2); }
.picker .dd div:hover, .picker .dd div.act { background: var(--pri-l); }
.picker .dd small { color: var(--text-3); margin-left: 6px; }
.picker .dd .none { color: var(--text-3); cursor: default; }

/* 弹窗 */
.mask { position: fixed; inset: 0; background: rgba(15, 23, 32, .45); display: flex; align-items: flex-start; justify-content: center; z-index: 100; padding: 6vh 20px; overflow-y: auto; }
.modal { background: #fff; border-radius: 10px; width: 560px; max-width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,.25); display: flex; flex-direction: column; }
.modal-h { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-h h3 { margin: 0; font-size: 15px; }
.modal-h .x { margin-left: auto; border: 0; background: none; font-size: 20px; cursor: pointer; color: var(--text-3); line-height: 1; }
.modal-b { padding: 16px 18px; }
.modal-f { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }

.lines-tbl input, .lines-tbl select { height: 28px; width: 100%; padding: 0 6px; font-size: 12px; }
.lines-tbl input[type=number] { width: 92px; }
.lines-tbl input[type=date] { width: 128px; }
.lines-tbl .picker { min-width: 230px; }
.lines-tbl select[data-f=batch_id] { min-width: 250px; }
.lines-tbl td { padding: 5px 6px !important; }
.lines-tbl .picker .dd { top: 30px; }

/* 导入 */
.drop {
  display: block; border: 2px dashed #c8d1d9; border-radius: 10px; padding: 34px; text-align: center; color: var(--text-2); background: #fafbfc; cursor: pointer;
}
.drop:hover, .drop.over { border-color: var(--pri); background: var(--pri-l); }
.drop b { font-size: 15px; color: var(--text); display: block; margin-bottom: 6px; }
.steps { display: flex; gap: 0; margin-bottom: 16px; }
.steps div { flex: 1; padding: 10px 14px; background: #fff; border: 1px solid var(--line); color: var(--text-3); position: relative; }
.steps div:first-child { border-radius: 8px 0 0 8px; }
.steps div:last-child { border-radius: 0 8px 8px 0; }
.steps div.on { color: var(--pri); border-color: var(--pri); background: var(--pri-l); font-weight: 600; z-index: 1; }
.steps div.done { color: var(--green); }

/* toast */
.toasts { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 200; display: grid; gap: 8px; }
.toast { background: #1f2933; color: #fff; padding: 9px 16px; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.18); max-width: 560px; }
.toast.err { background: #b42318; }
.toast.ok { background: #087443; }

.muted { color: var(--text-3); }
.red { color: var(--red); }
.amber { color: var(--amber); }
.green { color: var(--green); }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.mt { margin-top: 14px; }
.dict-layout { display: grid; grid-template-columns: 260px 1fr; gap: 14px; }
.dict-list a { display: flex; padding: 8px 14px; color: var(--text); border-bottom: 1px solid var(--line-2); text-decoration: none; }
.dict-list a:hover { background: var(--gray-l); }
.dict-list a.on { background: var(--pri-l); color: var(--pri); font-weight: 600; }
.dict-list a span { margin-left: auto; color: var(--text-3); font-weight: 400; }
.role-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.role-cards .card { padding: 12px 14px; box-shadow: none; }
.role-cards .card b { display: block; margin-bottom: 6px; }

@media (max-width: 1280px) {
  .alert-tiles { grid-template-columns: repeat(3, 1fr); }
  .g4 { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
