:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --surface-soft: #faf8f4;
  --border: #e5e0d5;
  --border-strong: #d5cec0;
  --text: #1f2924;
  --text-muted: #64706a;
  --primary: #1f6a56;
  --primary-hover: #175444;
  --primary-soft: #e8f3ef;
  --accent: #b86b2b;
  --accent-soft: #fbf1e6;
  --danger: #b9382c;
  --danger-soft: #fdecea;
  --success: #1b7a46;
  --success-soft: #e7f6ee;
  --shadow-sm: 0 1px 2px rgba(20, 32, 26, 0.05);
  --shadow-md: 0 10px 30px rgba(20, 32, 26, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

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

/* Auth & Forbidden Screen */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at top right, #e8f3ef 0%, var(--bg) 55%);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 32px;
  box-shadow: var(--shadow-md);
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 1px;
  margin-bottom: 16px;
}

.brand-sm {
  width: 38px;
  height: 38px;
  font-size: 13px;
  margin-bottom: 0;
}

.brand-warn {
  background: var(--danger);
  font-size: 22px;
}

.auth-card h1 {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 700;
}

.auth-subtitle {
  margin: 0 0 24px;
  color: var(--text-muted);
  font-size: 13px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Form Controls */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field > span {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
.select-input {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, .select-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 106, 86, 0.14);
}

input[readonly] {
  background: var(--surface-soft);
  color: var(--text-muted);
}

.form-error {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-sm {
  height: 30px;
  padding: 0 11px;
  font-size: 12px;
}

.btn-block {
  width: 100%;
}

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

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-outline {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-outline:hover:not(:disabled) {
  background: var(--surface-soft);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}

.btn-ghost:hover {
  background: var(--surface-soft);
  color: var(--text);
}

.link-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.link-btn:hover {
  text-decoration: underline;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
}

.icon-btn:hover {
  background: var(--surface-soft);
  color: var(--text);
}

/* App Shell */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 6px 20px;
  border-bottom: 1px solid var(--border);
}

.brand-title {
  font-size: 16px;
  font-weight: 700;
}

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

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 18px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.nav-item:hover {
  background: var(--surface-soft);
  color: var(--text);
}

.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.nav-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.65;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-badge {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

.admin-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
}

.admin-email {
  display: block;
  font-size: 12px;
  font-weight: 600;
  word-break: break-all;
}

.site-links {
  display: flex;
  gap: 12px;
  font-size: 12px;
}

.site-links a {
  color: var(--primary);
  text-decoration: none;
}

.site-links a:hover {
  text-decoration: underline;
}

/* Main Content */
.main-area {
  flex: 1;
  min-width: 0;
  padding: 24px 28px 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.topbar h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}

.page-desc {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}

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

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}

.kpi-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.kpi-value {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
}

.kpi-sub {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

/* Cards & Columns */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

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

.card-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.overview-columns {
  display: grid;
  grid-template-columns: 1fr 1.35fr;
  gap: 16px;
}

.popular-list, .recent-tx-list {
  padding: 12px 20px 18px;
}

.popular-row {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.popular-row:last-child {
  border-bottom: none;
}

.popular-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 6px;
}

.popular-name {
  font-weight: 600;
}

.popular-bar-bg {
  height: 6px;
  background: var(--bg);
  border-radius: 99px;
  overflow: hidden;
}

.popular-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 99px;
}

.recent-tx-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.recent-tx-row:last-child {
  border-bottom: none;
}

/* Toolbar & Filters */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
}

.search-box {
  flex: 1;
  min-width: 220px;
  max-width: 320px;
}

.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  height: 32px;
  padding: 0 12px;
  border-radius: 99px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.chip:hover {
  border-color: var(--primary);
  color: var(--primary);
}

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

.toolbar .select-input {
  width: auto;
  min-width: 170px;
  height: 34px;
  font-size: 13px;
}

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

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

.data-table th {
  text-align: left;
  padding: 11px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-soft);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

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

.col-actions {
  text-align: right !important;
  white-space: nowrap;
}

.actions-cell {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.table-footer {
  padding: 12px 20px;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface-soft);
}

/* Pills & Badges */
.pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

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

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

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

.pill-gray {
  background: #efede8;
  color: var(--text-muted);
}

.pill-primary {
  background: var(--primary-soft);
  color: var(--primary);
}

.points-num {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
}

.delta-pos {
  color: var(--success);
  font-weight: 700;
}

.delta-neg {
  color: var(--danger);
  font-weight: 700;
}

.empty-state {
  text-align: center;
  padding: 36px 16px;
  color: var(--text-muted);
  font-size: 13px;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 25, 20, 0.48);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal-card {
  width: 100%;
  max-width: 460px;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

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

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

.modal-body {
  padding: 20px 22px 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
}

.preset-btn, .reason-btn {
  height: 30px;
  padding: 0 11px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--surface-soft);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.preset-btn:hover, .reason-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

.preset-neg {
  color: var(--danger);
}

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

/* Drawer */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 25, 20, 0.45);
  display: flex;
  justify-content: flex-end;
  z-index: 90;
}

.drawer-panel {
  width: 100%;
  max-width: 640px;
  height: 100%;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.16);
}

.drawer-header {
  background: var(--surface);
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.drawer-header h3 {
  margin: 0 0 2px;
  font-size: 17px;
  word-break: break-all;
}

.drawer-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.detail-stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}

.detail-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.detail-section h4 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 700;
}

.album-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.album-tag {
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
}

.mini-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.mini-table th, .mini-table td {
  padding: 8px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.mini-table th {
  color: var(--text-muted);
  font-weight: 600;
}

/* Toast */
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: #1b2a24;
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  z-index: 200;
}

/* Responsive */
@media (max-width: 1024px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .overview-columns {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .app-shell {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 14px 16px;
  }
  .sidebar-nav {
    flex-direction: row;
    overflow-x: auto;
    margin-top: 12px;
  }
  .sidebar-footer {
    margin-top: 12px;
  }
  .main-area {
    padding: 18px 16px 32px;
  }
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .detail-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
