/* Referral system - author: astrix. Scoped to .ref: site themes restyle bare button / img / input. */
.ref {
    --ref-bg: #161616;
    --ref-card: #1d1d1d;
    --ref-card2: #232323;
    --ref-line: #2c2c2c;
    --ref-text: #e8e8e8;
    --ref-muted: #8d8d8d;
    --ref-accent: #8b9cff;
    --ref-accent-text: #0f1330;
    --ref-gold: #f5b72c;
    --ref-green: #4ade80;
    --ref-red: #f05252;
    --ref-radius: 14px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    color: var(--ref-text);
    font-size: 14px;
    line-height: 1.45;
    min-width: 0;
}
.ref *, .ref *::before, .ref *::after { box-sizing: border-box; }
.ref svg { width: 18px !important; height: 18px !important; flex: 0 0 18px; }

.ref-card {
    background: var(--ref-card);
    border: 1px solid var(--ref-line);
    border-radius: var(--ref-radius);
    padding: 20px;
    min-width: 0;
}
.ref-grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
.ref-head {
    display: flex; align-items: center; gap: 10px;
    font-weight: 700; font-size: 15px;
    padding-bottom: 14px; margin-bottom: 14px;
    border-bottom: 1px solid var(--ref-line);
}
.ref-head .ref-count { margin-left: 4px; }
.ref-text { margin: 0; color: #c9c9c9; }
.ref-muted { color: var(--ref-muted); font-size: 13px; margin: 0 0 12px; }
.ref-note { color: var(--ref-muted); margin: 14px 0; }
.ref-gold { color: var(--ref-gold) !important; }
.ref-green { color: var(--ref-green) !important; }
.ref-c { text-align: center !important; }
.ref-r { text-align: right !important; }
.ref-empty { color: var(--ref-muted); text-align: center; }

/* ---------------------------------------------------------------- buttons / inputs */
.ref .ref-btn {
    display: inline-flex !important; align-items: center; justify-content: center; gap: 8px;
    height: 40px !important; padding: 0 16px !important; margin: 0;
    border-radius: 9px !important; border: 1px solid var(--ref-line) !important;
    background: var(--ref-card2) !important; color: var(--ref-text) !important;
    font: inherit; font-weight: 600; font-size: 13px; cursor: pointer; text-decoration: none !important;
    transition: filter .15s, background .15s; white-space: nowrap; width: auto;
}
.ref .ref-btn:hover { filter: brightness(1.15); }
.ref .ref-btn:disabled { opacity: .55; cursor: default; }
.ref .ref-btn-primary { background: var(--ref-accent) !important; border-color: var(--ref-accent) !important; color: var(--ref-accent-text) !important; }
.ref .ref-btn-ghost { background: transparent !important; }
.ref .ref-btn-wide { width: 100% !important; margin-top: 12px; }
.ref .ref-btn.is-danger, .ref .ref-icon-btn.is-danger { background: rgba(240, 82, 82, .12) !important; border-color: rgba(240, 82, 82, .25) !important; color: var(--ref-red) !important; }
.ref .ref-icon-btn {
    display: inline-flex !important; align-items: center; justify-content: center;
    width: 40px !important; height: 40px !important; padding: 0 !important; border-radius: 9px !important;
    border: 1px solid var(--ref-line) !important; cursor: pointer; flex: 0 0 40px;
}
.ref .ref-input {
    width: 100% !important; min-height: 40px; padding: 9px 12px !important; margin: 0;
    background: var(--ref-bg) !important; color: var(--ref-text) !important;
    border: 1px solid var(--ref-line) !important; border-radius: 9px !important;
    font: inherit; font-size: 13px; outline: none; box-shadow: none !important;
}
.ref .ref-input:focus { border-color: var(--ref-accent) !important; }
.ref textarea.ref-input { resize: vertical; }
.ref select.ref-input { appearance: auto; }

/* ---------------------------------------------------------------- hero */
.ref-hero { display: flex; gap: 20px; align-items: stretch; position: relative; overflow: hidden; }
.ref-hero-body { flex: 1 1 auto; min-width: 0; }
.ref-hero h1 { margin: 0 0 10px; font-size: 26px; font-weight: 900; text-transform: uppercase; letter-spacing: .5px; color: #fff; }
.ref-hero p { margin: 0 0 18px; color: #bdbdbd; max-width: 760px; }
.ref .ref-hero-img { width: 190px !important; max-width: 26%; height: auto !important; max-height: 300px; object-fit: contain; object-position: bottom; align-self: flex-end; margin: -10px 10px -20px 0; filter: drop-shadow(0 10px 24px rgba(0, 0, 0, .55)); pointer-events: none; }
.ref-code-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 4px; }
.ref-code-row .ref-input { flex: 0 1 260px; width: 260px !important; }
.ref-code-row + .ref-code-row { margin-top: 10px; }
.ref-code-chip { display: flex; flex-direction: column; justify-content: center; padding: 0 14px; height: 40px; border-radius: 9px; background: var(--ref-bg); border: 1px dashed var(--ref-accent); }
.ref-code-chip small { font-size: 10px; color: var(--ref-muted); line-height: 1; }
.ref-code-chip b { font-size: 15px; letter-spacing: 1px; color: #fff; line-height: 1.3; }
.ref-stats { display: flex; flex-wrap: wrap; gap: 0; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--ref-line); max-width: 860px; }
.ref-stats > div { padding: 0 28px; border-left: 1px solid var(--ref-line); }
.ref-stats > div:first-child { padding-left: 0; border-left: 0; }
.ref-stats small { display: block; font-size: 12px; color: var(--ref-muted); margin-bottom: 4px; }
.ref-stats b { font-size: 16px; color: #fff; }
.ref-topbar { display: flex; justify-content: flex-end; }

/* ---------------------------------------------------------------- levels */
.ref-levels { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.ref-level { position: relative; background: var(--ref-card2); border: 1px solid var(--ref-line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; justify-content: space-between; min-height: 120px; }
.ref-level.is-available { border-color: var(--ref-accent); box-shadow: 0 0 0 1px rgba(139, 156, 255, .25) inset; }
.ref-level.is-locked { opacity: .55; }
.ref-level-lock { position: absolute; top: 12px; right: 12px; color: var(--ref-muted); }
.ref-level-top { display: flex; gap: 12px; align-items: flex-start; }
.ref-level-icon { display: flex; align-items: center; justify-content: center; width: 38px; height: 38px; flex: 0 0 38px; border-radius: 9px; background: rgba(74, 222, 128, .12); color: var(--ref-green); }
.ref-level-icon.t-balance { background: rgba(245, 183, 44, .12); color: var(--ref-gold); }
.ref-level-icon.t-vip { background: rgba(139, 156, 255, .14); color: var(--ref-accent); }
.ref-level-icon.t-rcon { background: rgba(255, 255, 255, .07); color: #ddd; }
.ref-level small { display: block; font-size: 10px; color: var(--ref-muted); text-transform: uppercase; }
.ref-level b { display: block; font-size: 13px; color: #fff; margin: 2px 0 4px; padding-right: 16px; }
.ref-level em { display: block; font-style: normal; font-size: 11px; color: var(--ref-muted); }
.ref-level .ref-btn-wide { margin-top: 14px; }
.ref-received { display: flex; align-items: center; gap: 6px; margin-top: 14px; color: var(--ref-green); font-weight: 600; font-size: 13px; }
.ref-linked { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-radius: 10px; background: var(--ref-card2); border: 1px solid var(--ref-line); }
.ref-linked span { flex: 1; }
.ref-badge { font-style: normal; font-size: 11px; padding: 3px 10px; border-radius: 20px; white-space: nowrap; }
.ref-badge.is-ok { background: rgba(139, 156, 255, .14); color: var(--ref-accent); }
.ref-badge.is-wait { background: rgba(245, 183, 44, .12); color: var(--ref-gold); }
.ref-activate { margin-top: 4px; }

/* ---------------------------------------------------------------- invited / top */
.ref-count { font-style: normal; font-size: 11px; padding: 2px 9px; border-radius: 20px; background: rgba(139, 156, 255, .14); color: var(--ref-accent); }
.ref-empty-big { color: #9a9a9a; font-size: 19px; font-weight: 800; line-height: 1.4; padding: 20px 0; }
.ref-list { display: flex; flex-direction: column; gap: 8px; }
.ref-player { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; background: var(--ref-card2); color: var(--ref-text) !important; text-decoration: none !important; }
.ref .ref-player img, .ref .ref-top-player img { width: 34px !important; height: 34px !important; border-radius: 50% !important; object-fit: cover; flex: 0 0 34px; }
.ref-player div { flex: 1; min-width: 0; }
.ref-player b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ref-player small { color: var(--ref-muted); font-size: 11px; }
.ref-income { color: var(--ref-green); font-weight: 700; font-size: 13px; }
.ref-pages { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.ref .ref-pages button { width: 34px !important; height: 34px !important; padding: 0 !important; border-radius: 8px !important; border: 1px solid var(--ref-line) !important; background: var(--ref-card2) !important; color: var(--ref-text) !important; cursor: pointer; font: inherit; }
.ref .ref-pages button.active { background: var(--ref-accent) !important; color: var(--ref-accent-text) !important; border-color: var(--ref-accent) !important; }
.ref-table-wrap { overflow-x: auto; border: 1px solid var(--ref-line); border-radius: 10px; }
.ref-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ref-table th { font-weight: 500; font-size: 12px; color: var(--ref-muted); text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--ref-line); }
.ref-table td { padding: 10px 12px; border-bottom: 1px solid var(--ref-line); vertical-align: middle; }
.ref-table tr:last-child td { border-bottom: 0; }
.ref-table a { color: var(--ref-text); }
.ref-top-player { display: flex; align-items: center; gap: 10px; color: var(--ref-text) !important; text-decoration: none !important; font-weight: 600; }
.ref-place { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 7px; font-style: normal; font-weight: 700; font-size: 12px; background: var(--ref-card2); }
.ref-place.p1 { background: rgba(245, 183, 44, .18); color: var(--ref-gold); }
.ref-place.p2 { background: rgba(200, 200, 210, .16); color: #d4d4dc; }
.ref-place.p3 { background: rgba(205, 127, 50, .18); color: #e09a5b; }

/* ---------------------------------------------------------------- FAQ */
.ref-faq { display: flex; flex-direction: column; gap: 8px; }
.ref-faq details { background: var(--ref-card2); border: 1px solid var(--ref-line); border-radius: 10px; }
.ref-faq summary { cursor: pointer; padding: 13px 16px; font-weight: 600; list-style: none; }
.ref-faq summary::-webkit-details-marker { display: none; }
.ref-faq summary::after { content: '+'; float: right; color: var(--ref-muted); }
.ref-faq details[open] summary::after { content: '–'; }
.ref-faq details > div { padding: 0 16px 14px; color: #bdbdbd; }

/* ---------------------------------------------------------------- toasts / modal (outside .ref) */
.ref-toasts { position: fixed; top: 18px; right: 18px; z-index: 100000; display: flex; flex-direction: column; gap: 10px; max-width: min(380px, calc(100vw - 36px)); }
.ref-toast { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 10px; background: #222; border: 1px solid #333; color: #eee; font-size: 13px; box-shadow: 0 10px 30px rgba(0, 0, 0, .4); animation: ref-in .2s ease; transition: opacity .4s, transform .4s; }
.ref-toast svg { width: 18px; height: 18px; flex: 0 0 18px; }
.ref-toast.is-ok svg { color: #4ade80; }
.ref-toast.is-error svg { color: #f05252; }
.ref-toast.is-hide { opacity: 0; transform: translateX(20px); }
@keyframes ref-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
.ref-modal { position: fixed; inset: 0; z-index: 99999; background: rgba(0, 0, 0, .6); display: flex; align-items: center; justify-content: center; padding: 16px; }
.ref-modal[hidden] { display: none; }
.ref-modal-box { width: 100%; max-width: 460px; max-height: 90vh; display: flex; flex-direction: column; background: #1d1d1d; border: 1px solid #2c2c2c; border-radius: 14px; padding: 20px; color: #e8e8e8; font-size: 14px; }
.ref-modal-box svg { width: 18px; height: 18px; }
.ref-modal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.ref-modal-head b { flex: 1; font-size: 16px; }
.ref-modal-box .ref-muted { color: #8d8d8d; font-size: 13px; margin: 0 0 12px; }
.ref-modal-box .ref-x { background: none !important; border: 0 !important; color: #8d8d8d !important; font-size: 24px; cursor: pointer; width: auto !important; height: auto !important; padding: 0 4px !important; }
.ref-servers { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; max-height: 50vh; padding-right: 4px; }
.ref-server { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 10px; background: #232323; border: 1px solid #2c2c2c; cursor: pointer; }
.ref-server span { flex: 1; font-weight: 600; }
.ref-server em { font-style: normal; font-size: 12px; color: #f5b72c; }
.ref-server.is-disabled { opacity: .6; cursor: default; }
.ref-server input { accent-color: #8b9cff; }
.ref-modal-foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.ref-modal-box .ref-btn { display: inline-flex !important; align-items: center; gap: 8px; height: 40px !important; padding: 0 16px !important; border-radius: 9px !important; border: 1px solid #2c2c2c !important; background: #232323 !important; color: #e8e8e8 !important; font: inherit; font-weight: 600; font-size: 13px; cursor: pointer; width: auto !important; }
.ref-modal-box .ref-btn-primary { background: #8b9cff !important; border-color: #8b9cff !important; color: #0f1330 !important; }

/* ---------------------------------------------------------------- admin */
.ref-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.ref .ref-tabs button, .ref .ref-tabs-back {
    display: inline-flex !important; align-items: center; gap: 8px; height: 38px !important; padding: 0 14px !important;
    border-radius: 10px !important; border: 1px solid var(--ref-line) !important; background: var(--ref-card) !important;
    color: var(--ref-text) !important; font: inherit; font-weight: 600; font-size: 13px; cursor: pointer; text-decoration: none !important; width: auto !important;
}
.ref .ref-tabs button.active { background: #fff !important; color: #111 !important; }
.ref .ref-tabs-back { margin-left: auto; }
.ref-form h3 { font-size: 17px; margin: 18px 0 10px; color: #fff; }
.ref-form h3:first-child { margin-top: 0; }
.ref-form-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px 20px; }
.ref-form-grid.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.ref-span2 { grid-column: span 2; }
.ref-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ref-field > span:first-child { font-size: 13px; color: #d6d6d6; }
.ref-field small { font-size: 11px; color: var(--ref-muted); }
.ref-field[hidden] { display: none; }
.ref-switch { position: relative; display: inline-block; width: 44px; height: 24px; flex: 0 0 44px; }
.ref-switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.ref-switch i { position: absolute; inset: 0; border-radius: 24px; background: #3a3a3a; transition: background .15s; }
.ref-switch i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; }
.ref-switch input:checked + i { background: var(--ref-accent); }
.ref-switch input:checked + i::after { transform: translateX(20px); }
.ref-level-edit { display: flex; gap: 14px; align-items: center; background: var(--ref-card2); border: 1px solid var(--ref-line); border-radius: 12px; padding: 16px; margin-bottom: 12px; }
.ref-level-edit .ref-form-grid { flex: 1; }
.ref-faq-edit { background: var(--ref-card2); border: 1px solid var(--ref-line); border-radius: 12px; padding: 16px; margin-bottom: 12px; display: flex; flex-direction: column; gap: 12px; }
.ref-faq-edit-head { display: flex; justify-content: space-between; align-items: center; padding-bottom: 10px; border-bottom: 1px solid var(--ref-line); }
.ref-srv-row { display: flex; align-items: center; gap: 16px; padding: 14px 16px; border-radius: 12px; background: var(--ref-card2); border: 1px solid var(--ref-line); margin-bottom: 10px; }
.ref-srv-info { flex: 1; min-width: 0; }
.ref-srv-info b { display: block; text-transform: uppercase; }
.ref-srv-info small { color: var(--ref-muted); font-size: 12px; }
.ref-srv-extra { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; align-items: center; }
.ref-srv-extra label { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--ref-muted); }
.ref-srv-extra .ref-input { width: 80px !important; min-height: 30px; padding: 4px 8px !important; }
.ref-srv-extra em { font-style: normal; font-size: 11px; color: var(--ref-gold); }
.ref-srv-count { text-align: center; }
.ref-srv-count b { display: block; color: var(--ref-accent); font-size: 18px; }
.ref-srv-count small { font-size: 11px; color: var(--ref-muted); }
.ref-seg { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.ref .ref-seg button { height: 38px !important; padding: 0 16px !important; border-radius: 9px !important; border: 0 !important; background: var(--ref-card2) !important; color: var(--ref-text) !important; font: inherit; font-weight: 600; font-size: 13px; cursor: pointer; display: inline-flex !important; align-items: center; gap: 6px; width: auto !important; }
.ref .ref-seg button.active { background: var(--ref-accent) !important; color: var(--ref-accent-text) !important; }
.ref .ref-seg button.is-danger { margin-left: auto; background: rgba(240, 82, 82, .12) !important; color: var(--ref-red) !important; }
.ref-stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.ref-stat { display: flex; gap: 12px; align-items: center; padding: 16px; border-radius: 12px; background: var(--ref-card2); border: 1px solid var(--ref-line); }
.ref-stat > span { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 10px; background: rgba(139, 156, 255, .12); color: var(--ref-accent); flex: 0 0 40px; }
.ref-stat.is-gold > span { background: rgba(245, 183, 44, .16); color: var(--ref-gold); }
.ref-stat.is-gold b { color: var(--ref-gold); }
.ref-stat b { display: block; font-size: 18px; color: #fff; }
.ref-stat small { font-size: 12px; color: var(--ref-muted); }

@media (max-width: 1100px) {
    .ref-levels, .ref-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ref-form-grid.g4 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
@media (max-width: 760px) {
    .ref-grid2, .ref-form-grid, .ref-form-grid.g4, .ref-levels, .ref-stat-grid { grid-template-columns: minmax(0, 1fr); }
    .ref-span2 { grid-column: auto; }
    .ref .ref-hero-img { display: none !important; }
    .ref-stats > div { padding: 0 14px; }
    .ref-code-row .ref-input { flex: 1 1 100%; width: 100% !important; }
    .ref-level-edit, .ref-srv-row { flex-wrap: wrap; }
    .ref .ref-tabs-back { margin-left: 0; }
}
