:root {
  --bg:        #FFFFFF;
  --bg-2:      #F8FAFC;
  --bg-3:      #F1F5F9;
  --border:    #E2E8F0;
  --text:      #0F172A;
  --text-2:    #475569;
  --text-3:    #94A3B8;
  --blue:      #3B82F6;
  --blue-dark: #1D4ED8;
  --blue-light:#EFF6FF;
  --red:       #EF4444;
  --red-light: #FEF2F2;
  --green:     #10B981;
  --green-light:#ECFDF5;
  --amber:     #F59E0B;
  --radius:    8px;
  --shadow:    0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-2); color: var(--text); font-size: 14px; }

.sidebar {
  width: 220px; height: 100vh; position: fixed; left: 0; top: 0;
  background: var(--bg); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 0;
}
.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 15px; font-weight: 600; color: var(--text);
}
.sidebar-logo span { color: var(--blue); }
.sidebar nav { flex: 1; padding: 8px 0; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 20px; color: var(--text-2); cursor: pointer;
  text-decoration: none; font-size: 13.5px;
  transition: all 0.15s;
}
.nav-item:hover { background: var(--bg-2); color: var(--text); }
.nav-item.active { background: var(--blue-light); color: var(--blue); font-weight: 500; }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.sidebar-footer {
  padding: 12px 20px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-3);
}

.main { margin-left: 220px; padding: 32px; min-height: 100vh; }
.page-header { margin-bottom: 24px; }
.page-title { font-size: 20px; font-weight: 600; color: var(--text); }
.page-subtitle { font-size: 13px; color: var(--text-2); margin-top: 2px; }

.card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: 14px; font-weight: 600; }
.card-body { padding: 20px; }

.stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow);
}
.stat-label { font-size: 12px; color: var(--text-3); font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1; }
.stat-sub { font-size: 12px; color: var(--text-2); margin-top: 6px; }
.stat-delta { font-size: 12px; margin-top: 4px; }
.stat-delta.up   { color: var(--green); }
.stat-delta.down { color: var(--red); }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 10px 16px; font-size: 12px; font-weight: 500;
  color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border); background: var(--bg-2); }
td { padding: 12px 16px; font-size: 13.5px; border-bottom: 1px solid var(--border);
  color: var(--text); }
tr:hover td { background: var(--bg-2); }
tr:last-child td { border-bottom: none; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 4px; font-size: 11px; font-weight: 500;
}
.badge-active  { background: var(--green-light); color: var(--green); }
.badge-banned  { background: var(--red-light); color: var(--red); }
.badge-trial   { background: #FEF3C7; color: var(--amber); }
.badge-paid    { background: var(--blue-light); color: var(--blue); }
.badge-free    { background: var(--bg-3); color: var(--text-2); }
.badge-sell    { background: var(--blue-light); color: var(--blue); }
.badge-buy     { background: var(--green-light); color: var(--green); }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius); font-size: 13px;
  font-weight: 500; cursor: pointer; border: none; transition: all 0.15s;
  font-family: inherit;
}
.btn-primary  { background: var(--blue); color: white; }
.btn-primary:hover  { background: var(--blue-dark); }
.btn-danger   { background: var(--red-light); color: var(--red); border: 1px solid #FECACA; }
.btn-danger:hover   { background: #FEE2E2; }
.btn-ghost    { background: transparent; color: var(--text-2); border: 1px solid var(--border); }
.btn-ghost:hover    { background: var(--bg-2); }
.btn-sm { padding: 4px 10px; font-size: 12px; }

input[type=text], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 13.5px; font-family: inherit;
  background: var(--bg); color: var(--text); outline: none;
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); }

.toggle {
  position: relative; width: 40px; height: 22px;
  background: var(--border); border-radius: 11px;
  cursor: pointer; transition: background 0.2s; flex-shrink: 0;
}
.toggle.on { background: var(--blue); }
.toggle::after {
  content: ''; position: absolute; width: 16px; height: 16px;
  border-radius: 50%; background: white; top: 3px; left: 3px;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle.on::after { transform: translateX(18px); }

.pagination { display: flex; gap: 4px; align-items: center; }
.page-btn {
  padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg); cursor: pointer; font-size: 13px; color: var(--text-2);
}
.page-btn.active { background: var(--blue); color: white; border-color: var(--blue); }
.page-btn:hover:not(.active) { background: var(--bg-2); }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.35);
  display: none; align-items: center; justify-content: center; z-index: 50;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg); border-radius: 12px; width: 480px; max-width: 95vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  border: 1px solid var(--border);
  max-height: 90vh; overflow-y: auto;
}
.modal-header {
  padding: 18px 24px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 15px; font-weight: 600; }
.modal-close { background: none; border: none; cursor: pointer;
  color: var(--text-3); font-size: 18px; line-height: 1; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px; }

.search-bar {
  display: flex; gap: 10px; align-items: center; margin-bottom: 16px;
}
.search-input { max-width: 280px; }
.filter-select { width: auto; }

.alert {
  padding: 12px 16px; border-radius: var(--radius); font-size: 13px;
  margin-bottom: 16px; border: 1px solid;
}
.alert-warning { background: #FFFBEB; border-color: #FDE68A; color: #92400E; }
.alert-danger   { background: var(--red-light); border-color: #FECACA; color: #991B1B; }
.alert-success  { background: var(--green-light); border-color: #A7F3D0; color: #065F46; }

/* form helpers */
.field { margin-bottom: 16px; }
.field label { display:block; font-size:12px; color:var(--text-2); margin-bottom:6px; font-weight:500; }
.row-between { display:flex; align-items:center; justify-content:space-between; gap:16px; padding:14px 0; border-bottom:1px solid var(--border); }
.row-between:last-child { border-bottom:none; }
.muted { color: var(--text-3); font-size: 12px; }
.pct-bar { height:6px; border-radius:3px; background:var(--bg-3); overflow:hidden; margin-top:6px; }
.pct-bar > span { display:block; height:100%; background:var(--blue); }
.mono { font-variant-numeric: tabular-nums; }
