:root {
  color: #18221f;
  background: #f4f6f5;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  font-synthesis: none;
  letter-spacing: 0;
  --brand: #176b55;
  --brand-strong: #0e4e3d;
  --ink: #18221f;
  --muted: #66736f;
  --line: #d9e0dd;
  --surface: #ffffff;
  --surface-soft: #f7f9f8;
  --warning: #9a5a08;
  --danger: #b42318;
  --info: #285ea8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: #f4f6f5;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button,
a,
input,
select,
textarea {
  outline-color: var(--brand);
}

button {
  cursor: pointer;
}

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

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(180deg, #eff4f2 0, #f4f6f5 42%, #eef1f0 100%);
}

.login-panel {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 16px 48px rgba(22, 43, 36, 0.1);
}

.login-heading {
  padding: 28px 28px 20px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  display: inline-grid;
  width: 38px;
  height: 38px;
  margin-bottom: 18px;
  place-items: center;
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
}

.login-heading h1 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 24px;
  line-height: 1.3;
}

.login-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.login-form {
  display: grid;
  gap: 18px;
  padding: 24px 28px 28px;
}

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

.field label {
  color: #34413d;
  font-size: 13px;
  font-weight: 600;
}

.field input,
.field select,
.field textarea,
.filter-input,
.filter-select {
  width: 100%;
  min-height: 40px;
  border: 1px solid #cbd5d1;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 8px 11px;
}

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

.field input:focus,
.field select:focus,
.field textarea:focus,
.filter-input:focus,
.filter-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(23, 107, 85, 0.12);
}

.primary-button,
.secondary-button,
.danger-button,
.text-button {
  min-height: 38px;
  border-radius: 6px;
  padding: 8px 14px;
  font-weight: 600;
  line-height: 1.2;
}

.primary-button {
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
}

.primary-button:hover {
  border-color: var(--brand-strong);
  background: var(--brand-strong);
}

.secondary-button {
  border: 1px solid #bac6c1;
  background: #fff;
  color: #25322e;
}

.secondary-button:hover {
  border-color: #83938d;
  background: #f8faf9;
}

.danger-button {
  border: 1px solid #f0b8b4;
  background: #fff7f6;
  color: var(--danger);
}

.text-button {
  min-height: 32px;
  border: 0;
  background: transparent;
  color: var(--brand);
  padding: 5px 8px;
}

.text-button.danger {
  color: var(--danger);
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid #d4ddd9;
  background: rgba(255, 255, 255, 0.96);
  padding: 0 28px;
}

.topbar-brand,
.topbar-actions,
.user-chip {
  display: flex;
  align-items: center;
}

.topbar-brand {
  min-width: 0;
  gap: 12px;
}

.topbar-brand .brand-mark {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  margin: 0;
  font-size: 15px;
}

.topbar-brand h1 {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 18px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions {
  gap: 8px;
}

.user-chip {
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.user-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #1d8a5b;
}

.icon-button {
  display: inline-grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid #c5d0cc;
  border-radius: 6px;
  background: #fff;
  color: #36433f;
  font-size: 20px;
}

.icon-button:hover {
  border-color: #8b9a95;
  background: #f7f9f8;
}

.main {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 26px 28px 44px;
}

.summary-strip {
  display: grid;
  overflow: hidden;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.summary-item {
  min-width: 0;
  padding: 18px 20px;
  border-right: 1px solid var(--line);
}

.summary-item:last-child {
  border-right: 0;
}

.summary-label {
  color: var(--muted);
  font-size: 12px;
}

.summary-value {
  margin-top: 8px;
  color: var(--ink);
  font-size: 25px;
  font-weight: 700;
  line-height: 1;
}

.workspace {
  margin-top: 24px;
}

.tabs-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}

.tabs {
  display: flex;
  overflow-x: auto;
  gap: 2px;
}

.tab {
  position: relative;
  min-width: 106px;
  height: 46px;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0 16px;
  font-weight: 600;
  white-space: nowrap;
}

.tab.active {
  color: var(--brand-strong);
}

.tab.active::after {
  position: absolute;
  right: 14px;
  bottom: -1px;
  left: 14px;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--brand);
  content: "";
}

.tab-count {
  display: inline-grid;
  min-width: 21px;
  height: 21px;
  margin-left: 6px;
  place-items: center;
  border-radius: 10px;
  background: #e8efec;
  color: #3d4b46;
  padding: 0 6px;
  font-size: 11px;
}

.view-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 7px;
}

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 0 16px;
}

.view-header h2 {
  margin: 0;
  font-size: 18px;
}

.view-header p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px 180px auto;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px 8px 0 0;
  background: var(--surface-soft);
}

.filter-input,
.filter-select {
  min-height: 38px;
  padding-top: 6px;
  padding-bottom: 6px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-top: 0;
  background: var(--surface);
}

.data-table {
  width: 100%;
  min-width: 1050px;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 13px 14px;
  border-bottom: 1px solid #e7ecea;
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

.data-table th {
  background: #fbfcfc;
  color: #596762;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.data-table tbody tr:hover {
  background: #fafcfb;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.primary-cell {
  color: var(--ink);
  font-weight: 600;
}

.secondary-line {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.mono {
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 12px;
  word-break: break-all;
}

.status {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 2px 9px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.status.success {
  border-color: #b6ddcd;
  background: #eef9f4;
  color: #176b4d;
}

.status.warning {
  border-color: #ecd19d;
  background: #fff8e8;
  color: var(--warning);
}

.status.danger {
  border-color: #edc0bc;
  background: #fff3f2;
  color: var(--danger);
}

.status.info {
  border-color: #bfd2ec;
  background: #f1f6fd;
  color: var(--info);
}

.status.neutral {
  border-color: #d2d9d6;
  background: #f4f6f5;
  color: #58635f;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  white-space: nowrap;
}

.empty-state,
.loading-state {
  display: grid;
  min-height: 240px;
  place-items: center;
  border: 1px solid var(--line);
  border-top: 0;
  background: var(--surface);
  color: var(--muted);
  font-size: 14px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 14px 0;
  color: var(--muted);
  font-size: 13px;
}

.notice {
  border-left: 3px solid #d99922;
  background: #fff9ed;
  color: #6d4b10;
  padding: 11px 13px;
  font-size: 13px;
  line-height: 1.6;
}

.modal-backdrop {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(15, 27, 23, 0.52);
  padding: 20px;
}

.modal {
  width: min(540px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 72px rgba(7, 24, 18, 0.28);
}

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

.modal-header h2 {
  margin: 0;
  font-size: 17px;
}

.modal-close {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 0;
  background: transparent;
  color: #52605b;
  font-size: 22px;
}

.modal-body {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding: 14px 20px;
}

.key-box {
  display: grid;
  gap: 10px;
  border: 1px solid #a8cdc0;
  border-radius: 6px;
  background: #f0f8f5;
  padding: 14px;
}

.key-value {
  width: 100%;
  min-height: 78px;
  resize: none;
  border: 1px solid #a8bcb5;
  border-radius: 5px;
  background: #fff;
  color: #123e31;
  padding: 11px;
  font-family: Consolas, "SFMono-Regular", monospace;
  line-height: 1.5;
}

#toast-root {
  position: fixed;
  z-index: 200;
  top: 78px;
  right: 22px;
  display: grid;
  width: min(360px, calc(100vw - 44px));
  gap: 8px;
}

.toast {
  border: 1px solid #b9c7c2;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 12px 30px rgba(21, 42, 35, 0.16);
  color: var(--ink);
  padding: 12px 14px;
  font-size: 13px;
}

.toast.error {
  border-color: #edb9b5;
  color: #8d2018;
}

@media (max-width: 980px) {
  .summary-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .summary-item {
    border-bottom: 1px solid var(--line);
  }

  .summary-item:nth-child(2n) {
    border-right: 0;
  }

  .summary-item:last-child {
    grid-column: 1 / -1;
    border-bottom: 0;
  }

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

@media (max-width: 680px) {
  .topbar {
    min-height: 58px;
    padding: 0 14px;
  }

  .topbar-brand h1 {
    font-size: 16px;
  }

  .user-chip,
  .back-admin {
    display: none;
  }

  .main {
    padding: 18px 14px 32px;
  }

  .summary-item {
    padding: 14px;
  }

  .summary-value {
    font-size: 22px;
  }

  .tabs-row {
    align-items: center;
  }

  .tab {
    min-width: 92px;
    padding: 0 10px;
  }

  .view-actions .primary-button {
    padding-right: 10px;
    padding-left: 10px;
  }

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

  .view-header {
    align-items: flex-start;
  }

  .modal-backdrop {
    align-items: end;
    padding: 0;
  }

  .modal {
    width: 100%;
    max-height: 92vh;
    border-radius: 8px 8px 0 0;
  }
}
