:root {
  color-scheme: light;
  --ink: #172b2b;
  --muted: #596a6a;
  --line: #dce6e3;
  --green: #13684f;
  --green-dark: #0c4e3c;
  --pale: #e8f5ee;
  --paper: #fff;
  --canvas: #f4f7f6;
  font-family: "Segoe UI", "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
  font-size: 16px;
  background: var(--canvas);
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; }
h1, h2, h3, p { margin: 0; }
a { color: var(--green-dark); }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:disabled { opacity: .65; cursor: wait; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid #50a98e; outline-offset: 2px;
}
.loading { padding: 2.5rem; }
.shell { display: grid; grid-template-columns: 222px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: #172c2d; color: #eef8f3; display: flex; flex-direction: column; padding: 26px 17px 18px; min-height: 100vh; }
.brand { display: flex; gap: 11px; align-items: center; font-size: 1.14rem; font-weight: 740; margin: 3px 9px 32px; letter-spacing: .04em; }
.mark { width: 34px; height: 34px; border-radius: 10px; background: #b3ebcf; color: #173c32; display: grid; place-items: center; font-weight: 800; line-height: 1; }
.sidebar nav { display: grid; gap: 6px; }
.nav { color: #d0e0dc; border: 0; padding: 12px 13px; width: 100%; text-align: left; border-radius: 8px; background: transparent; display: flex; gap: 10px; align-items: center; font-size: .94rem; }
.nav:hover { background: #243e3d; color: #fff; }
.nav.active { font-weight: 700; background: #294744; color: #edfff4; box-shadow: inset 3px 0 #a8e9c9; }
.nav-icon { width: 16px; color: #a8e9c9; text-align: center; font-size: .95rem; }
.sidebar-foot { margin-top: auto; padding: 20px 9px 0; color: #b8cdca; font-size: .82rem; }
.main { min-width: 0; }
.top { display: flex; padding: 12px clamp(18px, 3.4vw, 50px); min-height: 66px; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); background: #fff; }
.top > strong { font-size: .9rem; color: var(--muted); white-space: nowrap; }
.user { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 8px; font-size: .86rem; }
.content { max-width: 1570px; margin: 0 auto; padding: 29px clamp(18px, 3.4vw, 50px) 45px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 23px; }
h1 { font-size: clamp(1.65rem, 3vw, 2.1rem); line-height: 1.25; letter-spacing: -.035em; }
.page-head p { color: var(--muted); font-size: .92rem; margin-top: 8px; line-height: 1.6; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.btn { display: inline-flex; min-height: 38px; align-items: center; justify-content: center; padding: 7px 13px; border-radius: 8px; border: 1px solid #cbdad5; background: #fff; color: var(--ink); text-decoration: none; font-size: .88rem; font-weight: 650; white-space: nowrap; }
.btn:hover { background: #eef6f2; }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover { background: var(--green-dark); }
.btn.ghost { border: none; min-height: 33px; padding: 4px 7px; color: var(--green-dark); }
.btn.danger { color: #962f2f; }
.metrics { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 13px; margin-bottom: 20px; }
.metric, .panel { background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.metric { padding: 16px 17px; display: grid; gap: 7px; }
.metric:first-child { background: #edf8f2; border-color: #cde5da; }
.metric span, .muted { color: var(--muted); }
.metric > span { font-size: .89rem; }
.metric strong { font-size: clamp(1.03rem, 2.15vw, 1.62rem); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.035em; overflow-wrap: anywhere; }
.metric small { color: #526a64; font-size: .8rem; }
.panel { margin-bottom: 18px; overflow: hidden; }
.section-head { padding: 16px 17px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.section-head h2 { font-size: 1.02rem; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 0 17px 15px; }
input, select, textarea { width: 100%; min-width: 0; min-height: 40px; border: 1px solid #cbdad5; border-radius: 8px; background: #fff; color: var(--ink); padding: 7px 10px; font-size: .88rem; }
.filters input, .filters select { width: auto; min-height: 36px; }
.filters input[type=search] { flex: 1 1 190px; max-width: 310px; }
.filters input[type=month] { flex: 0 1 154px; }
.filters select { max-width: 160px; }
select { appearance: none; background-image: linear-gradient(45deg,transparent 50%,#506561 50%),linear-gradient(135deg,#506561 50%,transparent 50%); background-position: calc(100% - 14px) 52%,calc(100% - 9px) 52%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 27px; }
textarea { resize: vertical; min-height: 70px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; text-align: left; border-collapse: collapse; font-size: .88rem; }
th { background: #f2f7f5; color: #465d58; font-weight: 660; white-space: nowrap; }
td, th { padding: 11px 13px; border-top: 1px solid #e8eeec; }
td:first-child, th:first-child { padding-left: 17px; }
td:last-child, th:last-child { padding-right: 17px; }
td { vertical-align: middle; min-width: 80px; max-width: 340px; overflow-wrap: anywhere; }
tr:hover td { background: #fafcfb; }
td small { display: block; color: var(--muted); line-height: 1.45; margin-top: 4px; }
.amount { white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
.code { white-space: nowrap; font-variant-numeric: tabular-nums; }
.badge { display: inline-block; padding: 3px 8px; border-radius: 6px; font-size: .81rem; line-height: 1.45; font-weight: 650; white-space: nowrap; background: #edf1f0; color: #445c56; }
.badge.green { background: #e5f3eb; color: #155b41; }
.badge.amber { background: #fff0d5; color: #775016; }
.badge.red { background: #f9e9e7; color: #8e3432; }
.badge.blue { background: #e7f0f8; color: #315775; }
.empty { color: var(--muted); padding: 32px 18px; text-align: center; font-size: .94rem; }
.note { padding: 11px 12px; border-radius: 8px; background: #eef7f2; color: #3b5e51; font-size: .87rem; line-height: 1.6; overflow-wrap: anywhere; }
.note.warning { background: #fff0d8; color: #73511f; }
dialog { border: 1px solid var(--line); border-radius: 15px; padding: 0; max-height: 92dvh; width: min(680px, calc(100% - 22px)); max-width: none; color: var(--ink); box-shadow: 0 22px 80px #17332f38; }
dialog::backdrop { background: #0b1d1c80; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 15px 19px; border-bottom: 1px solid var(--line); background: #fff; position: sticky; top: 0; z-index: 1; }
.dialog-head h2 { font-size: 1.08rem; overflow-wrap: anywhere; }
.dialog-body { padding: 17px 19px 19px; display: grid; gap: 15px; }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
label.field { display: grid; align-content: start; gap: 5px; font-size: .88rem; font-weight: 620; }
.full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 6px; font-size: .88rem; }
.check input { width: auto; min-height: 0; }
.dialog-foot { display: flex; justify-content: flex-end; align-items: center; flex-wrap: wrap; gap: 8px; }
.form-message { color: #962f2f; font-size: .88rem; line-height: 1.5; }
.form-message:empty { display: none; }
.link-list { display: grid; gap: 7px; }
#inventory-filter { display: grid; grid-template-columns: minmax(160px, 1.5fr) minmax(115px, 1fr) minmax(110px, 1fr) auto; }
.link-line { display: grid; grid-template-columns: minmax(0, 1fr) minmax(94px, 140px) auto; align-items: center; gap: 7px; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.section-title h3, .dialog-body h3 { font-size: .94rem; }
.detail-grid { display: grid; grid-template-columns: repeat(2,minmax(0, 1fr)); gap: 11px; margin: 0; }
.detail-grid div { background: #f4f8f6; border-radius: 8px; padding: 10px; overflow-wrap: anywhere; }
.detail-grid dt { font-size: .82rem; color: var(--muted); margin-bottom: 4px; }
.detail-grid dd { margin: 0; font-size: .91rem; }
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 20px; background: radial-gradient(ellipse at 0% 0%, #dcefe5 0, transparent 65%), #edf3f1; }
.login { background: #fff; border: 1px solid #d4e3dd; border-radius: 16px; padding: 26px; width: min(100%, 435px); display: grid; gap: 16px; box-shadow: 0 12px 30px #16393110; }
.login .brand { margin: 0; }
.login form { display: grid; gap: 13px; }
.login h1 { font-size: 1.45rem; }
.login .btn { width: 100%; }
#toast:not(:empty) { position: fixed; background: #21443a; color: #fff; padding: 10px 16px; border-radius: 9px; bottom: 18px; right: 18px; box-shadow: 0 7px 24px #15302746; max-width: calc(100% - 36px); font-size: .9rem; z-index: 5; }
details { max-width: 340px; }
details summary { cursor: pointer; }
details pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .81rem; }
@media (max-width: 950px) {
  .shell { grid-template-columns: 170px minmax(0, 1fr); }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 690px) {
  .shell { display: block; }
  .sidebar { min-height: 0; padding: 11px 13px 8px; }
  .brand { margin: 0 0 10px; }
  .sidebar nav { display: flex; overflow-x: auto; }
  .nav { width: auto; white-space: nowrap; padding: 8px 9px; gap: 5px; }
  .nav.active { box-shadow: inset 0 -3px #a8e9c9; }
  .sidebar-foot { display: none; }
  .top { min-height: 52px; }
  .content { padding: 20px 12px 28px; }
  .page-head { align-items: flex-start; flex-wrap: wrap; margin-bottom: 15px; }
  .metrics { gap: 8px; }
  .metric { padding: 11px; }
  td, th { padding: 9px 10px; }
  #inventory-filter { grid-template-columns: minmax(0,1fr) minmax(0,1fr); }
}
@media (max-width: 420px) {
  .form-grid { grid-template-columns: minmax(0,1fr); }
  .dialog-body, .dialog-head { padding-left: 12px; padding-right: 12px; }
}
