:root {
  color-scheme: light;
  --ink: #182126;
  --muted: #64717a;
  --line: #dde5e8;
  --soft: #f4f7f8;
  --surface: #ffffff;
  --primary: #126b5f;
  --primary-dark: #0b4f46;
  --accent: #d86d3f;
  --warning: #f1b957;
  --danger: #ca4b52;
  --success: #27845f;
}

* {
  box-sizing: border-box;
}

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

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

button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  cursor: pointer;
}

button:hover {
  border-color: #b8c8ca;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 284px;
  padding: 22px 18px;
  color: #d9e7e4;
  background: #132421;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 22px;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  color: #fff;
  font-size: 18px;
}

.brand small {
  margin-top: 4px;
  color: #8fb1aa;
  font-size: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  color: #fff;
  background: var(--primary);
  font-weight: 800;
}

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

.menu button {
  display: grid;
  gap: 4px;
  width: 100%;
  min-height: 62px;
  padding: 12px 14px;
  border: 0;
  color: #c6d8d4;
  text-align: left;
  background: transparent;
}

.menu button:hover,
.menu button.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.menu span {
  font-weight: 800;
}

.menu em {
  color: #8fb1aa;
  font-size: 12px;
  font-style: normal;
}

.app {
  min-height: 100vh;
  margin-left: 284px;
  padding: 28px;
}

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

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.25;
}

h2 {
  margin-bottom: 8px;
  font-size: 20px;
}

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

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

.danger-btn {
  color: #fff;
  border-color: var(--danger);
  background: var(--danger);
}

.ghost {
  color: var(--primary-dark);
  background: #eef8f5;
}

.view {
  display: grid;
  gap: 18px;
}

.login-panel {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 160px);
}

.login-card {
  display: grid;
  gap: 16px;
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 50px rgba(19, 36, 33, 0.1);
}

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

.login-card label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.panel {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 14px 38px rgba(19, 36, 33, 0.06);
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.section-head p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.65;
}

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

.metric {
  min-height: 122px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfb;
}

.metric span,
.metric em {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
}

.metric strong {
  display: block;
  margin: 12px 0 8px;
  font-size: 28px;
}

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

.subpanel {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfb;
}

.danger-panel {
  border-color: rgba(202, 75, 82, 0.35);
  background: rgba(202, 75, 82, 0.06);
}

.subpanel h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.subpanel p {
  margin: 0 0 12px;
  color: var(--muted);
}

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

.import-grid,
.filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.import-grid label,
.filter-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

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

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

.locked-select {
  color: var(--muted);
  background: #eef5f3;
  border-color: #bfd3cf;
}

textarea {
  min-height: 80px;
  resize: vertical;
}

.form-actions {
  display: flex;
  align-items: end;
  gap: 10px;
}

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

.notice {
  display: grid;
  gap: 8px;
  margin-top: 16px;
  padding: 16px;
  border: 1px solid rgba(18, 107, 95, 0.22);
  border-radius: 8px;
  background: #f2faf7;
}

.notice.error {
  border-color: rgba(202, 75, 82, 0.35);
  background: #fff4f5;
}

.notice strong {
  font-size: 16px;
}

.notice p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

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

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

tr:last-child td {
  border-bottom: 0;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.tag.warning {
  color: #77520a;
  background: #fff4d8;
}

.tag.danger {
  color: #8c2730;
  background: #ffe8ea;
}

.tag.success {
  color: #176142;
  background: #e4f6ee;
}

.tag.neutral {
  color: #43525a;
  background: #edf1f2;
}

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

.module-card {
  display: grid;
  gap: 10px;
  min-height: 132px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfb;
}

.module-card span {
  color: var(--muted);
  line-height: 1.6;
}

.empty {
  display: grid;
  place-items: center;
  min-height: 180px;
  color: var(--muted);
  text-align: center;
}

.empty strong {
  color: var(--ink);
}

.toast {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 20;
  max-width: 360px;
  padding: 12px 16px;
  border-radius: 8px;
  color: #fff;
  background: var(--primary-dark);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
}

@media (max-width: 1120px) {
  .sidebar {
    position: static;
    width: auto;
  }

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

  .app {
    margin-left: 0;
  }

  .metrics,
  .form-grid,
  .import-grid,
  .filter-grid,
  .module-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app {
    padding: 18px;
  }

  .topbar,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .menu,
  .metrics,
  .grid-2,
  .form-grid,
  .import-grid,
  .filter-grid,
  .module-grid {
    grid-template-columns: 1fr;
  }
}
