:root {
  --bg: #f6f7f4;
  --surface: #ffffff;
  --text: #1f2528;
  --muted: #687276;
  --line: #dce3df;
  --primary: #24745a;
  --primary-dark: #185640;
  --warn: #b84d42;
  --blue: #3f6d95;
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #1f2b2c;
  color: #fff;
  padding: 24px 16px;
}

.brand {
  display: grid;
  gap: 4px;
  margin-bottom: 26px;
}

.brand strong {
  font-size: 20px;
}

.brand span {
  color: #b7c7c2;
  font-size: 13px;
}

nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  border: 0;
  border-radius: 8px;
  min-height: 42px;
  padding: 0 12px;
  text-align: left;
  background: transparent;
  color: #d5dfdc;
}

.nav-item.active,
.nav-item:hover {
  background: #314243;
  color: #fff;
}

.main {
  padding: 24px;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 22px;
}

.topbar h1,
.topbar p,
.panel h2,
.login-card h2 {
  margin: 0;
}

.userbar {
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.hidden {
  display: none !important;
}

.login-panel {
  display: grid;
  place-items: center;
  min-height: 70vh;
}

.login-card,
.panel,
.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 16px 40px rgba(38, 49, 45, 0.1);
}

.login-card {
  width: min(420px, 100%);
  padding: 24px;
}

label {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

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

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(36, 116, 90, 0.12);
}

.actions,
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary,
.ghost {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 14px;
}

.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-weight: 700;
}

.primary:hover {
  background: var(--primary-dark);
}

.ghost {
  background: #fff;
  color: var(--text);
  border-color: var(--line);
}

.ghost:hover {
  color: var(--primary);
  border-color: var(--primary);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.metric {
  padding: 18px;
}

.metric span {
  color: var(--muted);
}

.metric strong {
  display: block;
  font-size: 32px;
  margin-top: 6px;
}

.dashboard-detail {
  margin-top: 16px;
}

.dashboard-detail .toolbar {
  align-items: center;
}

.dashboard-detail select,
.dashboard-detail input {
  width: auto;
  min-width: 150px;
}

.panel {
  padding: 18px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.split {
  display: grid;
  grid-template-columns: minmax(300px, 0.8fr) minmax(0, 1.2fr);
  gap: 16px;
}

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

.wide {
  grid-column: 1 / -1;
}

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

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

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

th {
  color: var(--muted);
  font-size: 13px;
}

td .primary,
td .ghost {
  min-height: 34px;
  padding: 0 10px;
  margin-right: 6px;
}

.table-select {
  min-height: 34px;
  width: 110px;
  padding: 0 8px;
  border-radius: 6px;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  background: #eef3ef;
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 700;
}

.pill.warn {
  color: var(--warn);
  background: #f8e8e4;
}

.pill.blue {
  color: var(--blue);
  background: #e5edf5;
}

.task-list {
  display: grid;
  gap: 12px;
}

.task-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.task-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 12px;
}

.task-photo {
  display: block;
  width: 180px;
  height: 120px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 12px;
}

.reject-box {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.product-thumb {
  display: block;
  width: 56px;
  height: 56px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef3ef;
  cursor: zoom-in;
}

.product-thumb.empty {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  cursor: default;
}

.floating-image-preview {
  position: fixed;
  left: 18px;
  top: 18px;
  z-index: 9999;
  width: 280px;
  max-height: 320px;
  padding: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 44px rgba(31, 43, 44, 0.22);
  pointer-events: none;
}

.floating-image-preview img {
  display: block;
  width: 100%;
  max-height: 300px;
  object-fit: contain;
  background: #fff;
}

.manual-download {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10000;
  display: flex;
  gap: 10px;
  align-items: center;
  max-width: min(520px, calc(100vw - 36px));
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 14px 38px rgba(31, 43, 44, 0.2);
  color: var(--text);
  font-size: 14px;
}

.manual-download a {
  color: var(--primary);
  font-weight: 700;
  text-decoration: none;
}

.manual-download button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
}

.manual-download .primary {
  min-height: 30px;
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
}

.image-preview {
  display: grid;
  place-items: center;
  min-height: 160px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #f8faf8;
  color: var(--muted);
  overflow: hidden;
}

.image-preview img {
  width: 100%;
  max-height: 240px;
  object-fit: contain;
  background: #fff;
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
  }

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

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

.icp-footer {
  margin: 24px 0 8px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

.icp-footer a {
  color: var(--muted);
  text-decoration: none;
}

.icp-footer a:hover {
  color: var(--primary);
}
