:root {
  color-scheme: dark;
  --bg: #0d0c13;
  --sidebar: #111018;
  --surface: #17151e;
  --surface-2: #1f1c28;
  --surface-3: #272231;
  --text: #f6f2fb;
  --soft: #c2bdca;
  --muted: #7e7889;
  --acid: #c9fb63;
  --violet: #a995ff;
  --green: #70dfaa;
  --red: #ff8798;
  --amber: #ffc86b;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; background: var(--bg); }
body { margin: 0; min-width: 320px; color: var(--text); background: radial-gradient(circle at 74% -10%, rgba(147,115,255,.1), transparent 30%), var(--bg); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
button, input { color: inherit; font: inherit; }
button { cursor: pointer; }

.admin-shell { min-height: 100vh; display: grid; grid-template-columns: 240px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 28px 20px; display: flex; flex-direction: column; background: rgba(17,16,24,.96); }
.brand { display: flex; align-items: center; gap: 9px; color: var(--text); text-decoration: none; font-size: 20px; letter-spacing: -.04em; }
.brand > span { width: 32px; height: 32px; display: grid; place-items: center; color: #15131b; background: var(--acid); border-radius: 10px; font-size: 17px; transform: rotate(-4deg); }
.brand small { margin-left: auto; padding: 5px 7px; color: var(--violet); background: #29233c; border-radius: 7px; font-size: 8px; letter-spacing: .09em; }
.sidebar nav { margin-top: 54px; display: grid; gap: 8px; }
.sidebar nav button { height: 45px; padding: 0 12px; display: flex; align-items: center; gap: 12px; color: #8d8798; background: transparent; border: 0; border-radius: 13px; text-align: left; font-size: 13px; transition: .18s ease; }
.sidebar nav button span { width: 24px; color: inherit; font-size: 17px; text-align: center; }
.sidebar nav button:hover { color: var(--soft); background: #191720; }
.sidebar nav button.active { color: var(--text); background: #211d2c; }
.sidebar nav button.active span { color: var(--acid); }
.sidebar-foot { margin-top: auto; padding: 14px; display: flex; align-items: center; gap: 10px; background: #191720; border-radius: 15px; }
.sidebar-foot > i { width: 8px; height: 8px; background: var(--muted); border-radius: 50%; box-shadow: 0 0 0 5px rgba(126,120,137,.1); }
.sidebar-foot > i.online { background: var(--green); box-shadow: 0 0 0 5px rgba(112,223,170,.11); }
.sidebar-foot span { display: grid; gap: 3px; }
.sidebar-foot strong { font-size: 11px; }
.sidebar-foot small { color: var(--muted); font-size: 8px; }

main { width: min(1440px, 100%); padding: 30px clamp(24px, 4vw, 62px) 42px; }
.topbar { min-height: 92px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.topbar p, .section-heading p { margin: 0 0 7px; color: var(--violet); font-size: 9px; font-weight: 850; letter-spacing: .12em; }
.topbar h1 { margin: 0; font-size: clamp(28px, 3.4vw, 44px); letter-spacing: -.055em; }
.top-actions { display: flex; gap: 9px; }
.top-actions button { height: 40px; padding: 0 16px; color: #17141d; background: var(--acid); border: 0; border-radius: 12px; font-size: 11px; font-weight: 800; }
.top-actions button.quiet { color: var(--soft); background: var(--surface-2); }
.top-actions button:disabled { opacity: .55; cursor: wait; }

.dashboard-section { scroll-margin-top: 24px; margin-top: 42px; }
.hero-section { margin-top: 22px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.metric-grid article { min-height: 150px; padding: 21px; display: flex; flex-direction: column; background: var(--surface); border-radius: 20px; }
.metric-grid article.accent { color: #17141d; background: var(--acid); }
.metric-grid span { color: var(--muted); font-size: 11px; }
.metric-grid .accent span, .metric-grid .accent small { color: #536325; }
.metric-grid strong { margin: auto 0 3px; font-size: clamp(32px, 4vw, 52px); line-height: 1; letter-spacing: -.055em; }
.metric-grid small { color: #686273; font-size: 9px; }

.section-heading { margin-bottom: 15px; display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.section-heading h2 { margin: 0; font-size: 25px; letter-spacing: -.045em; }
.section-note { color: var(--muted); font-size: 9px; }
.status-chip { padding: 8px 11px; color: var(--muted); background: var(--surface-2); border-radius: 99px; font-size: 9px; font-weight: 800; }
.status-chip.good { color: var(--green); background: #173126; }
.status-chip.bad { color: var(--red); background: #351c25; }

.provider-card { padding: 24px; background: linear-gradient(140deg, #1d1927, #15131c); border-radius: 24px; }
.provider-main { display: flex; align-items: start; justify-content: space-between; gap: 20px; }
.provider-title { display: flex; align-items: center; gap: 13px; }
.provider-logo { width: 46px; height: 46px; display: grid; place-items: center; color: white; background: linear-gradient(145deg, #814cff, #5b27dc); border-radius: 14px; font-weight: 900; }
.provider-title div, .budget-value { display: grid; gap: 5px; }
.provider-title small, .budget-value small { color: var(--muted); font-size: 8px; letter-spacing: .1em; }
.provider-title strong { font: 600 13px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; }
.budget-value { text-align: right; }
.budget-value strong { font-size: 28px; letter-spacing: -.04em; }
.budget-value span { color: var(--muted); font-size: 8px; }
.budget-track { height: 8px; margin: 26px 0 17px; overflow: hidden; background: var(--surface-3); border-radius: 99px; }
.budget-track i { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--acid), #79dda5); border-radius: inherit; transition: width .5s ease; }
.budget-math { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; overflow: hidden; border-radius: 15px; }
.budget-math > div { min-height: 68px; padding: 13px; display: grid; gap: 8px; background: rgba(255,255,255,.035); }
.budget-math span { color: var(--muted); font-size: 8px; }
.budget-math strong { font-size: 14px; }

.search-field { width: min(340px, 44vw); height: 42px; padding: 0 13px; display: flex; align-items: center; gap: 8px; color: var(--muted); background: var(--surface); border-radius: 13px; }
.search-field input { width: 100%; padding: 0; color: var(--text); background: transparent; border: 0; outline: 0; font-size: 10px; }
.search-field input::placeholder { color: #5d5768; }
.table-card { overflow: hidden; background: var(--surface); border-radius: 20px; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 14px 16px; color: #6f697a; background: #13121a; font-size: 8px; font-weight: 800; letter-spacing: .07em; text-align: left; white-space: nowrap; }
td { padding: 16px; color: var(--soft); border-top: 1px solid #211e29; font-size: 10px; vertical-align: top; }
.user-cell { min-width: 190px; display: flex; gap: 10px; }
.user-avatar { width: 35px; height: 35px; flex: 0 0 35px; display: grid; place-items: center; color: #1a1721; background: var(--acid); border-radius: 50%; font-weight: 850; }
.user-cell div, .settings-cell { display: grid; gap: 4px; }
.user-cell strong { color: var(--text); font-size: 11px; }
.user-cell small, .settings-cell small, td small { color: var(--muted); font-size: 8px; }
.balance-number { color: var(--acid); font-size: 15px; font-weight: 850; }
.settings-cell { min-width: 280px; max-width: 430px; }
.settings-cell strong { color: var(--soft); font-weight: 650; line-height: 1.4; }
.match-counts { min-width: 116px; display: grid; gap: 5px; }
.match-counts span { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 8px; }
.match-counts b { min-width: 24px; padding: 3px 6px; color: var(--soft); background: var(--surface-3); border-radius: 7px; text-align: center; font-size: 8px; }
.tag-line { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { padding: 4px 6px; color: #b8a9f6; background: #29233c; border-radius: 6px; font-size: 7px; }
.empty-cell, .empty-state { padding: 30px; color: var(--muted); text-align: center; }

.matches-heading { align-items: flex-end; }
.owner-filter { min-width: 240px; display: grid; gap: 6px; }
.owner-filter > span { color: var(--muted); font-size: 7px; font-weight: 800; letter-spacing: .09em; }
.owner-filter select { height: 42px; padding: 0 35px 0 12px; color: var(--soft); background: var(--surface); border: 0; border-radius: 13px; outline: 0; font: 700 10px/1 Inter, -apple-system, sans-serif; }
.match-matrix { display: grid; gap: 13px; }
.match-owner { padding: 18px; background: var(--surface); border-radius: 22px; }
.match-owner-head { margin-bottom: 15px; display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.match-owner-person { display: flex; align-items: center; gap: 10px; }
.match-owner-person > span { width: 38px; height: 38px; display: grid; place-items: center; color: #17141d; background: var(--acid); border-radius: 50%; font-size: 10px; font-weight: 850; }
.match-owner-person div { display: grid; gap: 3px; }
.match-owner-person strong { font-size: 12px; }
.match-owner-person small, .match-owner-total { color: var(--muted); font-size: 8px; }
.match-owner-total b { color: var(--text); }
.role-columns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.role-column { min-width: 0; padding: 12px; background: #121118; border-radius: 16px; }
.role-column-title { margin-bottom: 10px; display: flex; align-items: center; gap: 7px; color: var(--soft); font-size: 9px; font-weight: 800; }
.role-column-title i { width: 8px; height: 8px; border-radius: 50%; }
.role-column-title b { margin-left: auto; min-width: 23px; padding: 3px 6px; background: var(--surface-3); border-radius: 7px; text-align: center; font-size: 8px; }
.role-column.investor .role-column-title i { background: var(--violet); box-shadow: 0 0 0 4px rgba(169,149,255,.1); }
.role-column.client .role-column-title i { background: var(--green); box-shadow: 0 0 0 4px rgba(112,223,170,.1); }
.role-column.partner .role-column-title i { background: var(--amber); box-shadow: 0 0 0 4px rgba(255,200,107,.1); }
.role-people { display: grid; gap: 6px; }
.role-person { min-width: 0; padding: 10px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px 8px; color: inherit; background: var(--surface-2); border-radius: 11px; text-decoration: none; }
.role-person:hover { background: var(--surface-3); }
.role-person strong { overflow: hidden; color: var(--text); font-size: 9px; white-space: nowrap; text-overflow: ellipsis; }
.role-person > span { color: var(--acid); font-size: 8px; font-weight: 850; }
.role-person small { grid-column: 1 / -1; overflow: hidden; color: var(--muted); font-size: 7px; line-height: 1.35; white-space: nowrap; text-overflow: ellipsis; }
.role-empty { padding: 13px 8px; color: #5f5968; font-size: 8px; text-align: center; }

.referral-list, .runs-list { display: grid; gap: 9px; }
.referral-row { padding: 16px 18px; display: grid; grid-template-columns: minmax(0, 1fr) 48px minmax(0, 1fr) 130px; align-items: center; gap: 14px; background: var(--surface); border-radius: 17px; }
.referral-person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.referral-person span { width: 32px; height: 32px; flex: 0 0 32px; display: grid; place-items: center; color: var(--violet); background: #29233c; border-radius: 50%; font-size: 9px; font-weight: 850; }
.referral-person div { min-width: 0; display: grid; gap: 3px; }
.referral-person strong { overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.referral-person small { color: var(--muted); font-size: 8px; }
.referral-arrow { color: var(--acid); text-align: center; font-size: 18px; }
.reward-state { justify-self: end; padding: 7px 9px; color: var(--amber); background: #332817; border-radius: 9px; font-size: 8px; }
.reward-state.done { color: var(--green); background: #173126; }

.run-card { padding: 18px; display: grid; grid-template-columns: 130px minmax(150px, .7fr) minmax(250px, 1.4fr) minmax(180px, 1fr); gap: 18px; align-items: start; background: var(--surface); border-radius: 18px; }
.run-status { display: grid; gap: 7px; }
.run-status span { width: max-content; padding: 6px 8px; color: var(--green); background: #173126; border-radius: 8px; font-size: 8px; font-weight: 800; }
.run-status span.failed { color: var(--red); background: #351c25; }
.run-status span.cached { color: var(--violet); background: #29233c; }
.run-status small, .run-block small { color: var(--muted); font-size: 8px; }
.run-block { display: grid; gap: 6px; min-width: 0; }
.run-block strong { font-size: 10px; line-height: 1.4; }
.run-block p { margin: 0; color: #918b9c; font-size: 8px; line-height: 1.45; overflow-wrap: anywhere; }
.run-block em { color: var(--acid); font-size: 16px; font-style: normal; font-weight: 850; }

footer { padding-top: 45px; color: #575260; font-size: 8px; text-align: center; }
.login-layer { position: fixed; inset: 0; z-index: 10; padding: 24px; display: grid; place-items: center; background: radial-gradient(circle at 50% 20%, rgba(143,111,255,.16), transparent 34%), rgba(8,7,11,.96); }
.login-layer.hidden { display: none; }
.login-card { width: min(390px, 100%); padding: 34px; background: #17151e; border-radius: 26px; box-shadow: 0 30px 90px rgba(0,0,0,.38); }
.login-mark { width: 48px; height: 48px; display: grid; place-items: center; color: #17141d; background: var(--acid); border-radius: 15px; font-size: 24px; transform: rotate(-4deg); }
.login-card > p { margin: 28px 0 7px; color: var(--violet); font-size: 9px; font-weight: 850; letter-spacing: .11em; }
.login-card h2 { margin: 0 0 28px; font-size: 26px; letter-spacing: -.04em; }
.login-card label { display: grid; gap: 8px; }
.login-card label span { color: var(--muted); font-size: 8px; letter-spacing: .08em; }
.login-card input { height: 48px; padding: 0 14px; background: var(--surface-2); border: 0; border-radius: 13px; outline: 0; }
.login-card input:focus { box-shadow: 0 0 0 2px rgba(169,149,255,.35); }
.login-card button { width: 100%; height: 48px; margin-top: 12px; color: #17141d; background: var(--acid); border: 0; border-radius: 13px; font-size: 11px; font-weight: 850; }
.login-card > small { display: block; margin-top: 13px; color: var(--muted); font-size: 8px; line-height: 1.45; }
.login-card > small.error { color: var(--red); }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 20; padding: 12px 16px; color: #17141d; background: var(--acid); border-radius: 12px; font-size: 10px; font-weight: 800; opacity: 0; transform: translateY(15px); pointer-events: none; transition: .22s ease; }
.toast.show { opacity: 1; transform: none; }

@media (max-width: 1050px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .run-card { grid-template-columns: 120px 1fr 1.5fr; }
  .run-card .run-block:last-child { grid-column: 2 / -1; }
}

@media (max-width: 760px) {
  .admin-shell { display: block; }
  .sidebar { position: relative; width: 100%; height: auto; padding: 16px; }
  .sidebar nav { margin-top: 18px; display: flex; overflow-x: auto; }
  .sidebar nav button { flex: 0 0 auto; }
  .sidebar-foot { display: none; }
  main { padding: 18px 16px 32px; }
  .topbar { align-items: flex-start; }
  .top-actions { flex-direction: column; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .metric-grid article { min-height: 125px; padding: 16px; }
  .provider-main { display: grid; }
  .budget-value { text-align: left; }
  .budget-math { grid-template-columns: 1fr 1fr; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .search-field { width: 100%; }
  .owner-filter { width: 100%; min-width: 0; }
  .role-columns { grid-template-columns: 1fr; }
  .referral-row { grid-template-columns: 1fr 26px 1fr; }
  .reward-state { grid-column: 1 / -1; justify-self: start; }
  .run-card { grid-template-columns: 1fr 1fr; }
  .run-card .run-block:last-child { grid-column: 1 / -1; }
}

@media (max-width: 470px) {
  .metric-grid { grid-template-columns: 1fr; }
  .topbar h1 { font-size: 29px; }
  .top-actions button { padding: 0 11px; }
  .referral-row, .run-card { grid-template-columns: 1fr; }
  .referral-arrow { transform: rotate(90deg); }
  .reward-state, .run-card .run-block:last-child { grid-column: auto; }
}
