:root {
  --bg: #f6f5f1;
  --panel: #ffffff;
  --panel-soft: #fbfaf6;
  --ink: #252522;
  --muted: #6c6a61;
  --line: #dfdacf;
  --green: #237a57;
  --green-soft: #e6f2eb;
  --amber: #b7791f;
  --amber-soft: #fbefd8;
  --red: #bd3d32;
  --red-soft: #f8e4e2;
  --teal: #237b80;
  --teal-soft: #e2f2f3;
  --violet: #635b95;
  --violet-soft: #eeecf7;
  --shadow: 0 14px 40px rgba(51, 47, 39, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px 18px;
  background: #2f332d;
  color: #f8f5ea;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 54px;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius);
  background: #fff7df;
  color: #2f332d;
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.brand p,
.eyebrow {
  margin: 3px 0 0;
  color: rgba(248, 245, 234, 0.72);
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-btn {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: var(--radius);
  padding: 9px 10px;
  background: transparent;
  color: rgba(248, 245, 234, 0.78);
  text-align: left;
}

.nav-btn:hover,
.nav-btn.active {
  background: rgba(255, 255, 255, 0.11);
  color: #fffdf6;
}

.nav-icon {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 13px;
}

.nav-count {
  min-width: 24px;
  border-radius: 999px;
  padding: 2px 7px;
  background: rgba(255, 255, 255, 0.14);
  font-size: 12px;
  text-align: center;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: var(--radius);
  color: rgba(248, 245, 234, 0.78);
  font-size: 13px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #7bd397;
}

.main {
  min-width: 0;
  padding: 24px clamp(16px, 3vw, 34px) 36px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 70px;
}

.topbar .eyebrow,
.drawer .eyebrow {
  color: var(--muted);
}

.topbar h2 {
  margin: 4px 0 0;
  font-size: clamp(24px, 3vw, 34px);
  letter-spacing: 0;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.search-box {
  display: grid;
  grid-template-columns: 24px minmax(120px, 240px);
  align-items: center;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 10px;
  background: var(--panel);
  color: var(--muted);
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.icon-btn,
.primary-btn,
.ghost-btn,
.small-btn {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
}

.icon-btn {
  width: 40px;
  padding: 0;
  font-size: 18px;
}

.primary-btn {
  padding: 0 15px;
  border-color: #2f332d;
  background: #2f332d;
  color: #fffdf6;
  font-weight: 700;
}

.ghost-btn,
.small-btn {
  padding: 0 12px;
}

.small-btn {
  min-height: 32px;
  font-size: 13px;
}

.notice-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  margin: 12px 0 18px;
  border: 1px solid #ead8aa;
  border-radius: var(--radius);
  padding: 10px 14px;
  background: #fff8e8;
  color: #5e4822;
}

.content-area {
  display: grid;
  gap: 18px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.metric-card,
.panel,
.data-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric-card {
  min-height: 128px;
  padding: 16px;
}

.metric-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.metric-value {
  margin: 18px 0 8px;
  font-size: 28px;
  font-weight: 800;
  line-height: 1.1;
}

.metric-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.trend-up {
  color: var(--green);
}

.trend-down {
  color: var(--red);
}

.section-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.8fr);
  gap: 14px;
}

.panel {
  min-width: 0;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
}

.panel-head h3 {
  margin: 0;
  font-size: 17px;
}

.panel-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.panel-body {
  padding: 16px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.filters select,
.filters input {
  min-height: 36px;
  max-width: 220px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 10px;
  background: #fff;
  color: var(--ink);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 780px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

td {
  font-size: 14px;
}

tr:hover td {
  background: #fbfaf6;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 700;
}

.tag.green {
  background: var(--green-soft);
  color: var(--green);
}

.tag.amber {
  background: var(--amber-soft);
  color: var(--amber);
}

.tag.red {
  background: var(--red-soft);
  color: var(--red);
}

.tag.teal {
  background: var(--teal-soft);
  color: var(--teal);
}

.tag.violet {
  background: var(--violet-soft);
  color: var(--violet);
}

.task-list,
.rank-list,
.timeline {
  display: grid;
  gap: 10px;
}

.task-item,
.rank-item,
.timeline-item {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--panel-soft);
}

.task-item {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.task-title,
.rank-title {
  margin: 0;
  font-weight: 700;
}

.task-meta,
.rank-meta,
.timeline-meta {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.bar-row {
  display: grid;
  grid-template-columns: 110px 1fr 70px;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
}

.bar-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #ece8dc;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.stock-cell {
  display: grid;
  grid-template-columns: minmax(60px, 1fr) 80px;
  align-items: center;
  gap: 8px;
}

.stock-meter {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #eee9dc;
}

.stock-meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.stock-meter.low span {
  background: var(--red);
}

.stock-meter.mid span {
  background: var(--amber);
}

.split-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: var(--muted);
  font-size: 13px;
}

.field input,
.field select,
.field textarea {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
}

.field textarea {
  min-height: 78px;
  resize: vertical;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(33, 31, 25, 0.24);
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 21;
  display: grid;
  grid-template-rows: auto 1fr;
  width: min(520px, 100vw);
  height: 100vh;
  border-left: 1px solid var(--line);
  background: #fff;
  box-shadow: -18px 0 50px rgba(39, 37, 31, 0.18);
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding: 18px;
}

.drawer-head h3 {
  margin: 4px 0 0;
}

.drawer-body {
  overflow: auto;
  padding: 18px;
}

.detail-list {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 10px;
}

.detail-list dt {
  color: var(--muted);
}

.detail-list dd {
  margin: 0;
  font-weight: 700;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 30;
  max-width: min(360px, calc(100vw - 44px));
  transform: translateY(18px);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: #2f332d;
  color: #fffdf6;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 28px;
  background: var(--panel-soft);
  text-align: center;
}

.empty-state h3 {
  margin: 0 0 8px;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 82px minmax(0, 1fr);
  }

  .brand h1,
  .brand p,
  .nav-btn span:not(.nav-icon):not(.nav-count),
  .sidebar-footer span:last-child {
    display: none;
  }

  .sidebar {
    padding: 18px 12px;
  }

  .nav-btn {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .nav-count {
    display: none;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .section-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: relative;
    width: 100%;
    height: auto;
  }

  .nav-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .nav-btn {
    grid-template-columns: 28px 1fr;
    justify-items: start;
  }

  .nav-btn span:not(.nav-icon):not(.nav-count) {
    display: inline;
  }

  .topbar,
  .top-actions,
  .notice-strip {
    align-items: stretch;
    flex-direction: column;
  }

  .search-box {
    grid-template-columns: 24px 1fr;
  }

  .metric-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 88px 1fr 54px;
  }
}
