:root {
  --bg: #f5f7f8;
  --panel: #ffffff;
  --text: #1d252b;
  --muted: #687782;
  --line: #dce3e7;
  --primary: #256f68;
  --primary-dark: #18564f;
  --accent: #b54836;
  --soft: #e7f2ef;
  --shadow: 0 8px 24px rgba(29, 37, 43, 0.08);
}

* {
  box-sizing: border-box;
}

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

.hidden {
  display: none !important;
}

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

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #f5f7f8 0%, #e8f1ef 100%);
}

.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  padding: 28px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 0;
  font-size: 28px;
}

.login-card p {
  margin: -6px 0 4px;
  color: var(--muted);
}

button,
.button,
input,
select {
  font: inherit;
}

button,
.button {
  border: 0;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  min-height: 38px;
  padding: 0 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

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

button.danger {
  background: var(--accent);
}

button.ghost {
  background: #eef3f4;
  color: var(--text);
}

button.ghost:hover {
  background: #dde8ea;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  min-height: 38px;
  padding: 8px 10px;
  color: var(--text);
}

label {
  display: grid;
  gap: 7px;
  font-size: 13px;
  color: var(--muted);
}

.sidebar {
  min-height: 100vh;
  min-width: 0;
  padding: 24px;
  background: #ffffff;
  border-right: 1px solid var(--line);
  position: sticky;
  top: 0;
  overflow: hidden auto;
}

.brand h1 {
  margin: 0;
  font-size: 24px;
}

.brand p {
  margin: 6px 0 0;
  color: var(--muted);
}

.vendor-form {
  margin: 26px 0 18px;
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 7px;
}

.vendor-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.vendor-card {
  position: relative;
  min-width: 0;
}

.vendor-item {
  width: 100%;
  min-width: 0;
  min-height: 78px;
  padding: 12px;
  display: grid;
  justify-items: start;
  gap: 9px;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  text-align: left;
  overflow: hidden;
}

.vendor-edit {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 34px;
  min-height: 28px;
  padding: 0;
  border-radius: 5px;
  background: #eef3f4;
  color: var(--text);
  font-size: 12px;
}

.vendor-edit:hover {
  background: #dce9e8;
}

.vendor-item:hover,
.vendor-item.active {
  background: var(--soft);
  border-color: #c8ded9;
}

.vendor-item span {
  font-weight: 700;
  width: 100%;
  padding-right: 40px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vendor-item small {
  width: 100%;
  color: var(--muted);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 10px;
  line-height: 1.25;
}

.vendor-item small span {
  min-width: 0;
  display: block;
  padding-right: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.vendor-item small b {
  color: var(--text);
  font-weight: 700;
}

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

.userbar {
  margin-bottom: 16px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
}

.userbar span {
  color: var(--muted);
  font-size: 14px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 14px;
}

.stats-grid article,
.panel,
.toolbar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.stats-grid article {
  padding: 16px;
  display: grid;
  gap: 8px;
}

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

.stats-grid strong {
  font-size: 28px;
  line-height: 1;
}

.toolbar {
  margin-top: 16px;
  padding: 18px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.toolbar h2 {
  margin: 0;
  font-size: 22px;
}

.toolbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.panel {
  margin-top: 16px;
  overflow: hidden;
}

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

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

.panel-head input {
  max-width: 280px;
}

.upload-form {
  padding: 18px;
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(220px, 1.4fr) minmax(160px, 1fr) auto;
  gap: 14px;
  align-items: end;
}

.import-progress {
  padding: 0 18px 18px;
}

.progress-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.progress-head strong {
  color: var(--text);
}

.progress-track {
  margin-top: 8px;
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7ecef;
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 0.2s ease;
}

.table-wrap {
  overflow: auto;
}

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

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  background: #f9fbfb;
  font-size: 13px;
  font-weight: 700;
}

td {
  font-size: 14px;
}

.effect-cell {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto;
  gap: 8px;
  align-items: center;
}

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

.empty {
  display: none;
  padding: 34px;
  text-align: center;
  color: var(--muted);
}

.empty.show {
  display: block;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: 360px;
  padding: 12px 14px;
  background: #1d252b;
  color: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: 0.18s ease;
}

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

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(29, 37, 43, 0.42);
}

.modal-card {
  width: min(920px, 100%);
  max-height: min(720px, 90vh);
  overflow: auto;
  background: #fff;
  border-radius: 8px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.user-form {
  padding: 18px;
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(180px, 1fr) minmax(140px, 0.7fr) auto;
  gap: 14px;
  align-items: end;
  border-bottom: 1px solid var(--line);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 700;
}

.status-badge.off {
  background: #f5e5e1;
  color: var(--accent);
}

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

  .sidebar {
    position: relative;
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

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

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

  .toolbar,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .actions {
    justify-content: flex-start;
  }
}

@media (max-width: 560px) {
  .main,
  .sidebar {
    padding: 16px;
  }

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

  .effect-cell {
    grid-template-columns: 1fr;
  }
}
