:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #1d2433;
  --muted: #687386;
  --line: #e4e8f1;
  --purple: #321b63;
  --blue: #4f6cff;
  --yellow: #ffe100;
  --orange: #ff8700;
  --red: #f05b64;
  --green: #19b58f;
  --shadow: 0 18px 40px rgba(40, 50, 90, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.login-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 12%, rgba(255, 225, 0, 0.52), transparent 28%),
    radial-gradient(circle at 80% 8%, rgba(79, 108, 255, 0.24), transparent 28%),
    linear-gradient(135deg, #fff7bf 0%, #f4f8ff 48%, #f7edff 100%);
}

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

.login-panel {
  width: min(420px, 100%);
  padding: 36px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.login-brand {
  margin-bottom: 28px;
}

.brand-logo {
  display: block;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  object-fit: contain;
  box-shadow: 0 5px 0 #d79a00;
}

.login-brand h1,
.topbar h1,
.leaderboard-head h2 {
  margin: 0;
  color: var(--purple);
}

.login-brand p,
.topbar p,
.leaderboard-head p {
  margin: 8px 0 0;
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 16px;
}

.login-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

.login-form input,
.month-field input,
.article-field input,
.article-field select {
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 14px;
  color: var(--text);
  background: #fff;
  outline: none;
}

.login-form input:focus,
.month-field input:focus,
.article-field input:focus,
.article-field select:focus,
.article-content-editor:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(79, 108, 255, 0.12);
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 42px;
  border: 0;
  border-radius: 14px;
  padding: 0 18px;
  font-weight: 800;
}

.primary-button {
  color: #fff;
  background: var(--orange);
  box-shadow: 0 5px 0 #c65b00;
}

.secondary-button {
  color: #fff;
  background: var(--blue);
  box-shadow: 0 5px 0 #2f49d9;
}

.ghost-button {
  color: var(--purple);
  background: #eef2ff;
}

.ghost-button.danger {
  color: var(--red);
  background: #fff0f0;
}

.modal-backdrop {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(30, 24, 58, 0.48);
}

.confirm-modal {
  width: min(420px, 100%);
  padding: 26px;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(30, 24, 58, 0.28);
}

.confirm-modal h2 {
  margin: 0;
  color: var(--purple);
  font-size: 22px;
}

.confirm-modal p {
  margin: 10px 0 20px;
  color: var(--muted);
  line-height: 1.7;
}

.confirm-password-field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}

.confirm-password-field input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 14px;
  outline: none;
}

.confirm-password-field input:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 4px rgba(240, 91, 100, 0.12);
}

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

.login-button {
  width: 100%;
  margin-top: 4px;
}

.login-message {
  min-height: 22px;
  margin-top: 16px;
  color: var(--muted);
}

.login-message.error {
  color: var(--red);
}

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

.sidebar {
  position: sticky;
  top: 0;
  display: block;
  height: 100vh;
  overflow-y: auto;
  padding: 18px 12px;
  background: var(--purple);
  color: #fff;
}

.sidebar-brand {
  display: grid;
  justify-items: center;
  gap: 10px;
  margin-bottom: 24px;
  text-align: center;
}

.sidebar-brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 13px;
}

.sidebar-brand strong,
.sidebar-brand span {
  display: block;
}

.sidebar-brand strong {
  font-size: 15px;
}

.sidebar-brand span {
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.62);
  font-size: 13px;
}

.sidebar-brand > div {
  min-width: 0;
  width: 100%;
}

.login-brand .brand-logo {
  width: 58px;
  height: 58px;
  margin-bottom: 16px;
  border-radius: 16px;
  box-shadow: 0 6px 0 #d79a00;
}

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

.side-nav-item {
  height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  text-align: left;
  color: rgba(255, 255, 255, 0.7);
  background: transparent;
  font-weight: 800;
}

.side-nav-item.active {
  color: var(--purple);
  background: var(--yellow);
}

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

.page-ads-workspace {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 18px;
}

.page-ads-page-panel {
  min-width: 0;
  padding: 18px 12px;
}

.page-ads-page-list {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

.page-ads-page-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 8px;
  min-width: 0;
  border: 0;
  border-radius: 10px;
  padding: 11px 12px;
  color: var(--text);
  text-align: left;
  background: transparent;
}

.page-ads-page-item:hover,
.page-ads-page-item.active {
  color: var(--purple);
  background: #fff4b5;
}

.page-ads-page-item strong,
.page-ads-page-item small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-ads-page-item small {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 11px;
}

.page-ads-page-item em {
  align-self: center;
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  white-space: nowrap;
}

.page-ads-editor-panel {
  min-width: 0;
  padding: 22px;
}

.page-ads-editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.page-ads-editor-head h2 {
  margin: 4px 0 0;
  color: var(--purple);
}

.page-ads-editor-head p {
  margin: 8px 0 0;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

.page-ads-editor-actions {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.page-ads-editor-actions .updated-at {
  margin: 0;
  white-space: nowrap;
}

.page-ads-preview {
  display: grid;
  gap: 14px;
}

.page-ads-preview.is-busy,
.page-ads-page-list.is-busy {
  opacity: .62;
  pointer-events: none;
}

.page-ads-empty {
  padding: 56px 24px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  color: var(--muted);
  text-align: center;
  background: #fbfcff;
}

.page-ad-slot-card {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--blue);
  border-radius: 14px;
  padding: 16px;
  background: #fff;
  box-shadow: 0 6px 18px rgba(40, 50, 90, 0.06);
}

.page-ad-slot-card.disabled {
  border-left-color: var(--muted);
  opacity: .68;
}

.page-ad-slot-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.page-ad-slot-preview > div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.page-ad-slot-preview strong {
  color: var(--purple);
}

.page-ad-slot-preview small {
  color: var(--muted);
  font-size: 12px;
}

.page-ad-slot-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  color: var(--purple);
  background: var(--yellow);
  font-weight: 900;
}

.page-ad-slot-fields {
  display: grid;
  grid-template-columns: minmax(130px, .9fr) minmax(180px, 1.4fr) minmax(130px, .9fr) 90px;
  gap: 10px;
}

.page-ad-slot-fields label,
.page-ad-enabled {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.page-ad-slot-fields input,
.page-ad-slot-fields select {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0 9px;
  color: var(--text);
  background: #fff;
  outline: none;
}

.page-ad-slot-fields input:focus,
.page-ad-slot-fields select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(79, 108, 255, .12);
}

.page-ad-slot-actions {
  display: grid;
  justify-items: end;
  gap: 14px;
}

.page-ad-enabled {
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.page-ad-enabled input {
  accent-color: var(--green);
}

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

.topbar-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 12px;
}

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

.dashboard-card {
  min-height: 130px;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-content: center;
  column-gap: 14px;
  row-gap: 4px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
  color: var(--text);
  text-align: left;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(40, 50, 90, 0.08);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.dashboard-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(40, 50, 90, 0.13);
}

.dashboard-card-mark {
  grid-row: 1 / 3;
  align-self: center;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  color: var(--purple);
  background: var(--yellow);
  font-size: 20px;
  font-weight: 900;
}

.dashboard-card strong {
  align-self: end;
  color: var(--purple);
  font-size: 19px;
}

.dashboard-card small {
  align-self: start;
  color: var(--muted);
  font-size: 13px;
}

.dashboard-card-orders .dashboard-card-mark {
  color: #fff;
  background: var(--orange);
}

.dashboard-card-members .dashboard-card-mark {
  color: #fff;
  background: var(--blue);
}

.dashboard-card-articles .dashboard-card-mark {
  color: #fff;
  background: var(--green);
}

.dashboard-card-ads .dashboard-card-mark {
  color: #fff;
  background: var(--red);
}

.dashboard-card-settings .dashboard-card-mark {
  color: #fff;
  background: var(--purple);
}

.dashboard-stats-panel {
  margin-top: 18px;
}

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

.dashboard-section-head h2 {
  margin: 5px 0 0;
  color: var(--purple);
}

.order-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.order-stats-grid.is-busy {
  opacity: .62;
}

.order-stats-card {
  min-height: 232px;
  display: flex;
  flex-direction: column;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(40, 50, 90, 0.08);
}

.order-stats-card-today {
  border-top: 5px solid var(--blue);
}

.order-stats-card-week {
  border-top: 5px solid var(--green);
}

.order-stats-card-month {
  border-top: 5px solid var(--orange);
}

.order-stats-card-total {
  border-top: 5px solid var(--yellow);
  background: #fffaf0;
}

.order-stats-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.order-stats-card-head > span {
  color: var(--muted);
  font-size: 12px;
}

.order-stats-period {
  color: var(--purple);
  font-size: 20px;
}

.order-stat {
  position: relative;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.order-stat span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  flex: 1 1 100%;
}

.order-stat strong {
  color: var(--text);
  font-size: 22px;
}

.order-stat small {
  color: var(--muted);
  font-size: 12px;
  margin-top:10px;
}

.order-stat-primary {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin-top: 22px;
}

.order-stat-primary span {
  order: 1;
  margin-left: auto;
}

.order-stat-primary strong {
  order: 0;
  color: var(--purple);
  font-size: 28px;
  line-height: 1;
}

.order-stat-primary small {
  order: 2;
}

.order-stats-card-divider {
  height: 1px;
  margin: 20px 0 18px;
  background: var(--line);
}

.order-stats-secondary {
  display: flex;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: auto;
}

.order-stats-secondary .order-stat strong {
  font-size: 24px;
}






.dashboard-stats-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 12px;
  margin-bottom:30px;
}

.order-stats-loading {
  grid-column: 1 / -1;
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  color: var(--muted);
  text-align: center;
}

.settings-panel {
  max-width: 720px;
  padding: 24px;
}

.settings-head h2 {
  margin: 5px 0 0;
  color: var(--purple);
}

.settings-list {
  margin-top: 22px;
  border-top: 1px solid var(--line);
}

.settings-row {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
}

.settings-row span {
  color: var(--muted);
}

.settings-status {
  color: var(--green);
}

.settings-logout-button {
  margin-top: 22px;
}

.hidden {
  display: none !important;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 18px;
  padding: 16px;
  border-radius: 20px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(40, 50, 90, 0.08);
}

.month-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 800;
}

.content-grid {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 18px;
}

.practice-panel,
.leaderboard-panel,
.article-editor-panel {
  border-radius: 22px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(40, 50, 90, 0.08);
}

.practice-panel {
  align-self: start;
  overflow: hidden;
}

.panel-title {
  padding: 18px 18px 10px;
  color: var(--purple);
  font-weight: 900;
}

.practice-list {
  max-height: calc(100vh - 214px);
  overflow: auto;
  padding: 0 12px 14px;
}

.practice-item {
  width: 100%;
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: 70px;
  margin-top: 8px;
  border: 1px solid transparent;
  border-radius: 16px;
  padding: 10px;
  color: var(--text);
  background: #f7f9fe;
  text-align: left;
}

.practice-item.active {
  border-color: #ffd75a;
  background: #fff7cc;
}

.total-practice-item {
  background:
    radial-gradient(circle at 14% 18%, rgba(255, 255, 255, 0.42), transparent 28%),
    linear-gradient(135deg, #ff4776 0%, #ff8700 68%, #ffe100 130%);
  color: #ffffff;
}

.total-practice-item .practice-copy small {
  color: rgba(255, 255, 255, 0.84);
}

.total-practice-item.active {
  border-color: #ffe100;
  background:
    radial-gradient(circle at 14% 18%, rgba(255, 255, 255, 0.52), transparent 28%),
    linear-gradient(135deg, #ff4776 0%, #ff8700 68%, #ffe100 130%);
}

.total-practice-index {
  color: var(--purple);
  background: #d79a00;
  box-shadow: 0 4px 0 #9f6f00;
}

.article-item {
  min-height: 84px;
}

.article-thumb {
  display: block;
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
  border-radius: 14px;
  object-fit: cover;
  background: #e8eefb;
  color: var(--purple);
  font-weight: 900;
}

.article-thumb-empty {
  display: grid;
  place-items: center;
}

.article-meta-line {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
}

.article-status {
  display: inline-flex;
  align-items: center;
  height: 22px;
  border-radius: 999px;
  padding: 0 9px;
  color: var(--purple);
  background: #eef2ff;
  font-size: 12px;
  font-weight: 900;
}

.article-status.published {
  color: #ffffff;
  background: var(--green);
}

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

.practice-index {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  color: #fff;
  background: var(--blue);
  font-weight: 900;
}

.practice-index.total-practice-index {
  color: var(--purple);
  background: var(--yellow);
  box-shadow: 0 4px 0 #d79a00;
}

.practice-copy {
  min-width: 0;
}

.practice-copy strong,
.practice-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.practice-copy small {
  margin-top: 5px;
  color: var(--muted);
}

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

.leaderboard-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.article-grid {
  grid-template-columns: 340px minmax(0, 1fr);
}

.article-toolbar {
  align-items: center;
}

.tuner-ads-toolbar {
  align-items: center;
}

.toolbar-copy {
  display: grid;
  flex: 1 1 360px;
  gap: 5px;
  min-width: 260px;
}

.toolbar-copy strong {
  color: var(--purple);
  font-size: 16px;
}

.toolbar-copy span {
  color: var(--muted);
  font-size: 13px;
}

.global-ad-toggle {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  column-gap: 8px;
  row-gap: 2px;
  min-width: 176px;
  color: var(--purple);
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}

.global-ad-toggle input {
  grid-row: 1 / span 2;
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--green);
}

.global-ad-toggle small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.tuner-ads-panel {
  min-width: 0;
  overflow-x: auto;
  padding: 22px;
}

.tuner-ads-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.tuner-ads-head h2 {
  margin: 4px 0 0;
  color: var(--purple);
}

.tuner-ads-head p {
  margin: 8px 0 0;
  color: var(--muted);
}

.tuner-ads-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 44px;
  min-width: 900px;
}

.tuner-ad-column {
  position: relative;
  display: grid;
  align-content: start;
  gap: 12px;
  min-width: 0;
}

.tuner-ad-column + .tuner-ad-column::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -22px;
  width: 1px;
  background: var(--line);
  content: '';
}

.tuner-ad-unit-field {
  display: grid;
  gap: 8px;
  min-height: 76px;
  color: var(--purple);
  font-size: 14px;
  font-weight: 900;
}

.tuner-ad-unit-field input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 13px;
  color: var(--text);
  background: #ffffff;
  outline: none;
}

.tuner-ad-unit-field input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(79, 108, 255, 0.12);
}

.tuner-ad-item {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  column-gap: 12px;
  align-items: center;
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  background: #f7f9fe;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease;
}

.tuner-ad-item.enabled {
  border-color: #ffd75a;
  background: #fff7cc;
}

.tuner-ad-item input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.tuner-ad-string {
  color: var(--text);
  font-weight: 900;
}

.tuner-ad-item.green-string .tuner-ad-string {
  color: #28c700;
  font-weight: 900;
}

.tuner-ad-state {
  color: var(--muted);
  font-size: 12px;
}

.tuner-ad-switch {
  position: relative;
  grid-column: 2;
  grid-row: 1 / span 2;
  display: inline-flex;
  align-items: center;
  width: 46px;
  height: 26px;
  border-radius: 999px;
  padding: 3px;
  background: #cfd6e5;
  transition: background 0.16s ease;
}

.tuner-ad-switch span {
  display: block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 5px rgba(40, 50, 90, 0.2);
  transition: transform 0.16s ease;
}

.tuner-ad-item.enabled .tuner-ad-switch {
  background: var(--orange);
}

.tuner-ad-item.enabled .tuner-ad-switch span {
  transform: translateX(20px);
}

.tuner-ads-grid.is-busy {
  pointer-events: none;
  opacity: 0.62;
}

.members-panel {
  margin-bottom: 18px;
}

.members-head,
.members-table-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.members-head h2,
.members-table-head h2 {
  margin: 4px 0 0;
  color: var(--purple);
}

.members-head p {
  margin: 8px 0 0;
  color: var(--muted);
}

.members-table-head p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.members-table-head > div {
  min-width: 0;
}

.members-table-head > button {
  flex: 0 0 auto;
}

.member-search-input {
  width: min(430px, 100%);
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 14px;
  color: var(--text);
  background: #fff;
  outline: none;
}

.member-order-status-filter {
  width: 150px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 12px;
  color: var(--text);
  background: #fff;
  outline: none;
}

.member-order-status-filter:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(79, 108, 255, 0.12);
}

.member-search-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(79, 108, 255, 0.12);
}

.member-product-list {
  display: grid;
  gap: 14px;
}

.member-product-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #f7f9fe;
}

.member-product-fields {
  display: grid;
  grid-template-columns: 1.3fr 1.2fr .8fr .8fr .6fr .8fr;
  gap: 10px;
}

.member-product-fields label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.member-product-fields input,
.member-product-fields select {
  width: 100%;
  height: 40px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 10px;
  color: var(--text);
  background: #fff;
  outline: none;
}

.member-product-fields input:focus,
.member-product-fields select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(79, 108, 255, 0.12);
}

.member-product-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.member-product-actions strong {
  margin-right: 4px;
  color: var(--red);
}

.member-product-actions button {
  min-height: 38px;
  padding: 0 12px;
  border-radius: 10px;
}

.member-product-list.is-busy {
  pointer-events: none;
  opacity: .62;
}

.member-data-panel {
  min-width: 0;
  margin-top: 18px;
  padding: 22px;
}

.member-table-wrap {
  overflow-x: auto;
}

.member-table-wrap table {
  min-width: 560px;
}

.member-table-wrap .member-orders-table {
  min-width: 1920px;
}

.member-table-wrap .member-entitlements-table {
  min-width: 1260px;
}

.member-table-wrap .member-events-table {
  min-width: 1240px;
}

.member-user-id {
  color: var(--purple);
  font-size: 12px;
}

.member-cell-time {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.member-status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  color: var(--purple);
  background: #eef2ff;
  font-size: 12px;
  font-weight: 900;
}

.member-status.success {
  color: #176f39;
  background: #dff7e8;
}

.member-status.pending {
  color: #845700;
  background: #fff2bf;
}

.member-status.failed,
.member-status.expired {
  color: #ad2637;
  background: #ffe5e8;
}

.member-error-text {
  max-width: 320px;
  overflow: hidden;
  color: var(--red);
  text-overflow: ellipsis;
}

.member-repair-button {
  min-height: 34px;
  border-radius: 10px;
  padding: 0 12px;
  white-space: nowrap;
}

.member-status-toggle {
  position: relative;
  width: 46px;
  height: 26px;
  border: 0;
  border-radius: 999px;
  padding: 3px;
  background: #cfd6e5;
  cursor: pointer;
  transition: background 0.16s ease, opacity 0.16s ease;
}

.member-status-toggle span {
  display: block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 5px rgba(40, 50, 90, 0.2);
  transition: transform 0.16s ease;
}

.member-status-toggle.enabled {
  background: #28c700;
}

.member-status-toggle.enabled span {
  transform: translateX(20px);
}

.member-status-toggle:disabled {
  cursor: wait;
  opacity: 0.55;
}

.member-inline-input {
  width: 100%;
  min-width: 120px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0 9px;
  color: var(--text);
  background: #fff;
  outline: none;
  margin-top:15px;
}

.member-inline-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(79, 108, 255, 0.12);
}

.member-expires-input {
  min-width: 142px;
}

.member-save-button {
  min-height: 36px;
  padding: 0 12px;
  white-space: nowrap;
}

.data-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.data-pagination button {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 10px;
}

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

.article-editor-panel {
  min-width: 0;
  padding: 22px;
}

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

.article-editor-head h2 {
  margin: 4px 0 0;
  color: var(--purple);
}

.article-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.article-field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}

.article-field-wide {
  grid-column: 1 / -1;
}

.cover-preview-wrap {
  margin-top: 16px;
}

.article-cover-preview {
  display: none;
  width: 100%;
  height: 200px;
  border: 1px solid var(--line);
  border-radius: 18px;
  object-fit: cover;
  background: #f7f9fe;
}

.article-cover-preview.show {
  display: block;
}

.article-content-head {
  margin-top: 20px;
  margin-bottom: 10px;
}

.article-content-head span {
  color: var(--purple);
  font-weight: 900;
}

.article-content-head small {
  color: var(--muted);
}

.article-content-editor {
  min-height: 320px;
  max-height: 520px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  background: #fff;
  color: var(--text);
  line-height: 1.8;
  outline: none;
}

.article-content-editor:empty::before {
  color: #9ca6bb;
  content: attr(data-placeholder);
}

.article-content-editor img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 12px 0;
  border-radius: 14px;
}

.eyebrow,
.updated-at {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.updated-at {
	margin-top:16px;
	margin-right:10px;
}

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

.metric-card {
  min-height: 86px;
  border-radius: 18px;
  padding: 16px;
  background: #f7f9fe;
}

.metric-card span,
.metric-card strong {
  display: block;
}

.metric-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.metric-card strong {
  margin-top: 8px;
  color: var(--purple);
  font-size: 30px;
  line-height: 1;
}

.table-wrap {
  position: relative;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
}

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

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

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

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

.rank-badge {
  display: inline-grid;
  place-items: center;
  min-width: 42px;
  height: 28px;
  border-radius: 999px;
  color: var(--purple);
  background: var(--yellow);
  font-weight: 900;
}

.total-rank-badge {
  color: #fff;
  background: var(--orange);
}

.empty-state {
  padding: 46px;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  z-index: 30;
  top: 22px;
  left: 50%;
  transform: translate(-50%, -20px);
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 18px;
  border-radius: 999px;
  color: var(--purple);
  background: var(--yellow);
  box-shadow: var(--shadow);
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.error {
  color: #fff;
  background: var(--red);
}

.toast.warn {
  background: #ffe59b;
}

.toast.success {
  color: #fff;
  background: var(--green);
}

@media (max-width: 980px) {
  .content-grid {
    grid-template-columns: 1fr;
  }

  .page-ads-workspace {
    grid-template-columns: 1fr;
  }

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

  .page-ad-slot-card {
    grid-template-columns: 150px minmax(0, 1fr);
  }

  .page-ad-slot-actions {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: flex-end;
  }

  .page-ad-slot-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

  .practice-list {
    max-height: 300px;
  }

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

  .member-product-row {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 12px;
  }

  .sidebar-brand {
    display: none;
  }

  .side-nav {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    overflow-x: auto;
  }

  .side-nav-item {
    min-width: 70px;
    text-align: center;
  }
}

@media (max-width: 640px) {
  .main {
    padding: 18px;
  }

  .topbar,
  .leaderboard-head,
  .article-editor-head {
    display: grid;
  }

  .toolbar {
    align-items: stretch;
  }

  .toolbar > * {
    width: 100%;
  }

  .topbar-actions {
    width: 100%;
  }

  .topbar-actions > * {
    flex: 1;
  }

  .article-form-grid {
    grid-template-columns: 1fr;
  }

  .page-ads-page-list,
  .page-ad-slot-card,
  .page-ad-slot-fields {
    grid-template-columns: 1fr;
  }

  .page-ads-editor-head,
  .page-ads-editor-actions {
    display: grid;
  }

  .page-ad-slot-actions {
    grid-column: auto;
    justify-content: space-between;
  }

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

  .dashboard-section-head {
    display: grid;
  }

  .order-stats-grid {
    grid-template-columns: 1fr;
  }

  .order-stats-card {
    min-height: 210px;
  }

  .order-stats-secondary {
    gap: 24px;
  }

  .tuner-ads-head {
    display: grid;
  }

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

  .member-product-actions {
    justify-content: flex-end;
    flex-wrap: wrap;
  }

}
