:root {
  --ink: #17211b;
  --muted: #65736b;
  --line: #dce3dd;
  --panel: #ffffff;
  --paper: #f5f7f2;
  --sidebar: #111815;
  --sidebar-2: #1d2a25;
  --teal: #0f8f7b;
  --teal-2: #096f62;
  --green: #1f9d55;
  --amber: #b9770e;
  --red: #c23b3b;
  --blue: #3367d6;
  --shadow: 0 18px 45px rgba(20, 31, 25, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 14px;
}

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

button {
  border: 0;
  cursor: pointer;
}

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

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  background:
    linear-gradient(115deg, rgba(15, 143, 123, 0.14), transparent 42%),
    linear-gradient(290deg, rgba(185, 119, 14, 0.12), transparent 38%),
    var(--paper);
}

.login-panel {
  width: min(430px, 100%);
  display: grid;
  gap: 20px;
  padding: 34px;
  border: 1px solid rgba(17, 24, 21, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, var(--teal), #244136);
  font-weight: 800;
  letter-spacing: 0;
}

.brand-mark.compact {
  width: 38px;
  height: 38px;
  font-size: 13px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--teal-2);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 30px;
}

h2 {
  font-size: 25px;
}

h3 {
  font-size: 18px;
}

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

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

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

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 143, 123, 0.13);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-weight: 600;
}

.checkbox-row input {
  width: 17px;
  height: 17px;
}

.login-foot {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 22px 16px;
  color: #f4f7f2;
  background: linear-gradient(180deg, var(--sidebar), var(--sidebar-2));
}

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

.sidebar-brand strong {
  display: block;
  font-size: 17px;
}

.sidebar-brand small,
.sidebar-foot small {
  display: block;
  color: rgba(244, 247, 242, 0.62);
  font-size: 12px;
}

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

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 8px;
  color: rgba(244, 247, 242, 0.76);
  background: transparent;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.nav-item.active::after {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #64d6c7;
}

.sidebar-foot {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.workspace {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(245, 247, 242, 0.9);
  backdrop-filter: blur(10px);
}

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

.operator {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fff;
  white-space: nowrap;
}

.content {
  min-width: 0;
  padding: 26px 28px 40px;
}

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

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

.metric-card,
.panel {
  border: 1px solid rgba(17, 24, 21, 0.08);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(17, 24, 21, 0.06);
}

.metric-card {
  padding: 18px;
}

.metric-label {
  margin: 0 0 9px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric-value {
  margin: 0;
  font-size: 30px;
  font-weight: 800;
}

.panel {
  overflow: hidden;
}

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

.panel-title {
  display: grid;
  gap: 3px;
}

.panel-title strong {
  font-size: 16px;
}

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

.panel-body {
  padding: 18px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfa;
}

.toolbar label {
  min-width: 170px;
}

.toolbar .grow {
  flex: 1 1 240px;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.table-wrap {
  width: 100%;
  overflow: auto;
}

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

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

th {
  color: var(--muted);
  background: #fbfcfa;
  font-size: 12px;
  font-weight: 800;
}

td {
  color: #243029;
}

tr:hover td {
  background: rgba(15, 143, 123, 0.035);
}

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

.mono {
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
}

.truncate {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.active {
  color: #0d5c39;
  background: rgba(31, 157, 85, 0.13);
}

.badge.pending {
  color: #87600b;
  background: rgba(185, 119, 14, 0.14);
}

.badge.disabled,
.badge.expired,
.badge.denied {
  color: #932828;
  background: rgba(194, 59, 59, 0.12);
}

.badge.replaced {
  color: #3156a6;
  background: rgba(51, 103, 214, 0.12);
}

.badge.soft {
  color: var(--muted);
  background: #eef2ee;
}

.primary,
.secondary,
.ghost,
.danger-soft,
.table-button {
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 800;
  white-space: nowrap;
}

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

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

.secondary {
  color: var(--ink);
  background: #e7eee9;
}

.ghost {
  color: var(--ink);
  border: 1px solid var(--line);
  background: #fff;
}

.danger-soft {
  color: #972d2d;
  background: rgba(194, 59, 59, 0.1);
}

.table-button {
  min-height: 30px;
  padding: 6px 9px;
  color: var(--ink);
  background: #eef2ee;
  font-size: 12px;
}

.table-button.primary-soft {
  color: #0a6d5f;
  background: rgba(15, 143, 123, 0.12);
}

.table-button.warn-soft {
  color: #8a5b07;
  background: rgba(185, 119, 14, 0.14);
}

.full {
  width: 100%;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  color: var(--muted);
}

.pager-controls {
  display: flex;
  gap: 8px;
}

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

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

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

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

.info-item:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

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

.info-item strong {
  text-align: right;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: start center;
  padding: 56px 20px;
  background: rgba(12, 18, 15, 0.44);
  overflow: auto;
}

.modal {
  width: min(640px, 100%);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

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

.modal-body {
  padding: 20px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 8px;
}

.icon-button {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: var(--muted);
  background: #eef2ee;
  font-size: 22px;
  line-height: 1;
}

.toast-host {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  display: grid;
  gap: 10px;
}

.toast {
  min-width: 240px;
  max-width: 380px;
  padding: 12px 14px;
  border-radius: 8px;
  color: #fff;
  background: #17211b;
  box-shadow: var(--shadow);
}

.toast.error {
  background: var(--red);
}

@media (max-width: 1180px) {
  .metric-grid {
    grid-template-columns: repeat(3, minmax(130px, 1fr));
  }

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

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

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

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

  .topbar {
    position: static;
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-actions {
    flex-wrap: wrap;
  }

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

@media (max-width: 560px) {
  .content,
  .topbar {
    padding-left: 16px;
    padding-right: 16px;
  }

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

  .toolbar label {
    min-width: 100%;
  }
}
