:root {
  --bg: #f5f6f4;
  --surface: #ffffff;
  --soft: #f9faf8;
  --text: #202421;
  --muted: #68716d;
  --line: #dde2dc;
  --orange: #e86f2f;
  --orange-dark: #bb4f1e;
  --green: #2f8f69;
  --green-soft: #e8f4ee;
  --amber: #b7791f;
  --amber-soft: #fff3db;
  --red: #c2413b;
  --red-soft: #fde9e7;
  --teal: #277d84;
  --shadow: 0 16px 44px rgba(34, 40, 36, 0.08);
  --radius: 8px;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  color: var(--text);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, rgba(232, 111, 47, 0.07), rgba(232, 111, 47, 0) 280px),
    var(--bg);
}

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

button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 8px 12px;
  cursor: pointer;
  background: #fff;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

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

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

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

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

.ghost {
  color: rgba(255, 255, 255, 0.82);
  background: transparent;
  border-color: rgba(255, 255, 255, 0.16);
}

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

textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.6;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(232, 111, 47, 0.14);
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(100%, 420px);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

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

.brand-row strong,
.brand-row span {
  display: block;
}

.brand-row span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

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

.login-card p {
  margin: 0 0 20px;
  color: var(--muted);
  line-height: 1.6;
}

.login-form {
  display: grid;
  gap: 14px;
}

.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: 20px;
  padding: 22px 18px;
  color: #fff;
  background: #202421;
}

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

.side-nav button {
  justify-content: flex-start;
  text-align: left;
  color: rgba(255, 255, 255, 0.78);
  background: transparent;
  border-color: transparent;
}

.side-nav button.active,
.side-nav button:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.user-box {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.06);
}

.user-box span,
.user-box strong {
  display: block;
}

.user-box span {
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
}

.user-box strong {
  margin-top: 5px;
  font-size: 14px;
}

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

.topbar {
  width: min(100%, 1380px);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin: 0 auto 18px;
}

.page-kicker {
  margin: 0 0 5px;
  color: var(--orange-dark);
  font-weight: 760;
  font-size: 13px;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 3vw, 40px);
  line-height: 1.14;
}

h2 {
  margin-bottom: 6px;
  font-size: 22px;
}

h3 {
  margin-bottom: 0;
  font-size: 16px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.section {
  width: min(100%, 1380px);
  margin: 0 auto 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

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

.section-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

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

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

.filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 10px;
}

.kpi-card {
  min-height: 112px;
  display: grid;
  align-content: space-between;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.kpi-card span {
  color: var(--muted);
  font-size: 12px;
}

.kpi-card strong {
  font-size: 26px;
  line-height: 1.1;
}

.table-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
}

.table-card + .table-card {
  margin-top: 14px;
}

.table-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--soft);
}

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

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

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

thead th {
  color: var(--muted);
  background: #fbfcfb;
  font-size: 12px;
}

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

td input,
td select {
  min-height: 34px;
  padding: 6px 8px;
}

.badge {
  display: inline-flex;
  min-width: 54px;
  justify-content: center;
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 760;
}

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

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

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

.notice {
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: var(--soft);
  font-size: 13px;
}

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

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

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

.detail-box {
  display: none;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.detail-box.open {
  display: block;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.detail-grid div {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--soft);
}

.detail-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.detail-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
}

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

.summary-text article {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--soft);
}

.summary-text p {
  margin-bottom: 0;
  color: var(--text);
  line-height: 1.6;
  white-space: pre-wrap;
}

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

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

  .sidebar {
    position: relative;
    height: auto;
  }

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

  .user-box {
    display: none;
  }

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

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

  .topbar,
  .section-heading,
  .table-title {
    flex-direction: column;
    align-items: stretch;
  }

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

  .side-nav,
  .filters,
  .kpi-grid,
  .form-grid,
  .two-grid,
  .detail-grid,
  .summary-text {
    grid-template-columns: 1fr;
  }
}
