:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #f0f5fb;
  --text: #132039;
  --muted: #66758f;
  --line: #dbe4f1;
  --line-strong: #c6d3e5;
  --blue: #1268e3;
  --blue-dark: #0c4fb2;
  --green: #11845f;
  --red: #c43d3d;
  --amber: #a86105;
  --shadow: 0 18px 46px rgba(19, 32, 57, 0.08);
  --radius: 8px;
}

* { box-sizing: border-box; }

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

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

button { cursor: pointer; }

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

.auth-card {
  width: min(430px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-card h1,
.panel h2,
.topbar h1,
.share-head h1 {
  margin: 0;
  letter-spacing: 0;
}

.auth-card h1 {
  font-size: 25px;
  line-height: 1.2;
}

.auth-card p,
.muted {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 22px 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
}

.tab {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(19, 32, 57, 0.08);
}

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

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

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

input,
select {
  min-height: 40px;
  padding: 0 11px;
}

textarea {
  min-height: 150px;
  padding: 11px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(18, 104, 227, 0.12);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 7px;
  font-weight: 800;
}

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

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

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

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

.button.ghost {
  background: transparent;
  color: var(--muted);
}

.button.wide { width: 100%; }

.button.small {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.error {
  padding: 10px 12px;
  border: 1px solid rgba(196, 61, 61, 0.24);
  border-radius: 7px;
  background: rgba(196, 61, 61, 0.08);
  color: var(--red);
  font-weight: 700;
}

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

.sidebar {
  padding: 22px 16px;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.brand {
  display: grid;
  gap: 3px;
  margin-bottom: 24px;
}

.brand strong {
  font-size: 20px;
  line-height: 1.1;
}

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

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

.nav button {
  min-height: 38px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  font-weight: 800;
  padding: 0 10px;
}

.nav button.active,
.nav button:hover {
  background: var(--surface-2);
  color: var(--text);
}

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

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

.topbar h1 {
  font-size: 24px;
  line-height: 1.2;
}

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

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  align-items: center;
}

.balance-pill {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid rgba(17, 132, 95, 0.22);
  border-radius: 7px;
  background: rgba(17, 132, 95, 0.08);
  color: var(--green);
  font-weight: 900;
}

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

.metric,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(19, 32, 57, 0.04);
}

.metric {
  padding: 14px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
  line-height: 1.1;
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(310px, 0.8fr);
  gap: 14px;
  align-items: start;
}

.panel {
  padding: 16px;
}

.panel h2 {
  font-size: 17px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-actions,
.row-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.split-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

.history-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
}

.history-filters {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) repeat(2, minmax(140px, 0.65fr)) repeat(2, minmax(140px, 0.65fr)) minmax(140px, 0.7fr) minmax(140px, 0.7fr) minmax(190px, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

.history-filters .field {
  min-width: 0;
}

.filter-actions {
  display: inline-flex;
  gap: 8px;
  align-items: end;
  padding-bottom: 0;
}

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

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

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

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

td a {
  color: var(--blue);
  text-decoration: none;
  border-bottom: 1px solid rgba(18, 104, 227, 0.25);
}

.link-action {
  max-width: 260px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--blue);
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.claim-cell {
  display: grid;
  gap: 4px;
  min-width: 92px;
}

.claim-toggle {
  min-height: 26px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
}

.claim-toggle.unclaimed {
  border-color: rgba(168, 97, 5, 0.28);
  background: rgba(168, 97, 5, 0.08);
  color: var(--amber);
}

.claim-toggle.claimed {
  border-color: rgba(17, 132, 95, 0.25);
  background: rgba(17, 132, 95, 0.1);
  color: var(--green);
}

.cell-note {
  color: var(--muted);
  font-size: 11px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(17, 132, 95, 0.1);
  color: var(--green);
  font-weight: 900;
  font-size: 12px;
}

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

.packages {
  display: grid;
  gap: 8px;
}

.package {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.package strong {
  display: block;
}

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

.admin-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.7fr) minmax(0, 1.3fr);
  gap: 14px;
}

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

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

.billing-table input {
  min-width: 110px;
}

.billing-table .check-cell {
  text-align: center;
}

.billing-table input[type="checkbox"] {
  width: 18px;
  min-width: 18px;
  min-height: 18px;
  height: 18px;
}

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

.message {
  margin-top: 10px;
  color: var(--green);
  font-weight: 800;
}

.share-body {
  background: var(--bg);
}

.share-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
}

.share-card {
  width: min(560px, 100%);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.share-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.share-head h1 {
  font-size: 24px;
  line-height: 1.25;
}

.share-head span {
  flex: 0 0 auto;
  color: var(--green);
  font-weight: 900;
}

.qr-frame {
  display: grid;
  place-items: center;
  min-height: 340px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
}

.qr-frame svg {
  width: min(328px, 86vw);
  height: auto;
}

.qr-frame .qr-image {
  width: min(328px, 86vw);
  height: auto;
  display: block;
}

.loading {
  color: var(--muted);
  font-weight: 800;
}

.share-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 14px 0;
}

.share-meta div {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfdff;
}

.share-meta span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.share-meta strong {
  display: block;
  margin-top: 4px;
}

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .nav { grid-template-columns: repeat(4, 1fr); }
  .grid,
  .admin-grid,
  .account-grid,
  .billing-fields,
  .history-filters { grid-template-columns: 1fr 1fr; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .main,
  .sidebar,
  .auth-shell { padding: 14px; }
  .topbar,
  .split-row,
  .history-search,
  .history-filters,
  .filter-actions,
  .share-head { flex-direction: column; display: flex; align-items: stretch; }
  .nav { grid-template-columns: 1fr 1fr; }
  .metrics,
  .share-meta { grid-template-columns: 1fr; }
}
