:root {
  --ink: #111315;
  --muted: #737b84;
  --blue: #2388ff;
  --blue-soft: #eaf3ff;
  --paper: #f3f2ee;
  --line: #e3e5e7;
  --white: #fff;
  --danger: #e5484d;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); }
button, input, select { font: inherit; }
button { cursor: pointer; }
.admin-app { min-height: 100vh; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(420px, 100%); background: var(--white); border: 1px solid var(--line); border-radius: 24px; padding: 36px; box-shadow: 0 20px 70px rgba(17,19,21,.08); }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 800; letter-spacing: -.03em; }
.brand-name { white-space: nowrap; }
.brand-word { color: var(--ink); }
.brand-accent { color: var(--blue); }
.brand-mark { width: 34px; height: 34px; display: block; object-fit: cover; border-radius: 50%; }
.login-card h1 { margin: 38px 0 8px; font-size: 32px; letter-spacing: -.04em; }
.login-card p { color: var(--muted); margin: 0 0 28px; }
.field { display: grid; gap: 8px; margin: 16px 0; }
.field label { font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.field input, .search input, .select { border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px; background: #fff; color: var(--ink); outline: none; }
.field input:focus, .search input:focus, .select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(35,136,255,.14); }
.primary { border: 0; border-radius: 12px; background: var(--blue); color: #fff; padding: 13px 18px; font-weight: 750; }
.primary:hover { background: #1076eb; }
.secondary { border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); padding: 11px 15px; font-weight: 700; }
.danger { color: var(--danger); }
.error { min-height: 20px; color: var(--danger); font-size: 14px; margin-top: 14px; }
.shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--ink); color: #fff; padding: 26px 18px; display: flex; flex-direction: column; gap: 32px; }
.sidebar .brand { color: #fff; }
.sidebar .brand-word { color: #fff; }
.nav { display: grid; gap: 6px; }
.nav button { border: 0; background: transparent; color: #a9b0b8; text-align: left; padding: 12px 14px; border-radius: 10px; font-weight: 700; }
.nav button:hover { background: #20252a; color: #fff; }
.nav button.active { background: var(--blue); color: #fff; box-shadow: none; }
.nav button:focus { outline: none; }
.nav button:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.sidebar-foot { margin-top: auto; border-top: 1px solid #30353a; padding-top: 18px; display: grid; gap: 10px; }
.role { color: #8e98a1; font-size: 13px; }
.content { min-width: 0; padding: 30px clamp(20px, 4vw, 58px); }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 30px; }
.eyebrow { color: var(--blue); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.topbar h1 { margin: 6px 0 0; font-size: clamp(28px, 4vw, 46px); letter-spacing: -.05em; }
.view { display: none; }
.view.active { display: block; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 24px; }
.metric, .panel { background: rgba(255,255,255,.84); border: 1px solid var(--line); border-radius: 16px; }
.metric { padding: 20px; min-height: 124px; }
.metric-label { color: var(--muted); font-size: 13px; font-weight: 700; }
.metric-value { margin-top: 16px; font-size: 30px; letter-spacing: -.05em; font-weight: 800; }
.panel { padding: 20px; }
.panel + .panel { margin-top: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.panel h2 { font-size: 18px; margin: 0; letter-spacing: -.03em; }
.panel-note { color: var(--muted); font-size: 13px; }
.health-panel { overflow: hidden; }
.health-summary { display: inline-flex; align-items: center; border-radius: 99px; padding: 6px 10px; font-size: 12px; font-weight: 800; }
.health-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.health-check { min-width: 0; padding: 13px 14px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.62); }
.health-check-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.health-emoji { flex: 0 0 auto; font-size: 14px; line-height: 1; }
.health-check-head strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.health-status { margin-left: auto; color: var(--muted); font-size: 11px; white-space: nowrap; }
.health-detail { margin-top: 7px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.health-dot { flex: 0 0 8px; width: 8px; height: 8px; border-radius: 50%; background: #b8bec4; }
.health-up { color: #267a51; background: #eaf7ef; }
.health-dot.health-up { background: #2da66a; }
.health-degraded { color: #9b6811; background: #fff5dc; }
.health-dot.health-degraded { background: #e0a52f; }
.health-down { color: #a62f35; background: #fff0f0; }
.health-dot.health-down { background: #e5484d; }
.health-muted { color: var(--muted); background: #eef0f2; }
.health-dot.health-muted { background: #aab1b8; }
.health-updated { margin-top: 14px; }
.search { display: flex; gap: 10px; margin-bottom: 16px; }
.search input { flex: 1; min-width: 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 680px; }
th, td { text-align: left; padding: 14px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
td { font-size: 14px; }
tbody tr[data-user-id] { cursor: pointer; }
tbody tr[data-user-id]:hover { background: var(--blue-soft); }
.badge { display: inline-flex; align-items: center; border-radius: 99px; padding: 5px 9px; font-size: 12px; font-weight: 750; background: #eef0f2; color: var(--muted); }
.badge.blue { color: #0d68d4; background: var(--blue-soft); }
.badge.green { color: #267a51; background: #eaf7ef; }
.badge.red { color: #a62f35; background: #fff0f0; }
.empty { color: var(--muted); padding: 28px 0; text-align: center; }
.pagination { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 16px; color: var(--muted); font-size: 13px; }
.pagination-actions { display: flex; gap: 8px; }
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; }
.profile-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.back-button { color: var(--ink); }
.profile-detail { min-height: 520px; }
.profile-facts { margin-top: 18px; }
.subscription-sources { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }
.subscription-sources .panel-head { margin-bottom: 12px; }
.subscription-source-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.subscription-source { min-width: 0; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #fafafa; }
.subscription-source-label { color: var(--muted); font-size: 12px; font-weight: 750; }
.subscription-source strong { display: block; margin-top: 7px; font-size: 16px; }
.subscription-source span { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.subscription-source-link { display: grid; gap: 8px; margin-top: 12px; }
.subscription-source-url { display: block; color: var(--blue); font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; text-decoration: none; }
a.subscription-source-url:hover { text-decoration: underline; }
.subscription-source-copy { justify-self: start; }
.subscription-source-active { border-color: #b8dfc8; background: #f4fbf6; }
.subscription-source-error { border-color: #f1c4c6; background: #fff7f7; }
.profile-history-head { margin-top: 24px; }
.operation-note { margin: 8px 0 16px; }
.referral-metrics { margin-bottom: 24px; }
.promo-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: end; }
.promo-form .field { margin: 0; }
.promo-form .primary { min-height: 48px; }
.referral-table { min-width: 1040px; }
.referral-url { display: block; max-width: 330px; overflow: hidden; text-overflow: ellipsis; color: var(--blue); }
.table-actions { display: flex; gap: 8px; }
.compact { padding: 8px 10px; border-radius: 9px; font-size: 12px; white-space: nowrap; }
.danger-action { color: var(--danger); }
.secondary:disabled { cursor: not-allowed; opacity: .5; }
.detail h3 { margin: 0 0 8px; font-size: 24px; letter-spacing: -.04em; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.fact { padding: 13px 14px; background: #fafafa; border-radius: 11px; }
.fact small { color: var(--muted); display: block; margin-bottom: 5px; }
.fact strong { word-break: break-word; }
.chart { display: flex; align-items: end; gap: 10px; height: 160px; padding-top: 20px; }
.bar { flex: 1; min-width: 8px; background: var(--blue); border-radius: 6px 6px 2px 2px; position: relative; }
.bar span { position: absolute; bottom: -22px; width: 100%; text-align: center; font-size: 10px; color: var(--muted); }
.toast { position: fixed; right: 22px; bottom: 22px; background: var(--ink); color: #fff; padding: 13px 16px; border-radius: 12px; box-shadow: 0 12px 30px rgba(0,0,0,.18); }

@media (max-width: 920px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { padding: 14px 16px; gap: 14px; position: sticky; top: 0; z-index: 5; }
  .nav { display: flex; overflow-x: auto; gap: 4px; }
  .nav button { white-space: nowrap; }
  .sidebar-foot { display: none; }
  .content { padding: 22px 16px 34px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .health-grid { grid-template-columns: 1fr; }
  .detail { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .login-card { padding: 24px; border-radius: 18px; }
  .topbar { display: block; }
  .topbar .secondary { margin-top: 14px; }
  .metrics { gap: 9px; }
  .metric { padding: 14px; min-height: 108px; }
  .metric-value { font-size: 24px; margin-top: 12px; }
  .facts { grid-template-columns: 1fr; }
  .subscription-source-grid { grid-template-columns: 1fr; }
  .promo-form { grid-template-columns: 1fr; }
  .profile-toolbar { align-items: flex-start; flex-direction: column; }
  .table-actions { flex-direction: column; }
}
