:root {
  color-scheme: light;
  --bg: #f4f7f9;
  --panel: #ffffff;
  --ink: #16202a;
  --muted: #667483;
  --line: #dbe3ea;
  --green: #0f9f6e;
  --red: #dc2626;
  --amber: #b7791f;
  --cyan: #0ea5e9;
  --nav: #11181f;
  --shadow: 0 12px 36px rgba(21, 31, 41, 0.06);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.is-auth-screen {
  background:
    radial-gradient(circle at top left, rgba(14, 165, 233, 0.12), transparent 28%),
    radial-gradient(circle at bottom right, rgba(15, 159, 110, 0.12), transparent 32%),
    var(--bg);
}

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

.login-card {
  width: min(460px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.08);
}

.login-brand,
.topbar,
.panel-head,
.task-list article,
.admin-actions,
.sidebar-user-head,
.detail-header {
  display: flex;
  align-items: center;
}

.login-brand {
  gap: 12px;
}

.login-brand span,
.brand span {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--green), var(--cyan));
  color: #04110d;
  font-weight: 900;
}

.login-copy {
  margin: 24px 0 18px;
}

.login-copy h1 {
  margin: 0 0 8px;
  font-size: 30px;
}

.login-copy p,
.login-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.login-form,
.form-card,
.inline-form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

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

textarea {
  min-height: 96px;
  padding: 10px 12px;
  resize: vertical;
}

.wide {
  width: 100%;
}

.login-note {
  margin-top: 14px;
}

.login-note code {
  display: inline-block;
  margin-left: 6px;
  border-radius: 8px;
  background: #f5f7fa;
  padding: 4px 8px;
  color: #0f3a30;
}

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

.sidebar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--nav);
  color: #edf3f7;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand small,
.sidebar-user small {
  display: block;
  margin-top: 2px;
  color: #9fb0bf;
}

.sidebar-user {
  margin: 12px;
  padding: 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
}

.sidebar-user-head {
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.sidebar-user strong {
  display: block;
  margin-bottom: 4px;
}

.side-nav {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 10px;
}

.nav-group {
  min-width: 220px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.3);
}

.nav-group-title {
  cursor: pointer;
  padding: 12px 14px;
  list-style: none;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #8ea2b4;
}

.nav-group-title::-webkit-details-marker {
  display: none;
}

.nav-group-items {
  display: grid;
  gap: 6px;
  padding: 0 10px 10px;
}

.side-nav button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #b7c6d2;
}

.side-nav button.active {
  background: #26313a;
  color: #ffffff;
}

.side-nav svg,
.primary svg,
.outline svg,
.ghost svg {
  width: 18px;
  height: 18px;
}

.workspace {
  padding: 16px;
}

.topbar {
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.topbar h1 {
  margin: 0 0 4px;
  font-size: 28px;
}

.topbar p {
  margin: 0;
  color: var(--muted);
}

.admin-actions {
  gap: 8px;
}

.admin-actions.compact {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.primary,
.outline,
.text-button,
.filters button,
td button,
.level-grid button,
.task-list button,
.ghost {
  border: 0;
  border-radius: 10px;
  min-height: 38px;
  padding: 0 12px;
}

.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--green);
  color: #ffffff;
  font-weight: 800;
}

.outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
}

.ghost {
  display: inline-grid;
  place-items: center;
  width: 38px;
  padding: 0;
  background: #f3f6f8;
  color: var(--ink);
}

.text-button {
  background: transparent;
  color: var(--green);
}

.admin-page {
  display: none;
}

.admin-page.active {
  display: block;
}

.metric-grid,
.setting-grid,
.level-grid,
.dashboard-grid,
.summary-grid {
  display: grid;
  gap: 12px;
}

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

.metric-grid article,
.panel,
.form-card,
.level-grid article {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric-grid article {
  padding: 16px;
}

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

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

.up {
  color: var(--green) !important;
}

.warn {
  color: var(--amber) !important;
}

.panel,
.form-card {
  padding: 16px;
}

.compact-form {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  margin: 14px 0;
}

.compact-form label:last-child {
  grid-column: 1 / -1;
}

.link-button {
  color: var(--green);
  font-weight: 800;
  text-decoration: none;
}

.panel {
  margin-top: 12px;
}

.panel h2,
.form-card h2 {
  margin: 0 0 14px;
  font-size: 18px;
}

.panel-head {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-head h2 {
  margin: 0;
}

.filters {
  display: flex;
  gap: 6px;
  overflow-x: auto;
}

.filters button {
  background: #edf2f6;
  color: var(--muted);
}

.filters button.active {
  background: #dff7ed;
  color: var(--green);
}

.task-list {
  display: grid;
  gap: 8px;
}

.task-list article {
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.task-list span {
  flex: 1;
  color: var(--muted);
}

.task-list button,
td button,
.level-grid button {
  background: #eef6fb;
  color: #0369a1;
}

.dashboard-grid,
.setting-grid {
  grid-template-columns: 1fr;
}

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

.summary-grid article {
  padding: 14px;
  border-radius: 12px;
  background: #f8fafc;
}

.summary-grid span,
.summary-grid small {
  display: block;
  color: var(--muted);
}

.summary-grid strong {
  display: block;
  margin: 8px 0 6px;
  font-size: 26px;
}

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

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

.admin-pagination button {
  min-height: 34px;
  padding: 0 14px;
}

.admin-pagination button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.table-input,
.table-textarea,
.filters input,
.filters select {
  width: 100%;
  min-width: 140px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
}

.table-input,
.filters input,
.filters select {
  min-height: 38px;
  padding: 0 10px;
}

.table-textarea {
  min-width: 320px;
  padding: 10px;
  resize: vertical;
  line-height: 1.5;
}

.i18n-table td:nth-child(2),
.i18n-table td:nth-child(3) {
  white-space: normal;
  min-width: 280px;
}

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

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-weight: 600;
  background: #f8fafc;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.badge.ok {
  background: #dcfce7;
  color: #166534;
}
.badge-ok {
  background: #dcfce7;
  color: #166534;
}

.badge.warn {
  background: #fef3c7;
  color: #92400e;
}
.badge-warn {
  background: #fef3c7;
  color: #92400e;
}

.badge.danger {
  background: #fee2e2;
  color: #991b1b;
}

.policy-list {
  display: grid;
  gap: 10px;
}

.policy-list article {
  padding: 12px;
  border-radius: 12px;
  background: #f8fafc;
}

.policy-list b {
  display: block;
  margin-bottom: 6px;
}

.policy-list span {
  color: var(--muted);
  line-height: 1.6;
}

.quick-grid {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.quick-grid button {
  justify-content: center;
}

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

.form-note-inline {
  padding: 10px 12px;
  border-radius: 12px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.table-actions.stack {
  display: grid;
  gap: 8px;
}

.restriction-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
}

.restriction-modal[hidden] {
  display: none;
}

.restriction-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.46);
}

.restriction-modal-panel {
  position: relative;
  width: min(680px, calc(100vw - 32px));
  margin: 72px auto 0;
  padding: 20px;
  border-radius: 18px;
  background: #ffffff;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.26);
}

.restriction-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.restriction-modal-header h2 {
  margin: 0 0 6px;
}

.restriction-modal-header p,
.restriction-modal-meta {
  margin: 0;
  color: var(--muted);
}

.restriction-modal-form {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.restriction-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.limit-editor-page {
  max-width: 920px;
}

.limit-editor-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 18px;
}

.limit-editor-header h2 {
  margin: 0 0 6px;
}

.limit-editor-header p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.restriction-editor-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.restriction-editor-meta article,
.restriction-preview-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8fafc;
}

.restriction-editor-meta span,
.restriction-preview-card span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.restriction-editor-meta strong {
  word-break: break-all;
}

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

.restriction-switch {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
}

.restriction-preview-card {
  margin-top: 16px;
}

.restriction-preview-card strong {
  display: block;
  margin-bottom: 8px;
}

.restriction-preview-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.restriction-editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

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

.level-profit-grid article {
  min-width: 0;
  padding: 16px;
  border: 1px solid #e7eef5;
  border-radius: 16px;
  background: #f8fafc;
}

.level-profit-grid h3 {
  margin: 0 0 8px;
  font-size: 20px;
}

.level-profit-grid p {
  min-height: 42px;
  margin: 0 0 14px;
  color: #64748b;
  font-size: 13px;
  line-height: 1.5;
}

.level-profit-grid label {
  display: grid;
  gap: 8px;
  color: #475569;
  font-size: 13px;
  font-weight: 700;
}

.level-profit-grid input {
  min-height: 44px;
  border: 1px solid #d8e2ee;
  border-radius: 12px;
  background: #ffffff;
  padding: 0 12px;
  color: #0f172a;
  font-weight: 800;
}

.level-profit-grid > button {
  grid-column: 1 / -1;
  justify-self: end;
}

@media (max-width: 860px) {
  .restriction-editor-meta {
    grid-template-columns: 1fr;
  }
}

.icon-only {
  width: 40px;
  min-width: 40px;
  padding: 0;
  justify-content: center;
}

.level-grid article {
  padding: 16px;
}

.level-grid h3 {
  margin: 0 0 8px;
}

.level-grid p {
  min-height: 72px;
  margin: 0 0 12px;
  color: var(--muted);
  line-height: 1.55;
}

.detail-drawer {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
}

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

.detail-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.28);
}

.detail-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(460px, 100vw);
  height: 100%;
  padding: 20px;
  border-left: 1px solid var(--line);
  background: #ffffff;
  box-shadow: -12px 0 36px rgba(15, 23, 42, 0.08);
  overflow-y: auto;
}

.detail-header {
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.detail-header h2 {
  margin: 0 0 6px;
  font-size: 22px;
}

.detail-header p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.detail-body {
  display: grid;
  gap: 14px;
}

.detail-card {
  padding: 14px;
  border-radius: 12px;
  background: #f8fafc;
}

.detail-card h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

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

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

.detail-grid article strong {
  display: block;
  margin-top: 4px;
  font-size: 14px;
  word-break: break-word;
}

.timeline {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline li {
  padding-left: 14px;
  border-left: 2px solid #d8e2ea;
}

.timeline li b {
  display: block;
  margin-bottom: 4px;
}

.timeline li p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.admin-toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 80;
  max-width: min(360px, calc(100vw - 32px));
  padding: 12px 16px;
  border-radius: 12px;
  background: #15212b;
  color: #ffffff;
  box-shadow: 0 18px 40px rgba(21, 33, 43, 0.22);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

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

@media (max-width: 700px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .admin-actions {
    width: 100%;
  }

  .admin-actions button {
    flex: 1;
  }

  .metric-grid,
  .summary-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 980px) {
  .admin-shell {
    display: grid;
    grid-template-columns: 272px 1fr;
  }

  .sidebar {
    height: 100vh;
  }

  .side-nav {
    display: grid;
    overflow: visible;
    padding: 12px;
  }

  .nav-group {
    min-width: 0;
  }

  .workspace {
    padding: 24px;
  }

  .metric-grid.four-up {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

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

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

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